add a getDisplayName function, which is used for rom display, and make getCleanName again strip paratheses, which is used in the scraper backends.

This commit is contained in:
Jools Wills 2016-03-29 16:33:19 +01:00
parent abcc9696a2
commit 53f69bf61b
3 changed files with 12 additions and 4 deletions

View file

@ -48,7 +48,7 @@ FileData::FileData(FileType type, const fs::path& path, SystemData* system)
{
// metadata needs at least a name field (since that's what getName() will return)
if(metadata.get("name").empty())
metadata.set("name", getCleanName());
metadata.set("name", getDisplayName());
}
FileData::~FileData()
@ -60,7 +60,7 @@ FileData::~FileData()
delete mChildren.back();
}
std::string FileData::getCleanName() const
std::string FileData::getDisplayName() const
{
std::string stem = mPath.stem().generic_string();
if(mSystem && mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO))
@ -69,6 +69,11 @@ std::string FileData::getCleanName() const
return stem;
}
std::string FileData::getCleanName() const
{
return removeParenthesis(this->getDisplayName());
}
const std::string& FileData::getThumbnailPath() const
{
if(!metadata.get("thumbnail").empty())

View file

@ -49,7 +49,10 @@ public:
void addChild(FileData* file); // Error if mType != FOLDER
void removeChild(FileData* file); //Error if mType != FOLDER
// Returns our best guess at the "real" name for this file (will strip parenthesis and attempt to perform MAME name translation)
// Returns our best guess at the "real" name for this file (will attempt to perform MAME name translation)
std::string getDisplayName() const;
// As above, but also remove parenthesis
std::string getCleanName() const;
typedef bool ComparisonFunction(const FileData* a, const FileData* b);

View file

@ -148,7 +148,7 @@ void addFileDataNode(pugi::xml_node& parent, const FileData* file, const char* t
if(newNode.children().begin() == newNode.child("name") //first element is name
&& ++newNode.children().begin() == newNode.children().end() //theres only one element
&& newNode.child("name").text().get() == file->getCleanName()) //the name is the default
&& newNode.child("name").text().get() == file->getDisplayName()) //the name is the default
{
//if the only info is the default name, don't bother with this node
//delete it and ultimately do nothing