Added letterSub option to skip to the next sub collection in stead of the next letter.

This commit is contained in:
Pieter Hulshoff 2019-04-09 23:03:24 +02:00
parent 8e9e55b47e
commit 18e268d111
8 changed files with 108 additions and 3 deletions

View File

@ -45,6 +45,7 @@ CollectionInfo::CollectionInfo(std::string name,
, metadataType(metadataType)
, menusort(true)
, subsSplit(false)
, hasSubs(false)
, metadataPath_(metadataPath)
, extensions_(extensions)
{

View File

@ -45,6 +45,7 @@ public:
bool menusort;
bool subsSplit;
bool hasSubs;
private:
std::string metadataPath_;
std::string extensions_;

View File

@ -345,6 +345,67 @@ void ScrollingList::letterChange( bool increment )
}
void ScrollingList::subUp( )
{
subChange( true );
}
void ScrollingList::subDown( )
{
subChange( false );
}
void ScrollingList::subChange( bool increment )
{
if ( !items_ || items_->size( ) == 0 ) return;
std::string startname = items_->at( (itemIndex_+selectedOffsetIndex_ ) % items_->size( ) )->collectionInfo->lowercaseName( );
for ( unsigned int i = 0; i < items_->size( ); ++i )
{
unsigned int index = 0;
if ( increment )
{
index = loopIncrement( itemIndex_, i, items_->size( ) );
}
else
{
index = loopDecrement( itemIndex_, i, items_->size( ) );
}
std::string endname = items_->at( (index+selectedOffsetIndex_ ) % items_->size( ) )->collectionInfo->lowercaseName( );
if (startname != endname)
{
itemIndex_ = index;
break;
}
}
if ( !increment ) // For decrement, find the first game of the new sub
{
startname = items_->at( (itemIndex_+selectedOffsetIndex_ ) % items_->size( ) )->collectionInfo->lowercaseName( );
for ( unsigned int i = 0; i < items_->size( ); ++i )
{
unsigned int index = loopDecrement( itemIndex_, i, items_->size( ) );
std::string endname = items_->at( (index+selectedOffsetIndex_ ) % items_->size( ) )->collectionInfo->lowercaseName( );
if (startname != endname)
{
itemIndex_ = loopIncrement( index,1,items_->size( ) );
break;
}
}
}
}
void ScrollingList::allocateGraphicsMemory( )
{
Component::allocateGraphicsMemory( );

View File

@ -71,6 +71,9 @@ public:
void letterUp( );
void letterDown( );
void letterChange( bool increment );
void subUp( );
void subDown( );
void subChange( bool increment );
void random( );
bool isIdle( );
unsigned int getScrollOffsetIndex( );

View File

@ -714,6 +714,26 @@ void Page::letterScroll(ScrollDirection direction)
}
void Page::subScroll(ScrollDirection direction)
{
for(std::vector<ScrollingList *>::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++)
{
ScrollingList *menu = *it;
if(menu)
{
if(direction == ScrollDirectionForward)
{
menu->subDown();
}
if(direction == ScrollDirectionBack)
{
menu->subUp();
}
}
}
}
unsigned int Page::getCollectionSize()
{
if(!(activeMenu_.size() > 0 && activeMenu_[0])) return 0;
@ -1336,3 +1356,9 @@ void Page::scroll(bool forward)
}
return;
}
bool Page::hasSubs()
{
return collections_.back().collection->hasSubs;
}

View File

@ -66,6 +66,7 @@ public:
bool addComponent(Component *c);
void pageScroll(ScrollDirection direction);
void letterScroll(ScrollDirection direction);
void subScroll(ScrollDirection direction);
unsigned int getCollectionSize();
unsigned int getSelectedIndex();
void selectRandom();
@ -112,6 +113,7 @@ public:
void resetScrollPeriod();
void updateScrollPeriod();
void scroll(bool forward);
bool hasSubs();
private:
void playlistChange();

View File

@ -1021,13 +1021,23 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page )
if (input_.keystate(UserInput::KeyCodeLetterUp))
{
attract_.reset( );
page->letterScroll(Page::ScrollDirectionBack);
bool letterSub;
config_.getProperty( "letterSub", letterSub );
if (letterSub && page->hasSubs())
page->subScroll(Page::ScrollDirectionBack);
else
page->letterScroll(Page::ScrollDirectionBack);
state = RETROFE_MENUJUMP_REQUEST;
}
if (input_.keystate(UserInput::KeyCodeLetterDown))
{
attract_.reset( );
page->letterScroll(Page::ScrollDirectionForward);
bool letterSub;
config_.getProperty( "letterSub", letterSub );
if (letterSub && page->hasSubs())
page->subScroll(Page::ScrollDirectionForward);
else
page->letterScroll(Page::ScrollDirectionForward);
state = RETROFE_MENUJUMP_REQUEST;
}
if ( input_.newKeyPressed(UserInput::KeyCodeFavPlaylist) )
@ -1211,6 +1221,7 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
collection->addSubcollection( subcollection );
subcollection->subsSplit = subsSplit;
cib.injectMetadata( subcollection );
collection->hasSubs = true;
}
}
}

View File

@ -21,7 +21,7 @@
std::string retrofe_version_major = "0";
std::string retrofe_version_minor = "8";
std::string retrofe_version_build = "24";
std::string retrofe_version_build = "25";
std::string Version::getString( )