1
0
Fork 0
Commit graph

295 commits

Author SHA1 Message Date
mfranz
7a300fca3e add tutorial loader function for AJ :-) 2007-03-24 23:28:41 +00:00
mfranz
269396c421 - remove tutorial dialogs from gui.nas and create a new XML dialog
$FG_ROOT/gui/dialogs/tutorial.xml. It combines the former selection
  and description dialogs, which makes browsing much more pleasant.
  No more switching back and forth between the two old dialogs. Also,
  the <list> box can handle a bigger number of tutorials than the
  <combo> box could.
- remove comments from the top of tutorial.nas. The documentation is
  now $FG_ROOT/Docs/README.tutorials
2007-03-24 20:56:40 +00:00
mfranz
b47f8f439d change <marker><[xyz]> to <marker><[xyz]-m> (for consistency with the
animation syntax, and to make tutorials noisier and harder to read :-)
2007-03-24 18:10:33 +00:00
mfranz
44305607b3 - s,/sim/tutorial,/sim/tutorials,
- add a <delay> property that can be used at top level (for the default),
  and in <init> and <step>  (Time in seconds in which the main loop should
  run again.)
- fix initialization bug
2007-03-24 13:39:01 +00:00
mfranz
7f375cf76c s,/sim/tutorial,/sim/tutorials, 2007-03-24 13:32:15 +00:00
mfranz
10093284ba If text contains "{display|voice}" groups, skip the delimiters and discard
the "voice" part. It's no longer possible to display the three letters {|}
in screen message at the moment, but they aren't overly useful. We may want
to support escaping in the future, if necessary.
2007-03-23 15:56:34 +00:00
mfranz
03ba6e2b80 - now *really* disable marker on stopTutorial()
- add target heading
2007-03-23 10:58:15 +00:00
mfranz
8a288f59c2 calculate "Estimated Time of Arrival" (ETA) in minutes for each <target>.
Negative values show that you are actually moving away. To avoid division
by zero, a small value is always added to speed. So, if you aren't moving
at all, you still get a non-infinity, but huge ETA.
2007-03-22 22:10:55 +00:00
mfranz
ef9caa1310 - <targets> can have arbitrary names
- <set> pair: allow to set <property> from <value> or second <property>
- support <set> pairs in <end>, too. This can be used to restore values.
- add optional <view> to <init>/<step>/<exit>/<end>. This is meant for
  cockpit tutorials. See the Lightning's startup tutorial for an example.
2007-03-22 17:08:05 +00:00
mfranz
9a0600b150 - replace "sprintf hack" by real sprintf
- add view manager for saving/restoring and moving/interpolating view
  axes & fov to absolute values. This is used for cockpit tutorials in
  $FG_ROOT/Nasal/tutorial.nas
2007-03-22 16:22:41 +00:00
mfranz
0606fa3703 make condition() slightly faster and prettier (or not) 2007-03-21 18:37:06 +00:00
mfranz
54693a663f - fix <audio> bug
- check a step's errors in random order (otherwise a retarded instructor
  bitches minutes about the climb angle, and only then notices that the
  heading is totally wrong ;-) ... mabye simple scheduling would be better
- document embedded <nasal>
- start of <view> support
2007-03-21 17:31:26 +00:00
mfranz
b482f5d852 - add <target> feature: for each defined <target> lon/lat pair, corresponding
entries /sim/tutorial/targets/target[n]/{distance-m,direction-deg} are
  provided and kept up-to-date. A direction angle of 0 means that the target
  is straight ahead, 90 means it's to the right (3 o'clock) 179 means the
  target is right behind, etc.

- everywhere where <message> and/or <audio> is supported, there can be more
  of those entries, in which case one is randomly chosen. This is to make
  the instructions less monotone:

  <message>You are too fast. Fly at 100 knots.</message>
  <message>Not so fast. 100 knots are more than enough.</message>
  <message>Slower! Idiot!</message>                                  ;-)
2007-03-21 00:21:51 +00:00
mfranz
80913de2e0 code from ufo.nas (used by ufo.nas and tutorial.nas)
- simple geo coordinates class: geo.Coord with methods to set/get single
  components, to apply distance/course and the get distance/course to other
  coords
- functions that return click and aircraft position as geo.Coord
- function that returns tile_path for given lon/lat
- function that returns normalized angle (0 <= angle < 360)
2007-03-20 20:54:52 +00:00
mfranz
cf16f4de88 support <model> definition in a tutorial file, so that tutorials can place
static scenery objects, like air-racing pylons, etc.
2007-03-20 17:32:28 +00:00
mfranz
6d20159866 - trim/sanitize screen messages, so that tabs aren't displayed as
question marks
- make listeners one-shot (saves a couple of bytes of RAM :-)
2007-03-20 16:25:11 +00:00
mfranz
7319f5e772 better condition() comment & cosmetics 2007-03-20 16:23:23 +00:00
mfranz
dcd471b63d - add dialog wrapper, so that "tutorial.dialog()" typed into the
Help->Nasal-Console opens the adjustment dialog
- reset Nasal namespace for emebedded Nasal for every tutorial
- rename <voice> to <audio>  (in the hope that this won't be mixed up
  with Festival voice synthesis; should we call it <audio-sample>?)
- rename <instruction> to <message> for consistency reasons, so there
  are now <step><message>s, <error><message>s, and <end><message>s
2007-03-20 16:22:26 +00:00
mfranz
7cb5ad477c major overhaul/part I:
- add <marker> support (blinking magenta circle to point to switches etc.)
- use "real" conditions instead of tutorial-only ones
- list of <error> with <message> and <condition> children, instead
  of one <error> group with <check> items (necessary because of <condition>)
- only one <exit> (use <condition><and>... to define a set
- rename properties <prop><val><msg> to <property><value><message>
  (consistency with other systems)
- <end><message>/<voice> instead of <endtext> and <endtext-voice> etc.
- add <nasal> support everywhere, with separate namespace and predefined
  tutorial functions in it (currently only say(), next(), previous())
- make <timeofday> property actually work

TODO:
- more cleanup/re-organization
- add optional <view> group, to direct user view to switches (for startup
  tutorials etc.)

2-space indentation changed to tabs (with Stuarts permission), and braces
to K&R style (rationale on request :-)
2007-03-19 23:46:50 +00:00
mfranz
5b812986fb undefined <condition>s are "true" 2007-03-19 18:17:05 +00:00
mfranz
b2f57eab81 boolify <property> result 2007-03-18 15:49:11 +00:00
mfranz
0b4e6f934e add a props.condition(property) command that evaluates a property branch
as <condition> according to the rules set out in $FG_ROOT/Docs/README.condition
2007-03-18 13:57:32 +00:00
mfranz
5f7104ac8a revert condition() patch. This can as easily be done in pure Nasal. 2007-03-18 10:52:08 +00:00
mfranz
d1c4bcea85 condition(property) wrapper for the _condition function.
See $FG_ROOT/Docs/README.condition
2007-03-17 15:59:39 +00:00
mfranz
ad8048627d add Dialog.namespace() method, which returns the XML dialog's namespace
if the dialog is open and contains embedded <nasal>, or nil otherwise.
This can be used to call dialog functions.
2007-02-26 11:00:04 +00:00
mfranz
2987f9660f let Shift-Space open property browser 2007-02-24 10:16:26 +00:00
mfranz
8f977f33ff - immediately unfreeze when mouse mode changes to a non-pointer mode
- rename variable s/speed/time/
2007-02-23 22:17:55 +00:00
mfranz
9e11e2102f - add property /sim/startup/terminal-ansi-colors {BOOL}. This is used
by debug.nas to turn on/off syntax coloring for dumped data (which
  is desirable as compound data types can fill several screens with
  rather hard to read data). Unfortunately, it can't be reliably deduced
  from the OS whether ANSI colors are available or not.
- move "multiplayer chat" properties to where they belong
2007-02-18 17:21:50 +00:00
mfranz
dfb4316b43 - make duration of view change configurable (default 0.2 seconds)
- extract some constants
2007-02-11 16:56:15 +00:00
mfranz
7763462f24 - add some documentation
- reset values
2007-02-10 23:47:02 +00:00
mfranz
7f30f1599e prevent math.ln(0) 2007-02-10 20:42:36 +00:00
mfranz
892f665997 small fix; need to remove the whole silly wrapper, anyway 2007-02-09 18:10:22 +00:00
mfranz
4b7c559b69 - extend lookat() function: dynamic_view.lookat(hdg, pitch, roll, x, y, z [, fov])
- use extra function for resuming normal mode after lookat: dynamic_view.resume()
- add fov (field-of-view) to interface:  me.fov_offset
- remove register_headshake and me.headshake; this can still be done via
  normal register(). If only headshaking is to be added, while keeping default
  plane view, do this:

  dynamic_view.register(func {
      default_plane();
      me.x_offset = ...
      me.y_offset = ...
      me.z_offset = ...
  });
2007-02-08 22:16:10 +00:00
mfranz
4ebd876c85 - move all module initialization code into one-shot listener
- initialize /sim/time/delta-realtime-sec, so that the lowpass filter doesn't
  complain if it's starter eraly (of course the results won't be correct
  until the delta is real)
2007-02-08 18:42:02 +00:00
mfranz
12f5714b37 add support for x/y/z axes. The built-in function is (still) a NOOP, but
aircraft can plug a custom function. This function can access all internal
variables of the ViewManager class. It can set me.{x,y,z}_offset, and also
add offsets to me.{heading,pitch,roll}_offset. Example:

dynamic_view.register_headshake(func {
        me.x_offset = rand() * 0.02;  # Parkinson effect
});

The advantage of this implementation is that it doesn't break MMB drag
functionality, and that is can be frozen by mouse movements.
2007-02-07 22:13:51 +00:00
mfranz
b07ebf0dfa work around Nasal bug (and/or operators) 2007-02-07 17:31:41 +00:00
mfranz
caf96d76c8 minor documentation fix 2007-02-07 17:06:52 +00:00
mfranz
3bec4f4cfc - add debug.local([<frame>]) to output local variables of frame #0
or of given frame
- add debug.string(<variable>). This returns the variable dump as
  string.
- add var to module function variables to avoid collisions with module names
2007-02-07 17:06:05 +00:00
mfranz
a1556fa69a make lookat work correctly for when the user changed view direction;
Remember: dynamic_view.lookat(heading, pitch, roll) moves view
smoothly to this direction, while dynamic_view.lookat() moves it back.
This can be used for quick view changes to the panel etc. It's currently
only used in the bo105 (flaps-up binding).
2007-02-07 16:58:46 +00:00
mfranz
e034e66c57 interpolate between frozen or lookat direction and current view direction 2007-02-06 16:25:44 +00:00
mfranz
df1bd972f8 - fix reinit/reset (has this caused the spinning view on reset for some?)
- add var to module functions to avoid conflicts with module names
2007-02-06 14:33:59 +00:00
mfranz
c9db8c22a3 don't waste time when we aren't in dyn-view mode at all 2007-02-05 22:59:51 +00:00
mfranz
286629c3e1 oh, and freeze while a button is pressed in arrow mode ... 2007-02-05 20:57:19 +00:00
mfranz
ea2d56aa33 don't generally freeze dynamic_view in arrow mouse mode, but only a short
time after mouse movements or clicks. After that period a rather ugly jump
happens. TODO: make this smoother
2007-02-05 20:36:29 +00:00
mfranz
90100e2514 disable dynamic view in mouse arrow mode. Operating all the tiny switches
on 3d panels while hopping over bumpy terrain has become difficult -- much
harder than in real life. I'm open for better solutions. Just complain. :-)
2007-02-05 16:14:51 +00:00
mfranz
0f07c14bd3 getBoolValue() on an undefined node shall return "false", not "true".
This isn't only more logical, it's also how SGPropertyNode::getBoolValue()
acts. The fix has potential to break code, but so far I haven't seen any
problems. I added a debug message to my copy and will for a while check
all cases that I run into. To check yourself, just add one line:

    getBoolValue : func {
        val = me.getValue();
+       if(val == nil) { debug.dump(me) }
        if(me.getType() == "STRING" and val == "false") { 0 }
        else { val != nil and val != 0 }
    }

This will output a debug message to the terminal for each case where
formerly "true" was returned, and now "false" is.
2007-02-05 11:40:49 +00:00
mfranz
cb25691c03 call setWeightOpts on reset, too 2007-01-31 21:37:14 +00:00
mfranz
003ba28784 make sure that setWeightOpts isn't called before fuel.nas' init fdm listener.
This is a bit hackish and needs to be reconsidered.
2007-01-31 21:13:16 +00:00
mfranz
221c23e18b - don't create tanks in empty tank nodes (that nasty native_fdm.cxx causes)
- use Nasal features that were introduced after this code was first written:
  * var for local variables (and to make clear when a variable is first used)
  * += operator
  * listeners to import seldom changing variables and to avoid waiting for
    the FDM in a loop

This new code started as empty file where I added my stuff and then copied
parts from the old code, piece by piece. This is why the coding & indentation
style has changed. Functionally the code should basically be equivalent.
2007-01-31 15:53:01 +00:00
mfranz
80b188706f cosmetics and stuff 2007-01-30 23:22:36 +00:00
mfranz
7ecdeec89e better backtrace section titles with added frame number 2007-01-29 23:48:41 +00:00
mfranz
6f073760af whoops 2007-01-29 19:57:54 +00:00
mfranz
feaf223d88 cleanup 2007-01-29 16:24:58 +00:00
mfranz
7d0fe51b9f first stab at nasal debugging helper module (nicks parts for files from
the Nasal repository :-)
2007-01-28 12:20:18 +00:00
mfranz
04de5c67c8 - add all entries in /sim/aircraft-data/path[*] to the save-list, so that one
can also write

      <sim>
          <aircraft-data>
              <path>/sim/author</path>
              <path>/sim/description</path>
              <path>/sim/rtatus</path>
          </aircraft-data>
      </sim>

  in a *-set.xml file instead of using Nasal (aircraft.data.add("/sim/author", ...)
- s/timeN/node/ to match the pattern described in the head comment
- make listener on-shot
2007-01-26 23:33:25 +00:00
mfranz
e3d90ee46c - don't prepend underscore to aircraft names (this was a leftover from
versions that wrote that name to the property tree)
- move HUD part to the bottom. It isn't really part of the library
- cleanup
2007-01-23 17:29:41 +00:00
mfranz
b47d2e2204 respect /sim/startup/save-on-exit 2007-01-22 19:05:35 +00:00
mfranz
97771b69ae - save aircraft data before the aircraft's Nasal files are executed
- make 0 a valid saving interval, and 'nil' or no arg stop the loop
  (this is for consistency with settimer() or aircraft.timer() intervals
- smaller fixes, cleanup
2007-01-22 16:49:28 +00:00
mfranz
f376ea5adb use /sim/signals/nasal-dir-initialized signal to simplify things 2007-01-22 00:03:07 +00:00
mfranz
bf7731c0af use /sim/signals/nasal-dir-initialized signal for library initialization;
this makes it possible to use screen.log.write() everywhere in aircraft
nasal files, not only after settimer(func{}, 0) were triggered
2007-01-21 20:56:25 +00:00
mfranz
977910c258 we can't use the setlistener() wrapper here, but need the real thing 2007-01-21 20:44:55 +00:00
mfranz
f61969ed01 add timer class that optionally saves time in the aircraft data file,
restores this time at next run and continues from this value. This is
meant for operation hour counters (Hobbs meters) for turbines, etc.
2007-01-21 20:06:05 +00:00
mfranz
722f35903d only save before the reset is executed, so we can save e.g. the Hobbs time 2007-01-21 00:21:53 +00:00
mfranz
ec18defa4c the dummy entry is no longer needed; files get only written if they
actually contain aircraft settings
2007-01-20 23:13:54 +00:00
mfranz
a73972512d add class for saving data into aircraft specific files
in ~/.fgfs/aircraft-data/ or %APPDATA%\flightgear.org\aircraft-data\
2007-01-20 20:15:06 +00:00
mfranz
51712052e1 this file is broken by design. Fixing the Nasal error apparently
overstrains it, so here's the error back. Have fun!  :-|
2007-01-13 22:37:38 +00:00
mfranz
4690b3c2c3 totally pointless mini-optimization 2007-01-13 21:46:07 +00:00
mfranz
f58fcdd492 make sure the property doesn't only exist, but is actually initialized 2007-01-13 18:35:22 +00:00
mfranz
7b6205d37b add props.Node.getAttribute() and props.Node.setAttribute() methods.
Examples:
  var tied = foo.getAttribute("TIED");
  foo.setAttribute("USERARCHIVE", 1);

Both methods accept attribute strings "READ", "WRITE", "ARCHIVE",
"TRACE_READ", "TRACE_WRITE", and "USERARCHIVE". getAttribute() does
additionally accept "TIED" (although this isn't an SGPropertyNode::Attribute).
Attribute "REMOVED" is not supported.
2007-01-12 18:06:50 +00:00
mfranz
41a756a6ba light class: make the first time-value always "on", even for odd numbered
light pattern. This is more robust and doesn't need the reinit listener.
2006-12-13 16:15:27 +00:00
mfranz
923f2b7299 - fix index and restart loop on reinit
- cosmetics
2006-12-12 22:42:52 +00:00
mfranz
30ce4f68c2 - make register() method more tolerant
- cosmetics
2006-12-11 18:37:10 +00:00
mfranz
ddc4b4c8e5 fix lookat() method (didn't consider unmanaged view "goals") 2006-12-10 23:09:42 +00:00
mfranz
bfacf76538 change per-aircraft configuration to a single function object that is
registered with dynamic_view.register() and is called in the main loop,
replacing the default plane/helicopter function. This has access to
all class functions/members and sets me.heading_offset, me.pitch_offset,
and me.roll_offset, which are then used as new view offsets.
The function can also do other things, such as call the lookat() method
to temporarily set heading and pitch. See the bo105 for an example.

While further minor changes are to be expected, the configuration method
seems to be the way to go.
2006-12-10 21:50:59 +00:00
mfranz
0529f66842 - first stab at making dynamic view parameters configurable on a per-aircraft
basis; see bo105.nas for an example; expect some changes, though
- move "lookat" feature here from bo105.nas (used by "flaps up" bindings)
2006-12-09 22:42:13 +00:00
mfranz
354a0f59ff make if-branch for helicopters (bo105 settings) and for everything else;
this *really* needs to be made configurable and less hackish
2006-12-07 22:38:07 +00:00
mfranz
28323bcec8 new light.new() arguments with light pattern array; error message for old
style args
2006-12-06 15:58:03 +00:00
mfranz
cb9361b067 showHelpDialog: automatically split the contents of a <line> block at
newlines
2006-12-06 00:24:48 +00:00
mfranz
a5aae32cc1 whoops; fix return value 2006-12-05 19:32:44 +00:00
mfranz
2cb4354814 - fix switch() method
- optimization (and code obfuscation ;-)
2006-12-05 19:17:17 +00:00
mfranz
eff0eecb8f lowpass: add set() method to set current average
light: - only trigger switch action if switch state actually changed
       - simplify loop
2006-12-04 10:42:05 +00:00
mfranz
c5ac5639a0 reset view after reinit (slowly, because the lowpass filters need to catch up) 2006-12-03 23:59:50 +00:00
mfranz
89710547ec Use a listener to watch the aircraft.light switch. This is slightly more
efficient and there's no more potential 0.5 s delay.
2006-12-03 22:20:16 +00:00
mfranz
4ae3ab11df don't silently fix bad user input -- complain loudly 2006-11-04 11:33:08 +00:00
mfranz
2145558999 documentation fix 2006-11-03 19:39:08 +00:00
mfranz
dabf3f300c - aircraft.nas: add variable-interval EWMA lowpass filter class
- dynamic_view.nas: use aircraft.lowpass() class

This makes the dynamic view independent of the frame rate. Currently,
each filter instance reads out dt on its own, which is a bit inefficient.
I'll change that to just one read for all instances later (when Nasal
implemented predictable module loading order. :-)
2006-11-03 17:38:32 +00:00
mfranz
0ff3f5da2b boring cleanup 2006-11-02 21:06:36 +00:00
mfranz
07e3e2b05b - minor fix
- add info/debug messages
2006-10-31 13:59:50 +00:00
mfranz
ae1df38643 better atc-message repetition (Remember: '+'-key) 2006-10-31 12:19:42 +00:00
mfranz
76e6f5247a disable joystick info dialog if no js available 2006-10-21 10:19:24 +00:00
mfranz
82c4dd05ed - replace indentation tabs with spaces
- fix sliders: revisions 1.43/1.44 had introduced a mandatory <min-lb>;
  if that was missing, a slider without handle was generated, and a click
  on the slider lead to a crash.
  -> check for both <min-lb> and <max-lb> and set default values
     0, respectively 100

  var min = w.getNode("min-lb", 1).getValue();
  var max = w.getNode("max-lb", 1).getValue();
  slider.set("min", min != nil ? min : 0);
  slider.set("max", max != nil ? max : 100);
2006-10-17 19:22:36 +00:00
frohlich
9c52cbf4ac Modified Files:
preferences.xml gui/menubar.xml gui/dialogs/rendering.xml
Added Files:
	Nasal/multiplayer.nas gui/dialogs/chat.xml
	gui/dialogs/chat_full.xml:
	the data part of Stuarts multiplayer/chat patch
2006-10-10 05:23:38 +00:00
mfranz
aad61698ff fix property_browser() 2006-08-27 19:27:21 +00:00
andy
d9ff131805 Oops, wrong sense of create predicte. Melchior was peeved. 2006-08-27 16:45:54 +00:00
andy
e2de2b4093 Melchior discovered an interpreter bug that is fixed (or seems to be
-- I need to verify) in current Nasal CVS.  Commit a workaround for
now.  Basically: don't return a tail call from a foreach.
2006-08-27 16:22:06 +00:00
mfranz
1f57ea72b4 a global symbol must not only *contain* __dlg:property_browser, but
start with it. ("__dlg:" is the namespace prefix for Nasal embedded
in XML dialogs. Subsequent property browsers get a random number added.)
2006-08-26 13:23:06 +00:00
mfranz
74b5436cde call Dialog.load() from the new() constructor already 2006-08-25 20:13:58 +00:00
andy
b6fb9d031a Further augment the weight subsystem so that weights can be tagged with
tank indices, so that changing drop tanks automatically modifies the
corresponding FDM tank capacity (and load, if it is too high).

Add the new tank stuff to the harrier config, along with a few new
items (e.g. AMRAAMs on the outboard pylons) that aren't in the 3D
model yet, but correspond to actual usage.
2006-08-25 19:59:05 +00:00
andy
3e268e394c [Yes, Andy's writing code again. The world is ending.]
An IRC discussion about shavlir's (really nice) harrier model showed
that it had its own version of something like the Fuel & Weight
dialog, developed because the existing subsystem only supported
sliders and not "combo box" style selection for specific external
stores.  That seemed sub-optimal, so I spent a few hours extending the
F&W dialog to do this and forward-ported the harrier to use it.

Check the harrier-set.xml file for an example.  Basically, the weight
dialog reads a list of options for each weight listed under
/sim/weight[n] and manages a "selected" proprty telling us which one
is in use.  The FDM code can then read out the weight-lb property as
before, and the model animations can use the selected option to
predicate drawing the appropriate 3D content.  It seems to work pretty
well.
2006-08-24 22:29:16 +00:00
mfranz
d27df588a6 reduce slip effect speed (harrier VTOL) 2006-08-24 20:55:18 +00:00