Air-to-air refueling enhancements
[fg:toms-fgdata.git] / gui / dialogs / tanker.xml
1 <?xml version="1.0"?>
2
3 <PropertyList>
4         <name>tanker</name>
5         <x>-10</x>
6         <layout>vbox</layout>
7
8   <nasal>
9     <open>
10       var dlgRoot = cmdarg();
11       
12                         var tankers = props.globals.getNode("/sim/ai/tankers/", 1).getChildren("tanker");
13       var types = props.globals.getNode("/systems/refuel/", 1).getChildren("type");
14       var tanker_node = props.globals.getNode("/sim/gui/dialogs/tanker/tanker", 1);
15       
16       #  Force default speed of 250kts
17       setprop("/sim/gui/dialogs/tanker/tanker/speed-kts", 250.0);
18       
19       if (size(types) == 0) {
20         # This really shouldn't happen, as Nasal/tanker.nas disables this menu item
21         # if no refueling type is available.        
22         gui.popupTip("Air to air refueling unavailable in this aircraft", 5);
23                                 fgcommand("dialog-close", props.Node.new({ "dialog-name" : "tanker"}));                                 
24       }
25       
26                                 
27                         if (size(tankers) > 0) {                                                        
28                                 var combo = gui.findElementByName(dlgRoot, "tanker-combo");
29                                 var idx = 0;
30                                 foreach (var t; tankers) {
31                                   foreach(var type; types) {                              
32                                     if (type.getValue() == t.getNode("type", 1).getValue()) {
33                                                         combo.getChild("value", idx, 1).setValue(t.getNode("name", 1).getValue());
34                                                         idx += 1;
35                                                 }
36                                         }
37                                 }
38                         }
39                         
40                         var select_tanker = func() {
41                           var name = getprop("/sim/gui/dialogs/tanker/selected-tanker");
42                                 
43                                 foreach (var t; tankers) {
44                                   if (name == t.getNode("name", 1).getValue()) {
45                                     props.copy(t, tanker_node);
46                                   }                             
47                                 }
48                         }
49                         
50                         var generate_tanker = func() {
51                                 if (tanker_node.getNode("name", 1).getValue()) {
52                                   tanker.request_new(tanker_node);
53                                 }
54                         }                       
55         
56                 </open>
57         </nasal>
58
59         <group>
60                 <layout>hbox</layout>
61                 <empty><stretch>1</stretch></empty>
62
63                 <text>
64                         <label>Air-to-Air Refueling Tanker</label>
65                 </text>
66
67                 <empty><stretch>1</stretch></empty>
68
69                 <button>
70                         <pref-width>16</pref-width>
71                         <pref-height>16</pref-height>
72                         <legend></legend>
73                         <keynum>27</keynum>
74                         <border>2</border>
75
76                         <binding>
77                                 <command>dialog-close</command>
78                         </binding>
79                 </button>
80         </group>
81
82         <hrule/>
83
84         <group>
85           <layout>table</layout>        
86           
87           <text>
88             <row>0</row>
89             <col>0</col>
90             <halign>right</halign>
91             <label>Tanker:</label>
92                 </text>
93                 
94                 <combo>
95       <name>tanker-combo</name>
96             <row>0</row>
97             <col>1</col>
98             <colspan>2</colspan>
99             <halign>left</halign>
100       <property>/sim/gui/dialogs/tanker/selected-tanker</property>
101       <editable>false</editable>
102       <pref-width>200</pref-width>
103       <halign>fill</halign>
104       <binding>
105         <command>dialog-apply</command>
106         <object-name>tanker-combo</object-name>
107       </binding>
108       <binding>
109         <command>nasal</command>
110         <script>select_tanker();</script>
111       </binding>
112                 </combo>
113
114           <text>
115             <row>1</row>
116             <col>0</col>
117             <halign>right</halign>
118             <label>Type:</label>
119                 </text>
120                 
121                 <text>
122             <row>1</row>
123             <col>1</col>
124             <visible>
125               <equals>
126                 <property>/sim/gui/dialogs/tanker/tanker/type</property>
127                 <value>probe</value>          
128               </equals>     
129             </visible>
130             <colspan>3</colspan>
131             <halign>left</halign>
132             <label>Drogue and Probe</label>
133                 </text>
134
135                 <text>
136             <row>1</row>
137             <col>1</col>
138             <visible>
139               <equals>
140                 <property>/sim/gui/dialogs/tanker/tanker/type</property>
141                 <value>boom</value>           
142               </equals>     
143             </visible>
144             <colspan>3</colspan>
145             <halign>left</halign>
146             <label>Boom</label>
147                 </text>
148                 
149           <text>
150             <row>2</row>
151             <col>0</col>
152             <halign>right</halign>
153             <label>Speed:</label>
154                 </text>
155
156                 <slider>
157                         <name>tanker-speed</name>                       
158                         <row>2</row>
159                         <col>1</col>
160                         <halign>fill</halign>
161                         <min>100</min>
162                         <max>350</max>
163                         <live>true</live>
164                         <property>/sim/gui/dialogs/tanker/tanker/speed-kts</property>
165       <binding>
166         <command>dialog-apply</command>
167         <object-name>tanker-speed</object-name>
168       </binding>
169                 </slider>
170                 
171                 <text>
172             <row>2</row>
173             <col>2</col>
174             <halign>left</halign>
175             <format>%2.0fkts</format>
176             <label>250</label>
177             <property>/sim/gui/dialogs/tanker/tanker/speed-kts</property>
178             <live>true</live>
179                 </text>
180
181           <text>
182             <row>3</row>
183             <col>0</col>
184             <halign>right</halign>
185             <label>Contact radius:</label>
186                 </text>
187                 
188                 <slider>
189                         <name>contact-radius</name>                     
190                         <row>3</row>
191                         <col>1</col>
192                         <halign>fill</halign>
193                         <min>1</min>
194                         <max>100</max>
195                         <property>/systems/refuel/contact-radius-m</property>
196       <binding>
197         <command>dialog-apply</command>
198         <object-name>contact-radius</object-name>
199       </binding>
200                 </slider>
201                 
202                 <text>
203                   <row>3</row>
204                   <col>2</col>
205             <halign>left</halign>
206                   <format>%2.0fm</format>
207                         <property>/systems/refuel/contact-radius-m</property>
208                         <live>true</live>
209                 </text>
210
211           <text>
212             <row>4</row>
213             <col>0</col>
214             <halign>right</halign>
215             <label>Report refueling:</label>
216                 </text>
217                 
218                 <checkbox>
219                         <name>report-contact</name>                     
220                         <row>4</row>
221                         <col>1</col>
222                         <halign>left</halign>
223                         <property>/systems/refuel/report-contact</property>
224       <binding>
225         <command>dialog-apply</command>
226         <object-name>report-contact</object-name>
227       </binding>
228                 </checkbox>
229                                 
230         </group>
231         
232         <hrule/>
233         
234         <group>
235           <layout>hbox</layout>
236                 <default-padding>5</default-padding>
237
238                 <empty><stretch>true</stretch></empty>
239         
240                 <button>
241                         <legend>Request</legend>
242                         <equal>true</equal>
243                         <binding>
244                                 <command>nasal</command>
245                                 <script>generate_tanker();</script>
246                         </binding>
247                 </button>
248
249                 <empty><stretch>true</stretch></empty>
250
251                 <button>
252                         <legend>Get Position</legend>
253                         <equal>true</equal>
254                         <binding>
255                                 <command>nasal</command>
256                                 <script>tanker.report()</script>
257                         </binding>
258                 </button>
259                 
260                 <empty><stretch>true</stretch></empty>
261
262                 <button>
263                         <legend>Close</legend>
264                         <equal>true</equal>
265                         <key>Esc</key>
266                         <binding>
267                                 <command>dialog-close</command>
268                         </binding>
269                 </button>
270                 
271                 <empty><stretch>true</stretch></empty>
272                 
273         </group>
274                 
275 </PropertyList>