From 18e268d111628ebee848b3aabe56253ac8e439e6 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Tue, 9 Apr 2019 23:03:24 +0200 Subject: [PATCH] Added letterSub option to skip to the next sub collection in stead of the next letter. --- RetroFE/Source/Collection/CollectionInfo.cpp | 1 + RetroFE/Source/Collection/CollectionInfo.h | 1 + .../Graphics/Component/ScrollingList.cpp | 61 +++++++++++++++++++ .../Source/Graphics/Component/ScrollingList.h | 3 + RetroFE/Source/Graphics/Page.cpp | 26 ++++++++ RetroFE/Source/Graphics/Page.h | 2 + RetroFE/Source/RetroFE.cpp | 15 ++++- RetroFE/Source/Version.cpp | 2 +- 8 files changed, 108 insertions(+), 3 deletions(-) diff --git a/RetroFE/Source/Collection/CollectionInfo.cpp b/RetroFE/Source/Collection/CollectionInfo.cpp index dc0e034..45cb16c 100644 --- a/RetroFE/Source/Collection/CollectionInfo.cpp +++ b/RetroFE/Source/Collection/CollectionInfo.cpp @@ -45,6 +45,7 @@ CollectionInfo::CollectionInfo(std::string name, , metadataType(metadataType) , menusort(true) , subsSplit(false) + , hasSubs(false) , metadataPath_(metadataPath) , extensions_(extensions) { diff --git a/RetroFE/Source/Collection/CollectionInfo.h b/RetroFE/Source/Collection/CollectionInfo.h index 4620e73..f16f849 100644 --- a/RetroFE/Source/Collection/CollectionInfo.h +++ b/RetroFE/Source/Collection/CollectionInfo.h @@ -45,6 +45,7 @@ public: bool menusort; bool subsSplit; + bool hasSubs; private: std::string metadataPath_; std::string extensions_; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 812bc7c..40ea538 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -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( ); diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index da6e044..f86b75e 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -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( ); diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 9591431..082d231 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -714,6 +714,26 @@ void Page::letterScroll(ScrollDirection direction) } +void Page::subScroll(ScrollDirection direction) +{ + for(std::vector::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; +} diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index 0c925eb..c908954 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -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(); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index b726fed..6756d1c 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -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; } } } diff --git a/RetroFE/Source/Version.cpp b/RetroFE/Source/Version.cpp index 93f2ebf..3d2e242 100644 --- a/RetroFE/Source/Version.cpp +++ b/RetroFE/Source/Version.cpp @@ -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( )