Support for <group> of checklists.
Checklists now support grouping by placing a group of checklists under a <group> node. e.g. /sim/checklists/group/checklist The group can have a <name>, which is used by the checklist dialog and can be used by other interfaces, such as the FG1000.
This commit is contained in:
parent
e66a5551c0
commit
9f7e17a434
3 changed files with 293 additions and 163 deletions
|
@ -7,6 +7,8 @@ the Help->Checklists menu within the simulator.
|
|||
Tutorials are automatically generated from checklists on startup.
|
||||
|
||||
Each checklist is defined as a property tree under /sim/checklists/checklist[n]
|
||||
or /sim/checklists/group[n]/checklist[m]
|
||||
|
||||
with the following tags
|
||||
|
||||
<title> - Name of the checklist
|
||||
|
@ -27,6 +29,18 @@ with the following tags
|
|||
The <page> tag may be omitted for single-page checklists, with the <item> tags
|
||||
immediately under the <checklist[n]> node.
|
||||
|
||||
Checklists may be grouped under <group> nodes with a <name> tag decribing the
|
||||
group. For example
|
||||
|
||||
<group>
|
||||
<name>Emergency</name>
|
||||
<checklist>...
|
||||
<checklist>...
|
||||
</group>
|
||||
<group>
|
||||
<name>Normal</name>
|
||||
<checklist>...
|
||||
<checklist>...
|
||||
</group>
|
||||
|
||||
See the c172p for an example of this in action (Aircraft/c172p/c172-checklists.xml).
|
||||
|
||||
|
||||
|
|
|
@ -3,12 +3,24 @@
|
|||
# Convert checklists into full tutorials.
|
||||
var convert_checklists = func {
|
||||
|
||||
if ((props.globals.getNode("/sim/checklists") != nil) and
|
||||
(props.globals.getNode("/sim/checklists").getChildren("checklist") != nil) and
|
||||
(size(props.globals.getNode("/sim/checklists").getChildren("checklist")) > 0) )
|
||||
{
|
||||
var checklists = props.globals.getNode("/sim/checklists").getChildren("checklist");
|
||||
if (props.globals.getNode("/sim/checklists") == nil) return;
|
||||
|
||||
var tutorials = props.globals.getNode("/sim/tutorials", 1);
|
||||
var groups = props.globals.getNode("/sim/checklists").getChildren("group");
|
||||
var checklists = [];
|
||||
|
||||
if (size(groups) > 0) {
|
||||
foreach (var grp; groups) {
|
||||
var checks = grp.getChildren("checklist");
|
||||
foreach (var chk; checks) {
|
||||
append(checklists, chk);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
checklists = props.globals.getNode("/sim/checklists").getChildren("checklist");
|
||||
}
|
||||
|
||||
if (size(checklists) == 0) return;
|
||||
|
||||
foreach (var ch; checklists) {
|
||||
var name = ch.getNode("title", 1).getValue();
|
||||
|
@ -66,7 +78,6 @@ var convert_checklists = func {
|
|||
|
||||
tutorial.getNode("description", 1).setValue(description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_setlistener("/sim/signals/nasal-dir-initialized", func {
|
||||
|
|
|
@ -13,27 +13,107 @@
|
|||
|
||||
<nasal>
|
||||
<open><![CDATA[
|
||||
|
||||
var dlgRoot = cmdarg();
|
||||
var dlgname = dlgRoot.getNode("name").getValue();
|
||||
|
||||
|
||||
# Update the checklist-combo with appropriate set of checklists for
|
||||
# the user to select from
|
||||
var setChecklistGroup = func(group_name) {
|
||||
var combo = gui.findElementByName(dlgRoot, "checklist-combo");
|
||||
combo.removeChildren("value");
|
||||
var idx = 0;
|
||||
|
||||
foreach (var name; checklist_group[group_name]) {
|
||||
combo.getChild("value", idx, 1).setValue(name);
|
||||
idx = idx + 1;
|
||||
}
|
||||
|
||||
var checklist_name = checklist_group[group_name][0];
|
||||
|
||||
var pgs = checklist_size[checklist_name];
|
||||
if (pgs == nil) pgs = 1;
|
||||
|
||||
setprop("/sim/gui/dialogs/checklist/selected-checklist-group", group_name);
|
||||
setprop("/sim/gui/dialogs/checklist/selected-checklist-max-pages", pgs);
|
||||
setprop("/sim/gui/dialogs/checklist/selected-page-text", "1 / " ~ pgs);
|
||||
setprop("sim/gui/dialogs/checklist/selected-checklist", checklist_name);
|
||||
gui.dialog_update("checklist", "checklist-combo", "checklist-table-group");
|
||||
};
|
||||
|
||||
var groups = props.globals.getNode("/sim/checklists", 1).getChildren("group");
|
||||
var checklists = props.globals.getNode("/sim/checklists", 1).getChildren("checklist");
|
||||
var checklist_size = {};
|
||||
var checklist_group = {};
|
||||
var current_group = nil;
|
||||
|
||||
# Set up the list of groups so the user can select a group and then
|
||||
# a checklist.
|
||||
var groups = props.globals.getNode("/sim/checklists").getChildren("group");
|
||||
|
||||
if (size(groups) > 0) {
|
||||
foreach (var grp; groups) {
|
||||
var name = grp.getNode("name", 1).getValue();
|
||||
var checks = grp.getChildren("checklist");
|
||||
foreach (var chk; checks) {
|
||||
var title = chk.getNode("title", 1).getValue();
|
||||
if (current_group == nil) current_group = name;
|
||||
append(checklists, chk);
|
||||
if (checklist_group[name] == nil) checklist_group[name] = [];
|
||||
append(checklist_group[name], title);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
checklists = props.globals.getNode("/sim/checklists").getChildren("checklist");
|
||||
foreach (var chk; checklists) {
|
||||
var title = chk.getNode("title", 1).getValue();
|
||||
var grp = "Standard";
|
||||
var items = [];
|
||||
if (find("emergency", string.lc(title)) != -1) {
|
||||
grp = "EMERGENCY";
|
||||
}
|
||||
|
||||
if (current_group == nil) current_group = grp;
|
||||
|
||||
if (checklist_group[grp] == nil) checklist_group[grp] = [];
|
||||
append(checklist_group[grp], title);
|
||||
}
|
||||
}
|
||||
|
||||
if (size(checklists) > 0) {
|
||||
|
||||
if (getprop("sim/gui/dialogs/checklist/selected-checklist") == nil) {
|
||||
setprop("sim/gui/dialogs/checklist/selected-checklist", checklists[0].getNode("title", 1).getValue());
|
||||
var current_checklist = getprop("sim/gui/dialogs/checklist/selected-checklist");
|
||||
if (current_checklist == nil) {
|
||||
current_checklist = checklists[0].getNode("title", 1).getValue();
|
||||
setprop("sim/gui/dialogs/checklist/selected-checklist", current_checklist);
|
||||
setprop("sim/gui/dialogs/checklist/selected-page", 0);
|
||||
}
|
||||
|
||||
var combo = gui.findElementByName(dlgRoot, "checklist-combo");
|
||||
foreach (var grp; keys(checklist_group)) {
|
||||
foreach (chklist; checklist_group[grp]) {
|
||||
if (chklist == current_checklist) {
|
||||
setChecklistGroup(grp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var combo = gui.findElementByName(dlgRoot, "checklist-group-combo");
|
||||
var idx = 0;
|
||||
|
||||
foreach (var grp_name; keys(checklist_group)) {
|
||||
combo.getChild("value", idx, 1).setValue(grp_name);
|
||||
idx = idx + 1;
|
||||
}
|
||||
|
||||
dlgRoot.setValues({"dialog-name": dlgname, "object-name": "checklist-group-combo"});
|
||||
fgcommand("dialog-update", dlgRoot);
|
||||
|
||||
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");
|
||||
|
@ -46,6 +126,7 @@
|
|||
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]);
|
||||
|
@ -243,7 +324,7 @@
|
|||
"scale/value": scale,
|
||||
"arrow-enabled": 1,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var nextPage = func() {
|
||||
var currentPage = getprop("/sim/gui/dialogs/checklist/selected-page");
|
||||
|
@ -258,7 +339,7 @@
|
|||
}
|
||||
|
||||
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");
|
||||
|
@ -269,7 +350,7 @@
|
|||
|
||||
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);
|
||||
|
@ -280,7 +361,7 @@
|
|||
fgcommand("dialog-close", n);
|
||||
fgcommand("dialog-show", n);
|
||||
}
|
||||
}
|
||||
};
|
||||
setTransparency(0);
|
||||
|
||||
]]></open>
|
||||
|
@ -324,6 +405,30 @@
|
|||
<label> </label>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<halign>right</halign>
|
||||
<label>Group:</label>
|
||||
</text>
|
||||
|
||||
<combo>
|
||||
<name>checklist-group-combo</name>
|
||||
<property>/sim/gui/dialogs/checklist/selected-checklist-group</property>
|
||||
<editable>false</editable>
|
||||
<pref-width>230</pref-width>
|
||||
<halign>fill</halign>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>checklist-group-combo</object-name>
|
||||
</binding>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
var s = getprop("/sim/gui/dialogs/checklist/selected-checklist-group");
|
||||
setChecklistGroup(s);
|
||||
</script>
|
||||
</binding>
|
||||
</combo>
|
||||
|
||||
<text>
|
||||
<halign>right</halign>
|
||||
<label>Checklist:</label>
|
||||
|
|
Loading…
Reference in a new issue