1
0
Fork 0

Fix bug #253, at least partially

make options
--wind=nnn@mm
--visibility
--visibility-miles
--ceiling
--turbulence
work again. These options now write properties in the
/environment/config/presets
branch. The values will be applied in the property-rules
in FGDATA/Environment/interpolator.xml
Corresponds to commit e86cecf4704a4bdcf43114245d8ac94adb1f1eef
in fg/next
This commit is contained in:
Torsten Dreyer 2011-01-19 19:42:40 +01:00
parent 2b648ea118
commit b43b53c977
3 changed files with 78 additions and 4 deletions

View file

@ -73,6 +73,12 @@
<property>/environment/config/enabled</property>
</condition>
</enable>
<input>
<condition>
<property>/environment/config/presets/visibility-m-override</property>
</condition>
<property>/environment/config/presets/visibility-m</property>
</input>
<input>/environment/config/interpolated/visibility-m</input>
<output>/environment/visibility-m</output>
<type>exponential</type>
@ -89,6 +95,12 @@
<property>/environment/config/enabled</property>
</condition>
</enable>
<input>
<condition>
<property>/environment/config/presets/wind-override</property>
</condition>
<property>/environment/config/presets/wind-from-north-fps</property>
</input>
<input>/environment/config/interpolated/wind-from-north-fps</input>
<output>/environment/wind-from-north-fps</output>
<type>exponential</type>
@ -102,6 +114,12 @@
<property>/environment/config/enabled</property>
</condition>
</enable>
<input>
<condition>
<property>/environment/config/presets/wind-override</property>
</condition>
<property>/environment/config/presets/wind-from-east-fps</property>
</input>
<input>/environment/config/interpolated/wind-from-east-fps</input>
<output>/environment/wind-from-east-fps</output>
<type>exponential</type>

45
Nasal/environment.nas Executable file
View file

@ -0,0 +1,45 @@
##
## environment.nas
##
## Nasal code for implementing environment-specific functionality.
##
# Handler. Increase visibility by one step
#
var increaseVisibility = func {
adjustVisibility(1.1);
}
##
# Handler. Decrease visibility by one step
#
var decreaseVisibility = func {
adjustVisibility(0.9);
}
var adjustVisibility = func( factor ) {
var val = visibilityProp.getValue() * factor;
if( val < 1.0 ) val = getprop("/environment/visibility-m");
if( val > 30 ) {
visibilityProp.setDoubleValue(val);
visibilityOverrideProp.setBoolValue(1);
gui.popupTip(sprintf("Visibility: %.0f m", val));
}
}
##
# Handler. Reset visibility to default.
#
var resetVisibility = func {
visibilityProp.setDoubleValue(0);
visibilityOverrideProp.setBoolValue(0);
}
var visibilityProp = nil;
var visibilityOverrideProp = nil;
_setlistener("/sim/signals/nasal-dir-initialized", func {
visibilityProp = props.globals.initNode("/environment/config/presets/visibility-m", 0, "DOUBLE" );
visibilityOverrideProp = props.globals.initNode("/environment/config/presets/visibility-m-override", 0, "BOOL" );
});

View file

@ -255,6 +255,15 @@ top down before the key bindings are parsed.
</binding>
</key>
<key n="26">
<name>Ctrl-Z</name>
<desc>Reset visibility to default</desc>
<binding>
<command>nasal</command>
<script>environment.resetVisibility()</script>
</binding>
</key>
<key n="27">
<name>ESC</name>
<desc>Prompt and quit FlightGear</desc>
@ -765,7 +774,8 @@ top down before the key bindings are parsed.
<desc>Decrease Visibility</desc>
<repeatable type="bool">true</repeatable>
<binding>
<command>decrease-visibility</command>
<command>nasal</command>
<script>environment.decreaseVisibility()</script>
</binding>
</key>
@ -1041,7 +1051,8 @@ top down before the key bindings are parsed.
<desc>Increase Visibility</desc>
<repeatable type="bool">true</repeatable>
<binding>
<command>increase-visibility</command>
<command>nasal</command>
<script>environment.increaseVisibility()</script>
</binding>
</key>