GUI engine improvement + gamesetup cleanup.

Grab the list of children of a GUI object directly instead of hardcoding
the names.

This was SVN commit r18296.
This commit is contained in:
elexis
2016-06-02 22:49:28 +00:00
parent 31a7181eb8
commit 8b30273a50
3 changed files with 22 additions and 28 deletions
+16 -10
View File
@@ -97,30 +97,36 @@ bool JSI_IGUIObject::getProperty(JSContext* cx, JS::HandleObject obj, JS::Handle
return true;
}
// Handle the "parent" property specially
if (propName == "parent")
{
IGUIObject* parent = e->GetParent();
if (parent)
{
// If the object isn't parentless, return a new object
vp.set(JS::ObjectValue(*parent->GetJSObject()));
}
else
{
// Return null if there's no parent
vp.set(JS::NullValue());
}
return true;
}
else if (propName == "children")
{
JS::RootedObject obj(cx, JS_NewArrayObject(cx, JS::HandleValueArray::empty()));
vp.setObject(*obj);
for (size_t i = 0; i < e->m_Children.size(); ++i)
{
JS::RootedValue val(cx);
ScriptInterface::ToJSVal(cx, &val, e->m_Children[i]);
JS_SetElement(cx, obj, i, val);
}
return true;
}
// Also handle "name" specially
else if (propName == "name")
{
vp.set(JS::StringValue(JS_NewStringCopyZ(cx, e->GetName().c_str())));
return true;
}
// Handle all other properties
else
{
// Retrieve the setting's type (and make sure it actually exists)