Merge pull request #7195 from Bigpet/copydefaults

copy the current config when creating a pre-game config
This commit is contained in:
Henrik Rydgård committed 2014-12-20 19:25:31 +01:00
commit 71c9804ffd
7 files changed
+36 -24

No files matched your search

+17 -14
View File
@@ -863,7 +863,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
void Config::Save() {
if (iniFilename_.size() && g_Config.bSaveSettings) {
saveGameConfig();
saveGameConfig(gameId);
CleanRecent();
IniFile iniFile;
@@ -1060,10 +1060,18 @@ const std::string Config::FindConfigFile(const std::string &baseFilename) {
}
void Config::RestoreDefaults() {
if(File::Exists(iniFilename_))
File::Delete(iniFilename_);
recentIsos.clear();
currentDirectory = "";
if (bGameSpecific)
{
deleteGameConfig(gameId);
createGameConfig(gameId);
}
else
{
if (File::Exists(iniFilename_))
File::Delete(iniFilename_);
recentIsos.clear();
currentDirectory = "";
}
Load();
}
@@ -1092,6 +1100,7 @@ bool Config::createGameConfig(const std::string &pGameId)
}
File::CreateEmptyFile(fullIniFilePath);
return true;
}
@@ -1099,11 +1108,6 @@ bool Config::deleteGameConfig(const std::string& pGameId)
{
std::string fullIniFilePath = getGameConfigFile(pGameId);
if (pGameId == gameId)
{
unloadGameConfig();
Load(iniFilename_.c_str(),controllerIniFilename_.c_str());
}
File::Delete(fullIniFilePath);
return true;
}
@@ -1116,14 +1120,14 @@ std::string Config::getGameConfigFile(const std::string &pGameId)
return iniFileNameFull;
}
bool Config::saveGameConfig()
bool Config::saveGameConfig(const std::string &pGameId)
{
if (!bGameSpecific)
if (pGameId.empty())
{
return false;
}
std::string fullIniFilePath = getGameConfigFile(gameId);
std::string fullIniFilePath = getGameConfigFile(pGameId);
IniFile iniFile;
@@ -1149,7 +1153,6 @@ bool Config::loadGameConfig(const std::string &pGameId)
if (!hasGameConfig(pGameId))
{
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;
}
+1 -1
View File
@@ -353,7 +353,7 @@ public:
bool createGameConfig(const std::string &game_id);
bool deleteGameConfig(const std::string& pGameId);
bool loadGameConfig(const std::string &game_id);
bool saveGameConfig();
bool saveGameConfig(const std::string &pGameId);
void unloadGameConfig();
std::string getGameConfigFile(const std::string &gameId);
bool hasGameConfig(const std::string &game_id);
+1
View File
@@ -442,6 +442,7 @@ void PSP_Shutdown() {
pspIsInited = false;
pspIsIniting = false;
pspIsQuiting = false;
g_Config.unloadGameConfig();
}
void PSP_RunLoopUntil(u64 globalticks) {
+2
View File
@@ -116,6 +116,8 @@ UI::EventReturn GameScreen::OnCreateConfig(UI::EventParams &e)
{
GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_,0);
g_Config.createGameConfig(info->id);
g_Config.saveGameConfig(info->id);
screenManager()->topScreen()->RecreateViews();
return UI::EVENT_DONE;
}
+12 -3
View File
@@ -933,9 +933,18 @@ void GameSettingsScreen::CallbackRestoreDefaults(bool yes) {
UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) {
I18NCategory *de = GetI18NCategory("Developer");
I18NCategory *d = GetI18NCategory("Dialog");
screenManager()->push(
new PromptScreen(de->T("RestoreDefaultSettings", "Are you sure you want to restore all settings(except control mapping)\nback to their defaults?\nYou can't undo this.\nPlease restart PPSSPP after restoring settings."), d->T("OK"), d->T("Cancel"),
std::bind(&GameSettingsScreen::CallbackRestoreDefaults, this, placeholder::_1)));
if (g_Config.bGameSpecific)
{
screenManager()->push(
new PromptScreen(de->T("RestoreGameDefaultSettings", "Are you sure you want to restore the game-specific settings back to the ppsspp defaults?\n"), d->T("OK"), d->T("Cancel"),
std::bind(&GameSettingsScreen::CallbackRestoreDefaults, this, placeholder::_1)));
}
else
{
screenManager()->push(
new PromptScreen(de->T("RestoreDefaultSettings", "Are you sure you want to restore all settings(except control mapping)\nback to their defaults?\nYou can't undo this.\nPlease restart PPSSPP after restoring settings."), d->T("OK"), d->T("Cancel"),
std::bind(&GameSettingsScreen::CallbackRestoreDefaults, this, placeholder::_1)));
}
return UI::EVENT_DONE;
}
+3 -1
View File
@@ -1226,7 +1226,6 @@ void GamePauseScreen::onFinish(DialogResult result) {
UI::EventReturn GamePauseScreen::OnExitToMenu(UI::EventParams &e) {
screenManager()->finishDialog(this, DR_OK);
NativeMessageReceived("stop","");
return UI::EVENT_DONE;
}
@@ -1272,6 +1271,7 @@ void GamePauseScreen::CallbackDeleteConfig(bool yes)
{
GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_, 0);
g_Config.deleteGameConfig(info->id);
g_Config.unloadGameConfig();
screenManager()->RecreateAllViews();
}
}
@@ -1281,6 +1281,8 @@ UI::EventReturn GamePauseScreen::OnCreateConfig(UI::EventParams &e)
std::string gameId = g_paramSFO.GetValueString("DISC_ID");
g_Config.createGameConfig(gameId);
g_Config.changeGameSpecific(gameId);
g_Config.saveGameConfig(gameId);
screenManager()->topScreen()->RecreateViews();
return UI::EVENT_DONE;
}
-5
View File
@@ -789,11 +789,6 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
if (msg == "inputDeviceConnected") {
KeyMap::NotifyPadConnected(value);
}
else if (msg == "stop")
{
g_Config.Save();
g_Config.unloadGameConfig();
}
}
void NativeUpdate(InputState &input) {