diff --git a/gui/dialogs/route-manager.xml b/gui/dialogs/route-manager.xml index e236abfaf..1a18fccb8 100644 --- a/gui/dialogs/route-manager.xml +++ b/gui/dialogs/route-manager.xml @@ -14,13 +14,6 @@ command interface /autopilot/route-manager/input: route-manager vbox - 4 - - - - - - @@ -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"); removelistener(lst); + dlg.remove(); + + hbox + 1 + + + + + + 1 + + + + + + hbox 2 @@ -193,11 +233,11 @@ command interface /autopilot/route-manager/input: true