Code compiles.

This commit is contained in:
emb
2015-02-17 20:20:17 -06:00
parent 52317560c4
commit 84b89b1f44
18 changed files with 146 additions and 193 deletions

View File

@@ -34,14 +34,13 @@ CollectionInfo::CollectionInfo(std::string name,
CollectionInfo::~CollectionInfo()
{
std::vector<Item *>::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<std::string> &extensions)
extensions.push_back(token);
}
}
std::vector<Item *> *CollectionInfo::GetItems()
std::vector<Item *> &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();
}

View File

@@ -31,12 +31,12 @@ public:
std::string GetMetadataType() const;
std::string GetMetadataPath() const;
std::string GetExtensions() const;
std::vector<Item *> *GetItems();
std::vector<Item *> &GetItems();
void SortItems();
void GetExtensions(std::vector<std::string> &extensions);
private:
static bool ItemIsLess(Item const *lhs, Item const *rhs);
static bool ItemIsLess(Item *lhs, Item *rhs);
std::string Name;
std::string ListPath;

View File

@@ -72,7 +72,6 @@ CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name)
}
CollectionInfo *collection = new CollectionInfo(name, listItemsPath, extensions, metadataType, metadataPath);
std::vector<Item *> *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);
}
}
}

View File

@@ -25,7 +25,7 @@
#include <fstream>
#include <sstream>
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<Item *> *items = collection->GetItems();
std::sort( items->begin(), items->end(), VectorSort);
std::vector<Item *> &items = collection->GetItems();
std::sort( items.begin(), items.end(), VectorSort);
retVal = true;
}

View File

@@ -194,10 +194,10 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
// items into a hash to make it easily searchable
std::vector<Item *> *items = collection->GetItems();
std::vector<Item *> &items = collection->GetItems();
std::map<std::string, Item *> itemMap;
for(std::vector<Item *>::iterator it = items->begin(); it != items->end(); it++)
for(std::vector<Item *>::iterator it = items.begin(); it != items.end(); it++)
{
itemMap[(*it)->GetName()] = *it;
}

View File

@@ -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<int, TweenAttributes>
}
}
return tweens->at(index);
return tweens.at(index);
}

View File

@@ -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

View File

@@ -72,7 +72,7 @@ ScrollingList::~ScrollingList()
DestroyItems();
}
void ScrollingList::SetItems(std::vector<ComponentItemBinding *> *spriteList)
void ScrollingList::SetItems(std::vector<ComponentItemBinding> *spriteList)
{
NotifyAllRequested = true;
SpriteList = spriteList;
@@ -89,7 +89,7 @@ void ScrollingList::SetItems(std::vector<ComponentItemBinding *> *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 &currentViewInfo = ScrollPoints->at(i);
unsigned int nextI = GetNextTween(i, ScrollPoints);
ViewInfo &nextViewInfo = ScrollPoints->at(nextI);
@@ -170,42 +170,29 @@ void ScrollingList::DestroyItems()
{
return;
}
std::vector<ComponentItemBinding *>::iterator it = SpriteList->begin();
std::vector<ComponentItemBinding>::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<ViewInfo *> *scrollPoints, std::vector<TweenSets *> *tweenPoints)
void ScrollingList::SetPoints(std::vector<ViewInfo> *scrollPoints, std::vector<TweenSets> *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 &currentViewInfo = 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<ViewInfo *> *list)
unsigned int ScrollingList::GetNextTween(unsigned int currentIndex, std::vector<ViewInfo> *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<MenuNotifierInterface *>::iterator it = NotificationComponents.begin();
it != NotificationComponents.end();
it++)
{
MenuNotifierInterface *c = *it;
if(c && item)
for(std::vector<MenuNotifierInterface *>::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 &currentViewInfo = 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 &current
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<Tween *> 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<Tween> 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 &currentViewInfo = 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<ComponentItemBinding *>::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<ViewInfo*>* list)
void ScrollingList::CircularIncrement(unsigned int &index, std::vector<ViewInfo>* list)
{
index++;
@@ -829,7 +789,7 @@ void ScrollingList::CircularIncrement(unsigned int &index, std::vector<ViewInfo*
}
}
void ScrollingList::CircularDecrement(unsigned int &index, std::vector<ViewInfo*>* list)
void ScrollingList::CircularDecrement(unsigned int &index, std::vector<ViewInfo>* list)
{
if(index > 0)
{
@@ -848,7 +808,7 @@ void ScrollingList::CircularDecrement(unsigned int &index, std::vector<ViewInfo*
}
}
int ScrollingList::CircularIncrement(unsigned int index, unsigned int offset, std::vector<ComponentItemBinding *> *list)
int ScrollingList::CircularIncrement(unsigned int index, unsigned int offset, std::vector<ComponentItemBinding> *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<ComponentItemBinding*> *list)
void ScrollingList::CircularIncrement(unsigned int &index, std::vector<ComponentItemBinding> *list)
{
index++;
@@ -871,7 +831,7 @@ void ScrollingList::CircularIncrement(unsigned int &index, std::vector<Component
}
}
void ScrollingList::CircularDecrement(unsigned int &index, std::vector<ComponentItemBinding*> *list)
void ScrollingList::CircularDecrement(unsigned int &index, std::vector<ComponentItemBinding> *list)
{
if(index > 0)
{

View File

@@ -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<ComponentItemBinding> *spriteList);
void DestroyItems();
void SetPoints(std::vector<ViewInfo> *scrollPoints, std::vector<TweenSets> *tweenPoints);
@@ -69,7 +69,7 @@ public:
ComponentItemBinding *GetPendingSelectedCollectionItemSprite();
void AddComponentForNotifications(MenuNotifierInterface *c);
void RemoveComponentForNotifications(MenuNotifierInterface *c);
std::vector<ComponentItemBinding> GetCollectionItemSprites();
std::vector<ComponentItemBinding> *GetCollectionItemSprites();
void RemoveSelectedItem();
void FreeGraphicsMemory();
void Update(float dt);

View File

@@ -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;
}

View File

@@ -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;
};

View File

@@ -26,12 +26,12 @@ ComponentItemBindingBuilder::~ComponentItemBindingBuilder()
{
}
std::vector<ComponentItemBinding> *ComponentItemBindingBuilder::BuildCollectionItems(std::vector<Item> *infoList)
std::vector<ComponentItemBinding> *ComponentItemBindingBuilder::BuildCollectionItems(std::vector<Item *> &infoList)
{
std::vector<ComponentItemBinding> *sprites = new std::vector<ComponentItemBinding>();
std::vector<Item>::iterator it;
std::vector<Item *>::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);

View File

@@ -26,5 +26,5 @@ class ComponentItemBindingBuilder
public:
ComponentItemBindingBuilder();
virtual ~ComponentItemBindingBuilder();
static std::vector<ComponentItemBinding *> *BuildCollectionItems(std::vector<Item *> *infoList);
static std::vector<ComponentItemBinding> *BuildCollectionItems(std::vector<Item *> &infoList);
};

View File

@@ -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());

View File

@@ -353,7 +353,7 @@ void Page::PageScroll(ScrollDirection direction)
bool Page::PushCollection(CollectionInfo *collection)
{
Collections.push_back(collection);
std::vector<ComponentItemBinding *> *sprites = ComponentItemBindingBuilder::BuildCollectionItems(collection->GetItems());
std::vector<ComponentItemBinding> *sprites = ComponentItemBindingBuilder::BuildCollectionItems(collection->GetItems());
int menuExitIndex = -1;
int menuEnterIndex = -1;

View File

@@ -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;
}

View File

@@ -39,7 +39,7 @@ private:
std::string LayoutPath;
Configuration &Config;
float ScaleX;
float ScaleY;->
float ScaleY;
int ScreenHeight;
int ScreenWidth;
SDL_Color FontColor;

View File

@@ -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);
}