mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-27 10:52:59 +00:00
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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user