From a5ef2bdcbcdf20b74bb6729c9c390ad4b4649b20 Mon Sep 17 00:00:00 2001 From: emb <> Date: Thu, 22 Oct 2015 22:04:28 -0500 Subject: [PATCH] ReloadableText support for collectionName, collectionSize, and collectionIndex --- .../Graphics/Component/ReloadableText.cpp | 32 +++++++++++++++++-- .../Graphics/Component/ReloadableText.h | 7 +++- .../Graphics/Component/ScrollingList.cpp | 13 ++++++++ .../Source/Graphics/Component/ScrollingList.h | 2 ++ RetroFE/Source/Graphics/Page.cpp | 10 ++++++ RetroFE/Source/Graphics/Page.h | 2 ++ RetroFE/Source/Graphics/PageBuilder.cpp | 2 +- 7 files changed, 64 insertions(+), 4 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ReloadableText.cpp b/RetroFE/Source/Graphics/Component/ReloadableText.cpp index b8454d1..430a274 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableText.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableText.cpp @@ -23,8 +23,9 @@ #include #include -ReloadableText::ReloadableText(std::string type, Font *font, std::string layoutKey, float scaleX, float scaleY) +ReloadableText::ReloadableText(std::string type, Page *page, Font *font, std::string layoutKey, float scaleX, float scaleY) : imageInst_(NULL) + , page_(page) , layoutKey_(layoutKey) , reloadRequested_(false) , firstLoad_(true) @@ -63,7 +64,18 @@ ReloadableText::ReloadableText(std::string type, Font *font, std::string layoutK { type_ = TextTypePlaylist; } - + else if(type == "collectionName") + { + type_ = TextTypeCollectionName; + } + else if(type == "collectionSize") + { + type_ = TextTypeCollectionSize; + } + else if(type == "collectionIndex") + { + type_ = TextTypeCollectionIndex; + } allocateGraphicsMemory(); } @@ -162,6 +174,22 @@ void ReloadableText::ReloadTexture() case TextTypePlaylist: ss << playlistName; break; + case TextTypeCollectionName: + if (page_ != NULL) { + ss << page_->getCollectionName(); + } + break; + case TextTypeCollectionSize: + if (page_ != NULL) { + ss << page_->getCollectionSize(); + } + break; + case TextTypeCollectionIndex: + if (page_ != NULL) { + ss << (1+page_->getSelectedIndex()); + } + break; + default: break; } diff --git a/RetroFE/Source/Graphics/Component/ReloadableText.h b/RetroFE/Source/Graphics/Component/ReloadableText.h index 578ad9f..608026b 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableText.h +++ b/RetroFE/Source/Graphics/Component/ReloadableText.h @@ -17,6 +17,7 @@ #include "Component.h" #include "Text.h" #include "../Font.h" +#include "../Page.h" #include "../../Collection/Item.h" #include #include @@ -24,7 +25,7 @@ class ReloadableText : public Component { public: - ReloadableText(std::string type, Font *font, std::string layoutKey, float scaleX, float scaleY); + ReloadableText(std::string type, Page *page, Font *font, std::string layoutKey, float scaleX, float scaleY); virtual ~ReloadableText(); void update(float dt); void draw(); @@ -44,12 +45,16 @@ private: TextTypeManufacturer, TextTypeGenre, TextTypePlaylist, + TextTypeCollectionName, + TextTypeCollectionSize, + TextTypeCollectionIndex }; void ReloadTexture(); Text *imageInst_; TextType type_; + Page *page_; std::string layoutKey_; bool reloadRequested_; bool firstLoad_; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index ca9c5fd..f8f5da3 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -501,6 +501,19 @@ void ScrollingList::update(float dt) notifyAllRequested_ = false; } +unsigned int ScrollingList::getSelectedIndex() +{ + if(!items_) return 0; + return loopIncrement(itemIndex_, selectedOffsetIndex_, items_->size()); +} + +unsigned int ScrollingList::getSize() +{ + if(!items_) return 0; + + return items_->size(); +} + void ScrollingList::resetTweens(Component *c, AnimationEvents *sets, ViewInfo *currentViewInfo, ViewInfo *nextViewInfo, double scrollTime) { if(!c) return; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 798b3ce..3702cb9 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -60,6 +60,8 @@ public: void destroyItems(); void setPoints(std::vector *scrollPoints, std::vector *tweenPoints); void setScrollDirection(ScrollDirection direction); + unsigned int getSelectedIndex(); + unsigned int getSize(); void pageUp(); void pageDown(); void letterUp(); diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 6776caf..d2c0c07 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -440,6 +440,16 @@ void Page::letterScroll(ScrollDirection direction) } } +unsigned int Page::getCollectionSize() +{ + return activeMenu_->getSize(); +} + +unsigned int Page::getSelectedIndex() +{ + return activeMenu_->getSelectedIndex(); +} + bool Page::pushCollection(CollectionInfo *collection) { diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index 6ac2a8b..852fc9e 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -56,6 +56,8 @@ public: bool addComponent(Component *c); void pageScroll(ScrollDirection direction); void letterScroll(ScrollDirection direction); + unsigned int getCollectionSize(); + unsigned int getSelectedIndex(); void selectRandom(); void start(); void startComponents(); diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index e912ccc..f6b94d8 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -438,7 +438,7 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName, if(type) { Font *font = addFont(componentXml, NULL); - c = new ReloadableText(type->value(), font, layoutKey, scaleX_, scaleY_); + c = new ReloadableText(type->value(), page, font, layoutKey, scaleX_, scaleY_); } } else