mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-28 17:13:12 +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:
+22
-8
@@ -466,6 +466,28 @@ void CGUI::SetFocusedObject(IGUIObject* pObject)
|
||||
}
|
||||
}
|
||||
|
||||
void CGUI::SetObjectHotkey(IGUIObject* pObject, const CStr& hotkeyTag)
|
||||
{
|
||||
if (!hotkeyTag.empty())
|
||||
m_HotkeyObjects[hotkeyTag].push_back(pObject);
|
||||
}
|
||||
|
||||
void CGUI::UnsetObjectHotkey(IGUIObject* pObject, const CStr& hotkeyTag)
|
||||
{
|
||||
if (hotkeyTag.empty())
|
||||
return;
|
||||
|
||||
std::vector<IGUIObject*>& assignment = m_HotkeyObjects[hotkeyTag];
|
||||
|
||||
assignment.erase(
|
||||
std::remove_if(
|
||||
assignment.begin(),
|
||||
assignment.end(),
|
||||
[&pObject](const IGUIObject* hotkeyObject)
|
||||
{ return pObject == hotkeyObject; }),
|
||||
assignment.end());
|
||||
}
|
||||
|
||||
const SGUIScrollBarStyle* CGUI::GetScrollBarStyle(const CStr& style) const
|
||||
{
|
||||
std::map<CStr, const SGUIScrollBarStyle>::const_iterator it = m_ScrollBarStyles.find(style);
|
||||
@@ -603,7 +625,6 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
ATTR(style);
|
||||
ATTR(type);
|
||||
ATTR(name);
|
||||
ATTR(hotkey);
|
||||
ATTR(z);
|
||||
ATTR(on);
|
||||
ATTR(file);
|
||||
@@ -635,7 +656,6 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
bool ManuallySetZ = false;
|
||||
|
||||
CStrW inclusionPath;
|
||||
CStr hotkeyTag;
|
||||
|
||||
for (XMBAttribute attr : attributes)
|
||||
{
|
||||
@@ -659,9 +679,6 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attr.Name == attr_hotkey)
|
||||
hotkeyTag = attr.Value;
|
||||
|
||||
if (attr.Name == attr_z)
|
||||
ManuallySetZ = true;
|
||||
|
||||
@@ -679,9 +696,6 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
++m_InternalNameNumber;
|
||||
}
|
||||
|
||||
if (!hotkeyTag.empty())
|
||||
m_HotkeyObjects[hotkeyTag].push_back(object);
|
||||
|
||||
CStrW caption(Element.GetText().FromUTF8());
|
||||
if (!caption.empty())
|
||||
object->SetSettingFromString("caption", caption, false);
|
||||
|
||||
Reference in New Issue
Block a user