mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 17:53:42 +01:00
Just some renaming and cleanup
This commit is contained in:
1 parent
1facc4d485
commit
4edb8e53cd
9 files changed
+60
-53
No files matched your search
+30
-28
@@ -1273,7 +1273,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
||||
// sadly it won't benefit from all the "version conversion" going on up-above
|
||||
// but these configs shouldn't contain older versions anyhow
|
||||
if (gameSpecific_) {
|
||||
loadGameConfig(gameId_, gameIdTitle_);
|
||||
LoadGameConfig(gameId_, gameIdTitle_);
|
||||
}
|
||||
|
||||
PostLoadCleanup();
|
||||
@@ -1293,7 +1293,7 @@ bool Config::Save(const char *saveReason) {
|
||||
}
|
||||
|
||||
if (!iniFilename_.empty() && g_Config.bSaveSettings) {
|
||||
saveGameConfig(gameId_, gameIdTitle_);
|
||||
SaveGameConfig(gameId_, gameIdTitle_);
|
||||
|
||||
PreSaveCleanup();
|
||||
|
||||
@@ -1362,7 +1362,7 @@ bool Config::Save(const char *saveReason) {
|
||||
}
|
||||
INFO_LOG(Log::Loader, "Config saved (%s): '%s' (%0.1f ms)", saveReason, iniFilename_.c_str(), (time_now_d() - startTime) * 1000.0);
|
||||
|
||||
if (!gameSpecific_) //otherwise we already did this in saveGameConfig()
|
||||
if (!gameSpecific_) //otherwise we already did this in SaveGameConfig()
|
||||
{
|
||||
IniFile controllerIniFile;
|
||||
if (!controllerIniFile.Load(controllerIniFilename_)) {
|
||||
@@ -1513,8 +1513,8 @@ const Path Config::FindConfigFile(const std::string &baseFilename, bool *exists)
|
||||
void Config::RestoreDefaults(RestoreSettingsBits whatToRestore, bool log) {
|
||||
if (gameSpecific_) {
|
||||
// TODO: This should be possible to do in a cleaner way.
|
||||
deleteGameConfig(gameId_);
|
||||
createGameConfig(gameId_);
|
||||
DeleteGameConfig(gameId_);
|
||||
CreateGameConfig(gameId_);
|
||||
Load();
|
||||
} else {
|
||||
if (whatToRestore & RestoreSettingsBits::SETTINGS) {
|
||||
@@ -1534,23 +1534,25 @@ void Config::RestoreDefaults(RestoreSettingsBits whatToRestore, bool log) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Config::hasGameConfig(const std::string &pGameId) {
|
||||
bool Config::HasGameConfig(std::string_view gameId) {
|
||||
bool exists = false;
|
||||
Path fullIniFilePath = getGameConfigFile(pGameId, &exists);
|
||||
Path fullIniFilePath = GetGameConfigFile(gameId, &exists);
|
||||
return exists;
|
||||
}
|
||||
|
||||
void Config::changeGameSpecific(const std::string &pGameId, const std::string &title) {
|
||||
if (!reload_)
|
||||
void Config::ChangeGameSpecific(const std::string &pGameId, std::string_view title) {
|
||||
if (!reload_) {
|
||||
Save("changeGameSpecific");
|
||||
}
|
||||
|
||||
gameId_ = pGameId;
|
||||
gameIdTitle_ = title;
|
||||
gameSpecific_ = !pGameId.empty();
|
||||
}
|
||||
|
||||
bool Config::createGameConfig(const std::string &pGameId) {
|
||||
bool Config::CreateGameConfig(std::string_view gameId) {
|
||||
bool exists;
|
||||
Path fullIniFilePath = getGameConfigFile(pGameId, &exists);
|
||||
Path fullIniFilePath = GetGameConfigFile(gameId, &exists);
|
||||
|
||||
if (exists) {
|
||||
INFO_LOG(Log::System, "Game config already exists");
|
||||
@@ -1561,9 +1563,9 @@ bool Config::createGameConfig(const std::string &pGameId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Config::deleteGameConfig(const std::string& pGameId) {
|
||||
bool exists;
|
||||
Path fullIniFilePath = Path(getGameConfigFile(pGameId, &exists));
|
||||
bool Config::DeleteGameConfig(std::string_view gameId) {
|
||||
bool exists = false;
|
||||
Path fullIniFilePath = Path(GetGameConfigFile(gameId, &exists));
|
||||
|
||||
if (exists) {
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_TRASH_BIN)) {
|
||||
@@ -1575,26 +1577,25 @@ bool Config::deleteGameConfig(const std::string& pGameId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Path Config::getGameConfigFile(const std::string &pGameId, bool *exists) {
|
||||
const char *ppssppIniFilename = IsVREnabled() ? "_ppssppvr.ini" : "_ppsspp.ini";
|
||||
std::string iniFileName = pGameId + ppssppIniFilename;
|
||||
Path Config::GetGameConfigFile(std::string_view gameId, bool *exists) {
|
||||
std::string_view ppssppIniFilename = IsVREnabled() ? "_ppssppvr.ini" : "_ppsspp.ini";
|
||||
std::string iniFileName = join(gameId, ppssppIniFilename);
|
||||
Path iniFileNameFull = FindConfigFile(iniFileName, exists);
|
||||
|
||||
return iniFileNameFull;
|
||||
}
|
||||
|
||||
bool Config::saveGameConfig(const std::string &pGameId, const std::string &titleForComment) {
|
||||
if (pGameId.empty()) {
|
||||
bool Config::SaveGameConfig(const std::string &gameId, std::string_view titleForComment) {
|
||||
if (gameId.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool exists;
|
||||
Path fullIniFilePath = getGameConfigFile(pGameId, &exists);
|
||||
Path fullIniFilePath = GetGameConfigFile(gameId, &exists);
|
||||
|
||||
IniFile iniFile;
|
||||
|
||||
Section *top = iniFile.GetOrCreateSection("");
|
||||
top->AddComment(StringFromFormat("Game config for %s - %s", pGameId.c_str(), titleForComment.c_str()));
|
||||
top->AddComment(StringFromFormat("Game config for %s - %.*s", gameId.c_str(), STR_VIEW(titleForComment)));
|
||||
|
||||
PreSaveCleanup();
|
||||
|
||||
@@ -1627,15 +1628,16 @@ bool Config::saveGameConfig(const std::string &pGameId, const std::string &title
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Config::loadGameConfig(const std::string &pGameId, const std::string &title) {
|
||||
bool Config::LoadGameConfig(const std::string &gameId, std::string_view title) {
|
||||
bool exists;
|
||||
Path iniFileNameFull = getGameConfigFile(pGameId, &exists);
|
||||
Path iniFileNameFull = GetGameConfigFile(gameId, &exists);
|
||||
if (!exists) {
|
||||
DEBUG_LOG(Log::Loader, "No game-specific settings found in %s. Using global defaults.", iniFileNameFull.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
changeGameSpecific(pGameId, title);
|
||||
ChangeGameSpecific(gameId, title);
|
||||
|
||||
IniFile iniFile;
|
||||
iniFile.Load(iniFileNameFull);
|
||||
|
||||
@@ -1666,17 +1668,17 @@ bool Config::loadGameConfig(const std::string &pGameId, const std::string &title
|
||||
KeyMap::LoadFromIni(iniFile);
|
||||
|
||||
if (!appendedConfigFileName_.ToString().empty() &&
|
||||
std::find(appendedConfigUpdatedGames_.begin(), appendedConfigUpdatedGames_.end(), pGameId) == appendedConfigUpdatedGames_.end()) {
|
||||
std::find(appendedConfigUpdatedGames_.begin(), appendedConfigUpdatedGames_.end(), gameId) == appendedConfigUpdatedGames_.end()) {
|
||||
|
||||
LoadAppendedConfig();
|
||||
appendedConfigUpdatedGames_.push_back(pGameId);
|
||||
appendedConfigUpdatedGames_.push_back(gameId);
|
||||
}
|
||||
|
||||
PostLoadCleanup();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Config::unloadGameConfig() {
|
||||
void Config::UnloadGameConfig() {
|
||||
if (!gameSpecific_) {
|
||||
return;
|
||||
}
|
||||
|
||||
+10
-8
@@ -622,14 +622,16 @@ public:
|
||||
void RestoreDefaults(RestoreSettingsBits whatToRestore, bool log = false);
|
||||
|
||||
// Per-game config management.
|
||||
void changeGameSpecific(const std::string &gameId = "", const std::string &title = "");
|
||||
bool createGameConfig(const std::string &game_id);
|
||||
bool deleteGameConfig(const std::string& pGameId);
|
||||
bool loadGameConfig(const std::string &game_id, const std::string &title);
|
||||
bool saveGameConfig(const std::string &pGameId, const std::string &title);
|
||||
void unloadGameConfig();
|
||||
Path getGameConfigFile(const std::string &gameId, bool *exists);
|
||||
bool hasGameConfig(const std::string &game_id);
|
||||
void ChangeGameSpecific(const std::string &gameId = "", std::string_view title = "");
|
||||
|
||||
// Note: This doesn't switch to the config, just creates it.
|
||||
bool CreateGameConfig(std::string_view gameId);
|
||||
bool DeleteGameConfig(std::string_view gameId);
|
||||
bool LoadGameConfig(const std::string &game_id, std::string_view title);
|
||||
bool SaveGameConfig(const std::string &pGameId, std::string_view title);
|
||||
void UnloadGameConfig();
|
||||
Path GetGameConfigFile(std::string_view gameId, bool *exists);
|
||||
bool HasGameConfig(std::string_view gameId);
|
||||
bool IsGameSpecific() const { return gameSpecific_; }
|
||||
|
||||
void SetSearchPath(const Path &path);
|
||||
|
||||
+3
-1
@@ -261,7 +261,9 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) {
|
||||
return false;
|
||||
}
|
||||
|
||||
g_Config.loadGameConfig(id, g_paramSFO.GetValueString("TITLE"));
|
||||
// If there's a game-specific config, load it.
|
||||
g_Config.LoadGameConfig(id, g_paramSFO.GetValueString("TITLE"));
|
||||
|
||||
System_PostUIMessage(UIMessage::CONFIG_LOADED);
|
||||
INFO_LOG(Log::Loader, "Loading %s...", bootpath.c_str());
|
||||
// TODO: We can't use the initial error_string pointer.
|
||||
|
||||
+2
-2
@@ -416,7 +416,7 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin
|
||||
g_CoreParameter.mountIsoLoader = ConstructFileLoader(g_CoreParameter.mountIso);
|
||||
}
|
||||
|
||||
// Game-specific settings are load from for example Load_PSP_ISO (which calls g_Config.loadGameConfig).
|
||||
// Game-specific settings are load from for example Load_PSP_ISO (which calls g_Config.LoadGameConfig).
|
||||
// We can't do things that depend on these before the below switch. So for example, the adjustment of the GPU core
|
||||
// to software has now been moved below it.
|
||||
|
||||
@@ -735,7 +735,7 @@ void PSP_Shutdown(bool success) {
|
||||
|
||||
currentMIPS = nullptr;
|
||||
|
||||
g_Config.unloadGameConfig();
|
||||
g_Config.UnloadGameConfig();
|
||||
|
||||
Core_NotifyLifecycle(CoreLifecycle::STOPPED);
|
||||
|
||||
|
||||
@@ -856,7 +856,7 @@ handleELF:
|
||||
|
||||
if (flags_ & GameInfoFlags::PARAM_SFO) {
|
||||
// We fetch the hasConfig together with the params, since that's what fills out the id.
|
||||
info_->hasConfig = g_Config.hasGameConfig(info_->id);
|
||||
info_->hasConfig = g_Config.HasGameConfig(info_->id);
|
||||
}
|
||||
|
||||
if (flags_ & GameInfoFlags::SIZE) {
|
||||
|
||||
+3
-3
@@ -382,8 +382,8 @@ void GameScreen::OnCreateConfig(UI::EventParams &e) {
|
||||
if (!info->Ready(GameInfoFlags::PARAM_SFO)) {
|
||||
return;
|
||||
}
|
||||
g_Config.createGameConfig(info->id);
|
||||
g_Config.saveGameConfig(info->id, info->GetTitle());
|
||||
g_Config.CreateGameConfig(info->id);
|
||||
g_Config.SaveGameConfig(info->id, info->GetTitle());
|
||||
info->hasConfig = true;
|
||||
|
||||
screenManager()->topScreen()->RecreateViews();
|
||||
@@ -400,7 +400,7 @@ void GameScreen::OnDeleteConfig(UI::EventParams &e) {
|
||||
if (!info->Ready(GameInfoFlags::PARAM_SFO)) {
|
||||
return;
|
||||
}
|
||||
g_Config.deleteGameConfig(info->id);
|
||||
g_Config.DeleteGameConfig(info->id);
|
||||
info->hasConfig = false;
|
||||
RecreateViews();
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ void GameSettingsScreen::PreCreateViews() {
|
||||
|
||||
if (editThenRestore_) {
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, gamePath_, GameInfoFlags::PARAM_SFO);
|
||||
g_Config.loadGameConfig(gameID_, info->GetTitle());
|
||||
g_Config.LoadGameConfig(gameID_, info->GetTitle());
|
||||
}
|
||||
|
||||
iAlternateSpeedPercent1_ = g_Config.iFpsLimit1 < 0 ? -1 : (g_Config.iFpsLimit1 * 100) / 60;
|
||||
@@ -1625,8 +1625,8 @@ void GameSettingsScreen::onFinish(DialogResult result) {
|
||||
if (editThenRestore_) {
|
||||
// In case we didn't have the title yet before, try again.
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, gamePath_, GameInfoFlags::PARAM_SFO);
|
||||
g_Config.changeGameSpecific(gameID_, info->GetTitle());
|
||||
g_Config.unloadGameConfig();
|
||||
g_Config.ChangeGameSpecific(gameID_, info->GetTitle());
|
||||
g_Config.UnloadGameConfig();
|
||||
}
|
||||
|
||||
System_Notify(SystemNotification::UI);
|
||||
|
||||
+2
-1
@@ -1516,7 +1516,8 @@ void MainScreen::OnGameSelectedInstant(UI::EventParams &e) {
|
||||
}
|
||||
|
||||
void MainScreen::OnGameSettings(UI::EventParams &e) {
|
||||
screenManager()->push(new GameSettingsScreen(Path(), ""));
|
||||
// Not passing a game ID, changing the global settings.
|
||||
screenManager()->push(new GameSettingsScreen(Path()));
|
||||
}
|
||||
|
||||
void MainScreen::OnCredits(UI::EventParams &e) {
|
||||
|
||||
+6
-6
@@ -531,7 +531,7 @@ void GamePauseScreen::CreateViews() {
|
||||
|
||||
rightColumnItems->Add(new Spacer(20.0));
|
||||
|
||||
if (g_paramSFO.IsValid() && g_Config.hasGameConfig(g_paramSFO.GetDiscID())) {
|
||||
if (g_paramSFO.IsValid() && g_Config.HasGameConfig(g_paramSFO.GetDiscID())) {
|
||||
rightColumnItems->Add(new Choice(pa->T("Game Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings);
|
||||
Choice *delGameConfig = rightColumnItems->Add(new Choice(pa->T("Delete Game Config")));
|
||||
delGameConfig->OnClick.Handle(this, &GamePauseScreen::OnDeleteConfig);
|
||||
@@ -752,8 +752,8 @@ void GamePauseScreen::CallbackDeleteConfig(bool yes) {
|
||||
if (yes) {
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO);
|
||||
if (info->Ready(GameInfoFlags::PARAM_SFO)) {
|
||||
g_Config.unloadGameConfig();
|
||||
g_Config.deleteGameConfig(info->id);
|
||||
g_Config.UnloadGameConfig();
|
||||
g_Config.DeleteGameConfig(info->id);
|
||||
info->hasConfig = false;
|
||||
screenManager()->RecreateAllViews();
|
||||
}
|
||||
@@ -764,9 +764,9 @@ void GamePauseScreen::OnCreateConfig(UI::EventParams &e) {
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO);
|
||||
if (info->Ready(GameInfoFlags::PARAM_SFO)) {
|
||||
std::string gameId = info->id;
|
||||
g_Config.createGameConfig(gameId);
|
||||
g_Config.changeGameSpecific(gameId, info->GetTitle());
|
||||
g_Config.saveGameConfig(gameId, info->GetTitle());
|
||||
g_Config.CreateGameConfig(gameId);
|
||||
g_Config.ChangeGameSpecific(gameId, info->GetTitle());
|
||||
g_Config.SaveGameConfig(gameId, info->GetTitle());
|
||||
if (info) {
|
||||
info->hasConfig = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user