mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-31 04:25:40 +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];
|
||||
decl.themeFolder = name;
|
||||
decl.name = name;
|
||||
decl.longName = name;
|
||||
decl.fullName = name;
|
||||
|
||||
return createNewCollectionEntry(name, decl, true, true);
|
||||
}
|
||||
|
@ -1113,7 +1113,7 @@ SystemData* CollectionSystemsManager::createNewCollectionEntry(std::string name,
|
|||
bool index,
|
||||
bool custom)
|
||||
{
|
||||
SystemData* newSys = new SystemData(name, sysDecl.longName, mCollectionEnvData,
|
||||
SystemData* newSys = new SystemData(name, sysDecl.fullName, "", mCollectionEnvData,
|
||||
sysDecl.themeFolder, true, custom);
|
||||
|
||||
CollectionSystemData newCollectionData;
|
||||
|
|
|
@ -43,7 +43,7 @@ enum CollectionSystemType {
|
|||
struct CollectionSystemDecl {
|
||||
CollectionSystemType type;
|
||||
std::string name;
|
||||
std::string longName;
|
||||
std::string fullName;
|
||||
std::string themeFolder;
|
||||
bool isCustom;
|
||||
};
|
||||
|
|
|
@ -178,12 +178,14 @@ void FindRules::loadFindRules()
|
|||
|
||||
SystemData::SystemData(const std::string& name,
|
||||
const std::string& fullName,
|
||||
const std::string& sortName,
|
||||
SystemEnvironmentData* envData,
|
||||
const std::string& themeFolder,
|
||||
bool CollectionSystem,
|
||||
bool CustomCollectionSystem)
|
||||
: mName(name)
|
||||
, mFullName(fullName)
|
||||
, mSortName(sortName)
|
||||
, mEnvData(envData)
|
||||
, mThemeFolder(themeFolder)
|
||||
, mIsCollectionSystem(CollectionSystem)
|
||||
|
@ -438,11 +440,13 @@ bool SystemData::loadConfig()
|
|||
system = system.next_sibling("system")) {
|
||||
std::string name;
|
||||
std::string fullname;
|
||||
std::string sortName;
|
||||
std::string path;
|
||||
std::string themeFolder;
|
||||
|
||||
name = system.child("name").text().get();
|
||||
fullname = system.child("fullname").text().get();
|
||||
sortName = system.child("systemsortname").text().get();
|
||||
path = system.child("path").text().get();
|
||||
|
||||
auto nameFindFunc = [&] {
|
||||
|
@ -583,6 +587,15 @@ bool SystemData::loadConfig()
|
|||
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.
|
||||
path = Utils::FileSystem::getGenericPath(path);
|
||||
|
||||
|
@ -601,7 +614,7 @@ bool SystemData::loadConfig()
|
|||
envData->mLaunchCommands = commands;
|
||||
envData->mPlatformIds = platformIds;
|
||||
|
||||
SystemData* newSys = new SystemData(name, fullname, envData, themeFolder);
|
||||
SystemData* newSys = new SystemData(name, fullname, sortName, envData, themeFolder);
|
||||
bool onlyHidden = false;
|
||||
|
||||
// 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),
|
||||
[](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.
|
||||
if (sSystemVector.size() > 0)
|
||||
|
|
|
@ -62,6 +62,7 @@ class SystemData
|
|||
public:
|
||||
SystemData(const std::string& name,
|
||||
const std::string& fullName,
|
||||
const std::string& sortName,
|
||||
SystemEnvironmentData* envData,
|
||||
const std::string& themeFolder,
|
||||
bool CollectionSystem = false,
|
||||
|
@ -72,6 +73,7 @@ public:
|
|||
FileData* getRootFolder() const { return mRootFolder; }
|
||||
const std::string& getName() const { return mName; }
|
||||
const std::string& getFullName() const { return mFullName; }
|
||||
const std::string& getSortName() const { return mSortName; }
|
||||
const std::string& getStartPath() const { return mEnvData->mStartPath; }
|
||||
const std::vector<std::string>& getExtensions() const { return mEnvData->mSearchExtensions; }
|
||||
const std::string& getThemeFolder() const { return mThemeFolder; }
|
||||
|
@ -152,6 +154,7 @@ public:
|
|||
private:
|
||||
std::string mName;
|
||||
std::string mFullName;
|
||||
std::string mSortName;
|
||||
SystemEnvironmentData* mEnvData;
|
||||
std::string mAlternativeEmulator;
|
||||
std::string mThemeFolder;
|
||||
|
|
|
@ -52,7 +52,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
|||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
|
||||
autoSystems.cbegin();
|
||||
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);
|
||||
addWithLabel("AUTOMATIC GAME COLLECTIONS", collection_systems_auto);
|
||||
addSaveFunc([this, autoSystems] {
|
||||
|
@ -101,7 +101,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
|||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
|
||||
customSystems.cbegin();
|
||||
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);
|
||||
|
||||
addWithLabel("CUSTOM GAME COLLECTIONS", collection_systems_custom);
|
||||
|
|
Loading…
Reference in a new issue