2019-10-18 01:17:44 +00:00
|
|
|
# Distance Zooming
|
2020-04-18 05:36:46 +00:00
|
|
|
# Copyright (c) 2020 Josh Davidson (Octal450)
|
2019-10-14 16:48:35 +00:00
|
|
|
# Based on PropertyRule file by onox
|
|
|
|
|
|
|
|
var distance = 0;
|
|
|
|
var min_dist = 0;
|
|
|
|
var max_dist = 0;
|
|
|
|
var canChangeZOffset = 0;
|
2020-05-24 20:21:51 +00:00
|
|
|
var decStep = -1;
|
|
|
|
var incStep = 1;
|
2019-10-14 16:48:35 +00:00
|
|
|
var viewName = "XX";
|
|
|
|
|
|
|
|
var fovZoom = func(d) {
|
2020-02-07 16:10:54 +00:00
|
|
|
viewName = getprop("sim/current-view/name");
|
2020-03-14 16:58:02 +00:00
|
|
|
canChangeZOffset = getprop("sim/current-view/type") == "lookat" and viewName != "Tower View" and viewName != "Tower View AGL" and viewName != "Fly-By View" and viewName != "Chase View" and viewName != "Chase View Without Yaw" and viewName != "Walk View" and viewName != "Walker Orbit View";
|
2019-10-14 16:48:35 +00:00
|
|
|
|
2020-02-07 17:52:34 +00:00
|
|
|
if (getprop("sim/current-view/z-offset-m") <= -20) {
|
|
|
|
decStep = -2;
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-02-07 17:52:34 +00:00
|
|
|
decStep = -1;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
2020-02-07 17:52:34 +00:00
|
|
|
if (getprop("sim/current-view/z-offset-m") < -20) { # Not a typo, the conditions are different
|
|
|
|
incStep = 2;
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-02-07 17:52:34 +00:00
|
|
|
incStep = 1;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d == -1) {
|
|
|
|
if (canChangeZOffset) {
|
2020-02-07 16:10:54 +00:00
|
|
|
distance = getprop("sim/current-view/z-offset-m");
|
|
|
|
min_dist = getprop("sim/current-view/z-offset-min-m");
|
2019-10-14 16:48:35 +00:00
|
|
|
|
|
|
|
distance = math.round(std.min(-min_dist, distance + incStep) / incStep, 0.1) * incStep;
|
2020-02-07 16:10:54 +00:00
|
|
|
setprop("sim/current-view/z-offset-m", distance);
|
2019-10-14 16:48:35 +00:00
|
|
|
|
|
|
|
gui.popupTip(sprintf("%d meters", abs(distance)));
|
|
|
|
} else {
|
|
|
|
view.decrease();
|
|
|
|
}
|
|
|
|
} else if (d == 1) {
|
|
|
|
if (canChangeZOffset) {
|
2020-02-07 16:10:54 +00:00
|
|
|
distance = getprop("sim/current-view/z-offset-m");
|
|
|
|
max_dist = getprop("sim/current-view/z-offset-max-m");
|
2019-10-14 16:48:35 +00:00
|
|
|
|
|
|
|
distance = math.round(std.max(-max_dist, distance + decStep) / decStep, 0.1) * decStep;
|
2020-02-07 16:10:54 +00:00
|
|
|
setprop("sim/current-view/z-offset-m", distance);
|
2019-10-14 16:48:35 +00:00
|
|
|
|
|
|
|
gui.popupTip(sprintf("%d meters", abs(distance)));
|
|
|
|
} else {
|
|
|
|
view.increase();
|
|
|
|
}
|
|
|
|
} else if (d == 0) {
|
|
|
|
if (canChangeZOffset) {
|
2020-02-07 16:10:54 +00:00
|
|
|
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")));
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-02-07 16:10:54 +00:00
|
|
|
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")))
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|