Sim: View system major bugfix/overhaul
This commit is contained in:
parent
2e9f12f8a1
commit
7a3e31c526
4 changed files with 70 additions and 154 deletions
|
@ -160,9 +160,6 @@
|
|||
<path>Aircraft/IDG-A32X/Systems/pfd.xml</path>
|
||||
</autopilot>
|
||||
<!-- 10 is sound -->
|
||||
<autopilot n="11">
|
||||
<path>Aircraft/IDG-A32X/Systems/zoom-views.xml</path>
|
||||
</autopilot>
|
||||
</systems>
|
||||
|
||||
<sounde>
|
||||
|
@ -383,10 +380,6 @@
|
|||
<gui n="0" include="Systems/it-gui.xml"/>
|
||||
|
||||
<current-view>
|
||||
<z-offset-dec-step type="double">0.0</z-offset-dec-step>
|
||||
<z-offset-inc-step type="double">0.0</z-offset-inc-step>
|
||||
<can-change-z-offset type="bool">false</can-change-z-offset>
|
||||
|
||||
<z-offset-default type="float">80.0</z-offset-default>
|
||||
<z-offset-min-m type="float">30.0</z-offset-min-m>
|
||||
<z-offset-max-m type="float">300.0</z-offset-max-m>
|
||||
|
@ -1016,18 +1009,7 @@
|
|||
</condition>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
if (getprop("/sim/current-view/can-change-z-offset")) {
|
||||
var distance = getprop("/sim/current-view/z-offset-m");
|
||||
var multiple = getprop("/sim/current-view/z-offset-inc-step");
|
||||
var min_dist = getprop("/sim/current-view/z-offset-min-m");
|
||||
|
||||
distance = math.round(std.min(-min_dist, distance + multiple) / multiple) * multiple;
|
||||
setprop("/sim/current-view/z-offset-m", distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.decrease();
|
||||
}
|
||||
libraries.fovZoom(-1);
|
||||
</script>
|
||||
</binding>
|
||||
</button>
|
||||
|
@ -1044,18 +1026,7 @@
|
|||
</condition>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
if (getprop("/sim/current-view/can-change-z-offset")) {
|
||||
var distance = getprop("/sim/current-view/z-offset-m");
|
||||
var multiple = getprop("/sim/current-view/z-offset-dec-step");
|
||||
var max_dist = getprop("/sim/current-view/z-offset-max-m");
|
||||
|
||||
distance = math.round(std.max(-max_dist, distance + multiple) / multiple) * multiple;
|
||||
setprop("/sim/current-view/z-offset-m", distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.increase();
|
||||
}
|
||||
libraries.fovZoom(1);
|
||||
</script>
|
||||
</binding>
|
||||
</button>
|
||||
|
@ -1090,15 +1061,7 @@
|
|||
<desc>Reset zoom to default</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
if (getprop("/sim/current-view/can-change-z-offset")) {
|
||||
setprop("/sim/current-view/z-offset-m", getprop("/sim/current-view/z-offset-default") * -1);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", getprop("/sim/current-view/z-offset-default")));
|
||||
} else {
|
||||
setprop("/sim/current-view/field-of-view", getprop("/sim/view/config/default-field-of-view-deg"));
|
||||
}
|
||||
</script>
|
||||
<script>libraries.fovZoom(0);</script>
|
||||
</binding>
|
||||
</key>
|
||||
<key n="33">
|
||||
|
@ -1345,20 +1308,7 @@
|
|||
<repeatable type="bool">true</repeatable>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
if (getprop("/sim/current-view/can-change-z-offset")) {
|
||||
var distance = getprop("/sim/current-view/z-offset-m");
|
||||
var multiple = getprop("/sim/current-view/z-offset-dec-step");
|
||||
var max_dist = getprop("/sim/current-view/z-offset-max-m");
|
||||
|
||||
distance = math.round(std.max(-max_dist, distance + multiple) / multiple) * multiple;
|
||||
setprop("/sim/current-view/z-offset-m", distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.increase();
|
||||
}
|
||||
</script>
|
||||
<script>libraries.fovZoom(1);</script>
|
||||
</binding>
|
||||
</key>
|
||||
<key n="120">
|
||||
|
@ -1367,20 +1317,7 @@
|
|||
<repeatable type="bool">true</repeatable>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
if (getprop("/sim/current-view/can-change-z-offset")) {
|
||||
var distance = getprop("/sim/current-view/z-offset-m");
|
||||
var multiple = getprop("/sim/current-view/z-offset-inc-step");
|
||||
var min_dist = getprop("/sim/current-view/z-offset-min-m");
|
||||
|
||||
distance = math.round(std.min(-min_dist, distance + multiple) / multiple) * multiple;
|
||||
setprop("/sim/current-view/z-offset-m", distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.decrease();
|
||||
}
|
||||
</script>
|
||||
<script>libraries.fovZoom(-1);</script>
|
||||
</binding>
|
||||
</key>
|
||||
<key n="127">
|
||||
|
@ -1509,6 +1446,7 @@
|
|||
<file>Aircraft/IDG-A32X/Nasal/ECAM.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/shake.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/light-manager.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/zoom-views.nas</file>
|
||||
</libraries>
|
||||
<acconfig>
|
||||
<file>Aircraft/IDG-A32X/AircraftConfig/acconfig.nas</file>
|
||||
|
|
62
Nasal/zoom-views.nas
Normal file
62
Nasal/zoom-views.nas
Normal file
|
@ -0,0 +1,62 @@
|
|||
# IDG Distance Zooming
|
||||
# Copyright (c) 2018 Joshua Davidson (it0uchpods)
|
||||
# Based on PropertyRule file by onox
|
||||
|
||||
var distance = 0;
|
||||
var min_dist = 0;
|
||||
var max_dist = 0;
|
||||
var canChangeZOffset = 0;
|
||||
var decStep = -5;
|
||||
var incStep = 5;
|
||||
var viewName = "XX";
|
||||
|
||||
var fovZoom = func(d) {
|
||||
viewName = getprop("/sim/current-view/name");
|
||||
canChangeZOffset = getprop("/sim/current-view/type") == "lookat" and (viewName != "Tower View" or viewName != "Fly-By View" or viewName != "Chase View" or viewName != "Chase View Without Yaw" or viewName != "Walk View");
|
||||
|
||||
if (getprop("/sim/current-view/z-offset-m") <= -50) {
|
||||
decStep = -10;
|
||||
} else {
|
||||
decStep = -5;
|
||||
}
|
||||
|
||||
if (getprop("/sim/current-view/z-offset-m") < -50) { # Not a typo, the conditions are different
|
||||
incStep = 10;
|
||||
} else {
|
||||
incStep = 5;
|
||||
}
|
||||
|
||||
if (d == -1) {
|
||||
if (canChangeZOffset) {
|
||||
distance = getprop("/sim/current-view/z-offset-m");
|
||||
min_dist = getprop("/sim/current-view/z-offset-min-m");
|
||||
|
||||
distance = math.round(std.min(-min_dist, distance + incStep) / incStep, 0.1) * incStep;
|
||||
setprop("/sim/current-view/z-offset-m", distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.decrease();
|
||||
}
|
||||
} else if (d == 1) {
|
||||
if (canChangeZOffset) {
|
||||
distance = getprop("/sim/current-view/z-offset-m");
|
||||
max_dist = getprop("/sim/current-view/z-offset-max-m");
|
||||
|
||||
distance = math.round(std.max(-max_dist, distance + decStep) / decStep, 0.1) * decStep;
|
||||
setprop("/sim/current-view/z-offset-m", distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.increase();
|
||||
}
|
||||
} else if (d == 0) {
|
||||
if (canChangeZOffset) {
|
||||
setprop("/sim/current-view/z-offset-m", getprop("/sim/current-view/z-offset-default") * -1);
|
||||
gui.popupTip(sprintf("%d meters", getprop("/sim/current-view/z-offset-default")));
|
||||
} else {
|
||||
setprop("/sim/current-view/field-of-view", getprop("/sim/view/config/default-field-of-view-deg"));
|
||||
gui.popupTip(sprintf("FOV: %.1f", getprop("/sim/current-view/field-of-view")))
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- IDG Distance Zooming -->
|
||||
<!-- Copyright (c) 2015-2017 onox -->
|
||||
<!-- Modified by Joshua Davidson (it0uchpods) -->
|
||||
|
||||
<PropertyList>
|
||||
|
||||
<logic>
|
||||
<name>View Zoom Enabled</name>
|
||||
<input>
|
||||
<and>
|
||||
<equals>
|
||||
<property>/sim/current-view/type</property>
|
||||
<value>lookat</value>
|
||||
</equals>
|
||||
<not-equals>
|
||||
<property>/sim/current-view/name</property>
|
||||
<value>Tower View</value>
|
||||
</not-equals>
|
||||
<not-equals>
|
||||
<property>/sim/current-view/name</property>
|
||||
<value>Fly-By View</value>
|
||||
</not-equals>
|
||||
<not-equals>
|
||||
<property>/sim/current-view/name</property>
|
||||
<value>Chase View</value>
|
||||
</not-equals>
|
||||
<not-equals>
|
||||
<property>/sim/current-view/name</property>
|
||||
<value>Chase View Without Yaw</value>
|
||||
</not-equals>
|
||||
<not-equals>
|
||||
<property>/sim/current-view/name</property>
|
||||
<value>Walk View</value>
|
||||
</not-equals>
|
||||
</and>
|
||||
</input>
|
||||
<output>
|
||||
<property>/sim/current-view/can-change-z-offset</property>
|
||||
</output>
|
||||
</logic>
|
||||
|
||||
<filter>
|
||||
<name>View Zoom Decrease Step</name>
|
||||
<type>gain</type>
|
||||
<input>
|
||||
<condition>
|
||||
<less-than-equals>
|
||||
<property>/sim/current-view/z-offset-m</property>
|
||||
<value>-50.0</value>
|
||||
</less-than-equals>
|
||||
</condition>
|
||||
<value>-10.0</value>
|
||||
</input>
|
||||
<input>
|
||||
<value>-5.0</value>
|
||||
</input>
|
||||
<output>
|
||||
<property>/sim/current-view/z-offset-dec-step</property>
|
||||
</output>
|
||||
</filter>
|
||||
|
||||
<filter>
|
||||
<name>View Zoom Increase Step</name>
|
||||
<type>gain</type>
|
||||
<input>
|
||||
<condition>
|
||||
<less-than>
|
||||
<property>/sim/current-view/z-offset-m</property>
|
||||
<value>-50.0</value>
|
||||
</less-than>
|
||||
</condition>
|
||||
<value>10.0</value>
|
||||
</input>
|
||||
<input>
|
||||
<value>5.0</value>
|
||||
</input>
|
||||
<output>
|
||||
<property>/sim/current-view/z-offset-inc-step</property>
|
||||
</output>
|
||||
</filter>
|
||||
|
||||
</PropertyList>
|
|
@ -1 +1 @@
|
|||
4667
|
||||
4668
|
Reference in a new issue