[Project64] Change handling of Glide64.rdb to Project64Video.rdb

This commit is contained in:
zilmar 2017-08-23 17:58:13 +10:00
parent e0f2af6338
commit 5f725bd928
6 changed files with 97 additions and 94 deletions

View File

@ -24,7 +24,7 @@ Filename: "{app}\Project64.exe"; Description: "{cm:LaunchProgram,{#StringChange(
[Files]
Source: "{#BaseDir}\Bin\{#Configuration}\Project64.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#BaseDir}\Config\Glide64.rdb"; DestDir: "{app}\Config"
Source: "{#BaseDir}\Config\Project64Video.rdb"; DestDir: "{app}\Config"
Source: "{#BaseDir}\Config\Project64.cht"; DestDir: "{app}\Config"
Source: "{#BaseDir}\Config\Project64.rdb"; DestDir: "{app}\Config"
Source: "{#BaseDir}\Config\Project64.rdx"; DestDir: "{app}\Config"

View File

@ -12,10 +12,10 @@
#include "SettingsType-RomDatabase.h"
CIniFile * CSettingTypeRomDatabase::m_SettingsIniFile = NULL;
CIniFile * CSettingTypeRomDatabase::m_GlideIniFile = NULL;
stdstr * CSettingTypeRomDatabase::m_SectionIdent = NULL;
CIniFile * CSettingTypeRomDatabase::m_Project64IniFile = NULL;
stdstr * CSettingTypeRomDatabase::m_SectionIdent = NULL;
CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, int DefaultValue, bool DeleteOnDefault ) :
CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, int DefaultValue, bool DeleteOnDefault) :
m_KeyName(StripNameSection(Name)),
m_DefaultStr(""),
m_DefaultValue(DefaultValue),
@ -25,7 +25,7 @@ CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, int DefaultV
{
}
CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, bool DefaultValue, bool DeleteOnDefault ) :
CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, bool DefaultValue, bool DeleteOnDefault) :
m_KeyName(StripNameSection(Name)),
m_DefaultStr(""),
m_DefaultValue(DefaultValue),
@ -35,7 +35,7 @@ CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, bool Default
{
}
CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, const char * DefaultValue, bool DeleteOnDefault ) :
CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, const char * DefaultValue, bool DeleteOnDefault) :
m_KeyName(StripNameSection(Name)),
m_DefaultStr(DefaultValue),
m_DefaultValue(0),
@ -45,7 +45,7 @@ CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, const char *
{
}
CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting, bool DeleteOnDefault ) :
CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting, bool DeleteOnDefault) :
m_KeyName(StripNameSection(Name)),
m_DefaultStr(""),
m_DefaultValue(0),
@ -59,33 +59,33 @@ CSettingTypeRomDatabase::~CSettingTypeRomDatabase()
{
}
void CSettingTypeRomDatabase::Initialize( void )
void CSettingTypeRomDatabase::Initialize(void)
{
WriteTrace(TraceAppInit, TraceDebug, "Start");
m_SettingsIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
m_GlideIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Glide64RDB).c_str());
m_Project64IniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Project64VideoRDB).c_str());
g_Settings->RegisterChangeCB(Game_IniKey,NULL,GameChanged);
g_Settings->RegisterChangeCB(Cmd_BaseDirectory,NULL,BaseDirChanged);
g_Settings->RegisterChangeCB(Game_IniKey, NULL, GameChanged);
g_Settings->RegisterChangeCB(Cmd_BaseDirectory, NULL, BaseDirChanged);
m_SectionIdent = new stdstr(g_Settings->LoadStringVal(Game_IniKey));
WriteTrace(TraceAppInit, TraceDebug, "Done");
}
void CSettingTypeRomDatabase::CleanUp( void )
void CSettingTypeRomDatabase::CleanUp(void)
{
g_Settings->UnregisterChangeCB(Cmd_BaseDirectory,NULL,BaseDirChanged);
g_Settings->UnregisterChangeCB(Game_IniKey,NULL,GameChanged);
g_Settings->UnregisterChangeCB(Cmd_BaseDirectory, NULL, BaseDirChanged);
g_Settings->UnregisterChangeCB(Game_IniKey, NULL, GameChanged);
if (m_SettingsIniFile)
{
delete m_SettingsIniFile;
m_SettingsIniFile = NULL;
}
if (m_GlideIniFile)
if (m_Project64IniFile)
{
delete m_GlideIniFile;
m_GlideIniFile = NULL;
delete m_Project64IniFile;
m_Project64IniFile = NULL;
}
if (m_SectionIdent)
{
@ -94,23 +94,23 @@ void CSettingTypeRomDatabase::CleanUp( void )
}
}
void CSettingTypeRomDatabase::BaseDirChanged ( void * /*Data */ )
void CSettingTypeRomDatabase::BaseDirChanged(void * /*Data */)
{
if (m_SettingsIniFile)
{
delete m_SettingsIniFile;
m_SettingsIniFile = NULL;
}
if (m_GlideIniFile)
if (m_Project64IniFile)
{
delete m_GlideIniFile;
m_GlideIniFile = NULL;
delete m_Project64IniFile;
m_Project64IniFile = NULL;
}
m_SettingsIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
m_GlideIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Glide64RDB).c_str());
m_Project64IniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Project64VideoRDB).c_str());
}
void CSettingTypeRomDatabase::GameChanged ( void * /*Data */ )
void CSettingTypeRomDatabase::GameChanged(void * /*Data */)
{
if (m_SectionIdent)
{
@ -118,43 +118,43 @@ void CSettingTypeRomDatabase::GameChanged ( void * /*Data */ )
}
}
bool CSettingTypeRomDatabase::Load ( int Index, bool & Value ) const
bool CSettingTypeRomDatabase::Load(int Index, bool & Value) const
{
uint32_t temp_value = Value;
bool bRes = Load(Index,temp_value);
bool bRes = Load(Index, temp_value);
Value = temp_value != 0;
return bRes;
}
bool CSettingTypeRomDatabase::Load ( int Index, uint32_t & Value ) const
bool CSettingTypeRomDatabase::Load(int Index, uint32_t & Value) const
{
bool bRes = false;
if (m_GlideSetting)
{
bRes = m_GlideIniFile->GetNumber(Section(),m_KeyName.c_str(),Value,Value);
bRes = m_Project64IniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value);
}
else
{
bRes = m_SettingsIniFile->GetNumber(Section(),m_KeyName.c_str(),Value,Value);
bRes = m_SettingsIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value);
}
if (!bRes)
{
LoadDefault(Index,Value);
LoadDefault(Index, Value);
}
return bRes;
}
bool CSettingTypeRomDatabase::Load ( int Index, stdstr & Value ) const
bool CSettingTypeRomDatabase::Load(int Index, stdstr & Value) const
{
stdstr temp_value;
bool bRes = false;
if (m_GlideSetting)
{
bRes = m_GlideIniFile->GetString(Section(),m_KeyName.c_str(),m_DefaultStr,temp_value);
bRes = m_Project64IniFile->GetString(Section(), m_KeyName.c_str(), m_DefaultStr, temp_value);
}
else
{
bRes = m_SettingsIniFile->GetString(Section(),m_KeyName.c_str(),m_DefaultStr,temp_value);
bRes = m_SettingsIniFile->GetString(Section(), m_KeyName.c_str(), m_DefaultStr, temp_value);
}
if (bRes)
{
@ -162,53 +162,56 @@ bool CSettingTypeRomDatabase::Load ( int Index, stdstr & Value ) const
}
else
{
LoadDefault(Index,Value);
LoadDefault(Index, Value);
}
return bRes;
}
//return the default values
void CSettingTypeRomDatabase::LoadDefault ( int /*Index*/, bool & Value ) const
void CSettingTypeRomDatabase::LoadDefault(int /*Index*/, bool & Value) const
{
if (m_DefaultSetting != Default_None)
{
if (m_DefaultSetting == Default_Constant)
{
Value = m_DefaultValue != 0;
} else {
g_Settings->LoadBool(m_DefaultSetting,Value);
}
else {
g_Settings->LoadBool(m_DefaultSetting, Value);
}
}
}
void CSettingTypeRomDatabase::LoadDefault ( int /*Index*/, uint32_t & Value ) const
void CSettingTypeRomDatabase::LoadDefault(int /*Index*/, uint32_t & Value) const
{
if (m_DefaultSetting != Default_None)
{
if (m_DefaultSetting == Default_Constant)
{
Value = m_DefaultValue;
} else {
g_Settings->LoadDword(m_DefaultSetting,Value);
}
else {
g_Settings->LoadDword(m_DefaultSetting, Value);
}
}
}
void CSettingTypeRomDatabase::LoadDefault ( int /*Index*/, stdstr & Value ) const
void CSettingTypeRomDatabase::LoadDefault(int /*Index*/, stdstr & Value) const
{
if (m_DefaultSetting != Default_None)
{
if (m_DefaultSetting == Default_Constant)
{
Value = m_DefaultStr;
} else {
g_Settings->LoadStringVal(m_DefaultSetting,Value);
}
else {
g_Settings->LoadStringVal(m_DefaultSetting, Value);
}
}
}
//Update the settings
void CSettingTypeRomDatabase::Save ( int /*Index*/, bool Value )
void CSettingTypeRomDatabase::Save(int /*Index*/, bool Value)
{
if (!g_Settings->LoadBool(Setting_RdbEditor))
{
@ -216,19 +219,19 @@ void CSettingTypeRomDatabase::Save ( int /*Index*/, bool Value )
}
if (m_DeleteOnDefault)
{
g_Notify->BreakPoint(__FILE__,__LINE__);
g_Notify->BreakPoint(__FILE__, __LINE__);
}
if (m_GlideSetting)
{
m_GlideIniFile->SaveNumber(Section(),m_KeyName.c_str(),Value);
m_Project64IniFile->SaveNumber(Section(), m_KeyName.c_str(), Value);
}
else
{
m_SettingsIniFile->SaveNumber(Section(),m_KeyName.c_str(),Value);
m_SettingsIniFile->SaveNumber(Section(), m_KeyName.c_str(), Value);
}
}
void CSettingTypeRomDatabase::Save ( int Index, uint32_t Value )
void CSettingTypeRomDatabase::Save(int Index, uint32_t Value)
{
if (!g_Settings->LoadBool(Setting_RdbEditor))
{
@ -237,7 +240,7 @@ void CSettingTypeRomDatabase::Save ( int Index, uint32_t Value )
if (m_DeleteOnDefault)
{
uint32_t defaultValue = 0;
LoadDefault(Index,defaultValue);
LoadDefault(Index, defaultValue);
if (defaultValue == Value)
{
Delete(Index);
@ -246,15 +249,15 @@ void CSettingTypeRomDatabase::Save ( int Index, uint32_t Value )
}
if (m_GlideSetting)
{
m_GlideIniFile->SaveNumber(Section(),m_KeyName.c_str(),Value);
m_Project64IniFile->SaveNumber(Section(), m_KeyName.c_str(), Value);
}
else
{
m_SettingsIniFile->SaveNumber(Section(),m_KeyName.c_str(),Value);
m_SettingsIniFile->SaveNumber(Section(), m_KeyName.c_str(), Value);
}
}
void CSettingTypeRomDatabase::Save ( int /*Index*/, const stdstr & Value )
void CSettingTypeRomDatabase::Save(int /*Index*/, const stdstr & Value)
{
if (!g_Settings->LoadBool(Setting_RdbEditor))
{
@ -262,15 +265,15 @@ void CSettingTypeRomDatabase::Save ( int /*Index*/, const stdstr & Value )
}
if (m_GlideSetting)
{
m_GlideIniFile->SaveString(Section(),m_KeyName.c_str(),Value.c_str());
m_Project64IniFile->SaveString(Section(), m_KeyName.c_str(), Value.c_str());
}
else
{
m_SettingsIniFile->SaveString(Section(),m_KeyName.c_str(),Value.c_str());
m_SettingsIniFile->SaveString(Section(), m_KeyName.c_str(), Value.c_str());
}
}
void CSettingTypeRomDatabase::Save ( int /*Index*/, const char * Value )
void CSettingTypeRomDatabase::Save(int /*Index*/, const char * Value)
{
if (!g_Settings->LoadBool(Setting_RdbEditor))
{
@ -278,15 +281,15 @@ void CSettingTypeRomDatabase::Save ( int /*Index*/, const char * Value )
}
if (m_GlideSetting)
{
m_GlideIniFile->SaveString(Section(),m_KeyName.c_str(),Value);
m_Project64IniFile->SaveString(Section(), m_KeyName.c_str(), Value);
}
else
{
m_SettingsIniFile->SaveString(Section(),m_KeyName.c_str(),Value);
m_SettingsIniFile->SaveString(Section(), m_KeyName.c_str(), Value);
}
}
void CSettingTypeRomDatabase::Delete ( int /*Index*/ )
void CSettingTypeRomDatabase::Delete(int /*Index*/)
{
if (!g_Settings->LoadBool(Setting_RdbEditor))
{
@ -294,28 +297,28 @@ void CSettingTypeRomDatabase::Delete ( int /*Index*/ )
}
if (m_GlideSetting)
{
m_GlideIniFile->SaveString(Section(),m_KeyName.c_str(),NULL);
m_Project64IniFile->SaveString(Section(), m_KeyName.c_str(), NULL);
}
else
{
m_SettingsIniFile->SaveString(Section(),m_KeyName.c_str(),NULL);
m_SettingsIniFile->SaveString(Section(), m_KeyName.c_str(), NULL);
}
}
bool CSettingTypeRomDatabase::IsGlideSetting (const char * Name)
bool CSettingTypeRomDatabase::IsGlideSetting(const char * Name)
{
if (_strnicmp(Name,"Glide64-",8) == 0)
if (_strnicmp(Name, "Glide64-", 8) == 0)
{
return true;
}
return false;
}
const char * CSettingTypeRomDatabase::StripNameSection (const char * Name)
const char * CSettingTypeRomDatabase::StripNameSection(const char * Name)
{
if (_strnicmp(Name,"Glide64-",8) == 0)
if (_strnicmp(Name, "Glide64-", 8) == 0)
{
return &Name[8];
}
return Name;
}
}

View File

@ -17,46 +17,46 @@ class CSettingTypeRomDatabase :
public CSettingType
{
public:
CSettingTypeRomDatabase(const char * Name, const char * DefaultValue, bool DeleteOnDefault = false );
CSettingTypeRomDatabase(const char * Name, bool DefaultValue, bool DeleteOnDefault = false );
CSettingTypeRomDatabase(const char * Name, int32_t DefaultValue, bool DeleteOnDefault = false );
CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting, bool DeleteOnDefault = false );
CSettingTypeRomDatabase(const char * Name, const char * DefaultValue, bool DeleteOnDefault = false);
CSettingTypeRomDatabase(const char * Name, bool DefaultValue, bool DeleteOnDefault = false);
CSettingTypeRomDatabase(const char * Name, int32_t DefaultValue, bool DeleteOnDefault = false);
CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting, bool DeleteOnDefault = false);
virtual ~CSettingTypeRomDatabase();
virtual bool IndexBasedSetting ( void ) const { return false; }
virtual SettingType GetSettingType ( void ) const { return SettingType_RomDatabase; }
virtual bool IsSettingSet(void) const { return false; }
virtual bool IndexBasedSetting(void) const { return false; }
virtual SettingType GetSettingType(void) const { return SettingType_RomDatabase; }
virtual bool IsSettingSet(void) const { return false; }
//return the values
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, stdstr & 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, stdstr & Value) const;
//return the default values
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, stdstr & 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, stdstr & Value) const;
//Update the settings
virtual void Save ( int32_t Index, bool 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 char * Value );
virtual void Save(int32_t Index, bool 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 char * Value);
// Delete the setting
virtual void Delete ( int32_t Index );
virtual void Delete(int32_t Index);
static void Initialize( void );
static void CleanUp ( void );
static void Initialize(void);
static void CleanUp(void);
protected:
static void GameChanged ( void * /*Data */ );
static void BaseDirChanged ( void * /*Data */ );
static void GameChanged(void * /*Data */);
static void BaseDirChanged(void * /*Data */);
static bool IsGlideSetting (const char * Name);
static const char * StripNameSection (const char * Name);
virtual const char * Section ( void ) const { return m_SectionIdent->c_str(); }
static bool IsGlideSetting(const char * Name);
static const char * StripNameSection(const char * Name);
virtual const char * Section(void) const { return m_SectionIdent->c_str(); }
mutable stdstr m_KeyName;
const char *const m_DefaultStr;
@ -67,7 +67,7 @@ protected:
static stdstr * m_SectionIdent;
static CIniFile * m_SettingsIniFile;
static CIniFile * m_GlideIniFile;
static CIniFile * m_Project64IniFile;
private:
CSettingTypeRomDatabase(); // Disable default constructor

View File

@ -31,8 +31,8 @@ enum SettingID
SupportFile_SettingsDefault,
SupportFile_RomDatabase,
SupportFile_RomDatabaseDefault,
SupportFile_Glide64RDB,
SupportFile_Glide64RDBDefault,
SupportFile_Project64VideoRDB,
SupportFile_Project64VideoRDBDefault,
SupportFile_Cheats,
SupportFile_CheatsDefault,
SupportFile_Notes,

View File

@ -94,8 +94,8 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(SupportFile_SettingsDefault, new CSettingTypeRelativePath("Config", "Project64.cfg"));
AddHandler(SupportFile_RomDatabase, new CSettingTypeApplicationPath("", "RomDatabase", SupportFile_RomDatabaseDefault));
AddHandler(SupportFile_RomDatabaseDefault, new CSettingTypeRelativePath("Config", "Project64.rdb"));
AddHandler(SupportFile_Glide64RDB, new CSettingTypeApplicationPath("", "Glide64RDB", SupportFile_Glide64RDBDefault));
AddHandler(SupportFile_Glide64RDBDefault, new CSettingTypeRelativePath("Config", "Glide64.rdb"));
AddHandler(SupportFile_Project64VideoRDB, new CSettingTypeApplicationPath("", "Project64VideoRDB", SupportFile_Project64VideoRDBDefault));
AddHandler(SupportFile_Project64VideoRDBDefault, new CSettingTypeRelativePath("Config", "Project64Video.rdb"));
AddHandler(SupportFile_Cheats, new CSettingTypeApplicationPath("", "Cheats", SupportFile_CheatsDefault));
AddHandler(SupportFile_CheatsDefault, new CSettingTypeRelativePath("Config", "Project64.cht"));
AddHandler(SupportFile_Notes, new CSettingTypeApplicationPath("", "Notes", SupportFile_NotesDefault));