From 38e88c44d746ae1318c904c3d4bf1e8ad4eb8ddf Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Sat, 23 Jun 2018 16:04:48 +0200 Subject: [PATCH] Added onMenuJumpEnter/Exit animation REPLACING onHighlightEnter/Exit animation for next/previous letter/page and for random selection; basically a jump within the same scrolling list menu. 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 | 53 ++++++++++------ RetroFE/Source/RetroFE.h | 2 + RetroFE/Source/Version.cpp | 2 +- 8 files changed, 122 insertions(+), 21 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 05fd1af..2dbd8ef 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -452,6 +452,24 @@ void ScrollingList::triggerPlaylistExitEvent( int menuIndex ) } } +void ScrollingList::triggerMenuJumpEnterEvent( int menuIndex ) +{ + for ( unsigned int i = 0; i < components_.size( ); ++i ) + { + Component *c = components_.at( i ); + if ( c ) c->triggerEvent( "menuJumpEnter", menuIndex ); + } +} + +void ScrollingList::triggerMenuJumpExitEvent( int menuIndex ) +{ + for ( unsigned int i = 0; i < components_.size( ); ++i ) + { + Component *c = components_.at( i ); + if ( c ) c->triggerEvent( "menuJumpExit", menuIndex ); + } +} + void ScrollingList::update( float dt ) { diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 6b0000e..da6e044 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -55,6 +55,8 @@ public: void triggerHighlightExitEvent( int menuIndex = -1 ); void triggerPlaylistEnterEvent( int menuIndex = -1 ); void triggerPlaylistExitEvent( int menuIndex = -1 ); + void triggerMenuJumpEnterEvent( int menuIndex = -1 ); + void triggerMenuJumpExitEvent( 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 0091f83..9591431 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -545,6 +545,68 @@ void Page::playlistExit() } +void Page::menuJumpEnter() +{ + 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( "menuJumpEnter", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerMenuJumpEnterEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "menuJumpEnter", menuDepth_ - 1 ); + menu->triggerMenuJumpEnterEvent( menuDepth_ - 1 ); + } + } + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "menuJumpEnter", menuDepth_ - 1 ); + } +} + + +void Page::menuJumpExit() +{ + 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( "menuJumpExit", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerMenuJumpExitEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "menuJumpExit", menuDepth_ - 1 ); + menu->triggerMenuJumpExitEvent( menuDepth_ - 1 ); + } + } + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "menuJumpExit", 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 065b8e0..0c925eb 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -100,6 +100,8 @@ public: void highlightExit(); void playlistEnter(); void playlistExit(); + void menuJumpEnter(); + void menuJumpExit(); 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 10573d7..c36d559 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -859,6 +859,8 @@ AnimationEvents *PageBuilder::createTweenInstance(xml_node<> *componentXml) buildTweenSet(tweens, componentXml, "onGameExit", "gameExit"); buildTweenSet(tweens, componentXml, "onPlaylistEnter", "playlistEnter"); buildTweenSet(tweens, componentXml, "onPlaylistExit", "playlistExit"); + buildTweenSet(tweens, componentXml, "onMenuJumpEnter", "menuJumpEnter"); + buildTweenSet(tweens, componentXml, "onMenuJumpExit", "menuJumpExit"); buildTweenSet(tweens, componentXml, "onMenuActionInputEnter", "menuActionInputEnter"); buildTweenSet(tweens, componentXml, "onMenuActionInputExit", "menuActionInputExit"); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 83b5453..4675cfc 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -494,23 +494,46 @@ void RetroFE::run( ) } break; - // Make a jump in the menu; start onHighlightExit animation + // Jump in menu; start onMenuJumpExit animation case RETROFE_MENUJUMP_REQUEST: + currentPage_->menuJumpExit( ); currentPage_->setScrolling(Page::ScrollDirectionIdle); - currentPage_->highlightExit( ); state = RETROFE_MENUJUMP_EXIT; break; - // Make a jump in the menu; wait for onHighlightExit animation to finish; load art + // Jump in menu; wait for onMenuJumpExit animation to finish; load art case RETROFE_MENUJUMP_EXIT: - if (currentPage_->isMenuIdle( ) && processUserInput( currentPage_ ) == RETROFE_MENUJUMP_REQUEST) - { - state = RETROFE_MENUJUMP_REQUEST; - } if (currentPage_->isIdle( )) { - currentPage_->highlightLoadArt( ); - state = RETROFE_HIGHLIGHT_LOAD_ART; + currentPage_->onNewItemSelected( ); + state = RETROFE_MENUJUMP_LOAD_ART; + } + break; + + // Jump in menu; start onMenuJumpEnter animation + case RETROFE_MENUJUMP_LOAD_ART: + if (currentPage_->isIdle( )) + { + currentPage_->reallocateMenuSpritePoints( ); + currentPage_->menuJumpEnter( ); + state = RETROFE_MENUJUMP_ENTER; + } + break; + + // Jump in menu; wait for onMenuJump animation to finish + case RETROFE_MENUJUMP_ENTER: + if (currentPage_->isIdle( )) + { + bool collectionInputClear = false; + config_.getProperty( "collectionInputClear", collectionInputClear ); + if ( collectionInputClear ) + { + // Empty event queue + SDL_Event e; + while ( SDL_PollEvent( &e ) ); + input_.resetStates( ); + } + state = RETROFE_IDLE; } break; @@ -996,32 +1019,24 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page ) { attract_.reset( ); page->pageScroll(Page::ScrollDirectionBack); - page->onNewItemSelected( ); - page->reallocateMenuSpritePoints( ); state = RETROFE_MENUJUMP_REQUEST; } if (input_.keystate(UserInput::KeyCodePageDown)) { attract_.reset( ); page->pageScroll(Page::ScrollDirectionForward); - page->onNewItemSelected( ); - page->reallocateMenuSpritePoints( ); state = RETROFE_MENUJUMP_REQUEST; } if (input_.keystate(UserInput::KeyCodeLetterUp)) { attract_.reset( ); page->letterScroll(Page::ScrollDirectionBack); - page->onNewItemSelected( ); - page->reallocateMenuSpritePoints( ); state = RETROFE_MENUJUMP_REQUEST; } if (input_.keystate(UserInput::KeyCodeLetterDown)) { attract_.reset( ); page->letterScroll(Page::ScrollDirectionForward); - page->onNewItemSelected( ); - page->reallocateMenuSpritePoints( ); state = RETROFE_MENUJUMP_REQUEST; } if ( input_.newKeyPressed(UserInput::KeyCodeFavPlaylist) ) @@ -1058,9 +1073,7 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page ) { attract_.reset( ); page->selectRandom( ); - page->onNewItemSelected( ); - page->reallocateMenuSpritePoints( ); - state = RETROFE_HIGHLIGHT_REQUEST; + state = RETROFE_MENUJUMP_REQUEST; } } diff --git a/RetroFE/Source/RetroFE.h b/RetroFE/Source/RetroFE.h index 189110f..800c8c7 100644 --- a/RetroFE/Source/RetroFE.h +++ b/RetroFE/Source/RetroFE.h @@ -68,6 +68,8 @@ private: RETROFE_PLAYLIST_ENTER, RETROFE_MENUJUMP_REQUEST, RETROFE_MENUJUMP_EXIT, + RETROFE_MENUJUMP_LOAD_ART, + RETROFE_MENUJUMP_ENTER, RETROFE_HIGHLIGHT_REQUEST, RETROFE_HIGHLIGHT_EXIT, RETROFE_HIGHLIGHT_LOAD_ART, diff --git a/RetroFE/Source/Version.cpp b/RetroFE/Source/Version.cpp index af0e633..4388857 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 = "16"; +std::string retrofe_version_build = "17"; std::string Version::getString( )