[Settings] Add RegisterSetting2

This commit is contained in:
zilmar 2016-03-03 21:07:16 +11:00
parent 2c648bd750
commit 0a4e436c07
2 changed files with 80 additions and 31 deletions

View File

@ -170,6 +170,54 @@ void RegisterSetting(short SettingID, SETTING_DATA_TYPE Type, const char * Name,
} }
} }
void RegisterSetting2(short SettingID, SETTING_DATA_TYPE Type, const char * Name, const char * Category, short DefaultID)
{
SettingLocation Location = (SettingLocation)g_PluginSettings.DefaultLocation;
char FullCategory[400];
if (Category && Category[0] != 0)
{
_snprintf(FullCategory, sizeof(FullCategory), "%s\\%s", g_PluginSettingName, Category);
}
else
{
_snprintf(FullCategory, sizeof(FullCategory), "%s", g_PluginSettingName);
}
switch (Type)
{
case Data_DWORD_Game:
case Data_String_Game:
Location = SettingType_GameSetting;
break;
case Data_DWORD_RDB:
case Data_String_RDB:
Location = SettingType_RomDatabase;
break;
case Data_DWORD_RDB_Setting:
case Data_String_RDB_Setting:
Location = SettingType_RdbSetting;
break;
}
switch (Type)
{
case Data_DWORD_Game:
case Data_DWORD_General:
case Data_DWORD_RDB:
case Data_DWORD_RDB_Setting:
g_PluginSettings.RegisterSetting(g_PluginSettings.handle, SettingID + g_PluginSettings.SettingStartRange,
DefaultID + g_PluginSettings.SettingStartRange, Data_DWORD, Location, FullCategory, Name, 0);
break;
case Data_String_General:
case Data_String_Game:
case Data_String_RDB:
case Data_String_RDB_Setting:
g_PluginSettings.RegisterSetting(g_PluginSettings.handle, SettingID + g_PluginSettings.SettingStartRange,
DefaultID + g_PluginSettings.SettingStartRange, Data_String, Location, FullCategory, Name, 0);
break;
}
}
short FindSystemSettingId(const char * Name) short FindSystemSettingId(const char * Name)
{ {
if (g_PluginSettings2.FindSystemSettingId && g_PluginSettings.handle) if (g_PluginSettings2.FindSystemSettingId && g_PluginSettings.handle)
@ -223,4 +271,4 @@ void SetSetting(short SettingID, unsigned int Value)
void SetSettingSz(short SettingID, const char * Value) void SetSettingSz(short SettingID, const char * Value)
{ {
g_PluginSettings.SetSettingSz(g_PluginSettings.handle, SettingID + g_PluginSettings.SettingStartRange, Value); g_PluginSettings.SetSettingSz(g_PluginSettings.handle, SettingID + g_PluginSettings.SettingStartRange, Value);
} }

View File

@ -4,41 +4,42 @@
extern "C" { extern "C" {
#endif #endif
// Get Plugin Settings, take a setting id // Get Plugin Settings, take a setting id
unsigned int GetSetting ( short SettingID ); unsigned int GetSetting(short SettingID);
const char * GetSettingSz ( short SettingID, char * Buffer, int BufferLen ); const char * GetSettingSz(short SettingID, char * Buffer, int BufferLen);
// Get System Settings, take a setting returned by FindSystemSettingId // Get System Settings, take a setting returned by FindSystemSettingId
unsigned int GetSystemSetting ( short SettingID ); unsigned int GetSystemSetting(short SettingID);
const char * GetSystemSettingSz( short SettingID, char * Buffer, int BufferLen ); const char * GetSystemSettingSz(short SettingID, char * Buffer, int BufferLen);
// Set a settings value // Set a settings value
void SetSetting ( short SettingID, unsigned int Value ); void SetSetting(short SettingID, unsigned int Value);
void SetSettingSz ( short SettingID, const char * Value ); void SetSettingSz(short SettingID, const char * Value);
// enum's // enum's
enum SETTING_DATA_TYPE enum SETTING_DATA_TYPE
{ {
Data_DWORD_General = 0, // A unsigned int setting used anywhere Data_DWORD_General = 0, // A unsigned int setting used anywhere
Data_String_General = 1, // A string setting used anywhere Data_String_General = 1, // A string setting used anywhere
Data_DWORD_Game = 2, // A unsigned int associated with the current game Data_DWORD_Game = 2, // A unsigned int associated with the current game
Data_String_Game = 3, // A string associated with the current game Data_String_Game = 3, // A string associated with the current game
Data_DWORD_RDB = 4, // A unsigned int associated with the current game in the rom database Data_DWORD_RDB = 4, // A unsigned int associated with the current game in the rom database
Data_String_RDB = 5, // A string associated with the current game in the rom database Data_String_RDB = 5, // A string associated with the current game in the rom database
Data_DWORD_RDB_Setting = 6, // A unsigned int read from the rom database, with config file Data_DWORD_RDB_Setting = 6, // A unsigned int read from the rom database, with config file
Data_String_RDB_Setting = 7, // A string read from the rom database, with config file Data_String_RDB_Setting = 7, // A string read from the rom database, with config file
}; };
// set other information about different settings // set other information about different settings
int SettingsInitilized ( void ); int SettingsInitilized(void);
void SetModuleName ( const char * Name ); void SetModuleName(const char * Name);
void RegisterSetting ( short SettingID, SETTING_DATA_TYPE Type, const char * Name, const char * Category, void RegisterSetting(short SettingID, SETTING_DATA_TYPE Type, const char * Name, const char * Category,
unsigned int DefaultDW, const char * DefaultStr ); unsigned int DefaultDW, const char * DefaultStr);
short FindSystemSettingId ( const char * Name ); void RegisterSetting2(short SettingID, SETTING_DATA_TYPE Type, const char * Name, const char * Category, short DefaultSettingID);
void FlushSettings ( void ); short FindSystemSettingId(const char * Name);
void FlushSettings(void);
// this must be implemented to be notified when a setting is used but has not been set up // this must be implemented to be notified when a setting is used but has not been set up
void UseUnregisteredSetting (int SettingID); void UseUnregisteredSetting(int SettingID);
#if defined(__cplusplus) #if defined(__cplusplus)
} }