From 57c465cef3d880368f54417bc97c008054c83c60 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Sat, 26 May 2018 08:18:53 +0200 Subject: [PATCH] Added onPlaylistEnter/Exit animations REPLACING the onHighlightEnter/Exit animations that used to be triggered. Layouts should be updated accordingly! --- .../Graphics/Component/ScrollingList.cpp | 18 ++++++ .../Source/Graphics/Component/ScrollingList.h | 2 + RetroFE/Source/Graphics/Page.cpp | 62 +++++++++++++++++++ RetroFE/Source/Graphics/Page.h | 2 + RetroFE/Source/Graphics/PageBuilder.cpp | 2 + RetroFE/Source/RetroFE.cpp | 4 +- 6 files changed, 88 insertions(+), 2 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 992d4d5..05fd1af 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -434,6 +434,24 @@ void ScrollingList::triggerHighlightExitEvent( int menuIndex ) } } +void ScrollingList::triggerPlaylistEnterEvent( int menuIndex ) +{ + for ( unsigned int i = 0; i < components_.size( ); ++i ) + { + Component *c = components_.at( i ); + if ( c ) c->triggerEvent( "playlistEnter", menuIndex ); + } +} + +void ScrollingList::triggerPlaylistExitEvent( int menuIndex ) +{ + for ( unsigned int i = 0; i < components_.size( ); ++i ) + { + Component *c = components_.at( i ); + if ( c ) c->triggerEvent( "playlistExit", menuIndex ); + } +} + void ScrollingList::update( float dt ) { diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index bb3aeb0..6b0000e 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -53,6 +53,8 @@ public: void triggerGameExitEvent( int menuIndex = -1 ); void triggerHighlightEnterEvent( int menuIndex = -1 ); void triggerHighlightExitEvent( int menuIndex = -1 ); + void triggerPlaylistEnterEvent( int menuIndex = -1 ); + void triggerPlaylistExitEvent( 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 7710e39..0091f83 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -483,6 +483,68 @@ void Page::highlightExit() } +void Page::playlistEnter() +{ + Item *item = selectedItem_; + + if(!item) return; + for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) + { + for(std::vector::iterator it2 = menus_[std::distance(menus_.begin(), it)].begin(); it2 != menus_[std::distance(menus_.begin(), it)].end(); it2++) + { + ScrollingList *menu = *it2; + if(menuDepth_-1 == static_cast(distance(menus_.begin(), it))) + { + // Also trigger animations for index i for active menu + menu->triggerEvent( "playlistEnter", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerPlaylistEnterEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "playlistEnter", menuDepth_ - 1 ); + menu->triggerPlaylistEnterEvent( menuDepth_ - 1 ); + } + } + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "playlistEnter", menuDepth_ - 1 ); + } +} + + +void Page::playlistExit() +{ + Item *item = selectedItem_; + + if(!item) return; + for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) + { + for(std::vector::iterator it2 = menus_[std::distance(menus_.begin(), it)].begin(); it2 != menus_[std::distance(menus_.begin(), it)].end(); it2++) + { + ScrollingList *menu = *it2; + if(menuDepth_-1 == static_cast(distance(menus_.begin(), it))) + { + // Also trigger animations for index i for active menu + menu->triggerEvent( "playlistExit", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerPlaylistExitEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "playlistExit", menuDepth_ - 1 ); + menu->triggerPlaylistExitEvent( menuDepth_ - 1 ); + } + } + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "playlistExit", menuDepth_ - 1 ); + } +} + + void Page::triggerEvent( std::string action ) { for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index 2269c87..065b8e0 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -98,6 +98,8 @@ public: void menuScroll(); void highlightEnter(); void highlightExit(); + void playlistEnter(); + void playlistExit(); void triggerEvent( std::string action ); void setText( std::string text, int id ); void addPlaylist(); diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 322eb69..10573d7 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -857,6 +857,8 @@ AnimationEvents *PageBuilder::createTweenInstance(xml_node<> *componentXml) buildTweenSet(tweens, componentXml, "onMenuExit", "menuExit"); buildTweenSet(tweens, componentXml, "onGameEnter", "gameEnter"); buildTweenSet(tweens, componentXml, "onGameExit", "gameExit"); + buildTweenSet(tweens, componentXml, "onPlaylistEnter", "playlistEnter"); + buildTweenSet(tweens, componentXml, "onPlaylistExit", "playlistExit"); buildTweenSet(tweens, componentXml, "onMenuActionInputEnter", "menuActionInputEnter"); buildTweenSet(tweens, componentXml, "onMenuActionInputExit", "menuActionInputExit"); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 31c002a..0cf965e 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -453,7 +453,7 @@ void RetroFE::run( ) // Switch playlist; start onHighlightExit animation case RETROFE_PLAYLIST_REQUEST: - currentPage_->highlightExit( ); + currentPage_->playlistExit( ); currentPage_->setScrolling(Page::ScrollDirectionIdle); state = RETROFE_PLAYLIST_EXIT; break; @@ -473,7 +473,7 @@ void RetroFE::run( ) { currentPage_->onNewItemSelected( ); currentPage_->reallocateMenuSpritePoints( ); - currentPage_->highlightEnter( ); + currentPage_->playlistEnter( ); state = RETROFE_PLAYLIST_ENTER; } break;