From 09dca7d3f0a4db02375640e69a1eb91134c835df Mon Sep 17 00:00:00 2001 From: Henning Stahlke Date: Sat, 27 Jun 2020 13:56:04 +0200 Subject: [PATCH] Configurable auto-gen of tutorials from checklists Previously tutorials were generated from all checklists. Now false can be set at any level of the checklist heirarchy to disable generation of tutorials for a given checklist, group, or for all checklists. --- Docs/README.checklists | 9 ++++++++- Nasal/checklist.nas | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Docs/README.checklists b/Docs/README.checklists index 18cf1db59..17c97e7f3 100644 --- a/Docs/README.checklists +++ b/Docs/README.checklists @@ -12,10 +12,12 @@ or /sim/checklists/group[n]/checklist[m] with the following tags - Name of the checklist +<auto-tutorial> - Whether a tutorial should be automatically generated (true, default) + or not (false). <page> - Zero or more pages for the checklist containing: <item> - One or more checklist items containing: <name> - name of the checklist item (e.g. Carb Heat), to appear on the left - <value> - One or more values for the checklist item, to appear on the right + <value> - One or more values for the checklist item, to appear on the right hand side <marker> - A tutorial marker (displayed when the user presses the ? button) This can be easily placed using the Help->Display Tutorial Marker. @@ -29,16 +31,21 @@ with the following tags The <page> tag may be omitted for single-page checklists, with the <item> tags immediately under the <checklist[n]> node. +Tutorial auto-generation of all checklists can be disabled by setting +/sim/checklists/auto-tutorials=false. + Checklists may be grouped under <group> nodes with a <name> tag decribing the group. For example <group> <name>Emergency</name> + <auto-tutorial>false</auto-tutorial> <checklist>... <checklist>... </group> <group> <name>Normal</name> + <auto-tutorial>true</auto-tutorial> <checklist>... <checklist>... </group> diff --git a/Nasal/checklist.nas b/Nasal/checklist.nas index 569230fa7..85c5ebeba 100644 --- a/Nasal/checklist.nas +++ b/Nasal/checklist.nas @@ -4,6 +4,8 @@ var convert_checklists = func { if (props.globals.getNode("/sim/checklists") == nil) return; + var autoTutorials = props.globals.getNode("/sim/checklists/auto-tutorials"); + if (autoTutorials != nil and !autoTutorials.getBoolValue()) return; var tutorials = props.globals.getNode("/sim/tutorials", 1); var groups = props.globals.getNode("/sim/checklists").getChildren("group"); @@ -11,6 +13,9 @@ var convert_checklists = func { if (size(groups) > 0) { foreach (var grp; groups) { + var allowed = grp.getNode("auto-tutorial"); + if (allowed != nil and !allowed.getBoolValue()) continue; + var checks = grp.getChildren("checklist"); foreach (var chk; checks) { append(checklists, chk); @@ -21,10 +26,13 @@ var convert_checklists = func { } if (size(checklists) == 0) return; - foreach (var ch; checklists) { var name = ch.getNode("title", 1).getValue(); - var tutorial = tutorials.getNode("tutorial[" ~ size(tutorials.getChildren("tutorial")) ~ "]", 1); + + var allowed = ch.getNode("auto-tutorial"); + if (allowed != nil and !allowed.getBoolValue()) continue; + + var tutorial = tutorials.addChild("tutorial"); # Initial high level config tutorial.getNode("name", 1).setValue("Checklist: " ~ name);