CoreParameter: Refactor game INI code
This commit is contained in:
parent
7d5a558f31
commit
a1f0f60a79
|
@ -375,58 +375,59 @@ void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::stri
|
||||||
|
|
||||||
IniFile SCoreStartupParameter::LoadDefaultGameIni() const
|
IniFile SCoreStartupParameter::LoadDefaultGameIni() const
|
||||||
{
|
{
|
||||||
IniFile game_ini;
|
return LoadDefaultGameIni(GetUniqueID(), m_revision);
|
||||||
LoadGameIni(&game_ini, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP, GetUniqueID(), m_revision);
|
|
||||||
return game_ini;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IniFile SCoreStartupParameter::LoadLocalGameIni() const
|
IniFile SCoreStartupParameter::LoadLocalGameIni() const
|
||||||
{
|
{
|
||||||
IniFile game_ini;
|
return LoadLocalGameIni(GetUniqueID(), m_revision);
|
||||||
LoadGameIni(&game_ini, File::GetUserPath(D_GAMESETTINGS_IDX), GetUniqueID(), m_revision);
|
|
||||||
return game_ini;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IniFile SCoreStartupParameter::LoadGameIni() const
|
IniFile SCoreStartupParameter::LoadGameIni() const
|
||||||
{
|
{
|
||||||
IniFile game_ini;
|
return LoadGameIni(GetUniqueID(), m_revision);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IniFile SCoreStartupParameter::LoadDefaultGameIni(const std::string& id, int revision)
|
IniFile SCoreStartupParameter::LoadDefaultGameIni(const std::string& id, int revision)
|
||||||
{
|
{
|
||||||
IniFile game_ini;
|
IniFile game_ini;
|
||||||
LoadGameIni(&game_ini, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP, id, revision);
|
for (const std::string& filename : GetGameIniFilenames(id, revision))
|
||||||
|
game_ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true);
|
||||||
return game_ini;
|
return game_ini;
|
||||||
}
|
}
|
||||||
|
|
||||||
IniFile SCoreStartupParameter::LoadLocalGameIni(const std::string& id, int revision)
|
IniFile SCoreStartupParameter::LoadLocalGameIni(const std::string& id, int revision)
|
||||||
{
|
{
|
||||||
IniFile game_ini;
|
IniFile game_ini;
|
||||||
LoadGameIni(&game_ini, File::GetUserPath(D_GAMESETTINGS_IDX), id, revision);
|
for (const std::string& filename : GetGameIniFilenames(id, revision))
|
||||||
|
game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true);
|
||||||
return game_ini;
|
return game_ini;
|
||||||
}
|
}
|
||||||
|
|
||||||
IniFile SCoreStartupParameter::LoadGameIni(const std::string& id, int revision)
|
IniFile SCoreStartupParameter::LoadGameIni(const std::string& id, int revision)
|
||||||
{
|
{
|
||||||
IniFile game_ini;
|
IniFile game_ini;
|
||||||
LoadGameIni(&game_ini, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP, id, revision);
|
for (const std::string& filename : GetGameIniFilenames(id, revision))
|
||||||
LoadGameIni(&game_ini, File::GetUserPath(D_GAMESETTINGS_IDX), id, revision);
|
game_ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true);
|
||||||
|
for (const std::string& filename : GetGameIniFilenames(id, revision))
|
||||||
|
game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true);
|
||||||
return game_ini;
|
return game_ini;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCoreStartupParameter::LoadGameIni(IniFile* game_ini, const std::string& path,
|
// Returns all possible filenames in ascending order of priority
|
||||||
const std::string& id, int revision)
|
std::vector<std::string> SCoreStartupParameter::GetGameIniFilenames(const std::string& id, int revision)
|
||||||
{
|
{
|
||||||
|
std::vector<std::string> filenames;
|
||||||
|
|
||||||
// INIs that match all regions
|
// INIs that match all regions
|
||||||
if (id.size() >= 4)
|
if (id.size() >= 4)
|
||||||
game_ini->Load(path + id.substr(0, 3) + ".ini", true);
|
filenames.push_back(id.substr(0, 3) + ".ini");
|
||||||
|
|
||||||
// Regular INIs
|
// Regular INIs
|
||||||
game_ini->Load(path + id + ".ini", true);
|
filenames.push_back(id + ".ini");
|
||||||
|
|
||||||
// INIs with specific revisions
|
// INIs with specific revisions
|
||||||
game_ini->Load(path + id + StringFromFormat("r%d", revision) + ".ini", true);
|
filenames.push_back(id + StringFromFormat("r%d", revision) + ".ini");
|
||||||
|
|
||||||
|
return filenames;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,5 @@ struct SCoreStartupParameter
|
||||||
static IniFile LoadLocalGameIni(const std::string& id, int revision);
|
static IniFile LoadLocalGameIni(const std::string& id, int revision);
|
||||||
static IniFile LoadGameIni(const std::string& id, int revision);
|
static IniFile LoadGameIni(const std::string& id, int revision);
|
||||||
|
|
||||||
private:
|
static std::vector<std::string> GetGameIniFilenames(const std::string& id, int revision);
|
||||||
static void LoadGameIni(IniFile* game_ini, const std::string& path, const std::string& id, int revision);
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue