From 2dc430889deb0d19eaf011918540516d21298c9b Mon Sep 17 00:00:00 2001 From: j4strngs Date: Tue, 9 Oct 2001 22:09:14 +0000 Subject: [PATCH] Added section on conditions Modified Files: README.xmlpanel.html --- Docs/README.xmlpanel.html | 155 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 147 insertions(+), 8 deletions(-) diff --git a/Docs/README.xmlpanel.html b/Docs/README.xmlpanel.html index 4147284ef..672aaad19 100644 --- a/Docs/README.xmlpanel.html +++ b/Docs/README.xmlpanel.html @@ -17,11 +17,11 @@ Author: John Check
  • Example Top Level Panel Config
  • Indexed Properties
  • Inclusion -
  • Aliasing
  • Instrument Architecture
  • Textures
  • Instrument Layers
  • Transformations +
  • Conditions
  • About Transformations and Needle Placement
  • Interpolation Tables
  • Actions @@ -580,6 +580,145 @@ This example is a switch that contains both static and dynamic text:
    +
    +

    Conditions:

    +
    + +

    +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. +

    +

    +For example, to ensure that a layer is drawn only if the /foo/bar +property has the value "active", you would do the following: +

    +
    +  <layer>
    +   <name>FooBar Layer</name>
    +   <condition>
    +    <equals>
    +     <property>/foo/bar</property>
    +     <value>active</value>
    +    </equals>
    +   </condition>
    +   ...
    +  </layer>
    +
    +

    +To draw a different layer when the /foo/bar property does not have the +value "active", you could follow with this: +

    +
    +  <layer>
    +   <name>FooBar Layer</name>
    +   <condition>
    +    <not-equals>
    +     <property>/foo/bar</property>
    +     <value>active</value>
    +    </not-equals>
    +   </condition>
    +   ...
    +  </layer>
    +
    +

    +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). +

    +
    +  <!-- 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>
    +
    +

    +The <condition> element acts as an implicit 'and' group for everything +contained in it. Here are the elements that can appear inside: +

    +
    +  <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>
    +
    +

    + - 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 +

    +

    Transformations:


    @@ -591,8 +730,8 @@ 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>.

    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 -use this texture in two layers, one defined as having a size of 128x128 and +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.

    @@ -705,12 +844,12 @@ always tied to properties: they can toggle a boolean property, adjust the value of a numeric property, or swap the values of two properties. The x/y placement for actions specifies the origin of the lower left corner. In the following example the first action sets up a hotspot 32 pixels wide -and 16 pixels high. It lower left corner is placed 96 pixels (relative to the -defined base size of the instrument) to the right of the center of the +and 16 pixels high. It lower left corner is placed 96 pixels (relative to the +defined base size of the instrument) to the right of the center of the instrument. It is also 32 pixels below the centerline of the instrument. The actual knob texture over which the action is superimposed is 32x32. -Omitted here is a second action, bound to the same property, with a positive -increment value. This second action is placed to cover the other half of the +Omitted here is a second action, bound to the same property, with a positive +increment value. This second action is placed to cover the other half of the knob. The result is that clicking on the left half of the knob texture decreases the value and clicking the right half increases the value. Also omitted here is a second pair of actions with the same coordinates but a larger increment @@ -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"