| 1 | <?xml version="1.0"?> |
| 2 | <!DOCTYPE xsl:stylesheet> |
| 3 | <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
| 4 | <xsl:variable name="model" select="concat(/assemblies/@fg-root, '/Aircraft/Instruments-3d/mk-viii/assembly/assembly.ac')"/> |
| 5 | <xsl:variable name="texture-path"> |
| 6 | <xsl:if test="/assemblies/@texture-path"><xsl:value-of select="concat(/assemblies/@texture-path, '/')"/></xsl:if> |
| 7 | </xsl:variable> |
| 8 | |
| 9 | <xsl:template name="generated"> |
| 10 | <xsl:comment>automatically generated, do not edit</xsl:comment> |
| 11 | </xsl:template> |
| 12 | |
| 13 | <xsl:template match="assembly"> |
| 14 | <xsl:variable name="actions" select="concat(@name, '-actions.xml')"/> |
| 15 | <xsl:variable name="prefix" select="concat('/controls/assemblies/', @name)"/> |
| 16 | <xsl:variable name="button" select="concat($prefix, '-button')"/> |
| 17 | <xsl:variable name="guard" select="concat($prefix, '-guard')"/> |
| 18 | <xsl:variable name="guarded"> |
| 19 | <xsl:choose> |
| 20 | <xsl:when test="@guarded='true'">true</xsl:when> |
| 21 | <xsl:otherwise>false</xsl:otherwise> |
| 22 | </xsl:choose> |
| 23 | </xsl:variable> |
| 24 | <xsl:variable name="latching"> |
| 25 | <xsl:choose> |
| 26 | <xsl:when test="not(@input)">true</xsl:when> |
| 27 | <xsl:otherwise>false</xsl:otherwise> |
| 28 | </xsl:choose> |
| 29 | </xsl:variable> |
| 30 | <xsl:variable name="input"> |
| 31 | <xsl:choose> |
| 32 | <xsl:when test="$latching='false'"><xsl:value-of select="@input"/></xsl:when> |
| 33 | <xsl:otherwise><xsl:value-of select="$button"/></xsl:otherwise> |
| 34 | </xsl:choose> |
| 35 | </xsl:variable> |
| 36 | <xsl:variable name="emission-red"> |
| 37 | <xsl:choose> |
| 38 | <xsl:when test="@emission-red"><xsl:value-of select="@emission-red"/></xsl:when> |
| 39 | <xsl:otherwise><xsl:value-of select="/assemblies/@emission-red"/></xsl:otherwise> |
| 40 | </xsl:choose> |
| 41 | </xsl:variable> |
| 42 | <xsl:variable name="emission-green"> |
| 43 | <xsl:choose> |
| 44 | <xsl:when test="@emission-green"><xsl:value-of select="@emission-green"/></xsl:when> |
| 45 | <xsl:otherwise><xsl:value-of select="/assemblies/@emission-green"/></xsl:otherwise> |
| 46 | </xsl:choose> |
| 47 | </xsl:variable> |
| 48 | <xsl:variable name="emission-blue"> |
| 49 | <xsl:choose> |
| 50 | <xsl:when test="@emission-blue"><xsl:value-of select="@emission-blue"/></xsl:when> |
| 51 | <xsl:otherwise><xsl:value-of select="/assemblies/@emission-blue"/></xsl:otherwise> |
| 52 | </xsl:choose> |
| 53 | </xsl:variable> |
| 54 | <xsl:variable name="emission-factor"> |
| 55 | <xsl:choose> |
| 56 | <xsl:when test="@emission-factor"><xsl:value-of select="@emission-factor"/></xsl:when> |
| 57 | <xsl:otherwise><xsl:value-of select="/assemblies/@emission-factor"/></xsl:otherwise> |
| 58 | </xsl:choose> |
| 59 | </xsl:variable> |
| 60 | <xsl:variable name="texture-prefix"> |
| 61 | <xsl:choose> |
| 62 | <xsl:when test="@texture"><xsl:value-of select="@texture"/></xsl:when> |
| 63 | <xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise> |
| 64 | </xsl:choose> |
| 65 | </xsl:variable> |
| 66 | <xsl:variable name="texture-on" select="concat($texture-path, $texture-prefix, '-on.rgb')"/> |
| 67 | <xsl:variable name="texture-off" select="concat($texture-path, $texture-prefix, '-off.rgb')"/> |
| 68 | |
| 69 | <xsl:document href="{@name}.xml" indent="yes"> |
| 70 | <xsl:call-template name="generated"/> |
| 71 | <PropertyList> |
| 72 | <path><xsl:value-of select="$model"/></path> |
| 73 | |
| 74 | <xsl:if test="@output"> |
| 75 | <panel> |
| 76 | <path><xsl:value-of select="concat(/assemblies/@pwd, '/', $actions)"/></path> |
| 77 | <bottom-left> |
| 78 | <x-m>0.00314583</x-m> |
| 79 | <y-m>-0.00965716</y-m> |
| 80 | <z-m>-0.00965716</z-m> |
| 81 | </bottom-left> |
| 82 | <bottom-right> |
| 83 | <x-m>0.00314583</x-m> |
| 84 | <y-m>0.00965716</y-m> |
| 85 | <z-m>-0.00965716</z-m> |
| 86 | </bottom-right> |
| 87 | <top-left> |
| 88 | <x-m>0.00314583</x-m> |
| 89 | <y-m>-0.00965716</y-m> |
| 90 | <z-m>0.02897148</z-m> |
| 91 | </top-left> |
| 92 | </panel> |
| 93 | |
| 94 | <animation> |
| 95 | <type>translate</type> |
| 96 | <object-name>lamp</object-name> |
| 97 | <property><xsl:value-of select="$button"/></property> |
| 98 | <factor>-0.0040</factor> |
| 99 | <axis> |
| 100 | <x>1.0</x> |
| 101 | <y>0.0</y> |
| 102 | <z>0.0</z> |
| 103 | </axis> |
| 104 | </animation> |
| 105 | </xsl:if> |
| 106 | |
| 107 | <animation> |
| 108 | <type>select</type> |
| 109 | <object-name>guard</object-name> |
| 110 | <condition> |
| 111 | <xsl:choose> |
| 112 | <xsl:when test="$guarded='true'"><not><property>/null</property></not></xsl:when> |
| 113 | <xsl:otherwise><property>/null</property></xsl:otherwise> |
| 114 | </xsl:choose> |
| 115 | </condition> |
| 116 | </animation> |
| 117 | |
| 118 | <xsl:if test="$guarded='true'"> |
| 119 | <animation> |
| 120 | <type>rotate</type> |
| 121 | <object-name>guard</object-name> |
| 122 | <property><xsl:value-of select="$guard"/></property> |
| 123 | <factor>-90</factor> |
| 124 | <center> |
| 125 | <x-m>-0.00314583</x-m> |
| 126 | <y-m>0.0</y-m> |
| 127 | <z-m>0.00965716</z-m> |
| 128 | </center> |
| 129 | <axis> |
| 130 | <x>0.0</x> |
| 131 | <y>1.0</y> |
| 132 | <z>0.0</z> |
| 133 | </axis> |
| 134 | </animation> |
| 135 | </xsl:if> |
| 136 | |
| 137 | <animation> |
| 138 | <type>material</type> |
| 139 | <object-name>lamp-off</object-name> |
| 140 | <texture><xsl:value-of select="$texture-off"/></texture> |
| 141 | </animation> |
| 142 | |
| 143 | <animation> |
| 144 | <type>material</type> |
| 145 | <object-name>lamp-on</object-name> |
| 146 | <texture><xsl:value-of select="$texture-on"/></texture> |
| 147 | </animation> |
| 148 | |
| 149 | <animation> |
| 150 | <type>select</type> |
| 151 | <object-name>lamp-off</object-name> |
| 152 | <condition> |
| 153 | <not><property><xsl:value-of select="$input"/></property></not> |
| 154 | </condition> |
| 155 | </animation> |
| 156 | |
| 157 | <animation> |
| 158 | <type>select</type> |
| 159 | <object-name>lamp-on</object-name> |
| 160 | <condition> |
| 161 | <property><xsl:value-of select="$input"/></property> |
| 162 | </condition> |
| 163 | </animation> |
| 164 | |
| 165 | <animation> |
| 166 | <type>material</type> |
| 167 | <object-name>lamp-off</object-name> |
| 168 | <emission> |
| 169 | <red-prop><xsl:value-of select="$emission-red"/></red-prop> |
| 170 | <green-prop><xsl:value-of select="$emission-green"/></green-prop> |
| 171 | <blue-prop><xsl:value-of select="$emission-blue"/></blue-prop> |
| 172 | <factor-prop><xsl:value-of select="$emission-factor"/></factor-prop> |
| 173 | </emission> |
| 174 | </animation> |
| 175 | </PropertyList> |
| 176 | </xsl:document> |
| 177 | |
| 178 | <xsl:if test="@output"> |
| 179 | <xsl:document href="{$actions}" indent="yes"> |
| 180 | <xsl:call-template name="generated"/> |
| 181 | <PropertyList> |
| 182 | <background>Aircraft/Instruments-3d/mk-viii/assembly/transparent-bg.rgb</background> |
| 183 | <w>64</w> |
| 184 | <h>64</h> |
| 185 | |
| 186 | <instruments> |
| 187 | <instrument> |
| 188 | <x>32</x> |
| 189 | <y>32</y> |
| 190 | <w>64</w> |
| 191 | <h>64</h> |
| 192 | <w-base>64</w-base> |
| 193 | <h-base>64</h-base> |
| 194 | |
| 195 | <actions> |
| 196 | <action> |
| 197 | <name>open guard or operate button</name> |
| 198 | <button>0</button> |
| 199 | <x>-32</x> |
| 200 | <y>-32</y> |
| 201 | <w>64</w> |
| 202 | <h>32</h> |
| 203 | |
| 204 | <binding> |
| 205 | <command>press-cockpit-button</command> |
| 206 | <guarded><xsl:value-of select="$guarded"/></guarded> |
| 207 | <latching><xsl:value-of select="$latching"/></latching> |
| 208 | <prefix><xsl:value-of select="$prefix"/></prefix> |
| 209 | <discrete><xsl:value-of select="@output"/></discrete> |
| 210 | </binding> |
| 211 | |
| 212 | <mod-up> |
| 213 | <binding> |
| 214 | <command>release-cockpit-button</command> |
| 215 | <guarded><xsl:value-of select="$guarded"/></guarded> |
| 216 | <latching><xsl:value-of select="$latching"/></latching> |
| 217 | <prefix><xsl:value-of select="$prefix"/></prefix> |
| 218 | <discrete><xsl:value-of select="@output"/></discrete> |
| 219 | </binding> |
| 220 | </mod-up> |
| 221 | </action> |
| 222 | |
| 223 | <xsl:if test="$guarded='true'"> |
| 224 | <action> |
| 225 | <name>close guard</name> |
| 226 | <button>0</button> |
| 227 | <x>-32</x> |
| 228 | <y>0</y> |
| 229 | <w>64</w> |
| 230 | <h>32</h> |
| 231 | |
| 232 | <binding> |
| 233 | <command>property-assign</command> |
| 234 | <property><xsl:value-of select="$guard"/></property> |
| 235 | <value type="double">0.0</value> |
| 236 | </binding> |
| 237 | </action> |
| 238 | </xsl:if> |
| 239 | |
| 240 | </actions> |
| 241 | </instrument> |
| 242 | </instruments> |
| 243 | </PropertyList> |
| 244 | </xsl:document> |
| 245 | </xsl:if> |
| 246 | </xsl:template> |
| 247 | |
| 248 | <xsl:template match="assemblies"> |
| 249 | <xsl:apply-templates select="*"/> |
| 250 | </xsl:template> |
| 251 | </xsl:stylesheet> |