mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-26 17:54:46 +01:00
ReloadableText support for collectionName, collectionSize, and collectionIndex
This commit is contained in:
parent
c19669e381
commit
a5ef2bdcbc
@ -23,8 +23,9 @@
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include "Component.h"
|
||||
#include "Text.h"
|
||||
#include "../Font.h"
|
||||
#include "../Page.h"
|
||||
#include "../../Collection/Item.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <string>
|
||||
@ -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_;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -60,6 +60,8 @@ public:
|
||||
void destroyItems();
|
||||
void setPoints(std::vector<ViewInfo *> *scrollPoints, std::vector<AnimationEvents *> *tweenPoints);
|
||||
void setScrollDirection(ScrollDirection direction);
|
||||
unsigned int getSelectedIndex();
|
||||
unsigned int getSize();
|
||||
void pageUp();
|
||||
void pageDown();
|
||||
void letterUp();
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user