add button to load waypoint file (idea by Philip COBBIN)
This commit is contained in:
parent
a856d86181
commit
31c7d5d748
1 changed files with 55 additions and 15 deletions
|
@ -14,13 +14,6 @@ command interface /autopilot/route-manager/input:
|
||||||
<PropertyList>
|
<PropertyList>
|
||||||
<name>route-manager</name>
|
<name>route-manager</name>
|
||||||
<layout>vbox</layout>
|
<layout>vbox</layout>
|
||||||
<default-padding>4</default-padding>
|
|
||||||
|
|
||||||
<text>
|
|
||||||
<label>Route Manager</label>
|
|
||||||
</text>
|
|
||||||
|
|
||||||
<hrule/>
|
|
||||||
|
|
||||||
<nasal>
|
<nasal>
|
||||||
<open>
|
<open>
|
||||||
|
@ -36,27 +29,31 @@ command interface /autopilot/route-manager/input:
|
||||||
var cmd = props.globals.getNode("/autopilot/route-manager/input", 1);
|
var cmd = props.globals.getNode("/autopilot/route-manager/input", 1);
|
||||||
var route = props.globals.getNode("/autopilot/route-manager/route", 1);
|
var route = props.globals.getNode("/autopilot/route-manager/route", 1);
|
||||||
|
|
||||||
sel_index = func {
|
var sel_index = func {
|
||||||
var s = selection.getValue();
|
var s = selection.getValue();
|
||||||
selection.setValue("");
|
selection.setValue("");
|
||||||
return s == "" ? -1 : split(':', s)[0] - 1;
|
return s == "" ? -1 : split(':', s)[0] - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear = func {
|
var clear = func {
|
||||||
cmd.setValue("@clear");
|
cmd.setValue("@clear");
|
||||||
}
|
}
|
||||||
|
|
||||||
insert = func {
|
var insert = func {
|
||||||
cmd.setValue("@insert" ~ sel_index() ~ ":" ~ input.getValue());
|
cmd.setValue("@insert" ~ sel_index() ~ ":" ~ input.getValue());
|
||||||
input.setValue("");
|
input.setValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
remove = func {
|
var remove = func {
|
||||||
var pos = sel_index();
|
var pos = sel_index();
|
||||||
cmd.setValue("@delete" ~ (pos > 0 ? pos : 0));
|
cmd.setValue("@delete" ~ (pos > 0 ? pos : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
route_changed = func {
|
var load = func {
|
||||||
|
file_selector.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
var route_changed = func {
|
||||||
list.removeChildren("value");
|
list.removeChildren("value");
|
||||||
var wp = route.getChildren("wp");
|
var wp = route.getChildren("wp");
|
||||||
forindex (var i; 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 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>
|
</open>
|
||||||
|
|
||||||
<close>
|
<close>
|
||||||
removelistener(lst);
|
removelistener(lst);
|
||||||
|
dlg.remove();
|
||||||
</close>
|
</close>
|
||||||
</nasal>
|
</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>
|
<group>
|
||||||
<layout>hbox</layout>
|
<layout>hbox</layout>
|
||||||
<default-padding>2</default-padding>
|
<default-padding>2</default-padding>
|
||||||
|
@ -193,11 +233,11 @@ command interface /autopilot/route-manager/input:
|
||||||
<empty><stretch>true</stretch></empty>
|
<empty><stretch>true</stretch></empty>
|
||||||
|
|
||||||
<button>
|
<button>
|
||||||
<legend>Close</legend>
|
<legend>Load List</legend>
|
||||||
<equal>true</equal>
|
<equal>true</equal>
|
||||||
<key>Esc</key>
|
|
||||||
<binding>
|
<binding>
|
||||||
<command>dialog-close</command>
|
<command>nasal</command>
|
||||||
|
<script>load()</script>
|
||||||
</binding>
|
</binding>
|
||||||
</button>
|
</button>
|
||||||
</group>
|
</group>
|
||||||
|
|
Loading…
Add table
Reference in a new issue