From 60356f0c48f12e1c148015a1b617f363de2ab501 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Wed, 17 May 2017 21:48:19 +0200 Subject: [PATCH] Added onGameEnter and onGameExit animation triggers. --- .../Graphics/Component/ScrollingList.cpp | 18 +++++++++ .../Source/Graphics/Component/ScrollingList.h | 2 + RetroFE/Source/Graphics/Page.cpp | 38 +++++++++++++++++++ RetroFE/Source/Graphics/Page.h | 2 + RetroFE/Source/Graphics/PageBuilder.cpp | 2 + RetroFE/Source/RetroFE.cpp | 28 +++++++++++--- RetroFE/Source/RetroFE.h | 2 + 7 files changed, 86 insertions(+), 6 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 681c652..47ff6f0 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -350,6 +350,24 @@ void ScrollingList::triggerMenuExitEvent( int menuIndex ) } } +void ScrollingList::triggerGameEnterEvent( int menuIndex ) +{ + for(unsigned int i = 0; i < components_.size(); ++i) + { + Component *c = components_.at(i); + if(c) c->triggerEvent( "gameEnter", menuIndex ); + } +} + +void ScrollingList::triggerGameExitEvent( int menuIndex ) +{ + for(unsigned int i = 0; i < components_.size(); ++i) + { + Component *c = components_.at(i); + if(c) c->triggerEvent( "gameExit", menuIndex ); + } +} + void ScrollingList::triggerHighlightEnterEvent( int menuIndex ) { for(unsigned int i = 0; i < components_.size(); ++i) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index a543b3d..6de2306 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -49,6 +49,8 @@ public: void triggerExitEvent(); void triggerMenuEnterEvent(int menuIndex = -1); void triggerMenuExitEvent(int menuIndex = -1); + void triggerGameEnterEvent(int menuIndex = -1); + void triggerGameExitEvent(int menuIndex = -1); void triggerHighlightEnterEvent(int menuIndex = -1); void triggerHighlightExitEvent(int menuIndex = -1); diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 1fc1229..bc79b2c 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -573,6 +573,44 @@ void Page::exitMenu() } +void Page::enterGame() +{ + + for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) + { + ScrollingList *menu = *it; + menu->triggerEvent( "gameEnter", menuDepth_ - 1 ); + menu->triggerGameEnterEvent( menuDepth_ - 1 ); + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "gameEnter", menuDepth_ - 1 ); + } + + return; +} + + +void Page::exitGame() +{ + + for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) + { + ScrollingList *menu = *it; + menu->triggerEvent( "gameExit" ); + menu->triggerGameExitEvent( menuDepth_ - 1 ); + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "gameExit", menuDepth_ - 1 ); + } + + return; +} + + std::string Page::getPlaylistName() { return playlist_->first; diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index 2b5c877..d7c9034 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -49,6 +49,8 @@ public: bool popCollection(); void enterMenu(); void exitMenu(); + void enterGame(); + void exitGame(); std::string getPlaylistName(); void favPlaylist(); void nextPlaylist(); diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 6cb6105..4811b6a 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -729,6 +729,8 @@ AnimationEvents *PageBuilder::createTweenInstance(xml_node<> *componentXml) buildTweenSet(tweens, componentXml, "onHighlightExit", "highlightExit"); buildTweenSet(tweens, componentXml, "onMenuEnter", "menuEnter"); buildTweenSet(tweens, componentXml, "onMenuExit", "menuExit"); + buildTweenSet(tweens, componentXml, "onGameEnter", "gameEnter"); + buildTweenSet(tweens, componentXml, "onGameExit", "gameExit"); return tweens; } diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 7dde45b..9dca19e 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -537,12 +537,28 @@ void RetroFE::run() } break; + case RETROFE_LAUNCH_ENTER: + currentPage_->enterGame(); + state = RETROFE_LAUNCH_REQUEST; + break; + case RETROFE_LAUNCH_REQUEST: - nextPageItem_ = currentPage_->getSelectedItem(); - launchEnter(); - l.run(nextPageItem_->collectionInfo->name, nextPageItem_); - launchExit(); - state = RETROFE_IDLE; + if(currentPage_->isIdle()) + { + nextPageItem_ = currentPage_->getSelectedItem(); + launchEnter(); + l.run(nextPageItem_->collectionInfo->name, nextPageItem_); + launchExit(); + currentPage_->exitGame(); + state = RETROFE_LAUNCH_EXIT; + } + break; + + case RETROFE_LAUNCH_EXIT: + if(currentPage_->isIdle()) + { + state = RETROFE_IDLE; + } break; case RETROFE_BACK_REQUEST: @@ -854,7 +870,7 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page) { if(nextPageItem_->leaf) { - state = RETROFE_LAUNCH_REQUEST; + state = RETROFE_LAUNCH_ENTER; } else { diff --git a/RetroFE/Source/RetroFE.h b/RetroFE/Source/RetroFE.h index b99419a..911ff0c 100644 --- a/RetroFE/Source/RetroFE.h +++ b/RetroFE/Source/RetroFE.h @@ -70,7 +70,9 @@ private: RETROFE_NEXT_PAGE_MENU_EXIT, RETROFE_NEXT_PAGE_MENU_LOAD_ART, RETROFE_NEXT_PAGE_MENU_ENTER, + RETROFE_LAUNCH_ENTER, RETROFE_LAUNCH_REQUEST, + RETROFE_LAUNCH_EXIT, RETROFE_BACK_REQUEST, RETROFE_BACK_MENU_EXIT, RETROFE_BACK_MENU_LOAD_ART,