model-view-select
model-view-select
5
33
hbox
0
var self = cmdarg();
var dlg = props.globals.getNode("sim/gui/dialogs/model-view-select", 1);
dlg.getNode("open", 1).setBoolValue(1);
var maxh = getprop("sim/startup/ysize") - 50;
var gui = getprop("sim/gui/current-style");
var baseline = getprop("/sim/gui/style[" ~ gui ~ "]/fonts/gui/baseline-height") or 21;
var list = cmdarg().getNode("list");
var data = view.model_view_handler.list;
var height = size(data) * baseline;
if (height > maxh)
height = maxh;
list.getNode("pref-height").setValue(height);
list.removeChildren("value");
var entries = {};
forindex (var i; data) {
if (i == 0) {
var ident = var myself = '[' ~ data[i].callsign ~ ']';
list.getChild("value", size(data), 1).setValue(ident);
} else {
var ident = '"' ~ data[i].callsign ~ '" (' ~ data[i].model ~ ')';
list.getChild("value", i - 1, 1).setValue(ident);
}
entries[ident] = data[i].callsign;
}
var select = func {
var e = dlg.initNode("choice", "").getValue();
if (e == myself or contains(multiplayer.model.callsign, entries[e]))
view.model_view_handler.select(which: entries[e], by_callsign: 1);
else
settimer(func fgcommand("dialog-show", self), 0);
}
dlg.getNode("open").setValue(0);
100
250
0
/sim/gui/dialogs/model-view-select/choice
dialog-apply
nasal
dialog-close