[Project64] Clean up some code related to Settings Type files
This commit is contained in:
parent
821922f133
commit
0f57b5d42e
|
@ -60,6 +60,13 @@ CSettingTypeApplication::~CSettingTypeApplication()
|
|||
|
||||
void CSettingTypeApplication::Initialize( const char * /*AppName*/ )
|
||||
{
|
||||
CPath BaseDir(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(),"");
|
||||
if (!BaseDir.DirectoryExists())
|
||||
{
|
||||
printf("BaseDir does not exists, doing nothing");
|
||||
return;
|
||||
}
|
||||
|
||||
stdstr SettingsFile, OrigSettingsFile;
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
|
@ -77,7 +84,11 @@ void CSettingTypeApplication::Initialize( const char * /*AppName*/ )
|
|||
{
|
||||
delete m_SettingsIniFile;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(),"");
|
||||
#else
|
||||
CPath SettingsDir(CPath(SettingsFile).GetDirectory(), "");
|
||||
#endif
|
||||
if (!SettingsDir.DirectoryExists())
|
||||
{
|
||||
SettingsDir.DirectoryCreate();
|
||||
|
@ -123,7 +134,9 @@ bool CSettingTypeApplication::Load ( int /*Index*/, bool & Value ) const
|
|||
if (m_DefaultSetting == Default_Constant)
|
||||
{
|
||||
Value = m_DefaultValue != 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Settings->LoadBool(m_DefaultSetting,Value);
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +151,9 @@ bool CSettingTypeApplication::Load ( int /*Index*/, uint32_t & Value ) const
|
|||
if (m_DefaultSetting == Default_Constant)
|
||||
{
|
||||
Value = m_DefaultValue;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Settings->LoadDword(m_DefaultSetting,Value);
|
||||
}
|
||||
}
|
||||
|
@ -168,20 +183,24 @@ void CSettingTypeApplication::LoadDefault ( int /*Index*/, bool & Value ) cons
|
|||
if (m_DefaultSetting == Default_Constant)
|
||||
{
|
||||
Value = m_DefaultValue != 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Settings->LoadBool(m_DefaultSetting,Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingTypeApplication::LoadDefault ( int /*Index*/, uint32_t & Value ) const
|
||||
void CSettingTypeApplication::LoadDefault(int /*Index*/, uint32_t & Value) const
|
||||
{
|
||||
if (m_DefaultSetting != Default_None)
|
||||
{
|
||||
if (m_DefaultSetting == Default_Constant)
|
||||
{
|
||||
Value = m_DefaultValue;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Settings->LoadDword(m_DefaultSetting,Value);
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +213,9 @@ void CSettingTypeApplication::LoadDefault ( int /*Index*/, stdstr & Value ) cons
|
|||
if (m_DefaultSetting == Default_Constant)
|
||||
{
|
||||
Value = m_DefaultStr;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Settings->LoadStringVal(m_DefaultSetting,Value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Common/IniFileClass.h>
|
||||
#include "SettingsType-Base.h"
|
||||
#include <Project64-core/Settings/SettingType/SettingsType-Base.h>
|
||||
|
||||
class CSettingTypeApplication :
|
||||
public CSettingType
|
||||
|
|
|
@ -26,6 +26,7 @@ CSettingTypeApplicationPath::~CSettingTypeApplicationPath()
|
|||
bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const
|
||||
{
|
||||
bool bRes = CSettingTypeApplication::Load(Index,Value);
|
||||
#ifdef WIN32
|
||||
if (bRes)
|
||||
{
|
||||
if (Value.substr(0,2) == ".\\" || Value.substr(0,2) == "./" ||
|
||||
|
@ -38,5 +39,6 @@ bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const
|
|||
Value = (const std::string &)FullFilePath;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return bRes;
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "../Settings.h"
|
||||
#include <Project64-core/Settings/Settings.h>
|
||||
#include <Common/StdString.h>
|
||||
|
||||
enum SettingType {
|
||||
enum SettingType
|
||||
{
|
||||
SettingType_Unknown = -1,
|
||||
SettingType_ConstString = 0,
|
||||
SettingType_ConstValue = 1,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "SettingsType-Base.h"
|
||||
#include <Project64-core/Settings/SettingType/SettingsType-Base.h>
|
||||
#include <Common/IniFileClass.h>
|
||||
|
||||
class CSettingTypeCheats :
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "stdafx.h"
|
||||
#include "SettingsType-RomDatabase.h"
|
||||
#include "SettingsType-RDBCpuType.h"
|
||||
#include "../../N64System/N64Types.h"
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
|
||||
CSettingTypeRDBCpuType::CSettingTypeRDBCpuType(const char * Name, SettingID DefaultSetting ) :
|
||||
CSettingTypeRomDatabase(Name,DefaultSetting)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "stdafx.h"
|
||||
#include "SettingsType-RomDatabase.h"
|
||||
#include "SettingsType-RDBSaveChip.h"
|
||||
#include "../../N64System/N64Types.h"
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
|
||||
CSettingTypeRDBSaveChip::CSettingTypeRDBSaveChip(const char * Name, SettingID DefaultSetting ) :
|
||||
CSettingTypeRomDatabase(Name,DefaultSetting)
|
||||
|
|
|
@ -11,59 +11,79 @@
|
|||
#include "stdafx.h"
|
||||
#include "SettingsType-RelativePath.h"
|
||||
|
||||
CSettingTypeRelativePath::CSettingTypeRelativePath(const char * Path, const char * FileName)
|
||||
CSettingTypeRelativePath::CSettingTypeRelativePath(const char * Directory, const char * FileName) :
|
||||
m_Directory(Directory),
|
||||
m_FileName(FileName)
|
||||
{
|
||||
m_FileName = CPath(CPath::MODULE_DIRECTORY,FileName);
|
||||
m_FileName.AppendDirectory(Path);
|
||||
BuildPath();
|
||||
g_Settings->RegisterChangeCB(Cmd_BaseDirectory, this, RefreshSettings);
|
||||
}
|
||||
|
||||
CSettingTypeRelativePath::~CSettingTypeRelativePath ( void )
|
||||
CSettingTypeRelativePath::~CSettingTypeRelativePath(void)
|
||||
{
|
||||
g_Settings->UnregisterChangeCB(Cmd_BaseDirectory, this, RefreshSettings);
|
||||
}
|
||||
|
||||
bool CSettingTypeRelativePath::Load ( int /*Index*/, stdstr & value ) const
|
||||
bool CSettingTypeRelativePath::Load(int /*Index*/, stdstr & value) const
|
||||
{
|
||||
value = (const char *)m_FileName;
|
||||
value = m_FullPath;
|
||||
return true;
|
||||
}
|
||||
|
||||
//return the default values
|
||||
void CSettingTypeRelativePath::LoadDefault ( int /*Index*/, bool & /*Value*/ ) const
|
||||
void CSettingTypeRelativePath::LoadDefault(int /*Index*/, bool & /*Value*/) const
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeRelativePath::LoadDefault ( int /*Index*/, uint32_t & /*Value*/ ) const
|
||||
void CSettingTypeRelativePath::LoadDefault(int /*Index*/, uint32_t & /*Value*/) const
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeRelativePath::LoadDefault ( int /*Index*/, stdstr & /*Value*/ ) const
|
||||
void CSettingTypeRelativePath::LoadDefault(int /*Index*/, stdstr & /*Value*/) const
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeRelativePath::Save ( int /*Index*/, bool /*Value*/ )
|
||||
void CSettingTypeRelativePath::Save(int /*Index*/, bool /*Value*/)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeRelativePath::Save ( int /*Index*/, uint32_t /*Value*/ )
|
||||
void CSettingTypeRelativePath::Save(int /*Index*/, uint32_t /*Value*/)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeRelativePath::Save ( int /*Index*/, const stdstr & Value )
|
||||
void CSettingTypeRelativePath::Save(int /*Index*/, const stdstr & Value)
|
||||
{
|
||||
m_FileName = CPath(CPath::MODULE_DIRECTORY,Value.c_str());
|
||||
m_Directory = "";
|
||||
m_FileName = Value;
|
||||
BuildPath();
|
||||
}
|
||||
|
||||
void CSettingTypeRelativePath::Save ( int /*Index*/, const char * Value )
|
||||
void CSettingTypeRelativePath::Save(int /*Index*/, const char * Value)
|
||||
{
|
||||
m_FileName = CPath(CPath::MODULE_DIRECTORY,Value);
|
||||
m_Directory = "";
|
||||
m_FileName = Value;
|
||||
BuildPath();
|
||||
}
|
||||
|
||||
void CSettingTypeRelativePath::Delete ( int /*Index*/ )
|
||||
void CSettingTypeRelativePath::Delete(int /*Index*/)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeRelativePath::BuildPath(void)
|
||||
{
|
||||
CPath FullPath(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(),"");
|
||||
FullPath.AppendDirectory(m_Directory.c_str());
|
||||
FullPath.SetNameExtension(m_FileName.c_str());
|
||||
m_FullPath = (const char *)FullPath;
|
||||
}
|
||||
|
||||
void CSettingTypeRelativePath::RefreshSettings(void * _this)
|
||||
{
|
||||
((CSettingTypeRelativePath *)_this)->BuildPath();
|
||||
}
|
||||
|
|
|
@ -10,15 +10,13 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
#include <Common/path.h>
|
||||
#include "SettingsType-Base.h"
|
||||
#include <Project64-core/Settings/SettingType/SettingsType-Base.h>
|
||||
|
||||
class CSettingTypeRelativePath :
|
||||
public CSettingType
|
||||
{
|
||||
CPath m_FileName;
|
||||
|
||||
public:
|
||||
CSettingTypeRelativePath(const char * Path, const char * FileName);
|
||||
CSettingTypeRelativePath(const char * Directory, const char * FileName);
|
||||
~CSettingTypeRelativePath();
|
||||
|
||||
bool IndexBasedSetting ( void ) const { return false; }
|
||||
|
@ -47,4 +45,11 @@ private:
|
|||
CSettingTypeRelativePath(void); // Disable default constructor
|
||||
CSettingTypeRelativePath(const CSettingTypeRelativePath&); // Disable copy constructor
|
||||
CSettingTypeRelativePath& operator=(const CSettingTypeRelativePath&); // Disable assignment
|
||||
|
||||
static void RefreshSettings(void * _this);
|
||||
void BuildPath ( void );
|
||||
|
||||
std::string m_FullPath;
|
||||
std::string m_Directory;
|
||||
std::string m_FileName;
|
||||
};
|
||||
|
|
|
@ -65,12 +65,14 @@ void CSettingTypeRomDatabase::Initialize( void )
|
|||
m_GlideIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Glide64RDB).c_str());
|
||||
|
||||
g_Settings->RegisterChangeCB(Game_IniKey,NULL,GameChanged);
|
||||
g_Settings->RegisterChangeCB(Cmd_BaseDirectory,NULL,BaseDirChanged);
|
||||
|
||||
m_SectionIdent = new stdstr(g_Settings->LoadStringVal(Game_IniKey));
|
||||
}
|
||||
|
||||
void CSettingTypeRomDatabase::CleanUp( void )
|
||||
{
|
||||
g_Settings->UnregisterChangeCB(Cmd_BaseDirectory,NULL,BaseDirChanged);
|
||||
g_Settings->UnregisterChangeCB(Game_IniKey,NULL,GameChanged);
|
||||
if (m_SettingsIniFile)
|
||||
{
|
||||
|
@ -89,6 +91,22 @@ void CSettingTypeRomDatabase::CleanUp( void )
|
|||
}
|
||||
}
|
||||
|
||||
void CSettingTypeRomDatabase::BaseDirChanged ( void * /*Data */ )
|
||||
{
|
||||
if (m_SettingsIniFile)
|
||||
{
|
||||
delete m_SettingsIniFile;
|
||||
m_SettingsIniFile = NULL;
|
||||
}
|
||||
if (m_GlideIniFile)
|
||||
{
|
||||
delete m_GlideIniFile;
|
||||
m_GlideIniFile = NULL;
|
||||
}
|
||||
m_SettingsIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
|
||||
m_GlideIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Glide64RDB).c_str());
|
||||
}
|
||||
|
||||
void CSettingTypeRomDatabase::GameChanged ( void * /*Data */ )
|
||||
{
|
||||
if (m_SectionIdent)
|
||||
|
@ -195,7 +213,7 @@ void CSettingTypeRomDatabase::Save ( int /*Index*/, bool Value )
|
|||
}
|
||||
if (m_DeleteOnDefault)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
if (m_GlideSetting)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Common/IniFileClass.h>
|
||||
#include "SettingsType-Base.h"
|
||||
#include <Project64-core/Settings/SettingType/SettingsType-Base.h>
|
||||
|
||||
class CSettingTypeRomDatabase :
|
||||
public CSettingType
|
||||
|
@ -51,6 +51,7 @@ public:
|
|||
|
||||
protected:
|
||||
static void GameChanged ( void * /*Data */ );
|
||||
static void BaseDirChanged ( void * /*Data */ );
|
||||
|
||||
static bool IsGlideSetting (const char * Name);
|
||||
static const char * StripNameSection (const char * Name);
|
||||
|
|
|
@ -25,13 +25,13 @@ CSettingTypeSelectedDirectory::~CSettingTypeSelectedDirectory()
|
|||
|
||||
bool CSettingTypeSelectedDirectory::Load ( int /*Index*/, bool & /*Value*/ ) const
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSettingTypeSelectedDirectory::Load ( int /*Index*/, uint32_t & /*Value*/ ) const
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -44,33 +44,33 @@ bool CSettingTypeSelectedDirectory::Load ( int /*Index*/, stdstr & Value ) const
|
|||
//return the default values
|
||||
void CSettingTypeSelectedDirectory::LoadDefault ( int /*Index*/, bool & /*Value*/ ) const
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeSelectedDirectory::LoadDefault ( int /*Index*/, uint32_t & /*Value*/ ) const
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeSelectedDirectory::LoadDefault ( int /*Index*/, stdstr & /*Value*/ ) const
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
|
||||
//Update the settings
|
||||
void CSettingTypeSelectedDirectory::Save ( int /*Index*/, bool /*Value*/ )
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeSelectedDirectory::Save ( int /*Index*/, uint32_t /*Value*/ )
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeSelectedDirectory::Save ( int /*Index*/, const stdstr & /*Value*/ )
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
|
||||
void CSettingTypeSelectedDirectory::Save ( int /*Index*/, const char * Value )
|
||||
|
@ -81,5 +81,5 @@ void CSettingTypeSelectedDirectory::Save ( int /*Index*/, const char * Value )
|
|||
|
||||
void CSettingTypeSelectedDirectory::Delete( int /*Index*/ )
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "SettingsType-Base.h"
|
||||
#include <Project64-core/Settings/SettingType/SettingsType-Base.h>
|
||||
|
||||
class CSettingTypeSelectedDirectory :
|
||||
public CSettingType
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "SettingsType-Base.h"
|
||||
#include <Project64-core/Settings/SettingType/SettingsType-Base.h>
|
||||
|
||||
class CSettingTypeTempBool :
|
||||
public CSettingType
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "SettingsType-Base.h"
|
||||
#include <Project64-core/Settings/SettingType/SettingsType-Base.h>
|
||||
|
||||
class CSettingTypeTempNumber :
|
||||
public CSettingType
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "SettingsType-Base.h"
|
||||
#include <Project64-core/Settings/SettingType/SettingsType-Base.h>
|
||||
|
||||
class CSettingTypeTempString :
|
||||
public CSettingType
|
||||
|
|
Loading…
Reference in New Issue