1
0
Fork 0

Improve scenario dialog

Support optional name for scenarios.
Add explicit scenario enable/disable switch.
This commit is contained in:
ThorstenB 2012-04-30 19:22:00 +02:00
parent 9c7051d2ce
commit 4b1d51a801
2 changed files with 31 additions and 11 deletions

View file

@ -30,7 +30,7 @@
<empty><stretch>true</stretch></empty> <empty><stretch>true</stretch></empty>
<text> <text>
<label>AI Scenario Select</label> <label>AI Scenario Selection</label>
</text> </text>
<empty><stretch>true</stretch></empty> <empty><stretch>true</stretch></empty>
@ -49,8 +49,24 @@
<hrule/> <hrule/>
<checkbox>
<halign>left</halign>
<label>Enable AI scenarios</label>
<name>enable-ai-scenarios</name>
<property>/sim/ai/scenarios-enabled</property>
<binding>
<command>dialog-apply</command>
<object-name>enable-ai-scenarios</object-name>
</binding>
</checkbox>
<text><label/></text>
<text> <text>
<label>Choose active scenario(s) for the next program start</label> <label>Choose active scenario(s) for the next program start</label>
<enable>
<property>/sim/ai/scenarios-enabled</property>
</enable>
</text> </text>
<hrule/> <hrule/>
@ -120,8 +136,12 @@
var scenarioN = rootN.getNode("scenario"); var scenarioN = rootN.getNode("scenario");
if( scenarioN == nil ) return; if( scenarioN == nil ) return;
var descriptionN = rootN.getNode("description"); var descriptionN = rootN.getNode("description");
if( descriptionN == nil ) var nameN = rootN.getNode("name");
var descriptionN = scenarioN.getNode("description"); if( (descriptionN == nil)and(nameN == nil) )
{
descriptionN = scenarioN.getNode("description");
nameN = scenarioN.getNode("name");
}
var description = descriptionN != nil ? descriptionN.getValue() : ""; var description = descriptionN != nil ? descriptionN.getValue() : "";
var propertyRoot = props.globals.getNode("sim/gui/dialogs/scenario",1).getChild( "scenario", nr, 1 ); var propertyRoot = props.globals.getNode("sim/gui/dialogs/scenario",1).getChild( "scenario", nr, 1 );
propertyRoot.getNode("selected",1).setBoolValue(isEnabledScenario(file)); propertyRoot.getNode("selected",1).setBoolValue(isEnabledScenario(file));
@ -131,8 +151,12 @@
group.getNode("layout",1).setValue("hbox"); group.getNode("layout",1).setValue("hbox");
var cb = group.getNode("checkbox",1); var cb = group.getNode("checkbox",1);
cb.getNode("property",1).setValue(propertyRoot.getNode("selected").getPath()); cb.getNode("property",1).setValue(propertyRoot.getNode("selected").getPath());
cb.getNode("label",1).setValue(file); var label = string.replace(file, "_", " ");
if (nameN != nil)
label = nameN.getValue();
cb.getNode("label",1).setValue(label);
cb.getNode("name",1).setValue(file); cb.getNode("name",1).setValue(file);
cb.getNode("enable/property",1).setValue("/sim/ai/scenarios-enabled");
group.getNode("empty",1).getNode("stretch",1).setValue("true"); group.getNode("empty",1).getNode("stretch",1).setValue("true");
} }

View file

@ -63,7 +63,7 @@ Started September 2000 by David Megginson, david@megginson.com
<season type="string" preserve="y">summer</season> <season type="string" preserve="y">summer</season>
</startup> </startup>
<rendering> <rendering>
<materials-file>Materials/default/materials.xml</materials-file> <materials-file>Materials/default/materials.xml</materials-file>
<rembrandt type="bool">false</rembrandt> <rembrandt type="bool">false</rembrandt>
<show-buffers type="bool" userarchive="y">true</show-buffers> <show-buffers type="bool" userarchive="y">true</show-buffers>
<ambient-occlusion type="bool" userarchive="y">false</ambient-occlusion> <ambient-occlusion type="bool" userarchive="y">false</ambient-occlusion>
@ -748,13 +748,9 @@ Started September 2000 by David Megginson, david@megginson.com
<ai> <ai>
<enabled type="bool">true</enabled> <enabled type="bool">true</enabled>
<scenarios-enabled type="bool" userarchive="y">true</scenarios-enabled>
<scenario>nimitz_demo</scenario> <scenario>nimitz_demo</scenario>
<groundnet-cache type="bool">true</groundnet-cache> <groundnet-cache type="bool">true</groundnet-cache>
<!-- <scenario>balloon_demo</scenario> -->
<!-- <scenario>aircraft_demo</scenario> -->
<!-- <scenario>refueling_demo</scenario> -->
<!-- <scenario>lead_aircraft</scenario> -->
<!-- <scenario>vinson_demo</scenario> -->
</ai> </ai>
<multiplay preserve="y"> <multiplay preserve="y">