diff options
| author | JosJuice <josjuice@gmail.com> | 2015-09-13 12:45:06 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2015-09-13 12:45:06 +0200 |
| commit | 10aafff5b94864c150f4f4f45d4e106afc795342 (patch) | |
| tree | be4a7d417bd81d3e85401e690180f55ad2caa535 /Source/Core/DolphinWX/ISOFile.cpp | |
| parent | 45c1cfa078cdcd58b5592917a7102e647e841f6a (diff) | |
DolphinWX: Fix sorting games by custom titles
The custom title reading code is moved so that custom titles are
returned by GameListItem::GetName(). The comparison code is changed
to use GetName() instead of GetName(DiscIO::IVolume::ELanguage).
GetName(DiscIO::IVolume::ELanguage) must not return custom titles,
because netplay relies on it returning the same name for all players.
Diffstat (limited to 'Source/Core/DolphinWX/ISOFile.cpp')
| -rw-r--r-- | Source/Core/DolphinWX/ISOFile.cpp | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 026dda93d8..00f707529b 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -73,6 +73,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 +131,44 @@ 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) + { + // Attempt to load game titles from titles.txt + // http://www.gametdb.com/Wii/Downloads + std::ifstream titlestxt; + OpenFStream(titlestxt, File::GetUserPath(D_LOAD_IDX) + "titles.txt", std::ios::in); + + if (!titlestxt.is_open()) + OpenFStream(titlestxt, File::GetUserPath(D_LOAD_IDX) + "wiitdb.txt", std::ios::in); + + if (titlestxt.is_open() && GetUniqueID().size() >= 4) + { + while (!titlestxt.eof()) + { + std::string line; + + if (!std::getline(titlestxt, line) && titlestxt.eof()) + break; + + const size_t equals_index = line.find('='); + 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); + + if (line.substr(0, equals_index - 1) == game_id) + { + m_custom_name = StripSpaces(line.substr(equals_index + 1)); + m_has_custom_name = true; + break; + } + } + titlestxt.close(); + } + } } if (!IsValid() && IsElfOrDol()) @@ -200,12 +239,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 +327,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 |
