mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-26 17:54:46 +01:00
Replaced numberPlayersRange, numberPlayersPlayers, and numberPlayersRangePlayers types with more general singlePrefix, single Postfix, pluralPrefix, and pluralPostfix attributes for reloadableText. This prints as follows:
printed text = 0: singlePrefix text pluralPostfix printed text = 1: singlePrefix text singlePostfix otherwise : pluralPrefix text pluralPostfix This allows support for themes in different languages or simply textual printing freedom.
This commit is contained in:
parent
5bc67f72fb
commit
da0fe6c299
@ -25,7 +25,7 @@
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
|
||||
ReloadableText::ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, float scaleX, float scaleY)
|
||||
ReloadableText::ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, std::string singlePrefix, std::string singlePostfix, std::string pluralPrefix, std::string pluralPostfix, float scaleX, float scaleY)
|
||||
: Component(page)
|
||||
, config_(config)
|
||||
, imageInst_(NULL)
|
||||
@ -34,6 +34,10 @@ ReloadableText::ReloadableText(std::string type, Page &page, Configuration &conf
|
||||
, fontInst_(font)
|
||||
, timeFormat_(timeFormat)
|
||||
, textFormat_(textFormat)
|
||||
, singlePrefix_(singlePrefix)
|
||||
, singlePostfix_(singlePostfix)
|
||||
, pluralPrefix_(pluralPrefix)
|
||||
, pluralPostfix_(pluralPostfix)
|
||||
, scaleX_(scaleX)
|
||||
, scaleY_(scaleY)
|
||||
{
|
||||
@ -114,47 +118,11 @@ void ReloadableText::ReloadTexture()
|
||||
}
|
||||
if (type_ == "numberButtons")
|
||||
{
|
||||
ss << selectedItem->numberButtons;
|
||||
text = selectedItem->numberButtons;
|
||||
}
|
||||
else if (type_ == "numberPlayers")
|
||||
{
|
||||
ss << selectedItem->numberPlayers;
|
||||
}
|
||||
else if (type_ == "numberPlayersRange")
|
||||
{
|
||||
if (selectedItem->numberPlayers != "" &&
|
||||
selectedItem->numberPlayers != "0" &&
|
||||
selectedItem->numberPlayers != "1")
|
||||
ss << "1-" << selectedItem->numberPlayers;
|
||||
else
|
||||
ss << selectedItem->numberPlayers;
|
||||
}
|
||||
else if (type_ == "numberPlayersPlayers")
|
||||
{
|
||||
ss << selectedItem->numberPlayers;
|
||||
if (selectedItem->numberPlayers != "")
|
||||
{
|
||||
if (selectedItem->numberPlayers == "1")
|
||||
text = " Player";
|
||||
else
|
||||
text = " Players";
|
||||
}
|
||||
}
|
||||
else if (type_ == "numberPlayersRangePlayers")
|
||||
{
|
||||
if (selectedItem->numberPlayers != "" &&
|
||||
selectedItem->numberPlayers != "0" &&
|
||||
selectedItem->numberPlayers != "1")
|
||||
ss << "1-" << selectedItem->numberPlayers;
|
||||
else
|
||||
ss << selectedItem->numberPlayers;
|
||||
if (selectedItem->numberPlayers != "")
|
||||
{
|
||||
if (selectedItem->numberPlayers == "1")
|
||||
text = " Player";
|
||||
else
|
||||
text = " Players";
|
||||
}
|
||||
text = selectedItem->numberPlayers;
|
||||
}
|
||||
else if (type_ == "ctrlType")
|
||||
{
|
||||
@ -203,16 +171,51 @@ void ReloadableText::ReloadTexture()
|
||||
}
|
||||
else if (type_ == "collectionSize")
|
||||
{
|
||||
ss << page.getCollectionSize();
|
||||
if (page.getCollectionSize() == 0)
|
||||
{
|
||||
ss << singlePrefix_ << page.getCollectionSize() << pluralPostfix_;
|
||||
}
|
||||
else if (page.getCollectionSize() == 1)
|
||||
{
|
||||
ss << singlePrefix_ << page.getCollectionSize() << singlePostfix_;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << pluralPrefix_ << page.getCollectionSize() << pluralPostfix_;
|
||||
}
|
||||
}
|
||||
else if (type_ == "collectionIndex")
|
||||
{
|
||||
ss << (1+page.getSelectedIndex());
|
||||
if (page.getSelectedIndex() == 0)
|
||||
{
|
||||
ss << singlePrefix_ << page.getSelectedIndex() << pluralPostfix_;
|
||||
}
|
||||
else if (page.getSelectedIndex() == 1)
|
||||
{
|
||||
ss << singlePrefix_ << page.getSelectedIndex() << singlePostfix_;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << pluralPrefix_ << page.getSelectedIndex() << pluralPostfix_;
|
||||
}
|
||||
} else if (!selectedItem->leaf) // item is not a leaf
|
||||
{
|
||||
(void)config_.getProperty("collections." + selectedItem->name + "." + type_, text );
|
||||
}
|
||||
|
||||
if (text == "0")
|
||||
{
|
||||
text = singlePrefix_ + text + pluralPostfix_;
|
||||
}
|
||||
else if (text == "1")
|
||||
{
|
||||
text = singlePrefix_ + text + singlePostfix_;
|
||||
}
|
||||
else if (text != "")
|
||||
{
|
||||
text = pluralPrefix_ + text + pluralPostfix_;
|
||||
}
|
||||
|
||||
if (text != "")
|
||||
{
|
||||
if (textFormat_ == "uppercase")
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
class ReloadableText : public Component
|
||||
{
|
||||
public:
|
||||
ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, float scaleX, float scaleY);
|
||||
ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, std::string singlePrefix, std::string singlePostfix, std::string pluralPrefix, std::string pluralPostfix, float scaleX, float scaleY);
|
||||
virtual ~ReloadableText();
|
||||
void update(float dt);
|
||||
void draw();
|
||||
@ -44,6 +44,10 @@ private:
|
||||
Font *fontInst_;
|
||||
std::string timeFormat_;
|
||||
std::string textFormat_;
|
||||
std::string singlePrefix_;
|
||||
std::string singlePostfix_;
|
||||
std::string pluralPrefix_;
|
||||
std::string pluralPostfix_;
|
||||
|
||||
float scaleX_;
|
||||
float scaleY_;
|
||||
|
||||
@ -413,10 +413,14 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
|
||||
{
|
||||
std::string reloadableImagePath;
|
||||
std::string reloadableVideoPath;
|
||||
xml_attribute<> *type = componentXml->first_attribute("type");
|
||||
xml_attribute<> *mode = componentXml->first_attribute("mode");
|
||||
xml_attribute<> *timeFormatXml = componentXml->first_attribute("timeFormat");
|
||||
xml_attribute<> *textFormatXml = componentXml->first_attribute("textFormat");
|
||||
xml_attribute<> *type = componentXml->first_attribute("type");
|
||||
xml_attribute<> *mode = componentXml->first_attribute("mode");
|
||||
xml_attribute<> *timeFormatXml = componentXml->first_attribute("timeFormat");
|
||||
xml_attribute<> *textFormatXml = componentXml->first_attribute("textFormat");
|
||||
xml_attribute<> *singlePrefixXml = componentXml->first_attribute("singlePrefix");
|
||||
xml_attribute<> *singlePostfixXml = componentXml->first_attribute("singlePostfix");
|
||||
xml_attribute<> *pluralPrefixXml = componentXml->first_attribute("pluralPrefix");
|
||||
xml_attribute<> *pluralPostfixXml = componentXml->first_attribute("pluralPostfix");
|
||||
xml_attribute<> *selectedOffsetXml = componentXml->first_attribute("selectedOffset");
|
||||
bool systemMode = false;
|
||||
bool layoutMode = false;
|
||||
@ -473,14 +477,34 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
|
||||
std::string timeFormat = "%H:%M";
|
||||
if (timeFormatXml)
|
||||
{
|
||||
timeFormat = timeFormatXml->value();
|
||||
timeFormat = timeFormatXml->value();
|
||||
}
|
||||
std::string textFormat = "";
|
||||
if (textFormatXml)
|
||||
{
|
||||
textFormat = textFormatXml->value();
|
||||
textFormat = textFormatXml->value();
|
||||
}
|
||||
c = new ReloadableText(type->value(), *page, config_, font, layoutKey, timeFormat, textFormat, scaleX_, scaleY_);
|
||||
std::string singlePrefix = "";
|
||||
if (singlePrefixXml)
|
||||
{
|
||||
singlePrefix = singlePrefixXml->value();
|
||||
}
|
||||
std::string singlePostfix = "";
|
||||
if (singlePostfixXml)
|
||||
{
|
||||
singlePostfix = singlePostfixXml->value();
|
||||
}
|
||||
std::string pluralPrefix = "";
|
||||
if (pluralPrefixXml)
|
||||
{
|
||||
pluralPrefix = pluralPrefixXml->value();
|
||||
}
|
||||
std::string pluralPostfix = "";
|
||||
if (pluralPostfixXml)
|
||||
{
|
||||
pluralPostfix = pluralPostfixXml->value();
|
||||
}
|
||||
c = new ReloadableText(type->value(), *page, config_, font, layoutKey, timeFormat, textFormat, singlePrefix, singlePostfix, pluralPrefix, pluralPostfix, scaleX_, scaleY_);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user