2003-12-22 20:05:18 +00:00
|
|
|
##
|
|
|
|
# Pop up a "tip" dialog for a moment, then remove it. The delay in
|
|
|
|
# seconds can be specified as the second argument. The default is 1
|
|
|
|
# second. Note that the tip dialog is a shared resource. If
|
|
|
|
# someone else comes along and wants to pop a tip up before your delay
|
|
|
|
# is finished, you lose. :)
|
|
|
|
#
|
|
|
|
popupTip = func {
|
|
|
|
delay = if(size(arg) > 1) {arg[1]} else {DELAY};
|
2004-05-12 18:41:29 +00:00
|
|
|
tmpl = { name : "PopTip", modal : 0, layout : "hbox",
|
|
|
|
y: screenHProp.getValue() - 140,
|
|
|
|
text : { label : arg[0], padding : 6 } };
|
2003-12-22 20:05:18 +00:00
|
|
|
|
|
|
|
popdown();
|
2004-05-12 18:41:29 +00:00
|
|
|
fgcommand("dialog-new", props.Node.new(tmpl));
|
2003-12-22 20:05:18 +00:00
|
|
|
fgcommand("dialog-show", tipArg);
|
|
|
|
|
|
|
|
currTimer = currTimer + 1;
|
|
|
|
thisTimer = currTimer;
|
2005-11-09 20:35:07 +00:00
|
|
|
|
|
|
|
# Final argument is a flag to use "real" time, not simulated time
|
|
|
|
settimer(func { if(currTimer == thisTimer) { popdown() } }, DELAY, 1);
|
2003-12-22 20:05:18 +00:00
|
|
|
}
|
|
|
|
|
2004-05-15 21:50:51 +00:00
|
|
|
showDialog = func {
|
|
|
|
fgcommand("dialog-show",
|
|
|
|
props.Node.new({ "dialog-name" : arg[0]}));
|
|
|
|
}
|
|
|
|
|
2005-12-09 10:34:43 +00:00
|
|
|
##
|
|
|
|
# Enable/disable named menu entry
|
|
|
|
#
|
2006-02-24 11:11:09 +00:00
|
|
|
menuEnable = func(searchname, state) {
|
2005-12-09 10:34:43 +00:00
|
|
|
foreach (menu; props.globals.getNode("/sim/menubar/default").getChildren("menu")) {
|
2006-02-24 11:11:09 +00:00
|
|
|
foreach (name; menu.getChildren("name")) {
|
|
|
|
if (name.getValue() == searchname) {
|
|
|
|
menu.getNode("enabled").setBoolValue(state);
|
|
|
|
}
|
2005-12-09 10:34:43 +00:00
|
|
|
}
|
|
|
|
foreach (item; menu.getChildren("item")) {
|
2006-02-24 11:11:09 +00:00
|
|
|
foreach (name; item.getChildren("name")) {
|
|
|
|
if (name.getValue() == searchname) {
|
|
|
|
item.getNode("enabled").setBoolValue(state);
|
|
|
|
}
|
2005-12-09 10:34:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-12-22 20:05:18 +00:00
|
|
|
########################################################################
|
|
|
|
# Private Stuff:
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
##
|
|
|
|
# Initialize property nodes via a timer, to insure the props module is
|
2004-05-12 18:41:29 +00:00
|
|
|
# loaded. See notes in view.nas. Simply cache the screen height
|
|
|
|
# property and the argument for the "dialog-show" command. This
|
|
|
|
# probably isn't really needed...
|
2003-12-22 20:05:18 +00:00
|
|
|
#
|
2005-12-16 19:15:08 +00:00
|
|
|
screenHProp = tipArg = nil;
|
2003-12-22 20:05:18 +00:00
|
|
|
INIT = func {
|
|
|
|
screenHProp = props.globals.getNode("/sim/startup/ysize");
|
|
|
|
tipArg = props.Node.new({ "dialog-name" : "PopTip" });
|
2005-04-19 13:43:44 +00:00
|
|
|
|
|
|
|
props.globals.getNode("/sim/help/debug", 1).setValues(debug_keys);
|
|
|
|
props.globals.getNode("/sim/help/basic", 1).setValues(basic_keys);
|
|
|
|
props.globals.getNode("/sim/help/common", 1).setValues(common_aircraft_keys);
|
2005-12-06 17:57:41 +00:00
|
|
|
|
2005-12-11 15:38:35 +00:00
|
|
|
# enable/disable menu entries
|
2005-12-09 10:34:43 +00:00
|
|
|
menuEnable("fuel-and-payload", getprop("/sim/flight-model") == "yasim");
|
|
|
|
menuEnable("autopilot", props.globals.getNode("/autopilot/KAP140/locks") == nil);
|
2007-03-24 13:32:15 +00:00
|
|
|
menuEnable("tutorial-start", size(props.globals.getNode("/sim/tutorials").getChildren("tutorial")));
|
2006-10-21 10:19:24 +00:00
|
|
|
menuEnable("joystick-info", size(props.globals.getNode("/input/joysticks").getChildren("js")));
|
2005-12-15 22:00:31 +00:00
|
|
|
|
2006-01-28 11:17:04 +00:00
|
|
|
var fps = props.globals.getNode("/sim/rendering/fps-display", 1);
|
2006-02-02 18:04:59 +00:00
|
|
|
setlistener(fps, fpsDisplay, 1);
|
|
|
|
setlistener("/sim/startup/xsize",
|
|
|
|
func { if (fps.getValue()) { fpsDisplay(0); fpsDisplay(1) } });
|
2003-12-22 20:05:18 +00:00
|
|
|
}
|
2006-04-06 09:49:49 +00:00
|
|
|
settimer(INIT, 1);
|
2003-12-22 20:05:18 +00:00
|
|
|
|
2005-12-09 10:34:43 +00:00
|
|
|
|
2005-12-15 22:00:31 +00:00
|
|
|
##
|
|
|
|
# Show/hide the fps display dialog.
|
|
|
|
#
|
2007-03-29 19:32:59 +00:00
|
|
|
fpsDisplay = func {
|
|
|
|
var w = (caller(0)[0]["arg"] == nil) ? cmdarg().getBoolValue() : arg[0];
|
2006-01-28 11:17:04 +00:00
|
|
|
fgcommand(w ? "dialog-show" : "dialog-close", props.Node.new({"dialog-name": "fps"}));
|
2005-12-15 22:00:31 +00:00
|
|
|
}
|
|
|
|
|
2005-12-09 10:34:43 +00:00
|
|
|
|
2003-12-22 20:05:18 +00:00
|
|
|
##
|
|
|
|
# How many seconds do we show the tip?
|
|
|
|
#
|
|
|
|
DELAY = 1.0;
|
|
|
|
|
|
|
|
##
|
|
|
|
# Pop down the tip dialog, if it is visible.
|
|
|
|
#
|
|
|
|
popdown = func { fgcommand("dialog-close", tipArg); }
|
|
|
|
|
|
|
|
# Marker for the "current" timer. This value gets stored in the
|
|
|
|
# closure of the timer function, and is used to check that there
|
|
|
|
# hasn't been a more recent timer set that should override.
|
|
|
|
currTimer = 0;
|
2004-05-15 21:50:51 +00:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Widgets & Layout Management
|
|
|
|
########################################################################
|
|
|
|
|
2005-04-19 13:43:44 +00:00
|
|
|
##
|
2004-05-15 21:50:51 +00:00
|
|
|
# A "widget" class that wraps a property node. It provides useful
|
|
|
|
# helper methods that are difficult or tedious with the raw property
|
|
|
|
# API. Note especially the slightly tricky addChild() method.
|
|
|
|
#
|
|
|
|
Widget = {
|
|
|
|
set : func { me.node.getNode(arg[0], 1).setValue(arg[1]); },
|
|
|
|
prop : func { return me.node; },
|
|
|
|
new : func { return { parents : [Widget], node : props.Node.new() } },
|
|
|
|
addChild : func {
|
|
|
|
type = arg[0];
|
|
|
|
idx = size(me.node.getChildren(type));
|
|
|
|
name = type ~ "[" ~ idx ~ "]";
|
|
|
|
newnode = me.node.getNode(name, 1);
|
|
|
|
return { parents : [Widget], node : newnode };
|
2005-05-02 16:00:13 +00:00
|
|
|
},
|
2005-05-03 13:45:33 +00:00
|
|
|
setColor : func(r, g, b, a = 1) {
|
|
|
|
me.node.setValues({ color : { red:r, green:g, blue:b, alpha:a } });
|
|
|
|
},
|
|
|
|
setFont : func(n, s = 13, t = 0) {
|
|
|
|
me.node.setValues({ font : { name:n, "size":s, slant:t } });
|
2005-05-02 16:00:13 +00:00
|
|
|
},
|
2006-08-24 12:44:14 +00:00
|
|
|
setBinding : func(cmd, carg = nil) {
|
|
|
|
var idx = size(me.node.getChildren("binding"));
|
|
|
|
var node = me.node.getChild("binding", idx, 1);
|
|
|
|
node.getNode("command", 1).setValue(cmd);
|
|
|
|
if (cmd == "nasal") {
|
|
|
|
node.getNode("script", 1).setValue(carg);
|
|
|
|
} elsif (carg != nil and (cmd == "dialog-apply" or cmd == "dialog-update")) {
|
|
|
|
node.getNode("object-name", 1).setValue(carg);
|
|
|
|
}
|
|
|
|
},
|
2004-05-15 21:50:51 +00:00
|
|
|
};
|
|
|
|
|
2005-05-02 16:00:13 +00:00
|
|
|
|
2006-08-24 16:32:09 +00:00
|
|
|
|
2006-07-14 16:03:43 +00:00
|
|
|
##
|
2006-08-24 16:32:09 +00:00
|
|
|
# Dialog class. Maintains one XML dialog.
|
2006-07-14 16:03:43 +00:00
|
|
|
#
|
2007-06-04 12:42:29 +00:00
|
|
|
# SYNOPSIS:
|
|
|
|
# (B) Dialog.new(<dialog-name>); ... use dialog from $FG_ROOT/gui/dialogs/
|
2007-06-14 23:19:43 +00:00
|
|
|
#
|
|
|
|
# (A) Dialog.new(<prop>, <path> [, <dialog-name>]);
|
|
|
|
# ... load aircraft specific dialog from
|
|
|
|
# <path> under property <prop> and under
|
|
|
|
# name <dialog-name>; if no name is given,
|
|
|
|
# then it's taken from the XML dialog
|
2007-06-04 12:42:29 +00:00
|
|
|
#
|
|
|
|
# prop ... target node (name must be "dialog")
|
|
|
|
# path ... file path relative to $FG_ROOT
|
|
|
|
# dialog-name ... dialog <name> of dialog in $FG_ROOT/gui/dialogs/
|
|
|
|
#
|
|
|
|
# EXAMPLES:
|
2006-07-14 16:03:43 +00:00
|
|
|
#
|
2006-08-24 16:32:09 +00:00
|
|
|
# var dlg = gui.Dialog.new("/sim/gui/dialogs/foo-config/dialog",
|
|
|
|
# "Aircraft/foo/foo_config.xml");
|
|
|
|
# dlg.open();
|
|
|
|
# dlg.close();
|
2006-07-14 16:03:43 +00:00
|
|
|
#
|
2007-06-04 12:42:29 +00:00
|
|
|
# var livery_dialog = gui.Dialog.new("livery-select");
|
|
|
|
# livery_dialog.toggle();
|
|
|
|
#
|
2006-08-24 16:32:09 +00:00
|
|
|
Dialog = {
|
2007-06-14 23:19:43 +00:00
|
|
|
new : func(prop, path = nil, name = nil) {
|
2006-08-24 16:32:09 +00:00
|
|
|
var m = { parents : [Dialog] };
|
|
|
|
m.state = 0;
|
2007-06-04 12:42:29 +00:00
|
|
|
if (path == nil) { # global dialog in $FG_ROOT/gui/dialogs/
|
2007-06-18 15:34:36 +00:00
|
|
|
m.name = prop;
|
2007-06-04 12:42:29 +00:00
|
|
|
m.prop = props.Node.new({ "dialog-name" : prop });
|
|
|
|
} else { # aircraft dialog with given path
|
2007-06-18 15:34:36 +00:00
|
|
|
m.name = name;
|
2007-06-04 12:42:29 +00:00
|
|
|
m.path = path;
|
2007-06-14 23:19:43 +00:00
|
|
|
m.prop = isa(prop, props.Node) ? prop : props.globals.getNode(prop, 1);
|
|
|
|
if (m.prop.getName() != "dialog")
|
2007-06-04 12:42:29 +00:00
|
|
|
die("Dialog class: node name must end with '/dialog'");
|
2007-06-14 23:19:43 +00:00
|
|
|
|
2007-06-04 12:42:29 +00:00
|
|
|
m.listener = setlistener("/sim/signals/reinit-gui", func { m.load() }, 1);
|
2006-08-25 20:13:58 +00:00
|
|
|
}
|
2007-06-15 16:22:13 +00:00
|
|
|
return Dialog.instance[m.name] = m;
|
2006-08-24 16:32:09 +00:00
|
|
|
},
|
|
|
|
# doesn't need to be called explicitly, but can be used to force a reload
|
|
|
|
load : func {
|
2007-03-25 10:00:53 +00:00
|
|
|
var state = me.state;
|
2007-06-04 12:42:29 +00:00
|
|
|
if (state)
|
2007-03-25 10:00:53 +00:00
|
|
|
me.close();
|
2007-06-04 12:42:29 +00:00
|
|
|
|
2007-03-25 10:00:53 +00:00
|
|
|
me.prop.removeChildren();
|
2007-06-12 16:20:55 +00:00
|
|
|
fgcommand("loadxml", props.Node.new({"filename": getprop("/sim/fg-root") ~ "/" ~ me.path,
|
2006-08-24 16:32:09 +00:00
|
|
|
"targetnode": me.prop.getPath()}));
|
2007-06-14 23:19:43 +00:00
|
|
|
|
2007-02-26 11:00:04 +00:00
|
|
|
var n = me.prop.getNode("name");
|
2007-06-04 12:42:29 +00:00
|
|
|
if (n == nil)
|
2006-08-24 16:32:09 +00:00
|
|
|
die("Dialog class: XML dialog must have <name>");
|
2007-06-04 12:42:29 +00:00
|
|
|
|
2007-06-14 23:19:43 +00:00
|
|
|
if (me.name == nil)
|
|
|
|
me.name = n.getValue();
|
|
|
|
else
|
|
|
|
n.setValue(me.name);
|
|
|
|
|
2007-02-26 11:00:04 +00:00
|
|
|
me.prop.getNode("dialog-name", 1).setValue(me.name);
|
2006-08-24 16:32:09 +00:00
|
|
|
fgcommand("dialog-new", me.prop);
|
2007-06-04 12:42:29 +00:00
|
|
|
if (state)
|
2007-03-25 10:00:53 +00:00
|
|
|
me.open();
|
2006-08-24 16:32:09 +00:00
|
|
|
},
|
2007-02-26 11:00:04 +00:00
|
|
|
# allows access to dialog-embedded Nasal variables/functions
|
|
|
|
namespace : func {
|
|
|
|
var ns = "__dlg:" ~ me.name;
|
|
|
|
me.state and contains(globals, ns) ? globals[ns] : nil;
|
|
|
|
},
|
2006-08-24 16:32:09 +00:00
|
|
|
open : func {
|
|
|
|
fgcommand("dialog-show", me.prop);
|
|
|
|
me.state = 1;
|
|
|
|
},
|
|
|
|
close : func {
|
|
|
|
fgcommand("dialog-close", me.prop);
|
|
|
|
me.state = 0;
|
|
|
|
},
|
|
|
|
toggle : func {
|
|
|
|
me.state ? me.close() : me.open();
|
|
|
|
},
|
|
|
|
is_open : func {
|
|
|
|
me.state;
|
|
|
|
},
|
2007-06-15 16:22:13 +00:00
|
|
|
instance : {},
|
2006-08-24 16:32:09 +00:00
|
|
|
};
|
|
|
|
|
2006-08-27 19:27:21 +00:00
|
|
|
|
2007-06-14 23:19:43 +00:00
|
|
|
##
|
2007-06-15 16:22:13 +00:00
|
|
|
# FileSelector class (derived from Dialog class).
|
2007-06-14 23:19:43 +00:00
|
|
|
#
|
2007-06-22 14:13:30 +00:00
|
|
|
# SYNOPSIS: FileSelector.new(<callback>, <title>, <button> [, <pattern> [, <dir> [, <file> [, <dotfiles>]]]])
|
2007-06-14 23:19:43 +00:00
|
|
|
#
|
|
|
|
# callback ... callback function that gets return value as cmdarg().getValue()
|
2007-06-17 15:27:33 +00:00
|
|
|
# title ... dialog title
|
2007-06-17 22:56:22 +00:00
|
|
|
# button ... button text (should say "Save", "Load", etc. and not just "OK")
|
2007-06-22 14:13:30 +00:00
|
|
|
# pattern ... array with shell pattern or nil (which is equivalent to "*")
|
2007-06-14 23:19:43 +00:00
|
|
|
# dir ... starting dir ($FG_ROOT if unset)
|
|
|
|
# file ... pre-selected default file name
|
2007-06-17 15:27:33 +00:00
|
|
|
# dotfiles ... flag that decids whether UNIX dotfiles should be shown (1) or not (0)
|
2007-06-14 23:19:43 +00:00
|
|
|
#
|
|
|
|
# EXAMPLE:
|
|
|
|
#
|
|
|
|
# var report = func { print("file ", cmdarg().getValue(), " selected") }
|
2007-06-22 14:13:30 +00:00
|
|
|
# var selector = gui.FileSelector.new(
|
|
|
|
# report, # callback function
|
|
|
|
# "Save Flight", # dialot title
|
|
|
|
# "Save", # button text
|
|
|
|
# ["*.sav", "*.xml"], # pattern for displayed files
|
|
|
|
# "/tmp", # start dir
|
|
|
|
# "flight.sav"); # default file name
|
2007-06-17 22:56:22 +00:00
|
|
|
# selector.open();
|
|
|
|
#
|
|
|
|
# selector.close();
|
|
|
|
# selector.set_title("Save Another Flight");
|
|
|
|
# selector.open();
|
2007-06-14 23:19:43 +00:00
|
|
|
#
|
|
|
|
var FileSelector = {
|
2007-06-22 14:13:30 +00:00
|
|
|
new : func(callback, title, button, pattern = nil, dir = "", file = "", dotfiles = 0) {
|
2007-06-17 15:27:33 +00:00
|
|
|
var name = "file-select-";
|
|
|
|
var data = props.globals.getNode("/sim/gui/dialogs/", 1);
|
|
|
|
var i = nil;
|
|
|
|
for (i = 1; 1; i += 1)
|
|
|
|
if (data.getNode(name ~ i, 0) == nil)
|
|
|
|
break;
|
|
|
|
data = data.getNode(name ~= i, 1);
|
2007-06-17 22:56:22 +00:00
|
|
|
|
2007-06-14 23:19:43 +00:00
|
|
|
var m = Dialog.new(data.getNode("dialog", 1), "gui/dialogs/file-select.xml", name);
|
|
|
|
m.parents = [FileSelector, Dialog];
|
2007-06-17 15:27:33 +00:00
|
|
|
m.data = data;
|
2007-06-17 22:56:22 +00:00
|
|
|
m.set_title(title);
|
|
|
|
m.set_button(button);
|
|
|
|
m.set_directory(dir);
|
|
|
|
m.set_file(file);
|
|
|
|
m.set_dotfiles(dotfiles);
|
2007-06-22 14:13:30 +00:00
|
|
|
m.set_pattern(pattern);
|
2007-06-14 23:19:43 +00:00
|
|
|
m.cblistener = setlistener(data.getNode("path", 1), callback);
|
|
|
|
return m;
|
|
|
|
},
|
2007-06-17 22:56:22 +00:00
|
|
|
# setters only take effect after the next call to open()
|
|
|
|
set_title : func(title) { me.data.getNode("title", 1).setValue(title) },
|
|
|
|
set_button : func(button) { me.data.getNode("button", 1).setValue(button) },
|
|
|
|
set_directory : func(dir) { me.data.getNode("directory", 1).setValue(dir) },
|
|
|
|
set_file : func(file) { me.data.getNode("selection", 1).setValue(file) },
|
|
|
|
set_dotfiles : func(dot) { me.data.getNode("dotfiles", 1).setBoolValue(dot) },
|
2007-06-22 14:13:30 +00:00
|
|
|
set_pattern : func(pattern) {
|
|
|
|
me.data.removeChildren("pattern");
|
|
|
|
if (pattern != nil)
|
|
|
|
forindex (var i; pattern)
|
|
|
|
me.data.getChild("pattern", i, 1).setValue(pattern[i]);
|
|
|
|
},
|
2007-06-14 23:19:43 +00:00
|
|
|
del : func {
|
|
|
|
me.close();
|
|
|
|
delete(me.instance, me.name);
|
|
|
|
removelistener(me.cblistener);
|
2007-06-17 15:27:33 +00:00
|
|
|
props.globals.getNode("/sim/gui/dialogs", 1).removeChildren(me.name);
|
2007-06-14 23:19:43 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-08-24 12:44:14 +00:00
|
|
|
##
|
|
|
|
# Open property browser with given target path.
|
|
|
|
#
|
2007-06-14 23:19:43 +00:00
|
|
|
var property_browser = func(dir = "/") {
|
2006-08-24 16:32:09 +00:00
|
|
|
var dlgname = "property-browser";
|
|
|
|
foreach (var module; keys(globals)) {
|
2006-08-26 13:23:06 +00:00
|
|
|
if (find("__dlg:" ~ dlgname, module) == 0) {
|
2006-08-27 16:22:06 +00:00
|
|
|
globals[module].clone(dir);
|
2006-08-27 19:27:21 +00:00
|
|
|
return;
|
2006-08-24 16:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-27 19:27:21 +00:00
|
|
|
setprop("/sim/gui/dialogs/" ~ dlgname ~ "/last", dir);
|
|
|
|
fgcommand("dialog-show", props.Node.new({"dialog-name": dlgname}));
|
2006-08-24 12:44:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Open one property browser per /browser[] property, where each contains
|
|
|
|
# the target path. On the command line use --prop:browser=orientation
|
|
|
|
#
|
|
|
|
settimer(func {
|
2006-08-24 16:32:09 +00:00
|
|
|
foreach (var b; props.globals.getChildren("browser")) {
|
|
|
|
var path = b.getValue();
|
2007-06-14 23:19:43 +00:00
|
|
|
if (path != nil and size(path))
|
2006-08-24 16:32:09 +00:00
|
|
|
property_browser(path);
|
|
|
|
}
|
|
|
|
props.globals.removeChildren("browser");
|
2006-08-24 12:44:14 +00:00
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
2007-03-29 14:50:27 +00:00
|
|
|
##
|
|
|
|
# Apply whole dialog or list of widgets. This copies the widgets'
|
|
|
|
# visible contents to the respective <property>.
|
|
|
|
#
|
|
|
|
var dialog_apply = func(dialog, objects...) {
|
|
|
|
var n = props.Node.new({ "dialog-name" : dialog });
|
|
|
|
if (!size(objects)) {
|
|
|
|
return fgcommand("dialog-apply", n);
|
|
|
|
}
|
|
|
|
var name = n.getNode("object-name", 1);
|
|
|
|
foreach (var o; objects) {
|
|
|
|
name.setValue(o);
|
|
|
|
fgcommand("dialog-apply", n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Update whole dialog or list of widgets. This makes the widgets
|
|
|
|
# adopt and display the value of their <property>.
|
|
|
|
#
|
|
|
|
var dialog_update = func(dialog, objects...) {
|
|
|
|
var n = props.Node.new({ "dialog-name" : dialog });
|
|
|
|
if (!size(objects)) {
|
|
|
|
return fgcommand("dialog-update", n);
|
|
|
|
}
|
|
|
|
var name = n.getNode("object-name", 1);
|
|
|
|
foreach (var o; objects) {
|
|
|
|
name.setValue(o);
|
|
|
|
fgcommand("dialog-update", n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-24 12:44:14 +00:00
|
|
|
|
2005-07-13 10:56:42 +00:00
|
|
|
########################################################################
|
|
|
|
# GUI theming
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
nextStyle = func {
|
2006-03-09 23:05:08 +00:00
|
|
|
numStyles = size(props.globals.getNode("/sim/gui").getChildren("style"));
|
|
|
|
curr = getprop("/sim/gui/current-style") + 1;
|
2005-12-06 17:57:41 +00:00
|
|
|
if (curr >= numStyles) {
|
|
|
|
curr = 0;
|
|
|
|
}
|
2006-03-09 23:05:08 +00:00
|
|
|
setprop("/sim/gui/current-style", curr);
|
2007-06-12 16:20:55 +00:00
|
|
|
fgcommand("gui-redraw");
|
2005-07-13 10:56:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-05-15 21:50:51 +00:00
|
|
|
########################################################################
|
|
|
|
# Dialog Boxes
|
|
|
|
########################################################################
|
|
|
|
|
2005-04-19 13:43:44 +00:00
|
|
|
dialog = {};
|
|
|
|
|
2006-08-25 19:59:05 +00:00
|
|
|
var setWeight = func(wgt, opt) {
|
|
|
|
var lbs = opt.getNode("lbs", 1).getValue();
|
|
|
|
wgt.getNode("weight-lb", 1).setValue(lbs);
|
|
|
|
|
|
|
|
# Weights can have "tank" indices which set the capacity of the
|
|
|
|
# corresponding tank. This code should probably be moved to
|
|
|
|
# something like fuel.setTankCap(tank, gals)...
|
|
|
|
if(wgt.getNode("tank") == nil) { return 0; }
|
|
|
|
var ti = wgt.getNode("tank").getValue();
|
|
|
|
var gn = opt.getNode("gals");
|
|
|
|
var gals = gn == nil ? 0 : gn.getValue();
|
|
|
|
var tn = props.globals.getNode("consumables/fuel/tank["~ti~"]", 1);
|
|
|
|
var ppg = tn.getNode("density-ppg", 1).getValue();
|
|
|
|
var lbs = gals * ppg;
|
|
|
|
var curr = tn.getNode("level-gal_us", 1).getValue();
|
|
|
|
curr = curr > gals ? gals : curr;
|
|
|
|
tn.getNode("capacity-gal_us", 1).setValue(gals);
|
|
|
|
tn.getNode("level-gal_us", 1).setValue(curr);
|
|
|
|
tn.getNode("level-lbs", 1).setValue(curr * ppg);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-08-24 22:29:16 +00:00
|
|
|
# Checks the /sim/weight[n]/{selected|opt} values and sets the
|
2006-08-25 19:59:05 +00:00
|
|
|
# appropriate weights therefrom.
|
2006-08-24 22:29:16 +00:00
|
|
|
var setWeightOpts = func {
|
2006-08-25 19:59:05 +00:00
|
|
|
var tankchange = 0;
|
2006-08-24 22:29:16 +00:00
|
|
|
foreach(w; props.globals.getNode("sim").getChildren("weight")) {
|
2006-10-17 19:22:36 +00:00
|
|
|
var selected = w.getNode("selected");
|
|
|
|
if(selected != nil) {
|
|
|
|
foreach(opt; w.getChildren("opt")) {
|
|
|
|
if(opt.getNode("name", 1).getValue() == selected.getValue()) {
|
|
|
|
if(setWeight(w, opt)) { tankchange = 1; }
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-08-24 22:29:16 +00:00
|
|
|
}
|
2006-08-25 19:59:05 +00:00
|
|
|
return tankchange;
|
|
|
|
}
|
2007-01-31 21:37:14 +00:00
|
|
|
# Run it at startup and on reset to make sure the tank settings are correct
|
|
|
|
_setlistener("/sim/signals/fdm-initialized", func { settimer(setWeightOpts, 0) });
|
|
|
|
_setlistener("/sim/signals/reset", func { cmdarg().getBoolValue() or setWeightOpts() });
|
2006-08-25 19:59:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Called from the F&W dialog when the user selects a weight option
|
|
|
|
var weightChangeHandler = func {
|
|
|
|
var tankchanged = setWeightOpts();
|
|
|
|
|
|
|
|
# This is unfortunate. Changing tanks means that the list of
|
|
|
|
# tanks selected and their slider bounds must change, but our GUI
|
|
|
|
# isn't dynamic in that way. The only way to get the changes on
|
|
|
|
# screen is to pop it down and recreate it.
|
|
|
|
if(tankchanged) {
|
2006-10-17 19:22:36 +00:00
|
|
|
var p = props.Node.new({"dialog-name" : "WeightAndFuel"});
|
|
|
|
fgcommand("dialog-close", p);
|
|
|
|
showWeightDialog();
|
2006-08-25 19:59:05 +00:00
|
|
|
}
|
2006-08-24 22:29:16 +00:00
|
|
|
}
|
2005-04-19 13:43:44 +00:00
|
|
|
|
2004-05-15 21:50:51 +00:00
|
|
|
##
|
|
|
|
# Dynamically generates a weight & fuel configuration dialog specific to
|
|
|
|
# the aircraft.
|
|
|
|
#
|
|
|
|
showWeightDialog = func {
|
|
|
|
name = "WeightAndFuel";
|
|
|
|
title = "Weight and Fuel Settings";
|
|
|
|
|
|
|
|
#
|
|
|
|
# General Dialog Structure
|
|
|
|
#
|
2005-04-19 13:43:44 +00:00
|
|
|
dialog[name] = Widget.new();
|
|
|
|
dialog[name].set("name", name);
|
|
|
|
dialog[name].set("layout", "vbox");
|
2004-05-15 21:50:51 +00:00
|
|
|
|
2005-04-19 13:43:44 +00:00
|
|
|
header = dialog[name].addChild("text");
|
2004-05-15 21:50:51 +00:00
|
|
|
header.set("label", title);
|
|
|
|
|
2007-03-26 15:26:23 +00:00
|
|
|
dialog[name].addChild("hrule");
|
2005-10-18 20:15:04 +00:00
|
|
|
|
|
|
|
if (props.globals.getNode("/yasim") == nil) {
|
|
|
|
msg = dialog[name].addChild("text");
|
|
|
|
msg.set("label", "Not supported for this aircraft");
|
|
|
|
cancel = dialog[name].addChild("button");
|
|
|
|
cancel.set("legend", "Cancel");
|
2006-08-24 12:44:14 +00:00
|
|
|
cancel.setBinding("dialog-close");
|
2005-10-18 20:15:04 +00:00
|
|
|
fgcommand("dialog-new", dialog[name].prop());
|
|
|
|
showDialog(name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-19 13:43:44 +00:00
|
|
|
contentArea = dialog[name].addChild("group");
|
2004-05-15 21:50:51 +00:00
|
|
|
contentArea.set("layout", "hbox");
|
|
|
|
|
|
|
|
grossWgt = props.globals.getNode("/yasim/gross-weight-lbs");
|
|
|
|
if(grossWgt != nil) {
|
2005-04-19 13:43:44 +00:00
|
|
|
gwg = dialog[name].addChild("group");
|
2004-05-15 21:50:51 +00:00
|
|
|
gwg.set("layout", "hbox");
|
|
|
|
gwg.addChild("empty").set("stretch", 1);
|
2005-03-26 22:15:26 +00:00
|
|
|
gwg.addChild("text").set("label", "Gross Weight:");
|
2004-05-15 21:50:51 +00:00
|
|
|
txt = gwg.addChild("text");
|
|
|
|
txt.set("label", "0123456789");
|
2005-03-26 22:15:26 +00:00
|
|
|
txt.set("format", "%.0f lb");
|
2004-05-15 21:50:51 +00:00
|
|
|
txt.set("property", "/yasim/gross-weight-lbs");
|
|
|
|
txt.set("live", 1);
|
|
|
|
gwg.addChild("empty").set("stretch", 1);
|
|
|
|
}
|
|
|
|
|
2005-04-19 13:43:44 +00:00
|
|
|
buttonBar = dialog[name].addChild("group");
|
2004-05-15 21:50:51 +00:00
|
|
|
buttonBar.set("layout", "hbox");
|
|
|
|
buttonBar.set("default-padding", 10);
|
2005-04-19 13:43:44 +00:00
|
|
|
|
2004-05-15 21:50:51 +00:00
|
|
|
ok = buttonBar.addChild("button");
|
|
|
|
ok.set("legend", "OK");
|
2006-02-24 15:54:45 +00:00
|
|
|
ok.set("key", "esc");
|
2006-08-24 12:44:14 +00:00
|
|
|
ok.setBinding("dialog-apply");
|
|
|
|
ok.setBinding("dialog-close");
|
2004-05-15 21:50:51 +00:00
|
|
|
|
|
|
|
# Temporary helper function
|
2006-08-24 22:29:16 +00:00
|
|
|
tcell = func(parent, type, row, col) {
|
|
|
|
cell = parent.addChild(type);
|
|
|
|
cell.set("row", row);
|
|
|
|
cell.set("col", col);
|
2004-05-15 21:50:51 +00:00
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Fill in the content area
|
|
|
|
#
|
|
|
|
fuelArea = contentArea.addChild("group");
|
|
|
|
fuelArea.set("layout", "vbox");
|
|
|
|
fuelArea.addChild("text").set("label", "Fuel Tanks");
|
|
|
|
|
|
|
|
fuelTable = fuelArea.addChild("group");
|
|
|
|
fuelTable.set("layout", "table");
|
|
|
|
|
|
|
|
fuelArea.addChild("empty").set("stretch", 1);
|
|
|
|
|
|
|
|
tcell(fuelTable, "text", 0, 0).set("label", "Tank");
|
|
|
|
tcell(fuelTable, "text", 0, 3).set("label", "Pounds");
|
|
|
|
tcell(fuelTable, "text", 0, 4).set("label", "Gallons");
|
|
|
|
|
|
|
|
tanks = props.globals.getNode("/consumables/fuel").getChildren("tank");
|
2005-05-03 13:45:33 +00:00
|
|
|
for(i=0; i<size(tanks); i+=1) {
|
2004-05-15 21:50:51 +00:00
|
|
|
t = tanks[i];
|
|
|
|
|
|
|
|
tname = i ~ "";
|
|
|
|
tnode = t.getNode("name");
|
|
|
|
if(tnode != nil) { tname = tnode.getValue(); }
|
|
|
|
|
|
|
|
tankprop = "/consumables/fuel/tank["~i~"]";
|
|
|
|
|
|
|
|
cap = t.getNode("capacity-gal_us", 1).getValue();
|
|
|
|
|
|
|
|
# Hack, to ignore the "ghost" tanks created by the C++ code.
|
2006-07-03 05:59:24 +00:00
|
|
|
if(cap == nil or cap < 1) { continue; }
|
2004-05-15 21:50:51 +00:00
|
|
|
|
|
|
|
title = tcell(fuelTable, "text", i+1, 0);
|
|
|
|
title.set("label", tname);
|
|
|
|
title.set("halign", "right");
|
|
|
|
|
|
|
|
sel = tcell(fuelTable, "checkbox", i+1, 1);
|
|
|
|
sel.set("property", tankprop ~ "/selected");
|
2007-03-29 14:50:27 +00:00
|
|
|
sel.set("live", 1);
|
2006-08-24 12:44:14 +00:00
|
|
|
sel.setBinding("dialog-apply");
|
2004-05-15 21:50:51 +00:00
|
|
|
|
|
|
|
slider = tcell(fuelTable, "slider", i+1, 2);
|
|
|
|
slider.set("property", tankprop ~ "/level-gal_us");
|
2007-03-29 14:50:27 +00:00
|
|
|
slider.set("live", 1);
|
2004-05-15 21:50:51 +00:00
|
|
|
slider.set("min", 0);
|
|
|
|
slider.set("max", cap);
|
2006-08-24 12:44:14 +00:00
|
|
|
slider.setBinding("dialog-apply");
|
2004-05-15 21:50:51 +00:00
|
|
|
|
|
|
|
lbs = tcell(fuelTable, "text", i+1, 3);
|
|
|
|
lbs.set("property", tankprop ~ "/level-lbs");
|
2005-03-26 22:15:26 +00:00
|
|
|
lbs.set("label", "0123456");
|
|
|
|
lbs.set("format", "%.3f");
|
2004-05-15 21:50:51 +00:00
|
|
|
lbs.set("live", 1);
|
2005-04-19 13:43:44 +00:00
|
|
|
|
2004-05-15 21:50:51 +00:00
|
|
|
gals = tcell(fuelTable, "text", i+1, 4);
|
|
|
|
gals.set("property", tankprop ~ "/level-gal_us");
|
2005-03-26 22:15:26 +00:00
|
|
|
gals.set("label", "0123456");
|
|
|
|
gals.set("format", "%.3f");
|
2004-05-15 21:50:51 +00:00
|
|
|
gals.set("live", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
weightArea = contentArea.addChild("group");
|
|
|
|
weightArea.set("layout", "vbox");
|
|
|
|
weightArea.addChild("text").set("label", "Payload");
|
|
|
|
|
|
|
|
weightTable = weightArea.addChild("group");
|
|
|
|
weightTable.set("layout", "table");
|
|
|
|
|
|
|
|
weightArea.addChild("empty").set("stretch", 1);
|
|
|
|
|
|
|
|
tcell(weightTable, "text", 0, 0).set("label", "Location");
|
|
|
|
tcell(weightTable, "text", 0, 2).set("label", "Pounds");
|
|
|
|
|
|
|
|
wgts = props.globals.getNode("/sim").getChildren("weight");
|
2005-05-03 13:45:33 +00:00
|
|
|
for(i=0; i<size(wgts); i+=1) {
|
2006-08-24 22:29:16 +00:00
|
|
|
var w = wgts[i];
|
|
|
|
var wname = w.getNode("name", 1).getValue();
|
2006-10-17 19:22:36 +00:00
|
|
|
var wprop = "/sim/weight[" ~ i ~ "]";
|
2004-05-15 21:50:51 +00:00
|
|
|
|
|
|
|
title = tcell(weightTable, "text", i+1, 0);
|
|
|
|
title.set("label", wname);
|
|
|
|
title.set("halign", "right");
|
|
|
|
|
2006-10-17 19:22:36 +00:00
|
|
|
if(w.getNode("opt") != nil) {
|
|
|
|
var combo = tcell(weightTable, "combo", i+1, 1);
|
|
|
|
combo.set("property", wprop ~ "/selected");
|
|
|
|
combo.set("pref-width", 300);
|
|
|
|
|
|
|
|
# Simple code we'd like to use:
|
|
|
|
#foreach(opt; w.getChildren("opt")) {
|
|
|
|
# var ent = combo.addChild("value");
|
|
|
|
# ent.prop().setValue(opt.getNode("name", 1).getValue());
|
|
|
|
#}
|
|
|
|
|
|
|
|
# More complicated workaround to move the "current" item
|
|
|
|
# into the first slot, because dialog.cxx doesn't set the
|
|
|
|
# selected item in the combo box.
|
|
|
|
var opts = [];
|
|
|
|
var curr = w.getNode("selected");
|
|
|
|
curr = curr == nil ? "" : curr.getValue();
|
|
|
|
foreach(opt; w.getChildren("opt")) {
|
|
|
|
append(opts, opt.getNode("name", 1).getValue());
|
|
|
|
}
|
|
|
|
forindex(oi; opts) {
|
|
|
|
if(opts[oi] == curr) {
|
|
|
|
var tmp = opts[0];
|
|
|
|
opts[0] = opts[oi];
|
|
|
|
opts[oi] = tmp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach(opt; opts) {
|
|
|
|
combo.addChild("value").prop().setValue(opt);
|
|
|
|
}
|
|
|
|
|
|
|
|
combo.setBinding("dialog-apply");
|
|
|
|
combo.setBinding("nasal", "gui.weightChangeHandler()");
|
|
|
|
} else {
|
|
|
|
var slider = tcell(weightTable, "slider", i+1, 1);
|
|
|
|
slider.set("property", wprop ~ "/weight-lb");
|
|
|
|
var min = w.getNode("min-lb", 1).getValue();
|
|
|
|
var max = w.getNode("max-lb", 1).getValue();
|
|
|
|
slider.set("min", min != nil ? min : 0);
|
|
|
|
slider.set("max", max != nil ? max : 100);
|
2007-03-29 14:50:27 +00:00
|
|
|
slider.set("live", 1);
|
2006-10-17 19:22:36 +00:00
|
|
|
slider.setBinding("dialog-apply");
|
|
|
|
}
|
2004-05-15 21:50:51 +00:00
|
|
|
|
|
|
|
lbs = tcell(weightTable, "text", i+1, 2);
|
2006-08-24 22:29:16 +00:00
|
|
|
lbs.set("property", wprop ~ "/weight-lb");
|
2005-03-26 22:15:26 +00:00
|
|
|
lbs.set("label", "0123456");
|
|
|
|
lbs.set("format", "%.0f");
|
2004-05-15 21:50:51 +00:00
|
|
|
lbs.set("live", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
# All done: pop it up
|
2005-04-19 13:43:44 +00:00
|
|
|
fgcommand("dialog-new", dialog[name].prop());
|
2004-05-15 21:50:51 +00:00
|
|
|
showDialog(name);
|
|
|
|
}
|
2005-04-19 13:43:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Dynamically generates a dialog from a help node.
|
|
|
|
#
|
|
|
|
# gui.showHelpDialog([<path> [, toggle]])
|
|
|
|
#
|
|
|
|
# path ... path to help node
|
|
|
|
# toggle ... decides if an already open dialog should be closed
|
|
|
|
# (useful when calling the dialog from a key binding; default: 0)
|
|
|
|
#
|
|
|
|
# help node
|
|
|
|
# =========
|
|
|
|
# each of <title>, <key>, <line>, <text> is optional; uses
|
|
|
|
# "/sim/description" or "/sim/aircraft" if <title> is omitted;
|
|
|
|
# only the first <text> is displayed
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# <help>
|
|
|
|
# <title>dialog title<title>
|
|
|
|
# <key>
|
|
|
|
# <name>g/G</name>
|
|
|
|
# <desc>gear up/down</desc>
|
|
|
|
# </key>
|
|
|
|
#
|
|
|
|
# <line>one line</line>
|
|
|
|
# <line>another line</line>
|
|
|
|
#
|
|
|
|
# <text>text in
|
|
|
|
# scrollable widget
|
|
|
|
# </text>
|
|
|
|
# </help>
|
|
|
|
#
|
|
|
|
showHelpDialog = func {
|
|
|
|
node = props.globals.getNode(arg[0]);
|
|
|
|
if (arg[0] == "/sim/help" and size(node.getChildren()) < 4) {
|
|
|
|
node = node.getChild("common");
|
|
|
|
}
|
|
|
|
|
|
|
|
name = node.getNode("title", 1).getValue();
|
|
|
|
if (name == nil) {
|
|
|
|
name = getprop("/sim/description");
|
|
|
|
if (name == nil) {
|
|
|
|
name = getprop("/sim/aircraft");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
toggle = size(arg) > 1 and arg[1] != nil and arg[1] > 0;
|
|
|
|
if (toggle and contains(dialog, name)) {
|
|
|
|
fgcommand("dialog-close", props.Node.new({ "dialog-name" : name }));
|
|
|
|
delete(dialog, name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-12 06:54:16 +00:00
|
|
|
dialog[name] = Widget.new();
|
2005-04-19 13:43:44 +00:00
|
|
|
dialog[name].set("layout", "vbox");
|
|
|
|
dialog[name].set("default-padding", 0);
|
|
|
|
dialog[name].set("name", name);
|
|
|
|
|
|
|
|
# title bar
|
|
|
|
titlebar = dialog[name].addChild("group");
|
|
|
|
titlebar.set("layout", "hbox");
|
|
|
|
titlebar.addChild("empty").set("stretch", 1);
|
2005-07-13 11:30:32 +00:00
|
|
|
titlebar.addChild("text").set("label", name);
|
2005-04-19 13:43:44 +00:00
|
|
|
titlebar.addChild("empty").set("stretch", 1);
|
|
|
|
|
|
|
|
w = titlebar.addChild("button");
|
|
|
|
w.set("pref-width", 16);
|
|
|
|
w.set("pref-height", 16);
|
|
|
|
w.set("legend", "");
|
|
|
|
w.set("default", 1);
|
2006-02-24 15:54:45 +00:00
|
|
|
w.set("key", "esc");
|
2006-08-24 12:44:14 +00:00
|
|
|
w.setBinding("nasal", "delete(gui.dialog, \"" ~ name ~ "\")");
|
|
|
|
w.setBinding("dialog-close");
|
2005-04-19 13:43:44 +00:00
|
|
|
|
2007-03-26 15:26:23 +00:00
|
|
|
dialog[name].addChild("hrule");
|
2005-07-13 11:30:32 +00:00
|
|
|
|
2005-04-19 13:43:44 +00:00
|
|
|
# key list
|
|
|
|
keylist = dialog[name].addChild("group");
|
|
|
|
keylist.set("layout", "table");
|
|
|
|
keylist.set("default-padding", 2);
|
|
|
|
keydefs = node.getChildren("key");
|
|
|
|
n = size(keydefs);
|
|
|
|
row = col = 0;
|
|
|
|
foreach (key; keydefs) {
|
|
|
|
if (n >= 60 and row >= n / 3 or n >= 16 and row >= n / 2) {
|
2005-05-03 13:45:33 +00:00
|
|
|
col += 1;
|
2005-04-19 13:43:44 +00:00
|
|
|
row = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
w = keylist.addChild("text");
|
|
|
|
w.set("row", row);
|
|
|
|
w.set("col", 2 * col);
|
|
|
|
w.set("halign", "right");
|
|
|
|
w.set("label", " " ~ key.getNode("name").getValue());
|
|
|
|
|
|
|
|
w = keylist.addChild("text");
|
|
|
|
w.set("row", row);
|
|
|
|
w.set("col", 2 * col + 1);
|
|
|
|
w.set("halign", "left");
|
|
|
|
w.set("label", "... " ~ key.getNode("desc").getValue() ~ " ");
|
2005-05-02 16:00:13 +00:00
|
|
|
row += 1;
|
2005-04-19 13:43:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# separate lines
|
|
|
|
lines = node.getChildren("line");
|
|
|
|
if (size(lines)) {
|
|
|
|
if (size(keydefs)) {
|
2005-12-11 15:38:35 +00:00
|
|
|
dialog[name].addChild("empty").set("pref-height", 4);
|
2007-03-26 15:26:23 +00:00
|
|
|
dialog[name].addChild("hrule");
|
2005-12-11 15:38:35 +00:00
|
|
|
dialog[name].addChild("empty").set("pref-height", 4);
|
2005-04-19 13:43:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g = dialog[name].addChild("group");
|
|
|
|
g.set("layout", "vbox");
|
|
|
|
g.set("default-padding", 1);
|
2006-12-06 00:24:48 +00:00
|
|
|
foreach (var lin; lines) {
|
|
|
|
foreach (var l; split("\n", lin.getValue())) {
|
|
|
|
w = g.addChild("text");
|
|
|
|
w.set("halign", "left");
|
|
|
|
w.set("label", " " ~ l ~ " ");
|
|
|
|
}
|
2005-04-19 13:43:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# scrollable text area
|
|
|
|
if (node.getNode("text") != nil) {
|
|
|
|
dialog[name].addChild("empty").set("pref-height", 10);
|
|
|
|
|
|
|
|
width = [640, 800, 1152][col];
|
|
|
|
height = screenHProp.getValue() - (100 + (size(keydefs) / (col + 1) + size(lines)) * 28);
|
|
|
|
if (height < 200) {
|
|
|
|
height = 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
w = dialog[name].addChild("textbox");
|
2006-02-24 11:11:09 +00:00
|
|
|
w.set("halign", "fill");
|
2005-04-19 13:43:44 +00:00
|
|
|
w.set("slider", 20);
|
|
|
|
w.set("pref-width", width);
|
|
|
|
w.set("pref-height", height);
|
|
|
|
w.set("editable", 0);
|
|
|
|
w.set("property", node.getPath() ~ "/text");
|
|
|
|
} else {
|
|
|
|
dialog[name].addChild("empty").set("pref-height", 8);
|
|
|
|
}
|
|
|
|
fgcommand("dialog-new", dialog[name].prop());
|
|
|
|
showDialog(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
debug_keys = {
|
|
|
|
title : "Development Keys",
|
|
|
|
key : [
|
|
|
|
#{ name : "Ctrl-U", desc : "add 1000 ft of emergency altitude" },
|
|
|
|
{ name : "F2", desc : "force tile cache reload" },
|
|
|
|
{ name : "F4", desc : "force lighting update" },
|
|
|
|
{ name : "F8", desc : "cycle fog type" },
|
|
|
|
{ name : "F9", desc : "toggle textures" },
|
|
|
|
{ name : "Shift-F3", desc : "load panel" },
|
|
|
|
{ name : "Shift-F4", desc : "reload global preferences" },
|
2005-07-13 11:30:32 +00:00
|
|
|
{ name : "Shift-F9", desc : "toggle FDM data logging" },
|
2007-02-24 10:16:26 +00:00
|
|
|
{ name : "Shift-Space", desc : "open property browser" },
|
2005-04-19 13:43:44 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
basic_keys = {
|
|
|
|
title : "Basic Keys",
|
|
|
|
key : [
|
|
|
|
{ name : "?", desc : "show/hide aircraft help dialog" },
|
|
|
|
#{ name : "Tab", desc : "show/hide aircraft config dialog" },
|
|
|
|
{ name : "Esc", desc : "quit FlightGear" },
|
|
|
|
{ name : "Shift-Esc", desc : "reset FlightGear" },
|
|
|
|
{ name : "a/A", desc : "increase/decrease speed-up" },
|
|
|
|
{ name : "c", desc : "toggle 3D/2D cockpit" },
|
|
|
|
{ name : "Ctrl-C", desc : "toggle clickable panel hotspots" },
|
|
|
|
{ name : "p", desc : "pause/continue sim" },
|
|
|
|
{ name : "r", desc : "activate instant replay system" },
|
|
|
|
{ name : "Ctrl-R", desc : "show radio setting dialog" },
|
|
|
|
{ name : "t/T", desc : "increase/decrease warp delta" },
|
|
|
|
{ name : "v/V", desc : "cycle views (forward/backward)" },
|
|
|
|
{ name : "Ctrl-V", desc : "select cockpit view" },
|
2005-04-20 12:19:27 +00:00
|
|
|
{ name : "w/W", desc : "increase/decrease warp" },
|
2005-04-19 13:43:44 +00:00
|
|
|
{ name : "x/X", desc : "zoom in/out" },
|
|
|
|
{ name : "Ctrl-X", desc : "reset zoom to default" },
|
|
|
|
{ name : "z/Z", desc : "increase/decrease visibility" },
|
|
|
|
{ name : "'", desc : "display ATC setting dialog" },
|
2006-02-24 15:54:45 +00:00
|
|
|
{ name : "+", desc : "let ATC/instructor repeat last message" },
|
2005-04-19 13:43:44 +00:00
|
|
|
{ name : "F1", desc : "load flight" },
|
|
|
|
{ name : "F3", desc : "capture screen" },
|
|
|
|
{ name : "F10", desc : "toggle menubar" },
|
|
|
|
{ name : "Shift-F2", desc : "save flight" },
|
2005-07-13 11:30:32 +00:00
|
|
|
{ name : "Shift-F10", desc : "cycle through GUI styles" },
|
2005-04-19 13:43:44 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
common_aircraft_keys = {
|
|
|
|
title : "Common Aircraft Keys",
|
|
|
|
key : [
|
|
|
|
{ name : "Enter", desc : "move rudder right" },
|
|
|
|
{ name : "0/Insert", desc : "move rudder left" },
|
|
|
|
{ name : "1/End", desc : "decrease elevator trim" },
|
|
|
|
{ name : "2/Up", desc : "increase elevator or AP altitude" },
|
|
|
|
{ name : "3/PgDn", desc : "decr. throttle or AP autothrottle" },
|
|
|
|
{ name : "4/Left", desc : "move aileron left or adj. AP hdg." },
|
|
|
|
{ name : "5/KP5", desc : "center aileron, elev., and rudder" },
|
|
|
|
{ name : "6/Right", desc : "move aileron right or adj. AP hdg." },
|
|
|
|
{ name : "7/Home", desc : "increase elevator trim" },
|
|
|
|
{ name : "8/Down", desc : "decrease elevator or AP altitude" },
|
|
|
|
{ name : "9/PgUp", desc : "incr. throttle or AP autothrottle" },
|
|
|
|
{ name : "Space", desc : "fire starter on selected eng." },
|
|
|
|
{ name : "!/@/#/$", desc : "select engine 1/2/3/4" },
|
|
|
|
{ name : "b", desc : "apply all brakes" },
|
|
|
|
{ name : "B", desc : "toggle parking brake" },
|
|
|
|
#{ name : "Ctrl-B", desc : "toggle speed brake" },
|
|
|
|
{ name : "g/G", desc : "gear up/down" },
|
|
|
|
{ name : "h", desc : "cycle HUD (head up display)" },
|
|
|
|
{ name : "H", desc : "cycle HUD brightness" },
|
|
|
|
{ name : "i/Shift-i", desc : "normal/minimal HUD" },
|
|
|
|
#{ name : "j", desc : "decrease spoilers" },
|
|
|
|
#{ name : "k", desc : "increase spoilers" },
|
|
|
|
{ name : "l", desc : "toggle tail-wheel lock" },
|
2005-04-20 12:19:27 +00:00
|
|
|
{ name : "m/M", desc : "mixture richer/leaner" },
|
2006-08-09 14:01:53 +00:00
|
|
|
{ name : "n/N", desc : "propeller finer/coarser" },
|
2005-04-19 13:43:44 +00:00
|
|
|
{ name : "P", desc : "toggle 2D panel" },
|
|
|
|
{ name : "s", desc : "swap panels" },
|
|
|
|
{ name : ", .", desc : "left/right brake (comma, period)" },
|
|
|
|
{ name : "~", desc : "select all engines (tilde)" },
|
|
|
|
{ name : "[ ]", desc : "flaps up/down" },
|
|
|
|
{ name : "{ }", desc : "decr/incr magneto on sel. eng." },
|
|
|
|
{ name : "Ctrl-A", desc : "AP: toggle altitude lock" },
|
|
|
|
{ name : "Ctrl-G", desc : "AP: toggle glide slope lock" },
|
|
|
|
{ name : "Ctrl-H", desc : "AP: toggle heading lock" },
|
|
|
|
{ name : "Ctrl-N", desc : "AP: toggle NAV1 lock" },
|
|
|
|
{ name : "Ctrl-P", desc : "AP: toggle pitch hold" },
|
|
|
|
{ name : "Ctrl-S", desc : "AP: toggle auto-throttle" },
|
|
|
|
{ name : "Ctrl-T", desc : "AP: toggle terrain lock" },
|
|
|
|
{ name : "Ctrl-W", desc : "AP: toggle wing leveler" },
|
|
|
|
{ name : "F6", desc : "AP: toggle heading mode" },
|
|
|
|
{ name : "F11", desc : "pop up autopilot (AP) dialog" },
|
|
|
|
{ name : "Shift-F5", desc : "scroll 2D panel down" },
|
|
|
|
{ name : "Shift-F6", desc : "scroll 2D panel up" },
|
|
|
|
{ name : "Shift-F7", desc : "scroll 2D panel left" },
|
|
|
|
{ name : "Shift-F8", desc : "scroll 2D panel right" },
|
|
|
|
],
|
|
|
|
};
|