Qt: Implement GetUniqueID()

This commit is contained in:
spycrab 2017-07-20 18:37:11 +02:00
parent ca1646d99b
commit 655778f7f1
2 changed files with 47 additions and 0 deletions

View File

@ -11,6 +11,7 @@
#include "Common/Assert.h"
#include "Common/FileUtil.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
#include "Core/HW/WiiSaveCrypted.h"
#include "Core/IOS/ES/ES.h"
@ -305,6 +306,51 @@ QString GameFile::GetLanguage(DiscIO::Language lang) const
}
}
QString GameFile::GetUniqueID() const
{
std::vector<std::string> info;
if (!GetGameID().isEmpty())
info.push_back(GetGameID().toStdString());
if (GetRevision() != 0)
{
info.push_back("Revision " + std::to_string(GetRevision()));
}
std::string name = m_long_names[DiscIO::Language::LANGUAGE_ENGLISH].toStdString();
if (name.empty())
{
if (!m_long_names.isEmpty())
name = m_long_names.begin().value().toStdString();
else
{
std::string filename, extension;
name = SplitPath(m_path.toStdString(), nullptr, &filename, &extension);
name = filename + extension;
}
}
int disc_number = GetDiscNumber() + 1;
std::string lower_name = name;
std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower);
if (disc_number > 1 &&
lower_name.find(std::string("disc ") + std::to_string(disc_number)) == std::string::npos &&
lower_name.find(std::string("disc") + std::to_string(disc_number)) == std::string::npos)
{
info.push_back("Disc " + std::to_string(disc_number));
}
if (info.empty())
return QString::fromStdString(name);
std::ostringstream ss;
std::copy(info.begin(), info.end() - 1, std::ostream_iterator<std::string>(ss, ", "));
ss << info.back();
return QString::fromStdString(name + " (" + ss.str() + ")");
}
bool GameFile::IsInstalled() const
{
_assert_(m_platform == DiscIO::Platform::WII_WAD);

View File

@ -41,6 +41,7 @@ public:
u64 GetTitleID() const { return m_title_id; }
u16 GetRevision() const { return m_revision; }
QString GetInternalName() const { return m_internal_name; }
QString GetUniqueID() const;
u8 GetDiscNumber() const { return m_disc_number; }
u64 GetRawSize() const { return m_raw_size; }
QPixmap GetBanner() const { return m_banner; }