2003-12-22 20:05:18 +00:00
|
|
|
##
|
|
|
|
# Pop up a "tip" dialog for a moment, then remove it. The delay in
|
2013-08-26 19:05:01 +00:00
|
|
|
# seconds can be specified as the second argument. The default is 4
|
|
|
|
# seconds. The third argument can be a hash with override values.
|
2007-11-09 13:00:05 +00:00
|
|
|
# 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. :)
|
2003-12-22 20:05:18 +00:00
|
|
|
#
|
2014-12-16 06:26:09 +00:00
|
|
|
var popupTip = func(label, delay = nil, override = nil, position = nil)
|
2013-03-16 12:47:51 +00:00
|
|
|
{
|
2014-12-16 06:26:09 +00:00
|
|
|
if (position == nil) {
|
|
|
|
position = {};
|
|
|
|
}
|
|
|
|
fgcommand("show-message", props.Node.new({ "label": label, "delay":delay, "x": position['x'], "y": position['y'] }));
|
2003-12-22 20:05:18 +00:00
|
|
|
}
|
|
|
|
|
2007-11-09 13:00:05 +00:00
|
|
|
var showDialog = func(name) {
|
|
|
|
fgcommand("dialog-show", props.Node.new({ "dialog-name" : name }));
|
2004-05-15 21:50:51 +00:00
|
|
|
}
|
|
|
|
|
2005-12-09 10:34:43 +00:00
|
|
|
##
|
|
|
|
# Enable/disable named menu entry
|
|
|
|
#
|
2007-11-09 13:00:05 +00:00
|
|
|
var menuEnable = func(searchname, state) {
|
|
|
|
foreach (var menu; props.globals.getNode("/sim/menubar/default").getChildren("menu")) {
|
|
|
|
foreach (var name; menu.getChildren("name")) {
|
2006-02-24 11:11:09 +00:00
|
|
|
if (name.getValue() == searchname) {
|
|
|
|
menu.getNode("enabled").setBoolValue(state);
|
|
|
|
}
|
2005-12-09 10:34:43 +00:00
|
|
|
}
|
2012-03-23 21:25:31 +00:00
|
|
|
foreach (var item; menu.getChildren("item")) {
|
|
|
|
foreach (var name; item.getChildren("name")) {
|
2006-02-24 11:11:09 +00:00
|
|
|
if (name.getValue() == searchname) {
|
|
|
|
item.getNode("enabled").setBoolValue(state);
|
|
|
|
}
|
2005-12-09 10:34:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-03 17:28:40 +00:00
|
|
|
##
|
|
|
|
# Set the binding for a menu item to a Nasal script,
|
|
|
|
# typically a dialog open() command.
|
|
|
|
#
|
|
|
|
var menuBind = func(searchname, command) {
|
|
|
|
foreach (var menu; props.globals.getNode("/sim/menubar/default").getChildren("menu")) {
|
2012-03-23 21:25:31 +00:00
|
|
|
foreach (var item; menu.getChildren("item")) {
|
|
|
|
foreach (var name; item.getChildren("name")) {
|
2011-01-03 17:28:40 +00:00
|
|
|
if (name.getValue() == searchname) {
|
|
|
|
item.getNode("binding", 1).getNode("command", 1).setValue("nasal");
|
|
|
|
item.getNode("binding", 1).getNode("script", 1).setValue(command);
|
|
|
|
fgcommand("gui-redraw");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-12-09 10:34:43 +00:00
|
|
|
|
2008-05-08 10:15:18 +00:00
|
|
|
##
|
|
|
|
# Set mouse cursor coordinates and shape (number or name), and return
|
|
|
|
# current shape (number).
|
|
|
|
#
|
|
|
|
# Example: var cursor = gui.setCursor();
|
|
|
|
# gui.setCursor(nil, nil, "wait");
|
|
|
|
#
|
|
|
|
var setCursor = func(x = nil, y = nil, cursor = nil) {
|
|
|
|
var args = props.Node.new();
|
|
|
|
if (x != nil) args.getNode("x", 1).setIntValue(x);
|
|
|
|
if (y != nil) args.getNode("y", 1).setIntValue(y);
|
|
|
|
if (cursor != nil) {
|
2008-11-20 23:03:24 +00:00
|
|
|
if (num(cursor) == nil)
|
|
|
|
cursor = cursor_types[cursor];
|
|
|
|
if (cursor == nil)
|
|
|
|
die("cursor must be one of: " ~ string.join(", ", keys(cursor_types)));
|
2008-05-08 10:15:18 +00:00
|
|
|
setprop("/sim/mouse/hide-cursor", cursor);
|
|
|
|
args.getNode("cursor", 1).setIntValue(cursor);
|
|
|
|
}
|
|
|
|
fgcommand("set-cursor", args);
|
2014-01-17 00:06:36 +00:00
|
|
|
return args.getValue("cursor");
|
2008-05-08 10:15:18 +00:00
|
|
|
}
|
2012-03-24 11:45:58 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# Supported mouse cursor types.
|
|
|
|
#
|
2009-01-11 15:04:55 +00:00
|
|
|
var cursor_types = { none: 0, pointer: 1, wait: 2, crosshair: 3, leftright: 4,
|
|
|
|
topside: 5, bottomside: 6, leftside: 7, rightside: 8,
|
|
|
|
topleft: 9, topright: 10, bottomleft: 11, bottomright: 12,
|
|
|
|
};
|
2008-05-08 10:15:18 +00:00
|
|
|
|
2012-03-24 11:45:58 +00:00
|
|
|
##
|
|
|
|
# Find a GUI element by given name.
|
|
|
|
# dialog: dialog root property.
|
|
|
|
# name: name of GUI element to be searched.
|
|
|
|
# Returns GUI element when found, nil otherwise.
|
|
|
|
#
|
|
|
|
var findElementByName = func(dialog,name) {
|
|
|
|
foreach( var child; dialog.getChildren() ) {
|
|
|
|
var n = child.getNode( "name" );
|
|
|
|
if( n != nil and n.getValue() == name )
|
|
|
|
return child;
|
|
|
|
var f = findElementByName(child, name);
|
|
|
|
if( f != nil ) return f;
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
};
|
2008-05-08 10:15:18 +00:00
|
|
|
|
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
|
|
|
#
|
2008-07-10 20:13:58 +00:00
|
|
|
var fdm = getprop("/sim/flight-model");
|
|
|
|
var screenHProp = nil;
|
2010-01-04 14:06:30 +00:00
|
|
|
var autopilotDisableProps = [
|
|
|
|
"/autopilot/hide-menu",
|
|
|
|
"/autopilot/KAP140/locks",
|
|
|
|
"/autopilot/CENTURYIIB/locks",
|
|
|
|
"/autopilot/CENTURYIII/locks"
|
|
|
|
];
|
2008-07-10 20:13:58 +00:00
|
|
|
|
2008-11-11 14:54:51 +00:00
|
|
|
_setlistener("/sim/signals/nasal-dir-initialized", func {
|
2003-12-22 20:05:18 +00:00
|
|
|
screenHProp = props.globals.getNode("/sim/startup/ysize");
|
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
|
2008-07-10 20:13:58 +00:00
|
|
|
menuEnable("fuel-and-payload", fdm == "yasim" or fdm == "jsb");
|
2012-09-18 10:29:17 +00:00
|
|
|
menuEnable("aircraft-checklists", props.globals.getNode("/sim/checklists") != nil);
|
2010-01-04 14:06:30 +00:00
|
|
|
var isAutopilotMenuEnabled = func {
|
|
|
|
foreach( var apdp; autopilotDisableProps ) {
|
|
|
|
if( props.globals.getNode( apdp ) != nil )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
menuEnable("autopilot", isAutopilotMenuEnabled() );
|
2006-10-21 10:19:24 +00:00
|
|
|
menuEnable("joystick-info", size(props.globals.getNode("/input/joysticks").getChildren("js")));
|
2012-05-11 22:29:40 +00:00
|
|
|
menuEnable("rendering-buffers", getprop("/sim/rendering/rembrandt/enabled"));
|
2012-05-18 10:53:33 +00:00
|
|
|
menuEnable("rembrandt-buffers-choice", getprop("/sim/rendering/rembrandt/enabled"));
|
2012-06-03 14:19:10 +00:00
|
|
|
menuEnable("stereoscopic-options", !getprop("/sim/rendering/rembrandt/enabled"));
|
2012-09-21 11:30:31 +00:00
|
|
|
menuEnable("sound-config", getprop("/sim/sound/working"));
|
2019-05-01 11:20:44 +00:00
|
|
|
menuEnable("swift_connection", getprop("/sim/swift/available"));
|
2005-12-15 22:00:31 +00:00
|
|
|
|
2011-03-27 22:24:32 +00:00
|
|
|
# frame-per-second display
|
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);
|
2008-11-11 14:54:51 +00:00
|
|
|
setlistener("/sim/startup/xsize", func {
|
|
|
|
if (fps.getValue()) {
|
|
|
|
fpsDisplay(0);
|
|
|
|
fpsDisplay(1);
|
|
|
|
}
|
|
|
|
});
|
2008-11-23 09:53:46 +00:00
|
|
|
|
2011-03-27 22:24:32 +00:00
|
|
|
# frame-latency display
|
|
|
|
var latency = props.globals.getNode("/sim/rendering/frame-latency-display", 1);
|
|
|
|
setlistener(latency, latencyDisplay, 1);
|
|
|
|
setlistener("/sim/startup/xsize", func {
|
|
|
|
if (latency.getValue()) {
|
|
|
|
latencyDisplay(0);
|
|
|
|
latencyDisplay(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2008-11-23 09:53:46 +00:00
|
|
|
# only enable precipitation if gui *and* aircraft want it
|
|
|
|
var p = "/sim/rendering/precipitation-";
|
|
|
|
var precip_gui = getprop(p ~ "gui-enable");
|
|
|
|
var precip_ac = getprop(p ~ "aircraft-enable");
|
|
|
|
props.globals.getNode(p ~ "enable").setAttribute("userarchive", 0); # TODO remove later
|
|
|
|
var set_precip = func setprop(p ~ "enable", precip_gui and precip_ac);
|
2011-03-14 19:51:56 +00:00
|
|
|
setlistener(p ~ "gui-enable", func(n) set_precip(precip_gui = n.getValue()),1);
|
|
|
|
setlistener(p ~ "aircraft-enable", func(n) set_precip(precip_ac = n.getValue()),1);
|
2009-11-16 20:40:15 +00:00
|
|
|
|
|
|
|
# the autovisibility feature of the menubar
|
|
|
|
# automatically show the menubar if the mouse is at the upper edge of the window
|
|
|
|
# the menubar is hidden by a binding to a LMB click in mode 0 in mice.xml
|
|
|
|
var menubarAutoVisibilityListener = nil;
|
|
|
|
var menubarAutoVisibilityEdge = props.globals.initNode( "/sim/menubar/autovisibility/edge-size", 5, "INT" );
|
|
|
|
var menubarVisibility = props.globals.initNode( "/sim/menubar/visibility", 0, "BOOL" );
|
|
|
|
var currentMenubarVisibility = menubarVisibility.getValue();
|
|
|
|
var mouseMode = props.globals.initNode( "/devices/status/mice/mouse/mode", 0, "INT" );
|
|
|
|
|
|
|
|
setlistener( "/sim/menubar/autovisibility/enabled", func(n) {
|
|
|
|
if( n.getValue() and menubarAutoVisibilityListener == nil ) {
|
|
|
|
currentMenubarVisibility = menubarVisibility.getValue();
|
|
|
|
menubarVisibility.setBoolValue( 0 );
|
|
|
|
menubarAutoVisibilityListener = setlistener( "/devices/status/mice/mouse/y", func(n) {
|
|
|
|
if( n.getValue() == nil ) return;
|
|
|
|
if( mouseMode.getValue() != 0 ) return;
|
2010-12-28 19:51:34 +00:00
|
|
|
|
2009-11-16 20:40:15 +00:00
|
|
|
if( n.getValue() <= menubarAutoVisibilityEdge.getValue() )
|
|
|
|
menubarVisibility.setBoolValue( 1 );
|
|
|
|
|
|
|
|
}, 1, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
# don't listen to the mouse position if this feature is enabled
|
|
|
|
if( n.getValue() == 0 and menubarAutoVisibilityListener != nil ) {
|
|
|
|
removelistener( menubarAutoVisibilityListener );
|
|
|
|
menubarAutoVisibilityListener = nil;
|
|
|
|
menubarVisibility.setBoolValue(currentMenubarVisibility);
|
|
|
|
}
|
|
|
|
}, 1, 0);
|
|
|
|
|
2008-11-11 14:54:51 +00:00
|
|
|
});
|
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-10-15 16:30:37 +00:00
|
|
|
var fpsDisplay = func(n) {
|
|
|
|
var w = isa(n, props.Node) ? n.getValue() : n;
|
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
|
|
|
}
|
2011-03-27 22:24:32 +00:00
|
|
|
var latencyDisplay = func(n) {
|
|
|
|
var w = isa(n, props.Node) ? n.getValue() : n;
|
|
|
|
fgcommand(w ? "dialog-show" : "dialog-close", props.Node.new({"dialog-name": "frame-latency"}));
|
|
|
|
}
|
2005-12-09 10:34:43 +00:00
|
|
|
|
2003-12-22 20:05:18 +00:00
|
|
|
##
|
|
|
|
# Pop down the tip dialog, if it is visible.
|
|
|
|
#
|
2013-08-26 19:05:01 +00:00
|
|
|
var popdown = func { fgcommand("clear-message", props.Node.new({"id": canvas.tooltip.getTooltipId()})); }
|
2003-12-22 20:05:18 +00:00
|
|
|
|
|
|
|
# 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.
|
2008-07-10 20:13:58 +00:00
|
|
|
var 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.
|
|
|
|
#
|
2008-07-10 20:13:58 +00:00
|
|
|
var Widget = {
|
2013-10-20 03:34:56 +00:00
|
|
|
set : func(name, val) { me.node.getNode(name, 1).setValue(val); },
|
2004-05-15 21:50:51 +00:00
|
|
|
prop : func { return me.node; },
|
|
|
|
new : func { return { parents : [Widget], node : props.Node.new() } },
|
2013-10-20 03:34:56 +00:00
|
|
|
addChild : func(type) {
|
2012-03-23 21:25:31 +00:00
|
|
|
var idx = size(me.node.getChildren(type));
|
|
|
|
var name = type ~ "[" ~ idx ~ "]";
|
|
|
|
var newnode = me.node.getNode(name, 1);
|
2004-05-15 21:50:51 +00:00
|
|
|
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-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();
|
|
|
|
#
|
2008-07-10 20:13:58 +00:00
|
|
|
var Dialog = {
|
2008-10-14 18:41:19 +00:00
|
|
|
new: func(prop, path = nil, name = nil) {
|
|
|
|
var m = { parents: [Dialog] };
|
2006-08-24 16:32:09 +00:00
|
|
|
m.state = 0;
|
2012-03-24 09:45:42 +00:00
|
|
|
m.listener = nil;
|
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
|
|
|
|
2008-10-15 15:27:56 +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
|
|
|
},
|
2012-03-24 09:45:42 +00:00
|
|
|
del: func
|
|
|
|
{
|
|
|
|
if (me.listener != nil)
|
|
|
|
removelistener(me.listener);
|
|
|
|
},
|
2006-08-24 16:32:09 +00:00
|
|
|
# doesn't need to be called explicitly, but can be used to force a reload
|
2008-10-14 18:41:19 +00:00
|
|
|
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();
|
2010-08-15 10:27:15 +00:00
|
|
|
io.read_properties(me.path, me.prop);
|
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
|
2008-10-14 18:41:19 +00:00
|
|
|
namespace: func {
|
2007-02-26 11:00:04 +00:00
|
|
|
var ns = "__dlg:" ~ me.name;
|
|
|
|
me.state and contains(globals, ns) ? globals[ns] : nil;
|
|
|
|
},
|
2008-10-14 18:41:19 +00:00
|
|
|
open: func {
|
2006-08-24 16:32:09 +00:00
|
|
|
fgcommand("dialog-show", me.prop);
|
|
|
|
me.state = 1;
|
|
|
|
},
|
2008-10-14 18:41:19 +00:00
|
|
|
close: func {
|
2006-08-24 16:32:09 +00:00
|
|
|
fgcommand("dialog-close", me.prop);
|
|
|
|
me.state = 0;
|
|
|
|
},
|
2008-10-14 18:41:19 +00:00
|
|
|
toggle: func {
|
2006-08-24 16:32:09 +00:00
|
|
|
me.state ? me.close() : me.open();
|
|
|
|
},
|
2008-10-14 18:41:19 +00:00
|
|
|
is_open: func {
|
2006-08-24 16:32:09 +00:00
|
|
|
me.state;
|
|
|
|
},
|
2008-10-14 18:41:19 +00:00
|
|
|
instance: {},
|
2006-08-24 16:32:09 +00:00
|
|
|
};
|
|
|
|
|
2006-08-27 19:27:21 +00:00
|
|
|
|
2008-10-15 15:27:56 +00:00
|
|
|
##
|
|
|
|
# Overlay selector. Displays a list of overlay XML files and copies the
|
|
|
|
# chosen one to the property tree. The class allows to select liveries,
|
|
|
|
# insignia, decals, variants, etc. Usually the overlay properties are
|
|
|
|
# fed to "select" and "material" animations.
|
|
|
|
#
|
|
|
|
# SYNOPSIS:
|
2008-10-19 11:52:56 +00:00
|
|
|
# OverlaySelector.new(<title>, <dir>, <nameprop> [, <sortprop> [, <mpprop> [, <callback>]]]);
|
2008-10-15 15:27:56 +00:00
|
|
|
#
|
|
|
|
# title ... dialog title
|
|
|
|
# dir ... directory where to find the XML overlay files,
|
|
|
|
# relative to FG_ROOT
|
|
|
|
# nameprop ... property in an overlay file that contains the name
|
2008-10-16 15:26:19 +00:00
|
|
|
# The result is written to this place in the
|
|
|
|
# property tree.
|
2008-10-15 15:27:56 +00:00
|
|
|
# sortprop ... property in an overlay file that should be used
|
|
|
|
# as sorting criterion, if alphabetic sorting by
|
2008-10-15 16:13:10 +00:00
|
|
|
# name is undesirable. Use nil if you don't need
|
|
|
|
# this, but want to set a callback function.
|
2008-10-19 11:52:56 +00:00
|
|
|
# mpprop ... property path of MP node where the file name should
|
|
|
|
# be written to
|
2008-10-16 15:26:19 +00:00
|
|
|
# callback ... function that's called after a new entry was chosen,
|
|
|
|
# with these arguments:
|
|
|
|
#
|
|
|
|
# callback(<number>, <name>, <sort-criterion>, <file>, <path>)
|
2008-10-15 15:27:56 +00:00
|
|
|
#
|
|
|
|
# EXAMPLE:
|
|
|
|
# aircraft.data.add("sim/model/pilot"); # autosave the pilot
|
|
|
|
# var pilots_dialog = gui.OverlaySelector.new("Pilots",
|
|
|
|
# "Aircraft/foo/Models/Pilots",
|
|
|
|
# "sim/model/pilot");
|
|
|
|
#
|
|
|
|
# pilots_dialog.open(); # or ... close(), or toggle()
|
|
|
|
#
|
|
|
|
#
|
|
|
|
var OverlaySelector = {
|
2008-10-19 11:52:56 +00:00
|
|
|
new: func(title, dir, nameprop, sortprop = nil, mpprop = nil, callback = nil) {
|
2008-10-15 15:27:56 +00:00
|
|
|
var name = "overlay-select-";
|
|
|
|
var data = props.globals.getNode("/sim/gui/dialogs/", 1);
|
2008-10-16 15:26:19 +00:00
|
|
|
for (var i = 1; 1; i += 1)
|
2008-10-15 15:27:56 +00:00
|
|
|
if (data.getNode(name ~ i, 0) == nil)
|
|
|
|
break;
|
|
|
|
data = data.getNode(name ~= i, 1);
|
|
|
|
|
|
|
|
var m = Dialog.new(data.getNode("dialog", 1), "gui/dialogs/overlay-select.xml", name);
|
|
|
|
m.parents = [OverlaySelector, Dialog];
|
2010-12-28 19:51:34 +00:00
|
|
|
|
2010-08-15 10:27:15 +00:00
|
|
|
# resolve the path in FG_ROOT, and --fg-aircraft dir, etc
|
|
|
|
m.dir = resolvepath(dir) ~ "/";
|
2010-12-28 19:51:34 +00:00
|
|
|
|
2008-10-19 12:34:09 +00:00
|
|
|
var relpath = func(p) substr(p, p[0] == `/`);
|
|
|
|
m.nameprop = relpath(nameprop);
|
|
|
|
m.sortprop = relpath(sortprop or nameprop);
|
2008-10-19 11:52:56 +00:00
|
|
|
m.mpprop = mpprop;
|
2008-10-15 16:13:10 +00:00
|
|
|
m.callback = callback;
|
2011-09-18 10:36:40 +00:00
|
|
|
m.title = title;
|
|
|
|
m.dialog_name = name;
|
2008-11-20 19:45:40 +00:00
|
|
|
m.result = data.initNode("result", "");
|
2008-10-15 15:27:56 +00:00
|
|
|
m.listener = setlistener(m.result, func(n) m.select(n.getValue()));
|
2008-11-12 11:43:26 +00:00
|
|
|
if (m.mpprop != nil)
|
2008-10-19 11:52:56 +00:00
|
|
|
aircraft.data.add(m.nameprop);
|
2011-09-18 10:36:40 +00:00
|
|
|
m.reinit();
|
|
|
|
# need to reinit again, whenever the GUI is reloaded
|
|
|
|
m.reinit_listener = setlistener("/sim/signals/reinit-gui", func(n) m.reinit());
|
2008-10-15 15:27:56 +00:00
|
|
|
return m;
|
|
|
|
},
|
2011-09-18 10:36:40 +00:00
|
|
|
reinit: func {
|
|
|
|
me.prop.getNode("group/text/label").setValue(me.title);
|
|
|
|
me.prop.getNode("group/button/binding/script").setValue('gui.Dialog.instance["' ~ me.dialog_name ~ '"].close()');
|
|
|
|
me.list = me.prop.getNode("list");
|
|
|
|
me.list.getNode("property").setValue(me.result.getPath());
|
|
|
|
me.rescan();
|
|
|
|
me.current = -1;
|
|
|
|
me.select(getprop(me.nameprop) or "");
|
|
|
|
},
|
2008-10-15 15:27:56 +00:00
|
|
|
del: func {
|
|
|
|
removelistener(me.listener);
|
2011-09-18 10:36:40 +00:00
|
|
|
removelistener(me.reinit_listener);
|
2012-03-24 09:45:42 +00:00
|
|
|
# call inherited 'del'
|
|
|
|
me.parents = subvec(me.parents,1);
|
|
|
|
me.del();
|
2008-10-15 15:27:56 +00:00
|
|
|
},
|
|
|
|
rescan: func {
|
|
|
|
me.data = [];
|
2009-01-11 02:42:33 +00:00
|
|
|
var files = directory(me.dir);
|
|
|
|
if (size(files)) {
|
|
|
|
foreach (var file; files) {
|
|
|
|
if (substr(file, -4) != ".xml")
|
|
|
|
continue;
|
|
|
|
var n = io.read_properties(me.dir ~ file);
|
|
|
|
var name = n.getNode(me.nameprop, 1).getValue();
|
|
|
|
var index = n.getNode(me.sortprop, 1).getValue();
|
|
|
|
if (name == nil or index == nil)
|
|
|
|
continue;
|
|
|
|
append(me.data, [name, index, substr(file, 0, size(file) - 4), me.dir ~ file]);
|
|
|
|
}
|
|
|
|
me.data = sort(me.data, func(a, b) num(a[1]) == nil or num(b[1]) == nil
|
|
|
|
? cmp(a[1], b[1]) : a[1] - b[1]);
|
2008-10-15 15:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
me.list.removeChildren("value");
|
|
|
|
forindex (var i; me.data)
|
|
|
|
me.list.getChild("value", i, 1).setValue(me.data[i][0]);
|
|
|
|
},
|
|
|
|
set: func(index) {
|
2008-10-15 16:13:10 +00:00
|
|
|
var last = me.current;
|
2008-10-15 15:27:56 +00:00
|
|
|
me.current = math.mod(index, size(me.data));
|
2008-10-16 15:26:19 +00:00
|
|
|
io.read_properties(me.data[me.current][3], props.globals);
|
2008-10-15 16:13:10 +00:00
|
|
|
if (last != me.current and me.callback != nil)
|
|
|
|
call(me.callback, [me.current] ~ me.data[me.current], me);
|
2008-11-12 11:43:26 +00:00
|
|
|
if (me.mpprop != nil)
|
2008-10-19 11:52:56 +00:00
|
|
|
setprop(me.mpprop, me.data[me.current][2]);
|
2008-10-15 15:27:56 +00:00
|
|
|
},
|
|
|
|
select: func(name) {
|
|
|
|
forindex (var i; me.data)
|
|
|
|
if (me.data[i][0] == name)
|
|
|
|
me.set(i);
|
|
|
|
},
|
|
|
|
next: func {
|
|
|
|
me.set(me.current + 1);
|
|
|
|
},
|
|
|
|
previous: func {
|
|
|
|
me.set(me.current - 1);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
#
|
2007-10-15 18:27:42 +00:00
|
|
|
# callback ... callback function that gets return value as first argument
|
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-22 18:49:38 +00:00
|
|
|
# dotfiles ... flag that decides whether UNIX dotfiles should be shown (1) or not (0)
|
2007-06-14 23:19:43 +00:00
|
|
|
#
|
|
|
|
# EXAMPLE:
|
|
|
|
#
|
2007-10-15 18:27:42 +00:00
|
|
|
# var report = func(n) { print("file ", n.getValue(), " selected") }
|
2007-06-22 14:13:30 +00:00
|
|
|
# var selector = gui.FileSelector.new(
|
|
|
|
# report, # callback function
|
2007-06-22 18:49:38 +00:00
|
|
|
# "Save Flight", # dialog title
|
2007-06-22 14:13:30 +00:00
|
|
|
# "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 = {
|
2011-08-21 13:00:45 +00:00
|
|
|
new: func(callback, title, button, pattern = nil, dir = "", file = "", dotfiles = 0, show_files=1) {
|
2013-01-26 14:16:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
var usage = gui.FILE_DIALOG_OPEN_FILE;
|
|
|
|
if (!show_files) {
|
|
|
|
usage = gui.FILE_DIALOG_CHOOSE_DIR;
|
|
|
|
} else if (button == 'Save') {
|
|
|
|
# nasty, should make this explicit
|
|
|
|
usage = gui.FILE_DIALOG_SAVE_FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
m = { parents:[FileSelector],
|
|
|
|
_inner: gui._createFileDialog(usage)};
|
|
|
|
|
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);
|
2013-01-26 14:16:00 +00:00
|
|
|
|
|
|
|
m._inner.setCallback(func (path) {
|
|
|
|
var node = props.Node.new();
|
|
|
|
node.setValue(path);
|
|
|
|
callback(node);
|
|
|
|
} );
|
|
|
|
|
2007-06-14 23:19:43 +00:00
|
|
|
return m;
|
|
|
|
},
|
2007-06-17 22:56:22 +00:00
|
|
|
# setters only take effect after the next call to open()
|
2013-01-26 14:16:00 +00:00
|
|
|
set_title: func(title) { me._inner.title = title },
|
|
|
|
set_button: func(button) { me._inner.button = button },
|
2016-12-30 01:22:23 +00:00
|
|
|
set_directory: func(dir) { me._inner.directory = dir },
|
2013-01-26 14:16:00 +00:00
|
|
|
set_file: func(file) { me._inner.placeholder = file },
|
|
|
|
set_dotfiles: func(dot) { me._inner.show_hidden = dot },
|
|
|
|
set_pattern: func(pattern) { me._inner.pattern = (pattern == nil) ? [] : pattern },
|
|
|
|
|
|
|
|
open: func() { me._inner.open(); },
|
|
|
|
close: func() { me._inner.close(); },
|
|
|
|
|
2008-10-14 18:41:19 +00:00
|
|
|
del: func {
|
2013-01-26 14:16:00 +00:00
|
|
|
me._inner.close();
|
|
|
|
me._inner = nil;
|
2007-06-14 23:19:43 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-08-21 13:00:45 +00:00
|
|
|
##
|
|
|
|
# DirSelector - convenience "class" (indeed using a reconfigured FileSelector)
|
|
|
|
#
|
|
|
|
var DirSelector = {
|
|
|
|
new: func(callback, title, button, dir = "") {
|
2012-03-23 21:25:31 +00:00
|
|
|
return FileSelector.new(callback, title, button, nil, dir, "", 0, 0);
|
2011-08-21 13:00:45 +00:00
|
|
|
}
|
|
|
|
};
|
2007-06-14 23:19:43 +00:00
|
|
|
|
2008-07-11 20:57:52 +00:00
|
|
|
##
|
|
|
|
# Save/load flight menu functions.
|
|
|
|
#
|
|
|
|
var save_flight_sel = nil;
|
|
|
|
var save_flight = func {
|
2008-07-29 00:07:18 +00:00
|
|
|
foreach (var n; props.globals.getNode("/sim/presets").getChildren())
|
|
|
|
n.setAttribute("archive", 1);
|
2008-07-11 20:57:52 +00:00
|
|
|
var save = func(n) fgcommand("save", props.Node.new({ file: n.getValue() }));
|
|
|
|
if (save_flight_sel == nil)
|
|
|
|
save_flight_sel = FileSelector.new(save, "Save Flight", "Save",
|
|
|
|
["*.sav"], getprop("/sim/fg-home"), "flight.sav");
|
|
|
|
save_flight_sel.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var load_flight_sel = nil;
|
|
|
|
var load_flight = func {
|
2008-08-03 13:41:07 +00:00
|
|
|
var load = func(n) {
|
|
|
|
fgcommand("load", props.Node.new({ file: n.getValue() }));
|
2014-03-05 16:46:10 +00:00
|
|
|
fgcommand("reposition");
|
2008-07-29 00:07:18 +00:00
|
|
|
}
|
2008-07-11 20:57:52 +00:00
|
|
|
if (load_flight_sel == nil)
|
|
|
|
load_flight_sel = FileSelector.new(load, "Load Flight", "Load",
|
|
|
|
["*.sav"], getprop("/sim/fg-home"), "flight.sav");
|
|
|
|
load_flight_sel.open();
|
|
|
|
}
|
|
|
|
|
2011-08-21 13:17:16 +00:00
|
|
|
##
|
|
|
|
# Screen-shot directory menu function
|
|
|
|
#
|
|
|
|
var set_screenshotdir_sel = nil;
|
|
|
|
var set_screenshotdir = func {
|
|
|
|
if (set_screenshotdir_sel == nil)
|
|
|
|
set_screenshotdir_sel = gui.DirSelector.new(
|
|
|
|
func(result) { setprop("/sim/paths/screenshot-dir", result.getValue()); },
|
|
|
|
"Select Screenshot Directory", "Ok", getprop("/sim/paths/screenshot-dir"));
|
|
|
|
set_screenshotdir_sel.open();
|
|
|
|
}
|
2008-07-11 20:57:52 +00:00
|
|
|
|
2006-08-24 12:44:14 +00:00
|
|
|
##
|
|
|
|
# Open property browser with given target path.
|
|
|
|
#
|
2007-11-28 22:22:29 +00:00
|
|
|
var property_browser = func(dir = nil) {
|
|
|
|
if (dir == nil)
|
|
|
|
dir = "/";
|
|
|
|
elsif (isa(dir, props.Node))
|
2007-11-14 20:13:35 +00:00
|
|
|
dir = dir.getPath();
|
2006-08-24 16:32:09 +00:00
|
|
|
var dlgname = "property-browser";
|
2008-08-05 05:28:27 +00:00
|
|
|
foreach (var module; keys(globals))
|
|
|
|
if (find("__dlg:" ~ dlgname, module) == 0)
|
|
|
|
return globals[module].clone(dir);
|
|
|
|
|
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 {
|
2007-11-28 22:22:29 +00:00
|
|
|
foreach (var b; props.globals.getChildren("browser"))
|
|
|
|
if ((var browser = b.getValue()) != nil)
|
|
|
|
foreach (var path; split(",", browser))
|
|
|
|
if (size(path))
|
|
|
|
property_browser(string.trim(path));
|
|
|
|
|
2006-08-24 16:32:09 +00:00
|
|
|
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...) {
|
2008-10-14 18:41:19 +00:00
|
|
|
var n = props.Node.new({ "dialog-name": dialog });
|
2008-08-05 05:28:27 +00:00
|
|
|
if (!size(objects))
|
2007-03-29 14:50:27 +00:00
|
|
|
return fgcommand("dialog-apply", n);
|
2008-08-05 05:28:27 +00:00
|
|
|
|
2007-03-29 14:50:27 +00:00
|
|
|
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...) {
|
2008-10-14 18:41:19 +00:00
|
|
|
var n = props.Node.new({ "dialog-name": dialog });
|
2008-08-05 05:28:27 +00:00
|
|
|
if (!size(objects))
|
2007-03-29 14:50:27 +00:00
|
|
|
return fgcommand("dialog-update", n);
|
2008-08-05 05:28:27 +00:00
|
|
|
|
2007-03-29 14:50:27 +00:00
|
|
|
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
|
|
|
|
2008-08-03 13:41:07 +00:00
|
|
|
##
|
|
|
|
# Searches a dialog tree for widgets with a particular <name> entry and
|
2008-08-05 05:28:27 +00:00
|
|
|
# sets their <enabled> flag.
|
2008-08-03 13:41:07 +00:00
|
|
|
#
|
2008-08-05 05:28:27 +00:00
|
|
|
var enable_widgets = func(node, name, enable = 1) {
|
2008-08-03 13:41:07 +00:00
|
|
|
foreach (var n; node.getChildren())
|
2008-08-05 05:28:27 +00:00
|
|
|
enable_widgets(n, name, enable);
|
2008-08-03 13:41:07 +00:00
|
|
|
if ((var n = node.getNode("name")) != nil and n.getValue() == name)
|
2008-08-05 05:28:27 +00:00
|
|
|
node.getNode("enabled", 1).setBoolValue(enable);
|
2008-08-03 13:41:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-13 10:56:42 +00:00
|
|
|
########################################################################
|
|
|
|
# GUI theming
|
|
|
|
########################################################################
|
|
|
|
|
2007-07-17 10:05:14 +00:00
|
|
|
var nextStyle = func {
|
|
|
|
var curr = getprop("/sim/gui/current-style");
|
|
|
|
var styles = props.globals.getNode("/sim/gui").getChildren("style");
|
|
|
|
forindex (var i; styles)
|
|
|
|
if (styles[i].getIndex() == curr)
|
|
|
|
break;
|
|
|
|
if ((i += 1) >= size(styles))
|
|
|
|
i = 0;
|
|
|
|
setprop("/sim/gui/current-style", styles[i].getIndex());
|
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
|
|
|
|
########################################################################
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var dialog = {};
|
2005-04-19 13:43:44 +00:00
|
|
|
|
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)...
|
2018-08-07 17:25:26 +00:00
|
|
|
var ti = wgt.getNode("tank");
|
|
|
|
|
|
|
|
if(ti == nil or ti.getValue() == "") {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
ti = ti.getValue();
|
|
|
|
|
2006-08-25 19:59:05 +00:00
|
|
|
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;
|
2018-08-07 17:25:26 +00:00
|
|
|
var root_node = nil;
|
|
|
|
if(fdm == "yasim")
|
|
|
|
root_node = props.globals.getNode("sim");
|
|
|
|
elsif (fdm == "jsb")
|
|
|
|
root_node = props.globals.getNode("payload");
|
|
|
|
if (root_node == nil) {
|
|
|
|
print("setWeight() - not supported for ",fdm);
|
|
|
|
tankchange = nil;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
foreach (var w; root_node.getChildren("weight")) {
|
|
|
|
var selected = w.getNode("selected");
|
|
|
|
if (selected != nil) {
|
|
|
|
foreach (var opt; w.getChildren("opt")) {
|
|
|
|
if (opt.getNode("name", 1).getValue() == selected.getValue()) {
|
|
|
|
if (setWeight(w, opt)) {
|
|
|
|
tankchange = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-10-17 19:22:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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) });
|
2008-05-08 10:15:18 +00:00
|
|
|
_setlistener("/sim/signals/reinit", func(n) { props._getValue(n, []) 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.
|
2018-08-07 17:25:26 +00:00
|
|
|
# 2018.3 - change to restore the current dialog as the topmost
|
|
|
|
# as otherwise the open / close will put this dialog at the
|
|
|
|
# front of the display. Requires the new logic in the core
|
|
|
|
# that maintains /sim/gui/dialogs/current-dialog
|
2006-08-25 19:59:05 +00:00
|
|
|
if(tankchanged) {
|
2018-08-07 17:25:26 +00:00
|
|
|
var current_dialog = getprop("/sim/gui/dialogs/current-dialog");
|
2008-10-14 18:41:19 +00:00
|
|
|
var p = props.Node.new({"dialog-name": "WeightAndFuel"});
|
2006-10-17 19:22:36 +00:00
|
|
|
fgcommand("dialog-close", p);
|
|
|
|
showWeightDialog();
|
2018-08-07 17:25:26 +00:00
|
|
|
if (current_dialog != ""){
|
|
|
|
var show_node = props.Node.new({"dialog-name": current_dialog});
|
|
|
|
debug.dump(show_node);
|
|
|
|
fgcommand("dialog-show", show_node);
|
|
|
|
}
|
2006-08-25 19:59:05 +00:00
|
|
|
}
|
2006-08-24 22:29:16 +00:00
|
|
|
}
|
2005-04-19 13:43:44 +00:00
|
|
|
|
2018-08-07 17:25:26 +00:00
|
|
|
# 2018.3 - certain aircraft (e.g. the F-15) have their own external stores dialog
|
|
|
|
# in addition to the standard one. This listener and associated code
|
|
|
|
# allow the two dialogs to remain synchronised.
|
|
|
|
|
|
|
|
var weightDialogOpen = 0;
|
|
|
|
setprop("sim/gui/dialogs/payload-reload",0);
|
|
|
|
|
|
|
|
_setlistener("sim/gui/dialogs/payload-reload", func(v){
|
|
|
|
if (weightDialogOpen)
|
|
|
|
weightChangeHandler();
|
|
|
|
});
|
2008-07-10 20:13:58 +00:00
|
|
|
|
|
|
|
|
2004-05-15 21:50:51 +00:00
|
|
|
##
|
|
|
|
# Dynamically generates a weight & fuel configuration dialog specific to
|
|
|
|
# the aircraft.
|
|
|
|
#
|
2018-08-07 17:25:26 +00:00
|
|
|
var weightAndFuel_x = nil;
|
|
|
|
var weightAndFuel_y = nil;
|
|
|
|
|
|
|
|
var dlg_nasal_close = "gui.weightAndFuel_y = cmdarg().getNode(\"lasty\").getValue();gui.weightAndFuel_x = cmdarg().getNode(\"lastx\").getValue();gui.weightDialogOpen = 0;";
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var showWeightDialog = func {
|
|
|
|
var name = "WeightAndFuel";
|
2013-12-01 03:18:31 +00:00
|
|
|
# menu entry is "Fuel and Payload"
|
|
|
|
var title = "Fuel and Payload Settings";
|
2018-08-07 17:25:26 +00:00
|
|
|
weightDialogOpen = 1;
|
2004-05-15 21:50:51 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
2018-08-07 17:25:26 +00:00
|
|
|
# 2018.3 - add a close method that will remember the coordinates and also clear the flag that
|
|
|
|
# indicates this dialog is visible
|
|
|
|
var nasal = dialog[name].addChild("nasal");
|
|
|
|
var nasal_close = nasal.addChild("close");
|
|
|
|
nasal_close.node.setValue(dlg_nasal_close);
|
|
|
|
|
|
|
|
# if we have an X coordinate then set both (to the previous position as recorded on close).
|
|
|
|
if (weightAndFuel_x != nil){
|
|
|
|
dialog[name].set("x", weightAndFuel_x);
|
|
|
|
dialog[name].set("y", weightAndFuel_y);
|
|
|
|
}
|
|
|
|
|
2010-12-28 19:51:34 +00:00
|
|
|
var header = dialog[name].addChild("group");
|
|
|
|
header.set("layout", "hbox");
|
|
|
|
header.addChild("empty").set("stretch", "1");
|
|
|
|
header.addChild("text").set("label", title);
|
|
|
|
header.addChild("empty").set("stretch", "1");
|
|
|
|
var w = header.addChild("button");
|
|
|
|
w.set("pref-width", 16);
|
|
|
|
w.set("pref-height", 16);
|
|
|
|
w.set("legend", "");
|
|
|
|
w.set("default", 0);
|
2013-12-01 03:18:31 +00:00
|
|
|
# "Esc" causes dialog-close
|
|
|
|
w.set("key", "Esc");
|
2010-12-28 19:51:34 +00:00
|
|
|
w.setBinding("dialog-close");
|
2004-05-15 21:50:51 +00:00
|
|
|
|
2007-03-26 15:26:23 +00:00
|
|
|
dialog[name].addChild("hrule");
|
2005-10-18 20:15:04 +00:00
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
if (fdm != "yasim" and fdm != "jsb") {
|
|
|
|
var msg = dialog[name].addChild("text");
|
2005-10-18 20:15:04 +00:00
|
|
|
msg.set("label", "Not supported for this aircraft");
|
2008-07-10 20:13:58 +00:00
|
|
|
var cancel = dialog[name].addChild("button");
|
2008-10-02 15:19:47 +00:00
|
|
|
cancel.set("key", "Esc");
|
2005-10-18 20:15:04 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
# FDM dependent settings
|
|
|
|
if(fdm == "yasim") {
|
|
|
|
var fdmdata = {
|
|
|
|
grosswgt : "/yasim/gross-weight-lbs",
|
|
|
|
payload : "/sim",
|
2017-01-23 16:57:18 +00:00
|
|
|
cg : "/fdm/yasim/cg-x-m",
|
2008-07-10 20:13:58 +00:00
|
|
|
};
|
2017-01-23 16:57:18 +00:00
|
|
|
setprop("/limits/mass-and-balance/cg/dimension","m");
|
2008-07-10 20:13:58 +00:00
|
|
|
} elsif(fdm == "jsb") {
|
|
|
|
var fdmdata = {
|
|
|
|
grosswgt : "/fdm/jsbsim/inertia/weight-lbs",
|
|
|
|
payload : "/payload",
|
2010-01-04 14:06:30 +00:00
|
|
|
cg : "/fdm/jsbsim/inertia/cg-x-in",
|
2008-07-10 20:13:58 +00:00
|
|
|
};
|
|
|
|
}
|
2005-10-18 20:15:04 +00:00
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var contentArea = dialog[name].addChild("group");
|
2004-05-15 21:50:51 +00:00
|
|
|
contentArea.set("layout", "hbox");
|
2012-07-29 21:44:14 +00:00
|
|
|
contentArea.set("default-padding", 10);
|
|
|
|
|
|
|
|
dialog[name].addChild("empty");
|
|
|
|
|
|
|
|
var limits = dialog[name].addChild("group");
|
|
|
|
limits.set("layout", "table");
|
|
|
|
limits.set("halign", "center");
|
|
|
|
var row = 0;
|
|
|
|
|
|
|
|
var massLimits = props.globals.getNode("/limits/mass-and-balance");
|
|
|
|
|
|
|
|
var tablerow = func(name, node, format ) {
|
|
|
|
|
|
|
|
var n = isa( node, props.Node ) ? node : massLimits.getNode( node );
|
|
|
|
if( n == nil ) return;
|
|
|
|
|
|
|
|
var label = limits.addChild("text");
|
|
|
|
label.set("row", row);
|
|
|
|
label.set("col", 0);
|
|
|
|
label.set("halign", "right");
|
|
|
|
label.set("label", name ~ ":");
|
|
|
|
|
|
|
|
var val = limits.addChild("text");
|
|
|
|
val.set("row", row);
|
|
|
|
val.set("col", 1);
|
|
|
|
val.set("halign", "left");
|
|
|
|
val.set("label", "0123457890123456789");
|
|
|
|
val.set("format", format);
|
|
|
|
val.set("property", n.getPath());
|
|
|
|
val.set("live", 1);
|
|
|
|
|
|
|
|
row += 1;
|
|
|
|
}
|
2004-05-15 21:50:51 +00:00
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var grossWgt = props.globals.getNode(fdmdata.grosswgt);
|
2004-05-15 21:50:51 +00:00
|
|
|
if(grossWgt != nil) {
|
2012-07-29 21:44:14 +00:00
|
|
|
tablerow("Gross Weight", grossWgt, "%.0f lb");
|
2004-05-15 21:50:51 +00:00
|
|
|
}
|
|
|
|
|
2010-01-04 14:06:30 +00:00
|
|
|
if(massLimits != nil ) {
|
2012-07-29 21:44:14 +00:00
|
|
|
tablerow("Max. Ramp Weight", "maximum-ramp-mass-lbs", "%.0f lb" );
|
|
|
|
tablerow("Max. Takeoff Weight", "maximum-takeoff-mass-lbs", "%.0f lb" );
|
|
|
|
tablerow("Max. Landing Weight", "maximum-landing-mass-lbs", "%.0f lb" );
|
2013-01-22 21:35:33 +00:00
|
|
|
tablerow("Max. Arrested Landing Weight", "maximum-arrested-landing-mass-lbs", "%.0f lb" );
|
2012-07-29 21:44:14 +00:00
|
|
|
tablerow("Max. Zero Fuel Weight", "maximum-zero-fuel-mass-lbs", "%.0f lb" );
|
|
|
|
}
|
2010-01-04 14:06:30 +00:00
|
|
|
|
2012-07-29 21:44:14 +00:00
|
|
|
if( fdmdata.cg != nil ) {
|
|
|
|
var n = props.globals.getNode("/limits/mass-and-balance/cg/dimension");
|
2017-01-23 16:57:18 +00:00
|
|
|
tablerow("Center of Gravity", props.globals.getNode(fdmdata.cg), "%.2f " ~ (n == nil ? "in" : n.getValue()));
|
2010-01-04 14:06:30 +00:00
|
|
|
}
|
|
|
|
|
2010-12-28 19:51:34 +00:00
|
|
|
dialog[name].addChild("hrule");
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var 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
|
|
|
|
2010-12-28 19:51:34 +00:00
|
|
|
var close = buttonBar.addChild("button");
|
|
|
|
close.set("legend", "Close");
|
|
|
|
close.set("default", "true");
|
|
|
|
close.set("key", "Enter");
|
|
|
|
close.setBinding("dialog-close");
|
2004-05-15 21:50:51 +00:00
|
|
|
|
|
|
|
# Temporary helper function
|
2008-07-10 20:13:58 +00:00
|
|
|
var tcell = func(parent, type, row, col) {
|
|
|
|
var cell = parent.addChild(type);
|
2006-08-24 22:29:16 +00:00
|
|
|
cell.set("row", row);
|
|
|
|
cell.set("col", col);
|
2004-05-15 21:50:51 +00:00
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Fill in the content area
|
|
|
|
#
|
2008-07-10 20:13:58 +00:00
|
|
|
var fuelArea = contentArea.addChild("group");
|
2004-05-15 21:50:51 +00:00
|
|
|
fuelArea.set("layout", "vbox");
|
|
|
|
fuelArea.addChild("text").set("label", "Fuel Tanks");
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var fuelTable = fuelArea.addChild("group");
|
2004-05-15 21:50:51 +00:00
|
|
|
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");
|
2012-07-29 21:44:14 +00:00
|
|
|
tcell(fuelTable, "text", 0, 5).set("label", "Fraction");
|
2004-05-15 21:50:51 +00:00
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var tanks = props.globals.getNode("/consumables/fuel").getChildren("tank");
|
2012-03-23 21:25:31 +00:00
|
|
|
for(var i=0; i<size(tanks); i+=1) {
|
2008-07-10 20:13:58 +00:00
|
|
|
var t = tanks[i];
|
2014-11-19 19:14:18 +00:00
|
|
|
var hidden=0;
|
2008-07-10 20:13:58 +00:00
|
|
|
var tname = i ~ "";
|
2014-11-19 19:14:18 +00:00
|
|
|
var hnode = t.getNode("hidden");
|
|
|
|
if(hnode != nil) { hidden = hnode.getValue(); }# Check for <hidden> property ,skip adding tank if true#
|
|
|
|
if(!hidden){
|
2008-07-10 20:13:58 +00:00
|
|
|
var tnode = t.getNode("name");
|
2004-05-15 21:50:51 +00:00
|
|
|
if(tnode != nil) { tname = tnode.getValue(); }
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var tankprop = "/consumables/fuel/tank["~i~"]";
|
2004-05-15 21:50:51 +00:00
|
|
|
|
2011-04-02 09:29:40 +00:00
|
|
|
var cap = t.getNode("capacity-gal_us", 0);
|
2004-05-15 21:50:51 +00:00
|
|
|
|
|
|
|
# Hack, to ignore the "ghost" tanks created by the C++ code.
|
2011-04-02 09:29:40 +00:00
|
|
|
if(cap == nil ) { continue; }
|
|
|
|
cap = cap.getValue();
|
2004-05-15 21:50:51 +00:00
|
|
|
|
2012-07-29 21:44:14 +00:00
|
|
|
# Ignore tanks of capacity 0
|
|
|
|
if (cap == 0) { continue; }
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var title = tcell(fuelTable, "text", i+1, 0);
|
2004-05-15 21:50:51 +00:00
|
|
|
title.set("label", tname);
|
|
|
|
title.set("halign", "right");
|
|
|
|
|
2008-12-04 11:34:05 +00:00
|
|
|
var selected = props.globals.initNode(tankprop ~ "/selected", 1, "BOOL");
|
|
|
|
if (selected.getAttribute("writable")) {
|
|
|
|
var sel = tcell(fuelTable, "checkbox", i+1, 1);
|
|
|
|
sel.set("property", tankprop ~ "/selected");
|
|
|
|
sel.set("live", 1);
|
|
|
|
sel.setBinding("dialog-apply");
|
|
|
|
}
|
2004-05-15 21:50:51 +00:00
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var slider = tcell(fuelTable, "slider", i+1, 2);
|
2004-05-15 21:50:51 +00:00
|
|
|
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
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var lbs = tcell(fuelTable, "text", i+1, 3);
|
2009-02-06 23:14:49 +00:00
|
|
|
lbs.set("property", tankprop ~ "/level-lbs");
|
2005-03-26 22:15:26 +00:00
|
|
|
lbs.set("label", "0123456");
|
2010-01-04 14:06:30 +00:00
|
|
|
lbs.set("format", cap < 1 ? "%.3f" : cap < 10 ? "%.2f" : "%.1f" );
|
2012-07-29 21:44:14 +00:00
|
|
|
lbs.set("halign", "right");
|
2004-05-15 21:50:51 +00:00
|
|
|
lbs.set("live", 1);
|
2005-04-19 13:43:44 +00:00
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var gals = tcell(fuelTable, "text", i+1, 4);
|
2004-05-15 21:50:51 +00:00
|
|
|
gals.set("property", tankprop ~ "/level-gal_us");
|
2005-03-26 22:15:26 +00:00
|
|
|
gals.set("label", "0123456");
|
2010-01-04 14:06:30 +00:00
|
|
|
gals.set("format", cap < 1 ? "%.3f" : cap < 10 ? "%.2f" : "%.1f" );
|
2012-07-29 21:44:14 +00:00
|
|
|
gals.set("halign", "right");
|
2004-05-15 21:50:51 +00:00
|
|
|
gals.set("live", 1);
|
2012-07-29 21:44:14 +00:00
|
|
|
|
|
|
|
var per = tcell(fuelTable, "text", i+1, 5);
|
|
|
|
per.set("property", tankprop ~ "/level-norm");
|
|
|
|
per.set("label", "0123456");
|
|
|
|
per.set("format", "%.2f");
|
|
|
|
per.set("halign", "right");
|
|
|
|
per.set("live", 1);
|
2014-11-19 19:14:18 +00:00
|
|
|
}
|
2004-05-15 21:50:51 +00:00
|
|
|
}
|
|
|
|
|
2012-07-29 21:44:14 +00:00
|
|
|
varbar = tcell(fuelTable, "hrule", size(tanks)+1, 0);
|
|
|
|
varbar.set("colspan", 6);
|
|
|
|
|
|
|
|
var total_label = tcell(fuelTable, "text", size(tanks)+2, 2);
|
|
|
|
total_label.set("label", "Total:");
|
|
|
|
total_label.set("halign", "right");
|
|
|
|
|
|
|
|
var lbs = tcell(fuelTable, "text", size(tanks)+2, 3);
|
|
|
|
lbs.set("property", "/consumables/fuel/total-fuel-lbs");
|
|
|
|
lbs.set("label", "0123456");
|
|
|
|
lbs.set("format", "%.1f" );
|
|
|
|
lbs.set("halign", "right");
|
|
|
|
lbs.set("live", 1);
|
|
|
|
|
|
|
|
var gals = tcell(fuelTable, "text",size(tanks) +2, 4);
|
|
|
|
gals.set("property", "/consumables/fuel/total-fuel-gal_us");
|
|
|
|
gals.set("label", "0123456");
|
|
|
|
gals.set("format", "%.1f" );
|
|
|
|
gals.set("halign", "right");
|
|
|
|
gals.set("live", 1);
|
|
|
|
|
|
|
|
var per = tcell(fuelTable, "text", size(tanks)+2, 5);
|
|
|
|
per.set("property", "/consumables/fuel/total-fuel-norm");
|
|
|
|
per.set("label", "0123456");
|
|
|
|
per.set("format", "%.2f");
|
|
|
|
per.set("halign", "right");
|
|
|
|
per.set("live", 1);
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var weightArea = contentArea.addChild("group");
|
2004-05-15 21:50:51 +00:00
|
|
|
weightArea.set("layout", "vbox");
|
|
|
|
weightArea.addChild("text").set("label", "Payload");
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var weightTable = weightArea.addChild("group");
|
2004-05-15 21:50:51 +00:00
|
|
|
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");
|
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var payload_base = props.globals.getNode(fdmdata.payload);
|
|
|
|
if (payload_base != nil)
|
|
|
|
var wgts = payload_base.getChildren("weight");
|
|
|
|
else
|
|
|
|
var wgts = [];
|
2012-03-23 21:25:31 +00:00
|
|
|
for(var i=0; i<size(wgts); i+=1) {
|
2006-08-24 22:29:16 +00:00
|
|
|
var w = wgts[i];
|
2017-01-23 16:54:15 +00:00
|
|
|
var wname = w.getNode("name", 1).getValue() or "";
|
2008-07-10 20:13:58 +00:00
|
|
|
var wprop = fdmdata.payload ~ "/weight[" ~ i ~ "]";
|
2004-05-15 21:50:51 +00:00
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var title = tcell(weightTable, "text", i+1, 0);
|
2004-05-15 21:50:51 +00:00
|
|
|
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")) {
|
2012-03-24 09:45:42 +00:00
|
|
|
# var ent = combo.addChild("value");
|
|
|
|
# ent.prop().setValue(opt.getNode("name", 1).getValue());
|
2006-10-17 19:22:36 +00:00
|
|
|
#}
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2008-07-10 20:13:58 +00:00
|
|
|
var 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>
|
|
|
|
#
|
2013-10-20 03:34:56 +00:00
|
|
|
var showHelpDialog = func(path, toggle=0) {
|
|
|
|
var node = props.globals.getNode(path);
|
|
|
|
if (path == "/sim/help" and size(node.getChildren()) < 4) {
|
2005-04-19 13:43:44 +00:00
|
|
|
node = node.getChild("common");
|
|
|
|
}
|
|
|
|
|
2012-03-23 21:25:31 +00:00
|
|
|
var name = node.getNode("title", 1).getValue();
|
2005-04-19 13:43:44 +00:00
|
|
|
if (name == nil) {
|
|
|
|
name = getprop("/sim/description");
|
|
|
|
if (name == nil) {
|
|
|
|
name = getprop("/sim/aircraft");
|
|
|
|
}
|
|
|
|
}
|
2013-10-20 03:34:56 +00:00
|
|
|
var toggle = toggle > 0;
|
2005-04-19 13:43:44 +00:00
|
|
|
if (toggle and contains(dialog, name)) {
|
2008-10-14 18:41:19 +00:00
|
|
|
fgcommand("dialog-close", props.Node.new({ "dialog-name": name }));
|
2005-04-19 13:43:44 +00:00
|
|
|
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
|
2012-03-23 21:25:31 +00:00
|
|
|
var titlebar = dialog[name].addChild("group");
|
2005-04-19 13:43:44 +00:00
|
|
|
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);
|
|
|
|
|
2012-03-23 21:25:31 +00:00
|
|
|
var w = titlebar.addChild("button");
|
2005-04-19 13:43:44 +00:00
|
|
|
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
|
2012-03-23 21:25:31 +00:00
|
|
|
var keylist = dialog[name].addChild("group");
|
2005-04-19 13:43:44 +00:00
|
|
|
keylist.set("layout", "table");
|
|
|
|
keylist.set("default-padding", 2);
|
2012-03-23 21:25:31 +00:00
|
|
|
var keydefs = node.getChildren("key");
|
|
|
|
var n = size(keydefs);
|
|
|
|
var row = var col = 0;
|
|
|
|
foreach (var key; keydefs) {
|
2005-04-19 13:43:44 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-23 21:25:31 +00:00
|
|
|
var w = keylist.addChild("text");
|
2005-04-19 13:43:44 +00:00
|
|
|
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
|
2012-03-23 21:25:31 +00:00
|
|
|
var lines = node.getChildren("line");
|
2005-04-19 13:43:44 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-03-23 21:25:31 +00:00
|
|
|
var g = dialog[name].addChild("group");
|
2005-04-19 13:43:44 +00:00
|
|
|
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())) {
|
2012-03-23 21:25:31 +00:00
|
|
|
var w = g.addChild("text");
|
2006-12-06 00:24:48 +00:00
|
|
|
w.set("halign", "left");
|
|
|
|
w.set("label", " " ~ l ~ " ");
|
|
|
|
}
|
2005-04-19 13:43:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# scrollable text area
|
|
|
|
if (node.getNode("text") != nil) {
|
2009-01-10 22:31:30 +00:00
|
|
|
dialog[name].set("resizable", 1);
|
2005-04-19 13:43:44 +00:00
|
|
|
dialog[name].addChild("empty").set("pref-height", 10);
|
|
|
|
|
2012-03-23 21:25:31 +00:00
|
|
|
var width = [640, 800, 1152][col];
|
|
|
|
var height = screenHProp.getValue() - (100 + (size(keydefs) / (col + 1) + size(lines)) * 28);
|
2005-04-19 13:43:44 +00:00
|
|
|
if (height < 200) {
|
|
|
|
height = 200;
|
|
|
|
}
|
|
|
|
|
2012-03-23 21:25:31 +00:00
|
|
|
var w = dialog[name].addChild("textbox");
|
2009-01-12 12:27:41 +00:00
|
|
|
w.set("padding", 4);
|
2006-02-24 11:11:09 +00:00
|
|
|
w.set("halign", "fill");
|
2009-01-10 22:31:30 +00:00
|
|
|
w.set("valign", "fill");
|
|
|
|
w.set("stretch", "true");
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-09 22:58:51 +00:00
|
|
|
var debug_keys = {
|
2008-10-14 18:41:19 +00:00
|
|
|
title: "Development Keys",
|
|
|
|
key: [
|
|
|
|
#{ name: "Ctrl-U", desc: "add 1000 ft of emergency altitude" },
|
|
|
|
{ name: "Shift-F3", desc: "load panel" },
|
|
|
|
{ name: "/", desc: "open property browser" },
|
2005-04-19 13:43:44 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2007-12-09 22:58:51 +00:00
|
|
|
var basic_keys = {
|
2008-10-14 18:41:19 +00:00
|
|
|
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: "Ctrl-R", desc: "activate instant replay system" },
|
2016-01-16 02:53:43 +00:00
|
|
|
{ name: "t/T", desc: "adjust time of day forward/backward" },
|
2008-10-14 18:41:19 +00:00
|
|
|
{ name: "v/V", desc: "cycle views (forward/backward)" },
|
|
|
|
{ name: "Ctrl-V", desc: "select cockpit view" },
|
|
|
|
{ name: "x/X", desc: "zoom in/out" },
|
|
|
|
{ name: "Ctrl-X", desc: "reset zoom to default" },
|
|
|
|
{ name: "z/Z", desc: "increase/decrease visibility" },
|
2011-01-19 19:02:53 +00:00
|
|
|
{ name: "Ctrl-Z", desc: "reset visibility to default" },
|
2008-10-14 18:41:19 +00:00
|
|
|
{ name: "'", desc: "display ATC setting dialog" },
|
|
|
|
{ name: "+", desc: "let ATC/instructor repeat last message" },
|
|
|
|
{ name: "-", desc: "open chat dialog" },
|
|
|
|
{ name: "_", desc: "compose chat message" },
|
|
|
|
{ name: "F3", desc: "capture screen" },
|
|
|
|
{ name: "F10", desc: "toggle menubar" },
|
2012-01-19 21:02:09 +00:00
|
|
|
#{ name: "Shift-F1", desc: "load flight" },
|
|
|
|
#{ name: "Shift-F2", desc: "save flight" },
|
2008-10-14 18:41:19 +00:00
|
|
|
{ name: "Shift-F10", desc: "cycle through GUI styles" },
|
2005-04-19 13:43:44 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2007-12-09 22:58:51 +00:00
|
|
|
var common_aircraft_keys = {
|
2008-10-14 18:41:19 +00:00
|
|
|
title: "Common Aircraft Keys",
|
|
|
|
key: [
|
|
|
|
{ name: "Enter", desc: "move rudder right" },
|
|
|
|
{ name: "0/Insert", desc: "move rudder left" },
|
2011-12-07 15:47:42 +00:00
|
|
|
{ name: "1/End", desc: "elevator trim up" },
|
|
|
|
{ name: "2/Down", desc: "elevator up or increase AP altitude" },
|
2008-10-14 18:41:19 +00:00
|
|
|
{ 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." },
|
2011-12-07 15:47:42 +00:00
|
|
|
{ name: "7/Home", desc: "elevator trim down" },
|
|
|
|
{ name: "8/Up", desc: "elevator down or decrease AP altitude" },
|
2008-10-14 18:41:19 +00:00
|
|
|
{ name: "9/PgUp", desc: "incr. throttle or AP autothrottle" },
|
|
|
|
{ name: "Space", desc: "PTT - Push To Talk (via VoIP)" },
|
|
|
|
{ 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" },
|
2011-07-12 21:24:32 +00:00
|
|
|
#{ name: "i/Shift-i", desc: "normal/alternative HUD" },
|
2008-10-14 18:41:19 +00:00
|
|
|
#{ name: "j", desc: "decrease spoilers" },
|
|
|
|
#{ name: "k", desc: "increase spoilers" },
|
|
|
|
{ name: "l", desc: "toggle tail-wheel lock" },
|
|
|
|
{ name: "m/M", desc: "mixture richer/leaner" },
|
|
|
|
{ name: "n/N", desc: "propeller finer/coarser" },
|
|
|
|
{ name: "P", desc: "toggle 2D panel" },
|
|
|
|
{ name: "S", desc: "swap panels" },
|
|
|
|
{ name: "s", desc: "fire starter on selected eng." },
|
|
|
|
{ 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: "open autopilot dialog" },
|
|
|
|
{ name: "F12", desc: "open radio settings 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" },
|
2005-04-19 13:43:44 +00:00
|
|
|
],
|
|
|
|
};
|
2011-05-28 21:22:34 +00:00
|
|
|
|
2011-06-13 18:38:04 +00:00
|
|
|
_setlistener("/sim/signals/screenshot", func {
|
|
|
|
var path = getprop("/sim/paths/screenshot-last");
|
|
|
|
var button = { button: { legend: "Ok", default: 1, binding: { command: "dialog-close" }}};
|
|
|
|
var success= getprop("/sim/signals/screenshot");
|
|
|
|
if (success) {
|
|
|
|
popupTip("Screenshot written to '" ~ path ~ "'", 3);
|
|
|
|
} else {
|
|
|
|
popupTip("Error writing screenshot '" ~ path ~ "'", 600, button);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-06-13 18:28:31 +00:00
|
|
|
var terrasync_stalled = 0;
|
|
|
|
_setlistener("/sim/terrasync/stalled", func {
|
|
|
|
var stalled = getprop("/sim/terrasync/stalled");
|
|
|
|
if (stalled and !terrasync_stalled)
|
|
|
|
{
|
|
|
|
var button = { button: { legend: "Ok", default: 1, binding: { command: "dialog-close" }}};
|
|
|
|
popupTip("Scenery download stalled. Too many errors reported. See log output.", 600, button);
|
|
|
|
}
|
|
|
|
terrasync_stalled = stalled;
|
|
|
|
});
|
|
|
|
|
2011-06-05 19:37:58 +00:00
|
|
|
var do_welcome = 1;
|
|
|
|
_setlistener("/sim/signals/fdm-initialized", func {
|
|
|
|
var haveTutorials = size(props.globals.getNode("/sim/tutorials", 1).getChildren("tutorial"));
|
|
|
|
gui.menuEnable("tutorial-start", haveTutorials);
|
|
|
|
if (do_welcome and haveTutorials)
|
|
|
|
settimer(func { setprop("/sim/messages/copilot", "Welcome aboard! Need help? Use 'Help -> Tutorials'.");}, 5.0);
|
|
|
|
do_welcome = 0;
|
|
|
|
});
|
|
|
|
|
2011-06-05 21:22:12 +00:00
|
|
|
|
2012-03-10 16:05:57 +00:00
|
|
|
##
|
|
|
|
# overwrite custom shader settings when quality-level is set on startup
|
|
|
|
var qualityLevel = getprop("/sim/rendering/shaders/quality-level");
|
2012-06-27 22:29:10 +00:00
|
|
|
var rembrandtOn = getprop("/sim/rendering/rembrandt/enabled");
|
2012-03-10 16:05:57 +00:00
|
|
|
if (qualityLevel == -1) {
|
2012-06-27 22:29:10 +00:00
|
|
|
setprop("/sim/rendering/shaders/custom-settings",1);
|
2012-03-10 16:05:57 +00:00
|
|
|
}
|
|
|
|
elsif (qualityLevel != nil) {
|
|
|
|
setprop("/sim/rendering/shaders/custom-settings",0);
|
|
|
|
setprop("/sim/rendering/shaders/quality-level-internal",qualityLevel);
|
2012-04-04 16:40:00 +00:00
|
|
|
if (qualityLevel == 0) {
|
|
|
|
setprop("/sim/rendering/shaders/skydome",0);
|
|
|
|
}
|
2012-03-10 16:05:57 +00:00
|
|
|
}
|
2012-06-27 22:29:10 +00:00
|
|
|
# overwrite custom shader settings when quality-level is set through the slider
|
2012-03-10 16:05:57 +00:00
|
|
|
# in the Rendering Options dialog
|
|
|
|
var update_shader_settings = func() {
|
2012-06-27 22:29:10 +00:00
|
|
|
if (!getprop("/sim/rendering/shaders/custom-settings")){
|
2012-03-10 16:05:57 +00:00
|
|
|
var qualityLvl = getprop("/sim/rendering/shaders/quality-level-internal");
|
2018-09-13 09:40:00 +00:00
|
|
|
setprop("/sim/rendering/shaders/quality-level", qualityLvl);
|
2012-03-10 16:05:57 +00:00
|
|
|
setprop("/sim/rendering/shaders/landmass",qualityLvl);
|
|
|
|
setprop("/sim/rendering/shaders/urban",qualityLvl);
|
|
|
|
setprop("/sim/rendering/shaders/water",qualityLvl);
|
2018-09-13 09:40:00 +00:00
|
|
|
if (qualityLvl >= 4.0)
|
|
|
|
qualityLvl = 4.0;
|
|
|
|
setprop("/sim/rendering/shaders/lights",qualityLvl);
|
|
|
|
if (qualityLvl >= 1.0)
|
2012-03-10 16:05:57 +00:00
|
|
|
qualityLvl = 1.0;
|
2014-01-18 08:47:33 +00:00
|
|
|
setprop("/sim/rendering/shaders/model",qualityLvl);
|
2012-03-10 16:05:57 +00:00
|
|
|
setprop("/sim/rendering/shaders/contrails",qualityLvl);
|
|
|
|
setprop("/sim/rendering/shaders/crop",qualityLvl);
|
|
|
|
setprop("/sim/rendering/shaders/generic",qualityLvl);
|
|
|
|
setprop("/sim/rendering/shaders/transition",qualityLvl);
|
2012-11-17 22:26:51 +00:00
|
|
|
} else {
|
|
|
|
setprop("/sim/rendering/shaders/quality-level",-1);
|
|
|
|
}
|
2012-06-27 22:29:10 +00:00
|
|
|
|
|
|
|
if (rembrandtOn) {
|
|
|
|
setprop("/sim/rendering/shaders/skydome",0);
|
|
|
|
}
|
2012-03-10 16:05:57 +00:00
|
|
|
};
|
|
|
|
_setlistener("/sim/rendering/shaders/custom-settings", func { update_shader_settings() } );
|
|
|
|
_setlistener("/sim/rendering/shaders/quality-level-internal", func { update_shader_settings() } );
|
2012-07-29 21:44:14 +00:00
|
|
|
update_shader_settings();
|