mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 09:35:39 +00:00
Added the ability to set a sortname specifically for custom collections.
This commit is contained in:
parent
6ca4d6b96e
commit
65702b6689
|
@ -90,6 +90,15 @@ const std::string& FileData::getName()
|
||||||
|
|
||||||
const std::string& FileData::getSortName()
|
const std::string& FileData::getSortName()
|
||||||
{
|
{
|
||||||
|
if (mSystem->isCustomCollection() && mType == GAME) {
|
||||||
|
if (!metadata.get("collectionsortname").empty())
|
||||||
|
return metadata.get("collectionsortname");
|
||||||
|
else if (!metadata.get("sortname").empty())
|
||||||
|
return metadata.get("sortname");
|
||||||
|
else
|
||||||
|
return metadata.get("name");
|
||||||
|
}
|
||||||
|
|
||||||
if (metadata.get("sortname").empty())
|
if (metadata.get("sortname").empty())
|
||||||
return metadata.get("name");
|
return metadata.get("name");
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "FileSorts.h"
|
#include "FileSorts.h"
|
||||||
|
|
||||||
|
#include "SystemData.h"
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -55,8 +56,28 @@ namespace FileSorts
|
||||||
{
|
{
|
||||||
// We compare the actual metadata name, as collection files have the system
|
// We compare the actual metadata name, as collection files have the system
|
||||||
// appended which messes up the order.
|
// appended which messes up the order.
|
||||||
std::string name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
|
std::string name1;
|
||||||
std::string name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
|
std::string name2;
|
||||||
|
|
||||||
|
if (file1->getSystem()->isCustomCollection()) {
|
||||||
|
if (Utils::String::toUpper(file1->metadata.get("collectionsortname")) != "")
|
||||||
|
name1 = Utils::String::toUpper(file1->metadata.get("collectionsortname"));
|
||||||
|
else if (Utils::String::toUpper(file1->metadata.get("sortname")) != "")
|
||||||
|
name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
|
||||||
|
else
|
||||||
|
name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
||||||
|
|
||||||
|
if (Utils::String::toUpper(file2->metadata.get("collectionsortname")) != "")
|
||||||
|
name2 = Utils::String::toUpper(file2->metadata.get("collectionsortname"));
|
||||||
|
else if (Utils::String::toUpper(file2->metadata.get("sortname")) != "")
|
||||||
|
name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
|
||||||
|
else
|
||||||
|
name2 = Utils::String::toUpper(file2->metadata.get("name"));
|
||||||
|
return name1.compare(name2) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
|
||||||
|
name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
|
||||||
if (name1.empty())
|
if (name1.empty())
|
||||||
name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
||||||
if (name2.empty())
|
if (name2.empty())
|
||||||
|
@ -66,8 +87,28 @@ namespace FileSorts
|
||||||
|
|
||||||
bool compareNameDescending(const FileData* file1, const FileData* file2)
|
bool compareNameDescending(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
std::string name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
|
std::string name1;
|
||||||
std::string name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
|
std::string name2;
|
||||||
|
|
||||||
|
if (file1->getSystem()->isCustomCollection()) {
|
||||||
|
if (Utils::String::toUpper(file1->metadata.get("collectionsortname")) != "")
|
||||||
|
name1 = Utils::String::toUpper(file1->metadata.get("collectionsortname"));
|
||||||
|
else if (Utils::String::toUpper(file1->metadata.get("sortname")) != "")
|
||||||
|
name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
|
||||||
|
else
|
||||||
|
name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
||||||
|
|
||||||
|
if (Utils::String::toUpper(file2->metadata.get("collectionsortname")) != "")
|
||||||
|
name2 = Utils::String::toUpper(file2->metadata.get("collectionsortname"));
|
||||||
|
else if (Utils::String::toUpper(file2->metadata.get("sortname")) != "")
|
||||||
|
name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
|
||||||
|
else
|
||||||
|
name2 = Utils::String::toUpper(file2->metadata.get("name"));
|
||||||
|
return name1.compare(name2) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
|
||||||
|
name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
|
||||||
if (name1.empty())
|
if (name1.empty())
|
||||||
name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
||||||
if (name2.empty())
|
if (name2.empty())
|
||||||
|
|
|
@ -20,28 +20,29 @@ namespace
|
||||||
// The statistic entries must be placed at the bottom or otherwise there will be problems with
|
// The statistic entries must be placed at the bottom or otherwise there will be problems with
|
||||||
// saving the values in GuiMetaDataEd.
|
// saving the values in GuiMetaDataEd.
|
||||||
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 name", true},
|
{"name", MD_STRING, "", false, "name", "enter name", true},
|
||||||
{"sortname", MD_STRING, "", false, "sortname", "enter sortname", false},
|
{"sortname", MD_STRING, "", false, "sortname", "enter sortname", false},
|
||||||
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true},
|
{"collectionsortname", MD_STRING, "", false, "custom collections sortname", "enter collections sortname", false},
|
||||||
{"rating", MD_RATING, "0", false, "rating", "enter rating", true},
|
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true},
|
||||||
{"releasedate", MD_DATE, "19700101T000000", false, "release date", "enter release date", true},
|
{"rating", MD_RATING, "0", false, "rating", "enter rating", true},
|
||||||
{"developer", MD_STRING, "unknown", false, "developer", "enter developer", true},
|
{"releasedate", MD_DATE, "19700101T000000", false, "release date", "enter release date", true},
|
||||||
{"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true},
|
{"developer", MD_STRING, "unknown", false, "developer", "enter developer", true},
|
||||||
{"genre", MD_STRING, "unknown", false, "genre", "enter genre", true},
|
{"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true},
|
||||||
{"players", MD_STRING, "unknown", false, "players", "enter number of players", true},
|
{"genre", MD_STRING, "unknown", false, "genre", "enter genre", true},
|
||||||
{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false},
|
{"players", MD_STRING, "unknown", false, "players", "enter number of players", true},
|
||||||
{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false},
|
{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false},
|
||||||
{"kidgame", MD_BOOL, "false", false, "kidgame", "enter kidgame off/on", false},
|
{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false},
|
||||||
{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false},
|
{"kidgame", MD_BOOL, "false", false, "kidgame", "enter kidgame off/on", false},
|
||||||
{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false},
|
{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false},
|
||||||
{"nogamecount", MD_BOOL, "false", false, "exclude from game counter", "enter don't count as game off/on", false},
|
{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false},
|
||||||
{"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no multi-scrape off/on", false},
|
{"nogamecount", MD_BOOL, "false", false, "exclude from game counter", "enter don't count as game off/on", false},
|
||||||
{"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false},
|
{"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no multi-scrape off/on", false},
|
||||||
{"playcount", MD_INT, "0", false, "times played", "enter number of times played", false},
|
{"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false},
|
||||||
{"controller", MD_CONTROLLER, "", false, "controller", "select controller", true},
|
{"playcount", MD_INT, "0", false, "times played", "enter number of times played", false},
|
||||||
{"altemulator", MD_ALT_EMULATOR, "", false, "alternative emulator", "select alternative emulator", false},
|
{"controller", MD_CONTROLLER, "", false, "controller", "select controller", true},
|
||||||
{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false}
|
{"altemulator", MD_ALT_EMULATOR, "", false, "alternative emulator", "select alternative emulator", false},
|
||||||
|
{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false}
|
||||||
};
|
};
|
||||||
|
|
||||||
MetaDataDecl folderDecls[] = {
|
MetaDataDecl folderDecls[] = {
|
||||||
|
|
|
@ -45,16 +45,21 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
, mBackground{window, ":/graphics/frame.svg"}
|
, mBackground{window, ":/graphics/frame.svg"}
|
||||||
, mGrid{window, glm::ivec2{2, 6}}
|
, mGrid{window, glm::ivec2{2, 6}}
|
||||||
, mScraperParams{scraperParams}
|
, mScraperParams{scraperParams}
|
||||||
|
, mControllerBadges{BadgeComponent::getGameControllers()}
|
||||||
, mMetaDataDecl{mdd}
|
, mMetaDataDecl{mdd}
|
||||||
, mMetaData{md}
|
, mMetaData{md}
|
||||||
, mSavedCallback{saveCallback}
|
, mSavedCallback{saveCallback}
|
||||||
, mClearGameFunc{clearGameFunc}
|
, mClearGameFunc{clearGameFunc}
|
||||||
, mDeleteGameFunc{deleteGameFunc}
|
, mDeleteGameFunc{deleteGameFunc}
|
||||||
|
, mIsCustomCollection{false}
|
||||||
, mMediaFilesUpdated{false}
|
, mMediaFilesUpdated{false}
|
||||||
, mSavedMediaAndAborted{false}
|
, mSavedMediaAndAborted{false}
|
||||||
, mInvalidEmulatorEntry{false}
|
, mInvalidEmulatorEntry{false}
|
||||||
{
|
{
|
||||||
mControllerBadges = BadgeComponent::getGameControllers();
|
if (ViewController::getInstance()->getState().getSystem()->isCustomCollection() ||
|
||||||
|
ViewController::getInstance()->getState().getSystem()->getThemeFolder() ==
|
||||||
|
"custom-collections")
|
||||||
|
mIsCustomCollection = true;
|
||||||
|
|
||||||
// Remove the last "unknown" controller entry.
|
// Remove the last "unknown" controller entry.
|
||||||
if (mControllerBadges.size() > 1)
|
if (mControllerBadges.size() > 1)
|
||||||
|
@ -115,6 +120,11 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
std::string originalValue = mMetaData->get(it->key);
|
std::string originalValue = mMetaData->get(it->key);
|
||||||
std::string gamePath;
|
std::string gamePath;
|
||||||
|
|
||||||
|
// Only display the custom collections sortname entry if we're editing the game
|
||||||
|
// from within a custom collection.
|
||||||
|
if (currentKey == "collectionsortname" && !mIsCustomCollection)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Don't add statistics.
|
// Don't add statistics.
|
||||||
if (it->isStatistic)
|
if (it->isStatistic)
|
||||||
continue;
|
continue;
|
||||||
|
@ -619,36 +629,45 @@ void GuiMetaDataEd::save()
|
||||||
|
|
||||||
// We need this to handle the special situation where the user sets a game to hidden while
|
// We need this to handle the special situation where the user sets a game to hidden while
|
||||||
// ShowHiddenGames is set to false, meaning it will immediately disappear from the gamelist.
|
// ShowHiddenGames is set to false, meaning it will immediately disappear from the gamelist.
|
||||||
bool showHiddenGames = Settings::getInstance()->getBool("ShowHiddenGames");
|
bool showHiddenGames{Settings::getInstance()->getBool("ShowHiddenGames")};
|
||||||
bool hideGameWhileHidden = false;
|
bool hideGameWhileHidden{false};
|
||||||
bool setGameAsCounted = false;
|
bool setGameAsCounted{false};
|
||||||
|
int offset{0};
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mEditors.size(); ++i) {
|
for (unsigned int i = 0; i < mEditors.size(); ++i) {
|
||||||
if (mMetaDataDecl.at(i).isStatistic)
|
// The offset is needed to make the editor and metadata fields match up if we're
|
||||||
continue;
|
// skipping the custom collections sortname field (which we do if not editing the
|
||||||
|
// game from within a custom collection gamelist).
|
||||||
if (mMetaDataDecl.at(i).key == "altemulator" && mInvalidEmulatorEntry == true)
|
if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection) {
|
||||||
continue;
|
offset = 1;
|
||||||
|
|
||||||
if (mMetaDataDecl.at(i).key == "controller" && mEditors.at(i)->getValue() != "") {
|
|
||||||
std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
|
|
||||||
if (shortName != "unknown")
|
|
||||||
mMetaData->set(mMetaDataDecl.at(i).key, shortName);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!showHiddenGames && mMetaDataDecl.at(i).key == "hidden" &&
|
if (mMetaDataDecl.at(i + offset).isStatistic)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mMetaDataDecl.at(i + offset).key == "altemulator" && mInvalidEmulatorEntry == true)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mMetaDataDecl.at(i + offset).key == "controller" && mEditors.at(i)->getValue() != "") {
|
||||||
|
std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
|
||||||
|
if (shortName != "unknown")
|
||||||
|
mMetaData->set(mMetaDataDecl.at(i + offset).key, shortName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!showHiddenGames && mMetaDataDecl.at(i + offset).key == "hidden" &&
|
||||||
mEditors.at(i)->getValue() != mMetaData->get("hidden"))
|
mEditors.at(i)->getValue() != mMetaData->get("hidden"))
|
||||||
hideGameWhileHidden = true;
|
hideGameWhileHidden = true;
|
||||||
|
|
||||||
// Check whether the flag to count the entry as a game was set to enabled.
|
// Check whether the flag to count the entry as a game was set to enabled.
|
||||||
if (mMetaDataDecl.at(i).key == "nogamecount" &&
|
if (mMetaDataDecl.at(i + offset).key == "nogamecount" &&
|
||||||
mEditors.at(i)->getValue() != mMetaData->get("nogamecount") &&
|
mEditors.at(i)->getValue() != mMetaData->get("nogamecount") &&
|
||||||
mMetaData->get("nogamecount") == "true") {
|
mMetaData->get("nogamecount") == "true") {
|
||||||
setGameAsCounted = true;
|
setGameAsCounted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mMetaData->set(mMetaDataDecl.at(i).key, mEditors.at(i)->getValue());
|
mMetaData->set(mMetaDataDecl.at(i + offset).key, mEditors.at(i)->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If hidden games are not shown and the hide flag was set for the entry, then write the
|
// If hidden games are not shown and the hide flag was set for the entry, then write the
|
||||||
|
@ -780,16 +799,27 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result)
|
||||||
void GuiMetaDataEd::close()
|
void GuiMetaDataEd::close()
|
||||||
{
|
{
|
||||||
// Find out if the user made any changes.
|
// Find out if the user made any changes.
|
||||||
bool metadataUpdated = false;
|
bool metadataUpdated{false};
|
||||||
|
int offset{0};
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mEditors.size(); ++i) {
|
for (unsigned int i = 0; i < mEditors.size(); ++i) {
|
||||||
const std::string& key = mMetaDataDecl.at(i).key;
|
const std::string& key{mMetaDataDecl.at(i + offset).key};
|
||||||
std::string mMetaDataValue = mMetaData->get(key);
|
// The offset is needed to make the editor and metadata fields match up if we're
|
||||||
std::string mEditorsValue = mEditors.at(i)->getValue();
|
// skipping the custom collections sortname field (which we do if not editing the
|
||||||
|
// game from within a custom collection gamelist).
|
||||||
|
if (key == "collectionsortname" && !mIsCustomCollection) {
|
||||||
|
offset = 1;
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (key == "altemulator" && mInvalidEmulatorEntry == true)
|
if (key == "altemulator" && mInvalidEmulatorEntry == true)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (mMetaDataDecl.at(i).key == "controller" && mEditors.at(i)->getValue() != "") {
|
std::string mMetaDataValue{mMetaData->get(key)};
|
||||||
|
std::string mEditorsValue{mEditors.at(i)->getValue()};
|
||||||
|
|
||||||
|
if (key == "controller" && mEditors.at(i)->getValue() != "") {
|
||||||
std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
|
std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
|
||||||
if (shortName == "unknown" || mMetaDataValue == shortName)
|
if (shortName == "unknown" || mMetaDataValue == shortName)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -69,6 +69,7 @@ private:
|
||||||
std::function<void()> mClearGameFunc;
|
std::function<void()> mClearGameFunc;
|
||||||
std::function<void()> mDeleteGameFunc;
|
std::function<void()> mDeleteGameFunc;
|
||||||
|
|
||||||
|
bool mIsCustomCollection;
|
||||||
bool mMediaFilesUpdated;
|
bool mMediaFilesUpdated;
|
||||||
bool mSavedMediaAndAborted;
|
bool mSavedMediaAndAborted;
|
||||||
bool mInvalidEmulatorEntry;
|
bool mInvalidEmulatorEntry;
|
||||||
|
|
Loading…
Reference in a new issue