[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)
{
if (g_PluginSettings2.FindSystemSettingId && g_PluginSettings.handle)

View File

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