Use CoreParameter's game INI functions in more places

This commit is contained in:
JosJuice 2015-02-07 21:27:26 +01:00
parent e186104960
commit f9d6c17c08
7 changed files with 51 additions and 51 deletions

View File

@ -378,34 +378,57 @@ void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::stri
IniFile SCoreStartupParameter::LoadDefaultGameIni() const
{
IniFile game_ini;
LoadGameIni(&game_ini, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP);
LoadGameIni(&game_ini, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP, GetUniqueID(), m_revision);
return game_ini;
}
IniFile SCoreStartupParameter::LoadLocalGameIni() const
{
IniFile game_ini;
LoadGameIni(&game_ini, File::GetUserPath(D_GAMESETTINGS_IDX));
LoadGameIni(&game_ini, File::GetUserPath(D_GAMESETTINGS_IDX), GetUniqueID(), m_revision);
return game_ini;
}
IniFile SCoreStartupParameter::LoadGameIni() const
{
IniFile game_ini;
LoadGameIni(&game_ini, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP);
LoadGameIni(&game_ini, File::GetUserPath(D_GAMESETTINGS_IDX));
LoadGameIni(&game_ini, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP, GetUniqueID(), m_revision);
LoadGameIni(&game_ini, File::GetUserPath(D_GAMESETTINGS_IDX), GetUniqueID(), m_revision);
return game_ini;
}
void SCoreStartupParameter::LoadGameIni(IniFile* game_ini, const std::string& path) const
IniFile SCoreStartupParameter::LoadDefaultGameIni(const std::string& id, int revision)
{
IniFile game_ini;
LoadGameIni(&game_ini, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP, id, revision);
return game_ini;
}
IniFile SCoreStartupParameter::LoadLocalGameIni(const std::string& id, int revision)
{
IniFile game_ini;
LoadGameIni(&game_ini, File::GetUserPath(D_GAMESETTINGS_IDX), id, revision);
return game_ini;
}
IniFile SCoreStartupParameter::LoadGameIni(const std::string& id, int revision)
{
IniFile game_ini;
LoadGameIni(&game_ini, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP, id, revision);
LoadGameIni(&game_ini, File::GetUserPath(D_GAMESETTINGS_IDX), id, revision);
return game_ini;
}
void SCoreStartupParameter::LoadGameIni(IniFile* game_ini, const std::string& path,
const std::string& id, int revision)
{
// INIs that match all regions
if (GetUniqueID().size() >= 4)
game_ini->Load(path + GetUniqueID().substr(0, 3) + ".ini", true);
if (id.size() >= 4)
game_ini->Load(path + id.substr(0, 3) + ".ini", true);
// Regular INIs
game_ini->Load(path + GetUniqueID() + ".ini", true);
game_ini->Load(path + id + ".ini", true);
// INIs with specific revisions
game_ini->Load(path + GetUniqueID() + StringFromFormat("r%d", m_revision) + ".ini", true);
game_ini->Load(path + id + StringFromFormat("r%d", revision) + ".ini", true);
}

View File

@ -264,6 +264,10 @@ struct SCoreStartupParameter
IniFile LoadLocalGameIni() const;
IniFile LoadGameIni() const;
static IniFile LoadDefaultGameIni(const std::string& id, int revision);
static IniFile LoadLocalGameIni(const std::string& id, int revision);
static IniFile LoadGameIni(const std::string& id, int revision);
private:
void LoadGameIni(IniFile* game_ini, const std::string& path) const;
static void LoadGameIni(IniFile* game_ini, const std::string& path, const std::string& id, int revision);
};

View File

@ -126,10 +126,7 @@ GameFile::GameFile(const QString& fileName)
if (m_valid)
{
IniFile ini;
ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + m_unique_id.toStdString() + ".ini");
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_unique_id.toStdString() + ".ini", true);
IniFile ini = SCoreStartupParameter::LoadGameIni(m_unique_id.toStdString(), m_revision);
std::string issues_temp;
ini.GetIfExists("EmuState", "EmulationStateId", &m_emu_state);
ini.GetIfExists("EmuState", "EmulationIssues", &issues_temp);

View File

@ -462,24 +462,10 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
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;
}
}
}
IniFile gameini = SCoreStartupParameter::LoadGameIni(rISOFile.GetUniqueID(), rISOFile.GetRevision());
if (gameini.GetIfExists("EmuState", "Title", &title))
name = title;
SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);

View File

@ -121,13 +121,9 @@ GameListItem::GameListItem(const std::string& _rFileName)
if (IsValid())
{
IniFile ini;
ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + m_UniqueID + ".ini");
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_UniqueID + ".ini", true);
IniFile::Section* emu_state = ini.GetOrCreateSection("EmuState");
emu_state->Get("EmulationStateId", &m_emu_state);
emu_state->Get("EmulationIssues", &m_issues);
IniFile ini = SCoreStartupParameter::LoadGameIni(m_UniqueID, m_Revision);
ini.GetIfExists("EmuState", "EmulationStateId", &m_emu_state);
ini.GetIfExists("EmuState", "EmulationIssues", &m_issues);
}
if (!m_pImage.empty())

View File

@ -163,11 +163,9 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
}
}
// Load game ini
// Is it really necessary to use GetTitleID in case GetUniqueID fails?
std::string _iniFilename = OpenISO->GetUniqueID();
std::string _iniFilenameRevisionSpecific = _iniFilename + "r" + std::to_string(OpenISO->GetRevision());
if (!_iniFilename.length())
if (_iniFilename.empty())
{
u8 title_id[8];
if (OpenISO->GetTitleID(title_id))
@ -176,13 +174,11 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
}
}
// Load game INIs
GameIniFileDefault = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + _iniFilename + ".ini";
std::string GameIniFileDefaultRevisionSpecific = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + _iniFilenameRevisionSpecific + ".ini";
GameIniFileLocal = File::GetUserPath(D_GAMESETTINGS_IDX) + _iniFilename + ".ini";
GameIniDefault.Load(GameIniFileDefault);
GameIniDefault.Load(GameIniFileDefaultRevisionSpecific, true);
GameIniLocal.Load(GameIniFileLocal);
GameIniDefault = SCoreStartupParameter::LoadDefaultGameIni(_iniFilename, OpenISO->GetRevision());
GameIniLocal = SCoreStartupParameter::LoadLocalGameIni(_iniFilename, OpenISO->GetRevision());
// Setup GUI
OpenGameListItem = new GameListItem(fileName);

View File

@ -17,7 +17,6 @@ InputConfig::~InputConfig()
bool InputConfig::LoadConfig(bool isGC)
{
IniFile inifile;
IniFile game_ini;
bool useProfile[MAX_BBMOTES] = {false, false, false, false, false};
std::string num[MAX_BBMOTES] = {"1", "2", "3", "4", "BB"};
std::string profile[MAX_BBMOTES];
@ -37,8 +36,7 @@ bool InputConfig::LoadConfig(bool isGC)
path = "Profiles/Wiimote/";
}
game_ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini");
game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini", true);
IniFile game_ini = SConfig::GetInstance().m_LocalCoreStartupParameter.LoadGameIni();
IniFile::Section* control_section = game_ini.GetOrCreateSection("Controls");
for (int i = 0; i < 4; i++)
@ -53,7 +51,7 @@ bool InputConfig::LoadConfig(bool isGC)
}
else
{
// TODO: Having a PanicAlert for this is dumb.
// TODO: PanicAlert shouldn't be used for this.
PanicAlertT("Selected controller profile does not exist");
}
}