mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-14 02:38:54 +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
@ -89,7 +89,3 @@ void AnimationEvents::clear()
|
|||||||
|
|
||||||
animationMap_.clear();
|
animationMap_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#include "../../Graphics/ViewInfo.h"
|
#include "../../Graphics/ViewInfo.h"
|
||||||
#include "../../Utility/Log.h"
|
#include "../../Utility/Log.h"
|
||||||
#include "../../SDL.h"
|
#include "../../SDL.h"
|
||||||
|
#include "../PageBuilder.h"
|
||||||
|
|
||||||
Component::Component(Page &p)
|
Component::Component(Page &p)
|
||||||
: page(p)
|
: page(p)
|
||||||
@ -127,7 +128,23 @@ void Component::update(float dt)
|
|||||||
|
|
||||||
if(animationRequested_ && animationRequestedType_ != "")
|
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)
|
if (newTweens && newTweens->size() > 0)
|
||||||
{
|
{
|
||||||
animationType_ = animationRequestedType_;
|
animationType_ = animationRequestedType_;
|
||||||
|
|||||||
@ -72,6 +72,7 @@ ScrollingList::ScrollingList(Configuration &c,
|
|||||||
ScrollingList::ScrollingList(const ScrollingList ©)
|
ScrollingList::ScrollingList(const ScrollingList ©)
|
||||||
: Component(copy)
|
: Component(copy)
|
||||||
, horizontalScroll(copy.horizontalScroll)
|
, horizontalScroll(copy.horizontalScroll)
|
||||||
|
, layoutMode_(copy.layoutMode_)
|
||||||
, spriteList_(NULL)
|
, spriteList_(NULL)
|
||||||
, itemIndex_(0)
|
, itemIndex_(0)
|
||||||
, componentIndex_(0)
|
, componentIndex_(0)
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
#include "Component/ScrollingList.h"
|
#include "Component/ScrollingList.h"
|
||||||
#include "../Sound/Sound.h"
|
#include "../Sound/Sound.h"
|
||||||
#include "ComponentItemBindingBuilder.h"
|
#include "ComponentItemBindingBuilder.h"
|
||||||
|
#include "PageBuilder.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -358,8 +359,17 @@ void Page::highlightEnter()
|
|||||||
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
|
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
|
||||||
{
|
{
|
||||||
ScrollingList *menu = *it;
|
ScrollingList *menu = *it;
|
||||||
menu->triggerEvent( "highlightEnter", menuDepth_ - 1 );
|
if(menus_[menuDepth_-1] == menu)
|
||||||
menu->triggerHighlightEnterEvent( menuDepth_ - 1 );
|
{
|
||||||
|
// 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)
|
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++)
|
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
|
||||||
{
|
{
|
||||||
ScrollingList *menu = *it;
|
ScrollingList *menu = *it;
|
||||||
menu->triggerEvent( "highlightExit", menuDepth_ - 1 );
|
if(menus_[menuDepth_-1] == menu)
|
||||||
menu->triggerHighlightExitEvent( menuDepth_ - 1 );
|
{
|
||||||
|
// 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)
|
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
|
// grow the menu as needed
|
||||||
if(menus_.size() >= menuDepth_ && activeMenu_)
|
if(menus_.size() <= menuDepth_ && activeMenu_)
|
||||||
{
|
{
|
||||||
activeMenu_ = new ScrollingList(*activeMenu_);
|
activeMenu_ = new ScrollingList(*activeMenu_);
|
||||||
pushMenu(activeMenu_);
|
pushMenu(activeMenu_);
|
||||||
@ -541,8 +560,17 @@ void Page::enterMenu()
|
|||||||
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
|
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
|
||||||
{
|
{
|
||||||
ScrollingList *menu = *it;
|
ScrollingList *menu = *it;
|
||||||
menu->triggerEvent( "menuEnter", menuDepth_ - 1 );
|
if(menus_[menuDepth_-1] == menu)
|
||||||
menu->triggerMenuEnterEvent( menuDepth_ - 1 );
|
{
|
||||||
|
// 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)
|
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++)
|
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
|
||||||
{
|
{
|
||||||
ScrollingList *menu = *it;
|
ScrollingList *menu = *it;
|
||||||
menu->triggerEvent( "menuExit" );
|
if(menus_[menuDepth_-1] == menu)
|
||||||
menu->triggerMenuExitEvent( menuDepth_ - 1 );
|
{
|
||||||
|
// 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)
|
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++)
|
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
|
||||||
{
|
{
|
||||||
ScrollingList *menu = *it;
|
ScrollingList *menu = *it;
|
||||||
menu->triggerEvent( "gameEnter", menuDepth_ - 1 );
|
if(menus_[menuDepth_-1] == menu)
|
||||||
menu->triggerGameEnterEvent( menuDepth_ - 1 );
|
{
|
||||||
|
// 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)
|
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++)
|
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
|
||||||
{
|
{
|
||||||
ScrollingList *menu = *it;
|
ScrollingList *menu = *it;
|
||||||
menu->triggerEvent( "gameExit" );
|
if(menus_[menuDepth_-1] == menu)
|
||||||
menu->triggerGameExitEvent( menuDepth_ - 1 );
|
{
|
||||||
|
// 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)
|
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()))
|
for(componentXml = componentXml->first_node(tagName.c_str()); componentXml; componentXml = componentXml->next_sibling(tagName.c_str()))
|
||||||
{
|
{
|
||||||
xml_attribute<> *indexXml = componentXml->first_attribute("menuIndex");
|
xml_attribute<> *indexXml = componentXml->first_attribute("menuIndex");
|
||||||
int index = (indexXml) ? Utils::convertInt(indexXml->value()) : -1;
|
|
||||||
|
|
||||||
Animation *animation = new Animation();
|
if(indexXml)
|
||||||
getTweenSet(componentXml, animation);
|
{
|
||||||
tweens->setAnimation(tweenName, index, animation);
|
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 <rapidxml.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
static const int MENU_INDEX_HIGH = 16;
|
||||||
|
|
||||||
class ScrollingList;
|
class ScrollingList;
|
||||||
class Page;
|
class Page;
|
||||||
class ViewInfo;
|
class ViewInfo;
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
std::string retrofe_version_major = "0";
|
std::string retrofe_version_major = "0";
|
||||||
std::string retrofe_version_minor = "8";
|
std::string retrofe_version_minor = "8";
|
||||||
std::string retrofe_version_build = "5";
|
std::string retrofe_version_build = "6";
|
||||||
|
|
||||||
|
|
||||||
std::string Version::getString()
|
std::string Version::getString()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user