diff --git a/RetroFE/Source/Graphics/Animate/AnimationEvents.cpp b/RetroFE/Source/Graphics/Animate/AnimationEvents.cpp index 5719b12..f7c8732 100644 --- a/RetroFE/Source/Graphics/Animate/AnimationEvents.cpp +++ b/RetroFE/Source/Graphics/Animate/AnimationEvents.cpp @@ -23,73 +23,69 @@ AnimationEvents::AnimationEvents() { } -AnimationEvents::AnimationEvents(AnimationEvents ©) -{ - for(std::map >::iterator it = copy.animationMap_.begin(); it != copy.animationMap_.end(); it++) - { - for(std::map::iterator it2 = (it->second).begin(); it2 != (it->second).end(); it2++) - { - Animation *t = new Animation(*it2->second); - animationMap_[it->first][it2->first] = t; - } - } -} - -AnimationEvents::~AnimationEvents() -{ - clear(); -} - -Animation *AnimationEvents::getAnimation(std::string tween) -{ - return getAnimation(tween, -1); -} - -Animation *AnimationEvents::getAnimation(std::string tween, int index) -{ - if(animationMap_.find(tween) == animationMap_.end()) - { - animationMap_[tween][-1] = new Animation(); - } - - if(animationMap_[tween].find(index) == animationMap_[tween].end()) - { - index = -1; - - if(animationMap_[tween].find(index) == animationMap_[tween].end()) - { - animationMap_[tween][index] = new Animation(); - } - } - - return animationMap_[tween][index]; -} - -void AnimationEvents::setAnimation(std::string tween, int index, Animation *animation) -{ - animationMap_[tween][index] = animation; -} - -void AnimationEvents::clear() -{ - std::map >::iterator it = animationMap_.begin(); - while(it != animationMap_.end()) - { - std::map::iterator it2 = (it->second).begin(); - while(it2 != (it->second).end()) - { - delete it2->second; - (it->second).erase(it2); - } - - (it->second).clear(); - animationMap_.erase(it); - it = animationMap_.begin(); - } - - animationMap_.clear(); -} +AnimationEvents::AnimationEvents(AnimationEvents ©) +{ + for(std::map >::iterator it = copy.animationMap_.begin(); it != copy.animationMap_.end(); it++) + { + for(std::map::iterator it2 = (it->second).begin(); it2 != (it->second).end(); it2++) + { + Animation *t = new Animation(*it2->second); + animationMap_[it->first][it2->first] = t; + } + } +} +AnimationEvents::~AnimationEvents() +{ + clear(); +} +Animation *AnimationEvents::getAnimation(std::string tween) +{ + return getAnimation(tween, -1); +} +Animation *AnimationEvents::getAnimation(std::string tween, int index) +{ + if(animationMap_.find(tween) == animationMap_.end()) + { + animationMap_[tween][-1] = new Animation(); + } + if(animationMap_[tween].find(index) == animationMap_[tween].end()) + { + index = -1; + + if(animationMap_[tween].find(index) == animationMap_[tween].end()) + { + animationMap_[tween][index] = new Animation(); + } + } + + return animationMap_[tween][index]; +} + +void AnimationEvents::setAnimation(std::string tween, int index, Animation *animation) +{ + animationMap_[tween][index] = animation; +} + +void AnimationEvents::clear() +{ + std::map >::iterator it = animationMap_.begin(); + while(it != animationMap_.end()) + { + std::map::iterator it2 = (it->second).begin(); + while(it2 != (it->second).end()) + { + delete it2->second; + (it->second).erase(it2); + } + + (it->second).clear(); + animationMap_.erase(it); + it = animationMap_.begin(); + } + + animationMap_.clear(); +} diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index e196c82..45373f7 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -18,6 +18,7 @@ #include "../../Graphics/ViewInfo.h" #include "../../Utility/Log.h" #include "../../SDL.h" +#include "../PageBuilder.h" Component::Component(Page &p) : page(p) @@ -127,7 +128,23 @@ void Component::update(float dt) if(animationRequested_ && animationRequestedType_ != "") { - Animation *newTweens = tweens_->getAnimation( animationRequestedType_, menuIndex_ ); + Animation *newTweens; + // Check if this component is part of an active scrolling list + if(menuIndex_ >= MENU_INDEX_HIGH) + { + // Check for animation at index i + newTweens = tweens_->getAnimation( animationRequestedType_, MENU_INDEX_HIGH ); + if(!(newTweens && newTweens->size() > 0)) + { + // Check for animation at the current menuIndex + newTweens = tweens_->getAnimation( animationRequestedType_, menuIndex_ - MENU_INDEX_HIGH); + } + } + else + { + // Check for animation at the current menuIndex + newTweens = tweens_->getAnimation( animationRequestedType_, menuIndex_ ); + } if (newTweens && newTweens->size() > 0) { animationType_ = animationRequestedType_; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 47ff6f0..59cb3c9 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -72,6 +72,7 @@ ScrollingList::ScrollingList(Configuration &c, ScrollingList::ScrollingList(const ScrollingList ©) : Component(copy) , horizontalScroll(copy.horizontalScroll) + , layoutMode_(copy.layoutMode_) , spriteList_(NULL) , itemIndex_(0) , componentIndex_(0) diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index bc79b2c..e544f72 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -23,6 +23,7 @@ #include "Component/ScrollingList.h" #include "../Sound/Sound.h" #include "ComponentItemBindingBuilder.h" +#include "PageBuilder.h" #include #include @@ -358,8 +359,17 @@ void Page::highlightEnter() for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { ScrollingList *menu = *it; - menu->triggerEvent( "highlightEnter", menuDepth_ - 1 ); - menu->triggerHighlightEnterEvent( menuDepth_ - 1 ); + if(menus_[menuDepth_-1] == menu) + { + // Also trigger animations for index i for active menu + menu->triggerEvent( "highlightEnter", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerHighlightEnterEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "highlightEnter", menuDepth_ - 1 ); + menu->triggerHighlightEnterEvent( menuDepth_ - 1 ); + } } for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) @@ -377,8 +387,17 @@ void Page::highlightExit() for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { ScrollingList *menu = *it; - menu->triggerEvent( "highlightExit", menuDepth_ - 1 ); - menu->triggerHighlightExitEvent( menuDepth_ - 1 ); + if(menus_[menuDepth_-1] == menu) + { + // Also trigger animations for index i for active menu + menu->triggerEvent( "highlightExit", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerHighlightExitEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "highlightExit", menuDepth_ - 1 ); + menu->triggerHighlightExitEvent( menuDepth_ - 1 ); + } } for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) @@ -471,7 +490,7 @@ bool Page::pushCollection(CollectionInfo *collection) { // grow the menu as needed - if(menus_.size() >= menuDepth_ && activeMenu_) + if(menus_.size() <= menuDepth_ && activeMenu_) { activeMenu_ = new ScrollingList(*activeMenu_); pushMenu(activeMenu_); @@ -541,8 +560,17 @@ void Page::enterMenu() for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { ScrollingList *menu = *it; - menu->triggerEvent( "menuEnter", menuDepth_ - 1 ); - menu->triggerMenuEnterEvent( menuDepth_ - 1 ); + if(menus_[menuDepth_-1] == menu) + { + // Also trigger animations for index i for active menu + menu->triggerEvent( "menuEnter", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerMenuEnterEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "menuEnter", menuDepth_ - 1 ); + menu->triggerMenuEnterEvent( menuDepth_ - 1 ); + } } for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) @@ -560,8 +588,17 @@ void Page::exitMenu() for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { ScrollingList *menu = *it; - menu->triggerEvent( "menuExit" ); - menu->triggerMenuExitEvent( menuDepth_ - 1 ); + if(menus_[menuDepth_-1] == menu) + { + // Also trigger animations for index i for active menu + menu->triggerEvent( "menuExit", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerMenuExitEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "menuExit", menuDepth_ - 1 ); + menu->triggerMenuExitEvent( menuDepth_ - 1 ); + } } for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) @@ -579,8 +616,17 @@ void Page::enterGame() for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { ScrollingList *menu = *it; - menu->triggerEvent( "gameEnter", menuDepth_ - 1 ); - menu->triggerGameEnterEvent( menuDepth_ - 1 ); + if(menus_[menuDepth_-1] == menu) + { + // Also trigger animations for index i for active menu + menu->triggerEvent( "gameEnter", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerGameEnterEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "gameEnter", menuDepth_ - 1 ); + menu->triggerGameEnterEvent( menuDepth_ - 1 ); + } } for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) @@ -598,8 +644,17 @@ void Page::exitGame() for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++) { ScrollingList *menu = *it; - menu->triggerEvent( "gameExit" ); - menu->triggerGameExitEvent( menuDepth_ - 1 ); + if(menus_[menuDepth_-1] == menu) + { + // Also trigger animations for index i for active menu + menu->triggerEvent( "gameExit", MENU_INDEX_HIGH + menuDepth_ - 1 ); + menu->triggerGameExitEvent( MENU_INDEX_HIGH + menuDepth_ - 1 ); + } + else + { + menu->triggerEvent( "gameExit", menuDepth_ - 1 ); + menu->triggerGameExitEvent( menuDepth_ - 1 ); + } } for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 4811b6a..3a53a89 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -740,11 +740,72 @@ void PageBuilder::buildTweenSet(AnimationEvents *tweens, xml_node<> *componentXm for(componentXml = componentXml->first_node(tagName.c_str()); componentXml; componentXml = componentXml->next_sibling(tagName.c_str())) { xml_attribute<> *indexXml = componentXml->first_attribute("menuIndex"); - int index = (indexXml) ? Utils::convertInt(indexXml->value()) : -1; - Animation *animation = new Animation(); - getTweenSet(componentXml, animation); - tweens->setAnimation(tweenName, index, animation); + if(indexXml) + { + std::string indexs = indexXml->value(); + if(indexs[0] == '!') + { + indexs.erase(0); + int index = Utils::convertInt(indexXml->value()); + for(int i = 0; i < MENU_INDEX_HIGH-1; i++) + { + if(i != index) + { + Animation *animation = new Animation(); + getTweenSet(componentXml, animation); + tweens->setAnimation(tweenName, i, animation); + } + } + } + else if(indexs[0] == '<') + { + indexs.erase(0); + int index = Utils::convertInt(indexXml->value()); + for(int i = 0; i < MENU_INDEX_HIGH-1; i++) + { + if(i < index) + { + Animation *animation = new Animation(); + getTweenSet(componentXml, animation); + tweens->setAnimation(tweenName, i, animation); + } + } + } + else if(indexs[0] == '>') + { + indexs.erase(0); + int index = Utils::convertInt(indexXml->value()); + for(int i = 0; i < MENU_INDEX_HIGH-1; i++) + { + if(i > index) + { + Animation *animation = new Animation(); + getTweenSet(componentXml, animation); + tweens->setAnimation(tweenName, i, animation); + } + } + } + else if(indexs[0] == 'i') + { + Animation *animation = new Animation(); + getTweenSet(componentXml, animation); + tweens->setAnimation(tweenName, MENU_INDEX_HIGH, animation); + } + else + { + int index = Utils::convertInt(indexXml->value()); + Animation *animation = new Animation(); + getTweenSet(componentXml, animation); + tweens->setAnimation(tweenName, index, animation); + } + } + else + { + Animation *animation = new Animation(); + getTweenSet(componentXml, animation); + tweens->setAnimation(tweenName, -1, animation); + } } } diff --git a/RetroFE/Source/Graphics/PageBuilder.h b/RetroFE/Source/Graphics/PageBuilder.h index ce390bc..5386f56 100644 --- a/RetroFE/Source/Graphics/PageBuilder.h +++ b/RetroFE/Source/Graphics/PageBuilder.h @@ -22,6 +22,8 @@ #include #include +static const int MENU_INDEX_HIGH = 16; + class ScrollingList; class Page; class ViewInfo; diff --git a/RetroFE/Source/Version.cpp b/RetroFE/Source/Version.cpp index 55cfac8..82addf8 100644 --- a/RetroFE/Source/Version.cpp +++ b/RetroFE/Source/Version.cpp @@ -20,7 +20,7 @@ std::string retrofe_version_major = "0"; std::string retrofe_version_minor = "8"; -std::string retrofe_version_build = "5"; +std::string retrofe_version_build = "6"; std::string Version::getString()