From ec23b073029faaa6039c3c0d27859a5b0c957d4d Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 22 Mar 2016 07:55:44 +1100 Subject: [PATCH] [Project64] Fix up plugin registering settings with default setting --- .../SettingType/SettingsType-RomDatabase.cpp | 2 +- .../Project64-core/Settings/SettingsClass.cpp | 35 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp index 293933c2a..db05ea152 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp @@ -46,7 +46,7 @@ CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, const char * } CSettingTypeRomDatabase::CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting, bool DeleteOnDefault ) : - m_KeyName(Name), + m_KeyName(StripNameSection(Name)), m_DefaultStr(""), m_DefaultValue(0), m_DefaultSetting(DefaultSetting), diff --git a/Source/Project64-core/Settings/SettingsClass.cpp b/Source/Project64-core/Settings/SettingsClass.cpp index 71914caae..af5cb4891 100644 --- a/Source/Project64-core/Settings/SettingsClass.cpp +++ b/Source/Project64-core/Settings/SettingsClass.cpp @@ -524,26 +524,35 @@ void CSettings::RegisterSetting(CSettings * _this, SettingID ID, SettingID Defau switch (DataType) { case Data_DWORD: - if (DefaultID == Default_None) { SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId; _this->m_NextAutoSettingId += 1; - _this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), (int)Value)); - _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting)); - } - else - { - _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID)); + if (DefaultID == Default_None) + { + _this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), (int)Value)); + _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting)); + } + else + { + _this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), DefaultID)); + _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting)); + } } break; case Data_String: - if (DefaultID == Default_None) { - _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), "")); - } - else - { - _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID)); + SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId; + _this->m_NextAutoSettingId += 1; + if (DefaultID == Default_None) + { + _this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), "")); + _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting)); + } + else + { + _this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), DefaultID)); + _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting)); + } } break; default: