diff --git a/RetroFE/Source/Graphics/Animate/TweenSet.cpp b/RetroFE/Source/Graphics/Animate/TweenSet.cpp index f2dde23..320b07a 100644 --- a/RetroFE/Source/Graphics/Animate/TweenSet.cpp +++ b/RetroFE/Source/Graphics/Animate/TweenSet.cpp @@ -23,11 +23,11 @@ TweenSet::~TweenSet() void TweenSet::DestroyTweens() { - std::map >::iterator it = TweenMap.begin(); + std::map >::iterator it = TweenMap.begin(); while(it != TweenMap.end()) { - std::map::iterator it2 = (it->second).begin(); + std::map::iterator it2 = (it->second).begin(); while(it2 != (it->second).end()) { @@ -40,22 +40,22 @@ void TweenSet::DestroyTweens() } } -TweenSet::TweenSets *TweenSet::GetTween(std::string tween) +TweenSet::TweenAttributes *TweenSet::GetTween(std::string tween) { return GetTween(tween, -1); } -TweenSet::TweenSets *TweenSet::GetTween(std::string tween, int index) +TweenSet::TweenAttributes *TweenSet::GetTween(std::string tween, int index) { return FindTween(TweenMap[tween], index); } -void TweenSet::SetTween(std::string tween, int index, TweenSets *set) +void TweenSet::SetTween(std::string tween, int index, TweenAttributes *set) { TweenMap[tween][index] = set; } -TweenSet::TweenSets *TweenSet::FindTween(std::map &tweens, int index) +TweenSet::TweenAttributes *TweenSet::FindTween(std::map &tweens, int index) { if(tweens.find(index) == tweens.end()) { @@ -63,7 +63,7 @@ TweenSet::TweenSets *TweenSet::FindTween(std::map &tweens, int if(tweens.find(index) == tweens.end()) { - TweenSets *set = new TweenSets(); + TweenAttributes *set = new TweenAttributes(); tweens[index] = set; } } diff --git a/RetroFE/Source/Graphics/Animate/TweenSet.h b/RetroFE/Source/Graphics/Animate/TweenSet.h index c095bf1..707ba06 100644 --- a/RetroFE/Source/Graphics/Animate/TweenSet.h +++ b/RetroFE/Source/Graphics/Animate/TweenSet.h @@ -20,21 +20,19 @@ #include #include - - class TweenSet { public: ~TweenSet(); - typedef std::vector *> TweenSets; + typedef std::vector *> TweenAttributes; - TweenSets *GetTween(std::string tween); - TweenSets *GetTween(std::string tween, int index); - void SetTween(std::string tween, int index, TweenSets *set); + TweenAttributes *GetTween(std::string tween); + TweenAttributes *GetTween(std::string tween, int index); + void SetTween(std::string tween, int index, TweenAttributes *set); private: - TweenSets *FindTween(std::map &tweens, int index); + TweenAttributes *FindTween(std::map &tweens, int index); void DestroyTweens(); - std::map > TweenMap; + std::map > TweenMap; }; diff --git a/RetroFE/Source/Graphics/Component/Component.h b/RetroFE/Source/Graphics/Component/Component.h index caad418..a04ef78 100644 --- a/RetroFE/Source/Graphics/Component/Component.h +++ b/RetroFE/Source/Graphics/Component/Component.h @@ -45,7 +45,7 @@ public: bool IsMenuScrolling(); std::string GetCollectionName(); void SetCollectionName(std::string collectionName); - typedef std::vector *> TweenSets; + typedef std::vector *> TweenAttributes; TweenSet *GetTweens() { return Tweens; } @@ -119,7 +119,7 @@ private: bool IsTweenSequencingComplete(); void ResetTweenSequence(std::vector *tweens); TweenSet *Tweens; - TweenSets *CurrentTweens; + TweenAttributes *CurrentTweens; unsigned int CurrentTweenIndex; bool CurrentTweenComplete; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 2e646b7..f5f8497 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -74,7 +74,7 @@ ScrollingList::~ScrollingList() void ScrollingList::SetItems(std::vector *spriteList) { - NotifyAllRequested = true; + NotifyAllRequested = true; SpriteList = spriteList; FirstSpriteIndex = 0; @@ -103,20 +103,20 @@ void ScrollingList::SetItems(std::vector *spriteList) AllocateSpritePoints(); } -void ScrollingList::SetScrollAcceleration(float value) -{ - ScrollAcceleration = value; -} - -void ScrollingList::SetStartScrollTime(float value) -{ - StartScrollTime = value; -} +void ScrollingList::SetScrollAcceleration(float value) +{ + ScrollAcceleration = value; +} + +void ScrollingList::SetStartScrollTime(float value) +{ + StartScrollTime = value; +} + +void ScrollingList::DeallocateSpritePoints() +{ + if(!SpriteList) { return; } -void ScrollingList::DeallocateSpritePoints() -{ - if(!SpriteList) { return; } - unsigned int spriteIndex = FirstSpriteIndex; for(unsigned int i = 0; i < ScrollPoints->size(); ++i) @@ -124,15 +124,15 @@ void ScrollingList::DeallocateSpritePoints() DeallocateTexture(SpriteList->at(spriteIndex)); CircularIncrement(spriteIndex, SpriteList); } -} - -void ScrollingList::AllocateSpritePoints() -{ - if(!ScrollPoints) { return; } - if(!SpriteList) { return; } - if(SpriteList->size() == 0) { return; } - if(!TweenPoints) { return; } - +} + +void ScrollingList::AllocateSpritePoints() +{ + if(!ScrollPoints) { return; } + if(!SpriteList) { return; } + if(SpriteList->size() == 0) { return; } + if(!TweenPoints) { return; } + unsigned int spriteIndex = FirstSpriteIndex; for(unsigned int i = 0; i < ScrollPoints->size(); ++i) @@ -147,10 +147,10 @@ void ScrollingList::AllocateSpritePoints() CircularIncrement(spriteIndex, SpriteList); } -} +} -void ScrollingList::DestroyItems() -{ +void ScrollingList::DestroyItems() +{ if(!SpriteList) { return; } std::vector::iterator it = SpriteList->begin(); @@ -176,7 +176,7 @@ void ScrollingList::DestroyItems() delete SpriteList; SpriteList = NULL; -} +} void ScrollingList::SetPoints(std::vector *scrollPoints, std::vector *tweenPoints) @@ -316,16 +316,16 @@ void ScrollingList::FreeGraphicsMemory() } } -void ScrollingList::TriggerMenuEnterEvent() -{ - Focus = true; - NotifyAllRequested = true; - - if(!ScrollPoints) { return; } - if(!SpriteList) { return; } - if(SpriteList->size() == 0 ) { return; } - if(FirstSpriteIndex >= SpriteList->size()) { return; } - +void ScrollingList::TriggerMenuEnterEvent() +{ + Focus = true; + NotifyAllRequested = true; + + if(!ScrollPoints) { return; } + if(!SpriteList) { return; } + if(SpriteList->size() == 0 ) { return; } + if(FirstSpriteIndex >= SpriteList->size()) { return; } + unsigned int spriteIndex = FirstSpriteIndex; for(unsigned int i = 0; i < ScrollPoints->size(); ++i) @@ -340,18 +340,18 @@ void ScrollingList::TriggerMenuEnterEvent() CircularIncrement(spriteIndex, SpriteList); } -} - -void ScrollingList::TriggerMenuExitEvent() -{ - Focus = false; - NotifyAllRequested = true; - - if(!ScrollPoints) { return; } - if(!SpriteList) { return; } - if(SpriteList->size() == 0 ) { return; } - if(FirstSpriteIndex >= SpriteList->size()) { return; } - +} + +void ScrollingList::TriggerMenuExitEvent() +{ + Focus = false; + NotifyAllRequested = true; + + if(!ScrollPoints) { return; } + if(!SpriteList) { return; } + if(SpriteList->size() == 0 ) { return; } + if(FirstSpriteIndex >= SpriteList->size()) { return; } + unsigned int spriteIndex = FirstSpriteIndex; for(unsigned int i = 0; i < ScrollPoints->size(); ++i) @@ -366,7 +366,7 @@ void ScrollingList::TriggerMenuExitEvent() CircularIncrement(spriteIndex, SpriteList); } -} +} void ScrollingList::Update(float dt) { @@ -515,24 +515,24 @@ void ScrollingList::UpdateSprite(unsigned int spriteIndex, unsigned int pointInd CircularIncrement(spriteIndex, SpriteList); } -void ScrollingList::ResetTweens(Component *c, TweenSet *sets, ViewInfo *currentViewInfo, ViewInfo *nextViewInfo, double scrollTime) -{ - if(!c) { return; } - if(!sets) { return; } - if(!currentViewInfo) { return; } - if(!nextViewInfo) { return; } - +void ScrollingList::ResetTweens(Component *c, TweenSet *sets, ViewInfo *currentViewInfo, ViewInfo *nextViewInfo, double scrollTime) +{ + if(!c) { return; } + if(!sets) { return; } + if(!currentViewInfo) { return; } + if(!nextViewInfo) { return; } + currentViewInfo->SetImageHeight(c->GetBaseViewInfo()->GetImageHeight()); currentViewInfo->SetImageWidth(c->GetBaseViewInfo()->GetImageWidth()); nextViewInfo->SetImageHeight(c->GetBaseViewInfo()->GetImageHeight()); nextViewInfo->SetImageWidth(c->GetBaseViewInfo()->GetImageWidth()); nextViewInfo->SetBackgroundAlpha(c->GetBaseViewInfo()->GetBackgroundAlpha()); - + //todo: delete properly, memory leak (big), proof of concept c->SetTweens(sets); - TweenSets *scrollTween = sets->GetTween("menuScroll"); - TweenSets::iterator it = scrollTween->begin(); + TweenAttributes *scrollTween = sets->GetTween("menuScroll"); + TweenAttributes::iterator it = scrollTween->begin(); while(it != scrollTween->end()) { @@ -566,7 +566,7 @@ void ScrollingList::ResetTweens(Component *c, TweenSet *sets, ViewInfo *currentV set->push_back(new Tween(TWEEN_PROPERTY_FONT_SIZE, EASE_INOUT_QUADRATIC, currentViewInfo->GetFontSize(), nextViewInfo->GetFontSize(), scrollTime)); set->push_back(new Tween(TWEEN_PROPERTY_BACKGROUND_ALPHA, EASE_INOUT_QUADRATIC, currentViewInfo->GetBackgroundAlpha(), nextViewInfo->GetBackgroundAlpha(), scrollTime)); scrollTween->push_back(set); -} +} bool ScrollingList::AllocateTexture(ComponentItemBinding *s) @@ -796,17 +796,17 @@ void ScrollingList::CircularDecrement(unsigned int &index, std::vector *list) -{ - unsigned int end = index + offset; - - while(end >= list->size() && list->size() > 0) - { - end -= list->size(); - } - - return end; -} +int ScrollingList::CircularIncrement(unsigned int index, unsigned int offset, std::vector *list) +{ + unsigned int end = index + offset; + + while(end >= list->size() && list->size() > 0) + { + end -= list->size(); + } + + return end; +} void ScrollingList::CircularIncrement(unsigned int &index, std::vector *list) diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index a3924aa..5c41ece 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -471,26 +471,26 @@ TweenSet *PageBuilder::CreateTweenInstance(xml_node<> *componentXml) { TweenSet *tweens = new TweenSet(); - BuildTweenSets(tweens, componentXml, "onEnter", "enter"); - BuildTweenSets(tweens, componentXml, "onExit", "exit"); - BuildTweenSets(tweens, componentXml, "onIdle", "idle"); - BuildTweenSets(tweens, componentXml, "onHighlightEnter", "highlightEnter"); - BuildTweenSets(tweens, componentXml, "onHighlightExit", "highlightExit"); - BuildTweenSets(tweens, componentXml, "onMenuEnter", "menuEnter"); - BuildTweenSets(tweens, componentXml, "onMenuExit", "menuExit"); + BuildTweenAttributes(tweens, componentXml, "onEnter", "enter"); + BuildTweenAttributes(tweens, componentXml, "onExit", "exit"); + BuildTweenAttributes(tweens, componentXml, "onIdle", "idle"); + BuildTweenAttributes(tweens, componentXml, "onHighlightEnter", "highlightEnter"); + BuildTweenAttributes(tweens, componentXml, "onHighlightExit", "highlightExit"); + BuildTweenAttributes(tweens, componentXml, "onMenuEnter", "menuEnter"); + BuildTweenAttributes(tweens, componentXml, "onMenuExit", "menuExit"); return tweens; } -void PageBuilder::BuildTweenSets(TweenSet *tweens, xml_node<> *componentXml, std::string tagName, std::string tweenName) +void PageBuilder::BuildTweenAttributes(TweenSet *tweens, xml_node<> *componentXml, std::string tagName, std::string tweenName) { 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; - TweenSet::TweenSets *sets = new TweenSet::TweenSets(); - GetTweenSets(componentXml, sets); + TweenSet::TweenAttributes *sets = new TweenSet::TweenAttributes(); + GetTweenAttributes(componentXml, sets); tweens->SetTween(tweenName, index, sets); } } @@ -810,7 +810,7 @@ void PageBuilder::BuildViewInfo(xml_node<> *componentXml, ViewInfo *info, xml_no } } -void PageBuilder::GetTweenSets(xml_node<> *node, std::vector *> *tweenSets) +void PageBuilder::GetTweenAttributes(xml_node<> *node, std::vector *> *TweenAttributes) { if(node) { @@ -818,7 +818,7 @@ void PageBuilder::GetTweenSets(xml_node<> *node, std::vector *tweens = new std::vector(); GetTweenSet(set, *tweens); - tweenSets->push_back(tweens); + TweenAttributes->push_back(tweens); } } } diff --git a/RetroFE/Source/Graphics/PageBuilder.h b/RetroFE/Source/Graphics/PageBuilder.h index c5e12a9..da59bef 100644 --- a/RetroFE/Source/Graphics/PageBuilder.h +++ b/RetroFE/Source/Graphics/PageBuilder.h @@ -54,7 +54,7 @@ private: bool BuildComponents(rapidxml::xml_node<> *layout, Page *page); void LoadTweens(Component *c, rapidxml::xml_node<> *componentXml); TweenSet *CreateTweenInstance(rapidxml::xml_node<> *componentXml); - void BuildTweenSets(TweenSet *tweens, rapidxml::xml_node<> *componentXml, std::string tagName, std::string tweenName); + void BuildTweenAttributes(TweenSet *tweens, rapidxml::xml_node<> *componentXml, std::string tagName, std::string tweenName); ScrollingList * BuildMenu(rapidxml::xml_node<> *menuXml); void BuildCustomMenu(ScrollingList *menu, rapidxml::xml_node<> *menuXml, rapidxml::xml_node<> *itemDefaults); void BuildVerticalMenu(ScrollingList *menu, rapidxml::xml_node<> *menuXml, rapidxml::xml_node<> *itemDefaults); @@ -63,7 +63,7 @@ private: rapidxml::xml_attribute<> *FindAttribute(rapidxml::xml_node<> *componentXml, std::string attribute, rapidxml::xml_node<> *defaultXml); - void GetTweenSets(rapidxml::xml_node<> *node, std::vector *> *tweenSets); + void GetTweenAttributes(rapidxml::xml_node<> *node, std::vector *> *TweenAttributes); void GetTweenSet(rapidxml::xml_node<> *node, std::vector &tweens);