2020-11-27 17:13:47 +00:00
|
|
|
# Octal's Distance Zooming
|
2021-04-23 17:21:07 +00:00
|
|
|
# Copyright (c) 2021 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-11-27 17:13:47 +00:00
|
|
|
var decStep = -5;
|
|
|
|
var incStep = 5;
|
2019-10-14 16:48:35 +00:00
|
|
|
var viewName = "XX";
|
|
|
|
|
|
|
|
var fovZoom = func(d) {
|
2020-11-27 17:13:47 +00:00
|
|
|
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";
|
2019-10-14 16:48:35 +00:00
|
|
|
|
2020-11-27 17:13:47 +00:00
|
|
|
if (pts.Sim.CurrentView.zOffsetM.getValue() <= -50) {
|
|
|
|
decStep = -10;
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-11-27 17:13:47 +00:00
|
|
|
decStep = -5;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 17:13:47 +00:00
|
|
|
if (pts.Sim.CurrentView.zOffsetM.getValue() < -50) { # Not a typo, the conditions are different
|
|
|
|
incStep = 10;
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-11-27 17:13:47 +00:00
|
|
|
incStep = 5;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d == -1) {
|
|
|
|
if (canChangeZOffset) {
|
2020-11-27 17:13:47 +00:00
|
|
|
distance = pts.Sim.CurrentView.zOffsetM.getValue();
|
|
|
|
min_dist = pts.Sim.CurrentView.zOffsetMinM.getValue();
|
2019-10-14 16:48:35 +00:00
|
|
|
|
|
|
|
distance = math.round(std.min(-min_dist, distance + incStep) / incStep, 0.1) * incStep;
|
2020-11-27 17:13:47 +00:00
|
|
|
pts.Sim.CurrentView.zOffsetM.setValue(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-11-27 17:13:47 +00:00
|
|
|
distance = pts.Sim.CurrentView.zOffsetM.getValue();
|
|
|
|
max_dist = pts.Sim.CurrentView.zOffsetMaxM.getValue();
|
2019-10-14 16:48:35 +00:00
|
|
|
|
|
|
|
distance = math.round(std.max(-max_dist, distance + decStep) / decStep, 0.1) * decStep;
|
2020-11-27 17:13:47 +00:00
|
|
|
pts.Sim.CurrentView.zOffsetM.setValue(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-11-27 17:13:47 +00:00
|
|
|
pts.Sim.CurrentView.zOffsetM.setValue(pts.Sim.CurrentView.zOffsetDefault.getValue() * -1);
|
|
|
|
gui.popupTip(sprintf("%d meters", pts.Sim.CurrentView.zOffsetDefault.getValue()));
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-11-27 17:13:47 +00:00
|
|
|
pts.Sim.CurrentView.fieldOfView.setValue(pts.Sim.View.Config.defaultFieldOfViewDeg.getValue());
|
|
|
|
gui.popupTip(sprintf("FOV: %.1f", pts.Sim.CurrentView.fieldOfView.getValue()));
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|