Added support to allow all menus to be animated in stead of just the active

menu.  WARNING: this will probably require menu animations to be updated
with a menuIndex attribute for old themes to continue functioning correctly.
This commit is contained in:
Pieter Hulshoff 2016-06-12 09:51:56 +02:00
parent b127b12b4e
commit 12aadc729e
4 changed files with 37 additions and 17 deletions

View File

@ -411,6 +411,24 @@ void ScrollingList::triggerMenuExitEvent( int menuIndex )
}
}
void ScrollingList::triggerHighlightEnterEvent( int menuIndex )
{
for(unsigned int i = 0; i < components_.size(); ++i)
{
Component *c = components_.at(i);
if(c) c->triggerEvent( "highlightEnter", menuIndex );
}
}
void ScrollingList::triggerHighlightExitEvent( int menuIndex )
{
for(unsigned int i = 0; i < components_.size(); ++i)
{
Component *c = components_.at(i);
if(c) c->triggerEvent( "highlightExit", menuIndex );
}
}
void ScrollingList::update(float dt)
{
Component::update(dt);

View File

@ -56,6 +56,8 @@ public:
void triggerExitEvent();
void triggerMenuEnterEvent(int menuIndex = -1);
void triggerMenuExitEvent(int menuIndex = -1);
void triggerHighlightEnterEvent(int menuIndex = -1);
void triggerHighlightExitEvent(int menuIndex = -1);
bool allocateTexture(unsigned int index, Item *i);
void deallocateTexture(unsigned int index);

View File

@ -237,12 +237,6 @@ void Page::start()
loadSoundChunk_->play();
}
startComponents();
}
void Page::startComponents()
{
for(unsigned int i = 0; i < NUM_LAYERS; ++i)
{
for(std::vector<Component *>::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it)
@ -252,6 +246,7 @@ void Page::startComponents()
}
}
void Page::stop()
{
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
@ -346,9 +341,11 @@ void Page::highlightEnter()
Item *item = selectedItem_;
if(!item) return;
if(activeMenu_)
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
{
activeMenu_->triggerEvent( "highlightEnter", menuDepth_ - 1 );
ScrollingList *menu = *it;
menu->triggerEvent( "highlightEnter", menuDepth_ - 1 );
menu->triggerHighlightEnterEvent( menuDepth_ - 1 );
}
for(unsigned int i = 0; i < NUM_LAYERS; ++i)
@ -366,9 +363,11 @@ void Page::highlightExit()
Item *item = selectedItem_;
if(!item) return;
if(activeMenu_)
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
{
activeMenu_->triggerEvent( "highlightExit", menuDepth_ - 1 );
ScrollingList *menu = *it;
menu->triggerEvent( "highlightExit", menuDepth_ - 1 );
menu->triggerHighlightExitEvent( menuDepth_ - 1 );
}
for(unsigned int i = 0; i < NUM_LAYERS; ++i)
@ -542,9 +541,11 @@ bool Page::popCollection()
void Page::enterMenu()
{
if(activeMenu_)
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
{
activeMenu_->triggerMenuEnterEvent( menuDepth_ - 1 );
ScrollingList *menu = *it;
menu->triggerEvent( "menuEnter", menuDepth_ - 1 );
menu->triggerMenuEnterEvent( menuDepth_ - 1 );
}
for(unsigned int i = 0; i < NUM_LAYERS; ++i)
@ -562,9 +563,11 @@ void Page::enterMenu()
void Page::exitMenu()
{
if(activeMenu_)
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
{
activeMenu_->triggerMenuExitEvent( menuDepth_ - 1 );
ScrollingList *menu = *it;
menu->triggerEvent( "menuExit" );
menu->triggerMenuExitEvent( menuDepth_ - 1 );
}
for(unsigned int i = 0; i < NUM_LAYERS; ++i)
@ -602,7 +605,6 @@ void Page::nextPlaylist()
}
activeMenu_->setItems(playlist_->second);
activeMenu_->triggerMenuEnterEvent();
playlistChange();
}
@ -630,7 +632,6 @@ void Page::selectPlaylist(std::string playlist)
playlist_ = playlist_store;
activeMenu_->setItems(playlist_->second);
activeMenu_->triggerMenuEnterEvent();
playlistChange();
}

View File

@ -64,7 +64,6 @@ public:
unsigned int getSelectedIndex();
void selectRandom();
void start();
void startComponents();
void stop();
void setScrolling(ScrollDirection direction);
bool isHorizontalScroll();