1
0
Fork 0

Replay upgrade, part IV: new GUI, config settings, keyboard bindings

This commit is contained in:
ThorstenB 2011-10-01 23:27:54 +02:00
parent bde90daa71
commit 7370dc93c1
4 changed files with 545 additions and 173 deletions

View file

@ -1,22 +1,249 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<PropertyList> <PropertyList>
<name>replay</name> <name>replay</name>
<modal>false</modal>
<layout>vbox</layout> <layout>vbox</layout>
<modal>false</modal>
<default-padding>1</default-padding>
<y>5</y>
<color>
<red>0.2</red>
<green>0.2</green>
<blue>0.2</blue>
<alpha>0.7</alpha>
</color>
<nasal>
<open><![CDATA[
var ReplayDialogController = {
new : func( dlgRoot ) {
var obj = { parents: [ReplayDialogController] };
obj.dlgRoot = dlgRoot;
return obj;
},
open : func {
var replaySlider = me.findElementByName( me.dlgRoot, "replay-time-slider" );
me.maxProp = replaySlider.getChild("max");
me.minProp = replaySlider.getChild("min");
me.maxListenerId = setlistener( "/sim/speed-up", func(n) { me.updateListener(n); }, 1, 1 );
if (getprop("/sim/replay/end-time")!=nil)
{
# update max/min range of replay-time slider
me.maxProp.setValue(getprop("/sim/replay/end-time"));
me.minProp.setValue(getprop("/sim/replay/start-time"));
}
me.updateListener(1);
},
updateListener : func( n ) {
var SpeedUp = getprop("/sim/speed-up");
if (SpeedUp<0.9)
{
SpeedUp=1/SpeedUp;
SpeedUp = "1/" ~ SpeedUp;
}
setprop("/sim/gui/dialogs/replay/time-factor","" ~ SpeedUp ~ "x");
},
close : func {
#removelistener( me.maxListenerId );
},
findElementByName : func(base,name) {
foreach( var child; base.getChildren() ) {
var n = child.getNode( "name" );
if( n != nil and n.getValue() == name )
return child;
var f = me.findElementByName(child,name);
if( f != nil ) return f;
}
return nil;
},
};
var controller = ReplayDialogController.new( cmdarg() );
controller.open();
]]></open>
<close><![CDATA[
controller.close();
]]></close>
</nasal>
<group> <group>
<layout>hbox</layout> <layout>hbox</layout>
<empty><stretch>1</stretch></empty> <halign>fill</halign>
<pref-height>28</pref-height>
<text> <text>
<label>Instant Replay</label> <font>
<name>SANS_12B</name>
</font>
<label>REPLAY</label>
<color>
<red>0.9</red>
<green>0.9</green>
<blue>0.9</blue>
<alpha>1</alpha>
</color>
<pref-width>70</pref-width>
</text> </text>
<empty><stretch>1</stretch></empty> <text>
<label>Loop:</label>
<color>
<red>0.7</red>
<green>0.7</green>
<blue>0.7</blue>
<alpha>1</alpha>
</color>
</text>
<checkbox>
<name>replay-looped</name>
<halign>left</halign>
<color-highlight>
<red type="float">0.6</red>
<green type="float">0.6</green>
<blue type="float">0.6</blue>
<alpha type="float">0.8</alpha>
</color-highlight>
<property>/sim/replay/looped</property>
<binding>
<command>dialog-apply</command>
<object-name>replay-looped</object-name>
</binding>
</checkbox>
<input>
<name>replay-duration</name>
<pref-width>40</pref-width>
<color>
<red>0.5</red>
<green>0.5</green>
<blue>0.5</blue>
<alpha type="float">0.8</alpha>
</color>
<property>/sim/replay/duration</property>
<binding>
<command>dialog-apply</command>
<object-name>replay-duration</object-name>
</binding>
</input>
<empty><pref-width>40</pref-width></empty>
<text>
<label>Time: 99:99:99.9</label>
<format>Time: %s</format>
<color>
<red>0.7</red>
<green>0.7</green>
<blue>0.7</blue>
<alpha>1</alpha>
</color>
<live>true</live>
<property>/sim/replay/time-str</property>
</text>
<empty><pref-width>10</pref-width></empty>
<text>
<label>Size: 999.9MB</label>
<format>Size: %.1fMB</format>
<color>
<red>0.7</red>
<green>0.7</green>
<blue>0.7</blue>
<alpha>1</alpha>
</color>
<property>/sim/replay/buffer-size-mbyte</property>
</text>
<empty><pref-width>40</pref-width></empty>
<text>
<label>Speed:</label>
<color>
<red>0.7</red>
<green>0.7</green>
<blue>0.7</blue>
<alpha>1</alpha>
</color>
</text>
<button>
<legend><![CDATA[-]]></legend>
<pref-width>20</pref-width>
<border>1</border>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<keynum>359</keynum>
<binding>
<command>nasal</command>
<script><![CDATA[
var t = getprop("/sim/speed-up");
if (t > 1/32)
t=t/2;
else
t=1/32;
setprop("/sim/speed-up", t);
]]></script>
</binding>
</button>
<text>
<label>1/16x</label>
<pref-width>28</pref-width>
<format>%s</format>
<color>
<red>0.7</red>
<green>0.7</green>
<blue>0.7</blue>
<alpha>1</alpha>
</color>
<live>true</live>
<property>/sim/gui/dialogs/replay/time-factor</property>
</text>
<button>
<legend><![CDATA[+]]></legend>
<pref-width>20</pref-width>
<border>1</border>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<keynum>357</keynum>
<binding>
<command>nasal</command>
<script><![CDATA[
var t = getprop("/sim/speed-up");
if (t < 32)
t=t*2;
else
t=32;
setprop("/sim/speed-up", t);
]]></script>
</binding>
</button>
<empty><stretch>1</stretch></empty>
<!--
<button> <button>
<pref-width>16</pref-width> <pref-width>16</pref-width>
<pref-height>16</pref-height> <pref-height>16</pref-height>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<legend></legend> <legend></legend>
<keynum>27</keynum> <keynum>27</keynum>
<border>2</border> <border>2</border>
@ -24,182 +251,291 @@
<command>dialog-close</command> <command>dialog-close</command>
</binding> </binding>
</button> </button>
</group> -->
<hrule/>
<nasal>
<open>
# Populate the view combo box with a list of the available views
var combo = cmdarg().getChildren("group")[1].getNode("combo");
combo.removeChildren("value");
var current_view = getprop("/sim/current-view/view-number");
var i = 0;
foreach (var v; view.views) {
var name = "Unnamed view " ~ v.getIndex();
if (v.getNode("name") != nil) {
name = v.getNode("name").getValue();
}
# Pre-populate the combo box selected value
if (v.getIndex() == current_view) {
setprop("/sim/replay/view-name", name);
}
combo.getNode("value[" ~ i ~ "]", 1).setValue(name);
i = i + 1;
}
</open>
</nasal>
<group>
<layout>table</layout>
<text>
<row>0</row><col>0</col>
<halign>right</halign>
<label>Duration:</label>
</text>
<input>
<row>0</row><col>1</col>
<pref-width>40</pref-width>
<halign>left</halign>
<property>/sim/replay/duration</property>
</input>
<text>
<row>1</row><col>0</col>
<halign>right</halign>
<label>View:</label>
</text>
<combo>
<row>1</row><col>1</col>
<halign>left</halign>
<pref-width>200</pref-width>
<property>/sim/replay/view-name</property>
<binding>
<command>dialog-apply</command>
</binding>
</combo>
<checkbox>
<row>2</row><col>1</col>
<halign>left</halign>
<property>/sim/replay/looped</property>
<label>Looped replay</label>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
</group>
<hrule/>
<text>
<halign>left</halign>
<label>During replay:</label>
</text>
<group>
<layout>table</layout>
<text>
<row>1</row><col>0</col>
<halign>center</halign>
<label>v/V</label>
</text>
<text>
<row>1</row><col>1</col>
<halign>left</halign>
<label>Change view</label>
</text>
<text>
<row>2</row><col>0</col>
<halign>center</halign>
<label>Ctrl-v</label>
</text>
<text>
<row>2</row><col>1</col>
<halign>left</halign>
<label>Reset view</label>
</text>
<text>
<row>3</row><col>0</col>
<halign>center</halign>
<label>p p</label>
</text>
<text>
<row>3</row><col>1</col>
<halign>left</halign>
<label>End replay</label>
</text>
</group>
<hrule/>
<group>
<layout>hbox</layout>
<empty><stretch>true</stretch></empty>
<button> <button>
<legend>Start</legend> <legend>Hide</legend>
<default>true</default> <border>1</border>
<equal>true</equal> <color>
<binding> <red type="float">0.3</red>
<command>dialog-apply</command> <green type="float">0.3</green>
</binding> <blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<pref-width>40</pref-width>
<binding> <binding>
<command>nasal</command> <command>nasal</command>
<script> <script><![CDATA[
var index = view.indexof(getprop("/sim/replay/view-name")); setprop("/sim/messages/copilot", "Replay active. 'Esc' to stop. 'Ctrl-R' to show replay controls.");
setprop("/sim/current-view/view-number", index); ]]></script>
</script>
</binding>
<binding>
<command>replay</command>
</binding> </binding>
<binding> <binding>
<command>dialog-close</command> <command>dialog-close</command>
</binding> </binding>
</button> </button>
<empty><stretch>true</stretch></empty> </group>
<group>
<layout>hbox</layout>
<halign>center</halign>
<button> <button>
<legend>Stop</legend> <legend><![CDATA[<<]]></legend>
<equal>true</equal> <pref-width>30</pref-width>
<enable> <border>1</border>
<greater-than> <color>
<property>/sim/freeze/replay-state</property> <red type="float">0.3</red>
<value>0</value> <green type="float">0.3</green>
</greater-than> <blue type="float">0.3</blue>
</enable> <alpha type="float">0.8</alpha>
</color>
<binding>
<command>nasal</command>
<script><![CDATA[
var t = getprop("/sim/replay/time");
if (t != "")
{
t-=30;
if (t<0) t=0;
setprop("/sim/replay/time", t);
}
]]></script>
</binding>
</button>
<button>
<legend><![CDATA[<]]></legend>
<pref-width>30</pref-width>
<border>1</border>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<keynum>356</keynum>
<binding>
<command>nasal</command>
<script><![CDATA[
var t = getprop("/sim/replay/time");
if (t != "")
{
t-=5;
if (t<0) t=0;
setprop("/sim/replay/time", t);
}
]]></script>
</binding>
</button>
<text>
<label>9:99:99</label>
<color>
<red>0.7</red>
<green>0.7</green>
<blue>0.7</blue>
<alpha>1</alpha>
</color>
<format>%8s</format>
<halign>right</halign>
<live>true</live>
<property>/sim/replay/start-time-str</property>
</text>
<slider>
<name>replay-time-slider</name>
<border>0</border>
<color>
<red>0.4</red>
<green>0.4</green>
<blue>0.4</blue>
<alpha>1</alpha>
</color>
<halign>left</halign>
<pref-width>350</pref-width>
<min>0</min><!-- property is updated on "dialog open" -->
<max>1.0</max><!-- property is updated on "dialog open" -->
<property>/sim/replay/time</property>
<live>true</live>
<binding>
<command>dialog-apply</command>
<object-name>replay-time-slider</object-name>
</binding>
</slider>
<text>
<label>9:99:99</label>
<color>
<red>0.7</red>
<green>0.7</green>
<blue>0.7</blue>
<alpha>1</alpha>
</color>
<format>%s</format>
<halign>left</halign>
<live>true</live>
<property>/sim/replay/end-time-str</property>
</text>
<button>
<legend><![CDATA[>]]></legend>
<pref-width>30</pref-width>
<border>1</border>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<keynum>358</keynum>
<binding>
<command>nasal</command>
<script><![CDATA[
var t = getprop("/sim/replay/time");
if (t != "")
{
t+=5;
if (t>getprop("/sim/replay/end-time"))
t = getprop("/sim/replay/end-time")-0.1;
if (t<0) t=0;
setprop("/sim/replay/time", t);
}
]]></script>
</binding>
</button>
<button>
<legend><![CDATA[>>]]></legend>
<pref-width>30</pref-width>
<border>1</border>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<binding>
<command>nasal</command>
<script><![CDATA[
var t = getprop("/sim/replay/time");
if (t != "")
{
t+=30;
if (t>getprop("/sim/replay/end-time"))
t = getprop("/sim/replay/end-time")-0.1;
if (t<0) t=0;
setprop("/sim/replay/time", t);
}
]]></script>
</binding>
</button>
</group>
<group>
<layout>hbox</layout>
<halign>center</halign>
<stretch>false</stretch>
<default-padding>3</default-padding>
<button>
<legend>Pause</legend>
<default>true</default>
<border>2</border>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<property>/sim/freeze/master</property>
<live>true</live>
<pref-width>47</pref-width>
<binding>
<command>property-toggle</command>
<property>/sim/freeze/clock</property>
</binding>
<binding>
<command>property-toggle</command>
<property>/sim/freeze/master</property>
</binding>
</button>
<button>
<legend>End Replay</legend>
<key>Esc</key>
<border>1</border>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<!--<pref-width>47</pref-width>-->
<binding> <binding>
<property>/sim/replay/disable</property>
<command>property-assign</command> <command>property-assign</command>
<property>/sim/replay/disable</property>
<value type="bool">true</value> <value type="bool">true</value>
</binding> </binding>
<binding> <binding>
<command>dialog-close</command> <command>dialog-close</command>
</binding> </binding>
</button> </button>
<empty><stretch>true</stretch></empty>
<!-- Future features...
<button> <button>
<legend>Cancel</legend> <legend>My controls!</legend>
<equal>true</equal> <border>1</border>
<key>Esc</key> <color>
<red>1</red>
<green>0.3</green>
<blue>0.3</blue>
<alpha>0.8</alpha>
</color>
<pref-width>80</pref-width>
<binding>
<command>property-assign</command>
<property>/sim/freeze/replay-state</property>
<value type="int">3</value>
</binding>
<binding>
<command>property-assign</command>
<property>/sim/replay/disable</property>
<value type="bool">true</value>
</binding>
<binding> <binding>
<command>dialog-close</command> <command>dialog-close</command>
</binding> </binding>
</button> </button>
<empty><stretch>true</stretch></empty> <button>
<legend>Save</legend>
<border>1</border>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<pref-width>43</pref-width>
<binding>
<command>nasal</command>
<script>gui.popupTip("Not implemented yet. Comming soon.");</script>
</binding>
</button>
<button>
<legend>Load</legend>
<border>1</border>
<enable>0</enable>
<color>
<red type="float">0.3</red>
<green type="float">0.3</green>
<blue type="float">0.3</blue>
<alpha type="float">0.8</alpha>
</color>
<pref-width>40</pref-width>
<binding>
<command>nasal</command>
<script>gui.popupTip("Not implemented yet. Comming soon.");</script>
</binding>
</button>
-->
</group> </group>
</PropertyList> </PropertyList>

View file

@ -190,6 +190,9 @@
<item> <item>
<label>Instant Replay (Ctrl-R)</label> <label>Instant Replay (Ctrl-R)</label>
<binding>
<command>replay</command>
</binding>
<binding> <binding>
<command>dialog-show</command> <command>dialog-show</command>
<dialog-name>replay</dialog-name> <dialog-name>replay</dialog-name>

View file

@ -168,6 +168,10 @@ top down before the key bindings are parsed.
<binding> <binding>
<command>replay</command> <command>replay</command>
</binding> </binding>
<binding>
<command>dialog-show</command>
<dialog-name>replay</dialog-name>
</binding>
</key> </key>
<key n="19"> <key n="19">
@ -268,9 +272,22 @@ top down before the key bindings are parsed.
<name>ESC</name> <name>ESC</name>
<desc>Prompt and quit FlightGear</desc> <desc>Prompt and quit FlightGear</desc>
<binding> <binding>
<condition>
<not>
<property>/sim/freeze/replay-state</property>
</not>
</condition>
<command>dialog-show</command> <command>dialog-show</command>
<dialog-name>exit</dialog-name> <dialog-name>exit</dialog-name>
</binding> </binding>
<binding>
<condition>
<property>/sim/freeze/replay-state</property>
</condition>
<command>property-assign</command>
<property>/sim/replay/disable</property>
<value type="bool">true</value>
</binding>
<mod-shift> <mod-shift>
<desc>Reset FlightGear</desc> <desc>Reset FlightGear</desc>
<binding> <binding>

View file

@ -677,6 +677,17 @@ Started September 2000 by David Megginson, david@megginson.com
<duration type="double">90</duration> <duration type="double">90</duration>
<view type="int">1</view> <view type="int">1</view>
<looped type="bool" userarchive="y">true</looped> <looped type="bool" userarchive="y">true</looped>
<buffer> <!-- replay buffer configuration -->
<!-- 1st buffer level: short term -->
<high-res-time type="double">60.0</high-res-time> <!-- 60 seconds -->
<!-- short term sample rate is as every frame (fixed) -->
<!-- 2nd buffer level: medium term -->
<medium-res-sample-dt type="double">0.5</medium-res-sample-dt>
<medium-res-time type="double">600.0</medium-res-time><!-- 10 mins -->
<!-- 3rd buffer level: long term -->
<low-res-sample-dt type="double">5.0</low-res-sample-dt>
<low-res-time type="double">3600.0</low-res-time><!-- 1 h -->
</buffer>
</replay> </replay>
<airport> <airport>
@ -768,6 +779,11 @@ Started September 2000 by David Megginson, david@megginson.com
<ext-svn-utility type="string">svn</ext-svn-utility> <!-- use absolute path if "svn" <ext-svn-utility type="string">svn</ext-svn-utility> <!-- use absolute path if "svn"
isn't on system PATH (external SVN only)--> isn't on system PATH (external SVN only)-->
</terrasync> </terrasync>
<flight-recorder>
<default-config type="string">/Aircraft/Generic/flightrecorder/generic-piston-propeller-4.xml</default-config>
</flight-recorder>
</sim> </sim>
<!-- mouse mode --> <!-- mouse mode -->
<devices> <devices>