void Config::Save() { if (jitForcedOff) { // if JIT has been forced off, we don't want to screw up the user's ppsspp.ini g_Config.bJit = true; } if (iniFilename_.size() && g_Config.bSaveSettings) { saveGameConfig(gameId_); CleanRecent(); IniFile iniFile; if (!iniFile.Load(iniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str()); } // Need to do this somewhere... bFirstRun = false; IterateSettings(iniFile, [&](IniFile::Section *section, ConfigSetting *setting) { if (!bGameSpecific || !setting->perGame_) { setting->Set(section); } }); IniFile::Section *recent = iniFile.GetOrCreateSection("Recent"); recent->Set("MaxRecent", iMaxRecent); for (int i = 0; i < iMaxRecent; i++) { char keyName[64]; snprintf(keyName, sizeof(keyName), "FileName%d", i); if (i < (int)recentIsos.size()) { recent->Set(keyName, recentIsos[i]); } else { recent->Delete(keyName); // delete the nonexisting FileName } } IniFile::Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths"); pinnedPaths->Clear(); for (size_t i = 0; i < vPinnedPaths.size(); ++i) { char keyName[64]; snprintf(keyName, sizeof(keyName), "Path%d", (int)i); pinnedPaths->Set(keyName, vPinnedPaths[i]); } IniFile::Section *control = iniFile.GetOrCreateSection("Control"); control->Delete("DPadRadius"); if (!iniFile.Save(iniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str()); return; } INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str()); if (!bGameSpecific) //otherwise we already did this in saveGameConfig() { IniFile controllerIniFile; if (!controllerIniFile.Load(controllerIniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str()); } KeyMap::SaveToIni(controllerIniFile); if (!controllerIniFile.Save(controllerIniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str()); return; } INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str()); } } else { INFO_LOG(LOADER, "Not saving config"); } if (jitForcedOff) { // force JIT off again just in case Config::Save() is called without exiting PPSSPP g_Config.bJit = false; } }
void Config::Save() { if (iniFilename_.size() && g_Config.bSaveSettings) { saveGameConfig(gameId_); CleanRecent(); IniFile iniFile; if (!iniFile.Load(iniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str()); } // Need to do this somewhere... bFirstRun = false; for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) { IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section); for (auto setting = sections[i].settings; setting->HasMore(); ++setting) { if (!bGameSpecific || !setting->perGame_){ setting->Set(section); } } } IniFile::Section *recent = iniFile.GetOrCreateSection("Recent"); recent->Set("MaxRecent", iMaxRecent); for (int i = 0; i < iMaxRecent; i++) { char keyName[64]; snprintf(keyName, sizeof(keyName), "FileName%d", i); if (i < (int)recentIsos.size()) { recent->Set(keyName, recentIsos[i]); } else { recent->Delete(keyName); // delete the nonexisting FileName } } IniFile::Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths"); pinnedPaths->Clear(); for (size_t i = 0; i < vPinnedPaths.size(); ++i) { char keyName[64]; snprintf(keyName, sizeof(keyName), "Path%d", (int)i); pinnedPaths->Set(keyName, vPinnedPaths[i]); } IniFile::Section *control = iniFile.GetOrCreateSection("Control"); control->Delete("DPadRadius"); if (!iniFile.Save(iniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str()); return; } INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str()); if (!bGameSpecific) //otherwise we already did this in saveGameConfig() { IniFile controllerIniFile; if (!controllerIniFile.Load(controllerIniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str()); } KeyMap::SaveToIni(controllerIniFile); if (!controllerIniFile.Save(controllerIniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str()); return; } INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str()); } } else { INFO_LOG(LOADER, "Not saving config"); } }
void Config::Save() { if (iniFilename_.size() && g_Config.bSaveSettings) { CleanRecent(); IniFile iniFile; if (!iniFile.Load(iniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str()); } IniFile::Section *general = iniFile.GetOrCreateSection("General"); // Need to do this somewhere... bFirstRun = false; general->Set("FirstRun", bFirstRun); general->Set("RunCount", iRunCount); general->Set("Enable Logging", bEnableLogging); general->Set("AutoRun", bAutoRun); general->Set("Browse", bBrowse); general->Set("IgnoreBadMemAccess", bIgnoreBadMemAccess); general->Set("CurrentDirectory", currentDirectory); general->Set("ShowDebuggerOnLoad", bShowDebuggerOnLoad); general->Set("ReportingHost", sReportHost); general->Set("AutoSaveSymbolMap", bAutoSaveSymbolMap); #if defined(_WIN32) && !defined(USING_QT_UI) general->Set("TopMost", bTopMost); general->Set("WindowX", iWindowX); general->Set("WindowY", iWindowY); general->Set("WindowWidth", iWindowWidth); general->Set("WindowHeight", iWindowHeight); general->Set("PauseOnLostFocus", bPauseOnLostFocus); #endif general->Set("Language", sLanguageIni); general->Set("NumWorkerThreads", iNumWorkerThreads); general->Set("EnableAutoLoad", bEnableAutoLoad); general->Set("EnableCheats", bEnableCheats); general->Set("ScreenshotsAsPNG", bScreenshotsAsPNG); general->Set("StateSlot", iCurrentStateSlot); general->Set("RewindFlipFrequency", iRewindFlipFrequency); general->Set("GridView1", bGridView1); general->Set("GridView2", bGridView2); general->Set("GridView3", bGridView3); general->Set("CheckForNewVersion", bCheckForNewVersion); IniFile::Section *recent = iniFile.GetOrCreateSection("Recent"); recent->Set("MaxRecent", iMaxRecent); for (int i = 0; i < iMaxRecent; i++) { char keyName[64]; sprintf(keyName,"FileName%d",i); if (i < (int)recentIsos.size()) { recent->Set(keyName, recentIsos[i]); } else { recent->Delete(keyName); // delete the nonexisting FileName } } IniFile::Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths"); pinnedPaths->Clear(); for (size_t i = 0; i < vPinnedPaths.size(); ++i) { char keyName[64]; snprintf(keyName, sizeof(keyName), "Path%d", i); pinnedPaths->Set(keyName, vPinnedPaths[i]); } IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU"); cpu->Set("Jit", bJit); cpu->Set("SeparateCPUThread", bSeparateCPUThread); cpu->Set("AtomicAudioLocks", bAtomicAudioLocks); cpu->Set("SeparateIOThread", bSeparateIOThread); cpu->Set("FastMemoryAccess", bFastMemory); cpu->Set("CPUSpeed", iLockedCPUSpeed); IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics"); graphics->Set("ShowFPSCounter", iShowFPSCounter); graphics->Set("RenderingMode", iRenderingMode); graphics->Set("SoftwareRendering", bSoftwareRendering); graphics->Set("HardwareTransform", bHardwareTransform); graphics->Set("SoftwareSkinning", bSoftwareSkinning); graphics->Set("TextureFiltering", iTexFiltering); graphics->Set("InternalResolution", iInternalResolution); graphics->Set("FrameSkip", iFrameSkip); graphics->Set("FrameRate", iFpsLimit); graphics->Set("FrameSkipUnthrottle", bFrameSkipUnthrottle); graphics->Set("ForceMaxEmulatedFPS", iForceMaxEmulatedFPS); graphics->Set("AnisotropyLevel", iAnisotropyLevel); graphics->Set("VertexCache", bVertexCache); #ifdef _WIN32 graphics->Set("FullScreen", bFullScreen); #endif graphics->Set("PartialStretch", bPartialStretch); graphics->Set("StretchToDisplay", bStretchToDisplay); graphics->Set("TrueColor", bTrueColor); graphics->Set("MipMap", bMipMap); graphics->Set("TexScalingLevel", iTexScalingLevel); graphics->Set("TexScalingType", iTexScalingType); graphics->Set("TexDeposterize", bTexDeposterize); graphics->Set("VSyncInterval", bVSync); graphics->Set("DisableStencilTest", bDisableStencilTest); graphics->Set("AlwaysDepthWrite", bAlwaysDepthWrite); graphics->Set("TimerHack", bTimerHack); graphics->Set("LowQualitySplineBezier", bLowQualitySplineBezier); graphics->Set("PostShader", sPostShaderName); IniFile::Section *sound = iniFile.GetOrCreateSection("Sound"); sound->Set("Enable", bEnableSound); sound->Set("VolumeBGM", iBGMVolume); sound->Set("VolumeSFX", iSFXVolume); sound->Set("LowLatency", bLowLatencyAudio); IniFile::Section *control = iniFile.GetOrCreateSection("Control"); control->Set("HapticFeedback", bHapticFeedback); control->Set("ShowTouchControls", bShowTouchControls); control->Set("ShowTouchCross", bShowTouchCross); control->Set("ShowTouchCircle", bShowTouchCircle); control->Set("ShowTouchSquare", bShowTouchSquare); control->Set("ShowTouchTriangle", bShowTouchTriangle); control->Set("ShowTouchStart", bShowTouchStart); control->Set("ShowTouchSelect", bShowTouchSelect); control->Set("ShowTouchLTrigger", bShowTouchLTrigger); control->Set("ShowTouchRTrigger", bShowTouchRTrigger); control->Set("ShowAnalogStick", bShowTouchAnalogStick); control->Set("ShowTouchUnthrottle", bShowTouchUnthrottle); control->Set("ShowTouchDpad", bShowTouchDpad); #ifdef USING_GLES2 control->Set("TiltBaseX", fTiltBaseX); control->Set("TiltBaseY", fTiltBaseY); control->Set("InvertTiltX", bInvertTiltX); control->Set("InvertTiltY", bInvertTiltY); control->Set("TiltSensitivityX", iTiltSensitivityX); control->Set("TiltSensitivityY", iTiltSensitivityY); control->Set("DeadzoneRadius", fDeadzoneRadius); control->Set("TiltInputType", iTiltInputType); #endif control->Set("DisableDpadDiagonals", bDisableDpadDiagonals); control->Set("TouchButtonStyle", iTouchButtonStyle); control->Set("TouchButtonOpacity", iTouchButtonOpacity); control->Set("ActionButtonScale", fActionButtonScale); control->Set("ActionButtonSpacing2", fActionButtonSpacing); control->Set("ActionButtonCenterX", fActionButtonCenterX); control->Set("ActionButtonCenterY", fActionButtonCenterY); control->Set("DPadX", fDpadX); control->Set("DPadY", fDpadY); control->Set("DPadScale", fDpadScale); control->Set("DPadSpacing", fDpadSpacing); control->Set("StartKeyX", fStartKeyX); control->Set("StartKeyY", fStartKeyY); control->Set("StartKeyScale", fStartKeyScale); control->Set("SelectKeyX", fSelectKeyX); control->Set("SelectKeyY", fSelectKeyY); control->Set("SelectKeyScale", fSelectKeyScale); control->Set("UnthrottleKeyX", fUnthrottleKeyX); control->Set("UnthrottleKeyY", fUnthrottleKeyY); control->Set("UnthrottleKeyScale", fUnthrottleKeyScale); control->Set("LKeyX", fLKeyX); control->Set("LKeyY", fLKeyY); control->Set("LKeyScale", fLKeyScale); control->Set("RKeyX", fRKeyX); control->Set("RKeyY", fRKeyY); control->Set("RKeyScale", fRKeyScale); control->Set("AnalogStickX", fAnalogStickX); control->Set("AnalogStickY", fAnalogStickY); control->Set("AnalogStickScale", fAnalogStickScale); control->Delete("DPadRadius"); IniFile::Section *network = iniFile.GetOrCreateSection("Network"); network->Set("EnableWlan", bEnableWlan); IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); pspConfig->Set("PSPModel", iPSPModel); pspConfig->Set("PSPFirmwareVersion", iFirmwareVersion); pspConfig->Set("NickName", sNickName.c_str()); pspConfig->Set("proAdhocServer", proAdhocServer.c_str()); pspConfig->Set("MacAddress", localMacAddress.c_str()); pspConfig->Set("Language", iLanguage); pspConfig->Set("TimeFormat", iTimeFormat); pspConfig->Set("DateFormat", iDateFormat); pspConfig->Set("TimeZone", iTimeZone); pspConfig->Set("DayLightSavings", bDayLightSavings); pspConfig->Set("ButtonPreference", iButtonPreference); pspConfig->Set("LockParentalLevel", iLockParentalLevel); pspConfig->Set("WlanAdhocChannel", iWlanAdhocChannel); pspConfig->Set("WlanPowerSave", bWlanPowerSave); pspConfig->Set("EncryptSave", bEncryptSave); #if defined(_WIN32) && !defined(USING_QT_UI) pspConfig->Set("BypassOSKWithKeyboard", bBypassOSKWithKeyboard); #endif IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger"); debugConfig->Set("DisasmWindowX", iDisasmWindowX); debugConfig->Set("DisasmWindowY", iDisasmWindowY); debugConfig->Set("DisasmWindowW", iDisasmWindowW); debugConfig->Set("DisasmWindowH", iDisasmWindowH); debugConfig->Set("GEWindowX", iGEWindowX); debugConfig->Set("GEWindowY", iGEWindowY); debugConfig->Set("GEWindowW", iGEWindowW); debugConfig->Set("GEWindowH", iGEWindowH); debugConfig->Set("ConsoleWindowX", iConsoleWindowX); debugConfig->Set("ConsoleWindowY", iConsoleWindowY); debugConfig->Set("FontWidth", iFontWidth); debugConfig->Set("FontHeight", iFontHeight); debugConfig->Set("DisplayStatusBar", bDisplayStatusBar); debugConfig->Set("ShowBottomTabTitles",bShowBottomTabTitles); debugConfig->Set("ShowDeveloperMenu", bShowDeveloperMenu); debugConfig->Set("SkipDeadbeefFilling", bSkipDeadbeefFilling); debugConfig->Set("FuncHashMap", bFuncHashMap); IniFile::Section *speedhacks = iniFile.GetOrCreateSection("SpeedHacks"); speedhacks->Set("PrescaleUV", bPrescaleUV); speedhacks->Set("DisableAlphaTest", bDisableAlphaTest); // Save upgrade check state IniFile::Section *upgrade = iniFile.GetOrCreateSection("Upgrade"); upgrade->Set("UpgradeMessage", upgradeMessage); upgrade->Set("UpgradeVersion", upgradeVersion); upgrade->Set("DismissedVersion", dismissedVersion); if (!iniFile.Save(iniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str()); return; } INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str()); IniFile controllerIniFile; if (!controllerIniFile.Load(controllerIniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str()); } KeyMap::SaveToIni(controllerIniFile); if (!controllerIniFile.Save(controllerIniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str()); return; } INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str()); } else { INFO_LOG(LOADER, "Not saving config"); } }