mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Use only section-based ini reading.
This commit is contained in:
@@ -436,61 +436,6 @@ bool IniFile::Save(const std::string& filename)
|
||||
return File::RenameSync(temp, filename);
|
||||
}
|
||||
|
||||
bool IniFile::Get(const std::string& sectionName, const std::string& key, std::vector<std::string>* values)
|
||||
{
|
||||
Section *section = GetSection(sectionName);
|
||||
if (!section)
|
||||
return false;
|
||||
return section->Get(key, values);
|
||||
}
|
||||
|
||||
bool IniFile::Get(const std::string& sectionName, const std::string& key, int* value, int defaultValue)
|
||||
{
|
||||
Section *section = GetSection(sectionName);
|
||||
if (!section) {
|
||||
*value = defaultValue;
|
||||
return false;
|
||||
} else {
|
||||
return section->Get(key, value, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
bool IniFile::Get(const std::string& sectionName, const std::string& key, u32* value, u32 defaultValue)
|
||||
{
|
||||
Section *section = GetSection(sectionName);
|
||||
if (!section) {
|
||||
*value = defaultValue;
|
||||
return false;
|
||||
} else {
|
||||
return section->Get(key, value, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
bool IniFile::Get(const std::string& sectionName, const std::string& key, bool* value, bool defaultValue)
|
||||
{
|
||||
Section *section = GetSection(sectionName);
|
||||
if (!section) {
|
||||
*value = defaultValue;
|
||||
return false;
|
||||
} else {
|
||||
return section->Get(key, value, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
bool IniFile::Get(const std::string& sectionName, const std::string& key, std::string* value, const std::string& defaultValue)
|
||||
{
|
||||
Section* section = GetSection(sectionName);
|
||||
if (!section) {
|
||||
if (&defaultValue != &NULL_STRING) {
|
||||
*value = defaultValue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return section->Get(key, value, defaultValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Unit test. TODO: Move to the real unit test framework.
|
||||
/*
|
||||
int main()
|
||||
|
||||
@@ -95,34 +95,11 @@ public:
|
||||
// Returns true if key exists in section
|
||||
bool Exists(const std::string& sectionName, const std::string& key) const;
|
||||
|
||||
// TODO: Get rid of these, in favor of the Section ones.
|
||||
void Set(const std::string& sectionName, const std::string& key, const std::string& newValue) {
|
||||
GetOrCreateSection(sectionName)->Set(key, newValue);
|
||||
}
|
||||
void Set(const std::string& sectionName, const std::string& key, int newValue) {
|
||||
GetOrCreateSection(sectionName)->Set(key, newValue);
|
||||
}
|
||||
void Set(const std::string& sectionName, const std::string& key, u32 newValue) {
|
||||
GetOrCreateSection(sectionName)->Set(key, newValue);
|
||||
}
|
||||
void Set(const std::string& sectionName, const std::string& key, bool newValue) {
|
||||
GetOrCreateSection(sectionName)->Set(key, newValue);
|
||||
}
|
||||
void Set(const std::string& sectionName, const std::string& key, const std::vector<std::string>& newValues) {
|
||||
GetOrCreateSection(sectionName)->Set(key, newValues);
|
||||
}
|
||||
|
||||
// TODO: Get rid of these, in favor of the Section ones.
|
||||
bool Get(const std::string& sectionName, const std::string& key, int* value, int defaultValue = 0);
|
||||
bool Get(const std::string& sectionName, const std::string& key, u32* value, u32 defaultValue = 0);
|
||||
bool Get(const std::string& sectionName, const std::string& key, bool* value, bool defaultValue = false);
|
||||
bool Get(const std::string& sectionName, const std::string& key, std::vector<std::string>* values);
|
||||
bool Get(const std::string& sectionName, const std::string& key, std::string* value, const std::string& defaultValue = NULL_STRING);
|
||||
|
||||
template<typename T> bool GetIfExists(const std::string& sectionName, const std::string& key, T value)
|
||||
{
|
||||
if (Exists(sectionName, key))
|
||||
return Get(sectionName, key, value);
|
||||
return GetOrCreateSection(sectionName)->Get(key, value);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,38 +136,43 @@ bool BootCore(const std::string& _rFilename)
|
||||
config_cache.bSetFrameSkip = false;
|
||||
|
||||
// General settings
|
||||
game_ini.Get("Core", "CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread);
|
||||
game_ini.Get("Core", "SkipIdle", &StartUp.bSkipIdle, StartUp.bSkipIdle);
|
||||
game_ini.Get("Core", "EnableFPRF", &StartUp.bEnableFPRF, StartUp.bEnableFPRF);
|
||||
game_ini.Get("Core", "MMU", &StartUp.bMMU, StartUp.bMMU);
|
||||
game_ini.Get("Core", "TLBHack", &StartUp.bTLBHack, StartUp.bTLBHack);
|
||||
game_ini.Get("Core", "DCBZ", &StartUp.bDCBZOFF, StartUp.bDCBZOFF);
|
||||
game_ini.Get("Core", "VBeam", &StartUp.bVBeamSpeedHack, StartUp.bVBeamSpeedHack);
|
||||
game_ini.Get("Core", "SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU);
|
||||
game_ini.Get("Core", "FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed);
|
||||
game_ini.Get("Core", "BlockMerging", &StartUp.bMergeBlocks, StartUp.bMergeBlocks);
|
||||
game_ini.Get("Core", "DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE);
|
||||
game_ini.Get("Core", "DSPThread", &StartUp.bDSPThread, StartUp.bDSPThread);
|
||||
game_ini.Get("Core", "GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend);
|
||||
game_ini.Get("Core", "CPUCore", &StartUp.iCPUCore, StartUp.iCPUCore);
|
||||
game_ini.Get("Core", "HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2);
|
||||
if (game_ini.Get("Core", "FrameLimit", &SConfig::GetInstance().m_Framelimit, SConfig::GetInstance().m_Framelimit))
|
||||
IniFile::Section* core_section = game_ini.GetOrCreateSection("Core");
|
||||
IniFile::Section* dsp_section = game_ini.GetOrCreateSection("DSP");
|
||||
IniFile::Section* controls_section = game_ini.GetOrCreateSection("Controls");
|
||||
|
||||
core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread);
|
||||
core_section->Get("SkipIdle", &StartUp.bSkipIdle, StartUp.bSkipIdle);
|
||||
core_section->Get("EnableFPRF", &StartUp.bEnableFPRF, StartUp.bEnableFPRF);
|
||||
core_section->Get("MMU", &StartUp.bMMU, StartUp.bMMU);
|
||||
core_section->Get("TLBHack", &StartUp.bTLBHack, StartUp.bTLBHack);
|
||||
core_section->Get("DCBZ", &StartUp.bDCBZOFF, StartUp.bDCBZOFF);
|
||||
core_section->Get("VBeam", &StartUp.bVBeamSpeedHack, StartUp.bVBeamSpeedHack);
|
||||
core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU);
|
||||
core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed);
|
||||
core_section->Get("BlockMerging", &StartUp.bMergeBlocks, StartUp.bMergeBlocks);
|
||||
core_section->Get("DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE);
|
||||
core_section->Get("DSPThread", &StartUp.bDSPThread, StartUp.bDSPThread);
|
||||
core_section->Get("GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend);
|
||||
core_section->Get("CPUCore", &StartUp.iCPUCore, StartUp.iCPUCore);
|
||||
core_section->Get("HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2);
|
||||
if (core_section->Get("FrameLimit", &SConfig::GetInstance().m_Framelimit, SConfig::GetInstance().m_Framelimit))
|
||||
config_cache.bSetFramelimit = true;
|
||||
if (game_ini.Get("Core", "FrameSkip", &SConfig::GetInstance().m_FrameSkip))
|
||||
if (core_section->Get("FrameSkip", &SConfig::GetInstance().m_FrameSkip))
|
||||
{
|
||||
config_cache.bSetFrameSkip = true;
|
||||
Movie::SetFrameSkipping(SConfig::GetInstance().m_FrameSkip);
|
||||
}
|
||||
if (game_ini.Get("DSP", "Volume", &SConfig::GetInstance().m_Volume, SConfig::GetInstance().m_Volume))
|
||||
|
||||
if (dsp_section->Get("Volume", &SConfig::GetInstance().m_Volume, SConfig::GetInstance().m_Volume))
|
||||
config_cache.bSetVolume = true;
|
||||
game_ini.Get("DSP", "EnableJIT", &SConfig::GetInstance().m_DSPEnableJIT, SConfig::GetInstance().m_DSPEnableJIT);
|
||||
game_ini.Get("DSP", "Backend", &SConfig::GetInstance().sBackend, SConfig::GetInstance().sBackend);
|
||||
dsp_section->Get("EnableJIT", &SConfig::GetInstance().m_DSPEnableJIT, SConfig::GetInstance().m_DSPEnableJIT);
|
||||
dsp_section->Get("Backend", &SConfig::GetInstance().sBackend, SConfig::GetInstance().sBackend);
|
||||
VideoBackend::ActivateBackend(StartUp.m_strVideoBackend);
|
||||
|
||||
for (unsigned int i = 0; i < MAX_SI_CHANNELS; ++i)
|
||||
{
|
||||
int source;
|
||||
game_ini.Get("Controls", StringFromFormat("PadType%u", i), &source, -1);
|
||||
controls_section->Get(StringFromFormat("PadType%u", i), &source, -1);
|
||||
if (source >= (int) SIDEVICE_NONE && source <= (int) SIDEVICE_AM_BASEBOARD)
|
||||
{
|
||||
SConfig::GetInstance().m_SIDevice[i] = (SIDevices) source;
|
||||
@@ -184,7 +189,7 @@ bool BootCore(const std::string& _rFilename)
|
||||
int source;
|
||||
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
|
||||
{
|
||||
game_ini.Get("Controls", StringFromFormat("WiimoteSource%u", i), &source, -1);
|
||||
controls_section->Get(StringFromFormat("WiimoteSource%u", i), &source, -1);
|
||||
if (source != -1 && g_wiimote_sources[i] != (unsigned) source && source >= WIIMOTE_SRC_NONE && source <= WIIMOTE_SRC_HYBRID)
|
||||
{
|
||||
config_cache.bSetWiimoteSource[i] = true;
|
||||
@@ -192,7 +197,7 @@ bool BootCore(const std::string& _rFilename)
|
||||
WiimoteReal::ChangeWiimoteSource(i, source);
|
||||
}
|
||||
}
|
||||
game_ini.Get("Controls", "WiimoteSourceBB", &source, -1);
|
||||
controls_section->Get("WiimoteSourceBB", &source, -1);
|
||||
if (source != -1 && g_wiimote_sources[WIIMOTE_BALANCE_BOARD] != (unsigned) source && (source == WIIMOTE_SRC_NONE || source == WIIMOTE_SRC_REAL))
|
||||
{
|
||||
config_cache.bSetWiimoteSource[WIIMOTE_BALANCE_BOARD] = true;
|
||||
|
||||
+403
-318
File diff suppressed because it is too large
Load Diff
@@ -114,5 +114,25 @@ private:
|
||||
SConfig();
|
||||
~SConfig();
|
||||
|
||||
void SaveGeneralSettings(IniFile& ini);
|
||||
void SaveInterfaceSettings(IniFile& ini);
|
||||
void SaveDisplaySettings(IniFile& ini);
|
||||
void SaveHotkeySettings(IniFile& ini);
|
||||
void SaveGameListSettings(IniFile& ini);
|
||||
void SaveCoreSettings(IniFile& ini);
|
||||
void SaveDSPSettings(IniFile& ini);
|
||||
void SaveMovieSettings(IniFile& ini);
|
||||
void SaveFifoPlayerSettings(IniFile& ini);
|
||||
|
||||
void LoadGeneralSettings(IniFile& ini);
|
||||
void LoadInterfaceSettings(IniFile& ini);
|
||||
void LoadDisplaySettings(IniFile& ini);
|
||||
void LoadHotkeySettings(IniFile& ini);
|
||||
void LoadGameListSettings(IniFile& ini);
|
||||
void LoadCoreSettings(IniFile& ini);
|
||||
void LoadDSPSettings(IniFile& ini);
|
||||
void LoadMovieSettings(IniFile& ini);
|
||||
void LoadFifoPlayerSettings(IniFile& ini);
|
||||
|
||||
static SConfig* m_Instance;
|
||||
};
|
||||
|
||||
@@ -208,9 +208,8 @@ bool Init()
|
||||
if (g_aspect_wide)
|
||||
{
|
||||
IniFile gameIni = _CoreParameter.LoadGameIni();
|
||||
gameIni.Get("Wii", "Widescreen", &g_aspect_wide,
|
||||
!!SConfig::GetInstance().m_SYSCONF->
|
||||
GetData<u8>("IPL.AR"));
|
||||
gameIni.GetOrCreateSection("Wii")->Get("Widescreen", &g_aspect_wide,
|
||||
!!SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.AR"));
|
||||
}
|
||||
|
||||
// g_pWindowHandle is first the m_Panel handle,
|
||||
|
||||
@@ -81,7 +81,7 @@ CEXIMemoryCard::CEXIMemoryCard(const int index)
|
||||
// Use a 16Mb (251 block) memory card for these games
|
||||
bool useMC251;
|
||||
IniFile gameIni = Core::g_CoreStartupParameter.LoadGameIni();
|
||||
gameIni.Get("Core", "MemoryCard251", &useMC251, false);
|
||||
gameIni.GetOrCreateSection("Core")->Get("MemoryCard251", &useMC251, false);
|
||||
nintendo_card_id = MemCard2043Mb;
|
||||
if (useMC251)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ bool CWII_IPC_HLE_Device_usb_kbd::Open(u32 _CommandAddress, u32 _Mode)
|
||||
INFO_LOG(WII_IPC_STM, "CWII_IPC_HLE_Device_usb_kbd: Open");
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||
ini.Get("USB Keyboard", "Layout", &m_KeyboardLayout, KBD_LAYOUT_QWERTY);
|
||||
ini.GetOrCreateSection("USB Keyboard")->Get("Layout", &m_KeyboardLayout, KBD_LAYOUT_QWERTY);
|
||||
|
||||
for (bool& pressed : m_OldKeyBuffer)
|
||||
{
|
||||
|
||||
@@ -132,7 +132,7 @@ static void LoadSpeedhacks(const std::string& section, IniFile& ini)
|
||||
for (const std::string& key : keys)
|
||||
{
|
||||
std::string value;
|
||||
ini.Get(section, key, &value, "BOGUS");
|
||||
ini.GetOrCreateSection(section)->Get(key, &value, "BOGUS");
|
||||
if (value != "BOGUS")
|
||||
{
|
||||
u32 address;
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace ButtonManager
|
||||
bool hasbind = false;
|
||||
char modifier = '+';
|
||||
std::string value;
|
||||
ini.Get("Android", config.str(), &value, "None");
|
||||
ini.GetOrCreateSection("Android")->Get(config.str(), &value, "None");
|
||||
if (value == "None")
|
||||
continue;
|
||||
if (std::string::npos != value.find("Axis"))
|
||||
|
||||
@@ -62,14 +62,15 @@ void CCodeWindow::Load()
|
||||
|
||||
// The font to override DebuggerFont with
|
||||
std::string fontDesc;
|
||||
ini.Get("General", "DebuggerFont", &fontDesc);
|
||||
|
||||
IniFile::Section* general = ini.GetOrCreateSection("General");
|
||||
general->Get("DebuggerFont", &fontDesc);
|
||||
general->Get("AutomaticStart", &bAutomaticStart, false);
|
||||
general->Get("BootToPause", &bBootToPause, true);
|
||||
|
||||
if (!fontDesc.empty())
|
||||
DebuggerFont.SetNativeFontInfoUserDesc(StrToWxStr(fontDesc));
|
||||
|
||||
// Boot to pause or not
|
||||
ini.Get("General", "AutomaticStart", &bAutomaticStart, false);
|
||||
ini.Get("General", "BootToPause", &bBootToPause, true);
|
||||
|
||||
const char* SettingName[] = {
|
||||
"Log",
|
||||
"LogConfig",
|
||||
@@ -85,19 +86,19 @@ void CCodeWindow::Load()
|
||||
|
||||
// Decide what windows to show
|
||||
for (int i = 0; i <= IDM_VIDEOWINDOW - IDM_LOGWINDOW; i++)
|
||||
ini.Get("ShowOnStart", SettingName[i], &bShowOnStart[i], false);
|
||||
ini.GetOrCreateSection("ShowOnStart")->Get(SettingName[i], &bShowOnStart[i], false);
|
||||
|
||||
// Get notebook affiliation
|
||||
std::string _Section = "P - " +
|
||||
std::string section = "P - " +
|
||||
((Parent->ActivePerspective < Parent->Perspectives.size())
|
||||
? Parent->Perspectives[Parent->ActivePerspective].Name : "Perspective 1");
|
||||
|
||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||
ini.Get(_Section, SettingName[i], &iNbAffiliation[i], 0);
|
||||
ini.GetOrCreateSection(section)->Get(SettingName[i], &iNbAffiliation[i], 0);
|
||||
|
||||
// Get floating setting
|
||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||
ini.Get("Float", SettingName[i], &Parent->bFloatWindow[i], false);
|
||||
ini.GetOrCreateSection("Float")->Get(SettingName[i], &Parent->bFloatWindow[i], false);
|
||||
}
|
||||
|
||||
void CCodeWindow::Save()
|
||||
@@ -105,11 +106,10 @@ void CCodeWindow::Save()
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
ini.Set("General", "DebuggerFont", WxStrToStr(DebuggerFont.GetNativeFontInfoUserDesc()));
|
||||
|
||||
// Boot to pause or not
|
||||
ini.Set("General", "AutomaticStart", GetMenuBar()->IsChecked(IDM_AUTOMATICSTART));
|
||||
ini.Set("General", "BootToPause", GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE));
|
||||
IniFile::Section* general = ini.GetOrCreateSection("General");
|
||||
general->Set("DebuggerFont", WxStrToStr(DebuggerFont.GetNativeFontInfoUserDesc()));
|
||||
general->Set("AutomaticStart", GetMenuBar()->IsChecked(IDM_AUTOMATICSTART));
|
||||
general->Set("BootToPause", GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE));
|
||||
|
||||
const char* SettingName[] = {
|
||||
"Log",
|
||||
@@ -126,16 +126,16 @@ void CCodeWindow::Save()
|
||||
|
||||
// Save windows settings
|
||||
for (int i = IDM_LOGWINDOW; i <= IDM_VIDEOWINDOW; i++)
|
||||
ini.Set("ShowOnStart", SettingName[i - IDM_LOGWINDOW], GetMenuBar()->IsChecked(i));
|
||||
ini.GetOrCreateSection("ShowOnStart")->Set(SettingName[i - IDM_LOGWINDOW], GetMenuBar()->IsChecked(i));
|
||||
|
||||
// Save notebook affiliations
|
||||
std::string _Section = "P - " + Parent->Perspectives[Parent->ActivePerspective].Name;
|
||||
std::string section = "P - " + Parent->Perspectives[Parent->ActivePerspective].Name;
|
||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||
ini.Set(_Section, SettingName[i], iNbAffiliation[i]);
|
||||
ini.GetOrCreateSection(section)->Set(SettingName[i], iNbAffiliation[i]);
|
||||
|
||||
// Save floating setting
|
||||
for (int i = IDM_LOGWINDOW_PARENT; i <= IDM_CODEWINDOW_PARENT; i++)
|
||||
ini.Set("Float", SettingName[i - IDM_LOGWINDOW_PARENT], !!FindWindowById(i));
|
||||
ini.GetOrCreateSection("Float")->Set(SettingName[i - IDM_LOGWINDOW_PARENT], !!FindWindowById(i));
|
||||
|
||||
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
}
|
||||
|
||||
@@ -88,10 +88,11 @@ void GFXDebuggerPanel::SaveSettings() const
|
||||
GetSize().GetWidth() < 1000 &&
|
||||
GetSize().GetHeight() < 1000)
|
||||
{
|
||||
file.Set("VideoWindow", "x", GetPosition().x);
|
||||
file.Set("VideoWindow", "y", GetPosition().y);
|
||||
file.Set("VideoWindow", "w", GetSize().GetWidth());
|
||||
file.Set("VideoWindow", "h", GetSize().GetHeight());
|
||||
IniFile::Section* video_window = file.GetOrCreateSection("VideoWindow");
|
||||
video_window->Set("x", GetPosition().x);
|
||||
video_window->Set("y", GetPosition().y);
|
||||
video_window->Set("w", GetSize().GetWidth());
|
||||
video_window->Set("h", GetSize().GetHeight());
|
||||
}
|
||||
|
||||
file.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
@@ -102,11 +103,17 @@ void GFXDebuggerPanel::LoadSettings()
|
||||
IniFile file;
|
||||
file.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
int x = 100, y = 100, w = 100, h = 100;
|
||||
file.Get("VideoWindow", "x", &x, GetPosition().x);
|
||||
file.Get("VideoWindow", "y", &y, GetPosition().y);
|
||||
file.Get("VideoWindow", "w", &w, GetSize().GetWidth());
|
||||
file.Get("VideoWindow", "h", &h, GetSize().GetHeight());
|
||||
int x = 100;
|
||||
int y = 100;
|
||||
int w = 100;
|
||||
int h = 100;
|
||||
|
||||
IniFile::Section* video_window = file.GetOrCreateSection("VideoWindow");
|
||||
video_window->Get("x", &x, GetPosition().x);
|
||||
video_window->Get("y", &y, GetPosition().y);
|
||||
video_window->Get("w", &w, GetSize().GetWidth());
|
||||
video_window->Get("h", &h, GetSize().GetHeight());
|
||||
|
||||
SetSize(x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,25 +127,29 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id,
|
||||
sizerBig->Fit(this);
|
||||
}
|
||||
|
||||
void CMemoryWindow::Save(IniFile& _IniFile) const
|
||||
void CMemoryWindow::Save(IniFile& ini) const
|
||||
{
|
||||
// Prevent these bad values that can happen after a crash or hanging
|
||||
if (GetPosition().x != -32000 && GetPosition().y != -32000)
|
||||
{
|
||||
_IniFile.Set("MemoryWindow", "x", GetPosition().x);
|
||||
_IniFile.Set("MemoryWindow", "y", GetPosition().y);
|
||||
_IniFile.Set("MemoryWindow", "w", GetSize().GetWidth());
|
||||
_IniFile.Set("MemoryWindow", "h", GetSize().GetHeight());
|
||||
IniFile::Section* mem_window = ini.GetOrCreateSection("MemoryWindow");
|
||||
mem_window->Set("x", GetPosition().x);
|
||||
mem_window->Set("y", GetPosition().y);
|
||||
mem_window->Set("w", GetSize().GetWidth());
|
||||
mem_window->Set("h", GetSize().GetHeight());
|
||||
}
|
||||
}
|
||||
|
||||
void CMemoryWindow::Load(IniFile& _IniFile)
|
||||
void CMemoryWindow::Load(IniFile& ini)
|
||||
{
|
||||
int x, y, w, h;
|
||||
_IniFile.Get("MemoryWindow", "x", &x, GetPosition().x);
|
||||
_IniFile.Get("MemoryWindow", "y", &y, GetPosition().y);
|
||||
_IniFile.Get("MemoryWindow", "w", &w, GetSize().GetWidth());
|
||||
_IniFile.Get("MemoryWindow", "h", &h, GetSize().GetHeight());
|
||||
|
||||
IniFile::Section* mem_window = ini.GetOrCreateSection("MemoryWindow");
|
||||
mem_window->Get("x", &x, GetPosition().x);
|
||||
mem_window->Get("y", &y, GetPosition().y);
|
||||
mem_window->Get("w", &w, GetSize().GetWidth());
|
||||
mem_window->Get("h", &h, GetSize().GetHeight());
|
||||
|
||||
SetSize(x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
@@ -835,8 +835,10 @@ void CFrame::LoadIniPerspectives()
|
||||
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
ini.Get("Perspectives", "Perspectives", &_Perspectives, "Perspective 1");
|
||||
ini.Get("Perspectives", "Active", &ActivePerspective, 0);
|
||||
|
||||
IniFile::Section* perspectives = ini.GetOrCreateSection("Perspectives");
|
||||
perspectives->Get("Perspectives", &_Perspectives, "Perspective 1");
|
||||
perspectives->Get("Active", &ActivePerspective, 0);
|
||||
SplitString(_Perspectives, ',', VPerspectives);
|
||||
|
||||
for (auto& VPerspective : VPerspectives)
|
||||
@@ -853,13 +855,15 @@ void CFrame::LoadIniPerspectives()
|
||||
}
|
||||
|
||||
_Section = StringFromFormat("P - %s", Tmp.Name.c_str());
|
||||
ini.Get(_Section, "Perspective", &_Perspective,
|
||||
"layout2|"
|
||||
"name=Pane 0;caption=Pane 0;state=768;dir=5;prop=100000;|"
|
||||
"name=Pane 1;caption=Pane 1;state=31458108;dir=4;prop=100000;|"
|
||||
"dock_size(5,0,0)=22|dock_size(4,0,0)=333|");
|
||||
ini.Get(_Section, "Width", &_Widths, "70,25");
|
||||
ini.Get(_Section, "Height", &_Heights, "80,80");
|
||||
|
||||
IniFile::Section* perspec_section = ini.GetOrCreateSection(_Section);
|
||||
perspec_section->Get("Perspective", &_Perspective,
|
||||
"layout2|"
|
||||
"name=Pane 0;caption=Pane 0;state=768;dir=5;prop=100000;|"
|
||||
"name=Pane 1;caption=Pane 1;state=31458108;dir=4;prop=100000;|"
|
||||
"dock_size(5,0,0)=22|dock_size(4,0,0)=333|");
|
||||
perspec_section->Get("Width", &_Widths, "70,25");
|
||||
perspec_section->Get("Height", &_Heights, "80,80");
|
||||
|
||||
Tmp.Perspective = StrToWxStr(_Perspective);
|
||||
|
||||
@@ -926,14 +930,17 @@ void CFrame::SaveIniPerspectives()
|
||||
STmp += Perspective.Name + ",";
|
||||
}
|
||||
STmp = STmp.substr(0, STmp.length()-1);
|
||||
ini.Set("Perspectives", "Perspectives", STmp);
|
||||
ini.Set("Perspectives", "Active", ActivePerspective);
|
||||
|
||||
IniFile::Section* perspectives = ini.GetOrCreateSection("Perspectives");
|
||||
perspectives->Set("Perspectives", STmp);
|
||||
perspectives->Set("Active", ActivePerspective);
|
||||
|
||||
// Save the perspectives
|
||||
for (auto& Perspective : Perspectives)
|
||||
{
|
||||
std::string _Section = "P - " + Perspective.Name;
|
||||
ini.Set(_Section, "Perspective", WxStrToStr(Perspective.Perspective));
|
||||
IniFile::Section* perspec_section = ini.GetOrCreateSection(_Section);
|
||||
perspec_section->Set("Perspective", WxStrToStr(Perspective.Perspective));
|
||||
|
||||
std::string SWidth = "", SHeight = "";
|
||||
for (u32 j = 0; j < Perspective.Width.size(); j++)
|
||||
@@ -945,8 +952,8 @@ void CFrame::SaveIniPerspectives()
|
||||
SWidth = SWidth.substr(0, SWidth.length()-1);
|
||||
SHeight = SHeight.substr(0, SHeight.length()-1);
|
||||
|
||||
ini.Set(_Section, "Width", SWidth);
|
||||
ini.Set(_Section, "Height", SHeight);
|
||||
perspec_section->Set("Width", SWidth);
|
||||
perspec_section->Set("Height", SHeight);
|
||||
}
|
||||
|
||||
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
@@ -127,8 +127,10 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||
IniFile ini;
|
||||
ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + m_UniqueID + ".ini");
|
||||
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_UniqueID + ".ini", true);
|
||||
ini.Get("EmuState", "EmulationStateId", &m_emu_state);
|
||||
ini.Get("EmuState", "EmulationIssues", &m_issues);
|
||||
|
||||
IniFile::Section* emu_state = ini.GetOrCreateSection("EmuState");
|
||||
emu_state->Get("EmulationStateId", &m_emu_state);
|
||||
emu_state->Get("EmulationIssues", &m_issues);
|
||||
}
|
||||
|
||||
if (!m_pImage.empty())
|
||||
|
||||
@@ -1019,9 +1019,9 @@ void CISOProperties::SetCheckboxValueFromGameini(const char* section, const char
|
||||
{
|
||||
// Prefer local gameini value over default gameini value.
|
||||
bool value;
|
||||
if (GameIniLocal.Get(section, key, &value))
|
||||
if (GameIniLocal.GetOrCreateSection(section)->Get(key, &value))
|
||||
checkbox->Set3StateValue((wxCheckBoxState)value);
|
||||
else if (GameIniDefault.Get(section, key, &value))
|
||||
else if (GameIniDefault.GetOrCreateSection(section)->Get(key, &value))
|
||||
checkbox->Set3StateValue((wxCheckBoxState)value);
|
||||
else
|
||||
checkbox->Set3StateValue(wxCHK_UNDETERMINED);
|
||||
@@ -1042,34 +1042,39 @@ void CISOProperties::LoadGameConfig()
|
||||
SetCheckboxValueFromGameini("Wii", "Widescreen", EnableWideScreen);
|
||||
SetCheckboxValueFromGameini("Video", "UseBBox", UseBBox);
|
||||
|
||||
IniFile::Section* default_video = GameIniDefault.GetOrCreateSection("Video");
|
||||
IniFile::Section* local_video = GameIniLocal.GetOrCreateSection("Video");
|
||||
|
||||
// First set values from default gameini, then apply values from local gameini
|
||||
int iTemp;
|
||||
GameIniDefault.Get("Video", "ProjectionHack", &iTemp);
|
||||
default_video->Get("ProjectionHack", &iTemp);
|
||||
PHackEnable->SetValue(!!iTemp);
|
||||
if (GameIniLocal.Get("Video", "ProjectionHack", &iTemp))
|
||||
if (local_video->Get("ProjectionHack", &iTemp))
|
||||
PHackEnable->SetValue(!!iTemp);
|
||||
|
||||
GameIniDefault.Get("Video", "PH_SZNear", &PHack_Data.PHackSZNear);
|
||||
default_video->Get("PH_SZNear", &PHack_Data.PHackSZNear);
|
||||
if (GameIniLocal.GetIfExists("Video", "PH_SZNear", &iTemp))
|
||||
PHack_Data.PHackSZNear = !!iTemp;
|
||||
GameIniDefault.Get("Video", "PH_SZFar", &PHack_Data.PHackSZFar);
|
||||
default_video->Get("PH_SZFar", &PHack_Data.PHackSZFar);
|
||||
if (GameIniLocal.GetIfExists("Video", "PH_SZFar", &iTemp))
|
||||
PHack_Data.PHackSZFar = !!iTemp;
|
||||
|
||||
std::string sTemp;
|
||||
GameIniDefault.Get("Video", "PH_ZNear", &PHack_Data.PHZNear);
|
||||
default_video->Get("PH_ZNear", &PHack_Data.PHZNear);
|
||||
if (GameIniLocal.GetIfExists("Video", "PH_ZNear", &sTemp))
|
||||
PHack_Data.PHZNear = sTemp;
|
||||
GameIniDefault.Get("Video", "PH_ZFar", &PHack_Data.PHZFar);
|
||||
default_video->Get("PH_ZFar", &PHack_Data.PHZFar);
|
||||
if (GameIniLocal.GetIfExists("Video", "PH_ZFar", &sTemp))
|
||||
PHack_Data.PHZFar = sTemp;
|
||||
|
||||
GameIniDefault.Get("EmuState", "EmulationStateId", &iTemp, 0/*Not Set*/);
|
||||
|
||||
IniFile::Section* default_emustate = GameIniDefault.GetOrCreateSection("EmuState");
|
||||
default_emustate->Get("EmulationStateId", &iTemp, 0/*Not Set*/);
|
||||
EmuState->SetSelection(iTemp);
|
||||
if (GameIniLocal.GetIfExists("EmuState", "EmulationStateId", &iTemp))
|
||||
EmuState->SetSelection(iTemp);
|
||||
|
||||
GameIniDefault.Get("EmuState", "EmulationIssues", &sTemp);
|
||||
default_emustate->Get("EmulationIssues", &sTemp);
|
||||
if (!sTemp.empty())
|
||||
EmuIssues->SetValue(StrToWxStr(sTemp));
|
||||
if (GameIniLocal.GetIfExists("EmuState", "EmulationIssues", &sTemp))
|
||||
@@ -1092,13 +1097,13 @@ void CISOProperties::SaveGameIniValueFrom3StateCheckbox(const char* section, con
|
||||
if (checkbox->Get3StateValue() == wxCHK_UNDETERMINED)
|
||||
GameIniLocal.DeleteKey(section, key);
|
||||
else if (!GameIniDefault.Exists(section, key))
|
||||
GameIniLocal.Set(section, key, checkbox_val);
|
||||
GameIniLocal.GetOrCreateSection(section)->Set(key, checkbox_val);
|
||||
else
|
||||
{
|
||||
bool default_value;
|
||||
GameIniDefault.Get(section, key, &default_value);
|
||||
GameIniDefault.GetOrCreateSection(section)->Get(key, &default_value);
|
||||
if (default_value != checkbox_val)
|
||||
GameIniLocal.Set(section, key, checkbox_val);
|
||||
GameIniLocal.GetOrCreateSection(section)->Set(key, checkbox_val);
|
||||
else
|
||||
GameIniLocal.DeleteKey(section, key);
|
||||
}
|
||||
@@ -1122,13 +1127,13 @@ bool CISOProperties::SaveGameConfig()
|
||||
#define SAVE_IF_NOT_DEFAULT(section, key, val, def) do { \
|
||||
if (GameIniDefault.Exists((section), (key))) { \
|
||||
std::remove_reference<decltype((val))>::type tmp__; \
|
||||
GameIniDefault.Get((section), (key), &tmp__); \
|
||||
GameIniDefault.GetOrCreateSection((section))->Get((key), &tmp__); \
|
||||
if ((val) != tmp__) \
|
||||
GameIniLocal.Set((section), (key), (val)); \
|
||||
GameIniLocal.GetOrCreateSection((section))->Set((key), (val)); \
|
||||
else \
|
||||
GameIniLocal.DeleteKey((section), (key)); \
|
||||
} else if ((val) != (def)) \
|
||||
GameIniLocal.Set((section), (key), (val)); \
|
||||
GameIniLocal.GetOrCreateSection((section))->Set((key), (val)); \
|
||||
else \
|
||||
GameIniLocal.DeleteKey((section), (key)); \
|
||||
} while (0)
|
||||
|
||||
@@ -117,9 +117,11 @@ void LogConfigWindow::LoadSettings()
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
||||
|
||||
IniFile::Section* options = ini.GetOrCreateSection("Options");
|
||||
|
||||
// Retrieve the verbosity value from the config ini file.
|
||||
int verbosity;
|
||||
ini.Get("Options", "Verbosity", &verbosity, 0);
|
||||
options->Get("Verbosity", &verbosity, 0);
|
||||
|
||||
// Ensure the verbosity level is valid.
|
||||
if (verbosity < 1)
|
||||
@@ -131,16 +133,16 @@ void LogConfigWindow::LoadSettings()
|
||||
m_verbosity->SetSelection(verbosity - 1);
|
||||
|
||||
// Get the logger output settings from the config ini file.
|
||||
ini.Get("Options", "WriteToFile", &m_writeFile, false);
|
||||
options->Get("WriteToFile", &m_writeFile, false);
|
||||
m_writeFileCB->SetValue(m_writeFile);
|
||||
ini.Get("Options", "WriteToConsole", &m_writeConsole, true);
|
||||
options->Get("WriteToConsole", &m_writeConsole, true);
|
||||
m_writeConsoleCB->SetValue(m_writeConsole);
|
||||
ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
|
||||
options->Get("WriteToWindow", &m_writeWindow, true);
|
||||
m_writeWindowCB->SetValue(m_writeWindow);
|
||||
#ifdef _MSC_VER
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
ini.Get("Options", "WriteToDebugger", &m_writeDebugger, true);
|
||||
options->Get("WriteToDebugger", &m_writeDebugger, true);
|
||||
m_writeDebuggerCB->SetValue(m_writeDebugger);
|
||||
}
|
||||
else
|
||||
@@ -154,7 +156,7 @@ void LogConfigWindow::LoadSettings()
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
{
|
||||
bool log_enabled;
|
||||
ini.Get("Logs", m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), &log_enabled, true);
|
||||
ini.GetOrCreateSection("Logs")->Get(m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), &log_enabled, true);
|
||||
|
||||
if (log_enabled)
|
||||
enableAll = false;
|
||||
@@ -168,22 +170,20 @@ void LogConfigWindow::SaveSettings()
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
||||
|
||||
// Save the verbosity level.
|
||||
ini.Set("Options", "Verbosity", m_verbosity->GetSelection() + 1);
|
||||
|
||||
// Save the enabled/disabled states of the logger outputs to the config ini.
|
||||
ini.Set("Options", "WriteToFile", m_writeFile);
|
||||
ini.Set("Options", "WriteToConsole", m_writeConsole);
|
||||
ini.Set("Options", "WriteToWindow", m_writeWindow);
|
||||
IniFile::Section* options = ini.GetOrCreateSection("Options");
|
||||
options->Set("Verbosity", m_verbosity->GetSelection() + 1);
|
||||
options->Set("WriteToFile", m_writeFile);
|
||||
options->Set("WriteToConsole", m_writeConsole);
|
||||
options->Set("WriteToWindow", m_writeWindow);
|
||||
#ifdef _MSC_VER
|
||||
if (IsDebuggerPresent())
|
||||
ini.Set("Options", "WriteToDebugger", m_writeDebugger);
|
||||
options->Set("WriteToDebugger", m_writeDebugger);
|
||||
#endif
|
||||
|
||||
// Save all enabled/disabled states of the log types to the config ini.
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
{
|
||||
ini.Set("Logs", m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), m_checks->IsChecked(i));
|
||||
ini.GetOrCreateSection("Logs")->Set(m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), m_checks->IsChecked(i));
|
||||
}
|
||||
|
||||
ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
||||
|
||||
@@ -69,13 +69,15 @@ void CLogWindow::CreateGUIControls()
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
||||
|
||||
ini.Get("LogWindow", "x", &x, Parent->GetSize().GetX() / 2);
|
||||
ini.Get("LogWindow", "y", &y, Parent->GetSize().GetY());
|
||||
ini.Get("LogWindow", "pos", &winpos, wxAUI_DOCK_RIGHT);
|
||||
IniFile::Section* options = ini.GetOrCreateSection("Options");
|
||||
IniFile::Section* log_window = ini.GetOrCreateSection("LogWindow");
|
||||
log_window->Get("x", &x, Parent->GetSize().GetX() / 2);
|
||||
log_window->Get("y", &y, Parent->GetSize().GetY());
|
||||
log_window->Get("pos", &winpos, wxAUI_DOCK_RIGHT);
|
||||
|
||||
// Set up log listeners
|
||||
int verbosity;
|
||||
ini.Get("Options", "Verbosity", &verbosity, 0);
|
||||
options->Get("Verbosity", &verbosity, 0);
|
||||
|
||||
// Ensure the verbosity level is valid
|
||||
if (verbosity < 1)
|
||||
@@ -84,12 +86,12 @@ void CLogWindow::CreateGUIControls()
|
||||
verbosity = MAX_LOGLEVEL;
|
||||
|
||||
// Get the logger output settings from the config ini file.
|
||||
ini.Get("Options", "WriteToFile", &m_writeFile, false);
|
||||
ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
|
||||
options->Get("WriteToFile", &m_writeFile, false);
|
||||
options->Get("WriteToWindow", &m_writeWindow, true);
|
||||
#ifdef _MSC_VER
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
ini.Get("Options", "WriteToDebugger", &m_writeDebugger, true);
|
||||
options->Get("WriteToDebugger", &m_writeDebugger, true);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -97,10 +99,11 @@ void CLogWindow::CreateGUIControls()
|
||||
m_writeDebugger = false;
|
||||
}
|
||||
|
||||
IniFile::Section* logs = ini.GetOrCreateSection("Logs");
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
{
|
||||
bool enable;
|
||||
ini.Get("Logs", m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), &enable, true);
|
||||
logs->Get(m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), &enable, true);
|
||||
|
||||
if (m_writeWindow && enable)
|
||||
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, this);
|
||||
@@ -133,12 +136,12 @@ void CLogWindow::CreateGUIControls()
|
||||
LogFont.push_back(DebuggerFont);
|
||||
|
||||
int font;
|
||||
ini.Get("Options", "Font", &font, 0);
|
||||
options->Get("Font", &font, 0);
|
||||
m_FontChoice->SetSelection(font);
|
||||
|
||||
// Word wrap
|
||||
bool wrap_lines;
|
||||
ini.Get("Options", "WrapLines", &wrap_lines, false);
|
||||
options->Get("WrapLines", &wrap_lines, false);
|
||||
m_WrapLine = new wxCheckBox(this, IDM_WRAPLINE, _("Word Wrap"));
|
||||
m_WrapLine->SetValue(wrap_lines);
|
||||
|
||||
@@ -190,12 +193,16 @@ void CLogWindow::SaveSettings()
|
||||
|
||||
if (!Parent->g_pCodeWindow)
|
||||
{
|
||||
ini.Set("LogWindow", "x", x);
|
||||
ini.Set("LogWindow", "y", y);
|
||||
ini.Set("LogWindow", "pos", winpos);
|
||||
IniFile::Section* log_window = ini.GetOrCreateSection("LogWindow");
|
||||
log_window->Set("x", x);
|
||||
log_window->Set("y", y);
|
||||
log_window->Set("pos", winpos);
|
||||
}
|
||||
ini.Set("Options", "Font", m_FontChoice->GetSelection());
|
||||
ini.Set("Options", "WrapLines", m_WrapLine->IsChecked());
|
||||
|
||||
IniFile::Section* options = ini.GetOrCreateSection("Options");
|
||||
options->Set("Font", m_FontChoice->GetSelection());
|
||||
options->Set("WrapLines", m_WrapLine->IsChecked());
|
||||
|
||||
ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
||||
}
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ void DolphinApp::InitLanguageSupport()
|
||||
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||
ini.Get("Interface", "Language", &language, wxLANGUAGE_DEFAULT);
|
||||
ini.GetOrCreateSection("Interface")->Get("Language", &language, wxLANGUAGE_DEFAULT);
|
||||
|
||||
// Load language if possible, fall back to system default otherwise
|
||||
if (wxLocale::IsAvailable(language))
|
||||
|
||||
@@ -298,7 +298,7 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig
|
||||
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
||||
std::string value;
|
||||
|
||||
ini.Get(section, key, &value, defaultValue);
|
||||
ini.GetOrCreateSection(section)->Get(key, &value, defaultValue);
|
||||
|
||||
return env->NewStringUTF(value.c_str());
|
||||
}
|
||||
@@ -313,7 +313,7 @@ jstring jValue)
|
||||
|
||||
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
||||
|
||||
ini.Set(section, key, value);
|
||||
ini.GetOrCreateSection(section)->Set(key, value);
|
||||
ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user