mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 15:55:31 +01:00
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.
This commit is contained in:
parent
45c1cfa078
commit
10aafff5b9
@ -83,13 +83,10 @@ static int CompareGameListItems(const GameListItem* iso1, const GameListItem* is
|
|||||||
sortData = -sortData;
|
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)
|
switch (sortData)
|
||||||
{
|
{
|
||||||
case CGameListCtrl::COLUMN_TITLE:
|
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())
|
if (iso1->GetUniqueID() != iso2->GetUniqueID())
|
||||||
return t * (iso1->GetUniqueID() > iso2->GetUniqueID() ? 1 : -1);
|
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())
|
if (iso1->GetDiscNumber() != iso2->GetDiscNumber())
|
||||||
return t * (iso1->GetDiscNumber() > iso2->GetDiscNumber() ? 1 : -1);
|
return t * (iso1->GetDiscNumber() > iso2->GetDiscNumber() ? 1 : -1);
|
||||||
}
|
}
|
||||||
return strcasecmp(iso1->GetName(languageOne).c_str(),
|
return strcasecmp(iso1->GetName().c_str(), iso2->GetName().c_str()) * t;
|
||||||
iso2->GetName(languageOther).c_str()) * t;
|
|
||||||
case CGameListCtrl::COLUMN_MAKER:
|
case CGameListCtrl::COLUMN_MAKER:
|
||||||
return strcasecmp(iso1->GetCompany().c_str(), iso2->GetCompany().c_str()) * t;
|
return strcasecmp(iso1->GetCompany().c_str(), iso2->GetCompany().c_str()) * t;
|
||||||
case CGameListCtrl::COLUMN_ID:
|
case CGameListCtrl::COLUMN_ID:
|
||||||
@ -388,46 +384,6 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
|||||||
|
|
||||||
wxString name = StrToWxStr(rISOFile.GetName());
|
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;
|
int disc_number = rISOFile.GetDiscNumber() + 1;
|
||||||
if (disc_number > 1 && name.Lower().find(wxString::Format("disc %i", disc_number)) == std::string::npos
|
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)
|
&& name.Lower().find(wxString::Format("disc%i", disc_number)) == std::string::npos)
|
||||||
|
@ -73,6 +73,7 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
|||||||
, m_ImageWidth(0)
|
, m_ImageWidth(0)
|
||||||
, m_ImageHeight(0)
|
, m_ImageHeight(0)
|
||||||
, m_disc_number(0)
|
, m_disc_number(0)
|
||||||
|
, m_has_custom_name(false)
|
||||||
{
|
{
|
||||||
if (LoadFromCache())
|
if (LoadFromCache())
|
||||||
{
|
{
|
||||||
@ -130,6 +131,44 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
|||||||
IniFile ini = SConfig::LoadGameIni(m_UniqueID, m_Revision);
|
IniFile ini = SConfig::LoadGameIni(m_UniqueID, m_Revision);
|
||||||
ini.GetIfExists("EmuState", "EmulationStateId", &m_emu_state);
|
ini.GetIfExists("EmuState", "EmulationStateId", &m_emu_state);
|
||||||
ini.GetIfExists("EmuState", "EmulationIssues", &m_issues);
|
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())
|
if (!IsValid() && IsElfOrDol())
|
||||||
@ -200,12 +239,10 @@ void GameListItem::DoState(PointerWrap &p)
|
|||||||
|
|
||||||
bool GameListItem::IsElfOrDol() const
|
bool GameListItem::IsElfOrDol() const
|
||||||
{
|
{
|
||||||
const std::string name = GetName();
|
const size_t pos = m_FileName.rfind('.');
|
||||||
const size_t pos = name.rfind('.');
|
|
||||||
|
|
||||||
if (pos != std::string::npos)
|
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);
|
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
||||||
|
|
||||||
return ext == ".elf" || ext == ".dol";
|
return ext == ".elf" || ext == ".dol";
|
||||||
@ -290,17 +327,18 @@ std::string GameListItem::GetName(DiscIO::IVolume::ELanguage language) const
|
|||||||
|
|
||||||
std::string GameListItem::GetName() const
|
std::string GameListItem::GetName() const
|
||||||
{
|
{
|
||||||
|
if (m_has_custom_name)
|
||||||
|
return m_custom_name;
|
||||||
|
|
||||||
bool wii = m_Platform != DiscIO::IVolume::GAMECUBE_DISC;
|
bool wii = m_Platform != DiscIO::IVolume::GAMECUBE_DISC;
|
||||||
std::string name = GetName(SConfig::GetInstance().GetCurrentLanguage(wii));
|
std::string name = GetName(SConfig::GetInstance().GetCurrentLanguage(wii));
|
||||||
if (name.empty())
|
if (!name.empty())
|
||||||
{
|
return name;
|
||||||
std::string ext;
|
|
||||||
|
|
||||||
// No usable name, return filename (better than nothing)
|
// No usable name, return filename (better than nothing)
|
||||||
SplitPath(GetFileName(), nullptr, &name, &ext);
|
std::string ext;
|
||||||
return name + ext;
|
SplitPath(GetFileName(), nullptr, &name, &ext);
|
||||||
}
|
return name + ext;
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<DiscIO::IVolume::ELanguage> GameListItem::GetLanguages() const
|
std::vector<DiscIO::IVolume::ELanguage> GameListItem::GetLanguages() const
|
||||||
|
@ -78,6 +78,9 @@ private:
|
|||||||
int m_ImageWidth, m_ImageHeight;
|
int m_ImageWidth, m_ImageHeight;
|
||||||
u8 m_disc_number;
|
u8 m_disc_number;
|
||||||
|
|
||||||
|
std::string m_custom_name;
|
||||||
|
bool m_has_custom_name;
|
||||||
|
|
||||||
bool LoadFromCache();
|
bool LoadFromCache();
|
||||||
void SaveToCache();
|
void SaveToCache();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user