diff --git a/Package/Environment/Common/controls.conf b/Package/Environment/Common/controls.conf index e2946ee..638ccb3 100644 --- a/Package/Environment/Common/controls.conf +++ b/Package/Environment/Common/controls.conf @@ -7,6 +7,7 @@ pageDown = B letterUp = N letterDown = M nextPlaylist = P +random = R select = Space back = Escape quit = Q diff --git a/RetroFE/Source/Control/UserInput.cpp b/RetroFE/Source/Control/UserInput.cpp index d57bd3b..5683b69 100644 --- a/RetroFE/Source/Control/UserInput.cpp +++ b/RetroFE/Source/Control/UserInput.cpp @@ -74,6 +74,7 @@ bool UserInput::initialize() retVal = MapKey("back", KeyCodeBack) && retVal; retVal = MapKey("quit", KeyCodeQuit) && retVal; MapKey("nextPlaylist", KeyCodeNextPlaylist); + MapKey("random", KeyCodeRandom); // these features will need to be implemented at a later time // retVal = MapKey("admin", KeyCodeAdminMode) && retVal; // retVal = MapKey("remove", KeyCodeHideItem) && retVal; diff --git a/RetroFE/Source/Control/UserInput.h b/RetroFE/Source/Control/UserInput.h index d63337e..dc7aa03 100644 --- a/RetroFE/Source/Control/UserInput.h +++ b/RetroFE/Source/Control/UserInput.h @@ -40,6 +40,7 @@ public: KeyCodeLetterDown, KeyCodeLetterUp, KeyCodeNextPlaylist, + KeyCodeRandom, KeyCodeAdminMode, KeyCodeHideItem, KeyCodeQuit, diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index d140618..cf688d9 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -292,6 +292,14 @@ void ScrollingList::pageDown() allocateSpritePoints(); } +void ScrollingList::random() +{ + if(!items_ || items_->size() == 0) return; + + deallocateSpritePoints(); + itemIndex_ = rand() % items_->size(); + allocateSpritePoints(); +} void ScrollingList::letterUp() { diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 9680317..f4f0f11 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -65,6 +65,7 @@ public: void letterUp(); void letterDown(); void letterChange(bool increment); + void random(); bool isIdle(); unsigned int getScrollOffsetIndex(); void setScrollOffsetIndex(unsigned int index); diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 5e9693e..0b54ef8 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -407,6 +407,11 @@ void Page::pageScroll(ScrollDirection direction) } } +void Page::selectRandom() +{ + if(activeMenu_) activeMenu_->random(); +} + void Page::letterScroll(ScrollDirection direction) { if(activeMenu_) diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index 69ba80a..29b62d9 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -56,6 +56,7 @@ public: bool addComponent(Component *c); void pageScroll(ScrollDirection direction); void letterScroll(ScrollDirection direction); + void selectRandom(); void start(); void startComponents(); void stop(); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index e974fe9..20ba9d6 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -448,7 +448,8 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page) !input_.keystate(UserInput::KeyCodePageDown) && !input_.keystate(UserInput::KeyCodeLetterUp) && !input_.keystate(UserInput::KeyCodeLetterDown) && - !input_.keystate(UserInput::KeyCodeNextPlaylist)) + !input_.keystate(UserInput::KeyCodeNextPlaylist) && + !input_.keystate(UserInput::KeyCodeRandom)) { keyLastTime_ = 0; keyDelayTime_= 0.3f; @@ -480,6 +481,10 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page) { page->nextPlaylist(); } + if(input_.keystate(UserInput::KeyCodeRandom)) + { + page->selectRandom(); + } } if (input_.keystate(UserInput::KeyCodeAdminMode))