diff --git a/Nasal/gui.nas b/Nasal/gui.nas index 524cc14cf..2a5c74414 100644 --- a/Nasal/gui.nas +++ b/Nasal/gui.nas @@ -135,7 +135,6 @@ _setlistener("/sim/signals/nasal-dir-initialized", func { } menuEnable("autopilot", isAutopilotMenuEnabled() ); menuEnable("multiplayer", multiplayer.is_active()); - menuEnable("tutorial-start", size(props.globals.getNode("/sim/tutorials", 1).getChildren("tutorial"))); menuEnable("joystick-info", size(props.globals.getNode("/input/joysticks").getChildren("js"))); # frame-per-second display diff --git a/Nasal/tutorial.nas b/Nasal/tutorial.nas index e5c9b82ae..85a4cf825 100644 --- a/Nasal/tutorial.nas +++ b/Nasal/tutorial.nas @@ -15,7 +15,7 @@ var step_start_time = nil; var step_iter_count = 0; # number or step loop iterations var last_step_time = nil; # for set_targets() eta calculation var audio_dir = nil; - +var do_welcome = 1; # property nodes (to be initialized with listener) var markerN = nil; @@ -37,7 +37,13 @@ _setlistener("/sim/signals/nasal-dir-initialized", func { setlistener("/sim/crashed", stopTutorial); }); - +_setlistener("/sim/signals/fdm-initialized", func { + var haveTutorials = size(props.globals.getNode("/sim/tutorials", 1).getChildren("tutorial")); + gui.menuEnable("tutorial-start", haveTutorials); + if (do_welcome and haveTutorials) + settimer(func { setprop("/sim/messages/copilot", "Welcome aboard! Need help? Use 'Help -> Tutorials'.");}, 5.0); + do_welcome = 0; +}); var startTutorial = func { var name = getprop("/sim/tutorials/current-tutorial"); @@ -192,7 +198,15 @@ var step_tutorial = func(id) { var exit = step.getNode("exit"); if (exit != nil) { if (!props.condition(exit.getNode("condition"))) + { + if (time_elapsedN.getValue() - step_start_time > 15.0) + { + # What's going on? Repeat last message. + last_messageN.setValue(""); + is_first_step = 1; + } return continue_after(exit, step_interval); + } do_group(exit); } @@ -363,7 +377,6 @@ var is_running = func(which = nil) { var prop = "/sim/tutorials/running"; if (which != nil) { setprop(prop, which); - gui.menuEnable("tutorial-stop", which); } return getprop(prop); } diff --git a/gui/dialogs/tutorial.xml b/gui/dialogs/tutorial.xml index 44de355c2..b95154682 100644 --- a/gui/dialogs/tutorial.xml +++ b/gui/dialogs/tutorial.xml @@ -4,17 +4,37 @@ <name>tutorial</name> <layout>vbox</layout> <resizable>true</resizable> - <default-padding>4</default-padding> + <default-padding>3</default-padding> - <text> - <label>Select Tutorial</label> - </text> + <group> + <layout>hbox</layout> + <default-padding>1</default-padding> + + <empty><stretch>true</stretch></empty> + + <text> + <label>Select Tutorial</label> + </text> + + <empty><stretch>true</stretch></empty> + + <button> + <legend></legend> + <key>Esc</key> + <pref-width>16</pref-width> + <pref-height>16</pref-height> + <border>2</border> + <binding> + <command>dialog-close</command> + </binding> + </button> + </group> <hrule/> <nasal> <open> - var list = cmdarg().getNode("group[1]/group/list"); + var list = cmdarg().getNode("group[2]/group/list"); var node = props.globals.getNode("/sim/tutorials", 1); var tut = node.getChildren("tutorial"); var current = node.getNode("current-tutorial", 1); @@ -105,15 +125,6 @@ </binding> </list> - <button> - <legend>Cancel</legend> - <equal>true</equal> - <key>Esc</key> - <binding> - <command>dialog-close</command> - </binding> - </button> - <button> <legend>Start Tutorial</legend> <equal>true</equal> @@ -126,6 +137,27 @@ <command>dialog-close</command> </binding> </button> + + <button> + <legend>Stop Tutorial</legend> + <equal>true</equal> + <binding> + <command>nasal</command> + <script>tutorial.stopTutorial()</script> + </binding> + <enable> + <property>/sim/tutorials/running</property> + </enable> + </button> + + <button> + <legend>Cancel</legend> + <equal>true</equal> + <binding> + <command>dialog-close</command> + </binding> + </button> + </group> </group> </PropertyList> diff --git a/gui/menubar.xml b/gui/menubar.xml index 15381a9f3..bbaa69a82 100644 --- a/gui/menubar.xml +++ b/gui/menubar.xml @@ -758,7 +758,7 @@ </item> <item> - <label>Start Tutorial</label> + <label>Tutorials</label> <name>tutorial-start</name> <binding> <command>dialog-show</command> @@ -766,16 +766,6 @@ </binding> </item> - <item> - <label>End Tutorial</label> - <name>tutorial-stop</name> - <enabled>false</enabled> - <binding> - <command>nasal</command> - <script>tutorial.stopTutorial()</script> - </binding> - </item> - <item> <label>About</label> <binding>