1
0
Fork 0

FG1000 - make Debug menu items more efficient

Previously a completely new PFD or MFD was created when the Debug
menu items were used.  This cause significant slowdown if used
multiple times.  Now we just create one instance of each and re-use it.

Also clean up redundant code in the GUI.
This commit is contained in:
Stuart Buchanan 2020-05-26 22:20:38 +01:00
parent d9244ac724
commit 07c21660d8
2 changed files with 16 additions and 23 deletions

View file

@ -132,12 +132,6 @@ var GUI =
obj.window.setCanvas(inset);
obj.window.del = func() {
# Over-ride the window.del function so we clean up when the user closes the window
# Use call method to ensure we have the correct closure.
call(obj.cleanup, [], obj);
};
# Add a event listener for the mouse wheel, which is used for turning the
# knobs.
inset.addEventListener("wheel", func(e)
@ -192,13 +186,4 @@ var GUI =
return obj;
},
cleanup : func()
{
# Clean up the MFD. Particularly important to stop it picking up
# Emesary notifications.
me.mfd.del();
# Clean up the window itself
call(canvas.Window.del, [], me.window);
},
};

View file

@ -838,13 +838,17 @@
if (! defined("fg1000")) {
io.load_nasal(nasal_dir ~ 'FG1000.nas', "fg1000");
io.load_nasal(nasal_dir ~ 'Interfaces/GenericInterfaceController.nas', "fg1000");
var interfaceController = fg1000.GenericInterfaceController.getOrCreateInstance();
interfaceController.start();
}
var interfaceController = fg1000.GenericInterfaceController.getOrCreateInstance();
interfaceController.start();
var fg1000system = fg1000.FG1000.getOrCreateInstance();
var pfdindex = fg1000system.addPFD();
var pfdindex = getprop("/sim/gui/fg1000/pfd-index");
if (pfdindex == nil) {
pfdindex = fg1000system.addPFD();
setprop("/sim/gui/fg1000/pfd-index", pfdindex);
}
fg1000system.displayGUI(pfdindex);
</script>
@ -860,13 +864,17 @@
if (! defined("fg1000")) {
io.load_nasal(nasal_dir ~ 'FG1000.nas', "fg1000");
io.load_nasal(nasal_dir ~ 'Interfaces/GenericInterfaceController.nas', "fg1000");
var interfaceController = fg1000.GenericInterfaceController.getOrCreateInstance();
interfaceController.start();
}
var interfaceController = fg1000.GenericInterfaceController.getOrCreateInstance();
interfaceController.start();
var fg1000system = fg1000.FG1000.getOrCreateInstance();
var mfdindex = fg1000system.addMFD();
var mfdindex = getprop("/sim/gui/fg1000/mfd-index");
if (mfdindex == nil) {
mfdindex = fg1000system.addPFD();
setprop("/sim/gui/fg1000/mfd-index", mfdindex);
}
fg1000system.displayGUI(mfdindex);
</script>