Merge pull request #2242 from Stevoisiak/Titles.txt

GameListCtrl: Improvements for reading custom game titles
This commit is contained in:
Scott Mansell 2015-09-13 14:03:47 +12:00
commit 45c1cfa078
1 changed files with 16 additions and 2 deletions

View File

@ -388,9 +388,16 @@ 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; std::ifstream titlestxt;
OpenFStream(titlestxt, File::GetUserPath(D_LOAD_IDX) + "titles.txt", std::ios::in); 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) if (titlestxt.is_open() && rISOFile.GetUniqueID().size() > 3)
{ {
while (!titlestxt.eof()) while (!titlestxt.eof())
@ -400,9 +407,16 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
if (!std::getline(titlestxt, line) && titlestxt.eof()) if (!std::getline(titlestxt, line) && titlestxt.eof())
break; break;
if (line.substr(0,rISOFile.GetUniqueID().size()) == rISOFile.GetUniqueID()) 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(line.substr(rISOFile.GetUniqueID().size() + 3)); name = StrToWxStr(StripSpaces(line.substr(equals_index + 1)));
break; break;
} }
} }