2006-05-08 14:15:39 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
command interface /autopilot/route-manager/input:
|
|
|
|
|
|
|
|
@clear ... clear route
|
|
|
|
@pop ... remove first entry
|
|
|
|
@delete3 ... delete 4th entry
|
|
|
|
@insert2:ksfo@900 ... insert "ksfo@900" as 3rd entry
|
|
|
|
ksfo@900 ... append "ksfo@900"
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
<PropertyList>
|
2006-05-10 09:42:27 +00:00
|
|
|
<name>route-manager</name>
|
2006-05-08 14:15:39 +00:00
|
|
|
<layout>vbox</layout>
|
|
|
|
|
|
|
|
<nasal>
|
|
|
|
<open>
|
2006-05-11 14:56:55 +00:00
|
|
|
var ft = getprop("/sim/startup/units") == "feet";
|
2006-05-10 09:42:27 +00:00
|
|
|
var dlg = props.globals.getNode("/sim/gui/dialogs/route-manager", 1);
|
2006-05-08 14:15:39 +00:00
|
|
|
var selection = dlg.getNode("selection", 1);
|
|
|
|
var input = dlg.getNode("input", 1);
|
|
|
|
|
|
|
|
selection.setValue("");
|
|
|
|
input.setValue("");
|
|
|
|
|
|
|
|
var list = cmdarg().getNode("list");
|
|
|
|
var cmd = props.globals.getNode("/autopilot/route-manager/input", 1);
|
2007-03-26 15:25:27 +00:00
|
|
|
var route = props.globals.getNode("/autopilot/route-manager/route", 1);
|
2006-05-08 14:15:39 +00:00
|
|
|
|
2008-01-22 19:45:57 +00:00
|
|
|
var sel_index = func {
|
2006-05-08 14:15:39 +00:00
|
|
|
var s = selection.getValue();
|
|
|
|
selection.setValue("");
|
|
|
|
return s == "" ? -1 : split(':', s)[0] - 1;
|
|
|
|
}
|
|
|
|
|
2008-01-22 19:45:57 +00:00
|
|
|
var clear = func {
|
2006-05-08 14:15:39 +00:00
|
|
|
cmd.setValue("@clear");
|
|
|
|
}
|
|
|
|
|
2008-01-22 19:45:57 +00:00
|
|
|
var insert = func {
|
2006-05-08 14:15:39 +00:00
|
|
|
cmd.setValue("@insert" ~ sel_index() ~ ":" ~ input.getValue());
|
|
|
|
input.setValue("");
|
|
|
|
}
|
|
|
|
|
2008-01-22 19:45:57 +00:00
|
|
|
var remove = func {
|
2006-05-11 14:56:55 +00:00
|
|
|
var pos = sel_index();
|
|
|
|
cmd.setValue("@delete" ~ (pos > 0 ? pos : 0));
|
2006-05-08 14:15:39 +00:00
|
|
|
}
|
|
|
|
|
2008-01-22 19:45:57 +00:00
|
|
|
var load = func {
|
|
|
|
file_selector.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
var route_changed = func {
|
2006-05-08 14:15:39 +00:00
|
|
|
list.removeChildren("value");
|
2007-03-26 15:25:27 +00:00
|
|
|
var wp = route.getChildren("wp");
|
2006-05-08 14:15:39 +00:00
|
|
|
forindex (var i; wp) {
|
|
|
|
var id = wp[i].getNode("id").getValue();
|
|
|
|
var lon = wp[i].getNode("longitude-deg").getValue();
|
|
|
|
var lat = wp[i].getNode("latitude-deg").getValue();
|
2006-05-11 14:56:55 +00:00
|
|
|
var alt = wp[i].getNode("altitude-m").getValue();
|
|
|
|
var entry = sprintf("%d: %-5s %3.4f lon %3.4f lat ",
|
2006-05-09 20:59:07 +00:00
|
|
|
i + 1, id, lon, lat);
|
|
|
|
if (alt > -9990) {
|
2006-05-11 14:56:55 +00:00
|
|
|
if (ft) {
|
|
|
|
entry ~= sprintf("%.0f ft", alt / 0.3048);
|
|
|
|
} else {
|
|
|
|
entry ~= sprintf("%.0f m", alt);
|
|
|
|
}
|
2006-05-09 20:59:07 +00:00
|
|
|
}
|
2006-05-08 14:15:39 +00:00
|
|
|
list.getChild("value", i, 1).setValue(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
fgcommand("dialog-update", props.Node.new({"object-name": "list",
|
2006-05-10 09:42:27 +00:00
|
|
|
"dialog-name": "route-manager"}));
|
2006-05-08 14:15:39 +00:00
|
|
|
}
|
|
|
|
|
2006-05-10 20:24:21 +00:00
|
|
|
var lst = setlistener("/autopilot/route-manager/route/num", route_changed, 1);
|
2008-01-22 19:45:57 +00:00
|
|
|
|
|
|
|
var load_wp_file = func(path) {
|
|
|
|
call(func {
|
|
|
|
var file = io.open(path.getValue(), "r");
|
|
|
|
while ((var wp = io.readln(file)) != nil) {
|
2008-01-22 20:03:00 +00:00
|
|
|
wp = string.trim(wp);
|
2008-01-22 19:45:57 +00:00
|
|
|
if (wp != "")
|
|
|
|
setprop("/autopilot/route-manager/input", wp);
|
|
|
|
}
|
|
|
|
io.close(file);
|
|
|
|
}, [], var err = []);
|
|
|
|
if (size(err))
|
|
|
|
gui.popupTip("can't open file " ~ path.getValue(), 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
var file_selector = gui.FileSelector.new(load_wp_file, "Select waypoint list", "Load File");
|
2006-05-08 14:15:39 +00:00
|
|
|
</open>
|
|
|
|
|
|
|
|
<close>
|
|
|
|
removelistener(lst);
|
2008-01-22 20:01:08 +00:00
|
|
|
file_selector.data.remove();
|
2006-05-08 14:15:39 +00:00
|
|
|
</close>
|
|
|
|
</nasal>
|
|
|
|
|
2008-01-22 19:45:57 +00:00
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<empty><stretch>1</stretch></empty>
|
|
|
|
|
|
|
|
<text>
|
|
|
|
<label>Route Manager</label>
|
|
|
|
</text>
|
|
|
|
|
|
|
|
<empty><stretch>1</stretch></empty>
|
|
|
|
|
|
|
|
<button>
|
|
|
|
<pref-width>16</pref-width>
|
|
|
|
<pref-height>16</pref-height>
|
|
|
|
<legend></legend>
|
|
|
|
<default>1</default>
|
|
|
|
<keynum>27</keynum>
|
|
|
|
<border>2</border>
|
|
|
|
|
|
|
|
<binding>
|
|
|
|
<command>dialog-close</command>
|
|
|
|
</binding>
|
|
|
|
</button>
|
|
|
|
</group>
|
|
|
|
|
|
|
|
<hrule/>
|
|
|
|
|
2006-05-08 14:15:39 +00:00
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<default-padding>2</default-padding>
|
|
|
|
|
|
|
|
<text>
|
|
|
|
<label>MMMMMMMMMMMMMMMM</label>
|
|
|
|
<format>Target: %s</format>
|
|
|
|
<property>/autopilot/route-manager/wp[0]/id</property>
|
|
|
|
<live>true</live>
|
|
|
|
</text>
|
|
|
|
|
|
|
|
<text>
|
|
|
|
<label>MMMMMMMMM</label>
|
|
|
|
<format>Dist: %.2f nm</format>
|
|
|
|
<property>/autopilot/route-manager/wp[0]/dist</property>
|
|
|
|
<live>true</live>
|
|
|
|
</text>
|
|
|
|
|
|
|
|
<text>
|
|
|
|
<label>MMMMMMMMM</label>
|
|
|
|
<format>ETA: %s</format>
|
|
|
|
<property>/autopilot/route-manager/wp[0]/eta</property>
|
|
|
|
<live>true</live>
|
|
|
|
</text>
|
|
|
|
</group>
|
|
|
|
|
|
|
|
<list>
|
|
|
|
<name>list</name>
|
|
|
|
<halign>fill</halign>
|
|
|
|
<pref-height>150</pref-height>
|
2006-05-10 09:42:27 +00:00
|
|
|
<property>/sim/gui/dialogs/route-manager/selection</property>
|
2006-05-08 14:15:39 +00:00
|
|
|
<binding>
|
|
|
|
<command>dialog-apply</command>
|
|
|
|
<object-name>list</object-name>
|
|
|
|
</binding>
|
|
|
|
</list>
|
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<default-padding>4</default-padding>
|
|
|
|
|
|
|
|
<text>
|
|
|
|
<label>Waypoint:</label>
|
|
|
|
<pref-width>60</pref-width>
|
|
|
|
</text>
|
|
|
|
|
|
|
|
<input>
|
|
|
|
<name>input</name>
|
|
|
|
<pref-width>220</pref-width>
|
2006-05-10 09:42:27 +00:00
|
|
|
<property>/sim/gui/dialogs/route-manager/input</property>
|
2006-05-08 14:15:39 +00:00
|
|
|
</input>
|
|
|
|
|
|
|
|
<button>
|
|
|
|
<legend>Add</legend>
|
|
|
|
<default>true</default>
|
|
|
|
<pref-width>70</pref-width>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-apply</command>
|
|
|
|
</binding>
|
|
|
|
<binding>
|
|
|
|
<command>nasal</command>
|
|
|
|
<script>insert()</script>
|
|
|
|
</binding>
|
|
|
|
<binding>
|
|
|
|
<command>dialog-update</command>
|
|
|
|
</binding>
|
|
|
|
</button>
|
|
|
|
</group>
|
|
|
|
|
|
|
|
<text>
|
|
|
|
<padding>1</padding>
|
2006-05-10 09:42:27 +00:00
|
|
|
<label>Format: (airport|fix|nav|lon,lat)[@alt] -- e.g. "KSFO@900"</label>
|
2006-05-08 14:15:39 +00:00
|
|
|
<color>
|
|
|
|
<red>0.5</red>
|
|
|
|
<green>0.5</green>
|
|
|
|
<blue>0.5</blue>
|
|
|
|
</color>
|
|
|
|
</text>
|
|
|
|
|
|
|
|
<group>
|
|
|
|
<layout>hbox</layout>
|
|
|
|
<halign>fill</halign>
|
|
|
|
<default-padding>6</default-padding>
|
|
|
|
|
|
|
|
<button>
|
|
|
|
<legend>Clear List</legend>
|
|
|
|
<equal>true</equal>
|
|
|
|
<binding>
|
|
|
|
<command>nasal</command>
|
|
|
|
<script>clear()</script>
|
|
|
|
</binding>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button>
|
|
|
|
<legend>Remove</legend>
|
|
|
|
<equal>true</equal>
|
|
|
|
<binding>
|
|
|
|
<command>nasal</command>
|
|
|
|
<script>remove()</script>
|
|
|
|
</binding>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<empty><stretch>true</stretch></empty>
|
|
|
|
|
|
|
|
<button>
|
2008-01-22 19:45:57 +00:00
|
|
|
<legend>Load List</legend>
|
2006-05-08 14:15:39 +00:00
|
|
|
<equal>true</equal>
|
|
|
|
<binding>
|
2008-01-22 19:45:57 +00:00
|
|
|
<command>nasal</command>
|
|
|
|
<script>load()</script>
|
2006-05-08 14:15:39 +00:00
|
|
|
</binding>
|
|
|
|
</button>
|
|
|
|
</group>
|
|
|
|
</PropertyList>
|