Added support for onAttractEnter/onAttract/onAttractExit animation types.

This commit is contained in:
Pieter Hulshoff 2019-10-13 21:49:09 +02:00
parent 6c9abdd626
commit 193e027046
10 changed files with 198 additions and 2 deletions

View File

@ -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");
}

View File

@ -38,6 +38,7 @@ public:
void setNewItemSelected();
void setNewScrollItemSelected();
bool isIdle();
bool isAttractIdle();
bool isMenuScrolling();
bool newItemSelected;
bool newScrollItemSelected;

View File

@ -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_;

View File

@ -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 );

View File

@ -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<ScrollingList *>::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<Component *>::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<ScrollingList *>::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<unsigned int>(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<Component *>::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<ScrollingList *>::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<unsigned int>(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<Component *>::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<ScrollingList *>::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<unsigned int>(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<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
{
(*it)->triggerEvent( "attractExit", menuDepth_ - 1 );
}
}
void Page::triggerEvent( std::string action )
{
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)

View File

@ -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();

View File

@ -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");

View File

@ -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_ )
{

View File

@ -129,6 +129,7 @@ private:
FontCache fontcache_;
AttractMode attract_;
bool menuMode_;
bool attractMode_;
std::map<std::string, unsigned int> lastMenuOffsets_;
std::map<std::string, std::string> lastMenuPlaylists_;

View File

@ -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( )