Merge pull request #2120 from JosJuice/show-default-gameini
ISOProperties: Allow opening region-free INIs with "Show Defaults" button
This commit is contained in:
commit
4f9fcbaba9
|
@ -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);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -149,22 +149,21 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it really necessary to use GetTitleID in case GetUniqueID fails?
|
// TODO: Is it really necessary to use GetTitleID in case GetUniqueID fails?
|
||||||
std::string _iniFilename = OpenISO->GetUniqueID();
|
game_id = OpenISO->GetUniqueID();
|
||||||
if (_iniFilename.empty())
|
if (game_id.empty())
|
||||||
{
|
{
|
||||||
u8 title_id[8];
|
u8 game_id_bytes[8];
|
||||||
if (OpenISO->GetTitleID(title_id))
|
if (OpenISO->GetTitleID(game_id_bytes))
|
||||||
{
|
{
|
||||||
_iniFilename = StringFromFormat("%016" PRIx64, Common::swap64(title_id));
|
game_id = StringFromFormat("%016" PRIx64, Common::swap64(game_id_bytes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load game INIs
|
// Load game INIs
|
||||||
GameIniFileDefault = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + _iniFilename + ".ini";
|
GameIniFileLocal = File::GetUserPath(D_GAMESETTINGS_IDX) + game_id + ".ini";
|
||||||
GameIniFileLocal = File::GetUserPath(D_GAMESETTINGS_IDX) + _iniFilename + ".ini";
|
GameIniDefault = SCoreStartupParameter::LoadDefaultGameIni(game_id, OpenISO->GetRevision());
|
||||||
GameIniDefault = SCoreStartupParameter::LoadDefaultGameIni(_iniFilename, OpenISO->GetRevision());
|
GameIniLocal = SCoreStartupParameter::LoadLocalGameIni(game_id, OpenISO->GetRevision());
|
||||||
GameIniLocal = SCoreStartupParameter::LoadLocalGameIni(_iniFilename, OpenISO->GetRevision());
|
|
||||||
|
|
||||||
// Setup GUI
|
// Setup GUI
|
||||||
OpenGameListItem = new GameListItem(fileName);
|
OpenGameListItem = new GameListItem(fileName);
|
||||||
|
@ -643,7 +642,16 @@ void CISOProperties::CreateGUIControls(bool IsWad)
|
||||||
sButtons->Add(new wxButton(this, wxID_OK, _("Close")));
|
sButtons->Add(new wxButton(this, wxID_OK, _("Close")));
|
||||||
|
|
||||||
// If there is no default gameini, disable the button.
|
// If there is no default gameini, disable the button.
|
||||||
if (!File::Exists(GameIniFileDefault))
|
bool game_ini_exists = false;
|
||||||
|
for (const std::string& ini_filename : SCoreStartupParameter::GetGameIniFilenames(game_id, OpenISO->GetRevision()))
|
||||||
|
{
|
||||||
|
if (File::Exists(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + ini_filename))
|
||||||
|
{
|
||||||
|
game_ini_exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!game_ini_exists)
|
||||||
EditConfigDefault->Disable();
|
EditConfigDefault->Disable();
|
||||||
|
|
||||||
// Add notebook and buttons to the dialog
|
// Add notebook and buttons to the dialog
|
||||||
|
@ -1283,9 +1291,16 @@ void CISOProperties::OnComputeMD5Sum(wxCommandEvent& WXUNUSED (event))
|
||||||
m_MD5Sum->SetValue(output_string);
|
m_MD5Sum->SetValue(output_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Opens all pre-defined INIs for the game. If there are multiple ones,
|
||||||
|
// they will all be opened, but there is usually only one
|
||||||
void CISOProperties::OnShowDefaultConfig(wxCommandEvent& WXUNUSED (event))
|
void CISOProperties::OnShowDefaultConfig(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
LaunchExternalEditor(GameIniFileDefault);
|
for (const std::string& filename : SCoreStartupParameter::GetGameIniFilenames(game_id, OpenISO->GetRevision()))
|
||||||
|
{
|
||||||
|
std::string path = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename;
|
||||||
|
if (File::Exists(path))
|
||||||
|
LaunchExternalEditor(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CISOProperties::ListSelectionChanged(wxCommandEvent& event)
|
void CISOProperties::ListSelectionChanged(wxCommandEvent& event)
|
||||||
|
|
|
@ -241,8 +241,8 @@ private:
|
||||||
|
|
||||||
IniFile GameIniDefault;
|
IniFile GameIniDefault;
|
||||||
IniFile GameIniLocal;
|
IniFile GameIniLocal;
|
||||||
std::string GameIniFileDefault;
|
|
||||||
std::string GameIniFileLocal;
|
std::string GameIniFileLocal;
|
||||||
|
std::string game_id;
|
||||||
|
|
||||||
std::set<std::string> DefaultPatches;
|
std::set<std::string> DefaultPatches;
|
||||||
std::set<std::string> DefaultCheats;
|
std::set<std::string> DefaultCheats;
|
||||||
|
|
Loading…
Reference in New Issue