Change GUI settings to explicitly be member variables.

Completes work starting in D2313 / a33fd55e81:
- Make C++ mistakes where values can be changed without messages being
sent easier to notice / harder to do.
- Make the IGUISetting interface more flexible, allowing custom settings
implementing their own logic. This is used to clean up hotkey code
introduced in 33af6da5e1.

Side effects:
- FromJSVal_Vector clears the vector being passed in. I have some vague
memory of not doing that in D24 / 2bae30c454 as an optimisation, but it
seems more like a footgun to me.
- Most usage of SetSettingFromString is replaced by direct method calls,
as we can generally cast to the proper GUI object type. Where we can't,
it is kept as a poor's man virtual dispatch.
- It moves a few member variables elsewhere, e.g. TextOwner now gets its
own member variable settings.

Differential Revision: https://code.wildfiregames.com/D3892
This was SVN commit r25392.
This commit is contained in:
wraitii
2021-05-06 08:22:37 +00:00
parent 4db5467717
commit 8b08f4ae7a
46 changed files with 797 additions and 945 deletions
+9 -4
View File
@@ -441,8 +441,7 @@ void CGUI::SetObjectStyle(IGUIObject* pObject, const CStr& styleName)
{
// If the style is not recognised (or an empty string) then ApplyStyle will
// emit an error message. Thus we don't need to handle it here.
if (pObject->ApplyStyle(styleName))
pObject->m_Style = styleName;
pObject->ApplyStyle(styleName);
}
void CGUI::UnsetObjectStyle(IGUIObject* pObject)
@@ -684,6 +683,12 @@ IGUIObject* CGUI::Xeromyces_ReadObject(const XMBData& xmb, XMBElement element, I
{
CStr name(attr.Value);
if (name.Left(2) == "__")
{
LOGERROR("GUI: Names starting with '__' are reserved for the engine (object: %s)", name.c_str());
continue;
}
for (const std::pair<CStr, CStr>& sub : NameSubst)
name.Replace(sub.first, sub.second);
@@ -894,10 +899,10 @@ IGUIObject* CGUI::Xeromyces_ReadObject(const XMBData& xmb, XMBElement element, I
if (object->m_Absolute)
// If the object is absolute, we'll have to get the parent's Z buffered,
// and add to that!
object->SetSetting<float>("z", pParent->GetBufferedZ() + 10.f, false);
object->m_Z.Set(pParent->GetBufferedZ() + 10.f, false);
else
// If the object is relative, then we'll just store Z as "10"
object->SetSetting<float>("z", 10.f, false);
object->m_Z.Set(10.f, false);
}
if (!AddObject(*pParent, *object))