From 12aadc729e22ce92db8722c202c044a4c14d17ac Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Sun, 12 Jun 2016 09:51:56 +0200 Subject: [PATCH] Added support to allow all menus to be animated in stead of just the active menu. WARNING: this will probably require menu animations to be updated with a menuIndex attribute for old themes to continue functioning correctly. --- .../Graphics/Component/ScrollingList.cpp | 18 ++++++++++ .../Source/Graphics/Component/ScrollingList.h | 2 ++ RetroFE/Source/Graphics/Page.cpp | 33 ++++++++++--------- RetroFE/Source/Graphics/Page.h | 1 - 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 43d0766..6516ee0 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -411,6 +411,24 @@ void ScrollingList::triggerMenuExitEvent( int menuIndex ) } } +void ScrollingList::triggerHighlightEnterEvent( int menuIndex ) +{ + for(unsigned int i = 0; i < components_.size(); ++i) + { + Component *c = components_.at(i); + if(c) c->triggerEvent( "highlightEnter", menuIndex ); + } +} + +void ScrollingList::triggerHighlightExitEvent( int menuIndex ) +{ + for(unsigned int i = 0; i < components_.size(); ++i) + { + Component *c = components_.at(i); + if(c) c->triggerEvent( "highlightExit", menuIndex ); + } +} + void ScrollingList::update(float dt) { Component::update(dt); diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 9059e77..7d658d5 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -56,6 +56,8 @@ public: void triggerExitEvent(); void triggerMenuEnterEvent(int menuIndex = -1); void triggerMenuExitEvent(int menuIndex = -1); + void triggerHighlightEnterEvent(int menuIndex = -1); + void triggerHighlightExitEvent(int menuIndex = -1); bool allocateTexture(unsigned int index, Item *i); void deallocateTexture(unsigned int index); diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 3a47525..da722da 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -237,12 +237,6 @@ void Page::start() loadSoundChunk_->play(); } - startComponents(); -} - - -void Page::startComponents() -{ for(unsigned int i = 0; i < NUM_LAYERS; ++i) { for(std::vector::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it) @@ -252,6 +246,7 @@ void Page::startComponents() } } + void Page::stop() { for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) @@ -346,9 +341,11 @@ void Page::highlightEnter() Item *item = selectedItem_; if(!item) return; - if(activeMenu_) + for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { - activeMenu_->triggerEvent( "highlightEnter", menuDepth_ - 1 ); + ScrollingList *menu = *it; + menu->triggerEvent( "highlightEnter", menuDepth_ - 1 ); + menu->triggerHighlightEnterEvent( menuDepth_ - 1 ); } for(unsigned int i = 0; i < NUM_LAYERS; ++i) @@ -366,9 +363,11 @@ void Page::highlightExit() Item *item = selectedItem_; if(!item) return; - if(activeMenu_) + for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { - activeMenu_->triggerEvent( "highlightExit", menuDepth_ - 1 ); + ScrollingList *menu = *it; + menu->triggerEvent( "highlightExit", menuDepth_ - 1 ); + menu->triggerHighlightExitEvent( menuDepth_ - 1 ); } for(unsigned int i = 0; i < NUM_LAYERS; ++i) @@ -542,9 +541,11 @@ bool Page::popCollection() void Page::enterMenu() { - if(activeMenu_) + for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { - activeMenu_->triggerMenuEnterEvent( menuDepth_ - 1 ); + ScrollingList *menu = *it; + menu->triggerEvent( "menuEnter", menuDepth_ - 1 ); + menu->triggerMenuEnterEvent( menuDepth_ - 1 ); } for(unsigned int i = 0; i < NUM_LAYERS; ++i) @@ -562,9 +563,11 @@ void Page::enterMenu() void Page::exitMenu() { - if(activeMenu_) + for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { - activeMenu_->triggerMenuExitEvent( menuDepth_ - 1 ); + ScrollingList *menu = *it; + menu->triggerEvent( "menuExit" ); + menu->triggerMenuExitEvent( menuDepth_ - 1 ); } for(unsigned int i = 0; i < NUM_LAYERS; ++i) @@ -602,7 +605,6 @@ void Page::nextPlaylist() } activeMenu_->setItems(playlist_->second); - activeMenu_->triggerMenuEnterEvent(); playlistChange(); } @@ -630,7 +632,6 @@ void Page::selectPlaylist(std::string playlist) playlist_ = playlist_store; activeMenu_->setItems(playlist_->second); - activeMenu_->triggerMenuEnterEvent(); playlistChange(); } diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index 94e6090..fc04820 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -64,7 +64,6 @@ public: unsigned int getSelectedIndex(); void selectRandom(); void start(); - void startComponents(); void stop(); void setScrolling(ScrollDirection direction); bool isHorizontalScroll();