diff options
| author | Scott Mansell <phiren@gmail.com> | 2015-09-18 17:41:32 +1200 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2015-09-18 17:41:32 +1200 |
| commit | 3f564809038bfb6679f319de81457b0d5677524a (patch) | |
| tree | 0147bc7410190f030b0483b0e02652fe473d46b0 /Source/Core/DolphinWX/ISOFile.cpp | |
| parent | 3ef103d1c984c72f6566306613fffeb033836223 (diff) | |
| parent | 210aa774d554bb9818d79030bbc26b8eb2c500b2 (diff) | |
Merge pull request #3037 from JosJuice/titles-txt-sort
DolphinWX: Fix sorting games by custom titles
Diffstat (limited to 'Source/Core/DolphinWX/ISOFile.cpp')
| -rw-r--r-- | Source/Core/DolphinWX/ISOFile.cpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 026dda93d8..28051d0fb0 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -8,6 +8,7 @@ #include <cstring> #include <memory> #include <string> +#include <unordered_map> #include <utility> #include <vector> #include <wx/app.h> @@ -62,7 +63,7 @@ static std::string GetLanguageString(DiscIO::IVolume::ELanguage language, std::m return ""; } -GameListItem::GameListItem(const std::string& _rFileName) +GameListItem::GameListItem(const std::string& _rFileName, const std::unordered_map<std::string, std::string>& custom_titles) : m_FileName(_rFileName) , m_emu_state(0) , m_FileSize(0) @@ -73,6 +74,7 @@ GameListItem::GameListItem(const std::string& _rFileName) , m_ImageWidth(0) , m_ImageHeight(0) , m_disc_number(0) + , m_has_custom_name(false) { if (LoadFromCache()) { @@ -130,6 +132,24 @@ GameListItem::GameListItem(const std::string& _rFileName) IniFile ini = SConfig::LoadGameIni(m_UniqueID, m_Revision); ini.GetIfExists("EmuState", "EmulationStateId", &m_emu_state); ini.GetIfExists("EmuState", "EmulationIssues", &m_issues); + m_has_custom_name = ini.GetIfExists("EmuState", "Title", &m_custom_name); + + if (!m_has_custom_name) + { + std::string game_id = m_UniqueID; + + // Ignore publisher ID for WAD files + if (m_Platform == DiscIO::IVolume::WII_WAD) + game_id.erase(game_id.size() - 2); + + auto end = custom_titles.end(); + auto it = custom_titles.find(game_id); + if (it != end) + { + m_custom_name = it->second; + m_has_custom_name = true; + } + } } if (!IsValid() && IsElfOrDol()) @@ -200,12 +220,10 @@ void GameListItem::DoState(PointerWrap &p) bool GameListItem::IsElfOrDol() const { - const std::string name = GetName(); - const size_t pos = name.rfind('.'); - + const size_t pos = m_FileName.rfind('.'); if (pos != std::string::npos) { - std::string ext = name.substr(pos); + std::string ext = m_FileName.substr(pos); std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); return ext == ".elf" || ext == ".dol"; @@ -290,17 +308,18 @@ std::string GameListItem::GetName(DiscIO::IVolume::ELanguage language) const std::string GameListItem::GetName() const { + if (m_has_custom_name) + return m_custom_name; + bool wii = m_Platform != DiscIO::IVolume::GAMECUBE_DISC; std::string name = GetName(SConfig::GetInstance().GetCurrentLanguage(wii)); - if (name.empty()) - { - std::string ext; + if (!name.empty()) + return name; - // No usable name, return filename (better than nothing) - SplitPath(GetFileName(), nullptr, &name, &ext); - return name + ext; - } - return name; + // No usable name, return filename (better than nothing) + std::string ext; + SplitPath(GetFileName(), nullptr, &name, &ext); + return name + ext; } std::vector<DiscIO::IVolume::ELanguage> GameListItem::GetLanguages() const |
