diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index 28865c6..3f35a7b 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -131,6 +131,11 @@ void Component::setId( int id ) } bool Component::isIdle() +{ + return (currentTweenComplete_ || animationType_ == "idle" || animationType_ == "menuIdle" || animationType_ == "attract"); +} + +bool Component::isAttractIdle() { return (currentTweenComplete_ || animationType_ == "idle" || animationType_ == "menuIdle"); } diff --git a/RetroFE/Source/Graphics/Component/Component.h b/RetroFE/Source/Graphics/Component/Component.h index ab0fd7a..a7a019e 100644 --- a/RetroFE/Source/Graphics/Component/Component.h +++ b/RetroFE/Source/Graphics/Component/Component.h @@ -38,6 +38,7 @@ public: void setNewItemSelected(); void setNewScrollItemSelected(); bool isIdle(); + bool isAttractIdle(); bool isMenuScrolling(); bool newItemSelected; bool newScrollItemSelected; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 2567135..20b852b 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -589,6 +589,33 @@ void ScrollingList::triggerMenuJumpExitEvent( int menuIndex ) } } +void ScrollingList::triggerAttractEnterEvent( int menuIndex ) +{ + for ( unsigned int i = 0; i < components_.size( ); ++i ) + { + Component *c = components_.at( i ); + if ( c ) c->triggerEvent( "attractEnter", menuIndex ); + } +} + +void ScrollingList::triggerAttractEvent( int menuIndex ) +{ + for ( unsigned int i = 0; i < components_.size( ); ++i ) + { + Component *c = components_.at( i ); + if ( c ) c->triggerEvent( "attract", menuIndex ); + } +} + +void ScrollingList::triggerAttractExitEvent( int menuIndex ) +{ + for ( unsigned int i = 0; i < components_.size( ); ++i ) + { + Component *c = components_.at( i ); + if ( c ) c->triggerEvent( "attractExit", menuIndex ); + } +} + void ScrollingList::update( float dt ) { @@ -854,6 +881,20 @@ bool ScrollingList::isIdle( ) } +bool ScrollingList::isAttractIdle( ) +{ + if ( !Component::isAttractIdle( ) ) return false; + + for ( unsigned int i = 0; i < components_.size( ); ++i ) + { + Component *c = components_.at( i ); + if ( c && !c->isAttractIdle( ) ) return false; + } + + return true; +} + + void ScrollingList::resetScrollPeriod( ) { scrollPeriod_ = startScrollTime_; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 4bb9443..98f0002 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -57,6 +57,9 @@ public: void triggerPlaylistExitEvent( int menuIndex = -1 ); void triggerMenuJumpEnterEvent( int menuIndex = -1 ); void triggerMenuJumpExitEvent( int menuIndex = -1 ); + void triggerAttractEnterEvent( int menuIndex = -1 ); + void triggerAttractEvent( int menuIndex = -1 ); + void triggerAttractExitEvent( int menuIndex = -1 ); bool allocateTexture( unsigned int index, Item *i ); void deallocateTexture( unsigned int index ); @@ -78,6 +81,7 @@ public: void cfwLetterSubDown( ); void random( ); bool isIdle( ); + bool isAttractIdle( ); unsigned int getScrollOffsetIndex( ); void setScrollOffsetIndex( unsigned int index ); void setSelectedIndex( int selectedIndex ); diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 7f0423f..b132601 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -275,6 +275,33 @@ bool Page::isIdle() } +bool Page::isAttractIdle() +{ + bool idle = true; + + 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(!menu->isAttractIdle()) + { + idle = false; + break; + } + } + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end() && idle; ++it) + { + idle = (*it)->isAttractIdle(); + } + + return idle; +} + + bool Page::isGraphicsIdle() { bool idle = true; @@ -607,6 +634,99 @@ void Page::menuJumpExit() } +void Page::attractEnter() +{ + 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( "attractEnter", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerAttractEnterEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "attractEnter", menuDepth_ - 1 ); + menu->triggerAttractEnterEvent( menuDepth_ - 1 ); + } + } + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "attractEnter", menuDepth_ - 1 ); + } +} + + +void Page::attract() +{ + 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( "attract", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerAttractEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "attract", menuDepth_ - 1 ); + menu->triggerAttractEvent( menuDepth_ - 1 ); + } + } + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "attract", menuDepth_ - 1 ); + } +} + + +void Page::attractExit() +{ + 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( "attractExit", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerAttractExitEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "attractExit", menuDepth_ - 1 ); + menu->triggerAttractExitEvent( menuDepth_ - 1 ); + } + } + } + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "attractExit", 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 dbf8e11..8be8747 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -83,6 +83,7 @@ public: void setScrollOffsetIndex(unsigned int i); unsigned int getScrollOffsetIndex(); bool isIdle(); + bool isAttractIdle(); bool isGraphicsIdle(); bool isMenuIdle(); void setStatusTextComponent(Text *t); @@ -106,6 +107,9 @@ public: void playlistExit(); void menuJumpEnter(); void menuJumpExit(); + void attractEnter( ); + void attract( ); + void attractExit( ); 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 34a6741..b957bac 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -868,6 +868,9 @@ AnimationEvents *PageBuilder::createTweenInstance(xml_node<> *componentXml) buildTweenSet(tweens, componentXml, "onPlaylistExit", "playlistExit"); buildTweenSet(tweens, componentXml, "onMenuJumpEnter", "menuJumpEnter"); buildTweenSet(tweens, componentXml, "onMenuJumpExit", "menuJumpExit"); + buildTweenSet(tweens, componentXml, "onAttractEnter", "attractEnter"); + buildTweenSet(tweens, componentXml, "onAttract", "attract"); + buildTweenSet(tweens, componentXml, "onAttractExit", "attractExit"); buildTweenSet(tweens, componentXml, "onMenuActionInputEnter", "menuActionInputEnter"); buildTweenSet(tweens, componentXml, "onMenuActionInputExit", "menuActionInputExit"); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index dc2637a..2cddbaa 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -70,7 +70,8 @@ RetroFE::RetroFE( Configuration &c ) , keyLastTime_(0) , keyDelayTime_(.3f) { - menuMode_ = false; + menuMode_ = false; + attractMode_ = false; } @@ -1136,6 +1137,22 @@ void RetroFE::run( ) currentPage_->nextPlaylist( ); state = RETROFE_PLAYLIST_REQUEST; } + if ( currentPage_->isAttractIdle( ) ) + { + if ( !attractMode_ && attract_.isSet( ) ) + { + currentPage_->attractEnter( ); + } + else if ( attractMode_ && !attract_.isSet( ) ) + { + currentPage_->attractExit( ); + } + else if ( attract_.isSet( ) ) + { + currentPage_->attract( ); + } + attractMode_ = attract_.isSet( ); + } } if ( menuMode_ ) { diff --git a/RetroFE/Source/RetroFE.h b/RetroFE/Source/RetroFE.h index ce573d8..b214df8 100644 --- a/RetroFE/Source/RetroFE.h +++ b/RetroFE/Source/RetroFE.h @@ -129,6 +129,7 @@ private: FontCache fontcache_; AttractMode attract_; bool menuMode_; + bool attractMode_; std::map lastMenuOffsets_; std::map lastMenuPlaylists_; diff --git a/RetroFE/Source/Version.cpp b/RetroFE/Source/Version.cpp index 065aa23..6d16cc9 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 = "9"; -std::string retrofe_version_build = "6"; +std::string retrofe_version_build = "7"; std::string Version::getString( )