From b1e14a65a22ed6ffd658a60ad22a7ccbbbf6c54f Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Wed, 22 Oct 2014 17:25:00 -0400 Subject: [PATCH] Read game title from ini file, or titles.txt if it exists. --- Source/Core/Common/CommonPaths.h | 2 +- Source/Core/Common/FileUtil.cpp | 7 +++- Source/Core/Common/FileUtil.h | 1 + Source/Core/DolphinWX/GameListCtrl.cpp | 45 +++++++++++++++++++++++++- 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/CommonPaths.h b/Source/Core/Common/CommonPaths.h index a3b15a2e8c..0f3cb682c1 100644 --- a/Source/Core/Common/CommonPaths.h +++ b/Source/Core/Common/CommonPaths.h @@ -62,7 +62,7 @@ #define STATESAVES_DIR "StateSaves" #define SCREENSHOTS_DIR "ScreenShots" #define LOAD_DIR "Load" -#define HIRES_TEXTURES_DIR LOAD_DIR DIR_SEP "Textures" +#define HIRES_TEXTURES_DIR "Textures" #define DUMP_DIR "Dump" #define DUMP_TEXTURES_DIR "Textures" #define DUMP_FRAMES_DIR "Frames" diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 1cce81ed81..56d326d0fa 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -825,7 +825,8 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; - paths[D_HIRESTEXTURES_IDX] = paths[D_USER_IDX] + HIRES_TEXTURES_DIR DIR_SEP; + paths[D_LOAD_IDX] = paths[D_USER_IDX] + LOAD_DIR DIR_SEP; + paths[D_HIRESTEXTURES_IDX] = paths[D_LOAD_IDX] + HIRES_TEXTURES_DIR DIR_SEP; paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; @@ -922,6 +923,10 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new case D_LOGS_IDX: paths[D_MAILLOGS_IDX] = paths[D_LOGS_IDX] + MAIL_LOGS_DIR DIR_SEP; paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; + break; + + case D_LOAD_IDX: + paths[D_HIRESTEXTURES_IDX] = paths[D_LOAD_IDX] + HIRES_TEXTURES_DIR DIR_SEP; } paths[D_WIIUSER_IDX] = paths[D_WIIROOT_IDX] + DIR_SEP; diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h index b587129761..dba184ba4e 100644 --- a/Source/Core/Common/FileUtil.h +++ b/Source/Core/Common/FileUtil.h @@ -36,6 +36,7 @@ enum { D_DUMPAUDIO_IDX, D_DUMPTEXTURES_IDX, D_DUMPDSP_IDX, + D_LOAD_IDX, D_LOGS_IDX, D_MAILLOGS_IDX, D_WIISYSCONF_IDX, diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index b801199d84..2addf1f64a 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -40,6 +40,7 @@ #include #include "Common/CDUtils.h" +#include "Common/CommonPaths.h" #include "Common/CommonTypes.h" #include "Common/FileSearch.h" #include "Common/FileUtil.h" @@ -437,7 +438,49 @@ void CGameListCtrl::InsertItemInReportView(long _Index) SelectedLanguage = SConfig::GetInstance().m_SYSCONF->GetData("IPL.LNG"); } - std::string const name = rISOFile.GetName(SelectedLanguage); + std::string name = rISOFile.GetName(SelectedLanguage); + + std::ifstream titlestxt; + OpenFStream(titlestxt, File::GetUserPath(D_LOAD_IDX) + "titles.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; + + if (line.substr(0,rISOFile.GetUniqueID().size()) == rISOFile.GetUniqueID()) + { + name = line.substr(rISOFile.GetUniqueID().size() + 3); + break; + } + + } + titlestxt.close(); + } + + std::string GameIni[3]; + GameIni[0] = File::GetUserPath(D_GAMESETTINGS_IDX) + rISOFile.GetUniqueID() + ".ini"; + GameIni[1] = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + rISOFile.GetUniqueID() + std::to_string(rISOFile.GetRevision()) + ".ini"; + GameIni[2] = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + rISOFile.GetUniqueID() + ".ini"; + std::string title; + IniFile gameini; + for (int i = 0; i < 3; ++i) + { + if (File::Exists(GameIni[i])) + { + gameini.Load(GameIni[i]); + if (gameini.GetIfExists("EmuState", "Title", &title)) + { + name = title; + break; + } + } + } + SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1); // We show the company string on GameCube only