Sim: Update view controller
This commit is contained in:
parent
694c2ea795
commit
9fa94b6982
4 changed files with 87 additions and 86 deletions
|
@ -2247,9 +2247,8 @@
|
|||
<not><property>/FMGC/keyboard-right</property></not>
|
||||
<not><property>/options/system/keyboard-mode</property></not>
|
||||
</condition>
|
||||
<command>property-assign</command>
|
||||
<property>/sim/current-view/view-number</property>
|
||||
<value>0</value>
|
||||
<command>nasal</command>
|
||||
<script>libraries.setView(1);</script>
|
||||
</binding>
|
||||
<binding>
|
||||
<condition>
|
||||
|
@ -2285,9 +2284,8 @@
|
|||
<not><property>/FMGC/keyboard-right</property></not>
|
||||
<not><property>/options/system/keyboard-mode</property></not>
|
||||
</condition>
|
||||
<command>property-assign</command>
|
||||
<property>/sim/current-view/view-number</property>
|
||||
<value>8</value>
|
||||
<command>nasal</command>
|
||||
<script>libraries.setView(2);</script>
|
||||
</binding>
|
||||
<binding>
|
||||
<condition>
|
||||
|
@ -2324,9 +2322,8 @@
|
|||
<not><property>/FMGC/keyboard-right</property></not>
|
||||
<not><property>/options/system/keyboard-mode</property></not>
|
||||
</condition>
|
||||
<command>property-assign</command>
|
||||
<property>/sim/current-view/view-number</property>
|
||||
<value>9</value>
|
||||
<command>nasal</command>
|
||||
<script>libraries.setView(3);</script>
|
||||
</binding>
|
||||
<binding>
|
||||
<condition>
|
||||
|
@ -2363,9 +2360,8 @@
|
|||
<not><property>/FMGC/keyboard-right</property></not>
|
||||
<not><property>/options/system/keyboard-mode</property></not>
|
||||
</condition>
|
||||
<command>property-assign</command>
|
||||
<property>/sim/current-view/view-number</property>
|
||||
<value>10</value>
|
||||
<command>nasal</command>
|
||||
<script>libraries.setView(4);</script>
|
||||
</binding>
|
||||
<binding>
|
||||
<condition>
|
||||
|
@ -2402,9 +2398,8 @@
|
|||
<not><property>/FMGC/keyboard-right</property></not>
|
||||
<not><property>/options/system/keyboard-mode</property></not>
|
||||
</condition>
|
||||
<command>property-assign</command>
|
||||
<property>/sim/current-view/view-number</property>
|
||||
<value>11</value>
|
||||
<command>nasal</command>
|
||||
<script>libraries.setView(5);</script>
|
||||
</binding>
|
||||
<binding>
|
||||
<condition>
|
||||
|
@ -2443,9 +2438,8 @@
|
|||
<not><property>/FMGC/keyboard-right</property></not>
|
||||
<not><property>/options/system/keyboard-mode</property></not>
|
||||
</condition>
|
||||
<command>property-assign</command>
|
||||
<property>/sim/current-view/view-number</property>
|
||||
<value>12</value>
|
||||
<command>nasal</command>
|
||||
<script>libraries.setView(6);</script>
|
||||
</binding>
|
||||
<binding>
|
||||
<condition>
|
||||
|
@ -4663,7 +4657,7 @@
|
|||
<file>Aircraft/A320-family/Nasal/Libraries/custom-views.nas</file>
|
||||
<file>Aircraft/A320-family/Nasal/Libraries/shake.nas</file>
|
||||
<file>Aircraft/A320-family/Nasal/Libraries/sounds.nas</file>
|
||||
<file>Aircraft/A320-family/Nasal/Libraries/zoom-views.nas</file>
|
||||
<file>Aircraft/A320-family/Nasal/Libraries/view-controller.nas</file>
|
||||
</libraries>
|
||||
<acconfig>
|
||||
<file>Aircraft/A320-family/AircraftConfig/acconfig.nas</file>
|
||||
|
|
|
@ -222,6 +222,7 @@ var Sim = {
|
|||
pitchOffsetDeg: props.globals.getNode("/sim/current-view/pitch-offset-deg", 1),
|
||||
rollOffsetDeg: props.globals.getNode("/sim/current-view/roll-offset-deg", 1),
|
||||
type: props.globals.getNode("/sim/current-view/type", 1),
|
||||
viewNumber: props.globals.getNode("/sim/current-view/view-number", 1),
|
||||
viewNumberRaw: props.globals.getNode("/sim/current-view/view-number-raw", 1),
|
||||
zOffsetDefault: props.globals.getNode("/sim/current-view/z-offset-default", 1),
|
||||
xOffsetM: props.globals.getNode("/sim/current-view/x-offset-m", 1),
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
# Custom view positions
|
||||
# Octal's View Controller
|
||||
# Copyright (c) 2021 Josh Davidson (Octal450)
|
||||
# FovZoom based on work by onox
|
||||
|
||||
#########
|
||||
# Views #
|
||||
#########
|
||||
var viewNumberRaw = 0;
|
||||
var fgfsVersion = num(string.replace(getprop("/sim/version/flightgear"), ".", ""));
|
||||
var distance = 0;
|
||||
var min_dist = 0;
|
||||
var max_dist = 0;
|
||||
var canChangeZOffset = 0;
|
||||
var decStep = -5;
|
||||
var incStep = 5;
|
||||
var shakeFlag = 0;
|
||||
var viewName = "XX";
|
||||
var viewNumberRaw = 0;
|
||||
var views = [0, 9, 10, 11, 12, 13];
|
||||
var viewsOld = [0, 8, 9, 10, 11, 12];
|
||||
|
||||
var resetView = func() {
|
||||
viewNumberRaw = pts.Sim.CurrentView.viewNumberRaw.getValue();
|
||||
if (viewNumberRaw == 0 or (viewNumberRaw >= 100 and viewNumberRaw <= 109) or viewNumberRaw == 112) {
|
||||
|
@ -127,3 +136,62 @@ var lightsView = func() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
var setView = func(n) {
|
||||
if (fgfsVersion >= 202040) {
|
||||
pts.Sim.CurrentView.viewNumber.setValue(views[n - 1]);
|
||||
} else {
|
||||
pts.Sim.CurrentView.viewNumber.setValue(viewsOld[n - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
var fovZoom = func(d) {
|
||||
viewName = pts.Sim.CurrentView.name.getValue();
|
||||
canChangeZOffset = pts.Sim.CurrentView.type.getValue() == "lookat" and viewName != "Tower View" and viewName != "Fly-By View" and viewName != "Chase View" and viewName != "Chase View Without Yaw" and viewName != "Walk View";
|
||||
|
||||
if (pts.Sim.CurrentView.zOffsetM.getValue() <= -50) {
|
||||
decStep = -10;
|
||||
} else {
|
||||
decStep = -5;
|
||||
}
|
||||
|
||||
if (pts.Sim.CurrentView.zOffsetM.getValue() < -50) { # Not a typo, the conditions are different
|
||||
incStep = 10;
|
||||
} else {
|
||||
incStep = 5;
|
||||
}
|
||||
|
||||
if (d == -1) {
|
||||
if (canChangeZOffset) {
|
||||
distance = pts.Sim.CurrentView.zOffsetM.getValue();
|
||||
min_dist = pts.Sim.CurrentView.zOffsetMinM.getValue();
|
||||
|
||||
distance = math.round(std.min(-min_dist, distance + incStep) / incStep, 0.1) * incStep;
|
||||
pts.Sim.CurrentView.zOffsetM.setValue(distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.decrease();
|
||||
}
|
||||
} else if (d == 1) {
|
||||
if (canChangeZOffset) {
|
||||
distance = pts.Sim.CurrentView.zOffsetM.getValue();
|
||||
max_dist = pts.Sim.CurrentView.zOffsetMaxM.getValue();
|
||||
|
||||
distance = math.round(std.max(-max_dist, distance + decStep) / decStep, 0.1) * decStep;
|
||||
pts.Sim.CurrentView.zOffsetM.setValue(distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.increase();
|
||||
}
|
||||
} else if (d == 0) {
|
||||
if (canChangeZOffset) {
|
||||
pts.Sim.CurrentView.zOffsetM.setValue(pts.Sim.CurrentView.zOffsetDefault.getValue() * -1);
|
||||
gui.popupTip(sprintf("%d meters", pts.Sim.CurrentView.zOffsetDefault.getValue()));
|
||||
} else {
|
||||
pts.Sim.CurrentView.fieldOfView.setValue(pts.Sim.View.Config.defaultFieldOfViewDeg.getValue());
|
||||
gui.popupTip(sprintf("FOV: %.1f", pts.Sim.CurrentView.fieldOfView.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
# Octal's Distance Zooming
|
||||
# Copyright (c) 2021 Josh Davidson (Octal450)
|
||||
# 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 = pts.Sim.CurrentView.name.getValue();
|
||||
canChangeZOffset = pts.Sim.CurrentView.type.getValue() == "lookat" and viewName != "Tower View" and viewName != "Fly-By View" and viewName != "Chase View" and viewName != "Chase View Without Yaw" and viewName != "Walk View";
|
||||
|
||||
if (pts.Sim.CurrentView.zOffsetM.getValue() <= -50) {
|
||||
decStep = -10;
|
||||
} else {
|
||||
decStep = -5;
|
||||
}
|
||||
|
||||
if (pts.Sim.CurrentView.zOffsetM.getValue() < -50) { # Not a typo, the conditions are different
|
||||
incStep = 10;
|
||||
} else {
|
||||
incStep = 5;
|
||||
}
|
||||
|
||||
if (d == -1) {
|
||||
if (canChangeZOffset) {
|
||||
distance = pts.Sim.CurrentView.zOffsetM.getValue();
|
||||
min_dist = pts.Sim.CurrentView.zOffsetMinM.getValue();
|
||||
|
||||
distance = math.round(std.min(-min_dist, distance + incStep) / incStep, 0.1) * incStep;
|
||||
pts.Sim.CurrentView.zOffsetM.setValue(distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.decrease();
|
||||
}
|
||||
} else if (d == 1) {
|
||||
if (canChangeZOffset) {
|
||||
distance = pts.Sim.CurrentView.zOffsetM.getValue();
|
||||
max_dist = pts.Sim.CurrentView.zOffsetMaxM.getValue();
|
||||
|
||||
distance = math.round(std.max(-max_dist, distance + decStep) / decStep, 0.1) * decStep;
|
||||
pts.Sim.CurrentView.zOffsetM.setValue(distance);
|
||||
|
||||
gui.popupTip(sprintf("%d meters", abs(distance)));
|
||||
} else {
|
||||
view.increase();
|
||||
}
|
||||
} else if (d == 0) {
|
||||
if (canChangeZOffset) {
|
||||
pts.Sim.CurrentView.zOffsetM.setValue(pts.Sim.CurrentView.zOffsetDefault.getValue() * -1);
|
||||
gui.popupTip(sprintf("%d meters", pts.Sim.CurrentView.zOffsetDefault.getValue()));
|
||||
} else {
|
||||
pts.Sim.CurrentView.fieldOfView.setValue(pts.Sim.View.Config.defaultFieldOfViewDeg.getValue());
|
||||
gui.popupTip(sprintf("FOV: %.1f", pts.Sim.CurrentView.fieldOfView.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue