forked from mirrors/0ad
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:
@@ -342,26 +342,14 @@ function initMapFilters()
|
||||
function resizeMoreOptionsWindow()
|
||||
{
|
||||
const elementHeight = 30;
|
||||
const elements = [
|
||||
"optionGameSpeed",
|
||||
"optionVictoryCondition",
|
||||
"optionWonderDuration",
|
||||
"optionPopulationCap",
|
||||
"optionStartingResources",
|
||||
"optionCeasefire",
|
||||
"optionRevealMap",
|
||||
"optionExploreMap",
|
||||
"optionDisableTreasures",
|
||||
"optionLockTeams",
|
||||
"optionCheats",
|
||||
"optionRating",
|
||||
"hideMoreOptions"
|
||||
];
|
||||
|
||||
let yPos = undefined;
|
||||
for (let element of elements)
|
||||
|
||||
for (let guiOption of Engine.GetGUIObjectByName("moreOptions").children)
|
||||
{
|
||||
let guiOption = Engine.GetGUIObjectByName(element);
|
||||
if (guiOption.name == "moreOptionsLabel")
|
||||
continue;
|
||||
|
||||
let gSize = guiOption.size;
|
||||
yPos = yPos || gSize.top;
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@
|
||||
<!-- More Options -->
|
||||
<object hidden="true" name="moreOptionsFade" type="image" z="60" sprite="ModernFade"/>
|
||||
<object name="moreOptions" type="image" sprite="ModernDialog" size="50%-200 50%-195 50%+200 50%+220" z="70" hidden="true">
|
||||
<object style="ModernLabelText" type="text" size="50%-128 -18 50%+128 14">
|
||||
<object name="moreOptionsLabel" style="ModernLabelText" type="text" size="50%-128 -18 50%+128 14">
|
||||
<translatableAttribute id="caption">More Options</translatableAttribute>
|
||||
</object>
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user