mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-02 02:05:55 +02:00
Code compiles.
This commit is contained in:
@@ -34,14 +34,13 @@ CollectionInfo::CollectionInfo(std::string name,
|
|||||||
|
|
||||||
CollectionInfo::~CollectionInfo()
|
CollectionInfo::~CollectionInfo()
|
||||||
{
|
{
|
||||||
std::vector<Item *>::iterator it = Items.begin();
|
for(unsigned int i = 0; i < Items.size(); ++i)
|
||||||
|
|
||||||
while(it != Items.end())
|
|
||||||
{
|
{
|
||||||
delete *it;
|
Item *item = Items.at(i);
|
||||||
Items.erase(it);
|
delete item;
|
||||||
it = Items.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CollectionInfo::GetName() const
|
std::string CollectionInfo::GetName() const
|
||||||
@@ -84,12 +83,12 @@ void CollectionInfo::GetExtensions(std::vector<std::string> &extensions)
|
|||||||
extensions.push_back(token);
|
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();
|
return lhs->GetLCTitle() < rhs->GetLCTitle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ public:
|
|||||||
std::string GetMetadataType() const;
|
std::string GetMetadataType() const;
|
||||||
std::string GetMetadataPath() const;
|
std::string GetMetadataPath() const;
|
||||||
std::string GetExtensions() const;
|
std::string GetExtensions() const;
|
||||||
std::vector<Item *> *GetItems();
|
std::vector<Item *> &GetItems();
|
||||||
void SortItems();
|
void SortItems();
|
||||||
void GetExtensions(std::vector<std::string> &extensions);
|
void GetExtensions(std::vector<std::string> &extensions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool ItemIsLess(Item const *lhs, Item const *rhs);
|
static bool ItemIsLess(Item *lhs, Item *rhs);
|
||||||
|
|
||||||
std::string Name;
|
std::string Name;
|
||||||
std::string ListPath;
|
std::string ListPath;
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CollectionInfo *collection = new CollectionInfo(name, listItemsPath, extensions, metadataType, metadataPath);
|
CollectionInfo *collection = new CollectionInfo(name, listItemsPath, extensions, metadataType, metadataPath);
|
||||||
std::vector<Item *> *list = collection->GetItems();
|
|
||||||
|
|
||||||
ImportDirectory(collection);
|
ImportDirectory(collection);
|
||||||
|
|
||||||
@@ -166,7 +165,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
|||||||
i->SetFullTitle(basename);
|
i->SetFullTitle(basename);
|
||||||
i->SetTitle(basename);
|
i->SetTitle(basename);
|
||||||
i->SetLauncher(launcher);
|
i->SetLauncher(launcher);
|
||||||
info->GetItems()->push_back(i);
|
info->GetItems().push_back(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
bool VectorSort(const Item *d1, const Item *d2)
|
bool VectorSort(Item *d1, Item *d2)
|
||||||
{
|
{
|
||||||
return d1->GetLCTitle() < d2->GetLCTitle();
|
return d1->GetLCTitle() < d2->GetLCTitle();
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
|
|||||||
item->SetFullTitle(title);
|
item->SetFullTitle(title);
|
||||||
item->SetName(collectionAttribute->value());
|
item->SetName(collectionAttribute->value());
|
||||||
item->SetIsLeaf(false);
|
item->SetIsLeaf(false);
|
||||||
collection->GetItems()->push_back(item);
|
collection->GetItems().push_back(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -105,8 +105,8 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: sorting should occur within the collection itself, not externally
|
// todo: sorting should occur within the collection itself, not externally
|
||||||
std::vector<Item *> *items = collection->GetItems();
|
std::vector<Item *> &items = collection->GetItems();
|
||||||
std::sort( items->begin(), items->end(), VectorSort);
|
std::sort( items.begin(), items.end(), VectorSort);
|
||||||
|
|
||||||
retVal = true;
|
retVal = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,10 +194,10 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
|
|||||||
|
|
||||||
|
|
||||||
// items into a hash to make it easily searchable
|
// 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;
|
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;
|
itemMap[(*it)->GetName()] = *it;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ TweenSets::~TweenSets()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TweenSets::DestroyTweens()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
TweenSets::TweenAttributes &TweenSets::GetTween(std::string tween)
|
TweenSets::TweenAttributes &TweenSets::GetTween(std::string tween)
|
||||||
{
|
{
|
||||||
return GetTween(tween, -1);
|
return GetTween(tween, -1);
|
||||||
@@ -57,5 +53,5 @@ TweenSets::TweenAttributes &TweenSets::FindTween(std::map<int, TweenAttributes>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tweens->at(index);
|
return tweens.at(index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
Component::Component()
|
Component::Component()
|
||||||
{
|
{
|
||||||
Tweens = NULL;
|
|
||||||
SelectedItem = NULL;
|
SelectedItem = NULL;
|
||||||
NewItemSelectedSinceEnter = false;
|
NewItemSelectedSinceEnter = false;
|
||||||
BackgroundTexture = NULL;
|
BackgroundTexture = NULL;
|
||||||
@@ -162,6 +161,7 @@ void Component::ImportTweens(TweenSets &set)
|
|||||||
CurrentAnimationState = IDLE;
|
CurrentAnimationState = IDLE;
|
||||||
CurrentTweenIndex = 0;
|
CurrentTweenIndex = 0;
|
||||||
CurrentTweenComplete = false;
|
CurrentTweenComplete = false;
|
||||||
|
CurrentTweens = NULL;
|
||||||
ElapsedTweenTime = 0;
|
ElapsedTweenTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ void Component::Update(float dt)
|
|||||||
|
|
||||||
|
|
||||||
case ENTER:
|
case ENTER:
|
||||||
CurrentTweens = Tweens.GetTween("enter", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("enter", MenuEnterIndex);
|
||||||
CurrentAnimationState = HIGHLIGHT_ENTER;
|
CurrentAnimationState = HIGHLIGHT_ENTER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ void Component::Update(float dt)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HIGHLIGHT_ENTER:
|
case HIGHLIGHT_ENTER:
|
||||||
CurrentTweens = Tweens.GetTween("idle", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("idle", MenuEnterIndex);
|
||||||
CurrentAnimationState = IDLE;
|
CurrentAnimationState = IDLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -242,13 +242,13 @@ void Component::Update(float dt)
|
|||||||
}
|
}
|
||||||
else if(MenuExitRequested && (!MenuEnterRequested || MenuExitRequested <= MenuEnterRequested))
|
else if(MenuExitRequested && (!MenuEnterRequested || MenuExitRequested <= MenuEnterRequested))
|
||||||
{
|
{
|
||||||
CurrentTweens = Tweens.GetTween("menuExit", MenuExitIndex);
|
CurrentTweens = &Tweens.GetTween("menuExit", MenuExitIndex);
|
||||||
CurrentAnimationState = MENU_EXIT;
|
CurrentAnimationState = MENU_EXIT;
|
||||||
MenuExitRequested = false;
|
MenuExitRequested = false;
|
||||||
}
|
}
|
||||||
else if(MenuEnterRequested && (!MenuExitRequested || MenuExitRequested > MenuEnterRequested))
|
else if(MenuEnterRequested && (!MenuExitRequested || MenuExitRequested > MenuEnterRequested))
|
||||||
{
|
{
|
||||||
CurrentTweens = Tweens.GetTween("menuEnter", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("menuEnter", MenuEnterIndex);
|
||||||
CurrentAnimationState = MENU_ENTER;
|
CurrentAnimationState = MENU_ENTER;
|
||||||
MenuEnterRequested = false;
|
MenuEnterRequested = false;
|
||||||
|
|
||||||
@@ -256,17 +256,17 @@ void Component::Update(float dt)
|
|||||||
else if(MenuScrollRequested)
|
else if(MenuScrollRequested)
|
||||||
{
|
{
|
||||||
MenuScrollRequested = false;
|
MenuScrollRequested = false;
|
||||||
CurrentTweens = Tweens.GetTween("menuScroll", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("menuScroll", MenuEnterIndex);
|
||||||
CurrentAnimationState = MENU_SCROLL;
|
CurrentAnimationState = MENU_SCROLL;
|
||||||
}
|
}
|
||||||
else if(IsScrollActive() || NewItemSelected || ExitRequested)
|
else if(IsScrollActive() || NewItemSelected || ExitRequested)
|
||||||
{
|
{
|
||||||
CurrentTweens = Tweens.GetTween("highlightExit", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("highlightExit", MenuEnterIndex);
|
||||||
CurrentAnimationState = HIGHLIGHT_EXIT;
|
CurrentAnimationState = HIGHLIGHT_EXIT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CurrentTweens = Tweens.GetTween("idle", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("idle", MenuEnterIndex);
|
||||||
CurrentAnimationState = IDLE;
|
CurrentAnimationState = IDLE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -278,14 +278,14 @@ void Component::Update(float dt)
|
|||||||
|
|
||||||
if(ExitRequested && (CurrentAnimationState == HIGHLIGHT_WAIT))
|
if(ExitRequested && (CurrentAnimationState == HIGHLIGHT_WAIT))
|
||||||
{
|
{
|
||||||
CurrentTweens = Tweens.GetTween("highlightExit", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("highlightExit", MenuEnterIndex);
|
||||||
CurrentAnimationState = HIGHLIGHT_EXIT;
|
CurrentAnimationState = HIGHLIGHT_EXIT;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(ExitRequested && (CurrentAnimationState == HIGHLIGHT_EXIT))
|
else if(ExitRequested && (CurrentAnimationState == HIGHLIGHT_EXIT))
|
||||||
{
|
{
|
||||||
|
|
||||||
CurrentTweens = Tweens.GetTween("exit", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("exit", MenuEnterIndex);
|
||||||
CurrentAnimationState = EXIT;
|
CurrentAnimationState = EXIT;
|
||||||
ExitRequested = false;
|
ExitRequested = false;
|
||||||
}
|
}
|
||||||
@@ -296,7 +296,7 @@ void Component::Update(float dt)
|
|||||||
}
|
}
|
||||||
else if(NewItemSelected)
|
else if(NewItemSelected)
|
||||||
{
|
{
|
||||||
CurrentTweens = Tweens.GetTween("highlightEnter", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("highlightEnter", MenuEnterIndex);
|
||||||
CurrentAnimationState = HIGHLIGHT_ENTER;
|
CurrentAnimationState = HIGHLIGHT_ENTER;
|
||||||
HighlightExitComplete = true;
|
HighlightExitComplete = true;
|
||||||
NewItemSelected = false;
|
NewItemSelected = false;
|
||||||
@@ -311,19 +311,19 @@ void Component::Update(float dt)
|
|||||||
case HIDDEN:
|
case HIDDEN:
|
||||||
if(EnterRequested || ExitRequested)
|
if(EnterRequested || ExitRequested)
|
||||||
{
|
{
|
||||||
CurrentTweens = Tweens.GetTween("enter", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("enter", MenuEnterIndex);
|
||||||
CurrentAnimationState = ENTER;
|
CurrentAnimationState = ENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(MenuExitRequested && (!MenuEnterRequested || MenuExitRequested <= MenuEnterRequested))
|
else if(MenuExitRequested && (!MenuEnterRequested || MenuExitRequested <= MenuEnterRequested))
|
||||||
{
|
{
|
||||||
CurrentTweens = Tweens.GetTween("menuExit", MenuExitIndex);
|
CurrentTweens = &Tweens.GetTween("menuExit", MenuExitIndex);
|
||||||
CurrentAnimationState = MENU_EXIT;
|
CurrentAnimationState = MENU_EXIT;
|
||||||
MenuExitRequested = false;
|
MenuExitRequested = false;
|
||||||
}
|
}
|
||||||
else if(MenuEnterRequested && (!MenuExitRequested || MenuExitRequested > MenuEnterRequested))
|
else if(MenuEnterRequested && (!MenuExitRequested || MenuExitRequested > MenuEnterRequested))
|
||||||
{
|
{
|
||||||
CurrentTweens = Tweens.GetTween("menuEnter", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("menuEnter", MenuEnterIndex);
|
||||||
CurrentAnimationState = MENU_ENTER;
|
CurrentAnimationState = MENU_ENTER;
|
||||||
MenuEnterRequested = false;
|
MenuEnterRequested = false;
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ void Component::Update(float dt)
|
|||||||
else if(MenuScrollRequested)
|
else if(MenuScrollRequested)
|
||||||
{
|
{
|
||||||
MenuScrollRequested = false;
|
MenuScrollRequested = false;
|
||||||
CurrentTweens = Tweens.GetTween("menuScroll", MenuEnterIndex);
|
CurrentTweens = &Tweens.GetTween("menuScroll", MenuEnterIndex);
|
||||||
CurrentAnimationState = MENU_SCROLL;
|
CurrentAnimationState = MENU_SCROLL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ ScrollingList::~ScrollingList()
|
|||||||
DestroyItems();
|
DestroyItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollingList::SetItems(std::vector<ComponentItemBinding *> *spriteList)
|
void ScrollingList::SetItems(std::vector<ComponentItemBinding> *spriteList)
|
||||||
{
|
{
|
||||||
NotifyAllRequested = true;
|
NotifyAllRequested = true;
|
||||||
SpriteList = spriteList;
|
SpriteList = spriteList;
|
||||||
@@ -89,7 +89,7 @@ void ScrollingList::SetItems(std::vector<ComponentItemBinding *> *spriteList)
|
|||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < originalSize; ++i)
|
for(unsigned int i = 0; i < originalSize; ++i)
|
||||||
{
|
{
|
||||||
Item newItem = SpriteList->at(i).GetCollectionItem();
|
Item *newItem = SpriteList->at(i).GetCollectionItem();
|
||||||
ComponentItemBinding newSprite(newItem);
|
ComponentItemBinding newSprite(newItem);
|
||||||
SpriteList->push_back(newSprite);
|
SpriteList->push_back(newSprite);
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ void ScrollingList::AllocateSpritePoints()
|
|||||||
for(unsigned int i = 0; i < ScrollPoints->size(); ++i)
|
for(unsigned int i = 0; i < ScrollPoints->size(); ++i)
|
||||||
{
|
{
|
||||||
AllocateTexture(SpriteList->at(spriteIndex));
|
AllocateTexture(SpriteList->at(spriteIndex));
|
||||||
Component *c = SpriteList->at(spriteIndex)->GetComponent();
|
Component *c = SpriteList->at(spriteIndex).GetComponent();
|
||||||
ViewInfo ¤tViewInfo = ScrollPoints->at(i);
|
ViewInfo ¤tViewInfo = ScrollPoints->at(i);
|
||||||
unsigned int nextI = GetNextTween(i, ScrollPoints);
|
unsigned int nextI = GetNextTween(i, ScrollPoints);
|
||||||
ViewInfo &nextViewInfo = ScrollPoints->at(nextI);
|
ViewInfo &nextViewInfo = ScrollPoints->at(nextI);
|
||||||
@@ -170,42 +170,29 @@ void ScrollingList::DestroyItems()
|
|||||||
{
|
{
|
||||||
return;
|
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(SpriteList->at(i));
|
||||||
{
|
|
||||||
DeallocateTexture(*it);
|
|
||||||
|
|
||||||
if((*it)->GetCollectionItem())
|
|
||||||
{
|
|
||||||
delete (*it)->GetCollectionItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
delete *it;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SpriteList->erase(it);
|
|
||||||
|
|
||||||
it = SpriteList->begin();
|
|
||||||
}
|
}
|
||||||
|
SpriteList->clear();
|
||||||
|
|
||||||
delete SpriteList;
|
delete SpriteList;
|
||||||
SpriteList = NULL;
|
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;
|
ScrollPoints = scrollPoints;
|
||||||
TweenPoints = tweenPoints;
|
TweenPoints = tweenPoints;
|
||||||
|
|
||||||
for(unsigned int i = 0; i != scrollPoints->size(); ++i)
|
for(unsigned int i = 0; i != scrollPoints->size(); ++i)
|
||||||
{
|
{
|
||||||
ViewInfo *info = scrollPoints->at(i);
|
ViewInfo &info = scrollPoints->at(i);
|
||||||
MaxLayer = (MaxLayer < info->GetLayer()) ? MaxLayer : info->GetLayer();
|
MaxLayer = (MaxLayer < info.GetLayer()) ? MaxLayer : info.GetLayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,15 +245,15 @@ void ScrollingList::Click(double nextScrollTime)
|
|||||||
DeallocateTexture(SpriteList->at(deallocSpriteIndex));
|
DeallocateTexture(SpriteList->at(deallocSpriteIndex));
|
||||||
AllocateTexture(SpriteList->at(allocSpriteIndex));
|
AllocateTexture(SpriteList->at(allocSpriteIndex));
|
||||||
|
|
||||||
Component *c = SpriteList->at(allocSpriteIndex)->GetComponent();
|
Component *c = SpriteList->at(allocSpriteIndex).GetComponent();
|
||||||
ViewInfo *currentViewInfo = ScrollPoints->at(allocPoint);
|
ViewInfo ¤tViewInfo = ScrollPoints->at(allocPoint);
|
||||||
unsigned int nextI = GetNextTween(allocPoint, ScrollPoints);
|
unsigned int nextI = GetNextTween(allocPoint, ScrollPoints);
|
||||||
ViewInfo *nextViewInfo = ScrollPoints->at(nextI);
|
ViewInfo &nextViewInfo = ScrollPoints->at(nextI);
|
||||||
|
|
||||||
ResetTweens(c, TweenPoints->at(allocPoint), currentViewInfo, nextViewInfo, nextScrollTime);
|
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)
|
if(CurrentScrollDirection == ScrollDirectionForward)
|
||||||
{
|
{
|
||||||
@@ -334,7 +321,7 @@ void ScrollingList::FreeGraphicsMemory()
|
|||||||
|
|
||||||
for(unsigned int i = 0; SpriteList && i < SpriteList->size(); i++)
|
for(unsigned int i = 0; SpriteList && i < SpriteList->size(); i++)
|
||||||
{
|
{
|
||||||
ComponentItemBinding *s = SpriteList->at(i);
|
ComponentItemBinding &s = SpriteList->at(i);
|
||||||
|
|
||||||
DeallocateTexture(s);
|
DeallocateTexture(s);
|
||||||
}
|
}
|
||||||
@@ -366,9 +353,9 @@ void ScrollingList::TriggerMenuEnterEvent()
|
|||||||
|
|
||||||
for(unsigned int i = 0; i < ScrollPoints->size(); ++i)
|
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)
|
if(c)
|
||||||
{
|
{
|
||||||
c->TriggerMenuEnterEvent();
|
c->TriggerMenuEnterEvent();
|
||||||
@@ -404,9 +391,9 @@ void ScrollingList::TriggerMenuExitEvent()
|
|||||||
|
|
||||||
for(unsigned int i = 0; i < ScrollPoints->size(); ++i)
|
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)
|
if(c)
|
||||||
{
|
{
|
||||||
c->TriggerMenuExitEvent();
|
c->TriggerMenuExitEvent();
|
||||||
@@ -443,8 +430,8 @@ void ScrollingList::Update(float dt)
|
|||||||
// validate all scroll points are done tweening to the next position
|
// validate all scroll points are done tweening to the next position
|
||||||
for(unsigned int i = 0; i < SpriteList->size(); i++)
|
for(unsigned int i = 0; i < SpriteList->size(); i++)
|
||||||
{
|
{
|
||||||
ComponentItemBinding *s = SpriteList->at(i);
|
ComponentItemBinding &s = SpriteList->at(i);
|
||||||
Component *c = s->GetComponent();
|
Component *c = s.GetComponent();
|
||||||
|
|
||||||
if(c && c->IsMenuScrolling())
|
if(c && c->IsMenuScrolling())
|
||||||
{
|
{
|
||||||
@@ -485,12 +472,12 @@ void ScrollingList::Update(float dt)
|
|||||||
|
|
||||||
for(unsigned int i = 0; i < TweenPoints->size(); ++i)
|
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)
|
if(c)
|
||||||
{
|
{
|
||||||
c->SetTweens(TweenPoints->at(i));
|
c->ImportTweens(TweenPoints->at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
CircularIncrement(spriteIndex, SpriteList);
|
CircularIncrement(spriteIndex, SpriteList);
|
||||||
@@ -522,21 +509,20 @@ void ScrollingList::Update(float dt)
|
|||||||
if(scrollStopped || (NotifyAllRequested && Focus))
|
if(scrollStopped || (NotifyAllRequested && Focus))
|
||||||
{
|
{
|
||||||
ComponentItemBinding *sprite = GetPendingCollectionItemSprite();
|
ComponentItemBinding *sprite = GetPendingCollectionItemSprite();
|
||||||
Item *item = NULL;
|
|
||||||
|
|
||||||
if(sprite)
|
if(sprite)
|
||||||
{
|
{
|
||||||
item = sprite->GetCollectionItem();
|
Item *item = sprite->GetCollectionItem();
|
||||||
}
|
|
||||||
|
|
||||||
for(std::vector<MenuNotifierInterface *>::iterator it = NotificationComponents.begin();
|
for(std::vector<MenuNotifierInterface *>::iterator it = NotificationComponents.begin();
|
||||||
it != NotificationComponents.end();
|
it != NotificationComponents.end();
|
||||||
it++)
|
it++)
|
||||||
{
|
|
||||||
MenuNotifierInterface *c = *it;
|
|
||||||
if(c && item)
|
|
||||||
{
|
{
|
||||||
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)
|
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
|
//todo: remove me
|
||||||
if(c && newScroll)
|
if(c && newScroll)
|
||||||
{
|
{
|
||||||
ViewInfo *currentViewInfo = ScrollPoints->at(pointIndex);
|
ViewInfo ¤tViewInfo = ScrollPoints->at(pointIndex);
|
||||||
unsigned int nextI = GetNextTween(pointIndex, ScrollPoints);
|
unsigned int nextI = GetNextTween(pointIndex, ScrollPoints);
|
||||||
ViewInfo *nextViewInfo = ScrollPoints->at(nextI);
|
ViewInfo &nextViewInfo = ScrollPoints->at(nextI);
|
||||||
|
|
||||||
ResetTweens(c, TweenPoints->at(pointIndex), currentViewInfo, nextViewInfo, nextScrollTime);
|
ResetTweens(c, TweenPoints->at(pointIndex), currentViewInfo, nextViewInfo, nextScrollTime);
|
||||||
c->TriggerMenuScrollEvent();
|
c->TriggerMenuScrollEvent();
|
||||||
@@ -579,46 +565,45 @@ void ScrollingList::ResetTweens(Component *c, TweenSets &sets, ViewInfo ¤t
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentViewInfo->SetImageHeight(c->GetBaseViewInfo()->GetImageHeight());
|
currentViewInfo.SetImageHeight(c->GetBaseViewInfo()->GetImageHeight());
|
||||||
currentViewInfo->SetImageWidth(c->GetBaseViewInfo()->GetImageWidth());
|
currentViewInfo.SetImageWidth(c->GetBaseViewInfo()->GetImageWidth());
|
||||||
nextViewInfo->SetImageHeight(c->GetBaseViewInfo()->GetImageHeight());
|
nextViewInfo.SetImageHeight(c->GetBaseViewInfo()->GetImageHeight());
|
||||||
nextViewInfo->SetImageWidth(c->GetBaseViewInfo()->GetImageWidth());
|
nextViewInfo.SetImageWidth(c->GetBaseViewInfo()->GetImageWidth());
|
||||||
nextViewInfo->SetBackgroundAlpha(c->GetBaseViewInfo()->GetBackgroundAlpha());
|
nextViewInfo.SetBackgroundAlpha(c->GetBaseViewInfo()->GetBackgroundAlpha());
|
||||||
|
|
||||||
c->SetTweens(sets);
|
TweenSets::TweenAttributes &scrollTween = sets.GetTween("menuScroll");
|
||||||
|
|
||||||
TweenSets::TweenAttributes &scrollTween = sets->GetTween("menuScroll");
|
|
||||||
TweenSets::TweenAttributes::iterator it = scrollTween->begin();
|
|
||||||
scrollTween.clear();
|
scrollTween.clear();
|
||||||
|
|
||||||
c->UpdateBaseViewInfo(currentViewInfo);
|
c->UpdateBaseViewInfo(currentViewInfo);
|
||||||
|
|
||||||
std::vector<Tween *> set;
|
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(Tween(TWEEN_PROPERTY_HEIGHT, EASE_INOUT_QUADRATIC, currentViewInfo.GetHeight(), nextViewInfo.GetHeight(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_ANGLE, EASE_INOUT_QUADRATIC, currentViewInfo->GetAngle(), nextViewInfo->GetAngle(), scrollTime));
|
set.push_back(Tween(TWEEN_PROPERTY_WIDTH, EASE_INOUT_QUADRATIC, currentViewInfo.GetWidth(), nextViewInfo.GetWidth(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_ALPHA, EASE_INOUT_QUADRATIC, currentViewInfo->GetAlpha(), nextViewInfo->GetAlpha(), scrollTime));
|
set.push_back(Tween(TWEEN_PROPERTY_ANGLE, EASE_INOUT_QUADRATIC, currentViewInfo.GetAngle(), nextViewInfo.GetAngle(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_X, EASE_INOUT_QUADRATIC, currentViewInfo->GetX(), nextViewInfo->GetX(), scrollTime));
|
set.push_back(Tween(TWEEN_PROPERTY_ALPHA, EASE_INOUT_QUADRATIC, currentViewInfo.GetAlpha(), nextViewInfo.GetAlpha(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_Y, EASE_INOUT_QUADRATIC, currentViewInfo->GetY(), nextViewInfo->GetY(), scrollTime));
|
set.push_back(Tween(TWEEN_PROPERTY_X, EASE_INOUT_QUADRATIC, currentViewInfo.GetX(), nextViewInfo.GetX(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_X_ORIGIN, EASE_INOUT_QUADRATIC, currentViewInfo->GetXOrigin(), nextViewInfo->GetXOrigin(), scrollTime));
|
set.push_back(Tween(TWEEN_PROPERTY_Y, EASE_INOUT_QUADRATIC, currentViewInfo.GetY(), nextViewInfo.GetY(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_Y_ORIGIN, EASE_INOUT_QUADRATIC, currentViewInfo->GetYOrigin(), nextViewInfo->GetYOrigin(), scrollTime));
|
set.push_back(Tween(TWEEN_PROPERTY_X_ORIGIN, EASE_INOUT_QUADRATIC, currentViewInfo.GetXOrigin(), nextViewInfo.GetXOrigin(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_X_OFFSET, EASE_INOUT_QUADRATIC, currentViewInfo->GetXOffset(), nextViewInfo->GetXOffset(), scrollTime));
|
set.push_back(Tween(TWEEN_PROPERTY_Y_ORIGIN, EASE_INOUT_QUADRATIC, currentViewInfo.GetYOrigin(), nextViewInfo.GetYOrigin(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_Y_OFFSET, EASE_INOUT_QUADRATIC, currentViewInfo->GetYOffset(), nextViewInfo->GetYOffset(), scrollTime));
|
set.push_back(Tween(TWEEN_PROPERTY_X_OFFSET, EASE_INOUT_QUADRATIC, currentViewInfo.GetXOffset(), nextViewInfo.GetXOffset(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_FONT_SIZE, EASE_INOUT_QUADRATIC, currentViewInfo->GetFontSize(), nextViewInfo->GetFontSize(), scrollTime));
|
set.push_back(Tween(TWEEN_PROPERTY_Y_OFFSET, EASE_INOUT_QUADRATIC, currentViewInfo.GetYOffset(), nextViewInfo.GetYOffset(), scrollTime));
|
||||||
set->push_back(new Tween(TWEEN_PROPERTY_BACKGROUND_ALPHA, EASE_INOUT_QUADRATIC, currentViewInfo->GetBackgroundAlpha(), nextViewInfo->GetBackgroundAlpha(), 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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Item *item = s->GetCollectionItem();
|
Item *item = s.GetCollectionItem();
|
||||||
//todo: will create a runtime fault if not of the right type
|
//todo: will create a runtime fault if not of the right type
|
||||||
//todo: remove coupling from knowing the collection name
|
//todo: remove coupling from knowing the collection name
|
||||||
|
|
||||||
@@ -643,20 +628,20 @@ bool ScrollingList::AllocateTexture(ComponentItemBinding *s)
|
|||||||
|
|
||||||
if(t)
|
if(t)
|
||||||
{
|
{
|
||||||
s->SetComponent(t);
|
s.SetComponent(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
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)
|
//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()
|
void ScrollingList::Draw()
|
||||||
@@ -685,7 +670,7 @@ void ScrollingList::Draw(unsigned int layer)
|
|||||||
for(unsigned int i = 0; i < ScrollPoints->size(); i++)
|
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();
|
||||||
ViewInfo ¤tViewInfo = ScrollPoints->at(i);
|
ViewInfo ¤tViewInfo = ScrollPoints->at(i);
|
||||||
|
|
||||||
if(c && currentViewInfo.GetLayer() == layer)
|
if(c && currentViewInfo.GetLayer() == layer)
|
||||||
@@ -706,32 +691,7 @@ void ScrollingList::SetScrollDirection(ScrollDirection direction)
|
|||||||
|
|
||||||
void ScrollingList::RemoveSelectedItem()
|
void ScrollingList::RemoveSelectedItem()
|
||||||
{
|
{
|
||||||
ComponentItemBinding *sprite = GetSelectedCollectionItemSprite();
|
//todo: implement me
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -745,7 +705,7 @@ ComponentItemBinding* ScrollingList::GetSelectedCollectionItemSprite()
|
|||||||
if(SpriteList && SpriteList->size() > 0)
|
if(SpriteList && SpriteList->size() > 0)
|
||||||
{
|
{
|
||||||
int index = (FirstSpriteIndex + SelectedSpriteListIndex) % SpriteList->size();
|
int index = (FirstSpriteIndex + SelectedSpriteListIndex) % SpriteList->size();
|
||||||
ComponentItemBinding item = &SpriteList->at(index);
|
ComponentItemBinding &item = SpriteList->at(index);
|
||||||
return &item;
|
return &item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -759,7 +719,7 @@ ComponentItemBinding* ScrollingList::GetPendingCollectionItemSprite()
|
|||||||
{
|
{
|
||||||
index = (index + SelectedSpriteListIndex) % SpriteList->size();
|
index = (index + SelectedSpriteListIndex) % SpriteList->size();
|
||||||
|
|
||||||
ComponentItemBinding item = &SpriteList->at(index);
|
ComponentItemBinding &item = SpriteList->at(index);
|
||||||
return &item;
|
return &item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -819,7 +779,7 @@ bool ScrollingList::IsIdle()
|
|||||||
return (Component::IsIdle() && CurrentScrollState == ScrollStateIdle);
|
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++;
|
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)
|
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;
|
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++;
|
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)
|
if(index > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public:
|
|||||||
void TriggerMenuEnterEvent();
|
void TriggerMenuEnterEvent();
|
||||||
void TriggerMenuExitEvent();
|
void TriggerMenuExitEvent();
|
||||||
|
|
||||||
bool AllocateTexture(ComponentItemBinding *s);
|
bool AllocateTexture(ComponentItemBinding &s);
|
||||||
void DeallocateTexture(ComponentItemBinding *s);
|
void DeallocateTexture(ComponentItemBinding &s);
|
||||||
void SetItems(std::vector<ComponentItemBinding> *spriteList);
|
void SetItems(std::vector<ComponentItemBinding> *spriteList);
|
||||||
void DestroyItems();
|
void DestroyItems();
|
||||||
void SetPoints(std::vector<ViewInfo> *scrollPoints, std::vector<TweenSets> *tweenPoints);
|
void SetPoints(std::vector<ViewInfo> *scrollPoints, std::vector<TweenSets> *tweenPoints);
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
ComponentItemBinding *GetPendingSelectedCollectionItemSprite();
|
ComponentItemBinding *GetPendingSelectedCollectionItemSprite();
|
||||||
void AddComponentForNotifications(MenuNotifierInterface *c);
|
void AddComponentForNotifications(MenuNotifierInterface *c);
|
||||||
void RemoveComponentForNotifications(MenuNotifierInterface *c);
|
void RemoveComponentForNotifications(MenuNotifierInterface *c);
|
||||||
std::vector<ComponentItemBinding> GetCollectionItemSprites();
|
std::vector<ComponentItemBinding> *GetCollectionItemSprites();
|
||||||
void RemoveSelectedItem();
|
void RemoveSelectedItem();
|
||||||
void FreeGraphicsMemory();
|
void FreeGraphicsMemory();
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
#include "ComponentItemBinding.h"
|
#include "ComponentItemBinding.h"
|
||||||
|
|
||||||
ComponentItemBinding::ComponentItemBinding( Component *c, Item &item)
|
ComponentItemBinding::ComponentItemBinding( Component *c, Item *item)
|
||||||
: CollectionComponent(c)
|
: CollectionComponent(c)
|
||||||
, CollectionItem(item)
|
, CollectionItem(item)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ComponentItemBinding::ComponentItemBinding(Item &item)
|
ComponentItemBinding::ComponentItemBinding(Item *item)
|
||||||
: CollectionComponent(NULL)
|
: CollectionComponent(NULL)
|
||||||
, CollectionItem(item)
|
, CollectionItem(item)
|
||||||
{
|
{
|
||||||
@@ -31,7 +31,7 @@ ComponentItemBinding::~ComponentItemBinding()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Item &ComponentItemBinding::GetCollectionItem() const
|
Item *ComponentItemBinding::GetCollectionItem()
|
||||||
{
|
{
|
||||||
return CollectionItem;
|
return CollectionItem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@
|
|||||||
class ComponentItemBinding
|
class ComponentItemBinding
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComponentItemBinding(Component *c, Item &item);
|
ComponentItemBinding(Component *c, Item *item);
|
||||||
ComponentItemBinding(Item &item);
|
ComponentItemBinding(Item *item);
|
||||||
virtual ~ComponentItemBinding();
|
virtual ~ComponentItemBinding();
|
||||||
Item &GetCollectionItem() const;
|
Item *GetCollectionItem();
|
||||||
|
|
||||||
void SetComponent(Component *c);
|
void SetComponent(Component *c);
|
||||||
Component* GetComponent() const;
|
Component* GetComponent() const;
|
||||||
@@ -32,5 +32,5 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Component *CollectionComponent;
|
Component *CollectionComponent;
|
||||||
Item CollectionItem;
|
Item *CollectionItem;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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<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);
|
ComponentItemBinding s(*it);
|
||||||
sprites->push_back(s);
|
sprites->push_back(s);
|
||||||
|
|||||||
@@ -26,5 +26,5 @@ class ComponentItemBindingBuilder
|
|||||||
public:
|
public:
|
||||||
ComponentItemBindingBuilder();
|
ComponentItemBindingBuilder();
|
||||||
virtual ~ComponentItemBindingBuilder();
|
virtual ~ComponentItemBindingBuilder();
|
||||||
static std::vector<ComponentItemBinding *> *BuildCollectionItems(std::vector<Item *> *infoList);
|
static std::vector<ComponentItemBinding> *BuildCollectionItems(std::vector<Item *> &infoList);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,14 +69,13 @@ bool Font::Initialize(std::string fontPath, int fontSize, SDL_Color color)
|
|||||||
|
|
||||||
for(unsigned short int i = 32; i < 128; ++i)
|
for(unsigned short int i = 32; i < 128; ++i)
|
||||||
{
|
{
|
||||||
GlyphInfoBuild *info = new GlyphInfoBuild;
|
GlyphInfoBuild info;
|
||||||
memset(info, 0, sizeof(GlyphInfoBuild));
|
|
||||||
|
|
||||||
color.a = 255;
|
color.a = 255;
|
||||||
info->Surface = TTF_RenderGlyph_Blended(font, i, color);
|
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);
|
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;
|
atlasHeight += y;
|
||||||
atlasWidth = (atlasWidth >= x) ? atlasWidth : x;
|
atlasWidth = (atlasWidth >= x) ? atlasWidth : x;
|
||||||
@@ -84,14 +83,14 @@ bool Font::Initialize(std::string fontPath, int fontSize, SDL_Color color)
|
|||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->Glyph.Rect.w = info->Surface->w;
|
info.Glyph.Rect.w = info.Surface->w;
|
||||||
info->Glyph.Rect.h = info->Surface->h;
|
info.Glyph.Rect.h = info.Surface->h;
|
||||||
info->Glyph.Rect.x = x;
|
info.Glyph.Rect.x = x;
|
||||||
info->Glyph.Rect.y = atlasHeight;
|
info.Glyph.Rect.y = atlasHeight;
|
||||||
Atlas[i] = info;
|
Atlas[i] = info;
|
||||||
|
|
||||||
x += info->Glyph.Rect.w;
|
x += info.Glyph.Rect.w;
|
||||||
y = (y > info->Glyph.Rect.h) ? y : info->Glyph.Rect.h;
|
y = (y > info.Glyph.Rect.h) ? y : info.Glyph.Rect.h;
|
||||||
/*
|
/*
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << " tw:" << atlasWidth << " th:" << atlasHeight << " x:" << x << " y:" << y << " w:" << info->Glyph.Rect.w << " h:" << info->Glyph.Rect.h;
|
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;
|
GlyphInfoBuild &info = it->second;
|
||||||
SDL_BlitSurface(info.Surface, NULL, atlasSurface, &info.Glyph.Rect);
|
SDL_BlitSurface(info.Surface, NULL, atlasSurface, &info.Glyph.Rect);
|
||||||
SDL_FreeSurface(info.Surface);
|
SDL_FreeSurface(info.Surface);
|
||||||
info->Surface = NULL;
|
info.Surface = NULL;
|
||||||
}
|
}
|
||||||
SDL_LockMutex(SDL::GetMutex());
|
SDL_LockMutex(SDL::GetMutex());
|
||||||
|
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ void Page::PageScroll(ScrollDirection direction)
|
|||||||
bool Page::PushCollection(CollectionInfo *collection)
|
bool Page::PushCollection(CollectionInfo *collection)
|
||||||
{
|
{
|
||||||
Collections.push_back(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 menuExitIndex = -1;
|
||||||
int menuEnterIndex = -1;
|
int menuEnterIndex = -1;
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ void PageBuilder::LoadTweens(Component *c, xml_node<> *componentXml)
|
|||||||
|
|
||||||
BuildViewInfo(componentXml, v);
|
BuildViewInfo(componentXml, v);
|
||||||
|
|
||||||
c->SetTweens(CreateTweenInstance(componentXml));
|
c->ImportTweens(CreateTweenInstance(componentXml));
|
||||||
}
|
}
|
||||||
|
|
||||||
TweenSets PageBuilder::CreateTweenInstance(xml_node<> *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())
|
if(overrideItems.find(MENU_START) != overrideItems.end())
|
||||||
{
|
{
|
||||||
xml_node<> *component = overrideItems[MENU_START];
|
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);
|
points->push_back(viewInfo);
|
||||||
tweenPoints->push_back(CreateTweenInstance(component));
|
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
|
// 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");
|
xml_attribute<> *itemSpacingXml = component->first_attribute("spacing");
|
||||||
int itemSpacing = itemSpacingXml ? Utils::ConvertInt(itemSpacingXml->value()) : 0;
|
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())
|
if(nextHeight >= menu->GetBaseViewInfo()->GetHeight())
|
||||||
{
|
{
|
||||||
@@ -654,14 +654,14 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm
|
|||||||
{
|
{
|
||||||
component = overrideItems[MENU_LAST];
|
component = overrideItems[MENU_LAST];
|
||||||
|
|
||||||
BuildViewInfo(component, viewInfo, itemDefaults);
|
BuildViewInfo(component, &viewInfo, itemDefaults);
|
||||||
xml_attribute<> *itemSpacingXml = component->first_attribute("spacing");
|
xml_attribute<> *itemSpacingXml = component->first_attribute("spacing");
|
||||||
int itemSpacing = itemSpacingXml ? Utils::ConvertInt(itemSpacingXml->value()) : 0;
|
int itemSpacing = itemSpacingXml ? Utils::ConvertInt(itemSpacingXml->value()) : 0;
|
||||||
nextHeight = height + viewInfo->GetHeight() + itemSpacing;
|
nextHeight = height + viewInfo.GetHeight() + itemSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
height = nextHeight;
|
height = nextHeight;
|
||||||
viewInfo->SetY(menu->GetBaseViewInfo()->GetY() + (float)height);
|
viewInfo.SetY(menu->GetBaseViewInfo()->GetY() + (float)height);
|
||||||
points->push_back(viewInfo);
|
points->push_back(viewInfo);
|
||||||
tweenPoints->push_back(CreateTweenInstance(component));
|
tweenPoints->push_back(CreateTweenInstance(component));
|
||||||
index++;
|
index++;
|
||||||
@@ -671,7 +671,7 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm
|
|||||||
if(overrideItems.find(MENU_END) != overrideItems.end())
|
if(overrideItems.find(MENU_END) != overrideItems.end())
|
||||||
{
|
{
|
||||||
xml_node<> *component = overrideItems[MENU_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);
|
points->push_back(viewInfo);
|
||||||
tweenPoints->push_back(CreateTweenInstance(component));
|
tweenPoints->push_back(CreateTweenInstance(component));
|
||||||
}
|
}
|
||||||
@@ -693,7 +693,7 @@ ViewInfo PageBuilder::CreateMenuItemInfo(xml_node<> *component, xml_node<> *defa
|
|||||||
{
|
{
|
||||||
ViewInfo viewInfo;
|
ViewInfo viewInfo;
|
||||||
BuildViewInfo(component, &viewInfo, defaults);
|
BuildViewInfo(component, &viewInfo, defaults);
|
||||||
viewInfo->SetY(y);
|
viewInfo.SetY(y);
|
||||||
return viewInfo;
|
return viewInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ private:
|
|||||||
std::string LayoutPath;
|
std::string LayoutPath;
|
||||||
Configuration &Config;
|
Configuration &Config;
|
||||||
float ScaleX;
|
float ScaleX;
|
||||||
float ScaleY;->
|
float ScaleY;
|
||||||
int ScreenHeight;
|
int ScreenHeight;
|
||||||
int ScreenWidth;
|
int ScreenWidth;
|
||||||
SDL_Color FontColor;
|
SDL_Color FontColor;
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ CollectionInfo *RetroFE::GetCollection(std::string collectionName)
|
|||||||
CollectionInfoBuilder cib(Config, *MetaDb);
|
CollectionInfoBuilder cib(Config, *MetaDb);
|
||||||
CollectionInfo *collection = cib.BuildCollection(collectionName);
|
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);
|
Logger::Write(Logger::ZONE_WARNING, "RetroFE", "No list items found for collection " + collectionName);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user