mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 08:05:38 +00:00
Merge pull request #240 from Joemommasfat/master
add sortname to gamelist.xml to sort by a different name
This commit is contained in:
commit
aa4ea2d019
|
@ -82,6 +82,14 @@ const std::string& FileData::getName()
|
||||||
return metadata.get("name");
|
return metadata.get("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& FileData::getSortName()
|
||||||
|
{
|
||||||
|
if (metadata.get("sortname").empty())
|
||||||
|
return metadata.get("name");
|
||||||
|
else
|
||||||
|
return metadata.get("sortname");
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
|
const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
|
||||||
|
|
||||||
FileFilterIndex* idx = CollectionSystemManager::get()->getSystemToView(mSystem)->getIndex();
|
FileFilterIndex* idx = CollectionSystemManager::get()->getSystemToView(mSystem)->getIndex();
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
virtual ~FileData();
|
virtual ~FileData();
|
||||||
|
|
||||||
virtual const std::string& getName();
|
virtual const std::string& getName();
|
||||||
|
virtual const std::string& getSortName();
|
||||||
inline FileType getType() const { return mType; }
|
inline FileType getType() const { return mType; }
|
||||||
inline const std::string& getPath() const { return mPath; }
|
inline const std::string& getPath() const { return mPath; }
|
||||||
inline FileData* getParent() const { return mParent; }
|
inline FileData* getParent() const { return mParent; }
|
||||||
|
|
|
@ -42,8 +42,14 @@ namespace FileSorts
|
||||||
bool compareName(const FileData* file1, const FileData* file2)
|
bool compareName(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
// we compare the actual metadata name, as collection files have the system appended which messes up the order
|
// we compare the actual metadata name, as collection files have the system appended which messes up the order
|
||||||
std::string name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
std::string name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
|
||||||
std::string name2 = Utils::String::toUpper(file2->metadata.get("name"));
|
std::string name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
|
||||||
|
if(name1.empty()){
|
||||||
|
name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
||||||
|
}
|
||||||
|
if(name2.empty()){
|
||||||
|
name2 = Utils::String::toUpper(file2->metadata.get("name"));
|
||||||
|
}
|
||||||
return name1.compare(name2) < 0;
|
return name1.compare(name2) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
MetaDataDecl gameDecls[] = {
|
MetaDataDecl gameDecls[] = {
|
||||||
// key, type, default, statistic, name in GuiMetaDataEd, prompt in GuiMetaDataEd
|
// key, type, default, statistic, name in GuiMetaDataEd, prompt in GuiMetaDataEd
|
||||||
{"name", MD_STRING, "", false, "name", "enter game name"},
|
{"name", MD_STRING, "", false, "name", "enter game name"},
|
||||||
|
{"sortname", MD_STRING, "", false, "sortname", "enter game sort name"},
|
||||||
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description"},
|
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description"},
|
||||||
{"image", MD_PATH, "", false, "image", "enter path to image"},
|
{"image", MD_PATH, "", false, "image", "enter path to image"},
|
||||||
{"video", MD_PATH , "", false, "video", "enter path to video"},
|
{"video", MD_PATH , "", false, "video", "enter path to video"},
|
||||||
|
@ -28,6 +29,7 @@ const std::vector<MetaDataDecl> gameMDD(gameDecls, gameDecls + sizeof(gameDecls)
|
||||||
|
|
||||||
MetaDataDecl folderDecls[] = {
|
MetaDataDecl folderDecls[] = {
|
||||||
{"name", MD_STRING, "", false, "name", "enter game name"},
|
{"name", MD_STRING, "", false, "name", "enter game name"},
|
||||||
|
{"sortname", MD_STRING, "", false, "sortname", "enter game sort name"},
|
||||||
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description"},
|
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description"},
|
||||||
{"image", MD_PATH, "", false, "image", "enter path to image"},
|
{"image", MD_PATH, "", false, "image", "enter path to image"},
|
||||||
{"thumbnail", MD_PATH, "", false, "thumbnail", "enter path to thumbnail"},
|
{"thumbnail", MD_PATH, "", false, "thumbnail", "enter path to thumbnail"},
|
||||||
|
|
|
@ -30,7 +30,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
|
||||||
char startChar = '!';
|
char startChar = '!';
|
||||||
char endChar = '_';
|
char endChar = '_';
|
||||||
|
|
||||||
char curChar = (char)toupper(getGamelist()->getCursor()->getName()[0]);
|
char curChar = (char)toupper(getGamelist()->getCursor()->getSortName()[0]);
|
||||||
if(curChar < startChar || curChar > endChar)
|
if(curChar < startChar || curChar > endChar)
|
||||||
curChar = startChar;
|
curChar = startChar;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
|
||||||
const std::vector<FileData*>& files = getGamelist()->getCursor()->getParent()->getChildrenListToDisplay();
|
const std::vector<FileData*>& files = getGamelist()->getCursor()->getParent()->getChildrenListToDisplay();
|
||||||
for (auto file : files)
|
for (auto file : files)
|
||||||
{
|
{
|
||||||
char candidate = (char)toupper(file->getName()[0]);
|
char candidate = (char)toupper(file->getSortName()[0]);
|
||||||
if (c == candidate)
|
if (c == candidate)
|
||||||
{
|
{
|
||||||
mJumpToLetterList->add(std::string(1, c), c, c == curChar);
|
mJumpToLetterList->add(std::string(1, c), c, c == curChar);
|
||||||
|
@ -218,11 +218,11 @@ void GuiGamelistOptions::jumpToLetter()
|
||||||
if(files.at(mid)->getName().empty())
|
if(files.at(mid)->getName().empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
char checkLetter = (char)toupper(files.at(mid)->getName()[0]);
|
char checkLetter = (char)toupper(files.at(mid)->getSortName()[0]);
|
||||||
|
|
||||||
if(checkLetter < letter)
|
if(checkLetter < letter)
|
||||||
min = mid + 1;
|
min = mid + 1;
|
||||||
else if(checkLetter > letter || (mid > 0 && (letter == toupper(files.at(mid - 1)->getName()[0]))))
|
else if(checkLetter > letter || (mid > 0 && (letter == toupper(files.at(mid - 1)->getSortName()[0]))))
|
||||||
max = mid - 1;
|
max = mid - 1;
|
||||||
else
|
else
|
||||||
break; //exact match found
|
break; //exact match found
|
||||||
|
|
Loading…
Reference in a new issue