mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-24 23:25:38 +00:00
Improvements to the date and time handling.
This commit is contained in:
parent
3923ad32c6
commit
3ae0726d1a
|
@ -17,7 +17,7 @@ MetaDataDecl gameDecls[] = {
|
|||
{"sortname", MD_STRING, "", false, "sortname", "enter game sort name", false},
|
||||
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true},
|
||||
{"rating", MD_RATING, "0", false, "rating", "enter rating", true},
|
||||
{"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date", true},
|
||||
{"releasedate", MD_DATE, "19700101T010000", false, "release date", "enter release date", true},
|
||||
{"developer", MD_STRING, "unknown", false, "developer", "enter game developer", true},
|
||||
{"publisher", MD_STRING, "unknown", false, "publisher", "enter game publisher", true},
|
||||
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre", true},
|
||||
|
@ -41,7 +41,7 @@ MetaDataDecl folderDecls[] = {
|
|||
{"name", MD_STRING, "", false, "name", "enter game name", true},
|
||||
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true},
|
||||
{"rating", MD_RATING, "0", false, "rating", "enter rating", true},
|
||||
{"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date", true},
|
||||
{"releasedate", MD_DATE, "19700101T010000", false, "release date", "enter release date", true},
|
||||
{"developer", MD_STRING, "unknown", false, "developer", "enter game developer", true},
|
||||
{"publisher", MD_STRING, "unknown", false, "publisher", "enter game publisher", true},
|
||||
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre", true},
|
||||
|
|
|
@ -128,6 +128,7 @@ GuiMetaDataEd::GuiMetaDataEd(
|
|||
row.addElement(spacer, false);
|
||||
|
||||
ed = std::make_shared<DateTimeEditComponent>(window);
|
||||
ed->setOriginalColor(DEFAULT_TEXTCOLOR);
|
||||
ed->setChangedColor(TEXTCOLOR_USERMARKED);
|
||||
row.addElement(ed, false);
|
||||
|
||||
|
@ -430,11 +431,6 @@ void GuiMetaDataEd::close()
|
|||
std::string mMetaDataValue = mMetaData->get(key);
|
||||
std::string mEditorsValue = mEditors.at(i)->getValue();
|
||||
|
||||
// Incredibly ugly workaround to avoid the "SAVE CHANGES?" window for games
|
||||
// with missing release date metadata.
|
||||
if (key == "releasedate" && (mMetaDataValue == "" || mMetaDataValue == "not-a-date-time"))
|
||||
mMetaDataValue = "19700101T010000";
|
||||
|
||||
if (mMetaDataValue != mEditorsValue) {
|
||||
metadataUpdated = true;
|
||||
break;
|
||||
|
|
|
@ -73,6 +73,7 @@ GuiScraperSearch::GuiScraperSearch(
|
|||
mMD_Rating = std::make_shared<RatingComponent>(mWindow);
|
||||
mMD_ReleaseDate = std::make_shared<DateTimeEditComponent>(mWindow);
|
||||
mMD_ReleaseDate->setColor(mdColor);
|
||||
mMD_ReleaseDate->setUppercase(true);
|
||||
mMD_Developer = std::make_shared<TextComponent>(mWindow, "", font, mdColor);
|
||||
mMD_Publisher = std::make_shared<TextComponent>(mWindow, "", font, mdColor);
|
||||
mMD_Genre = std::make_shared<TextComponent>(mWindow, "", font, mdColor);
|
||||
|
|
|
@ -40,12 +40,18 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
|||
if (mDisplayMode != DISP_RELATIVE_TO_NOW) // Don't allow editing for relative times.
|
||||
mEditing = !mEditing;
|
||||
|
||||
// Change the color of the text to reflect the changes.
|
||||
if (mTime == mOriginalValue)
|
||||
setColor(mColorOriginalValue);
|
||||
else
|
||||
setColor(mColorChangedValue);
|
||||
|
||||
if (mEditing) {
|
||||
// Started editing.
|
||||
mTimeBeforeEdit = mTime;
|
||||
|
||||
// Initialize to now if unset.
|
||||
if (mTime.getTime() == Utils::Time::NOT_A_DATE_TIME) {
|
||||
if (mTime.getTime() == Utils::Time::DEFAULT_TIMEVALUE) {
|
||||
mTime = Utils::Time::now();
|
||||
updateTextCache();
|
||||
}
|
||||
|
@ -55,6 +61,11 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
|||
}
|
||||
|
||||
if (mEditing) {
|
||||
|
||||
if (config->isMappedLike("lefttrigger", input) ||
|
||||
config->isMappedLike("righttrigger", input))
|
||||
return true;
|
||||
|
||||
if (config->isMappedTo("b", input)) {
|
||||
mEditing = false;
|
||||
mTime = mTimeBeforeEdit;
|
||||
|
@ -107,12 +118,6 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
|||
|
||||
mTime = new_tm;
|
||||
|
||||
// Change the color of the text to reflect the changes.
|
||||
if (mTime == mOriginalValue)
|
||||
setColor(mColorOriginalValue);
|
||||
else
|
||||
setColor(mColorChangedValue);
|
||||
|
||||
updateTextCache();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Utils
|
|||
tm timeStruct = { 0, 0, 0, 1, 0, 0, 0, 0, -1 };
|
||||
size_t parsedChars = 0;
|
||||
|
||||
if (_string == "not-a-date-time")
|
||||
if (_string == "19700101T010000")
|
||||
return mktime(&timeStruct);
|
||||
|
||||
while (*f && (parsedChars < _string.length())) {
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Utils
|
|||
{
|
||||
namespace Time
|
||||
{
|
||||
static int NOT_A_DATE_TIME = 0;
|
||||
static int DEFAULT_TIMEVALUE = 0;
|
||||
|
||||
class DateTime
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue