Thorsten wrote in Sat Sep 15, 2018 5:48 pm:The launcher thing is probably easy - one of you can have a go at it - look closely at everything that calls set_tile() - probably the call is duplicated when the property set by the launcher changes to true in-sim.
onApply: {
// important that we always set a value here, to override
// the auto-saved value in FlightGear. Otherwise we get
// confusing behaviour when the user toggles the setting
// inside the sim
_config.setProperty("/nasal/local_weather/enabled", advancedWeather.checked);
// Thorsten R advises that these are also needed for AW to startup
// correctly.
if (advancedWeather.checked) {
_config.setProperty("/sim/gui/dialogs/metar/mode/global-weather", !advancedWeather.checked);
_config.setProperty("/sim/gui/dialogs/metar/mode/local-weather", advancedWeather.checked);
_config.setProperty("/sim/gui/dialogs/metar/mode/manual-weather", advancedWeather.checked);
}
var index = weatherScenario.selectedIndex;
// set description from the weather scenarios, so Local-weather
// can run the appropriate simulation
if (fetchMetar.checked) {
if (advancedWeather.checked) {
_config.setProperty("/local-weather/tmp/tile-management", "METAR");
_config.setProperty("/local-weather/tmp/tile-type", "live");
}
} else {
if (weatherScenario.isCustomMETAR) {
_config.setArg("metar", customMETAR.value)
} else {
_config.setArg("metar", _weatherScenarios.metarForItem(index))
}
// either way, set the scenario name since Local-Weather keys off
// this to know what to do with the scenario + metar data
_config.setProperty("/environment/weather-scenario",
_weatherScenarios.nameForItem(index))
if (advancedWeather.checked) {
// set AW tile options
var s = _weatherScenarios.localWeatherData(index);
if (s.length === 0) {
console.warn("Weather scenario " + _weatherScenarios.nameForItem(index)
+ " does not specify local weather data");
} else {
_config.setProperty("/local-weather/tmp/tile-management", s[0]);
_config.setProperty("/local-weather/tmp/tile-type", s[1]);
}
} // of using Advanced (local) weather
} // of not using real-wxr
}
apply : func {
var scenarioName = getprop( me.base ~ "/source-selection");
var metar = getprop( "environment/metar/data" );
var global_weather_enabled = getprop( me.base ~ "/mode/global-weather");
var local_weather_enabled = getprop( me.base ~ "/mode/local-weather");
var manual_weather_enabled = getprop( me.base ~ "/mode/manual-weather");
# General weather settings based on scenario
if (manual_weather_enabled == 1) {
setprop( "/environment/params/metar-updates-environment", 0 );
setprop( "/environment/realwx/enabled", 0 );
setprop( "/environment/config/enabled", 1 );
metar = "";
} else if( scenarioName == "Live data" ) {
setprop( "/environment/params/metar-updates-environment", 1 );
setprop( "/environment/realwx/enabled", 1 );
setprop( "/environment/config/enabled", 1 );
} else if( scenarioName == "Manual input" ) {
setprop( "/environment/params/metar-updates-environment", 1 );
setprop( "/environment/realwx/enabled", 0 );
setprop( "/environment/config/enabled", 1 );
metar = getprop( me.base ~ "/metar-string" );
setprop("/environment/weather-scenario", scenarioName);
} else {
setprop( "/environment/params/metar-updates-environment", 1 );
setprop( "/environment/realwx/enabled", 0 );
setprop( "/environment/config/enabled", 1 );
metar = getprop( me.base ~ "/metar-string" );
setprop("/environment/weather-scenario", scenarioName);
}
if( metar != nil ) {
setprop( "environment/metar/data", normalize_string(metar) );
}
# Clear any local weather that might be running
if (getprop("/nasal/local_weather/loaded")) local_weather.clear_all();
setprop("/nasal/local_weather/enabled", "false");
if (local_weather_enabled) {
# If Local Weather is enabled, re-initialize with updated
# initial tile and tile selection.
setprop("/nasal/local_weather/enabled", "true");
# Re-initialize local weather.
settimer( func {local_weather.set_tile();}, 0.2);
}
},
# Re-initialize local weather.
settimer( func {local_weather.set_tile();}, 0.2); i
Users browsing this forum: No registered users and 1 guest