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) , metadataType(metadataType)
, menusort(true) , menusort(true)
, subsSplit(false) , subsSplit(false)
, hasSubs(false)
, metadataPath_(metadataPath) , metadataPath_(metadataPath)
, extensions_(extensions) , extensions_(extensions)
{ {

View File

@@ -45,6 +45,7 @@ public:
bool menusort; bool menusort;
bool subsSplit; bool subsSplit;
bool hasSubs;
private: private:
std::string metadataPath_; std::string metadataPath_;
std::string extensions_; 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( ) void ScrollingList::allocateGraphicsMemory( )
{ {
Component::allocateGraphicsMemory( ); Component::allocateGraphicsMemory( );

View File

@@ -71,6 +71,9 @@ public:
void letterUp( ); void letterUp( );
void letterDown( ); void letterDown( );
void letterChange( bool increment ); void letterChange( bool increment );
void subUp( );
void subDown( );
void subChange( bool increment );
void random( ); void random( );
bool isIdle( ); bool isIdle( );
unsigned int getScrollOffsetIndex( ); 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() unsigned int Page::getCollectionSize()
{ {
if(!(activeMenu_.size() > 0 && activeMenu_[0])) return 0; if(!(activeMenu_.size() > 0 && activeMenu_[0])) return 0;
@@ -1336,3 +1356,9 @@ void Page::scroll(bool forward)
} }
return; return;
} }
bool Page::hasSubs()
{
return collections_.back().collection->hasSubs;
}

View File

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

View File

@@ -1021,13 +1021,23 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page )
if (input_.keystate(UserInput::KeyCodeLetterUp)) if (input_.keystate(UserInput::KeyCodeLetterUp))
{ {
attract_.reset( ); 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; state = RETROFE_MENUJUMP_REQUEST;
} }
if (input_.keystate(UserInput::KeyCodeLetterDown)) if (input_.keystate(UserInput::KeyCodeLetterDown))
{ {
attract_.reset( ); 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; state = RETROFE_MENUJUMP_REQUEST;
} }
if ( input_.newKeyPressed(UserInput::KeyCodeFavPlaylist) ) if ( input_.newKeyPressed(UserInput::KeyCodeFavPlaylist) )
@@ -1211,6 +1221,7 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
collection->addSubcollection( subcollection ); collection->addSubcollection( subcollection );
subcollection->subsSplit = subsSplit; subcollection->subsSplit = subsSplit;
cib.injectMetadata( subcollection ); cib.injectMetadata( subcollection );
collection->hasSubs = true;
} }
} }
} }

View File

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