Add Application Path setting and change config files to able to change where they are located
This commit is contained in:
parent
39e6781d24
commit
804accc0b7
|
@ -270,6 +270,10 @@
|
|||
RelativePath="Settings\SettingType\SettingsType-ApplicationIndex.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Settings\SettingType\SettingsType-ApplicationPath.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Settings\SettingType\SettingsType-Cheats.cpp"
|
||||
>
|
||||
|
@ -983,6 +987,10 @@
|
|||
RelativePath="Settings\SettingType\SettingsType-ApplicationIndex.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Settings\SettingType\SettingsType-ApplicationPath.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Settings\SettingType\SettingsType-Base.h"
|
||||
>
|
||||
|
|
|
@ -15,12 +15,19 @@ enum SettingID {
|
|||
SupportFile_Settings,
|
||||
SupportFile_SettingsDefault,
|
||||
SupportFile_RomDatabase,
|
||||
SupportFile_RomDatabaseDefault,
|
||||
SupportFile_Cheats,
|
||||
SupportFile_CheatsDefault,
|
||||
SupportFile_Notes,
|
||||
SupportFile_NotesDefault,
|
||||
SupportFile_ExtInfo,
|
||||
SupportFile_ExtInfoDefault,
|
||||
SupportFile_ShortCuts,
|
||||
SupportFile_ShortCutsDefault,
|
||||
SupportFile_RomListCache,
|
||||
SupportFile_RomListCacheDefault,
|
||||
SupportFile_7zipCache,
|
||||
SupportFile_7zipCacheDefault,
|
||||
|
||||
//Settings
|
||||
Setting_ApplicationName,
|
||||
|
|
|
@ -56,7 +56,10 @@ void CSettingTypeApplication::Initilize( const char * AppName )
|
|||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
OrigSettingsFile = SettingsFile;
|
||||
SettingsFile = _Settings->LoadString(SupportFile_Settings);
|
||||
if (!_Settings->LoadString(SupportFile_Settings,SettingsFile) && i > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (SettingsFile == OrigSettingsFile)
|
||||
{
|
||||
break;
|
||||
|
@ -65,8 +68,14 @@ void CSettingTypeApplication::Initilize( const char * AppName )
|
|||
{
|
||||
delete m_SettingsIniFile;
|
||||
}
|
||||
CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(),"");
|
||||
if (!SettingsDir.DirectoryExists())
|
||||
{
|
||||
SettingsDir.CreateDirectory();
|
||||
}
|
||||
|
||||
m_SettingsIniFile = new CIniFile(SettingsFile.c_str());
|
||||
} while (SettingsFile != OrigSettingsFile);
|
||||
}
|
||||
|
||||
m_SettingsIniFile->SetAutoFlush(false);
|
||||
m_UseRegistry = _Settings->LoadBool(Setting_UseFromRegistry);
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
CSettingTypeApplication(LPCSTR Section, LPCSTR Name, bool DefaultValue );
|
||||
CSettingTypeApplication(LPCSTR Section, LPCSTR Name, DWORD DefaultValue );
|
||||
CSettingTypeApplication(LPCSTR Section, LPCSTR Name, SettingID DefaultSetting );
|
||||
~CSettingTypeApplication();
|
||||
virtual ~CSettingTypeApplication();
|
||||
|
||||
virtual bool IndexBasedSetting ( void ) const { return false; }
|
||||
virtual SettingType GetSettingType ( void ) const { return m_UseRegistry ? SettingType_Registry : SettingType_CfgFile; }
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#include "stdafx.h"
|
||||
#include "SettingsType-Application.h"
|
||||
#include "SettingsType-ApplicationPath.h"
|
||||
|
||||
CSettingTypeApplicationPath::CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, SettingID DefaultSetting ) :
|
||||
CSettingTypeApplication(Section,Name,DefaultSetting)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CSettingTypeApplicationPath::~CSettingTypeApplicationPath()
|
||||
{
|
||||
}
|
||||
|
||||
bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const
|
||||
{
|
||||
bool bRes = CSettingTypeApplication::Load(Index,Value);
|
||||
if (bRes)
|
||||
{
|
||||
if (Value.substr(0,2) == ".\\" || Value.substr(0,2) == "./" ||
|
||||
Value.substr(0,3) == "..\\" || Value.substr(0,3) == "../")
|
||||
{
|
||||
CPath FullFilePath(CPath::MODULE_DIRECTORY), RelativePath(Value);
|
||||
FullFilePath.SetNameExtension(RelativePath.GetNameExtension().c_str());
|
||||
FullFilePath.AppendDirectory(RelativePath.GetDirectory().c_str());
|
||||
|
||||
Value = FullFilePath;
|
||||
}
|
||||
}
|
||||
return bRes;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
class CSettingTypeApplicationPath :
|
||||
public CSettingTypeApplication
|
||||
{
|
||||
private:
|
||||
CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, LPCSTR DefaultValue );
|
||||
CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, bool DefaultValue );
|
||||
CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, DWORD DefaultValue );
|
||||
|
||||
public:
|
||||
virtual ~CSettingTypeApplicationPath();
|
||||
|
||||
CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, SettingID DefaultSetting );
|
||||
|
||||
//return the values
|
||||
virtual bool Load ( int Index, stdstr & Value ) const;
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "SettingType/SettingsType-Application.h"
|
||||
#include "SettingType/SettingsType-ApplicationPath.h"
|
||||
#include "SettingType/SettingsType-ApplicationIndex.h"
|
||||
#include "SettingType/SettingsType-Cheats.h"
|
||||
#include "SettingType/SettingsType-GameSetting.h"
|
||||
|
@ -66,15 +67,22 @@ void CSettings::AddHowToHandleSetting ()
|
|||
|
||||
//Support Files
|
||||
AddHandler(SupportFile_SettingsDefault, new CSettingTypeRelativePath("Config","Project64.cfg"));
|
||||
AddHandler(SupportFile_Settings, new CSettingTypeApplication("","ConfigFile",SupportFile_SettingsDefault));
|
||||
AddHandler(SupportFile_Settings, new CSettingTypeApplicationPath("","ConfigFile",SupportFile_SettingsDefault));
|
||||
AddHandler(SupportFile_SettingsDefault, new CSettingTypeRelativePath("Config","Project64.cfg"));
|
||||
AddHandler(SupportFile_RomDatabase, new CSettingTypeRelativePath("Config","Project64.rdb"));
|
||||
AddHandler(SupportFile_Cheats, new CSettingTypeRelativePath("Config","Project64.cht"));
|
||||
AddHandler(SupportFile_Notes, new CSettingTypeRelativePath("Config","Project64.rdn"));
|
||||
AddHandler(SupportFile_ExtInfo, new CSettingTypeRelativePath("Config","Project64.rdx"));
|
||||
AddHandler(SupportFile_ShortCuts, new CSettingTypeRelativePath("Config","Project64.sc3"));
|
||||
AddHandler(SupportFile_RomListCache,new CSettingTypeRelativePath("Config","Project64.cache3"));
|
||||
AddHandler(SupportFile_7zipCache, new CSettingTypeRelativePath("Config","Project64.zcache"));
|
||||
AddHandler(SupportFile_RomDatabase, new CSettingTypeApplicationPath("","RomDatabase",SupportFile_RomDatabaseDefault));
|
||||
AddHandler(SupportFile_RomDatabaseDefault, new CSettingTypeRelativePath("Config","Project64.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));
|
||||
AddHandler(SupportFile_NotesDefault, new CSettingTypeRelativePath("Config","Project64.rdn"));
|
||||
AddHandler(SupportFile_ExtInfo, new CSettingTypeApplicationPath("","ExtInfo",SupportFile_ExtInfoDefault));
|
||||
AddHandler(SupportFile_ExtInfoDefault, new CSettingTypeRelativePath("Config","Project64.rdx"));
|
||||
AddHandler(SupportFile_ShortCuts, new CSettingTypeApplicationPath("","ShortCuts",SupportFile_ShortCutsDefault));
|
||||
AddHandler(SupportFile_ShortCutsDefault, new CSettingTypeRelativePath("Config","Project64.sc3"));
|
||||
AddHandler(SupportFile_RomListCache, new CSettingTypeApplicationPath("","RomListCache",SupportFile_ShortCutsDefault));
|
||||
AddHandler(SupportFile_RomListCacheDefault,new CSettingTypeRelativePath("Config","Project64.cache3"));
|
||||
AddHandler(SupportFile_7zipCache, new CSettingTypeApplicationPath("","7zipCache",SupportFile_7zipCacheDefault));
|
||||
AddHandler(SupportFile_7zipCacheDefault, new CSettingTypeRelativePath("Config","Project64.zcache"));
|
||||
|
||||
//AddHandler(SyncPluginDir, new CSettingTypeRelativePath("SyncPlugin",""));
|
||||
|
||||
|
|
Loading…
Reference in New Issue