From 768e11d0a6001e9d590bf75e9ed4f5b5e0b34418 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Sun, 25 Apr 2021 16:39:00 +0100 Subject: [PATCH] Nasal/view.nas: Allow view to be changed by setting /sim/current-view/view-number-raw. This avoids problems when/if new default views numbers (between 0 and 99) are added. --- Nasal/view.nas | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Nasal/view.nas b/Nasal/view.nas index 0dc47a83c..d17ae1c0b 100644 --- a/Nasal/view.nas +++ b/Nasal/view.nas @@ -942,6 +942,20 @@ setlistener("/sim/current-view/view-number", func(n) { current = views[index = n.getValue()]; }, 1); +# Allow view changes by setting view-number-raw - avoids problems when/if we +# add new default views (between 0 and 99). +# +setlistener("/sim/current-view/view-number-raw", func(n) { + var index = n.getValue(); + forindex (var i; views) { + if (views[i].getIndex() == index) { + props.globals.getNode("/sim/current-view/view-number", 1).setValue(i); + return; + } + } + printf("Failed to find view-number-raw=%s", index); +}, 1); + props.globals.initNode("/position/altitude-agl-ft"); # needed by Fly-By View screenWidthCompens.init(); manager.init();