1
0
Fork 0

Merge Nimitz into new carrier control scheme, add clickspots and individual animations

This commit is contained in:
Thorsten Renk 2017-11-10 10:20:44 +02:00
parent 00972633bf
commit a885fc0885
3 changed files with 669 additions and 23 deletions

View file

@ -14,6 +14,111 @@ apart from most of the very excellent textures, remain. -->
var self = cmdarg();
print("Model load Nimitz ", self.getPath());
var pathc = self.getPath();
# timescales
var elevator_transit_time = 30.0;
var jbd_transit_time = 5.0;
# register the dialog
setprop(pathc~"/dlg-name", "Nimitz");
# init course control, animation and detail properties
setprop("/controls/nimitz/deck-park",0);
setprop("/controls/nimitz/crew",0);
setprop("/controls/nimitz/lights", 0);
setprop("/controls/nimitz/turn-to-launch-hdg", 0);
setprop("/controls/nimitz/turn-to-recovery-hdg", 0);
setprop("/controls/nimitz/turn-to-base-course", 1);
################
# elevators
setprop("/controls/nimitz/elevator[0]/state",1);
setprop("/controls/nimitz/elevator[1]/state",0);
var elevator1 = aircraft.door.new(pathc~"/surface-positions/elevator[0]", elevator_transit_time, 1);
var elevator2 = aircraft.door.new(pathc~"/surface-positions/elevator[1]", elevator_transit_time, 0);
var elevator_array = [elevator1, elevator2];
################
# jet blast deflectors
setprop("/controls/nimitz/jbd[0]/state", 0);
setprop("/controls/nimitz/jbd[1]/state", 0);
setprop("/controls/nimitz/jbd[2]/state", 0);
setprop("/controls/nimitz/jbd[3]/state", 0);
var jbd1 = aircraft.door.new(pathc~"/surface-positions/jbd[0]", jbd_transit_time, 0);
var jbd2 = aircraft.door.new(pathc~"/surface-positions/jbd[1]", jbd_transit_time, 0);
var jbd3 = aircraft.door.new(pathc~"/surface-positions/jbd[2]", jbd_transit_time, 0);
var jbd4 = aircraft.door.new(pathc~"/surface-positions/jbd[3]", jbd_transit_time, 0);
var jbd_array = [jbd1, jbd2, jbd3, jbd4];
# elevator control
var elevator_operate = func (i){
var tgt = getprop("/controls/nimitz/elevator["~i~"]/state");
if (tgt == 1)
{
print ("Elevator ", i+1, " up.");
elevator_array[i].open();
}
else
{
print ("Elevator ", i+1, " down.");
elevator_array[i].close();
}
}
# JBD control
var jbd_operate = func (i) {
var tgt = getprop("/controls/nimitz/jbd["~i~"]/state");
if (tgt == 1)
{
print ("JBD ", i+1, " up.");
jbd_array[i].open();
}
else
{
print ("JBD ", i+1, " down.");
jbd_array[i].close();
}
}
# lighting control
var toggle_lights = func {
var state = getprop(pathc~"/controls/lighting/deck-lights");
if (state == 0)
{
setprop(pathc~"/controls/lighting/deck-lights", 1);
setprop(pathc~"/controls/lighting/flood-lights-red-norm", 0.7);
}
else
{
setprop(pathc~"/controls/lighting/deck-lights", 0);
setprop(pathc~"/controls/lighting/flood-lights-red-norm", 0.0);
}
}
fn_an_spn_46 = getprop("/sim/fg-root") ~ "/Aircraft/Generic/an_spn_46.nas";
io.load_nasal(fn_an_spn_46, "an_spn_46");
@ -24,12 +129,39 @@ apart from most of the very excellent textures, remain. -->
an_spn_46_timer.restart(anspn.GetUpdateRate());
});
an_spn_46_timer.restart(6);
# listeners
var l_elev1 = setlistener("/controls/nimitz/elevator/state", func {elevator_operate(0);},0,0);
var l_elev2 = setlistener("/controls/nimitz/elevator[1]/state", func {elevator_operate(1);},0,0);
var l_jbd1 = setlistener("/controls/nimitz/jbd[0]/state", func {jbd_operate(0);},0,0);
var l_jbd2 = setlistener("/controls/nimitz/jbd[1]/state", func {jbd_operate(1);},0,0);
var l_jbd3 = setlistener("/controls/nimitz/jbd[2]/state", func {jbd_operate(2);},0,0);
var l_jbd4 = setlistener("/controls/nimitz/jbd[3]/state", func {jbd_operate(3);},0,0);
var l_lights = setlistener("/controls/nimitz/lights", func {toggle_lights();},0,0);
]]>
</load>
<unload>
<![CDATA[
an_spn_46_timer.stop();
# clean up listeners
removelistener(l_elev_1);
removelistener(l_elev_2);
removelistener(l_jbd_1);
removelistener(l_jbd_2);
removelistener(l_jbd_3);
removelistener(l_jbd_4);
removelistener(l_lights);
]]>
</unload>
</nasal>
@ -391,7 +523,7 @@ apart from most of the very excellent textures, remain. -->
<animation>
<type>translate</type>
<object-name>Elevator-2</object-name>
<property>surface-positions/elevators-pos-norm</property>
<property>surface-positions/elevator[0]/position-norm</property>
<factor>10.62</factor>
<axis>
<x>0</x>
@ -405,7 +537,7 @@ apart from most of the very excellent textures, remain. -->
<object-name>Elevator-1</object-name>
<object-name>tractor-15</object-name>
<object-name>Crew-41</object-name>
<property>surface-positions/elevators-pos-norm</property>
<property>surface-positions/elevator[1]/position-norm</property>
<factor>10.62</factor>
<axis>
<x>0</x>
@ -418,7 +550,7 @@ apart from most of the very excellent textures, remain. -->
<object-name>Crew</object-name>
<object-name>Crew-41</object-name>
<condition>
<property>controls/crew</property>
<property>/controls/nimitz/crew</property>
</condition>
</animation>
@ -440,7 +572,7 @@ apart from most of the very excellent textures, remain. -->
<animation>
<type>rotate</type>
<object-name>JBD-1</object-name>
<property>surface-positions/jbd-pos-norm</property>
<property>surface-positions/jbd[0]/position-norm</property>
<factor>70</factor>
<axis>
<x1-m>9.5327</x1-m>
@ -455,7 +587,7 @@ apart from most of the very excellent textures, remain. -->
<animation>
<type>rotate</type>
<object-name>JBD-2</object-name>
<property>surface-positions/jbd-pos-norm</property>
<property>surface-positions/jbd[1]/position-norm</property>
<factor>70</factor>
<axis>
<x1-m>17.5861</x1-m>
@ -469,25 +601,25 @@ apart from most of the very excellent textures, remain. -->
<!-- non-op until I can figure out a way of stopping JBD3 & 4 interfering -->
<!--<animation>
<type>rotate</type>
<object-name>JBD-3</object-name>
<property>surface-positions/jbd-pos-norm</property>
<factor>70</factor>
<axis>
<x1-m>107.709</x1-m>
<y1-m>-15.4622</y1-m>
<z1-m>20</z1-m>
<x2-m>107.71</x2-m>
<y2-m>-25.034</y2-m>
<z2-m>20</z2-m>
</axis>
</animation>-->
<animation>
<type>rotate</type>
<object-name>JBD-3</object-name>
<property>surface-positions/jbd[2]/position-norm</property>
<factor>70</factor>
<axis>
<x1-m>107.709</x1-m>
<y1-m>-15.4622</y1-m>
<z1-m>20</z1-m>
<x2-m>107.71</x2-m>
<y2-m>-25.034</y2-m>
<z2-m>20</z2-m>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>JBD-4</object-name>
<property>surface-positions/jbd-pos-norm</property>
<property>surface-positions/jbd[3]/position-norm</property>
<factor>70</factor>
<axis>
<x1-m>125.471</x1-m>
@ -3799,4 +3931,178 @@ apart from most of the very excellent textures, remain. -->
<type>range</type>
<max-m>60000</max-m>
</animation>
<!-- elevators -->
<animation>
<type>pick</type>
<object-name>Elevator-2</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>property-toggle</command>
<property>/controls/nimitz/elevator/state</property>
</binding>
</action>
<hovered>
<binding>
<command>set-tooltip</command>
<tooltip-id>elev1</tooltip-id>
<label>move elevator 1</label>
</binding>
</hovered>
</animation>
<animation>
<type>pick</type>
<object-name>Elevator-1</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>property-toggle</command>
<property>/controls/nimitz/elevator[1]/state</property>
</binding>
</action>
<hovered>
<binding>
<command>set-tooltip</command>
<tooltip-id>elev2</tooltip-id>
<label>move elevator 2</label>
</binding>
</hovered>
</animation>
<!-- jet blast deflectors -->
<animation>
<type>pick</type>
<object-name>JBD-1</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>property-toggle</command>
<property>/controls/nimitz/jbd[0]/state</property>
</binding>
</action>
<hovered>
<binding>
<command>set-tooltip</command>
<tooltip-id>jbd1</tooltip-id>
<label>operate JBD1</label>
</binding>
</hovered>
</animation>
<animation>
<type>pick</type>
<object-name>JBD-2</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>property-toggle</command>
<property>/controls/nimitz/jbd[1]/state</property>
</binding>
</action>
<hovered>
<binding>
<command>set-tooltip</command>
<tooltip-id>jbd2</tooltip-id>
<label>operate JBD2</label>
</binding>
</hovered>
</animation>
<animation>
<type>pick</type>
<object-name>JBD-3</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>property-toggle</command>
<property>/controls/nimitz/jbd[2]/state</property>
</binding>
</action>
<hovered>
<binding>
<command>set-tooltip</command>
<tooltip-id>jbd3</tooltip-id>
<label>operate JBD3</label>
</binding>
</hovered>
</animation>
<animation>
<type>pick</type>
<object-name>JBD-4</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>property-toggle</command>
<property>/controls/nimitz/jbd[3]/state</property>
</binding>
</action>
<hovered>
<binding>
<command>set-tooltip</command>
<tooltip-id>jbd4</tooltip-id>
<label>operate JBD4</label>
</binding>
</hovered>
</animation>
<animation>
<type>pick</type>
<object-name>Flightdeck</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>property-toggle</command>
<property>/controls/nimitz/lights</property>
</binding>
</action>
<hovered>
<binding>
<command>set-tooltip</command>
<tooltip-id>lights</tooltip-id>
<label>switch lights</label>
</binding>
</hovered>
</animation>
<animation>
<type>pick</type>
<object-name>Island</object-name>
<object-name>Nav-Bridge-Deck</object-name>
<object-name>Flag-Bridge-Deck</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>dialog-show</command>
<dialog-name>Nimitz</dialog-name>
<property></property>
</binding>
</action>
<hovered>
<binding>
<command>set-tooltip</command>
<tooltip-id>bridge</tooltip-id>
<label>show Nimitz control dialog</label>
</binding>
</hovered>
</animation>
</PropertyList>

View file

@ -36,9 +36,9 @@ apart from most of the very excellent textures, remain. -->
setprop("/controls/vinson/crew",0);
setprop("/controls/vinson/lights", 0);
setprop("/controls/vinson/turn-to-launch-hdg", 0);
setprop("/controls/vinson/turn-to-recovery-hdg", 0);
setprop("/controls/vinson/turn-to-base-course", 1);
setprop("/controls/vinson/turn-to-launch-hdg", 0);
setprop("/controls/vinson/turn-to-recovery-hdg", 0);
setprop("/controls/vinson/turn-to-base-course", 1);
################
# elevators

340
gui/dialogs/nimitz.xml Normal file
View file

@ -0,0 +1,340 @@
<?xml version="1.0"?>
<PropertyList>
<name>Nimitz</name>
<modal>false</modal>
<layout>vbox</layout>
<group>
<layout>hbox</layout>
<empty>
<stretch>1</stretch>
</empty>
<text>
<label>USS Nimitz Controls</label>
</text>
<empty>
<stretch>1</stretch>
</empty>
<button>
<pref-width>16</pref-width>
<pref-height>16</pref-height>
<legend></legend>
<keynum>27</keynum>
<border>2</border>
<binding>
<command>dialog-close</command>
</binding>
</button>
</group>
<hrule/>
<group>
<layout>table</layout>
<text>
<label>Course</label>
<row>0</row>
<col>0</col>
</text>
<radio>
<row>1</row>
<col>0</col>
<halign>left</halign>
<label>Turn to launch course</label>
<property>/controls/nimitz/turn-to-launch-hdg</property>
<live>true</live>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>
var v = getprop("/controls/nimitz/turn-to-launch-hdg");
foreach (var c; props.globals.getNode("/ai/models").getChildren("carrier")){
if (c.getNode("name").getValue() == "Nimitz")
{
c.getNode("controls/turn-to-launch-hdg").setBoolValue(v);
c.getNode("controls/turn-to-recovery-hdg").setBoolValue(0);
c.getNode("controls/turn-to-base-course").setBoolValue(0);
}
}
setprop("/controls/nimitz/turn-to-base-course", 0);
setprop("/controls/nimitz/turn-to-recovery-hdg", 0);
</script>
</binding>
</radio>
<radio>
<row>2</row>
<col>0</col>
<halign>left</halign>
<label>Turn to recovery course</label>
<property>/controls/nimitz/turn-to-recovery-hdg</property>
<live>true</live>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>
var v = getprop("/controls/nimitz/turn-to-recovery-hdg");
foreach (var c; props.globals.getNode("/ai/models").getChildren("carrier")){
if (c.getNode("name").getValue() == "Nimitz")
{
c.getNode("controls/turn-to-recovery-hdg").setBoolValue(v);
c.getNode("controls/turn-to-launch-hdg").setBoolValue(0);
c.getNode("controls/turn-to-base-course").setBoolValue(0);
}
}
setprop("/controls/nimitz/turn-to-base-course", 0);
setprop("/controls/nimitz/turn-to-launch-hdg", 0);
</script>
</binding>
</radio>
<radio>
<row>3</row>
<col>0</col>
<halign>left</halign>
<label>Turn to base course</label>
<property>/controls/nimitz/turn-to-base-course</property>
<live>true</live>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>
var v = getprop("/controls/nimitz/turn-to-base-course");
foreach (var c; props.globals.getNode("/ai/models").getChildren("carrier")){
if (c.getNode("name").getValue() == "Nimitz")
{
c.getNode("controls/turn-to-base-course").setBoolValue(v);
c.getNode("controls/turn-to-recovery-hdg").setBoolValue(0);
c.getNode("controls/turn-to-launch-hdg").setBoolValue(0);
}
}
setprop("/controls/nimitz/turn-to-launch-hdg", 0);
setprop("/controls/nimitz/turn-to-recovery-hdg", 0);
</script>
</binding>
</radio>
</group>
<hrule/>
<group>
<layout>table</layout>
<text>
<label>Equipment</label>
<row>0</row>
<col>0</col>
</text>
<checkbox>
<halign>left</halign>
<row>1</row>
<col>0</col>
<label>Elevator 1</label>
<property>/controls/nimitz/elevator[0]/state</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
<checkbox>
<halign>left</halign>
<row>1</row>
<col>1</col>
<label>Elevator 2</label>
<property>/controls/nimitz/elevator[1]/state</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
<checkbox>
<halign>left</halign>
<row>3</row>
<col>0</col>
<label>JBD 1</label>
<property>/controls/nimitz/jbd[0]/state</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
<checkbox>
<halign>left</halign>
<row>3</row>
<col>1</col>
<label>JBD 2</label>
<property>/controls/nimitz/jbd[1]/state</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
<checkbox>
<halign>left</halign>
<row>3</row>
<col>2</col>
<label>JBD 3</label>
<property>/controls/nimitz/jbd[2]/state</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
<checkbox>
<halign>left</halign>
<row>3</row>
<col>3</col>
<label>JBD 4</label>
<property>/controls/nimitz/jbd[3]/state</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
</group>
<hrule/>
<group>
<layout>table</layout>
<text>
<label>Options</label>
<row>0</row>
<col>0</col>
</text>
<!--<checkbox>
<halign>left</halign>
<row>1</row>
<col>0</col>
<label>Enable Deck Park</label>
<property>/controls/nimitz/deck-park</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>-->
<checkbox>
<halign>left</halign>
<row>1</row>
<col>0</col>
<label>Enable Crew</label>
<property>/controls/nimitz/crew</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
<checkbox>
<halign>left</halign>
<row>1</row>
<col>1</col>
<label>Deck lights</label>
<property>/controls/nimitz/lights</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
<!--<checkbox>
<halign>left</halign>
<row>2</row>
<col>1</col>
<label>Enable Wave motion</label>
<property>/controls/vinson/wave-motion</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>-->
</group>
<empty>
<stretch>1</stretch>
</empty>
<hrule/>
<hrule/>
<group>
<layout>hbox</layout>
<default-padding>6</default-padding>
<empty>
<stretch>true</stretch>
</empty>
<button>
<legend>OK</legend>
<default>true</default>
<equal>true</equal>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>dialog-close</command>
</binding>
</button>
<button>
<legend>Apply</legend>
<equal>true</equal>
<binding>
<command>dialog-apply</command>
</binding>
</button>
<button>
<legend>Reset</legend>
<equal>true</equal>
<binding>
<command>dialog-update</command>
</binding>
</button>
<button>
<legend>Cancel</legend>
<equal>true</equal>
<key>Esc</key>
<binding>
<command>dialog-close</command>
</binding>
</button>
<empty>
<stretch>true</stretch>
</empty>
</group>
</PropertyList>