Added section on conditions
Modified Files: README.xmlpanel.html
This commit is contained in:
parent
bd5853743b
commit
2dc430889d
1 changed files with 147 additions and 8 deletions
|
@ -17,11 +17,11 @@ Author: John Check <j4strngs@rockfish.net>
|
|||
<li><A HREF="#example_panel">Example Top Level Panel Config</A>
|
||||
<li><A HREF="#indexed_properties">Indexed Properties</A>
|
||||
<li><A HREF="#inclusion">Inclusion</A>
|
||||
<li><A HREF="#aliasing">Aliasing</A>
|
||||
<li><A HREF="#instrument_architecture">Instrument Architecture</A>
|
||||
<li><A HREF="#textures">Textures</A>
|
||||
<li><A HREF="#instrument_layers">Instrument Layers</A>
|
||||
<li><A HREF="#transformations">Transformations</a>
|
||||
<li><A HREF="#conditions">Conditions</A>
|
||||
<li><A HREF="#needle_placement">About Transformations and Needle Placement</A>
|
||||
<li><A HREF="#interpolation">Interpolation Tables</A>
|
||||
<li><A HREF="#actions">Actions</A>
|
||||
|
@ -580,6 +580,145 @@ This example is a switch that contains both static and dynamic text:
|
|||
</pre>
|
||||
<br>
|
||||
|
||||
<HR WIDTH="20%">
|
||||
<H2><A NAME="conditions">Conditions:</A></H2>
|
||||
<HR WIDTH="20%">
|
||||
|
||||
<p>
|
||||
A condition may appear in a binding (for keyboard, joystick, or panel
|
||||
action) or in most parts of a panel configuration file (specifically,
|
||||
for an instrument, layer, transformation, text chunk, or action). If
|
||||
a condition is present, it must succeed for the component to be used
|
||||
(i.e. if the condition fails, the binding will not be fired, the layer
|
||||
will not be drawn, etc.). Conditions are compiled to an efficient
|
||||
internal form and load time.
|
||||
</p>
|
||||
<p>
|
||||
For example, to ensure that a layer is drawn only if the /foo/bar
|
||||
property has the value "active", you would do the following:
|
||||
</p>
|
||||
<pre>
|
||||
<layer>
|
||||
<name>FooBar Layer</name>
|
||||
<condition>
|
||||
<equals>
|
||||
<property>/foo/bar</property>
|
||||
<value>active</value>
|
||||
</equals>
|
||||
</condition>
|
||||
...
|
||||
</layer>
|
||||
</pre>
|
||||
<p>
|
||||
To draw a different layer when the /foo/bar property does not have the
|
||||
value "active", you could follow with this:
|
||||
</p>
|
||||
<pre>
|
||||
<layer>
|
||||
<name>FooBar Layer</name>
|
||||
<condition>
|
||||
<not-equals>
|
||||
<property>/foo/bar</property>
|
||||
<value>active</value>
|
||||
</not-equals>
|
||||
</condition>
|
||||
...
|
||||
</layer>
|
||||
</pre>
|
||||
<p>
|
||||
While conditions were originally created for panel designers, they
|
||||
have proven to be very useful for binding input devices (such
|
||||
as the keyboard or joystick), since they effectively allow any key,
|
||||
axis, button, or panel action to act as a modifier for any other key,
|
||||
axis, button, or panel action, and in fact, allow mind-numbingly
|
||||
complicated combinations for people who like them (i.e. Emacs users).
|
||||
</p>
|
||||
<pre>
|
||||
<!-- make 'u' a modifier key -->
|
||||
<!-- could also use property-toggle to make it a toggle modifier -->
|
||||
<key n="117">
|
||||
<name>u</name>
|
||||
<desc>Special 'u' modifier</desc>
|
||||
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/modifiers/u</property>
|
||||
<value>1</value>
|
||||
</binding>
|
||||
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/modifiers/u</property>
|
||||
<value>0</value>
|
||||
</binding>
|
||||
</mod-up>
|
||||
|
||||
</key>
|
||||
|
||||
<!-- take different actions based on the u modifier -->
|
||||
<key n="118">
|
||||
<name>v</name>
|
||||
|
||||
<binding>
|
||||
<condition>
|
||||
<property>/modifiers/u</property>
|
||||
</condition>
|
||||
<command>property-toggle</command>
|
||||
<property>/foo/bar</property>
|
||||
</binding>
|
||||
|
||||
<binding>
|
||||
<condition>
|
||||
<not>
|
||||
<property>/modifiers/u</property>
|
||||
</not>
|
||||
</condition>
|
||||
<command>property-toggle</command>
|
||||
<property>/bar/foo</property>
|
||||
</binding>
|
||||
|
||||
</key>
|
||||
</pre>
|
||||
<p>
|
||||
The <condition> element acts as an implicit 'and' group for everything
|
||||
contained in it. Here are the elements that can appear inside:
|
||||
</p>
|
||||
<pre>
|
||||
<property>[name]</property>
|
||||
|
||||
- true if the named property returns a true boolean value (i.e. a
|
||||
non-0 numeric value)
|
||||
|
||||
<and>[condition...]</and>
|
||||
|
||||
- true if all of the conditions contained in it are true
|
||||
|
||||
<or>[condition...]</or>
|
||||
|
||||
- true if any of the conditions contained in it is true
|
||||
|
||||
<not>[condition]</not>
|
||||
|
||||
- true if the condition contained in it is false
|
||||
|
||||
<less-than>...</less-than>
|
||||
<less-than-equals>...</less-than-equals>
|
||||
<equals>...</equals>
|
||||
<not-equals>...</not-equals>
|
||||
<greater-than>...</greater-than>
|
||||
<greater-than-equals>...</greater-than-equals>
|
||||
</pre>
|
||||
<p>
|
||||
- all of these take two child elements; the first, "property", is
|
||||
the property to test; the second argument may be "property" or
|
||||
"value". If it is also "property" (i.e. property[1]), the named
|
||||
property's value will be used; otherwise, the literal value
|
||||
provided will be used
|
||||
- be warned that any string comparison other than equals/not-equals
|
||||
is guaranteed to be flaky
|
||||
</p>
|
||||
|
||||
<HR WIDTH="20%">
|
||||
<H2><A NAME="transformations">Transformations:</A></H2>
|
||||
<HR WIDTH="20%">
|
||||
|
@ -591,7 +730,7 @@ based on properties are useful for driving instrument needles. I.E. rotate the
|
|||
number of degrees equal to the airspeed. X and y shifts are relative to the
|
||||
center of the instrument. Each specified transformation type takes an <offset>.</p><p>
|
||||
Offsets are relative to the center of the instrument. A shift without an offset
|
||||
has no effect. For example, let's say we have a texure that is a circle. If we
|
||||
has no effect. For example, let's say we have a texture that is a circle. If we
|
||||
use this texture in two layers, one defined as having a size of 128x128 and
|
||||
the second layer is defined as 64x64 and neither is supplied a shift and offset
|
||||
the net result appears as 2 concentric circles.
|
||||
|
@ -887,7 +1026,7 @@ Here is a list of property names including appropriate units:
|
|||
/engines/engine0/rpm => /engines/engine[0]/rpm
|
||||
/environment/clouds/altitude += "-ft"
|
||||
/environment/magnetic-dip += "-deg"
|
||||
/environment/magnetic-varation += "-deg"
|
||||
/environment/magnetic-variation += "-deg"
|
||||
/environment/visibility += "-m"
|
||||
/environment/wind-down += "-fps"
|
||||
/environment/wind-east += "-fps"
|
||||
|
|
Loading…
Reference in a new issue