FGCom: add silence threshold setting
[fg:toms-fgdata.git] / gui / dialogs / fgcom.xml
1 <?xml version="1.0"?>
2
3 <PropertyList>
4   <name>fgcom</name>
5   <layout>vbox</layout>
6   <resizable>false</resizable>
7
8   <nasal>
9         <open><![CDATA[
10             var autofill = func {
11                 if ((getprop("/sim/fgcom/selected-server") == nil) or 
12                     (getprop("/sim/fgcom/selected-server") == "" )   ){
13                     var tx = getprop("/sim/fgcom/server");
14                     var dlg = cmdarg();
15                     #var servers = cmdarg().getChildren("group")[5].getChildren("combo")[0].getChildren("value");
16                     var servers = props.globals.getNode("/sim/gui/dialogs/multiplay/fgcom-servers", 1);
17                     foreach (var s; servers.getChildren("value")) {
18                         var server = s.getValue();
19                         var host = split(" ", server)[0];
20                         if (host == tx) {
21                             setprop("/sim/fgcom/selected-server", server);
22                         }
23                     }
24                 }
25             }
26             
27             var servers = props.globals.getNode("/sim/gui/dialogs/multiplay/fgcom-servers", 1);
28             var updateServers = func {
29                 servers.removeChildren("value");                
30                 # get the results list from the server
31                 var serverlist = props.globals.getNode("/sim/multiplay/server-list", 1);
32             
33                 var i=0;
34                 foreach (var s; serverlist.getChildren("fgcom")) {
35                     
36                     if (!s.getNode("online").getBoolValue()) {
37                       continue; # skip offline servers
38                     }
39                   
40                 # label is name and location, for the moment
41                 # should we include the number of users? or wait until we
42                 # have a better UI toolkit?
43                     var nm = s.getNode("hostname").getValue() ~ " - " ~ s.getNode("location").getValue();
44                     servers.getNode("value[" ~ i ~ "]", 1).setValue(nm);
45                     i += 1;
46                 }
47
48                 autofill();
49                 gui.dialog_update("fgcom", "server");
50             }
51             
52             var static_serverList = [
53                     ['fgcom.flightgear.org', 'Avignon, France']
54                 ];
55                 
56             var updateServersFailed = func {
57                 debug.dump("Failed to retrieve server list!");
58     
59                 servers.removeChildren("value"); 
60                 var i=0;
61                 foreach (var s; static_serverList) {
62                 # create the node the PUI combo
63                     var nm = s[0] ~ " - " ~ s[1];
64                     servers.getNode("value[" ~ i ~ "]", 1).setValue(nm);
65                     i += 1;
66                 }
67                 
68                 autofill();
69                 gui.dialog_update("fgcom", "server");
70             }
71             
72             # listen for results arriving  
73             setlistener("/sim/multiplay/got-servers", updateServers);
74             setlistener("/sim/multiplay/get-servers-failure", updateServersFailed);
75             
76             fgcommand("xmlhttprequest",  props.Node.new({
77               "url" : "http://liveries.flightgear.org/mpstatus/mpservers.xml",
78               "targetnode" : "/sim/multiplay/server-list",
79               "complete" : "/sim/multiplay/got-servers",
80               "failure" : "/sim/multiplay/get-servers-failure"
81             }));
82             ]]>
83         </open>
84     <close>
85     </close>
86   </nasal>
87
88   <!-- titlebar -->
89   <group>
90     <layout>hbox</layout>
91     <empty>
92       <stretch>1</stretch>
93     </empty>
94
95     <text>
96       <label>FGCom Settings</label>
97     </text>
98
99     <empty>
100       <stretch>1</stretch>
101     </empty>
102
103     <button>
104       <pref-width>16</pref-width>
105       <pref-height>16</pref-height>
106       <legend></legend>
107       <keynum>27</keynum>
108       <border>2</border>
109       <binding>
110         <command>dialog-close</command>
111       </binding>
112     </button>
113   </group>
114   <hrule/>
115
116   <!-- main dialog area -->
117   <group>
118     <layout>table</layout>
119     <halign>left</halign>
120
121     <text>
122       <row>0</row>
123       <col>0</col>
124       <label>Enabled:</label>
125       <halign>right</halign>
126       <enable>
127         <equals>
128           <property>/sim/fgcom/test</property>
129           <value>0</value>
130         </equals>
131       </enable>
132     </text>
133     <checkbox>
134       <row>0</row>
135       <col>1</col>
136       <colspan>2</colspan>
137       <halign>left</halign>
138       <name>enabled</name>
139       <label></label>
140       <enable>
141         <equals>
142           <property>/sim/fgcom/test</property>
143           <value>0</value>
144         </equals>
145       </enable>
146       <property>/sim/fgcom/enabled</property>
147       <binding>
148         <command>dialog-apply</command>
149         <object-name>enabled</object-name>
150       </binding>
151     </checkbox>
152
153     <text>
154       <row>1</row>
155       <col>0</col>
156       <label>Display messages:</label>
157       <halign>right</halign>
158     </text>
159     <checkbox>
160       <row>1</row>
161       <col>1</col>
162       <colspan>2</colspan>
163       <halign>left</halign>
164       <name>showMessages</name>
165       <label></label>
166       <property>/sim/fgcom/show-messages</property>
167       <binding>
168         <command>dialog-apply</command>
169         <object-name>showMessages</object-name>
170       </binding>
171     </checkbox>
172     <text>
173       <row>1</row>
174       <col>1</col>
175       <label>        (for debug only)</label>
176       <halign>right</halign>
177     </text>
178
179     <text>
180       <row>3</row>
181       <col>0</col>
182       <label>Echo test:</label>
183       <halign>right</halign>
184       <enable>
185         <equals>
186           <property>/sim/fgcom/enabled</property>
187           <value>1</value>
188         </equals>
189       </enable>
190     </text>
191     <checkbox>
192       <row>3</row>
193       <col>1</col>
194       <colspan>2</colspan>
195       <halign>left</halign>
196       <name>test</name>
197       <label></label>
198       <enable>
199         <equals>
200           <property>/sim/fgcom/enabled</property>
201           <value>1</value>
202         </equals>
203       </enable>
204       <property>/sim/fgcom/test</property>
205       <binding>
206         <command>dialog-apply</command>
207         <object-name>test</object-name>
208       </binding>
209     </checkbox>
210
211     <text>
212       <row>4</row>
213       <col>0</col>
214       <label>Speaker Volume:</label>
215       <halign>right</halign>
216     </text>
217     <slider>
218       <row>4</row>
219       <col>1</col>
220       <halign>left</halign>
221       <name>speaker-vol</name>
222       <label></label>
223       <min>0</min>
224       <max>1.0</max>
225       <step>0.1</step>
226       <property>/sim/fgcom/speaker-level</property>
227       <binding>
228         <command>dialog-apply</command>
229         <object-name>speaker-vol</object-name>
230       </binding>
231     </slider>
232     <text>
233       <row>4</row>
234       <col>2</col>
235       <label>1234</label>
236       <format>%.1f</format>
237       <live>true</live>
238       <property>/sim/fgcom/speaker-level</property>
239     </text>
240
241     <text>
242       <row>5</row>
243       <col>0</col>
244       <label>Silence threshold:</label>
245       <halign>right</halign>
246     </text>
247     <slider>
248       <row>5</row>
249       <col>1</col>
250       <halign>left</halign>
251       <name>silence-thd</name>
252       <label></label>
253       <min>-60.0</min>
254       <max>0.0</max>
255       <step>1</step>
256       <property>/sim/fgcom/silence-threshold</property>
257       <binding>
258         <command>dialog-apply</command>
259         <object-name>silence-thd</object-name>
260       </binding>
261     </slider>
262     <text>
263       <row>5</row>
264       <col>2</col>
265       <label>1234</label>
266       <format>%.1f</format>
267       <live>true</live>
268       <property>/sim/fgcom/silence-threshold</property>
269     </text>
270   </group>
271
272   <hrule/>
273
274   <!-- registration (keep it for the day we need it)
275   <group>
276     <layout>hbox</layout>
277     <empty>
278       <stretch>1</stretch>
279     </empty>
280
281     <text>
282       <label>Registration</label>
283     </text>
284
285     <empty>
286       <stretch>1</stretch>
287     </empty>
288   </group>
289
290   <group>
291     <layout>table</layout>
292     <halign>left</halign>
293
294     <text>
295       <row>0</row>
296       <col>0</col>
297       <halign>right</halign>
298       <label>Enabled:</label>
299       <enable>
300         <equals>
301           <property>/sim/fgcom/enabled</property>
302           <value>0</value>
303         </equals>
304       </enable>
305     </text>
306     <checkbox>
307       <row>0</row>
308       <col>1</col>
309       <colspan>2</colspan>
310       <halign>left</halign>
311       <name>reg-enabled</name>
312       <label></label>
313       <property>/sim/fgcom/register/enabled</property>
314       <enable>
315         <equals>
316           <property>/sim/fgcom/enabled</property>
317           <value>0</value>
318         </equals>
319       </enable>
320       <binding>
321         <command>dialog-apply</command>
322         <object-name>reg-enabled</object-name>
323       </binding>
324     </checkbox>
325
326     <text>
327       <row>1</row>
328       <col>0</col>
329       <halign>right</halign>
330       <label>Username:</label>
331       <enable>
332         <equals>
333           <property>/sim/fgcom/enabled</property>
334           <value>0</value>
335         </equals>
336       </enable>
337     </text>
338     <input>
339       <name>username</name>
340       <row>1</row>
341       <col>1</col>
342       <colspan>2</colspan>
343       <halign>left</halign>
344       <pref-width>125</pref-width>
345       <editable>true</editable>
346       <property>/sim/fgcom/register/username</property>
347       <enable>
348         <equals>
349           <property>/sim/fgcom/enabled</property>
350           <value>0</value>
351         </equals>
352       </enable>
353       <binding>
354         <command>dialog-apply</command>
355         <object-name>username</object-name>
356       </binding>
357     </input>
358
359     <text>
360       <row>2</row>
361       <col>0</col>
362       <halign>right</halign>
363       <label>Password:</label>
364       <enable>
365         <equals>
366           <property>/sim/fgcom/enabled</property>
367           <value>0</value>
368         </equals>
369       </enable>
370     </text>
371     <input>
372       <name>password</name>
373       <row>2</row>
374       <col>1</col>
375       <colspan>2</colspan>
376       <halign>left</halign>
377       <pref-width>125</pref-width>
378       <editable>true</editable>
379       <property>/sim/fgcom/register/password</property>
380       <enable>
381         <equals>
382           <property>/sim/fgcom/enabled</property>
383           <value>0</value>
384         </equals>
385       </enable>
386       <binding>
387         <command>dialog-apply</command>
388         <object-name>password</object-name>
389       </binding>
390     </input>
391   </group>
392
393   <hrule/>
394 -->
395   <!-- server -->
396   <group>
397     <layout>hbox</layout>
398     <empty>
399       <stretch>1</stretch>
400     </empty>
401
402     <text>
403       <label>Server</label>
404     </text>
405
406     <empty>
407       <stretch>1</stretch>
408     </empty>
409   </group>
410
411   <group>
412     <layout>table</layout>
413     <halign>left</halign>
414
415
416
417     <combo>
418       <name>server</name>
419       <row>1</row>
420       <col>0</col>
421       <colspan>6</colspan>
422       <pref-width>275</pref-width>
423       <editable>false</editable>
424       <property>/sim/fgcom/selected-server</property>
425       <properties>/sim/gui/dialogs/multiplay/fgcom-servers</properties>
426       <enable>
427         <and>
428           <equals>
429             <property>/sim/fgcom/enabled</property>
430             <value>1</value>
431           </equals>
432           <equals>
433             <property>/sim/fgcom/test</property>
434             <value>0</value>
435           </equals>
436         </and>
437       </enable>
438       <binding>
439         <command>dialog-apply</command>
440         <object-name>server</object-name>
441       </binding>
442       <binding>
443         <command>nasal</command>
444         <script>
445           <![CDATA[
446                  setprop("/sim/fgcom/enabled", 0);
447
448                  var server = getprop("/sim/fgcom/selected-server");
449                  server = split(" ", server)[0];
450                  setprop("/sim/fgcom/server", server);
451
452                  setprop("/sim/fgcom/enabled", 1);
453              ]]>
454         </script>
455       </binding>
456       <binding>
457         <command>dialog-apply</command>
458         <object-name>test</object-name>
459       </binding>
460     </combo>
461
462   </group>
463
464   <!-- button area -->
465
466   <hrule/>
467   <group>
468     <layout>hbox</layout>
469     <default-padding>10</default-padding>
470     <empty>
471       <stretch>true</stretch>
472     </empty>
473
474     <button>
475       <legend>Close</legend>
476       <default>true</default>
477       <equal>true</equal>
478       <binding>
479         <command>dialog-close</command>
480       </binding>
481     </button>
482
483     <empty>
484       <stretch>true</stretch>
485     </empty>
486   </group>
487
488 </PropertyList>
489