mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-06 16:18:58 +00:00
Unify GetGameIniFilenames
This deduplicates code and fixes the new config system's lack of 1-char game ID INI support.
This commit is contained in:
parent
1de9bf2cca
commit
d4f5038571
5 changed files with 23 additions and 39 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "Core/Analytics.h"
|
||||
#include "Core/Boot/Boot.h"
|
||||
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/FifoPlayer/FifoDataFile.h"
|
||||
#include "Core/HLE/HLE.h"
|
||||
|
@ -1082,7 +1083,7 @@ IniFile SConfig::LoadGameIni() const
|
|||
IniFile SConfig::LoadDefaultGameIni(const std::string& id, std::optional<u16> revision)
|
||||
{
|
||||
IniFile game_ini;
|
||||
for (const std::string& filename : GetGameIniFilenames(id, revision))
|
||||
for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision))
|
||||
game_ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true);
|
||||
return game_ini;
|
||||
}
|
||||
|
@ -1090,7 +1091,7 @@ IniFile SConfig::LoadDefaultGameIni(const std::string& id, std::optional<u16> re
|
|||
IniFile SConfig::LoadLocalGameIni(const std::string& id, std::optional<u16> revision)
|
||||
{
|
||||
IniFile game_ini;
|
||||
for (const std::string& filename : GetGameIniFilenames(id, revision))
|
||||
for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision))
|
||||
game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true);
|
||||
return game_ini;
|
||||
}
|
||||
|
@ -1098,35 +1099,9 @@ IniFile SConfig::LoadLocalGameIni(const std::string& id, std::optional<u16> revi
|
|||
IniFile SConfig::LoadGameIni(const std::string& id, std::optional<u16> revision)
|
||||
{
|
||||
IniFile game_ini;
|
||||
for (const std::string& filename : GetGameIniFilenames(id, revision))
|
||||
for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision))
|
||||
game_ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true);
|
||||
for (const std::string& filename : GetGameIniFilenames(id, revision))
|
||||
for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision))
|
||||
game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true);
|
||||
return game_ini;
|
||||
}
|
||||
|
||||
// Returns all possible filenames in ascending order of priority
|
||||
std::vector<std::string> SConfig::GetGameIniFilenames(const std::string& id,
|
||||
std::optional<u16> revision)
|
||||
{
|
||||
std::vector<std::string> filenames;
|
||||
|
||||
if (id.empty())
|
||||
return filenames;
|
||||
|
||||
// INIs that match the system code (unique for each Virtual Console system)
|
||||
filenames.push_back(id.substr(0, 1) + ".ini");
|
||||
|
||||
// INIs that match all regions
|
||||
if (id.size() >= 4)
|
||||
filenames.push_back(id.substr(0, 3) + ".ini");
|
||||
|
||||
// Regular INIs
|
||||
filenames.push_back(id + ".ini");
|
||||
|
||||
// INIs with specific revisions
|
||||
if (revision)
|
||||
filenames.push_back(id + StringFromFormat("r%d", *revision) + ".ini");
|
||||
|
||||
return filenames;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue