2012-11-01 15:19:01 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 22:01:49 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
|
|
|
|
#include "Config.h"
|
|
|
|
#include "IniFile.h"
|
|
|
|
|
|
|
|
SState g_State;
|
|
|
|
CConfig g_Config;
|
|
|
|
|
|
|
|
CConfig::CConfig()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CConfig::~CConfig()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CConfig::Load(const char *iniFileName)
|
|
|
|
{
|
|
|
|
iniFilename_ = iniFileName;
|
|
|
|
NOTICE_LOG(LOADER, "Loading config: %s", iniFileName);
|
|
|
|
bSaveSettings = true;
|
|
|
|
|
|
|
|
IniFile iniFile;
|
|
|
|
iniFile.Load(iniFileName);
|
|
|
|
|
|
|
|
IniFile::Section *general = iniFile.GetOrCreateSection("General");
|
|
|
|
|
|
|
|
bSpeedLimit = false;
|
|
|
|
general->Get("FirstRun", &bFirstRun, true);
|
|
|
|
general->Get("AutoLoadLast", &bAutoLoadLast, false);
|
|
|
|
general->Get("AutoRun", &bAutoRun, false);
|
|
|
|
general->Get("ConfirmOnQuit", &bConfirmOnQuit, false);
|
|
|
|
general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
|
|
|
|
general->Get("CurrentDirectory", ¤tDirectory, "");
|
2012-12-04 16:04:24 +00:00
|
|
|
general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);
|
2012-11-23 11:42:35 +00:00
|
|
|
IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
|
|
|
|
cpu->Get("Core", &iCpuCore, 0);
|
|
|
|
|
2012-11-20 09:59:23 +00:00
|
|
|
IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
|
|
|
|
graphics->Get("ShowFPSCounter", &bShowFPSCounter, false);
|
|
|
|
graphics->Get("DisplayFramebuffer", &bDisplayFramebuffer, false);
|
|
|
|
graphics->Get("WindowZoom", &iWindowZoom, 1);
|
|
|
|
graphics->Get("BufferedRendering", &bBufferedRendering, true);
|
2012-12-21 10:08:54 +00:00
|
|
|
graphics->Get("HardwareTransform", &bHardwareTransform, false);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
|
|
|
sound->Get("Enable", &bEnableSound, true);
|
|
|
|
|
|
|
|
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
|
|
|
control->Get("ShowStick", &bShowAnalogStick, false);
|
2012-12-01 22:20:08 +00:00
|
|
|
control->Get("ShowTouchControls", &bShowTouchControls, true);
|
2012-12-19 14:14:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Ephemeral settings
|
|
|
|
bDrawWireframe = false;
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CConfig::Save()
|
|
|
|
{
|
|
|
|
if (g_Config.bSaveSettings && iniFilename_.size())
|
|
|
|
{
|
|
|
|
IniFile iniFile;
|
|
|
|
iniFile.Load(iniFilename_.c_str());
|
|
|
|
|
|
|
|
IniFile::Section *general = iniFile.GetOrCreateSection("General");
|
|
|
|
general->Set("FirstRun", bFirstRun);
|
|
|
|
general->Set("AutoLoadLast", bAutoLoadLast);
|
|
|
|
general->Set("AutoRun", bAutoRun);
|
|
|
|
general->Set("ConfirmOnQuit", bConfirmOnQuit);
|
|
|
|
general->Set("IgnoreBadMemAccess", bIgnoreBadMemAccess);
|
|
|
|
general->Set("CurrentDirectory", currentDirectory);
|
2012-12-04 16:04:24 +00:00
|
|
|
general->Set("ShowDebuggerOnLoad", bShowDebuggerOnLoad);
|
2012-11-23 11:42:35 +00:00
|
|
|
IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
|
|
|
|
cpu->Set("Core", iCpuCore);
|
|
|
|
|
2012-11-20 09:59:23 +00:00
|
|
|
IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
|
|
|
|
graphics->Set("ShowFPSCounter", bShowFPSCounter);
|
|
|
|
graphics->Set("DisplayFramebuffer", bDisplayFramebuffer);
|
|
|
|
graphics->Set("WindowZoom", iWindowZoom);
|
|
|
|
graphics->Set("BufferedRendering", bBufferedRendering);
|
2012-12-21 10:08:54 +00:00
|
|
|
graphics->Set("HardwareTransform", bHardwareTransform);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
|
|
|
sound->Set("Enable", bEnableSound);
|
|
|
|
|
|
|
|
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
|
|
|
control->Set("ShowStick", bShowAnalogStick);
|
2012-12-01 22:20:08 +00:00
|
|
|
control->Set("ShowTouchControls", bShowTouchControls);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
iniFile.Save(iniFilename_.c_str());
|
|
|
|
NOTICE_LOG(LOADER, "Config saved: %s", iniFilename_.c_str());
|
2012-11-04 10:54:45 +00:00
|
|
|
} else {
|
|
|
|
NOTICE_LOG(LOADER, "Error saving config: %s", iniFilename_.c_str());
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
}
|