Fix load default settings on first run.
Confirmed tested on my computer with default value.
This commit is contained in:
parent
4182df723f
commit
1f0c6bda5f
|
@ -38,8 +38,7 @@
|
|||
#include "Settings.hpp"
|
||||
#include "CxbxKrnl/Emu.h"
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <experimental/filesystem>
|
||||
|
||||
// TODO: Implement Qt support when real CPU emulation is available.
|
||||
#ifndef QT_VERSION // NOTE: Non-Qt will be using current directory for data
|
||||
|
@ -198,16 +197,8 @@ bool Settings::Init()
|
|||
#endif
|
||||
saveFile.append(szSettings_settings_file);
|
||||
|
||||
// If the config file does not exists, create a blank one
|
||||
// We can't call Save here because that overrides default values with false!
|
||||
if (!std::experimental::filesystem::exists(saveFile)) {
|
||||
std::ofstream ofs(saveFile, std::ofstream::out);
|
||||
ofs << "\n";
|
||||
ofs.close();
|
||||
}
|
||||
|
||||
// Call LoadUserConfig, this will load the config, applying defaults for any missing fields
|
||||
bRet = LoadUserConfig();
|
||||
// Call LoadConfig, this will load the config, applying defaults for any missing fields
|
||||
bRet = LoadConfig();
|
||||
|
||||
if (!bRet) {
|
||||
MessageBox(nullptr, szSettings_setup_error, "Cxbx-Reloaded", MB_OK);
|
||||
|
@ -245,9 +236,6 @@ bool Settings::LoadUserConfig()
|
|||
|
||||
bool Settings::LoadFile(std::string file_path)
|
||||
{
|
||||
bool bRet;
|
||||
const char* si_data;
|
||||
int iStatus;
|
||||
std::list<CSimpleIniA::Entry> si_list;
|
||||
std::list<CSimpleIniA::Entry>::iterator si_list_iterator;
|
||||
|
||||
|
@ -258,6 +246,17 @@ bool Settings::LoadFile(std::string file_path)
|
|||
}
|
||||
m_file_path = file_path;
|
||||
|
||||
return LoadConfig();
|
||||
}
|
||||
|
||||
bool Settings::LoadConfig()
|
||||
{
|
||||
bool bRet;
|
||||
const char* si_data;
|
||||
int iStatus;
|
||||
std::list<CSimpleIniA::Entry> si_list;
|
||||
std::list<CSimpleIniA::Entry>::iterator si_list_iterator;
|
||||
|
||||
// ==== GUI Begin ===========
|
||||
|
||||
m_gui.CxbxDebugMode = (DebugMode)m_si.GetLongValue(section_gui, sect_gui_keys.CxbxDebugMode, /*Default=*/DM_NONE);
|
||||
|
|
|
@ -123,6 +123,7 @@ public:
|
|||
bool Init();
|
||||
bool LoadUserConfig();
|
||||
bool LoadFile(std::string file_path);
|
||||
bool LoadConfig();
|
||||
bool Save(std::string file_path = "");
|
||||
void Delete();
|
||||
void SyncToEmulator();
|
||||
|
|
Loading…
Reference in New Issue