flightgear-addon-missions/GUI/mission_browser.xml

153 lines
3.6 KiB
XML
Raw Permalink Normal View History

<?xml version="1.0"?>
<PropertyList>
<name>mission-browser</name>
<layout>vbox</layout>
<group>
<layout>hbox</layout>
<empty><stretch>1</stretch></empty>
<text>
<label>Mission browser</label>
</text>
<empty><stretch>1</stretch></empty>
<button>
<legend> </legend>
<halign>right</halign>
<pref-width>20</pref-width>
<pref-height>20</pref-height>
<binding>
<command>dialog-close</command>
</binding>
</button>
</group>
<hrule/>
<group>
<layout>hbox</layout>
<list>
<name>mission_list</name>
<pref-width>300</pref-width>
<pref-height>250</pref-height>
<halign>fill</halign>
<valign>fill</valign>
<stretch>true</stretch>
<padding>6</padding>
<property>/sim/mission/gui/selected-mission</property>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>
select_mission();
</script>
</binding>
<value>...</value>
<value>...</value>
</list>
<group>
<layout>vbox</layout>
<canvas>
<name>mission-image</name>
<valign>fill</valign>
<halign>fill</halign>
<pref-width>250</pref-width>
<pref-height>250</pref-height>
<nasal>
<load> <![CDATA[
var myCanvas1 = canvas.get( cmdarg() );
myCanvas1.setColorBackground(1,1,1,0);
var img = myCanvas1.createGroup().createChild("image");
]]> </load>
</nasal>
</canvas>
</group>
</group>
<textbox>
<name>mission_description</name>
<halign>fill</halign>
<valign>fill</valign>
<stretch>true</stretch>
<pref-width>600</pref-width>
<pref-height>200</pref-height>
<padding>6</padding>
<slider>20</slider>
<editable>false</editable>
<wrap>false</wrap>
<property>/sim/mission/gui/data/description</property>
</textbox>
<hrule/>
<button>
<legend>Start mission</legend>
<pref-height>30</pref-height>
<binding>
<command>nasal</command>
<script>
fgcommand("dialog-close", {"dialog-name" : "mission-browser"});
mission.start_mission(selected_mission);
</script>
</binding>
</button>
<nasal>
<open> <![CDATA[
var list = cmdarg().getNode("group[1]/list");
var mission_root = "";
var selected_mission = "";
var data_node = props.getNode("sim/mission/gui/data", 1);
data_node.setValues({description: ""});
var dialog_update = func () {
forindex (var i; arg) {
var hash = {
"object-name" : arg[i],
"dialog-name" : "mission-browser"
};
fgcommand( "dialog-update", props.Node.new(hash) );
}
}
var update_list = func {
list.removeChildren("value");
var mission_path = getprop("/sim/mission/root_path") ~ "/Missions";
foreach (var a; directory(mission_path)) {
if (a != "." and a != ".." and a != "Generic") {
foreach (var b; directory(mission_path ~ "/" ~ a)) {
if (b != "." and b != "..") {
list.addChild("value").setValue(a ~ "/" ~ b);
}
}
}
}
dialog_update("mission_list");
}
var select_mission = func {
selected_mission = getprop("/sim/mission/gui/selected-mission");
mission_root = getprop("/sim/mission/root_path") ~ "/Missions/" ~ selected_mission;
data_node.setValues({description: ""});
io.read_properties(mission_root ~ "/metadata.xml", data_node);
dialog_update("mission_description");
img.set("src", mission_root ~ "/image.png").setSize(250, 250);
}
update_list();
]]> </open>
<close>
#
</close>
</nasal>
</PropertyList>