summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2015-09-13 12:45:06 +0200
committerJosJuice <josjuice@gmail.com>2015-09-13 12:45:06 +0200
commit10aafff5b94864c150f4f4f45d4e106afc795342 (patch)
treebe4a7d417bd81d3e85401e690180f55ad2caa535 /Source
parent45c1cfa078cdcd58b5592917a7102e647e841f6a (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')
-rw-r--r--Source/Core/DolphinWX/GameListCtrl.cpp48
-rw-r--r--Source/Core/DolphinWX/ISOFile.cpp62
-rw-r--r--Source/Core/DolphinWX/ISOFile.h3
3 files changed, 55 insertions, 58 deletions
diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp
index c22992df97..01aa4afa18 100644
--- a/Source/Core/DolphinWX/GameListCtrl.cpp
+++ b/Source/Core/DolphinWX/GameListCtrl.cpp
@@ -83,13 +83,10 @@ static int CompareGameListItems(const GameListItem* iso1, const GameListItem* is
sortData = -sortData;
}
- DiscIO::IVolume::ELanguage languageOne = SConfig::GetInstance().GetCurrentLanguage(iso1->GetPlatform() != DiscIO::IVolume::GAMECUBE_DISC);
- DiscIO::IVolume::ELanguage languageOther = SConfig::GetInstance().GetCurrentLanguage(iso2->GetPlatform() != DiscIO::IVolume::GAMECUBE_DISC);
-
switch (sortData)
{
case CGameListCtrl::COLUMN_TITLE:
- if (!strcasecmp(iso1->GetName(languageOne).c_str(), iso2->GetName(languageOther).c_str()))
+ if (!strcasecmp(iso1->GetName().c_str(), iso2->GetName().c_str()))
{
if (iso1->GetUniqueID() != iso2->GetUniqueID())
return t * (iso1->GetUniqueID() > iso2->GetUniqueID() ? 1 : -1);
@@ -98,8 +95,7 @@ static int CompareGameListItems(const GameListItem* iso1, const GameListItem* is
if (iso1->GetDiscNumber() != iso2->GetDiscNumber())
return t * (iso1->GetDiscNumber() > iso2->GetDiscNumber() ? 1 : -1);
}
- return strcasecmp(iso1->GetName(languageOne).c_str(),
- iso2->GetName(languageOther).c_str()) * t;
+ return strcasecmp(iso1->GetName().c_str(), iso2->GetName().c_str()) * t;
case CGameListCtrl::COLUMN_MAKER:
return strcasecmp(iso1->GetCompany().c_str(), iso2->GetCompany().c_str()) * t;
case CGameListCtrl::COLUMN_ID:
@@ -388,46 +384,6 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
wxString name = StrToWxStr(rISOFile.GetName());
- // 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() && rISOFile.GetUniqueID().size() > 3)
- {
- 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 = rISOFile.GetUniqueID();
-
- // Ignore publisher ID for WAD files
- if (rISOFile.GetPlatform() == DiscIO::IVolume::WII_WAD)
- game_id.erase(game_id.size() - 2);
-
- if (line.substr(0, equals_index - 1) == game_id)
- {
- name = StrToWxStr(StripSpaces(line.substr(equals_index + 1)));
- break;
- }
- }
- titlestxt.close();
- }
-
- std::string title;
- IniFile gameini = SConfig::LoadGameIni(rISOFile.GetUniqueID(), rISOFile.GetRevision());
- if (gameini.GetIfExists("EmuState", "Title", &title))
- name = StrToWxStr(title);
-
int disc_number = rISOFile.GetDiscNumber() + 1;
if (disc_number > 1 && name.Lower().find(wxString::Format("disc %i", disc_number)) == std::string::npos
&& name.Lower().find(wxString::Format("disc%i", disc_number)) == std::string::npos)
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
diff --git a/Source/Core/DolphinWX/ISOFile.h b/Source/Core/DolphinWX/ISOFile.h
index 4ede1a11c9..da5c80a300 100644
--- a/Source/Core/DolphinWX/ISOFile.h
+++ b/Source/Core/DolphinWX/ISOFile.h
@@ -78,6 +78,9 @@ private:
int m_ImageWidth, m_ImageHeight;
u8 m_disc_number;
+ std::string m_custom_name;
+ bool m_has_custom_name;
+
bool LoadFromCache();
void SaveToCache();