mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
Added automatic copying of last menu setup for higher level menus.
Added support for <, >, and ! to the menuIndex parameter. Added support for i to the menuIndex parameter of menu items. This will allow for easier support for multi-level layouts, e.g. Rather than defining an animation for menuIndex 1, 2, 3, 4, ... you can use !0 or >0 Rather than defining the same menu for menuIndex 1, 2, 3, 4, ... with animations for that specific menuIndex you can create a single menu and set the menuIndex for the animations to i.
This commit is contained in:
parent
465be1846b
commit
d30158ea67
@ -23,73 +23,69 @@ AnimationEvents::AnimationEvents()
|
||||
{
|
||||
}
|
||||
|
||||
AnimationEvents::AnimationEvents(AnimationEvents ©)
|
||||
{
|
||||
for(std::map<std::string, std::map<int , Animation *> >::iterator it = copy.animationMap_.begin(); it != copy.animationMap_.end(); it++)
|
||||
{
|
||||
for(std::map<int, Animation *>::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<std::string, std::map<int, Animation *> >::iterator it = animationMap_.begin();
|
||||
while(it != animationMap_.end())
|
||||
{
|
||||
std::map<int, Animation *>::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<std::string, std::map<int , Animation *> >::iterator it = copy.animationMap_.begin(); it != copy.animationMap_.end(); it++)
|
||||
{
|
||||
for(std::map<int, Animation *>::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<std::string, std::map<int, Animation *> >::iterator it = animationMap_.begin();
|
||||
while(it != animationMap_.end())
|
||||
{
|
||||
std::map<int, Animation *>::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();
|
||||
}
|
||||
|
||||
@ -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_;
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "Component/ScrollingList.h"
|
||||
#include "../Sound/Sound.h"
|
||||
#include "ComponentItemBindingBuilder.h"
|
||||
#include "PageBuilder.h"
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
@ -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<Component *>::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<Component *>::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<Component *>::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<Component *>::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<Component *>::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<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,8 @@
|
||||
#include <rapidxml.hpp>
|
||||
#include <vector>
|
||||
|
||||
static const int MENU_INDEX_HIGH = 16;
|
||||
|
||||
class ScrollingList;
|
||||
class Page;
|
||||
class ViewInfo;
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user