Made the sort order and the metadata editor fields a bit more consistent.

This commit is contained in:
Leon Styhre 2021-01-08 21:36:43 +01:00
parent 23dd5b838f
commit fc69a2942f
4 changed files with 28 additions and 28 deletions

View file

@ -1059,8 +1059,8 @@ Sorting can be applied using the following metadata, in either ascending or desc
* Publisher * Publisher
* Genre * Genre
* Players * Players
* Times played
* Last played * Last played
* Times played
* System _(Only for collections)_ * System _(Only for collections)_
The secondary sorting is always in ascending filename order. The secondary sorting is always in ascending filename order.

View file

@ -38,12 +38,12 @@ namespace FileSorts
FileData::SortType(&compareNumPlayers, "players, ascending"), FileData::SortType(&compareNumPlayers, "players, ascending"),
FileData::SortType(&compareNumPlayersDescending, "players, descending"), FileData::SortType(&compareNumPlayersDescending, "players, descending"),
FileData::SortType(&compareTimesPlayed, "times played, ascending"),
FileData::SortType(&compareTimesPlayedDescending, "times played, descending"),
FileData::SortType(&compareLastPlayed, "last played, ascending"), FileData::SortType(&compareLastPlayed, "last played, ascending"),
FileData::SortType(&compareLastPlayedDescending, "last played, descending"), FileData::SortType(&compareLastPlayedDescending, "last played, descending"),
FileData::SortType(&compareTimesPlayed, "times played, ascending"),
FileData::SortType(&compareTimesPlayedDescending, "times played, descending"),
FileData::SortType(&compareSystem, "system, ascending"), FileData::SortType(&compareSystem, "system, ascending"),
FileData::SortType(&compareSystemDescending, "system, descending") FileData::SortType(&compareSystemDescending, "system, descending")
}; };
@ -185,6 +185,18 @@ namespace FileSorts
return file1Int > file2Int; return file1Int > file2Int;
} }
bool compareLastPlayed(const FileData* file1, const FileData* file2)
{
// Since it's stored as an ISO string (YYYYMMDDTHHMMSS), we can compare as a string
// which is a lot faster than the time casts and the time comparisons.
return (file1)->metadata.get("lastplayed") > (file2)->metadata.get("lastplayed");
}
bool compareLastPlayedDescending(const FileData* file1, const FileData* file2)
{
return (file1)->metadata.get("lastplayed") < (file2)->metadata.get("lastplayed");
}
bool compareTimesPlayed(const FileData* file1, const FileData* file2) bool compareTimesPlayed(const FileData* file1, const FileData* file2)
{ {
// Only games have playcount metadata. // Only games have playcount metadata.
@ -202,18 +214,6 @@ namespace FileSorts
return false; return false;
} }
bool compareLastPlayed(const FileData* file1, const FileData* file2)
{
// Since it's stored as an ISO string (YYYYMMDDTHHMMSS), we can compare as a string
// which is a lot faster than the time casts and the time comparisons.
return (file1)->metadata.get("lastplayed") > (file2)->metadata.get("lastplayed");
}
bool compareLastPlayedDescending(const FileData* file1, const FileData* file2)
{
return (file1)->metadata.get("lastplayed") < (file2)->metadata.get("lastplayed");
}
bool compareSystem(const FileData* file1, const FileData* file2) bool compareSystem(const FileData* file1, const FileData* file2)
{ {
std::string system1 = Utils::String::toUpper(file1->getSystemName()); std::string system1 = Utils::String::toUpper(file1->getSystemName());

View file

@ -30,10 +30,10 @@ namespace FileSorts
bool compareGenreDescending(const FileData* file1, const FileData* file2); bool compareGenreDescending(const FileData* file1, const FileData* file2);
bool compareNumPlayers(const FileData* file1, const FileData* file2); bool compareNumPlayers(const FileData* file1, const FileData* file2);
bool compareNumPlayersDescending(const FileData* file1, const FileData* file2); bool compareNumPlayersDescending(const FileData* file1, const FileData* file2);
bool compareTimesPlayed(const FileData* file1, const FileData* fil2);
bool compareTimesPlayedDescending(const FileData* file1, const FileData* fil2);
bool compareLastPlayed(const FileData* file1, const FileData* file2); bool compareLastPlayed(const FileData* file1, const FileData* file2);
bool compareLastPlayedDescending(const FileData* file1, const FileData* file2); bool compareLastPlayedDescending(const FileData* file1, const FileData* file2);
bool compareTimesPlayed(const FileData* file1, const FileData* fil2);
bool compareTimesPlayedDescending(const FileData* file1, const FileData* fil2);
bool compareSystem(const FileData* file1, const FileData* file2); bool compareSystem(const FileData* file1, const FileData* file2);
bool compareSystemDescending(const FileData* file1, const FileData* file2); bool compareSystemDescending(const FileData* file1, const FileData* file2);

View file

@ -16,14 +16,14 @@
MetaDataDecl gameDecls[] = { MetaDataDecl gameDecls[] = {
// key, type, default, statistic, name in GuiMetaDataEd, prompt in GuiMetaDataEd, shouldScrape // key, type, default, statistic, name in GuiMetaDataEd, prompt in GuiMetaDataEd, shouldScrape
{"name", MD_STRING, "", false, "name", "enter game name", true}, {"name", MD_STRING, "", false, "name", "enter name", true},
{"sortname", MD_STRING, "", false, "sortname", "enter game sort name", false}, {"sortname", MD_STRING, "", false, "sortname", "enter sort name", false},
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true}, {"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true},
{"rating", MD_RATING, "0", false, "rating", "enter rating", true}, {"rating", MD_RATING, "0", false, "rating", "enter rating", true},
{"releasedate", MD_DATE, "19700101T010000", 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}, {"developer", MD_STRING, "unknown", false, "developer", "enter developer", true},
{"publisher", MD_STRING, "unknown", false, "publisher", "enter game publisher", true}, {"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true},
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre", true}, {"genre", MD_STRING, "unknown", false, "genre", "enter genre", true},
{"players", MD_STRING, "unknown", false, "players", "enter number of players", true}, {"players", MD_STRING, "unknown", false, "players", "enter number of players", true},
{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false}, {"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false},
{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false}, {"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false},
@ -35,7 +35,7 @@ MetaDataDecl gameDecls[] = {
{"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false}, {"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false},
{"launchcommand", MD_LAUNCHCOMMAND, "", false, "launch command", "enter game launch command " {"launchcommand", MD_LAUNCHCOMMAND, "", false, "launch command", "enter game launch command "
"(emulator override)", false}, "(emulator override)", false},
{"playcount", MD_INT, "0", false, "play count", "enter number of times played", false}, {"playcount", MD_INT, "0", false, "times played", "enter number of times played", false},
{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false} {"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false}
}; };
@ -43,13 +43,13 @@ const std::vector<MetaDataDecl> gameMDD(gameDecls, gameDecls +
sizeof(gameDecls) / sizeof(gameDecls[0])); sizeof(gameDecls) / sizeof(gameDecls[0]));
MetaDataDecl folderDecls[] = { MetaDataDecl folderDecls[] = {
{"name", MD_STRING, "", false, "name", "enter game name", true}, {"name", MD_STRING, "", false, "name", "enter name", true},
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true}, {"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true},
{"rating", MD_RATING, "0", false, "rating", "enter rating", true}, {"rating", MD_RATING, "0", false, "rating", "enter rating", true},
{"releasedate", MD_DATE, "19700101T010000", 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}, {"developer", MD_STRING, "unknown", false, "developer", "enter developer", true},
{"publisher", MD_STRING, "unknown", false, "publisher", "enter game publisher", true}, {"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true},
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre", true}, {"genre", MD_STRING, "unknown", false, "genre", "enter genre", true},
{"players", MD_STRING, "unknown", false, "players", "enter number of players", true}, {"players", MD_STRING, "unknown", false, "players", "enter number of players", true},
{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false}, {"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false},
{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false}, {"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false},