mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Added support for defining custom system sorting using the <systemsortname> tag.
This commit is contained in:
parent
78db6cd18c
commit
966d2616be
|
@ -925,7 +925,7 @@ SystemData* CollectionSystemsManager::addNewCustomCollection(std::string name)
|
||||||
CollectionSystemDecl decl = mCollectionSystemDeclsIndex[myCollectionsName];
|
CollectionSystemDecl decl = mCollectionSystemDeclsIndex[myCollectionsName];
|
||||||
decl.themeFolder = name;
|
decl.themeFolder = name;
|
||||||
decl.name = name;
|
decl.name = name;
|
||||||
decl.longName = name;
|
decl.fullName = name;
|
||||||
|
|
||||||
return createNewCollectionEntry(name, decl, true, true);
|
return createNewCollectionEntry(name, decl, true, true);
|
||||||
}
|
}
|
||||||
|
@ -1113,7 +1113,7 @@ SystemData* CollectionSystemsManager::createNewCollectionEntry(std::string name,
|
||||||
bool index,
|
bool index,
|
||||||
bool custom)
|
bool custom)
|
||||||
{
|
{
|
||||||
SystemData* newSys = new SystemData(name, sysDecl.longName, mCollectionEnvData,
|
SystemData* newSys = new SystemData(name, sysDecl.fullName, "", mCollectionEnvData,
|
||||||
sysDecl.themeFolder, true, custom);
|
sysDecl.themeFolder, true, custom);
|
||||||
|
|
||||||
CollectionSystemData newCollectionData;
|
CollectionSystemData newCollectionData;
|
||||||
|
|
|
@ -43,7 +43,7 @@ enum CollectionSystemType {
|
||||||
struct CollectionSystemDecl {
|
struct CollectionSystemDecl {
|
||||||
CollectionSystemType type;
|
CollectionSystemType type;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string longName;
|
std::string fullName;
|
||||||
std::string themeFolder;
|
std::string themeFolder;
|
||||||
bool isCustom;
|
bool isCustom;
|
||||||
};
|
};
|
||||||
|
|
|
@ -178,12 +178,14 @@ void FindRules::loadFindRules()
|
||||||
|
|
||||||
SystemData::SystemData(const std::string& name,
|
SystemData::SystemData(const std::string& name,
|
||||||
const std::string& fullName,
|
const std::string& fullName,
|
||||||
|
const std::string& sortName,
|
||||||
SystemEnvironmentData* envData,
|
SystemEnvironmentData* envData,
|
||||||
const std::string& themeFolder,
|
const std::string& themeFolder,
|
||||||
bool CollectionSystem,
|
bool CollectionSystem,
|
||||||
bool CustomCollectionSystem)
|
bool CustomCollectionSystem)
|
||||||
: mName(name)
|
: mName(name)
|
||||||
, mFullName(fullName)
|
, mFullName(fullName)
|
||||||
|
, mSortName(sortName)
|
||||||
, mEnvData(envData)
|
, mEnvData(envData)
|
||||||
, mThemeFolder(themeFolder)
|
, mThemeFolder(themeFolder)
|
||||||
, mIsCollectionSystem(CollectionSystem)
|
, mIsCollectionSystem(CollectionSystem)
|
||||||
|
@ -438,11 +440,13 @@ bool SystemData::loadConfig()
|
||||||
system = system.next_sibling("system")) {
|
system = system.next_sibling("system")) {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string fullname;
|
std::string fullname;
|
||||||
|
std::string sortName;
|
||||||
std::string path;
|
std::string path;
|
||||||
std::string themeFolder;
|
std::string themeFolder;
|
||||||
|
|
||||||
name = system.child("name").text().get();
|
name = system.child("name").text().get();
|
||||||
fullname = system.child("fullname").text().get();
|
fullname = system.child("fullname").text().get();
|
||||||
|
sortName = system.child("systemsortname").text().get();
|
||||||
path = system.child("path").text().get();
|
path = system.child("path").text().get();
|
||||||
|
|
||||||
auto nameFindFunc = [&] {
|
auto nameFindFunc = [&] {
|
||||||
|
@ -583,6 +587,15 @@ bool SystemData::loadConfig()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sortName == "") {
|
||||||
|
sortName = fullname;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG(LogDebug) << "SystemData::loadConfig(): System \"" << name
|
||||||
|
<< "\" has a <systemsortname> tag set, sorting as \"" << sortName
|
||||||
|
<< "\" instead of \"" << fullname << "\"";
|
||||||
|
}
|
||||||
|
|
||||||
// Convert path to generic directory seperators.
|
// Convert path to generic directory seperators.
|
||||||
path = Utils::FileSystem::getGenericPath(path);
|
path = Utils::FileSystem::getGenericPath(path);
|
||||||
|
|
||||||
|
@ -601,7 +614,7 @@ bool SystemData::loadConfig()
|
||||||
envData->mLaunchCommands = commands;
|
envData->mLaunchCommands = commands;
|
||||||
envData->mPlatformIds = platformIds;
|
envData->mPlatformIds = platformIds;
|
||||||
|
|
||||||
SystemData* newSys = new SystemData(name, fullname, envData, themeFolder);
|
SystemData* newSys = new SystemData(name, fullname, sortName, envData, themeFolder);
|
||||||
bool onlyHidden = false;
|
bool onlyHidden = false;
|
||||||
|
|
||||||
// If the option to show hidden games has been disabled, then check whether all
|
// If the option to show hidden games has been disabled, then check whether all
|
||||||
|
@ -630,9 +643,9 @@ bool SystemData::loadConfig()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort systems by their full names.
|
// Sort systems by sortName, which will normally be the same as the full name.
|
||||||
std::sort(std::begin(sSystemVector), std::end(sSystemVector),
|
std::sort(std::begin(sSystemVector), std::end(sSystemVector),
|
||||||
[](SystemData* a, SystemData* b) { return a->getFullName() < b->getFullName(); });
|
[](SystemData* a, SystemData* b) { return a->getSortName() < b->getSortName(); });
|
||||||
|
|
||||||
// Don't load any collections if there are no systems available.
|
// Don't load any collections if there are no systems available.
|
||||||
if (sSystemVector.size() > 0)
|
if (sSystemVector.size() > 0)
|
||||||
|
|
|
@ -62,6 +62,7 @@ class SystemData
|
||||||
public:
|
public:
|
||||||
SystemData(const std::string& name,
|
SystemData(const std::string& name,
|
||||||
const std::string& fullName,
|
const std::string& fullName,
|
||||||
|
const std::string& sortName,
|
||||||
SystemEnvironmentData* envData,
|
SystemEnvironmentData* envData,
|
||||||
const std::string& themeFolder,
|
const std::string& themeFolder,
|
||||||
bool CollectionSystem = false,
|
bool CollectionSystem = false,
|
||||||
|
@ -72,6 +73,7 @@ public:
|
||||||
FileData* getRootFolder() const { return mRootFolder; }
|
FileData* getRootFolder() const { return mRootFolder; }
|
||||||
const std::string& getName() const { return mName; }
|
const std::string& getName() const { return mName; }
|
||||||
const std::string& getFullName() const { return mFullName; }
|
const std::string& getFullName() const { return mFullName; }
|
||||||
|
const std::string& getSortName() const { return mSortName; }
|
||||||
const std::string& getStartPath() const { return mEnvData->mStartPath; }
|
const std::string& getStartPath() const { return mEnvData->mStartPath; }
|
||||||
const std::vector<std::string>& getExtensions() const { return mEnvData->mSearchExtensions; }
|
const std::vector<std::string>& getExtensions() const { return mEnvData->mSearchExtensions; }
|
||||||
const std::string& getThemeFolder() const { return mThemeFolder; }
|
const std::string& getThemeFolder() const { return mThemeFolder; }
|
||||||
|
@ -152,6 +154,7 @@ public:
|
||||||
private:
|
private:
|
||||||
std::string mName;
|
std::string mName;
|
||||||
std::string mFullName;
|
std::string mFullName;
|
||||||
|
std::string mSortName;
|
||||||
SystemEnvironmentData* mEnvData;
|
SystemEnvironmentData* mEnvData;
|
||||||
std::string mAlternativeEmulator;
|
std::string mAlternativeEmulator;
|
||||||
std::string mThemeFolder;
|
std::string mThemeFolder;
|
||||||
|
|
|
@ -52,7 +52,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
||||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
|
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
|
||||||
autoSystems.cbegin();
|
autoSystems.cbegin();
|
||||||
it != autoSystems.cend(); it++)
|
it != autoSystems.cend(); it++)
|
||||||
collection_systems_auto->add(it->second.decl.longName, it->second.decl.name,
|
collection_systems_auto->add(it->second.decl.fullName, it->second.decl.name,
|
||||||
it->second.isEnabled);
|
it->second.isEnabled);
|
||||||
addWithLabel("AUTOMATIC GAME COLLECTIONS", collection_systems_auto);
|
addWithLabel("AUTOMATIC GAME COLLECTIONS", collection_systems_auto);
|
||||||
addSaveFunc([this, autoSystems] {
|
addSaveFunc([this, autoSystems] {
|
||||||
|
@ -101,7 +101,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
||||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
|
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
|
||||||
customSystems.cbegin();
|
customSystems.cbegin();
|
||||||
it != customSystems.cend(); it++)
|
it != customSystems.cend(); it++)
|
||||||
collection_systems_custom->add(it->second.decl.longName, it->second.decl.name,
|
collection_systems_custom->add(it->second.decl.fullName, it->second.decl.name,
|
||||||
it->second.isEnabled);
|
it->second.isEnabled);
|
||||||
|
|
||||||
addWithLabel("CUSTOM GAME COLLECTIONS", collection_systems_custom);
|
addWithLabel("CUSTOM GAME COLLECTIONS", collection_systems_custom);
|
||||||
|
|
Loading…
Reference in a new issue