1
0
Fork 0
fgdata/gui/dialogs/scenario.xml
James Turner 867d898b68 Adapt scenarios dialog for revised AIManager
AIManager now takes care of finding scenarios which can be loaded, so
the work here is much simpler.
2019-02-03 12:19:42 +00:00

236 lines
5.8 KiB
XML

<?xml version="1.0"?>
<!--
This file is part of FlightGear, the free flight simulator
http://www.flightgear.org/
Copyright (C) 2010 Torsten Dreyer, Torsten (at) t3r _dot_ de
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
-->
<PropertyList>
<name>scenario</name>
<modal>false</modal>
<layout>vbox</layout>
<resizable>false</resizable>
<default-padding>3</default-padding>
<group>
<layout>hbox</layout>
<default-padding>1</default-padding>
<empty><stretch>true</stretch></empty>
<text>
<label>AI Traffic and Scenario Settings</label>
</text>
<empty><stretch>true</stretch></empty>
<button>
<legend></legend>
<key>Esc</key>
<pref-width>16</pref-width>
<pref-height>16</pref-height>
<border>2</border>
<binding>
<command>dialog-close</command>
</binding>
</button>
</group>
<hrule/>
<group>
<layout>hbox</layout>
<halign>left</halign>
<!-- only for a gap -->
<group>
<layout>vbox</layout>
<default-padding>1</default-padding>
<text>
<label> </label>
</text>
</group>
<checkbox>
<halign>left</halign>
<label>Enable AI traffic</label>
<name>enable-ai-traffic</name>
<property>/sim/traffic-manager/enabled</property>
<live>true</live>
<binding>
<command>dialog-apply</command>
<object-name>enable-ai-traffic</object-name>
</binding>
</checkbox>
</group>
<text><label/></text>
<text>
<label>Aerodynamic interaction</label>
</text>
<hrule/>
<group>
<layout>table</layout>
<halign>left</halign>
<text>
<row>0</row>
<col>0</col>
<halign>left</halign>
<label>Enable AI aerodynamic wake</label>
</text>
<checkbox>
<row>0</row>
<col>1</col>
<name>enable-ai-wake</name>
<halign>left</halign>
<property>/fdm/ai-wake/enabled</property>
<binding>
<command>dialog-apply</command>
<object-name>enable-ai-wake</object-name>
</binding>
</checkbox>
<text>
<row>1</row>
<col>0</col>
<halign>left</halign>
<label>Max. radius of interaction (nm)</label>
</text>
<input>
<row>1</row>
<col>1</col>
<property>/fdm/ai-wake/max-radius-nm</property>
<enable>
<property>/fdm/ai-wake/enabled</property>
</enable>
<binding>
<command>dialog-apply</command>
</binding>
</input>
</group>
<text><label/></text>
<text>
<label>Choose active scenario(s) </label>
</text>
<hrule/>
<group>
<layout>hbox</layout>
<!-- only for a gap -->
<group>
<layout>vbox</layout>
<default-padding>1</default-padding>
<text>
<label> </label>
</text>
</group>
<group>
<name>left-column</name>
<layout>vbox</layout>
</group>
<group>
<layout>vbox</layout>
<name>right-column</name>
</group>
</group>
<hrule/>
<group>
<layout>hbox</layout>
<halign>center</halign>
<button>
<legend>Close</legend>
<key>Esc</key>
<binding>
<command>dialog-close</command>
</binding>
</button>
<empty><stretch>true</stretch></empty>
</group>
<nasal>
<open><![CDATA[
var dlg_root = cmdarg();
var isEnabledScenario = func(scenario) {
foreach( var n; props.globals.getNode("sim/ai",1).getChildren("scenario") )
if( n.getValue() == scenario )
return 1;
return 0;
};
var columns = [ "left-column", "right-column" ];
var processScenario = func(nr, rootN) {
var descriptionN = rootN.getNode("description");
var nameN = rootN.getNode("name");
var description = descriptionN != nil ? descriptionN.getValue() : "";
var scenarioId = rootN.getNode("id").getValue();
var propertyRoot = props.globals.getNode("sim/gui/dialogs/scenario",1).getChild( "scenario", nr, 1 );
propertyRoot.getNode("selected",1).setBoolValue(isEnabledScenario(scenarioId));
propertyRoot.getNode("name",1).setValue(scenarioId);
var group = gui.findElementByName( dlg_root, columns[math.mod(nr,2)] ).getChild("group", nr, 1 );
group.getNode("layout",1).setValue("hbox");
var cb = group.getNode("checkbox",1);
cb.getNode("property",1).setValue(propertyRoot.getNode("selected").getPath());
var label = nameN.getValue();
cb.getNode("label",1).setValue(label);
cb.getNode("name",1).setValue(scenarioId);
var applyBind = cb.addChild("binding", 0);
applyBind.getNode("command", 1).setValue("dialog-apply");
var bind = cb.addChild("binding", 1);
bind.getNode("command", 1).setValue("load-scenario");
bind.getNode("name", 1).setValue(scenarioId);
bind.getNode("load-property", 1).setValue(propertyRoot.getNode("selected").getPath());
#cb.getNode("enable/property",1).setValue("/sim/ai/scenarios-enabled");
group.getNode("empty",1).getNode("stretch",1).setValue("true");
}
var path = getprop("/sim/fg-root") ~ "/AI";
var i = -1;
foreach(var s; props.globals.getNode("sim/ai/scenarios",1).getChildren("scenario"))
processScenario( i+=1, s );
]]></open>
<close><![CDATA[
]]></close>
</nasal>
</PropertyList>