1
0
Fork 0

add button to load waypoint file (idea by Philip COBBIN)

This commit is contained in:
mfranz 2008-01-22 19:45:57 +00:00
parent a856d86181
commit 31c7d5d748

View file

@ -14,13 +14,6 @@ command interface /autopilot/route-manager/input:
<PropertyList>
<name>route-manager</name>
<layout>vbox</layout>
<default-padding>4</default-padding>
<text>
<label>Route Manager</label>
</text>
<hrule/>
<nasal>
<open>
@ -36,27 +29,31 @@ command interface /autopilot/route-manager/input:
var cmd = props.globals.getNode("/autopilot/route-manager/input", 1);
var route = props.globals.getNode("/autopilot/route-manager/route", 1);
sel_index = func {
var sel_index = func {
var s = selection.getValue();
selection.setValue("");
return s == "" ? -1 : split(':', s)[0] - 1;
}
clear = func {
var clear = func {
cmd.setValue("@clear");
}
insert = func {
var insert = func {
cmd.setValue("@insert" ~ sel_index() ~ ":" ~ input.getValue());
input.setValue("");
}
remove = func {
var remove = func {
var pos = sel_index();
cmd.setValue("@delete" ~ (pos > 0 ? pos : 0));
}
route_changed = func {
var load = func {
file_selector.open();
}
var route_changed = func {
list.removeChildren("value");
var wp = route.getChildren("wp");
forindex (var i; wp) {
@ -81,13 +78,56 @@ command interface /autopilot/route-manager/input:
}
var lst = setlistener("/autopilot/route-manager/route/num", route_changed, 1);
var load_wp_file = func(path) {
call(func {
var file = io.open(path.getValue(), "r");
while ((var wp = io.readln(file)) != nil) {
string.trim(wp);
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");
</open>
<close>
removelistener(lst);
dlg.remove();
</close>
</nasal>
<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/>
<group>
<layout>hbox</layout>
<default-padding>2</default-padding>
@ -193,11 +233,11 @@ command interface /autopilot/route-manager/input:
<empty><stretch>true</stretch></empty>
<button>
<legend>Close</legend>
<legend>Load List</legend>
<equal>true</equal>
<key>Esc</key>
<binding>
<command>dialog-close</command>
<command>nasal</command>
<script>load()</script>
</binding>
</button>
</group>