Namespace globals gui
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 4 seconds. The third argument can be a hash with override values. 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. :)
Classes
Dialog
Dialog class. Maintains one XML dialog. SYNOPSIS: (B) Dialog.new(<dialog-name>); ... use dialog from $FG_ROOT/gui/dialogs/ (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 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: var dlg = gui.Dialog.new("/sim/gui/dialogs/foo-config/dialog", "Aircraft/foo/foo_config.xml"); dlg.open(); dlg.close(); var livery_dialog = gui.Dialog.new("livery-select"); livery_dialog.toggle();
DirSelector
DirSelector - convenience "class" (indeed using a reconfigured FileSelector)
FileSelector
FileSelector class (derived from Dialog class). SYNOPSIS: FileSelector.new(<callback>, <title>, <button> [, <pattern> [, <dir> [, <file> [, <dotfiles>]]]]) callback ... callback function that gets return value as first argument title ... dialog title button ... button text (should say "Save", "Load", etc. and not just "OK") pattern ... array with shell pattern or nil (which is equivalent to "*") dir ... starting dir ($FG_ROOT if unset) file ... pre-selected default file name dotfiles ... flag that decides whether UNIX dotfiles should be shown (1) or not (0) EXAMPLE: var report = func(n) { print("file ", n.getValue(), " selected") } var selector = gui.FileSelector.new( report, # callback function "Save Flight", # dialog title "Save", # button text ["*.sav", "*.xml"], # pattern for displayed files "/tmp", # start dir "flight.sav"); # default file name selector.open(); selector.close(); selector.set_title("Save Another Flight"); selector.open();
OverlaySelector
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: OverlaySelector.new(<title>, <dir>, <nameprop> [, <sortprop> [, <mpprop> [, <callback>]]]); 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 The result is written to this place in the property tree. sortprop ... property in an overlay file that should be used as sorting criterion, if alphabetic sorting by name is undesirable. Use nil if you don't need this, but want to set a callback function. mpprop ... property path of MP node where the file name should be written to callback ... function that's called after a new entry was chosen, with these arguments: callback(<number>, <name>, <sort-criterion>, <file>, <path>) 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()
Widget
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.
cursor_types
Supported mouse cursor types.
Functions
dialog_apply
Apply whole dialog or list of widgets. This copies the widgets' visible contents to the respective <property>.
dialog_update
Update whole dialog or list of widgets. This makes the widgets adopt and display the value of their <property>.
enable_widgets
Searches a dialog tree for widgets with a particular <name> entry and sets their <enabled> flag.
findElementByName
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.
fpsDisplay
Show/hide the fps display dialog.
menuBind
Set the binding for a menu item to a Nasal script, typically a dialog open() command.
menuEnable
Enable/disable named menu entry
popdown
Pop down the tip dialog, if it is visible.
popupTip
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 4 seconds. The third argument can be a hash with override values. 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. :)
property_browser
Open property browser with given target path.
setCursor
Set mouse cursor coordinates and shape (number or name), and return current shape (number). Example: var cursor = gui.setCursor(); gui.setCursor(nil, nil, "wait");
setWeightOpts
Checks the /sim/weight[n]/{selected|opt} values and sets the appropriate weights therefrom.
showHelpDialog
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>
update_shader_settings
overwrite custom shader settings when quality-level is set through the slider in the Rendering Options dialog
weightChangeHandler
Called from the F&W dialog when the user selects a weight option
Variables
currTimer
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.
fdm
Initialize property nodes via a timer, to insure the props module is 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...
fps
frame-per-second display
latency
frame-latency display
menubarAutoVisibilityListener
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 mouse mode != 0 and a binding to a LMB click in mode 0 in mice.xml
p
only enable precipitation if gui *and* aircraft want it
qualityLevel
overwrite custom shader settings when quality-level is set on startup
save_flight_sel
Save/load flight menu functions.
set_screenshotdir_sel
Screen-shot directory menu function
weightAndFuel_x
Dynamically generates a weight & fuel configuration dialog specific to the aircraft.