2010-04-09 09:45:25 +00:00
|
|
|
<?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>
|
2012-05-01 09:10:37 +00:00
|
|
|
<label>AI Traffic and Scenario Settings</label>
|
2010-04-09 09:45:25 +00:00
|
|
|
</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/>
|
|
|
|
|
2015-05-03 16:13:50 +00:00
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
2012-05-01 09:10:37 +00:00
|
|
|
<halign>left</halign>
|
2015-05-03 16:13:50 +00:00
|
|
|
|
|
|
|
<!-- 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>
|
2012-05-01 09:10:37 +00:00
|
|
|
|
2012-04-30 17:22:00 +00:00
|
|
|
<text><label/></text>
|
|
|
|
|
2010-12-27 20:19:31 +00:00
|
|
|
<text>
|
2013-04-02 17:01:59 +00:00
|
|
|
<label>Choose active scenario(s) </label>
|
2010-12-27 20:19:31 +00:00
|
|
|
</text>
|
|
|
|
|
|
|
|
<hrule/>
|
|
|
|
|
2010-04-09 09:45:25 +00:00
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
|
2015-05-03 16:13:50 +00:00
|
|
|
<!-- only for a gap -->
|
|
|
|
<group>
|
|
|
|
<layout>vbox</layout>
|
|
|
|
<default-padding>1</default-padding>
|
|
|
|
<text>
|
|
|
|
<label> </label>
|
|
|
|
</text>
|
|
|
|
</group>
|
|
|
|
|
2010-04-09 09:45:25 +00:00
|
|
|
<group>
|
|
|
|
<name>left-column</name>
|
|
|
|
<layout>vbox</layout>
|
|
|
|
</group>
|
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>vbox</layout>
|
|
|
|
<name>right-column</name>
|
|
|
|
</group>
|
|
|
|
|
|
|
|
</group>
|
|
|
|
|
2010-12-27 20:19:31 +00:00
|
|
|
<hrule/>
|
2010-04-09 09:45:25 +00:00
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<halign>center</halign>
|
|
|
|
|
|
|
|
<button>
|
2013-04-02 17:01:59 +00:00
|
|
|
<legend>Close</legend>
|
2010-04-09 09:45:25 +00:00
|
|
|
<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,file, rootN) {
|
|
|
|
var scenarioN = rootN.getNode("scenario");
|
|
|
|
if( scenarioN == nil ) return;
|
|
|
|
var descriptionN = rootN.getNode("description");
|
2012-04-30 17:22:00 +00:00
|
|
|
var nameN = rootN.getNode("name");
|
|
|
|
if( (descriptionN == nil)and(nameN == nil) )
|
|
|
|
{
|
|
|
|
descriptionN = scenarioN.getNode("description");
|
|
|
|
nameN = scenarioN.getNode("name");
|
|
|
|
}
|
2010-04-09 09:45:25 +00:00
|
|
|
var description = descriptionN != nil ? descriptionN.getValue() : "";
|
|
|
|
var propertyRoot = props.globals.getNode("sim/gui/dialogs/scenario",1).getChild( "scenario", nr, 1 );
|
|
|
|
propertyRoot.getNode("selected",1).setBoolValue(isEnabledScenario(file));
|
|
|
|
propertyRoot.getNode("name",1).setValue(file);
|
|
|
|
|
2012-03-24 11:45:58 +00:00
|
|
|
var group = gui.findElementByName( dlg_root, columns[math.mod(nr,2)] ).getChild("group", nr, 1 );
|
2010-04-09 09:45:25 +00:00
|
|
|
group.getNode("layout",1).setValue("hbox");
|
|
|
|
var cb = group.getNode("checkbox",1);
|
|
|
|
cb.getNode("property",1).setValue(propertyRoot.getNode("selected").getPath());
|
2012-04-30 17:22:00 +00:00
|
|
|
var label = string.replace(file, "_", " ");
|
|
|
|
if (nameN != nil)
|
|
|
|
label = nameN.getValue();
|
2013-04-02 17:01:59 +00:00
|
|
|
|
2012-04-30 17:22:00 +00:00
|
|
|
cb.getNode("label",1).setValue(label);
|
2010-04-09 09:45:25 +00:00
|
|
|
cb.getNode("name",1).setValue(file);
|
2013-04-02 17:01:59 +00:00
|
|
|
|
|
|
|
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(file);
|
|
|
|
bind.getNode("load-property", 1).setValue(propertyRoot.getNode("selected").getPath());
|
|
|
|
|
|
|
|
#cb.getNode("enable/property",1).setValue("/sim/ai/scenarios-enabled");
|
|
|
|
|
2010-04-09 09:45:25 +00:00
|
|
|
group.getNode("empty",1).getNode("stretch",1).setValue("true");
|
|
|
|
}
|
|
|
|
|
|
|
|
var path = getprop("/sim/fg-root") ~ "/AI";
|
|
|
|
var i = -1;
|
|
|
|
foreach(var file; sort(directory(path), cmp))
|
|
|
|
if(size(file) > 4 and substr(file, -4) == ".xml")
|
|
|
|
processScenario( i+=1, substr(file,0,size(file)-4), io.read_properties(path ~ "/" ~ file) );
|
|
|
|
|
|
|
|
]]></open>
|
|
|
|
|
|
|
|
<close><![CDATA[
|
|
|
|
]]></close>
|
|
|
|
|
|
|
|
</nasal>
|
|
|
|
</PropertyList>
|
|
|
|
|