Make 'load defaults' work for per-game configs. Move 'stop' code into PSP_Shutdown

This commit is contained in:
Peter Tissen 2014-12-19 14:52:44 +01:00
parent 664ac1061f
commit a5fcf9dd5f
5 changed files with 18 additions and 17 deletions

View file

@ -1060,10 +1060,18 @@ const std::string Config::FindConfigFile(const std::string &baseFilename) {
} }
void Config::RestoreDefaults() { void Config::RestoreDefaults() {
if(File::Exists(iniFilename_)) if (bGameSpecific)
File::Delete(iniFilename_); {
recentIsos.clear(); deleteGameConfig(gameId);
currentDirectory = ""; createGameConfig(gameId);
}
else
{
if (File::Exists(iniFilename_))
File::Delete(iniFilename_);
recentIsos.clear();
currentDirectory = "";
}
Load(); Load();
} }
@ -1092,7 +1100,6 @@ bool Config::createGameConfig(const std::string &pGameId)
} }
File::CreateEmptyFile(fullIniFilePath); File::CreateEmptyFile(fullIniFilePath);
g_Config.saveGameConfig(pGameId);
return true; return true;
} }
@ -1101,11 +1108,6 @@ bool Config::deleteGameConfig(const std::string& pGameId)
{ {
std::string fullIniFilePath = getGameConfigFile(pGameId); std::string fullIniFilePath = getGameConfigFile(pGameId);
if (pGameId == gameId)
{
unloadGameConfig();
Load(iniFilename_.c_str(),controllerIniFilename_.c_str());
}
File::Delete(fullIniFilePath); File::Delete(fullIniFilePath);
return true; return true;
} }
@ -1150,7 +1152,6 @@ bool Config::loadGameConfig(const std::string &pGameId)
if (!hasGameConfig(pGameId)) if (!hasGameConfig(pGameId))
{ {
INFO_LOG(LOADER, "Failed to read %s. No game-specific settings found, using global defaults.", iniFileNameFull.c_str()); INFO_LOG(LOADER, "Failed to read %s. No game-specific settings found, using global defaults.", iniFileNameFull.c_str());
// NO game specific config file found
return false; return false;
} }

View file

@ -441,6 +441,7 @@ void PSP_Shutdown() {
pspIsInited = false; pspIsInited = false;
pspIsIniting = false; pspIsIniting = false;
pspIsQuiting = false; pspIsQuiting = false;
g_Config.unloadGameConfig();
} }
void PSP_RunLoopUntil(u64 globalticks) { void PSP_RunLoopUntil(u64 globalticks) {

View file

@ -116,6 +116,8 @@ UI::EventReturn GameScreen::OnCreateConfig(UI::EventParams &e)
{ {
GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_,0); GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_,0);
g_Config.createGameConfig(info->id); g_Config.createGameConfig(info->id);
g_Config.saveGameConfig(info->id);
screenManager()->topScreen()->RecreateViews(); screenManager()->topScreen()->RecreateViews();
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }

View file

@ -1226,7 +1226,6 @@ void GamePauseScreen::onFinish(DialogResult result) {
UI::EventReturn GamePauseScreen::OnExitToMenu(UI::EventParams &e) { UI::EventReturn GamePauseScreen::OnExitToMenu(UI::EventParams &e) {
screenManager()->finishDialog(this, DR_OK); screenManager()->finishDialog(this, DR_OK);
NativeMessageReceived("stop","");
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
@ -1272,6 +1271,7 @@ void GamePauseScreen::CallbackDeleteConfig(bool yes)
{ {
GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_, 0); GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_, 0);
g_Config.deleteGameConfig(info->id); g_Config.deleteGameConfig(info->id);
g_Config.unloadGameConfig();
screenManager()->RecreateAllViews(); screenManager()->RecreateAllViews();
} }
} }
@ -1281,6 +1281,8 @@ UI::EventReturn GamePauseScreen::OnCreateConfig(UI::EventParams &e)
std::string gameId = g_paramSFO.GetValueString("DISC_ID"); std::string gameId = g_paramSFO.GetValueString("DISC_ID");
g_Config.createGameConfig(gameId); g_Config.createGameConfig(gameId);
g_Config.changeGameSpecific(gameId); g_Config.changeGameSpecific(gameId);
g_Config.saveGameConfig(gameId);
screenManager()->topScreen()->RecreateViews(); screenManager()->topScreen()->RecreateViews();
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }

View file

@ -760,11 +760,6 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
if (msg == "inputDeviceConnected") { if (msg == "inputDeviceConnected") {
KeyMap::NotifyPadConnected(value); KeyMap::NotifyPadConnected(value);
} }
else if (msg == "stop")
{
g_Config.Save();
g_Config.unloadGameConfig();
}
} }
void NativeUpdate(InputState &input) { void NativeUpdate(InputState &input) {