From 84b89b1f4477a8f56bff66dca99e31c0d93b25a1 Mon Sep 17 00:00:00 2001 From: emb <> Date: Tue, 17 Feb 2015 20:20:17 -0600 Subject: [PATCH] Code compiles. --- RetroFE/Source/Collection/CollectionInfo.cpp | 17 +- RetroFE/Source/Collection/CollectionInfo.h | 4 +- .../Collection/CollectionInfoBuilder.cpp | 3 +- RetroFE/Source/Collection/MenuParser.cpp | 8 +- RetroFE/Source/Database/MetadataDatabase.cpp | 4 +- RetroFE/Source/Graphics/Animate/TweenSets.cpp | 6 +- .../Source/Graphics/Component/Component.cpp | 30 +-- .../Graphics/Component/ScrollingList.cpp | 192 +++++++----------- .../Source/Graphics/Component/ScrollingList.h | 6 +- .../Source/Graphics/ComponentItemBinding.cpp | 6 +- .../Source/Graphics/ComponentItemBinding.h | 8 +- .../Graphics/ComponentItemBindingBuilder.cpp | 6 +- .../Graphics/ComponentItemBindingBuilder.h | 2 +- RetroFE/Source/Graphics/Font.cpp | 23 +-- RetroFE/Source/Graphics/Page.cpp | 2 +- RetroFE/Source/Graphics/PageBuilder.cpp | 18 +- RetroFE/Source/Graphics/PageBuilder.h | 2 +- RetroFE/Source/RetroFE.cpp | 2 +- 18 files changed, 146 insertions(+), 193 deletions(-) diff --git a/RetroFE/Source/Collection/CollectionInfo.cpp b/RetroFE/Source/Collection/CollectionInfo.cpp index 893a62f..41d19d5 100644 --- a/RetroFE/Source/Collection/CollectionInfo.cpp +++ b/RetroFE/Source/Collection/CollectionInfo.cpp @@ -34,14 +34,13 @@ CollectionInfo::CollectionInfo(std::string name, CollectionInfo::~CollectionInfo() { - std::vector::iterator it = Items.begin(); - - while(it != Items.end()) + for(unsigned int i = 0; i < Items.size(); ++i) { - delete *it; - Items.erase(it); - it = Items.begin(); + Item *item = Items.at(i); + delete item; } + + Items.clear(); } std::string CollectionInfo::GetName() const @@ -84,12 +83,12 @@ void CollectionInfo::GetExtensions(std::vector &extensions) extensions.push_back(token); } } -std::vector *CollectionInfo::GetItems() +std::vector &CollectionInfo::GetItems() { - return &Items; + return Items; } -bool CollectionInfo::ItemIsLess(Item const *lhs, Item const *rhs) +bool CollectionInfo::ItemIsLess(Item *lhs, Item *rhs) { return lhs->GetLCTitle() < rhs->GetLCTitle(); } diff --git a/RetroFE/Source/Collection/CollectionInfo.h b/RetroFE/Source/Collection/CollectionInfo.h index 494f025..c834272 100644 --- a/RetroFE/Source/Collection/CollectionInfo.h +++ b/RetroFE/Source/Collection/CollectionInfo.h @@ -31,12 +31,12 @@ public: std::string GetMetadataType() const; std::string GetMetadataPath() const; std::string GetExtensions() const; - std::vector *GetItems(); + std::vector &GetItems(); void SortItems(); void GetExtensions(std::vector &extensions); private: - static bool ItemIsLess(Item const *lhs, Item const *rhs); + static bool ItemIsLess(Item *lhs, Item *rhs); std::string Name; std::string ListPath; diff --git a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp index dfe442e..d98c953 100644 --- a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp +++ b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp @@ -72,7 +72,6 @@ CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name) } CollectionInfo *collection = new CollectionInfo(name, listItemsPath, extensions, metadataType, metadataPath); - std::vector *list = collection->GetItems(); ImportDirectory(collection); @@ -166,7 +165,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info) i->SetFullTitle(basename); i->SetTitle(basename); i->SetLauncher(launcher); - info->GetItems()->push_back(i); + info->GetItems().push_back(i); } } } diff --git a/RetroFE/Source/Collection/MenuParser.cpp b/RetroFE/Source/Collection/MenuParser.cpp index aa27634..348770b 100644 --- a/RetroFE/Source/Collection/MenuParser.cpp +++ b/RetroFE/Source/Collection/MenuParser.cpp @@ -25,7 +25,7 @@ #include #include -bool VectorSort(const Item *d1, const Item *d2) +bool VectorSort(Item *d1, Item *d2) { return d1->GetLCTitle() < d2->GetLCTitle(); } @@ -91,7 +91,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection) item->SetFullTitle(title); item->SetName(collectionAttribute->value()); item->SetIsLeaf(false); - collection->GetItems()->push_back(item); + collection->GetItems().push_back(item); } else @@ -105,8 +105,8 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection) } // todo: sorting should occur within the collection itself, not externally - std::vector *items = collection->GetItems(); - std::sort( items->begin(), items->end(), VectorSort); + std::vector &items = collection->GetItems(); + std::sort( items.begin(), items.end(), VectorSort); retVal = true; } diff --git a/RetroFE/Source/Database/MetadataDatabase.cpp b/RetroFE/Source/Database/MetadataDatabase.cpp index 2170fe0..dab1996 100644 --- a/RetroFE/Source/Database/MetadataDatabase.cpp +++ b/RetroFE/Source/Database/MetadataDatabase.cpp @@ -194,10 +194,10 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection) // items into a hash to make it easily searchable - std::vector *items = collection->GetItems(); + std::vector &items = collection->GetItems(); std::map itemMap; - for(std::vector::iterator it = items->begin(); it != items->end(); it++) + for(std::vector::iterator it = items.begin(); it != items.end(); it++) { itemMap[(*it)->GetName()] = *it; } diff --git a/RetroFE/Source/Graphics/Animate/TweenSets.cpp b/RetroFE/Source/Graphics/Animate/TweenSets.cpp index 9882e40..d44a2ba 100644 --- a/RetroFE/Source/Graphics/Animate/TweenSets.cpp +++ b/RetroFE/Source/Graphics/Animate/TweenSets.cpp @@ -25,10 +25,6 @@ TweenSets::~TweenSets() { } -void TweenSets::DestroyTweens() -{ -} - TweenSets::TweenAttributes &TweenSets::GetTween(std::string tween) { return GetTween(tween, -1); @@ -57,5 +53,5 @@ TweenSets::TweenAttributes &TweenSets::FindTween(std::map } } - return tweens->at(index); + return tweens.at(index); } diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index 81a8f00..63cc782 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -21,7 +21,6 @@ Component::Component() { - Tweens = NULL; SelectedItem = NULL; NewItemSelectedSinceEnter = false; BackgroundTexture = NULL; @@ -162,6 +161,7 @@ void Component::ImportTweens(TweenSets &set) CurrentAnimationState = IDLE; CurrentTweenIndex = 0; CurrentTweenComplete = false; + CurrentTweens = NULL; ElapsedTweenTime = 0; } @@ -219,7 +219,7 @@ void Component::Update(float dt) case ENTER: - CurrentTweens = Tweens.GetTween("enter", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("enter", MenuEnterIndex); CurrentAnimationState = HIGHLIGHT_ENTER; break; @@ -229,7 +229,7 @@ void Component::Update(float dt) break; case HIGHLIGHT_ENTER: - CurrentTweens = Tweens.GetTween("idle", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("idle", MenuEnterIndex); CurrentAnimationState = IDLE; break; @@ -242,13 +242,13 @@ void Component::Update(float dt) } else if(MenuExitRequested && (!MenuEnterRequested || MenuExitRequested <= MenuEnterRequested)) { - CurrentTweens = Tweens.GetTween("menuExit", MenuExitIndex); + CurrentTweens = &Tweens.GetTween("menuExit", MenuExitIndex); CurrentAnimationState = MENU_EXIT; MenuExitRequested = false; } else if(MenuEnterRequested && (!MenuExitRequested || MenuExitRequested > MenuEnterRequested)) { - CurrentTweens = Tweens.GetTween("menuEnter", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("menuEnter", MenuEnterIndex); CurrentAnimationState = MENU_ENTER; MenuEnterRequested = false; @@ -256,17 +256,17 @@ void Component::Update(float dt) else if(MenuScrollRequested) { MenuScrollRequested = false; - CurrentTweens = Tweens.GetTween("menuScroll", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("menuScroll", MenuEnterIndex); CurrentAnimationState = MENU_SCROLL; } else if(IsScrollActive() || NewItemSelected || ExitRequested) { - CurrentTweens = Tweens.GetTween("highlightExit", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("highlightExit", MenuEnterIndex); CurrentAnimationState = HIGHLIGHT_EXIT; } else { - CurrentTweens = Tweens.GetTween("idle", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("idle", MenuEnterIndex); CurrentAnimationState = IDLE; } break; @@ -278,14 +278,14 @@ void Component::Update(float dt) if(ExitRequested && (CurrentAnimationState == HIGHLIGHT_WAIT)) { - CurrentTweens = Tweens.GetTween("highlightExit", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("highlightExit", MenuEnterIndex); CurrentAnimationState = HIGHLIGHT_EXIT; } else if(ExitRequested && (CurrentAnimationState == HIGHLIGHT_EXIT)) { - CurrentTweens = Tweens.GetTween("exit", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("exit", MenuEnterIndex); CurrentAnimationState = EXIT; ExitRequested = false; } @@ -296,7 +296,7 @@ void Component::Update(float dt) } else if(NewItemSelected) { - CurrentTweens = Tweens.GetTween("highlightEnter", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("highlightEnter", MenuEnterIndex); CurrentAnimationState = HIGHLIGHT_ENTER; HighlightExitComplete = true; NewItemSelected = false; @@ -311,19 +311,19 @@ void Component::Update(float dt) case HIDDEN: if(EnterRequested || ExitRequested) { - CurrentTweens = Tweens.GetTween("enter", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("enter", MenuEnterIndex); CurrentAnimationState = ENTER; } else if(MenuExitRequested && (!MenuEnterRequested || MenuExitRequested <= MenuEnterRequested)) { - CurrentTweens = Tweens.GetTween("menuExit", MenuExitIndex); + CurrentTweens = &Tweens.GetTween("menuExit", MenuExitIndex); CurrentAnimationState = MENU_EXIT; MenuExitRequested = false; } else if(MenuEnterRequested && (!MenuExitRequested || MenuExitRequested > MenuEnterRequested)) { - CurrentTweens = Tweens.GetTween("menuEnter", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("menuEnter", MenuEnterIndex); CurrentAnimationState = MENU_ENTER; MenuEnterRequested = false; @@ -331,7 +331,7 @@ void Component::Update(float dt) else if(MenuScrollRequested) { MenuScrollRequested = false; - CurrentTweens = Tweens.GetTween("menuScroll", MenuEnterIndex); + CurrentTweens = &Tweens.GetTween("menuScroll", MenuEnterIndex); CurrentAnimationState = MENU_SCROLL; } else diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index e5b97dc..ab80c61 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -72,7 +72,7 @@ ScrollingList::~ScrollingList() DestroyItems(); } -void ScrollingList::SetItems(std::vector *spriteList) +void ScrollingList::SetItems(std::vector *spriteList) { NotifyAllRequested = true; SpriteList = spriteList; @@ -89,7 +89,7 @@ void ScrollingList::SetItems(std::vector *spriteList) { for(unsigned int i = 0; i < originalSize; ++i) { - Item newItem = SpriteList->at(i).GetCollectionItem(); + Item *newItem = SpriteList->at(i).GetCollectionItem(); ComponentItemBinding newSprite(newItem); SpriteList->push_back(newSprite); } @@ -153,7 +153,7 @@ void ScrollingList::AllocateSpritePoints() for(unsigned int i = 0; i < ScrollPoints->size(); ++i) { AllocateTexture(SpriteList->at(spriteIndex)); - Component *c = SpriteList->at(spriteIndex)->GetComponent(); + Component *c = SpriteList->at(spriteIndex).GetComponent(); ViewInfo ¤tViewInfo = ScrollPoints->at(i); unsigned int nextI = GetNextTween(i, ScrollPoints); ViewInfo &nextViewInfo = ScrollPoints->at(nextI); @@ -170,42 +170,29 @@ void ScrollingList::DestroyItems() { return; } - std::vector::iterator it = SpriteList->begin(); + std::vector::iterator it = SpriteList->begin(); - while(it != SpriteList->end()) + for(unsigned int i = 0; i < SpriteList->size(); ++i) { - if(*it != NULL) - { - DeallocateTexture(*it); + DeallocateTexture(SpriteList->at(i)); - if((*it)->GetCollectionItem()) - { - delete (*it)->GetCollectionItem(); - } - - delete *it; - } - - - SpriteList->erase(it); - - it = SpriteList->begin(); } + SpriteList->clear(); delete SpriteList; SpriteList = NULL; } -void ScrollingList::SetPoints(std::vector *scrollPoints, std::vector *tweenPoints) +void ScrollingList::SetPoints(std::vector *scrollPoints, std::vector *tweenPoints) { ScrollPoints = scrollPoints; TweenPoints = tweenPoints; for(unsigned int i = 0; i != scrollPoints->size(); ++i) { - ViewInfo *info = scrollPoints->at(i); - MaxLayer = (MaxLayer < info->GetLayer()) ? MaxLayer : info->GetLayer(); + ViewInfo &info = scrollPoints->at(i); + MaxLayer = (MaxLayer < info.GetLayer()) ? MaxLayer : info.GetLayer(); } } @@ -258,15 +245,15 @@ void ScrollingList::Click(double nextScrollTime) DeallocateTexture(SpriteList->at(deallocSpriteIndex)); AllocateTexture(SpriteList->at(allocSpriteIndex)); - Component *c = SpriteList->at(allocSpriteIndex)->GetComponent(); - ViewInfo *currentViewInfo = ScrollPoints->at(allocPoint); + Component *c = SpriteList->at(allocSpriteIndex).GetComponent(); + ViewInfo ¤tViewInfo = ScrollPoints->at(allocPoint); unsigned int nextI = GetNextTween(allocPoint, ScrollPoints); - ViewInfo *nextViewInfo = ScrollPoints->at(nextI); + ViewInfo &nextViewInfo = ScrollPoints->at(nextI); ResetTweens(c, TweenPoints->at(allocPoint), currentViewInfo, nextViewInfo, nextScrollTime); } -unsigned int ScrollingList::GetNextTween(unsigned int currentIndex, std::vector *list) +unsigned int ScrollingList::GetNextTween(unsigned int currentIndex, std::vector *list) { if(CurrentScrollDirection == ScrollDirectionForward) { @@ -334,7 +321,7 @@ void ScrollingList::FreeGraphicsMemory() for(unsigned int i = 0; SpriteList && i < SpriteList->size(); i++) { - ComponentItemBinding *s = SpriteList->at(i); + ComponentItemBinding &s = SpriteList->at(i); DeallocateTexture(s); } @@ -366,9 +353,9 @@ void ScrollingList::TriggerMenuEnterEvent() for(unsigned int i = 0; i < ScrollPoints->size(); ++i) { - ComponentItemBinding *s = SpriteList->at(spriteIndex); + ComponentItemBinding &s = SpriteList->at(spriteIndex); - Component *c = s->GetComponent(); + Component *c = s.GetComponent(); if(c) { c->TriggerMenuEnterEvent(); @@ -404,9 +391,9 @@ void ScrollingList::TriggerMenuExitEvent() for(unsigned int i = 0; i < ScrollPoints->size(); ++i) { - ComponentItemBinding *s = SpriteList->at(spriteIndex); + ComponentItemBinding &s = SpriteList->at(spriteIndex); - Component *c = s->GetComponent(); + Component *c = s.GetComponent(); if(c) { c->TriggerMenuExitEvent(); @@ -443,8 +430,8 @@ void ScrollingList::Update(float dt) // validate all scroll points are done tweening to the next position for(unsigned int i = 0; i < SpriteList->size(); i++) { - ComponentItemBinding *s = SpriteList->at(i); - Component *c = s->GetComponent(); + ComponentItemBinding &s = SpriteList->at(i); + Component *c = s.GetComponent(); if(c && c->IsMenuScrolling()) { @@ -485,12 +472,12 @@ void ScrollingList::Update(float dt) for(unsigned int i = 0; i < TweenPoints->size(); ++i) { - ComponentItemBinding *s = SpriteList->at(spriteIndex); + ComponentItemBinding &s = SpriteList->at(spriteIndex); - Component *c = s->GetComponent(); + Component *c = s.GetComponent(); if(c) { - c->SetTweens(TweenPoints->at(i)); + c->ImportTweens(TweenPoints->at(i)); } CircularIncrement(spriteIndex, SpriteList); @@ -522,21 +509,20 @@ void ScrollingList::Update(float dt) if(scrollStopped || (NotifyAllRequested && Focus)) { ComponentItemBinding *sprite = GetPendingCollectionItemSprite(); - Item *item = NULL; if(sprite) - { - item = sprite->GetCollectionItem(); - } + { + Item *item = sprite->GetCollectionItem(); - for(std::vector::iterator it = NotificationComponents.begin(); - it != NotificationComponents.end(); - it++) - { - MenuNotifierInterface *c = *it; - if(c && item) + for(std::vector::iterator it = NotificationComponents.begin(); + it != NotificationComponents.end(); + it++) { - c->OnNewItemSelected(item); + MenuNotifierInterface *c = *it; + if(c) + { + c->OnNewItemSelected(item); + } } } @@ -551,15 +537,15 @@ void ScrollingList::Update(float dt) void ScrollingList::UpdateSprite(unsigned int spriteIndex, unsigned int pointIndex, bool newScroll, float dt, double nextScrollTime) { - ComponentItemBinding *s = SpriteList->at(spriteIndex); + ComponentItemBinding &s = SpriteList->at(spriteIndex); - Component *c = s->GetComponent(); + Component *c = s.GetComponent(); //todo: remove me if(c && newScroll) { - ViewInfo *currentViewInfo = ScrollPoints->at(pointIndex); + ViewInfo ¤tViewInfo = ScrollPoints->at(pointIndex); unsigned int nextI = GetNextTween(pointIndex, ScrollPoints); - ViewInfo *nextViewInfo = ScrollPoints->at(nextI); + ViewInfo &nextViewInfo = ScrollPoints->at(nextI); ResetTweens(c, TweenPoints->at(pointIndex), currentViewInfo, nextViewInfo, nextScrollTime); c->TriggerMenuScrollEvent(); @@ -579,46 +565,45 @@ void ScrollingList::ResetTweens(Component *c, TweenSets &sets, ViewInfo ¤t 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()); + 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()); - c->SetTweens(sets); - - TweenSets::TweenAttributes &scrollTween = sets->GetTween("menuScroll"); - TweenSets::TweenAttributes::iterator it = scrollTween->begin(); + TweenSets::TweenAttributes &scrollTween = sets.GetTween("menuScroll"); scrollTween.clear(); c->UpdateBaseViewInfo(currentViewInfo); - std::vector set; - set->push_back(new Tween(TWEEN_PROPERTY_HEIGHT, EASE_INOUT_QUADRATIC, currentViewInfo->GetHeight(), nextViewInfo->GetHeight(), scrollTime)); - set->push_back(new Tween(TWEEN_PROPERTY_WIDTH, EASE_INOUT_QUADRATIC, currentViewInfo->GetWidth(), nextViewInfo->GetWidth(), scrollTime)); - set->push_back(new Tween(TWEEN_PROPERTY_ANGLE, EASE_INOUT_QUADRATIC, currentViewInfo->GetAngle(), nextViewInfo->GetAngle(), scrollTime)); - set->push_back(new Tween(TWEEN_PROPERTY_ALPHA, EASE_INOUT_QUADRATIC, currentViewInfo->GetAlpha(), nextViewInfo->GetAlpha(), scrollTime)); - set->push_back(new Tween(TWEEN_PROPERTY_X, EASE_INOUT_QUADRATIC, currentViewInfo->GetX(), nextViewInfo->GetX(), scrollTime)); - set->push_back(new Tween(TWEEN_PROPERTY_Y, EASE_INOUT_QUADRATIC, currentViewInfo->GetY(), nextViewInfo->GetY(), scrollTime)); - set->push_back(new Tween(TWEEN_PROPERTY_X_ORIGIN, EASE_INOUT_QUADRATIC, currentViewInfo->GetXOrigin(), nextViewInfo->GetXOrigin(), scrollTime)); - set->push_back(new Tween(TWEEN_PROPERTY_Y_ORIGIN, EASE_INOUT_QUADRATIC, currentViewInfo->GetYOrigin(), nextViewInfo->GetYOrigin(), scrollTime)); - set->push_back(new Tween(TWEEN_PROPERTY_X_OFFSET, EASE_INOUT_QUADRATIC, currentViewInfo->GetXOffset(), nextViewInfo->GetXOffset(), scrollTime)); - set->push_back(new Tween(TWEEN_PROPERTY_Y_OFFSET, EASE_INOUT_QUADRATIC, currentViewInfo->GetYOffset(), nextViewInfo->GetYOffset(), scrollTime)); - 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)); + std::vector set; + + set.push_back(Tween(TWEEN_PROPERTY_HEIGHT, EASE_INOUT_QUADRATIC, currentViewInfo.GetHeight(), nextViewInfo.GetHeight(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_WIDTH, EASE_INOUT_QUADRATIC, currentViewInfo.GetWidth(), nextViewInfo.GetWidth(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_ANGLE, EASE_INOUT_QUADRATIC, currentViewInfo.GetAngle(), nextViewInfo.GetAngle(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_ALPHA, EASE_INOUT_QUADRATIC, currentViewInfo.GetAlpha(), nextViewInfo.GetAlpha(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_X, EASE_INOUT_QUADRATIC, currentViewInfo.GetX(), nextViewInfo.GetX(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_Y, EASE_INOUT_QUADRATIC, currentViewInfo.GetY(), nextViewInfo.GetY(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_X_ORIGIN, EASE_INOUT_QUADRATIC, currentViewInfo.GetXOrigin(), nextViewInfo.GetXOrigin(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_Y_ORIGIN, EASE_INOUT_QUADRATIC, currentViewInfo.GetYOrigin(), nextViewInfo.GetYOrigin(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_X_OFFSET, EASE_INOUT_QUADRATIC, currentViewInfo.GetXOffset(), nextViewInfo.GetXOffset(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_Y_OFFSET, EASE_INOUT_QUADRATIC, currentViewInfo.GetYOffset(), nextViewInfo.GetYOffset(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_FONT_SIZE, EASE_INOUT_QUADRATIC, currentViewInfo.GetFontSize(), nextViewInfo.GetFontSize(), scrollTime)); + set.push_back(Tween(TWEEN_PROPERTY_BACKGROUND_ALPHA, EASE_INOUT_QUADRATIC, currentViewInfo.GetBackgroundAlpha(), nextViewInfo.GetBackgroundAlpha(), scrollTime)); scrollTween.push_back(set); + c->ImportTweens(sets); } -bool ScrollingList::AllocateTexture(ComponentItemBinding *s) +bool ScrollingList::AllocateTexture(ComponentItemBinding &s) { - if(!s || s->GetComponent() != NULL) + if(s.GetComponent() != NULL) { return false; } - const Item *item = s->GetCollectionItem(); + Item *item = s.GetCollectionItem(); //todo: will create a runtime fault if not of the right type //todo: remove coupling from knowing the collection name @@ -643,20 +628,20 @@ bool ScrollingList::AllocateTexture(ComponentItemBinding *s) if(t) { - s->SetComponent(t); + s.SetComponent(t); } return true; } -void ScrollingList::DeallocateTexture(ComponentItemBinding *s) +void ScrollingList::DeallocateTexture(ComponentItemBinding &s) { - if(s && s->GetComponent() != NULL) + if(s.GetComponent() != NULL) { - delete s->GetComponent(); + delete s.GetComponent(); //todo: memory leak here, need to destroy allocated tween points here and in page (cannot be destroyed by component) } - s->SetComponent(NULL); + s.SetComponent(NULL); } void ScrollingList::Draw() @@ -685,7 +670,7 @@ void ScrollingList::Draw(unsigned int layer) for(unsigned int i = 0; i < ScrollPoints->size(); i++) { ComponentItemBinding &s = SpriteList->at(spriteIndex); - Component *c = s->GetComponent(); + Component *c = s.GetComponent(); ViewInfo ¤tViewInfo = ScrollPoints->at(i); if(c && currentViewInfo.GetLayer() == layer) @@ -706,32 +691,7 @@ void ScrollingList::SetScrollDirection(ScrollDirection direction) void ScrollingList::RemoveSelectedItem() { - ComponentItemBinding *sprite = GetSelectedCollectionItemSprite(); - if(sprite && SpriteList) - { - Item *item = sprite->GetCollectionItem(); - DeallocateTexture(sprite); - int index = (FirstSpriteIndex + SelectedSpriteListIndex) % SpriteList->size(); - - std::vector::iterator it = SpriteList->begin() + index; - - SpriteList->erase(it); - delete sprite; - - if(item) - { - delete item; - } - - if(SelectedSpriteListIndex >= SpriteList->size()) - { - SelectedSpriteListIndex = 0; - } - if(FirstSpriteIndex >= SpriteList->size()) - { - FirstSpriteIndex = 0; - } - } + //todo: implement me } @@ -745,7 +705,7 @@ ComponentItemBinding* ScrollingList::GetSelectedCollectionItemSprite() if(SpriteList && SpriteList->size() > 0) { int index = (FirstSpriteIndex + SelectedSpriteListIndex) % SpriteList->size(); - ComponentItemBinding item = &SpriteList->at(index); + ComponentItemBinding &item = SpriteList->at(index); return &item; } @@ -759,7 +719,7 @@ ComponentItemBinding* ScrollingList::GetPendingCollectionItemSprite() { index = (index + SelectedSpriteListIndex) % SpriteList->size(); - ComponentItemBinding item = &SpriteList->at(index); + ComponentItemBinding &item = SpriteList->at(index); return &item; } @@ -819,7 +779,7 @@ bool ScrollingList::IsIdle() return (Component::IsIdle() && CurrentScrollState == ScrollStateIdle); } -void ScrollingList::CircularIncrement(unsigned int &index, std::vector* list) +void ScrollingList::CircularIncrement(unsigned int &index, std::vector* list) { index++; @@ -829,7 +789,7 @@ void ScrollingList::CircularIncrement(unsigned int &index, std::vector* list) +void ScrollingList::CircularDecrement(unsigned int &index, std::vector* list) { if(index > 0) { @@ -848,7 +808,7 @@ void ScrollingList::CircularDecrement(unsigned int &index, std::vector *list) +int ScrollingList::CircularIncrement(unsigned int index, unsigned int offset, std::vector *list) { unsigned int end = index + offset; @@ -861,7 +821,7 @@ int ScrollingList::CircularIncrement(unsigned int index, unsigned int offset, st } -void ScrollingList::CircularIncrement(unsigned int &index, std::vector *list) +void ScrollingList::CircularIncrement(unsigned int &index, std::vector *list) { index++; @@ -871,7 +831,7 @@ void ScrollingList::CircularIncrement(unsigned int &index, std::vector *list) +void ScrollingList::CircularDecrement(unsigned int &index, std::vector *list) { if(index > 0) { diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 7c67f96..a73096a 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -54,8 +54,8 @@ public: void TriggerMenuEnterEvent(); void TriggerMenuExitEvent(); - bool AllocateTexture(ComponentItemBinding *s); - void DeallocateTexture(ComponentItemBinding *s); + bool AllocateTexture(ComponentItemBinding &s); + void DeallocateTexture(ComponentItemBinding &s); void SetItems(std::vector *spriteList); void DestroyItems(); void SetPoints(std::vector *scrollPoints, std::vector *tweenPoints); @@ -69,7 +69,7 @@ public: ComponentItemBinding *GetPendingSelectedCollectionItemSprite(); void AddComponentForNotifications(MenuNotifierInterface *c); void RemoveComponentForNotifications(MenuNotifierInterface *c); - std::vector GetCollectionItemSprites(); + std::vector *GetCollectionItemSprites(); void RemoveSelectedItem(); void FreeGraphicsMemory(); void Update(float dt); diff --git a/RetroFE/Source/Graphics/ComponentItemBinding.cpp b/RetroFE/Source/Graphics/ComponentItemBinding.cpp index 32e4f15..138adce 100644 --- a/RetroFE/Source/Graphics/ComponentItemBinding.cpp +++ b/RetroFE/Source/Graphics/ComponentItemBinding.cpp @@ -15,13 +15,13 @@ */ #include "ComponentItemBinding.h" -ComponentItemBinding::ComponentItemBinding( Component *c, Item &item) +ComponentItemBinding::ComponentItemBinding( Component *c, Item *item) : CollectionComponent(c) , CollectionItem(item) { } -ComponentItemBinding::ComponentItemBinding(Item &item) +ComponentItemBinding::ComponentItemBinding(Item *item) : CollectionComponent(NULL) , CollectionItem(item) { @@ -31,7 +31,7 @@ ComponentItemBinding::~ComponentItemBinding() { } -Item &ComponentItemBinding::GetCollectionItem() const +Item *ComponentItemBinding::GetCollectionItem() { return CollectionItem; } diff --git a/RetroFE/Source/Graphics/ComponentItemBinding.h b/RetroFE/Source/Graphics/ComponentItemBinding.h index 1c1ce6f..0d84f20 100644 --- a/RetroFE/Source/Graphics/ComponentItemBinding.h +++ b/RetroFE/Source/Graphics/ComponentItemBinding.h @@ -21,10 +21,10 @@ class ComponentItemBinding { public: - ComponentItemBinding(Component *c, Item &item); - ComponentItemBinding(Item &item); + ComponentItemBinding(Component *c, Item *item); + ComponentItemBinding(Item *item); virtual ~ComponentItemBinding(); - Item &GetCollectionItem() const; + Item *GetCollectionItem(); void SetComponent(Component *c); Component* GetComponent() const; @@ -32,5 +32,5 @@ public: private: Component *CollectionComponent; - Item CollectionItem; + Item *CollectionItem; }; diff --git a/RetroFE/Source/Graphics/ComponentItemBindingBuilder.cpp b/RetroFE/Source/Graphics/ComponentItemBindingBuilder.cpp index aae670b..576cde3 100644 --- a/RetroFE/Source/Graphics/ComponentItemBindingBuilder.cpp +++ b/RetroFE/Source/Graphics/ComponentItemBindingBuilder.cpp @@ -26,12 +26,12 @@ ComponentItemBindingBuilder::~ComponentItemBindingBuilder() { } -std::vector *ComponentItemBindingBuilder::BuildCollectionItems(std::vector *infoList) +std::vector *ComponentItemBindingBuilder::BuildCollectionItems(std::vector &infoList) { std::vector *sprites = new std::vector(); - std::vector::iterator it; + std::vector::iterator it; - for(it = infoList->begin(); it != infoList->end(); ++it) + for(it = infoList.begin(); it != infoList.end(); ++it) { ComponentItemBinding s(*it); sprites->push_back(s); diff --git a/RetroFE/Source/Graphics/ComponentItemBindingBuilder.h b/RetroFE/Source/Graphics/ComponentItemBindingBuilder.h index 1295c85..8b0cf87 100644 --- a/RetroFE/Source/Graphics/ComponentItemBindingBuilder.h +++ b/RetroFE/Source/Graphics/ComponentItemBindingBuilder.h @@ -26,5 +26,5 @@ class ComponentItemBindingBuilder public: ComponentItemBindingBuilder(); virtual ~ComponentItemBindingBuilder(); - static std::vector *BuildCollectionItems(std::vector *infoList); + static std::vector *BuildCollectionItems(std::vector &infoList); }; diff --git a/RetroFE/Source/Graphics/Font.cpp b/RetroFE/Source/Graphics/Font.cpp index c467dac..6585dc1 100644 --- a/RetroFE/Source/Graphics/Font.cpp +++ b/RetroFE/Source/Graphics/Font.cpp @@ -69,14 +69,13 @@ bool Font::Initialize(std::string fontPath, int fontSize, SDL_Color color) for(unsigned short int i = 32; i < 128; ++i) { - GlyphInfoBuild *info = new GlyphInfoBuild; - memset(info, 0, sizeof(GlyphInfoBuild)); + GlyphInfoBuild info; color.a = 255; - info->Surface = TTF_RenderGlyph_Blended(font, i, color); - TTF_GlyphMetrics(font, i, &info->Glyph.MinX, &info->Glyph.MaxX, &info->Glyph.MinY, &info->Glyph.MaxY, &info->Glyph.Advance); + info.Surface = TTF_RenderGlyph_Blended(font, i, color); + TTF_GlyphMetrics(font, i, &info.Glyph.MinX, &info.Glyph.MaxX, &info.Glyph.MinY, &info.Glyph.MaxY, &info.Glyph.Advance); - if(x + info->Surface->w >= 1024) + if(x + info.Surface->w >= 1024) { atlasHeight += y; atlasWidth = (atlasWidth >= x) ? atlasWidth : x; @@ -84,14 +83,14 @@ bool Font::Initialize(std::string fontPath, int fontSize, SDL_Color color) y = 0; } - info->Glyph.Rect.w = info->Surface->w; - info->Glyph.Rect.h = info->Surface->h; - info->Glyph.Rect.x = x; - info->Glyph.Rect.y = atlasHeight; + info.Glyph.Rect.w = info.Surface->w; + info.Glyph.Rect.h = info.Surface->h; + info.Glyph.Rect.x = x; + info.Glyph.Rect.y = atlasHeight; Atlas[i] = info; - x += info->Glyph.Rect.w; - y = (y > info->Glyph.Rect.h) ? y : info->Glyph.Rect.h; + x += info.Glyph.Rect.w; + y = (y > info.Glyph.Rect.h) ? y : info.Glyph.Rect.h; /* std::stringstream ss; ss << " tw:" << atlasWidth << " th:" << atlasHeight << " x:" << x << " y:" << y << " w:" << info->Glyph.Rect.w << " h:" << info->Glyph.Rect.h; @@ -125,7 +124,7 @@ bool Font::Initialize(std::string fontPath, int fontSize, SDL_Color color) GlyphInfoBuild &info = it->second; SDL_BlitSurface(info.Surface, NULL, atlasSurface, &info.Glyph.Rect); SDL_FreeSurface(info.Surface); - info->Surface = NULL; + info.Surface = NULL; } SDL_LockMutex(SDL::GetMutex()); diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 3f3305e..7539b1c 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -353,7 +353,7 @@ void Page::PageScroll(ScrollDirection direction) bool Page::PushCollection(CollectionInfo *collection) { Collections.push_back(collection); - std::vector *sprites = ComponentItemBindingBuilder::BuildCollectionItems(collection->GetItems()); + std::vector *sprites = ComponentItemBindingBuilder::BuildCollectionItems(collection->GetItems()); int menuExitIndex = -1; int menuEnterIndex = -1; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 61e8a1f..cdfb27e 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -464,7 +464,7 @@ void PageBuilder::LoadTweens(Component *c, xml_node<> *componentXml) BuildViewInfo(componentXml, v); - c->SetTweens(CreateTweenInstance(componentXml)); + c->ImportTweens(CreateTweenInstance(componentXml)); } TweenSets PageBuilder::CreateTweenInstance(xml_node<> *componentXml) @@ -623,7 +623,7 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm if(overrideItems.find(MENU_START) != overrideItems.end()) { xml_node<> *component = overrideItems[MENU_START]; - ViewInfo *viewInfo = CreateMenuItemInfo(component, itemDefaults, menu->GetBaseViewInfo()->GetY() + height); + ViewInfo &viewInfo = CreateMenuItemInfo(component, itemDefaults, menu->GetBaseViewInfo()->GetY() + height); points->push_back(viewInfo); tweenPoints->push_back(CreateTweenInstance(component)); } @@ -639,10 +639,10 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm } // calculate the total height of our menu items if we can load any additional items - BuildViewInfo(component, viewInfo, itemDefaults); + BuildViewInfo(component, &viewInfo, itemDefaults); xml_attribute<> *itemSpacingXml = component->first_attribute("spacing"); int itemSpacing = itemSpacingXml ? Utils::ConvertInt(itemSpacingXml->value()) : 0; - float nextHeight = height + viewInfo->GetHeight() + itemSpacing; + float nextHeight = height + viewInfo.GetHeight() + itemSpacing; if(nextHeight >= menu->GetBaseViewInfo()->GetHeight()) { @@ -654,14 +654,14 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm { component = overrideItems[MENU_LAST]; - BuildViewInfo(component, viewInfo, itemDefaults); + BuildViewInfo(component, &viewInfo, itemDefaults); xml_attribute<> *itemSpacingXml = component->first_attribute("spacing"); int itemSpacing = itemSpacingXml ? Utils::ConvertInt(itemSpacingXml->value()) : 0; - nextHeight = height + viewInfo->GetHeight() + itemSpacing; + nextHeight = height + viewInfo.GetHeight() + itemSpacing; } height = nextHeight; - viewInfo->SetY(menu->GetBaseViewInfo()->GetY() + (float)height); + viewInfo.SetY(menu->GetBaseViewInfo()->GetY() + (float)height); points->push_back(viewInfo); tweenPoints->push_back(CreateTweenInstance(component)); index++; @@ -671,7 +671,7 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm if(overrideItems.find(MENU_END) != overrideItems.end()) { xml_node<> *component = overrideItems[MENU_END]; - ViewInfo *viewInfo = CreateMenuItemInfo(component, itemDefaults, menu->GetBaseViewInfo()->GetY() + height); + ViewInfo &viewInfo = CreateMenuItemInfo(component, itemDefaults, menu->GetBaseViewInfo()->GetY() + height); points->push_back(viewInfo); tweenPoints->push_back(CreateTweenInstance(component)); } @@ -693,7 +693,7 @@ ViewInfo PageBuilder::CreateMenuItemInfo(xml_node<> *component, xml_node<> *defa { ViewInfo viewInfo; BuildViewInfo(component, &viewInfo, defaults); - viewInfo->SetY(y); + viewInfo.SetY(y); return viewInfo; } diff --git a/RetroFE/Source/Graphics/PageBuilder.h b/RetroFE/Source/Graphics/PageBuilder.h index 1de288f..f30d499 100644 --- a/RetroFE/Source/Graphics/PageBuilder.h +++ b/RetroFE/Source/Graphics/PageBuilder.h @@ -39,7 +39,7 @@ private: std::string LayoutPath; Configuration &Config; float ScaleX; - float ScaleY;-> + float ScaleY; int ScreenHeight; int ScreenWidth; SDL_Color FontColor; diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 10dbfa2..2b9c4a8 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -484,7 +484,7 @@ CollectionInfo *RetroFE::GetCollection(std::string collectionName) CollectionInfoBuilder cib(Config, *MetaDb); CollectionInfo *collection = cib.BuildCollection(collectionName); - if(collection->GetItems()->size() == 0) + if(collection->GetItems().size() == 0) { Logger::Write(Logger::ZONE_WARNING, "RetroFE", "No list items found for collection " + collectionName); }