Implement JS support for GUI object "hotkey" setting missing from 6d8b9e33ef, refs #567, #2604, 9e499cdec5.

Allows JS GUI to assign hotkeys to GUI objects from JS instead of XML.

Differential Revision: https://code.wildfiregames.com/D2257
Comments By: nani
Tested By: nani, Jenkins
Tested on: clang, VS2015

This was SVN commit r22845.
This commit is contained in:
elexis
2019-09-04 15:29:36 +00:00
parent 0d47644b08
commit 33af6da5e1
4 changed files with 39 additions and 10 deletions
+10
View File
@@ -154,6 +154,7 @@ bool IGUIObject::SetSettingFromString(const CStr& Setting, const CStrW& Value, c
template <typename T>
void IGUIObject::SetSetting(const CStr& Setting, T& Value, const bool SendMessage)
{
PreSettingChange(Setting);
static_cast<CGUISetting<T>* >(m_Settings[Setting])->m_pSetting = std::move(Value);
SettingChanged(Setting, SendMessage);
}
@@ -161,10 +162,17 @@ void IGUIObject::SetSetting(const CStr& Setting, T& Value, const bool SendMessag
template <typename T>
void IGUIObject::SetSetting(const CStr& Setting, const T& Value, const bool SendMessage)
{
PreSettingChange(Setting);
static_cast<CGUISetting<T>* >(m_Settings[Setting])->m_pSetting = Value;
SettingChanged(Setting, SendMessage);
}
void IGUIObject::PreSettingChange(const CStr& Setting)
{
if (Setting == "hotkey")
m_pGUI.UnsetObjectHotkey(this, GetSetting<CStr>(Setting));
}
void IGUIObject::SettingChanged(const CStr& Setting, const bool SendMessage)
{
if (Setting == "size")
@@ -178,6 +186,8 @@ void IGUIObject::SettingChanged(const CStr& Setting, const bool SendMessage)
if (GetSetting<bool>(Setting))
RecurseObject(nullptr, &IGUIObject::ResetStates);
}
else if (Setting == "hotkey")
m_pGUI.SetObjectHotkey(this, GetSetting<CStr>(Setting));
if (SendMessage)
{