[Project64] Clean up settings
This commit is contained in:
parent
c187bc1e91
commit
d4bddb3892
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
CIniFile * CSettingTypeApplication::m_SettingsIniFile = NULL;
|
CIniFile * CSettingTypeApplication::m_SettingsIniFile = NULL;
|
||||||
|
|
||||||
CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, uint32_t DefaultValue ) :
|
CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, uint32_t DefaultValue) :
|
||||||
m_DefaultStr(""),
|
m_DefaultStr(""),
|
||||||
m_DefaultValue(DefaultValue),
|
m_DefaultValue(DefaultValue),
|
||||||
m_DefaultSetting(Default_Constant),
|
m_DefaultSetting(Default_Constant),
|
||||||
|
@ -24,33 +24,33 @@ CSettingTypeApplication::CSettingTypeApplication(const char * Section, const cha
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, bool DefaultValue ) :
|
CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, bool DefaultValue) :
|
||||||
m_DefaultStr(""),
|
m_DefaultStr(""),
|
||||||
m_DefaultValue(DefaultValue),
|
m_DefaultValue(DefaultValue),
|
||||||
m_DefaultSetting(Default_Constant),
|
m_DefaultSetting(Default_Constant),
|
||||||
m_Section(FixSectionName(Section)),
|
m_Section(FixSectionName(Section)),
|
||||||
m_KeyName(Name),
|
m_KeyName(Name),
|
||||||
m_KeyNameIdex(m_KeyName)
|
m_KeyNameIdex(m_KeyName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, const char * DefaultValue ) :
|
CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, const char * DefaultValue) :
|
||||||
m_DefaultStr(DefaultValue),
|
m_DefaultStr(DefaultValue),
|
||||||
m_DefaultValue(0),
|
m_DefaultValue(0),
|
||||||
m_DefaultSetting(Default_Constant),
|
m_DefaultSetting(Default_Constant),
|
||||||
m_Section(FixSectionName(Section)),
|
m_Section(FixSectionName(Section)),
|
||||||
m_KeyName(Name),
|
m_KeyName(Name),
|
||||||
m_KeyNameIdex(m_KeyName)
|
m_KeyNameIdex(m_KeyName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, SettingID DefaultSetting ) :
|
CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, SettingID DefaultSetting) :
|
||||||
m_DefaultStr(""),
|
m_DefaultStr(""),
|
||||||
m_DefaultValue(0),
|
m_DefaultValue(0),
|
||||||
m_DefaultSetting(DefaultSetting),
|
m_DefaultSetting(DefaultSetting),
|
||||||
m_Section(FixSectionName(Section)),
|
m_Section(FixSectionName(Section)),
|
||||||
m_KeyName(Name),
|
m_KeyName(Name),
|
||||||
m_KeyNameIdex(m_KeyName)
|
m_KeyNameIdex(m_KeyName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,23 +58,23 @@ CSettingTypeApplication::~CSettingTypeApplication()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeApplication::Initialize( const char * /*AppName*/ )
|
void CSettingTypeApplication::Initialize(const char * /*AppName*/)
|
||||||
{
|
{
|
||||||
WriteTrace(TraceAppInit, TraceDebug, "Start");
|
WriteTrace(TraceAppInit, TraceDebug, "Start");
|
||||||
CPath BaseDir(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(),"");
|
CPath BaseDir(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(), "");
|
||||||
if (!BaseDir.DirectoryExists())
|
if (!BaseDir.DirectoryExists())
|
||||||
{
|
{
|
||||||
WriteTrace(TraceAppInit, TraceDebug, "BaseDir does not exists, doing nothing");
|
WriteTrace(TraceAppInit, TraceDebug, "BaseDir does not exists, doing nothing");
|
||||||
WriteTrace(TraceAppInit, TraceDebug, "Done");
|
WriteTrace(TraceAppInit, TraceDebug, "Done");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stdstr SettingsFile, OrigSettingsFile;
|
stdstr SettingsFile, OrigSettingsFile;
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
OrigSettingsFile = SettingsFile;
|
OrigSettingsFile = SettingsFile;
|
||||||
if (!g_Settings->LoadStringVal(SupportFile_Settings,SettingsFile) && i > 0)
|
if (!g_Settings->LoadStringVal(SupportFile_Settings, SettingsFile) && i > 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -87,13 +87,13 @@ void CSettingTypeApplication::Initialize( const char * /*AppName*/ )
|
||||||
delete m_SettingsIniFile;
|
delete m_SettingsIniFile;
|
||||||
}
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(),"");
|
CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(), "");
|
||||||
#else
|
#else
|
||||||
CPath SettingsDir(CPath(SettingsFile).GetDirectory(), "");
|
CPath SettingsDir(CPath(SettingsFile).GetDirectory(), "");
|
||||||
#endif
|
#endif
|
||||||
if (!SettingsDir.DirectoryExists())
|
if (!SettingsDir.DirectoryExists())
|
||||||
{
|
{
|
||||||
SettingsDir.DirectoryCreate();
|
SettingsDir.DirectoryCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_SettingsIniFile = new CIniFile(SettingsFile.c_str());
|
m_SettingsIniFile = new CIniFile(SettingsFile.c_str());
|
||||||
|
@ -121,7 +121,7 @@ void CSettingTypeApplication::CleanUp()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettingTypeApplication::Load ( int /*Index*/, bool & Value ) const
|
bool CSettingTypeApplication::Load(int /*Index*/, bool & Value) const
|
||||||
{
|
{
|
||||||
bool bRes = false;
|
bool bRes = false;
|
||||||
|
|
||||||
|
@ -138,48 +138,48 @@ bool CSettingTypeApplication::Load ( int /*Index*/, bool & Value ) const
|
||||||
{
|
{
|
||||||
Value = m_DefaultValue != 0;
|
Value = m_DefaultValue != 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_Settings->LoadBool(m_DefaultSetting,Value);
|
g_Settings->LoadBool(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bRes;
|
return bRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettingTypeApplication::Load ( int /*Index*/, uint32_t & Value ) const
|
bool CSettingTypeApplication::Load(int /*Index*/, uint32_t & Value) const
|
||||||
{
|
{
|
||||||
bool bRes = m_SettingsIniFile->GetNumber(SectionName(),m_KeyNameIdex.c_str(),Value,Value);
|
bool bRes = m_SettingsIniFile->GetNumber(SectionName(), m_KeyNameIdex.c_str(), Value, Value);
|
||||||
if (!bRes && m_DefaultSetting != Default_None)
|
if (!bRes && m_DefaultSetting != Default_None)
|
||||||
{
|
{
|
||||||
if (m_DefaultSetting == Default_Constant)
|
if (m_DefaultSetting == Default_Constant)
|
||||||
{
|
{
|
||||||
Value = m_DefaultValue;
|
Value = m_DefaultValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_Settings->LoadDword(m_DefaultSetting,Value);
|
g_Settings->LoadDword(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bRes;
|
return bRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * CSettingTypeApplication::SectionName ( void ) const
|
const char * CSettingTypeApplication::SectionName(void) const
|
||||||
{
|
{
|
||||||
return m_Section.c_str();
|
return m_Section.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettingTypeApplication::Load ( int Index, stdstr & Value ) const
|
bool CSettingTypeApplication::Load(int Index, stdstr & Value) const
|
||||||
{
|
{
|
||||||
bool bRes = m_SettingsIniFile ? m_SettingsIniFile->GetString(SectionName(),m_KeyNameIdex.c_str(),m_DefaultStr,Value) : false;
|
bool bRes = m_SettingsIniFile ? m_SettingsIniFile->GetString(SectionName(), m_KeyNameIdex.c_str(), m_DefaultStr, Value) : false;
|
||||||
if (!bRes)
|
if (!bRes)
|
||||||
{
|
{
|
||||||
CSettingTypeApplication::LoadDefault(Index,Value);
|
CSettingTypeApplication::LoadDefault(Index, Value);
|
||||||
}
|
}
|
||||||
return bRes;
|
return bRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//return the default values
|
//return the default values
|
||||||
void CSettingTypeApplication::LoadDefault ( int /*Index*/, bool & Value ) const
|
void CSettingTypeApplication::LoadDefault(int /*Index*/, bool & Value) const
|
||||||
{
|
{
|
||||||
if (m_DefaultSetting != Default_None)
|
if (m_DefaultSetting != Default_None)
|
||||||
{
|
{
|
||||||
|
@ -187,9 +187,9 @@ void CSettingTypeApplication::LoadDefault ( int /*Index*/, bool & Value ) cons
|
||||||
{
|
{
|
||||||
Value = m_DefaultValue != 0;
|
Value = m_DefaultValue != 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_Settings->LoadBool(m_DefaultSetting,Value);
|
g_Settings->LoadBool(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,14 +202,14 @@ void CSettingTypeApplication::LoadDefault(int /*Index*/, uint32_t & Value) const
|
||||||
{
|
{
|
||||||
Value = m_DefaultValue;
|
Value = m_DefaultValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_Settings->LoadDword(m_DefaultSetting,Value);
|
g_Settings->LoadDword(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeApplication::LoadDefault ( int /*Index*/, stdstr & Value ) const
|
void CSettingTypeApplication::LoadDefault(int /*Index*/, stdstr & Value) const
|
||||||
{
|
{
|
||||||
if (m_DefaultSetting != Default_None)
|
if (m_DefaultSetting != Default_None)
|
||||||
{
|
{
|
||||||
|
@ -217,20 +217,20 @@ void CSettingTypeApplication::LoadDefault ( int /*Index*/, stdstr & Value ) cons
|
||||||
{
|
{
|
||||||
Value = m_DefaultStr;
|
Value = m_DefaultStr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_Settings->LoadStringVal(m_DefaultSetting,Value);
|
g_Settings->LoadStringVal(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the settings
|
//Update the settings
|
||||||
void CSettingTypeApplication::Save ( int /*Index*/, bool Value )
|
void CSettingTypeApplication::Save(int /*Index*/, bool Value)
|
||||||
{
|
{
|
||||||
m_SettingsIniFile->SaveNumber(SectionName(),m_KeyNameIdex.c_str(),Value);
|
m_SettingsIniFile->SaveNumber(SectionName(), m_KeyNameIdex.c_str(), Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeApplication::Save ( int /*Index*/, uint32_t Value )
|
void CSettingTypeApplication::Save(int /*Index*/, uint32_t Value)
|
||||||
{
|
{
|
||||||
if (m_DefaultSetting != Default_None &&
|
if (m_DefaultSetting != Default_None &&
|
||||||
((m_DefaultSetting == Default_Constant && m_DefaultValue == Value) ||
|
((m_DefaultSetting == Default_Constant && m_DefaultValue == Value) ||
|
||||||
|
@ -244,14 +244,14 @@ void CSettingTypeApplication::Save ( int /*Index*/, uint32_t Value )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeApplication::Save ( int /*Index*/, const stdstr & Value )
|
void CSettingTypeApplication::Save(int /*Index*/, const stdstr & Value)
|
||||||
{
|
{
|
||||||
m_SettingsIniFile->SaveString(SectionName(),m_KeyNameIdex.c_str(),Value.c_str());
|
m_SettingsIniFile->SaveString(SectionName(), m_KeyNameIdex.c_str(), Value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeApplication::Save ( int /*Index*/, const char * Value )
|
void CSettingTypeApplication::Save(int /*Index*/, const char * Value)
|
||||||
{
|
{
|
||||||
m_SettingsIniFile->SaveString(SectionName(),m_KeyNameIdex.c_str(),Value);
|
m_SettingsIniFile->SaveString(SectionName(), m_KeyNameIdex.c_str(), Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
stdstr CSettingTypeApplication::FixSectionName(const char * Section)
|
stdstr CSettingTypeApplication::FixSectionName(const char * Section)
|
||||||
|
@ -262,11 +262,11 @@ stdstr CSettingTypeApplication::FixSectionName(const char * Section)
|
||||||
{
|
{
|
||||||
SectionName = "default";
|
SectionName = "default";
|
||||||
}
|
}
|
||||||
SectionName.Replace("\\","-");
|
SectionName.Replace("\\", "-");
|
||||||
return SectionName;
|
return SectionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeApplication::Delete( int /*Index*/ )
|
void CSettingTypeApplication::Delete(int /*Index*/)
|
||||||
{
|
{
|
||||||
m_SettingsIniFile->SaveString(SectionName(),m_KeyNameIdex.c_str(),NULL);
|
m_SettingsIniFile->SaveString(SectionName(), m_KeyNameIdex.c_str(), NULL);
|
||||||
}
|
}
|
|
@ -14,32 +14,32 @@ class CSettingTypeApplicationIndex :
|
||||||
public CSettingTypeApplication
|
public CSettingTypeApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CSettingTypeApplicationIndex(const char * Section, const char * Name, const char * DefaultValue );
|
CSettingTypeApplicationIndex(const char * Section, const char * Name, const char * DefaultValue);
|
||||||
CSettingTypeApplicationIndex(const char * Section, const char * Name, bool DefaultValue );
|
CSettingTypeApplicationIndex(const char * Section, const char * Name, bool DefaultValue);
|
||||||
CSettingTypeApplicationIndex(const char * Section, const char * Name, uint32_t DefaultValue );
|
CSettingTypeApplicationIndex(const char * Section, const char * Name, uint32_t DefaultValue);
|
||||||
CSettingTypeApplicationIndex(const char * Section, const char * Name, SettingID DefaultSetting );
|
CSettingTypeApplicationIndex(const char * Section, const char * Name, SettingID DefaultSetting);
|
||||||
~CSettingTypeApplicationIndex();
|
~CSettingTypeApplicationIndex();
|
||||||
|
|
||||||
virtual bool IndexBasedSetting ( void ) const { return true; }
|
virtual bool IndexBasedSetting(void) const { return true; }
|
||||||
|
|
||||||
//return the values
|
//return the values
|
||||||
virtual bool Load ( int32_t Index, bool & Value ) const;
|
virtual bool Load(int32_t Index, bool & Value) const;
|
||||||
virtual bool Load ( int32_t Index, uint32_t & Value ) const;
|
virtual bool Load(int32_t Index, uint32_t & Value) const;
|
||||||
virtual bool Load ( int32_t Index, stdstr & Value ) const;
|
virtual bool Load(int32_t Index, stdstr & Value) const;
|
||||||
|
|
||||||
//return the default values
|
//return the default values
|
||||||
virtual void LoadDefault ( int32_t Index, bool & Value ) const;
|
virtual void LoadDefault(int32_t Index, bool & Value) const;
|
||||||
virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
|
virtual void LoadDefault(int32_t Index, uint32_t & Value) const;
|
||||||
virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
|
virtual void LoadDefault(int32_t Index, stdstr & Value) const;
|
||||||
|
|
||||||
//Update the settings
|
//Update the settings
|
||||||
virtual void Save ( int32_t Index, bool Value );
|
virtual void Save(int32_t Index, bool Value);
|
||||||
virtual void Save ( int32_t Index, uint32_t Value );
|
virtual void Save(int32_t Index, uint32_t Value);
|
||||||
virtual void Save ( int32_t Index, const stdstr & Value );
|
virtual void Save(int32_t Index, const stdstr & Value);
|
||||||
virtual void Save ( int32_t Index, const char * Value );
|
virtual void Save(int32_t Index, const char * Value);
|
||||||
|
|
||||||
// Delete the setting
|
// Delete the setting
|
||||||
virtual void Delete ( int32_t Index );
|
virtual void Delete(int32_t Index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSettingTypeApplicationIndex(void); // Disable default constructor
|
CSettingTypeApplicationIndex(void); // Disable default constructor
|
||||||
|
|
|
@ -14,23 +14,23 @@
|
||||||
#include <Common/StdString.h>
|
#include <Common/StdString.h>
|
||||||
#include <Common/stdtypes.h>
|
#include <Common/stdtypes.h>
|
||||||
|
|
||||||
enum SettingType
|
enum SettingType
|
||||||
{
|
{
|
||||||
SettingType_Unknown = -1,
|
SettingType_Unknown = -1,
|
||||||
SettingType_ConstString = 0,
|
SettingType_ConstString = 0,
|
||||||
SettingType_ConstValue = 1,
|
SettingType_ConstValue = 1,
|
||||||
SettingType_CfgFile = 2,
|
SettingType_CfgFile = 2,
|
||||||
SettingType_Registry = 3,
|
SettingType_Registry = 3,
|
||||||
SettingType_RelativePath = 4,
|
SettingType_RelativePath = 4,
|
||||||
TemporarySetting = 5,
|
TemporarySetting = 5,
|
||||||
SettingType_RomDatabase = 6,
|
SettingType_RomDatabase = 6,
|
||||||
SettingType_CheatSetting = 7,
|
SettingType_CheatSetting = 7,
|
||||||
SettingType_GameSetting = 8,
|
SettingType_GameSetting = 8,
|
||||||
SettingType_BoolVariable = 9,
|
SettingType_BoolVariable = 9,
|
||||||
SettingType_NumberVariable = 10,
|
SettingType_NumberVariable = 10,
|
||||||
SettingType_StringVariable = 11,
|
SettingType_StringVariable = 11,
|
||||||
SettingType_SelectedDirectory = 12,
|
SettingType_SelectedDirectory = 12,
|
||||||
SettingType_RdbSetting = 13,
|
SettingType_RdbSetting = 13,
|
||||||
};
|
};
|
||||||
|
|
||||||
class CSettingType
|
class CSettingType
|
||||||
|
@ -38,25 +38,25 @@ class CSettingType
|
||||||
public:
|
public:
|
||||||
virtual ~CSettingType() {};
|
virtual ~CSettingType() {};
|
||||||
|
|
||||||
virtual SettingType GetSettingType ( void ) const = 0;
|
virtual SettingType GetSettingType(void) const = 0;
|
||||||
virtual bool IndexBasedSetting ( void ) const = 0;
|
virtual bool IndexBasedSetting(void) const = 0;
|
||||||
|
|
||||||
//return the values
|
//return the values
|
||||||
virtual bool Load ( int32_t Index, bool & Value ) const = 0;
|
virtual bool Load(int32_t Index, bool & Value) const = 0;
|
||||||
virtual bool Load ( int32_t Index, uint32_t & Value ) const = 0;
|
virtual bool Load(int32_t Index, uint32_t & Value) const = 0;
|
||||||
virtual bool Load ( int32_t Index, stdstr & Value ) const = 0;
|
virtual bool Load(int32_t Index, stdstr & Value) const = 0;
|
||||||
|
|
||||||
//return the default values
|
//return the default values
|
||||||
virtual void LoadDefault ( int32_t Index, bool & Value ) const = 0;
|
virtual void LoadDefault(int32_t Index, bool & Value) const = 0;
|
||||||
virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const = 0;
|
virtual void LoadDefault(int32_t Index, uint32_t & Value) const = 0;
|
||||||
virtual void LoadDefault ( int32_t Index, stdstr & Value ) const = 0;
|
virtual void LoadDefault(int32_t Index, stdstr & Value) const = 0;
|
||||||
|
|
||||||
//Update the settings
|
//Update the settings
|
||||||
virtual void Save ( int32_t Index, bool Value ) = 0;
|
virtual void Save(int32_t Index, bool Value) = 0;
|
||||||
virtual void Save ( int32_t Index, uint32_t Value ) = 0;
|
virtual void Save(int32_t Index, uint32_t Value) = 0;
|
||||||
virtual void Save ( int32_t Index, const stdstr & Value ) = 0;
|
virtual void Save(int32_t Index, const stdstr & Value) = 0;
|
||||||
virtual void Save ( int32_t Index, const char * Value ) = 0;
|
virtual void Save(int32_t Index, const char * Value) = 0;
|
||||||
|
|
||||||
// Delete the setting
|
// Delete the setting
|
||||||
virtual void Delete ( int32_t Index ) = 0;
|
virtual void Delete(int32_t Index) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -62,19 +62,6 @@ void CSettingTypeCheats::GameChanged ( void * /*Data */ )
|
||||||
*m_SectionIdent = g_Settings->LoadStringVal(Game_IniKey);
|
*m_SectionIdent = g_Settings->LoadStringVal(Game_IniKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*stdstr CSettingTypeCheats::FixName ( const char * Section, const char * Name )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * CSettingTypeCheats::SectionName ( void ) const
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSettingTypeCheats::UpdateSettings ( void * )
|
|
||||||
{
|
|
||||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
bool CSettingTypeCheats::Load ( int /*Index*/, bool & /*Value*/ ) const
|
bool CSettingTypeCheats::Load ( int /*Index*/, bool & /*Value*/ ) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,18 +16,18 @@ bool CSettingTypeGame::m_RdbEditor = false;
|
||||||
bool CSettingTypeGame::m_EraseDefaults = true;
|
bool CSettingTypeGame::m_EraseDefaults = true;
|
||||||
stdstr * CSettingTypeGame::m_SectionIdent = NULL;
|
stdstr * CSettingTypeGame::m_SectionIdent = NULL;
|
||||||
|
|
||||||
CSettingTypeGame::CSettingTypeGame(const char * Name, const char * DefaultValue ) :
|
CSettingTypeGame::CSettingTypeGame(const char * Name, const char * DefaultValue) :
|
||||||
CSettingTypeApplication("",Name,DefaultValue)
|
CSettingTypeApplication("", Name, DefaultValue)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettingTypeGame::CSettingTypeGame(const char * Name, uint32_t DefaultValue ) :
|
CSettingTypeGame::CSettingTypeGame(const char * Name, uint32_t DefaultValue) :
|
||||||
CSettingTypeApplication("",Name,DefaultValue)
|
CSettingTypeApplication("", Name, DefaultValue)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettingTypeGame::CSettingTypeGame(const char * Name, SettingID DefaultSetting ) :
|
CSettingTypeGame::CSettingTypeGame(const char * Name, SettingID DefaultSetting) :
|
||||||
CSettingTypeApplication("",Name,DefaultSetting)
|
CSettingTypeApplication("", Name, DefaultSetting)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,17 +35,17 @@ CSettingTypeGame::~CSettingTypeGame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeGame::Initialize ( void )
|
void CSettingTypeGame::Initialize(void)
|
||||||
{
|
{
|
||||||
WriteTrace(TraceAppInit, TraceDebug, "Start");
|
WriteTrace(TraceAppInit, TraceDebug, "Start");
|
||||||
UpdateSettings(NULL);
|
UpdateSettings(NULL);
|
||||||
g_Settings->RegisterChangeCB(Game_IniKey,NULL,UpdateSettings);
|
g_Settings->RegisterChangeCB(Game_IniKey, NULL, UpdateSettings);
|
||||||
WriteTrace(TraceAppInit, TraceDebug, "Done");
|
WriteTrace(TraceAppInit, TraceDebug, "Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeGame::CleanUp ( void )
|
void CSettingTypeGame::CleanUp(void)
|
||||||
{
|
{
|
||||||
g_Settings->UnregisterChangeCB(Game_IniKey,NULL,UpdateSettings);
|
g_Settings->UnregisterChangeCB(Game_IniKey, NULL, UpdateSettings);
|
||||||
if (m_SectionIdent)
|
if (m_SectionIdent)
|
||||||
{
|
{
|
||||||
delete m_SectionIdent;
|
delete m_SectionIdent;
|
||||||
|
@ -53,14 +53,14 @@ void CSettingTypeGame::CleanUp ( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * CSettingTypeGame::SectionName ( void ) const
|
const char * CSettingTypeGame::SectionName(void) const
|
||||||
{
|
{
|
||||||
return m_SectionIdent ? m_SectionIdent->c_str() : "";
|
return m_SectionIdent ? m_SectionIdent->c_str() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeGame::UpdateSettings ( void * /*Data */ )
|
void CSettingTypeGame::UpdateSettings(void * /*Data */)
|
||||||
{
|
{
|
||||||
m_RdbEditor = g_Settings->LoadBool(Setting_RdbEditor);
|
m_RdbEditor = g_Settings->LoadBool(Setting_RdbEditor);
|
||||||
m_EraseDefaults = g_Settings->LoadBool(Setting_EraseGameDefaults);
|
m_EraseDefaults = g_Settings->LoadBool(Setting_EraseGameDefaults);
|
||||||
stdstr SectionIdent = g_Settings->LoadStringVal(Game_IniKey);
|
stdstr SectionIdent = g_Settings->LoadStringVal(Game_IniKey);
|
||||||
|
|
||||||
|
@ -76,101 +76,119 @@ void CSettingTypeGame::UpdateSettings ( void * /*Data */ )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettingTypeGame::Load ( int Index, bool & Value ) const
|
bool CSettingTypeGame::Load(int Index, bool & Value) const
|
||||||
{
|
{
|
||||||
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
return g_Settings->LoadBoolIndex(m_DefaultSetting,Index,Value);
|
return g_Settings->LoadBoolIndex(m_DefaultSetting, Index, Value);
|
||||||
} else {
|
}
|
||||||
return g_Settings->LoadBool(m_DefaultSetting,Value);
|
else
|
||||||
|
{
|
||||||
|
return g_Settings->LoadBool(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CSettingTypeApplication::Load(Index,Value);
|
return CSettingTypeApplication::Load(Index, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettingTypeGame::Load ( int Index, uint32_t & Value ) const
|
bool CSettingTypeGame::Load(int Index, uint32_t & Value) const
|
||||||
{
|
{
|
||||||
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
return g_Settings->LoadDwordIndex(m_DefaultSetting,Index,Value);
|
return g_Settings->LoadDwordIndex(m_DefaultSetting, Index, Value);
|
||||||
} else {
|
}
|
||||||
return g_Settings->LoadDword(m_DefaultSetting,Value);
|
else
|
||||||
|
{
|
||||||
|
return g_Settings->LoadDword(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CSettingTypeApplication::Load(Index,Value);
|
return CSettingTypeApplication::Load(Index, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettingTypeGame::Load ( int Index, stdstr & Value ) const
|
bool CSettingTypeGame::Load(int Index, stdstr & Value) const
|
||||||
{
|
{
|
||||||
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
return g_Settings->LoadStringIndex(m_DefaultSetting,Index,Value);
|
return g_Settings->LoadStringIndex(m_DefaultSetting, Index, Value);
|
||||||
} else {
|
}
|
||||||
return g_Settings->LoadStringVal(m_DefaultSetting,Value);
|
else
|
||||||
|
{
|
||||||
|
return g_Settings->LoadStringVal(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CSettingTypeApplication::Load(Index,Value);
|
return CSettingTypeApplication::Load(Index, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//return the default values
|
//return the default values
|
||||||
void CSettingTypeGame::LoadDefault ( int Index, bool & Value ) const
|
void CSettingTypeGame::LoadDefault(int Index, bool & Value) const
|
||||||
{
|
{
|
||||||
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
g_Settings->LoadDefaultBoolIndex(m_DefaultSetting,Index,Value);
|
g_Settings->LoadDefaultBoolIndex(m_DefaultSetting, Index, Value);
|
||||||
} else {
|
|
||||||
g_Settings->LoadDefaultBool(m_DefaultSetting,Value);
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
CSettingTypeApplication::LoadDefault(Index,Value);
|
{
|
||||||
|
g_Settings->LoadDefaultBool(m_DefaultSetting, Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSettingTypeApplication::LoadDefault(Index, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeGame::LoadDefault ( int Index, uint32_t & Value ) const
|
void CSettingTypeGame::LoadDefault(int Index, uint32_t & Value) const
|
||||||
{
|
{
|
||||||
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
g_Settings->LoadDefaultDwordIndex(m_DefaultSetting,Index,Value);
|
g_Settings->LoadDefaultDwordIndex(m_DefaultSetting, Index, Value);
|
||||||
} else {
|
|
||||||
g_Settings->LoadDefaultDword(m_DefaultSetting,Value);
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
CSettingTypeApplication::LoadDefault(Index,Value);
|
{
|
||||||
|
g_Settings->LoadDefaultDword(m_DefaultSetting, Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSettingTypeApplication::LoadDefault(Index, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeGame::LoadDefault ( int Index, stdstr & Value ) const
|
void CSettingTypeGame::LoadDefault(int Index, stdstr & Value) const
|
||||||
{
|
{
|
||||||
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
g_Settings->LoadDefaultStringIndex(m_DefaultSetting,Index,Value);
|
g_Settings->LoadDefaultStringIndex(m_DefaultSetting, Index, Value);
|
||||||
} else {
|
|
||||||
g_Settings->LoadDefaultString(m_DefaultSetting,Value);
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
CSettingTypeApplication::LoadDefault(Index,Value);
|
{
|
||||||
|
g_Settings->LoadDefaultString(m_DefaultSetting, Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSettingTypeApplication::LoadDefault(Index, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the settings
|
//Update the settings
|
||||||
void CSettingTypeGame::Save ( int Index, bool Value )
|
void CSettingTypeGame::Save(int Index, bool Value)
|
||||||
{
|
{
|
||||||
if (m_EraseDefaults)
|
if (m_EraseDefaults)
|
||||||
{
|
{
|
||||||
bool bDefault;
|
bool bDefault;
|
||||||
LoadDefault(Index,bDefault);
|
LoadDefault(Index, bDefault);
|
||||||
if (bDefault == Value)
|
if (bDefault == Value)
|
||||||
{
|
{
|
||||||
Delete(Index);
|
Delete(Index);
|
||||||
|
@ -181,21 +199,25 @@ void CSettingTypeGame::Save ( int Index, bool Value )
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
g_Settings->SaveBoolIndex(m_DefaultSetting,Index,Value);
|
g_Settings->SaveBoolIndex(m_DefaultSetting, Index, Value);
|
||||||
} else {
|
|
||||||
g_Settings->SaveBool(m_DefaultSetting,Value);
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
CSettingTypeApplication::Save(Index,Value);
|
{
|
||||||
|
g_Settings->SaveBool(m_DefaultSetting, Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSettingTypeApplication::Save(Index, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeGame::Save ( int Index, uint32_t Value )
|
void CSettingTypeGame::Save(int Index, uint32_t Value)
|
||||||
{
|
{
|
||||||
if (m_EraseDefaults)
|
if (m_EraseDefaults)
|
||||||
{
|
{
|
||||||
uint32_t ulDefault;
|
uint32_t ulDefault;
|
||||||
CSettingTypeGame::LoadDefault(Index,ulDefault);
|
CSettingTypeGame::LoadDefault(Index, ulDefault);
|
||||||
if (ulDefault == Value)
|
if (ulDefault == Value)
|
||||||
{
|
{
|
||||||
Delete(Index);
|
Delete(Index);
|
||||||
|
@ -206,27 +228,31 @@ void CSettingTypeGame::Save ( int Index, uint32_t Value )
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
g_Settings->SaveDwordIndex(m_DefaultSetting,Index,Value);
|
g_Settings->SaveDwordIndex(m_DefaultSetting, Index, Value);
|
||||||
} else {
|
|
||||||
g_Settings->SaveDword(m_DefaultSetting,Value);
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
CSettingTypeApplication::Save(Index,Value);
|
{
|
||||||
|
g_Settings->SaveDword(m_DefaultSetting, Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSettingTypeApplication::Save(Index, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeGame::Save ( int Index, const stdstr & Value )
|
void CSettingTypeGame::Save(int Index, const stdstr & Value)
|
||||||
{
|
{
|
||||||
Save(Index,Value.c_str());
|
Save(Index, Value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeGame::Save ( int Index, const char * Value )
|
void CSettingTypeGame::Save(int Index, const char * Value)
|
||||||
{
|
{
|
||||||
if (m_EraseDefaults && m_DefaultSetting != Rdb_GoodName)
|
if (m_EraseDefaults && m_DefaultSetting != Rdb_GoodName)
|
||||||
{
|
{
|
||||||
stdstr szDefault;
|
stdstr szDefault;
|
||||||
CSettingTypeGame::LoadDefault(Index,szDefault);
|
CSettingTypeGame::LoadDefault(Index, szDefault);
|
||||||
if (_stricmp(szDefault.c_str(),Value) == 0)
|
if (_stricmp(szDefault.c_str(), Value) == 0)
|
||||||
{
|
{
|
||||||
Delete(Index);
|
Delete(Index);
|
||||||
return;
|
return;
|
||||||
|
@ -236,26 +262,34 @@ void CSettingTypeGame::Save ( int Index, const char * Value )
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
g_Settings->SaveStringIndex(m_DefaultSetting,Index,Value);
|
g_Settings->SaveStringIndex(m_DefaultSetting, Index, Value);
|
||||||
} else {
|
|
||||||
g_Settings->SaveString(m_DefaultSetting,Value);
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
CSettingTypeApplication::Save(Index,Value);
|
{
|
||||||
|
g_Settings->SaveString(m_DefaultSetting, Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSettingTypeApplication::Save(Index, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingTypeGame::Delete ( int Index )
|
void CSettingTypeGame::Delete(int Index)
|
||||||
{
|
{
|
||||||
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase)
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
g_Settings->DeleteSettingIndex(m_DefaultSetting,Index);
|
g_Settings->DeleteSettingIndex(m_DefaultSetting, Index);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
g_Settings->DeleteSetting(m_DefaultSetting);
|
g_Settings->DeleteSetting(m_DefaultSetting);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CSettingTypeApplication::Delete(Index);
|
CSettingTypeApplication::Delete(Index);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,8 +12,8 @@
|
||||||
#include "SettingsType-RelativePath.h"
|
#include "SettingsType-RelativePath.h"
|
||||||
|
|
||||||
CSettingTypeRelativePath::CSettingTypeRelativePath(const char * Directory, const char * FileName) :
|
CSettingTypeRelativePath::CSettingTypeRelativePath(const char * Directory, const char * FileName) :
|
||||||
m_Directory(Directory),
|
m_Directory(Directory),
|
||||||
m_FileName(FileName)
|
m_FileName(FileName)
|
||||||
{
|
{
|
||||||
BuildPath();
|
BuildPath();
|
||||||
g_Settings->RegisterChangeCB(Cmd_BaseDirectory, this, RefreshSettings);
|
g_Settings->RegisterChangeCB(Cmd_BaseDirectory, this, RefreshSettings);
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
#include "SettingsType-SelectedDirectory.h"
|
#include "SettingsType-SelectedDirectory.h"
|
||||||
|
|
||||||
CSettingTypeSelectedDirectory::CSettingTypeSelectedDirectory(const char * Name, SettingID InitialDir, SettingID SelectedDir, SettingID UseSelected, SettingID NotifyChangeId) :
|
CSettingTypeSelectedDirectory::CSettingTypeSelectedDirectory(const char * Name, SettingID InitialDir, SettingID SelectedDir, SettingID UseSelected, SettingID NotifyChangeId) :
|
||||||
m_Name(Name),
|
m_Name(Name),
|
||||||
m_InitialDir(InitialDir),
|
m_InitialDir(InitialDir),
|
||||||
m_SelectedDir(SelectedDir),
|
m_SelectedDir(SelectedDir),
|
||||||
m_UseSelected(UseSelected),
|
m_UseSelected(UseSelected),
|
||||||
m_NotifyChangeId(NotifyChangeId)
|
m_NotifyChangeId(NotifyChangeId)
|
||||||
{
|
{
|
||||||
g_Settings->RegisterChangeCB(m_InitialDir, this, (CSettings::SettingChangedFunc)DirectoryChanged);
|
g_Settings->RegisterChangeCB(m_InitialDir, this, (CSettings::SettingChangedFunc)DirectoryChanged);
|
||||||
g_Settings->RegisterChangeCB(m_SelectedDir, this, (CSettings::SettingChangedFunc)DirectoryChanged);
|
g_Settings->RegisterChangeCB(m_SelectedDir, this, (CSettings::SettingChangedFunc)DirectoryChanged);
|
||||||
|
|
Loading…
Reference in New Issue