mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-15 03:08:52 +01:00
Added support for reloadableText attribute textFormat="uppercase" and
textFormat="lowercase" to print a reloadable string in uppercase or lowercase format.
This commit is contained in:
parent
12aadc729e
commit
50148fa213
@ -23,8 +23,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
ReloadableText::ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, float scaleX, float scaleY)
|
ReloadableText::ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, float scaleX, float scaleY)
|
||||||
: Component(page)
|
: Component(page)
|
||||||
, config_(config)
|
, config_(config)
|
||||||
, imageInst_(NULL)
|
, imageInst_(NULL)
|
||||||
@ -32,6 +33,7 @@ ReloadableText::ReloadableText(std::string type, Page &page, Configuration &conf
|
|||||||
, layoutKey_(layoutKey)
|
, layoutKey_(layoutKey)
|
||||||
, fontInst_(font)
|
, fontInst_(font)
|
||||||
, timeFormat_(timeFormat)
|
, timeFormat_(timeFormat)
|
||||||
|
, textFormat_(textFormat)
|
||||||
, scaleX_(scaleX)
|
, scaleX_(scaleX)
|
||||||
, scaleY_(scaleY)
|
, scaleY_(scaleY)
|
||||||
{
|
{
|
||||||
@ -100,7 +102,7 @@ void ReloadableText::ReloadTexture()
|
|||||||
if (selectedItem != NULL)
|
if (selectedItem != NULL)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::string text;
|
std::string text = "";
|
||||||
if (type_ == "time")
|
if (type_ == "time")
|
||||||
{
|
{
|
||||||
time_t now = time(0);
|
time_t now = time(0);
|
||||||
@ -133,9 +135,9 @@ void ReloadableText::ReloadTexture()
|
|||||||
if (selectedItem->numberPlayers != "")
|
if (selectedItem->numberPlayers != "")
|
||||||
{
|
{
|
||||||
if (selectedItem->numberPlayers == "1")
|
if (selectedItem->numberPlayers == "1")
|
||||||
ss << " Player";
|
text = " Player";
|
||||||
else
|
else
|
||||||
ss << " Players";
|
text = " Players";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type_ == "numberPlayersRangePlayers")
|
else if (type_ == "numberPlayersRangePlayers")
|
||||||
@ -149,9 +151,9 @@ void ReloadableText::ReloadTexture()
|
|||||||
if (selectedItem->numberPlayers != "")
|
if (selectedItem->numberPlayers != "")
|
||||||
{
|
{
|
||||||
if (selectedItem->numberPlayers == "1")
|
if (selectedItem->numberPlayers == "1")
|
||||||
ss << " Player";
|
text = " Player";
|
||||||
else
|
else
|
||||||
ss << " Players";
|
text = " Players";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type_ == "ctrlType")
|
else if (type_ == "ctrlType")
|
||||||
@ -172,7 +174,6 @@ void ReloadableText::ReloadTexture()
|
|||||||
text = selectedItem->year;
|
text = selectedItem->year;
|
||||||
else // item is a collection
|
else // item is a collection
|
||||||
(void)config_.getProperty("collections." + selectedItem->name + ".year", text );
|
(void)config_.getProperty("collections." + selectedItem->name + ".year", text );
|
||||||
ss << text;
|
|
||||||
}
|
}
|
||||||
else if (type_ == "title")
|
else if (type_ == "title")
|
||||||
{
|
{
|
||||||
@ -184,7 +185,6 @@ void ReloadableText::ReloadTexture()
|
|||||||
text = selectedItem->manufacturer;
|
text = selectedItem->manufacturer;
|
||||||
else // item is a collection
|
else // item is a collection
|
||||||
(void)config_.getProperty("collections." + selectedItem->name + ".manufacturer", text );
|
(void)config_.getProperty("collections." + selectedItem->name + ".manufacturer", text );
|
||||||
ss << text;
|
|
||||||
}
|
}
|
||||||
else if (type_ == "genre")
|
else if (type_ == "genre")
|
||||||
{
|
{
|
||||||
@ -192,7 +192,6 @@ void ReloadableText::ReloadTexture()
|
|||||||
text = selectedItem->genre;
|
text = selectedItem->genre;
|
||||||
else // item is a collection
|
else // item is a collection
|
||||||
(void)config_.getProperty("collections." + selectedItem->name + ".genre", text );
|
(void)config_.getProperty("collections." + selectedItem->name + ".genre", text );
|
||||||
ss << text;
|
|
||||||
}
|
}
|
||||||
else if (type_ == "playlist")
|
else if (type_ == "playlist")
|
||||||
{
|
{
|
||||||
@ -212,6 +211,18 @@ void ReloadableText::ReloadTexture()
|
|||||||
} else if (!selectedItem->leaf) // item is not a leaf
|
} else if (!selectedItem->leaf) // item is not a leaf
|
||||||
{
|
{
|
||||||
(void)config_.getProperty("collections." + selectedItem->name + "." + type_, text );
|
(void)config_.getProperty("collections." + selectedItem->name + "." + type_, text );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text != "")
|
||||||
|
{
|
||||||
|
if (textFormat_ == "uppercase")
|
||||||
|
{
|
||||||
|
std::transform(text.begin(), text.end(), text.begin(), ::toupper);
|
||||||
|
}
|
||||||
|
if (textFormat_ == "lowercase")
|
||||||
|
{
|
||||||
|
std::transform(text.begin(), text.end(), text.begin(), ::tolower);
|
||||||
|
}
|
||||||
ss << text;
|
ss << text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
class ReloadableText : public Component
|
class ReloadableText : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, float scaleX, float scaleY);
|
ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, float scaleX, float scaleY);
|
||||||
virtual ~ReloadableText();
|
virtual ~ReloadableText();
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
void draw();
|
void draw();
|
||||||
@ -43,6 +43,7 @@ private:
|
|||||||
std::string layoutKey_;
|
std::string layoutKey_;
|
||||||
Font *fontInst_;
|
Font *fontInst_;
|
||||||
std::string timeFormat_;
|
std::string timeFormat_;
|
||||||
|
std::string textFormat_;
|
||||||
|
|
||||||
float scaleX_;
|
float scaleX_;
|
||||||
float scaleY_;
|
float scaleY_;
|
||||||
|
|||||||
@ -412,6 +412,7 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
|
|||||||
xml_attribute<> *type = componentXml->first_attribute("type");
|
xml_attribute<> *type = componentXml->first_attribute("type");
|
||||||
xml_attribute<> *mode = componentXml->first_attribute("mode");
|
xml_attribute<> *mode = componentXml->first_attribute("mode");
|
||||||
xml_attribute<> *timeFormatXml = componentXml->first_attribute("timeFormat");
|
xml_attribute<> *timeFormatXml = componentXml->first_attribute("timeFormat");
|
||||||
|
xml_attribute<> *textFormatXml = componentXml->first_attribute("textFormat");
|
||||||
xml_attribute<> *selectedOffsetXml = componentXml->first_attribute("selectedOffset");
|
xml_attribute<> *selectedOffsetXml = componentXml->first_attribute("selectedOffset");
|
||||||
bool systemMode = false;
|
bool systemMode = false;
|
||||||
bool layoutMode = false;
|
bool layoutMode = false;
|
||||||
@ -470,7 +471,12 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
|
|||||||
{
|
{
|
||||||
timeFormat = timeFormatXml->value();
|
timeFormat = timeFormatXml->value();
|
||||||
}
|
}
|
||||||
c = new ReloadableText(type->value(), *page, config_, font, layoutKey, timeFormat, scaleX_, scaleY_);
|
std::string textFormat = "";
|
||||||
|
if (textFormatXml)
|
||||||
|
{
|
||||||
|
textFormat = textFormatXml->value();
|
||||||
|
}
|
||||||
|
c = new ReloadableText(type->value(), *page, config_, font, layoutKey, timeFormat, textFormat, scaleX_, scaleY_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user