-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to maintain and persist <folder/> information in a gamelist: #841
Conversation
As it involved several files I will comment on the crucial changes. |
@@ -127,7 +137,7 @@ void parseGamelist(SystemData* system) | |||
} | |||
|
|||
// Check whether the file's extension is allowed in the system | |||
if (std::find(allowedExtensions.cbegin(), allowedExtensions.cend(), Utils::FileSystem::getExtension(path)) == allowedExtensions.cend()) | |||
if (i == 0 /*game*/ && std::find(allowedExtensions.cbegin(), allowedExtensions.cend(), Utils::FileSystem::getExtension(path)) == allowedExtensions.cend()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only be strict on type game FileData, without this check no elements will be loaded into ES from the gamelist.
@@ -142,7 +152,7 @@ void parseGamelist(SystemData* system) | |||
else if(!file->isArcadeAsset()) | |||
{ | |||
std::string defaultName = file->metadata.get("name"); | |||
file->metadata = MetaDataList::createFromXML(GAME_METADATA, fileNode, relativeTo); | |||
file->metadata = MetaDataList::createFromXML(i == 0 ? GAME_METADATA : FOLDER_METADATA, fileNode, relativeTo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flag got mandatory to differentiate between recognized subelements of and
es-app/src/MetaData.cpp
Outdated
{"publisher", MD_STRING, "unknown", false, "publisher", "enter game publisher"}, | ||
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre"}, | ||
{"players", MD_INT, "1", false, "players", "enter number of players"} | ||
{"rating", MD_RATING, "", true, "rating", "enter rating"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hide (statistics=true) some elements for editing and define default values when not defined in XML. 1970-01-02 was picked as 1970-01-01 is already taken for games without : "not-a-date-time" will put 1970-01-01 which then is rendered as "unknown". As a folder most of the time has not releasdate I wanted it to render as blank, this is what 1970-01-02 serves for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the decision, but I am not fully thrilled with the approach here. 1970-01-01 is, effectively, a null date. 1970-01-02 is an actual value that we are choosing to have a different behavior. It's pretty much begging to be caught in an edge case at some point in time when nobody else knows why it was here and what for :)
What other options could we have here, potentially even reusing 1970-01-01?
Also, happy new year!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, hope you started well too.
I have considered to reuse 1970-01-01 in some form, but the crucial part is that the flag folder/game is only available in the Metadata / Metadatalist class (which is used by the Filedata class). For rendering it is then applied to Datetimecomponent class (setValue()) e.g. in Detailgamelistview class. In the setValue() is then the display format decided (in getDisplayString()).
Which means to me one must either put render/display information in the Metadataclass and or overload the setValue() to allow a Game/Folder flag for reusing 1970-01-01 to be displayed as "" for folders.
Neither path did not make sense to me. Thus I have chosen 1970-01-02.
On a folder the releasedate information can not be edited from within ES. An user must set it deliberately via gamlist editing.
I also assume there will be no game released on one of these two dates for any system which are also supported by ES.
However, if users want one of these dates displayed (instead of "unknown"/""), they could append a non zero time to the releasedate (again via gamelist.xml editing).
I made the reference/usage of 1970-01-02 more coherent, by referring to the constant. The usage can be more easily reconstructed with grep or an IDE.
HTH
Epilogue: I found some corner cases which promted the user to "Save changes?" even when there are no changes (an efffect that the initial author assumed that any statistical (non editable) value are at the end of the MetaDataDecl (in Metadata.class). I fixed it to be more robust, when statistical values are in between.
I also noted that the releasedate in die ES editor rolls over at the end of the 32bit Unix-time-epoch. But that is a different story. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
// create ed and add it (and any related components) to mMenu | ||
// ed's value will be set below | ||
ComponentListRow row; | ||
auto lbl = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(iter->displayName), Font::get(FONT_SIZE_SMALL), 0x777777FF); | ||
auto lblTxt = Utils::String::toUpper(iter->displayName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a hint about the date format, as the MM/DD/YY can be confusing if the day-of-month is less than 12.
@@ -111,6 +117,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector | |||
{ | |||
// MD_STRING | |||
ed = std::make_shared<TextComponent>(window, "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT); | |||
const float height = lbl->getSize().y() * 0.71f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one fixes the text misalignment after editing a metadata.
@@ -47,9 +49,13 @@ void DateTimeComponent::onTextChanged() | |||
|
|||
std::string DateTimeComponent::getDisplayString() const | |||
{ | |||
if(std::difftime(mTime.getTime(), Utils::Time::BLANK_DATE) == 0.0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If 1970-01-02 then render blank.
5f6acec
to
c87b0b7
Compare
@Gemba pinging this, in case you were waiting for me to make progress here. I am ok with the changes, just had the couple minor questions I added there. No pressure though - just wanted to make sure this wasn't in a limbo because of me. Have a great weekend. |
Thanks. I have read through this issue twice. Did I miss a question to answer? I you can recap the one(s) which escaped my attention it would be nice. |
Sure. Main questions I had:
|
c87b0b7
to
8c554e0
Compare
You are right. Well spotted. Done.
It was more an assumption of mine. I don't stick to that. Enabled the rating edit on folders. Thanks for nudging me. |
Thanks. I just tested this and, from what I was able to test on my end, I'm good with merging. Just a minor question I asked regarding a label, but I'm good to go next. I don't have folders on my setup, though, so it should be test run by more in the community if you can share it there! |
Will ask for more testers in the forum. Just let me know: Before the merge or after the merge? |
Afterwards is fine, it's just to make sure the different scenarios get covered. Do check my comment on the variable and squash as appropriate. Let me know when it's good to go. |
Ok.
I sure will. But I am really sorry to bother you again, I cannot spot your comment on the label/variable. Would you be so kind to highlight/repeat it? Thanks. |
GuiMetaDataEd.cpp:41 - why ROM and not GAME? |
Ah. Thanks. I put "ROM" here deliberatly as the filename with extension will be shown. The ROM's display title is shown first in the edit fields. |
If I'm reading this correctly, then we should probably keep GAME for a few reasons:
A bit long, apologies, but hopefully will relay where I'm coming from here. |
1. folder elements are loaded when present in a gamelist and if they match the filesystem representation 2. missing optional folder elements are rendered empty in theme (and not "unknown") 3. As before non-existing folder elements are generated by ES, with mandatory elements <path/> and <name/>, but with this PR, whenever metadata is edited for this folder object (FileData class) it is persisted 4. Editiing metadata on existing <folder/> gets persisted too 5. UI metadata edit: layout fix that renders entered metadata not centered when returning from editing 6. UI metadata edit: format tooltip for date format in release date field
8c554e0
to
a113b22
Compare
I am ok with your justification, better avoid "surprises" for the end-user and step-back a little on technical preciseness. Did adjust the subtitle to "GAME: ..." |
Thank you. |
Relates to the PR RetroPie#841 after the discussion in RetroPie#861, but code changes only needed in Skyscraper.
<path/>
and<name/>
, but with this PR, whenever metadata is edited for this folder object (FileData class) it is persisted<folder/>
gets persisted too