mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-07 14:39:02 +01:00
Windows time crashes were caused by unsupported %r parameter. Added
timeFormat attribute to the reloadableText layout element, with a default of %H:%M (<24 hour>:<minutes>).
This commit is contained in:
parent
382edc61f8
commit
4b05992a19
@ -24,7 +24,7 @@
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
|
||||
ReloadableText::ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, float scaleX, float scaleY)
|
||||
ReloadableText::ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, float scaleX, float scaleY)
|
||||
: Component(page)
|
||||
, config_(config)
|
||||
, imageInst_(NULL)
|
||||
@ -33,6 +33,7 @@ ReloadableText::ReloadableText(std::string type, Page &page, Configuration &conf
|
||||
, reloadRequested_(false)
|
||||
, firstLoad_(true)
|
||||
, fontInst_(font)
|
||||
, timeFormat_(timeFormat)
|
||||
, scaleX_(scaleX)
|
||||
, scaleY_(scaleY)
|
||||
{
|
||||
@ -118,7 +119,7 @@ void ReloadableText::ReloadTexture()
|
||||
struct tm tstruct;
|
||||
char buf[80];
|
||||
tstruct = *localtime(&now);
|
||||
strftime(buf, sizeof(buf), "%r", &tstruct);
|
||||
strftime(buf, sizeof(buf), timeFormat_.c_str(), &tstruct);
|
||||
ss << buf;
|
||||
}
|
||||
if (type_ == "numberButtons")
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
class ReloadableText : public Component
|
||||
{
|
||||
public:
|
||||
ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, float scaleX, float scaleY);
|
||||
ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, float scaleX, float scaleY);
|
||||
virtual ~ReloadableText();
|
||||
void update(float dt);
|
||||
void draw();
|
||||
@ -44,6 +44,7 @@ private:
|
||||
bool reloadRequested_;
|
||||
bool firstLoad_;
|
||||
Font *fontInst_;
|
||||
std::string timeFormat_;
|
||||
|
||||
float scaleX_;
|
||||
float scaleY_;
|
||||
|
||||
@ -403,6 +403,7 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
|
||||
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<> *selectedOffsetXml = componentXml->first_attribute("selectedOffset");
|
||||
bool systemMode = false;
|
||||
int selectedOffset = 0;
|
||||
@ -446,7 +447,12 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
|
||||
if(type)
|
||||
{
|
||||
Font *font = addFont(componentXml, NULL);
|
||||
c = new ReloadableText(type->value(), *page, config_, font, layoutKey, scaleX_, scaleY_);
|
||||
std::string timeFormat = "%H:%M";
|
||||
if (timeFormatXml)
|
||||
{
|
||||
timeFormat = timeFormatXml->value();
|
||||
}
|
||||
c = new ReloadableText(type->value(), *page, config_, font, layoutKey, timeFormat, scaleX_, scaleY_);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user