2005-05-15 09:25:17 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<PropertyList>
|
|
|
|
<name>weather_scenario</name>
|
|
|
|
<modal>false</modal>
|
|
|
|
<layout>vbox</layout>
|
2009-01-11 00:10:13 +00:00
|
|
|
<resizable>true</resizable>
|
2009-05-29 10:27:30 +00:00
|
|
|
<default-padding>3</default-padding>
|
2005-05-15 09:25:17 +00:00
|
|
|
|
2009-05-29 10:27:30 +00:00
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<default-padding>1</default-padding>
|
2005-05-15 09:25:17 +00:00
|
|
|
|
2009-05-29 10:27:30 +00:00
|
|
|
<empty><stretch>true</stretch></empty>
|
|
|
|
|
|
|
|
<text>
|
|
|
|
<label>Automatic Weather Generation</label>
|
|
|
|
</text>
|
2005-11-04 20:09:31 +00:00
|
|
|
|
2009-05-29 10:27:30 +00:00
|
|
|
<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>
|
2005-11-04 20:09:31 +00:00
|
|
|
|
2009-05-29 10:27:30 +00:00
|
|
|
<hrule/>
|
2005-05-15 09:25:17 +00:00
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<text>
|
2009-05-29 10:27:30 +00:00
|
|
|
<label>METAR Source</label>
|
2005-05-15 09:25:17 +00:00
|
|
|
</text>
|
2009-05-29 10:27:30 +00:00
|
|
|
<empty><stretch>true</stretch></empty>
|
2005-05-15 09:25:17 +00:00
|
|
|
</group>
|
|
|
|
|
2009-05-29 10:27:30 +00:00
|
|
|
<combo>
|
|
|
|
<name>source-selection</name>
|
|
|
|
<halign>fill</halign>
|
|
|
|
<stretch>true</stretch>
|
|
|
|
<property>sim/gui/dialogs/weather-scenario/source-selection</property>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-apply</command>
|
|
|
|
<object-name>source-selection</object-name>
|
|
|
|
</binding>
|
|
|
|
</combo>
|
|
|
|
|
2005-11-04 20:09:31 +00:00
|
|
|
<textbox>
|
2009-05-29 10:27:30 +00:00
|
|
|
<name>description</name>
|
2006-02-24 11:01:17 +00:00
|
|
|
<halign>fill</halign>
|
2009-01-11 00:10:13 +00:00
|
|
|
<stretch>true</stretch>
|
2009-05-29 10:27:30 +00:00
|
|
|
<pref-width>180</pref-width>
|
|
|
|
<pref-height>100</pref-height>
|
2006-02-24 11:01:17 +00:00
|
|
|
<slider>20</slider>
|
2009-05-29 10:27:30 +00:00
|
|
|
<editable>false</editable>
|
|
|
|
<wrap>true</wrap>
|
2005-05-15 09:25:17 +00:00
|
|
|
<live>true</live>
|
2009-05-29 10:27:30 +00:00
|
|
|
<property>sim/gui/dialogs/weather-scenario/description</property>
|
|
|
|
</textbox>
|
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<text>
|
|
|
|
<label>METAR Data</label>
|
|
|
|
</text>
|
|
|
|
<empty><stretch>true</stretch></empty>
|
|
|
|
</group>
|
|
|
|
|
|
|
|
<textbox>
|
|
|
|
<name>metar</name>
|
|
|
|
<halign>fill</halign>
|
|
|
|
<stretch>true</stretch>
|
|
|
|
<pref-width>180</pref-width>
|
|
|
|
<pref-height>50</pref-height>
|
|
|
|
<slider>20</slider>
|
|
|
|
<editable>true</editable>
|
2005-11-04 20:09:31 +00:00
|
|
|
<wrap>true</wrap>
|
2009-05-29 10:27:30 +00:00
|
|
|
<live>true</live>
|
|
|
|
<property>sim/gui/dialogs/weather-scenario/metar</property>
|
2005-11-04 20:09:31 +00:00
|
|
|
</textbox>
|
2005-05-15 09:25:17 +00:00
|
|
|
|
2009-05-29 10:27:30 +00:00
|
|
|
<hrule/>
|
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<empty><stretch>true</stretch></empty>
|
|
|
|
<checkbox>
|
|
|
|
<property>/environment/params/metar-updates-winds-aloft</property>
|
|
|
|
<label>Update winds aloft</label>
|
|
|
|
<name>aloft</name>
|
|
|
|
</checkbox>
|
|
|
|
<empty><stretch>true</stretch></empty>
|
|
|
|
</group>
|
2005-05-15 09:25:17 +00:00
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
2008-12-21 15:54:18 +00:00
|
|
|
|
2005-05-15 09:25:17 +00:00
|
|
|
<empty><stretch>true</stretch></empty>
|
2009-05-29 10:27:30 +00:00
|
|
|
<button>
|
|
|
|
<legend>OK</legend>
|
|
|
|
<default>true</default>
|
|
|
|
<equal>true</equal>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-apply</command>
|
|
|
|
</binding>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-close</command>
|
|
|
|
</binding>
|
|
|
|
</button>
|
2005-05-15 09:25:17 +00:00
|
|
|
|
2008-12-21 15:54:18 +00:00
|
|
|
<button>
|
2009-05-29 10:27:30 +00:00
|
|
|
<legend>Apply</legend>
|
|
|
|
<equal>true</equal>
|
|
|
|
<binding>
|
|
|
|
<command>nasal</command>
|
|
|
|
<script>apply()</script>
|
|
|
|
</binding>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-apply</command>
|
|
|
|
</binding>
|
2008-12-21 15:54:18 +00:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<button>
|
2009-05-29 10:27:30 +00:00
|
|
|
<legend>Instant-Apply</legend>
|
|
|
|
<equal>true</equal>
|
|
|
|
<binding>
|
|
|
|
<command>nasal</command>
|
|
|
|
<script>apply()</script>
|
|
|
|
</binding>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-apply</command>
|
|
|
|
</binding>
|
|
|
|
<binding>
|
|
|
|
<command>reinit</command>
|
|
|
|
<subsystem>environment</subsystem>
|
|
|
|
</binding>
|
2008-12-21 15:54:18 +00:00
|
|
|
</button>
|
|
|
|
|
2005-05-15 09:25:17 +00:00
|
|
|
<button>
|
2009-05-29 10:27:30 +00:00
|
|
|
<legend>Cancel</legend>
|
|
|
|
<equal>true</equal>
|
2005-11-05 18:42:28 +00:00
|
|
|
<key>Esc</key>
|
2005-05-15 09:25:17 +00:00
|
|
|
<binding>
|
|
|
|
<command>dialog-close</command>
|
|
|
|
</binding>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<empty><stretch>true</stretch></empty>
|
|
|
|
</group>
|
2009-05-29 10:27:30 +00:00
|
|
|
|
|
|
|
<nasal>
|
|
|
|
<open><![CDATA[
|
2009-05-29 16:24:10 +00:00
|
|
|
var dlg_root = cmdarg();
|
2009-05-29 10:27:30 +00:00
|
|
|
|
|
|
|
var normalize_string = func(src) {
|
|
|
|
if( src == nil ) src = "";
|
|
|
|
var dst = "";
|
|
|
|
for( var i = 0; i < size(src); i+=1 ) {
|
2009-05-29 16:24:10 +00:00
|
|
|
if( src[i] == `\n` or src[i] == `\r` )
|
|
|
|
src[i] = ` `;
|
2009-05-29 10:27:30 +00:00
|
|
|
|
|
|
|
if( i != 0 and src[i] == 32 and src[i-1] == 32 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
dst = dst ~ " ";
|
|
|
|
dst[size(dst)-1] = src[i];
|
|
|
|
}
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
var findScenarioByName = func(name) {
|
|
|
|
var wsn = props.globals.getNode( "/environment/weather-scenarios" );
|
|
|
|
if( wsn != nil ) {
|
|
|
|
var scenarios = wsn.getChildren("scenario");
|
|
|
|
foreach (var scenario; scenarios ) {
|
|
|
|
if( scenario.getNode("name").getValue() == name )
|
|
|
|
return scenario;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
var propertyChangeListener = setlistener( "sim/gui/dialogs/weather-scenario/source-selection", func(n) {
|
|
|
|
description = "";
|
|
|
|
metar = "nil";
|
|
|
|
var scenario = findScenarioByName( n.getValue() );
|
|
|
|
if( scenario != nil ) {
|
|
|
|
description = normalize_string(scenario.getNode("description", 1 ).getValue());
|
|
|
|
metar = normalize_string(scenario.getNode("metar", 1 ).getValue());
|
|
|
|
}
|
|
|
|
setprop("sim/gui/dialogs/weather-scenario/description", description );
|
|
|
|
setprop("sim/gui/dialogs/weather-scenario/metar", metar );
|
|
|
|
});
|
|
|
|
|
|
|
|
#initialize the METAR source selection
|
|
|
|
if( getprop( "environment/params/metar-updates-environment" ) == 0 ) {
|
|
|
|
setprop("sim/gui/dialogs/weather-scenario/source-selection", "Disabled" );
|
|
|
|
} else if( getprop( "environment/params/real-world-weather-fetch" ) ) {
|
|
|
|
setprop("sim/gui/dialogs/weather-scenario/source-selection", "Live data" );
|
|
|
|
} else {
|
|
|
|
setprop("sim/gui/dialogs/weather-scenario/source-selection", "Manual input" );
|
|
|
|
}
|
|
|
|
setprop( "sim/gui/dialogs/weather-scenario/metar", normalize_string(getprop("environment/metar/data")) );
|
|
|
|
|
|
|
|
|
|
|
|
var findElementByName = func(rootN, name) {
|
|
|
|
foreach( var child; rootN.getChildren() ) {
|
|
|
|
var n = child.getNode( "name" );
|
|
|
|
if( n != nil and n.getValue() == name )
|
|
|
|
return child;
|
|
|
|
var f = findElementByName(child,name);
|
|
|
|
if( f != nil ) return f;
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
};
|
|
|
|
|
|
|
|
# fill the METAR source combo box
|
|
|
|
var combo = findElementByName( dlg_root, "source-selection" );
|
|
|
|
var wsn = props.globals.getNode( "/environment/weather-scenarios" );
|
|
|
|
if( wsn != nil ) {
|
|
|
|
var scenarios = wsn.getChildren("scenario");
|
|
|
|
forindex (var i; scenarios )
|
|
|
|
combo.getChild("value", i, 1).setValue(scenarios[i].getNode("name").getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var apply = func {
|
|
|
|
var scenarioName = getprop("sim/gui/dialogs/weather-scenario/source-selection");
|
|
|
|
var metar = nil;
|
|
|
|
if( scenarioName == "Disabled" ) {
|
|
|
|
setprop( "/environment/params/metar-updates-environment", 0 );
|
|
|
|
setprop( "/environment/params/real-world-weather-fetch", 0 );
|
|
|
|
} else if( scenarioName == "Live data" ) {
|
|
|
|
setprop( "/environment/params/metar-updates-environment", 1 );
|
|
|
|
setprop( "/environment/params/real-world-weather-fetch", 1 );
|
|
|
|
} else if( scenarioName == "Manual input" ) {
|
|
|
|
setprop( "/environment/params/metar-updates-environment", 1 );
|
|
|
|
setprop( "/environment/params/real-world-weather-fetch", 0 );
|
|
|
|
metar = getprop( "sim/gui/dialogs/weather-scenario/metar" );
|
|
|
|
} else {
|
|
|
|
metar = getprop( "sim/gui/dialogs/weather-scenario/metar" );
|
|
|
|
}
|
|
|
|
if( metar != nil )
|
|
|
|
setprop( "environment/metar/data", normalize_string(metar) );
|
|
|
|
}
|
|
|
|
|
|
|
|
]]></open>
|
|
|
|
|
|
|
|
<close><![CDATA[
|
|
|
|
removelistener( propertyChangeListener );
|
|
|
|
]]></close>
|
|
|
|
|
|
|
|
</nasal>
|
2005-05-15 09:25:17 +00:00
|
|
|
</PropertyList>
|