Debian Codegraph @

gui/dialogs/scenario.xml

raw symbols SCIP
1 <?xml version="1.0"?>
2 <!--
3 This file is part of FlightGear, the free flight simulator
4 http://www.flightgear.org/
5
6 Copyright (C) 2010 Torsten Dreyer, Torsten (at) t3r _dot_ de
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17 -->
18
19 <PropertyList>
20 <name>scenario</name>
21 <modal>false</modal>
22 <layout>vbox</layout>
23 <resizable>false</resizable>
24 <default-padding>3</default-padding>
25
26 <group>
27 <layout>hbox</layout>
28 <default-padding>1</default-padding>
29
30 <text>
31 <label>AI Traffic and Scenario Settings</label>
32 </text>
33
34 <empty><stretch>true</stretch></empty>
35
36 <button>
37 <legend>X</legend>
38 <key>Esc</key>
39 <pref-width>20</pref-width>
40 <pref-height>20</pref-height>
41 <binding>
42 <command>dialog-close</command>
43 </binding>
44 </button>
45 </group>
46
47 <hrule/>
48
49 <group>
50 <layout>hbox</layout>
51 <hrule>
52 <stretch>true</stretch>
53 </hrule>
54 <text>
55 <label>Timetable-Based AI Traffic</label>
56 <halign>center</halign>
57 </text>
58 <hrule>
59 <stretch>true</stretch>
60 </hrule>
61 </group>
62
63 <group>
64 <layout>vbox</layout>
65 <halign>left</halign>
66
67 <checkbox>
68 <halign>left</halign>
69 <label>Enable AI traffic</label>
70 <name>enable-ai-traffic</name>
71 <property>/sim/traffic-manager/enabled</property>
72 <live>true</live>
73 <binding>
74 <command>dialog-apply</command>
75 <object-name>enable-ai-traffic</object-name>
76 </binding>
77 </checkbox>
78
79 <group>
80 <layout>vbox</layout>
81 <visible>
82 <not-equals>
83 <property>/sim/traffic-manager/enabled</property>
84 <value>0</value>
85 </not-equals>
86 </visible>
87 <checkbox>
88 <name>enable-ai-wake</name>
89 <halign>left</halign>
90 <label>Enable AI aerodynamic wake</label>
91 <property>/fdm/ai-wake/enabled</property>
92 <binding>
93 <command>dialog-apply</command>
94 <object-name>enable-ai-wake</object-name>
95 </binding>
96 </checkbox>
97
98 <group>
99 <layout>hbox</layout>
100 <visible>
101 <not-equals>
102 <property>/fdm/ai-wake/enabled</property>
103 <value>0</value>
104 </not-equals>
105 </visible>
106 <text>
107 <halign>left</halign>
108 <label>Max. radius of interaction (nm)</label>
109 </text>
110
111 <input>
112 <property>/fdm/ai-wake/max-radius-nm</property>
113 <enable>
114 <property>/fdm/ai-wake/enabled</property>
115 </enable>
116 <binding>
117 <command>dialog-apply</command>
118 </binding>
119 </input>
120 </group>
121 </group>
122 </group>
123
124 <group>
125 <layout>hbox</layout>
126 <hrule>
127 <stretch>true</stretch>
128 </hrule>
129 <text>
130 <label>Scenarios</label>
131 <halign>center</halign>
132 </text>
133 <hrule>
134 <stretch>true</stretch>
135 </hrule>
136 </group>
137
138 <group>
139 <layout>hbox</layout>
140
141 <!-- only for a gap -->
142 <group>
143 <layout>vbox</layout>
144 <default-padding>1</default-padding>
145 <text>
146 <label></label>
147 </text>
148 </group>
149
150 <group>
151 <name>column0</name>
152 <layout>vbox</layout>
153 </group>
154
155 <group>
156 <layout>vbox</layout>
157 <name>column1</name>
158 </group>
159
160 <group>
161 <layout>vbox</layout>
162 <name>column2</name>
163 </group>
164
165 </group>
166
167 <hrule/>
168
169 <group>
170 <layout>hbox</layout>
171 <halign>center</halign>
172
173 <button>
174 <legend>Close</legend>
175 <key>Esc</key>
176 <binding>
177 <command>dialog-close</command>
178 </binding>
179 </button>
180
181 <empty><stretch>true</stretch></empty>
182 </group>
183
184 <nasal>
185 <open><![CDATA[
186 var dlg_root = cmdarg();
187
188 var isEnabledScenario = func(scenario) {
189 foreach( var n; props.globals.getNode("sim/ai",1).getChildren("scenario") )
190 if( n.getValue() == scenario )
191 return 1;
192 return 0;
193 };
194
195 var processScenario = func(nr, col, rootN) {
196 var descriptionN = rootN.getNode("description");
197 var nameN = rootN.getNode("name");
198 var description = descriptionN != nil ? descriptionN.getValue() : "";
199 var scenarioId = rootN.getNode("id").getValue();
200
201 var propertyRoot = props.globals.getNode("sim/gui/dialogs/scenario",1).getChild( "scenario", nr, 1 );
202 propertyRoot.getNode("selected",1).setBoolValue(isEnabledScenario(scenarioId));
203 propertyRoot.getNode("name",1).setValue(scenarioId);
204
205 var group = gui.findElementByName( dlg_root, "column"~math.mod(col,3) ).getChild("group", nr, 1 );
206 group.getNode("layout",1).setValue("hbox");
207 var cb = group.getNode("checkbox",1);
208 cb.getNode("property",1).setValue(propertyRoot.getNode("selected").getPath());
209 var label = nameN.getValue();
210
211 cb.getNode("label",1).setValue(label);
212 cb.getNode("name",1).setValue(scenarioId);
213
214 var applyBind = cb.addChild("binding", 0);
215 applyBind.getNode("command", 1).setValue("dialog-apply");
216
217 var bind = cb.addChild("binding", 1);
218 bind.getNode("command", 1).setValue("load-scenario");
219 bind.getNode("name", 1).setValue(scenarioId);
220 bind.getNode("load-property", 1).setValue(propertyRoot.getNode("selected").getPath());
221
222 #cb.getNode("enable/property",1).setValue("/sim/ai/scenarios-enabled");
223
224 group.getNode("empty",1).getNode("stretch",1).setValue("true");
225 }
226
227 var path = getprop("/sim/fg-root") ~ "/AI";
228 scenarios = [];
229
230 foreach(var s; props.globals.getNode("sim/ai/scenarios",1).getChildren("scenario")){
231 append(scenarios, s);
232 }
233 # sort the scenarios into alpha order.
234 scenarios = sort (scenarios, func (a,b) {cmp(a.getNode("name").getValue(), b.getNode("name").getValue());});
235
236 # display in three columns top-to-bottom
237 ssz = size(scenarios);
238 colsz = math.round(ssz/3);
239 coli = 0;
240 col = 0;
241
242 for(i=0;i<size(scenarios);i += 1) {
243 processScenario( i, col, scenarios[i]);
244 coli += 1;
245 if (coli >= colsz){
246 coli = 0;
247 col += 1;
248 }
249 }
250 ]]></open>
251
252 <close><![CDATA[
253 ]]></close>
254
255 </nasal>
256 </PropertyList>
257