checklistvbox-5511.0 0) {
if (getprop("sim/gui/dialogs/checklist/selected-checklist") == nil) {
setprop("sim/gui/dialogs/checklist/selected-checklist", checklists[0].getNode("title", 1).getValue());
setprop("sim/gui/dialogs/checklist/selected-page", 0);
}
var combo = gui.findElementByName(dlgRoot, "checklist-combo");
var group = gui.findElementByName(dlgRoot, "checklist-table-group");
var table_count = 0;
forindex (var idx; checklists) {
var checklist_name = checklists[idx].getNode("title", 1).getValue();
combo.getChild("value", idx, 1).setValue(checklist_name);
# Checklist may consist of one or more pages.
var pages = checklists[idx].getChildren("page");
if (size(pages) == 0) {
# Or no pages at all, in which case we need to create a checklist of one page
append(pages, checklists[idx]);
}
checklist_size[checklist_name] = size(pages);
if (idx == 0) {
setprop("/sim/gui/dialogs/checklist/next-available", 1);
setprop("/sim/gui/dialogs/checklist/selected-checklist-max-pages", checklist_size[checklist_name]);
setprop("/sim/gui/dialogs/checklist/selected-page-text", "1 / " ~ checklist_size[checklist_name]);
}
forindex (var p; pages) {
var c = pages[p];
var row = 0;
# Set up a new table, only visible when this checklist is selected.
var table = group.getChild("group", table_count, 1);
table.getNode("row", 1).setValue(0);
table.getNode("col", 1).setValue(0);
table.getNode("default-padding", 1).setValue(4);
table.getNode("layout", 1).setValue("table");
table.getNode("valign", 1).setValue("top");
# Set up conditional to only display when the checklist is selected
# and the page is correct.
var vis = table.getNode("visible", 1).getNode("and", 1);
var e = vis.getChild("equals", 0, 1);
e.getNode("property", 1).setValue("sim/gui/dialogs/checklist/selected-checklist");
e.getNode("value", 1).setValue(checklists[idx].getNode("title").getValue());
e = vis.getChild("equals", 1, 1);
e.getNode("property", 1).setValue("sim/gui/dialogs/checklist/selected-page");
e.getNode("value", 1).setValue(p);
var items = c.getChildren("item");
var txtcount = 0;
var btncount = 0;
forindex (var i; items) {
var item = items[i];
var t = table.getChild("text", txtcount, 1);
txtcount += 1;
var values = item.getChildren("value");
if (size(values) == 0) {
# Single name element with no values. Used as title
t.getNode("halign", 1).setValue("center");
t.getNode("row", 1).setValue(row);
t.getNode("col", 1).setValue(0);
t.getNode("colspan", 1).setValue(2);
t.getNode("label", 1).setValue(item.getNode("name", 1).getValue());
row = row + 1;
} else {
t.getNode("halign", 1).setValue("left");
t.getNode("row", 1).setValue(row);
t.getNode("col", 1).setValue(0);
t.getNode("label", 1).setValue(item.getNode("name", 1).getValue());
forindex (var v; values) {
var t = table.getChild("text", txtcount, 1);
txtcount += 1;
t.getNode("halign", 1).setValue("right");
t.getNode("row", 1).setValue(row);
if (v > 0) {
# The second row of values can overlap with the
# first column if required - helps keep the
# checklist dialog as compact as possible
t.getNode("col", 1).setValue(0);
t.getNode("colspan", 1).setValue(2);
} else {
t.getNode("col", 1).setValue(1);
}
t.getNode("label", 1).setValue(values[v].getValue());
# If there's a complete node, it contains a condition
# that can be checked to ensure the checklist item is
# complete. We display this item in yellow while the
# condition is not met, and green once it is complete.
var condition = item.getNode("condition");
if (condition != nil) {
var vis = t.getNode("visible", 1);
props.copy(condition, vis);
var c = t.getNode("color", 1);
c.getNode("red", 1).setValue(0.2);
c.getNode("green", 1).setValue(1.0);
c.getNode("blue", 1).setValue(0.2);
# Now create an amber version for when the condition
# is not met.
t = table.getChild("text", txtcount, 1);
txtcount += 1;
t.getNode("halign", 1).setValue("right");
t.getNode("row", 1).setValue(row);
if (v > 0) {
# The second row of values can overlap with the
# first column if required - helps keep the
# checklist dialog as compact as possible
t.getNode("col", 1).setValue(0);
t.getNode("colspan", 1).setValue(2);
} else {
t.getNode("col", 1).setValue(1);
}
t.getNode("label", 1).setValue(values[v].getValue());
c = t.getNode("color", 1);
c.getNode("red", 1).setValue(1.0);
c.getNode("green", 1).setValue(0.7);
c.getNode("blue", 1).setValue(0.2);
vis = t.getNode("visible", 1).getNode("not", 1);
props.copy(condition, vis);
}
# If there is a marker node we display a small
# button that enables the marker.
var marker = item.getNode("marker");
if ((v == 0) and (marker != nil)) {
var s = marker.getNode("scale");
var scale = s != nil ? s.getValue() : 1;
var btn = table.getChild("button", btncount, 1);
btncount += 1;
btn.getNode("row", 1).setValue(row);
btn.getNode("col", 1).setValue(2);
btn.getNode("pref-width", 1).setValue(20);
btn.getNode("pref-height", 1).setValue(20);
btn.getNode("padding", 1).setValue(0);
btn.getNode("legend", 1).setValue("?");
var binding = btn.getNode("binding", 1);
binding.getNode("command", 1).setValue("nasal");
binding.getNode("script", 1).setValue(
"placeMarker(" ~ marker.getNode("x-m", 1).getValue() ~ ", " ~
marker.getNode("y-m", 1).getValue() ~ ", " ~
marker.getNode("z-m", 1).getValue() ~ ", " ~
scale ~ ");");
}
# If there's one or more binding nodes we display a
# small button that executes the binding. Used to
# demonstrate the checklist item
var bindings = item.getChildren("binding");
if ((v == 0) and (size(bindings) > 0)) {
var btn = table.getChild("button", btncount, 1);
btncount += 1;
btn.getNode("row", 1).setValue(row);
btn.getNode("col", 1).setValue(3);
btn.getNode("pref-width", 1).setValue(20);
btn.getNode("pref-height", 1).setValue(20);
btn.getNode("padding", 1).setValue(1);
btn.getNode("legend", 1).setValue(">");
forindex (var bdg; bindings) {
var binding = btn.getChild("binding", bdg, 1);
props.copy(bindings[bdg], binding);
}
}
row = row + 1;
}
table_count = table_count + 1;
}
}
}
}
var s = getprop("/sim/gui/dialogs/checklist/selected-checklist");
setprop("/sim/gui/dialogs/checklist/selected-checklist-max-pages", checklist_size[s]);
setprop("/sim/gui/dialogs/checklist/selected-page", 0);
setprop("/sim/gui/dialogs/checklist/next-available", 1);
setprop("/sim/gui/dialogs/checklist/selected-page-text", "1 / " ~ checklist_size[s]);
} else {
var group = gui.findElementByName(dlgRoot, "checklist-table-group");
var table = group.getNode("text", 1);
table.getNode("row", 1).setValue(0);
table.getNode("col", 1).setValue(0);
table.getNode("default-padding", 1).setValue(4);
table.getNode("layout", 1).setValue("table");
table.getNode("valign", 1).setValue("top");
table.getNode("halign", 1).setValue("center");
table.getNode("label", 1).setValue("No checklists exist for this aircraft");
}
var placeMarker = func(x,y,z,scale) {
var markerN = props.globals.getNode("/sim/model/marker", 1);
markerN.setValues({
"x/value": x,
"y/value": y,
"z/value": z,
"scale/value": scale,
"arrow-enabled": 1,
});
}
var nextPage = func() {
var currentPage = getprop("/sim/gui/dialogs/checklist/selected-page");
var s = getprop("/sim/gui/dialogs/checklist/selected-checklist");
if (currentPage < (checklist_size[s] - 1)) {
setprop("/sim/gui/dialogs/checklist/selected-page", currentPage + 1);
}
if (currentPage == (checklist_size[s] - 2)) {
setprop("/sim/gui/dialogs/checklist/next-available", 0);
}
setprop("/sim/gui/dialogs/checklist/selected-page-text", (currentPage + 2) ~ " / " ~ checklist_size[s]);
}
var previousPage = func() {
var currentPage = getprop("/sim/gui/dialogs/checklist/selected-page");
if (currentPage > 0) {
setprop("/sim/gui/dialogs/checklist/selected-page", currentPage - 1);
}
setprop("/sim/gui/dialogs/checklist/next-available", 1);
setprop("/sim/gui/dialogs/checklist/selected-page-text", currentPage ~ " / " ~ checklist_size[s]);
}
var setTransparency = func(updateDialog){
var alpha = (getprop("/sim/gui/dialogs/checklist/transparent") or 0);
dlgRoot.getNode("color/alpha").setValue(1-alpha*0.3);
var n = props.Node.new({ "dialog-name": "checklist" });
if (updateDialog)
{
fgcommand("dialog-close", n);
fgcommand("dialog-show", n);
}
}
setTransparency(0);
]]>hbox1truehboxrightrightchecklist-combo/sim/gui/dialogs/checklist/selected-checklistfalse230filldialog-applychecklist-combonasaltrueright/sim/gui/dialogs/checklist/transparenttruerightdialog-applyproperty-togglenasalright4filltablechecklist-table-group5fillhbox/sim/gui/dialogs/checklist/selected-checklist-max-pages1truetruecenter/sim/gui/dialogs/checklist/selected-page-texttruetruetrue