Switch the route-manager dialog over to use the waypoint-list widget, and update other functionality to match.
This commit is contained in:
parent
38832daf77
commit
b38d470782
1 changed files with 59 additions and 43 deletions
|
@ -22,10 +22,9 @@ command interface /autopilot/route-manager/input:
|
||||||
var dlg = props.globals.getNode("/sim/gui/dialogs/route-manager", 1);
|
var dlg = props.globals.getNode("/sim/gui/dialogs/route-manager", 1);
|
||||||
var selection = dlg.getNode("selection", 1);
|
var selection = dlg.getNode("selection", 1);
|
||||||
var input = dlg.getNode("input", 1);
|
var input = dlg.getNode("input", 1);
|
||||||
|
|
||||||
var routem = props.globals.getNode("/autopilot/route-manager", 1);
|
var routem = props.globals.getNode("/autopilot/route-manager", 1);
|
||||||
|
|
||||||
selection.setValue("");
|
selection.setIntValue(-1);
|
||||||
input.setValue("");
|
input.setValue("");
|
||||||
|
|
||||||
var list = cmdarg().getNode("list");
|
var list = cmdarg().getNode("list");
|
||||||
|
@ -33,9 +32,7 @@ command interface /autopilot/route-manager/input:
|
||||||
var route = routem.getNode("route", 1);
|
var route = routem.getNode("route", 1);
|
||||||
|
|
||||||
var sel_index = func {
|
var sel_index = func {
|
||||||
var s = selection.getValue();
|
return int(selection.getValue());
|
||||||
selection.setValue("");
|
|
||||||
return s == "" ? -1 : split(':', s)[0] - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var clear = func {
|
var clear = func {
|
||||||
|
@ -43,45 +40,37 @@ command interface /autopilot/route-manager/input:
|
||||||
}
|
}
|
||||||
|
|
||||||
var insert = func {
|
var insert = func {
|
||||||
cmd.setValue("@insert" ~ sel_index() ~ ":" ~ input.getValue());
|
var insertIndex = sel_index();
|
||||||
|
if (insertIndex >= 0) {
|
||||||
|
# when selection index is valid, insert *after* the waypoint
|
||||||
|
insertIndex = insertIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.setValue("@insert" ~ insertIndex ~ ":" ~ input.getValue());
|
||||||
input.setValue("");
|
input.setValue("");
|
||||||
|
|
||||||
|
if (insertIndex >= 0) {
|
||||||
|
selection.setValue(insertIndex);
|
||||||
|
gui.dialog_update("route-manager");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var remove = func {
|
var remove = func {
|
||||||
var pos = sel_index();
|
cmd.setValue("@delete" ~ sel_index());
|
||||||
cmd.setValue("@delete" ~ (pos > 0 ? pos : 0));
|
}
|
||||||
|
|
||||||
|
var auto_route = func {
|
||||||
|
cmd.setValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
var jump_to = func {
|
||||||
|
cmd.setValue("@jump" ~ sel_index());
|
||||||
}
|
}
|
||||||
|
|
||||||
var load = func {
|
var load = func {
|
||||||
file_selector.open();
|
file_selector.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
var route_changed = func {
|
|
||||||
list.removeChildren("value");
|
|
||||||
var wp = route.getChildren("wp");
|
|
||||||
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();
|
|
||||||
var alt = wp[i].getNode("altitude-m").getValue();
|
|
||||||
var entry = sprintf("%d: %-5s %3.4f lon %3.4f lat ",
|
|
||||||
i + 1, id, lon, lat);
|
|
||||||
if (alt > -9990) {
|
|
||||||
if (ft) {
|
|
||||||
entry ~= sprintf("%.0f ft", alt / 0.3048);
|
|
||||||
} else {
|
|
||||||
entry ~= sprintf("%.0f m", alt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list.getChild("value", i, 1).setValue(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
fgcommand("dialog-update", props.Node.new({"object-name": "list",
|
|
||||||
"dialog-name": "route-manager"}));
|
|
||||||
}
|
|
||||||
|
|
||||||
var lst = setlistener("/autopilot/route-manager/route/num", route_changed, 1);
|
|
||||||
|
|
||||||
var load_route = func(path) {
|
var load_route = func(path) {
|
||||||
routem.getNode("file-path", 1).setValue(path.getValue());
|
routem.getNode("file-path", 1).setValue(path.getValue());
|
||||||
cmd.setValue("@load");
|
cmd.setValue("@load");
|
||||||
|
@ -131,7 +120,6 @@ command interface /autopilot/route-manager/input:
|
||||||
</open>
|
</open>
|
||||||
|
|
||||||
<close>
|
<close>
|
||||||
removelistener(lst);
|
|
||||||
file_selector.del();
|
file_selector.del();
|
||||||
</close>
|
</close>
|
||||||
</nasal>
|
</nasal>
|
||||||
|
@ -234,7 +222,7 @@ command interface /autopilot/route-manager/input:
|
||||||
<properties>/sim/gui/dialogs/route-manager/destination-runways</properties>
|
<properties>/sim/gui/dialogs/route-manager/destination-runways</properties>
|
||||||
</combo>
|
</combo>
|
||||||
</group>
|
</group>
|
||||||
|
<!--
|
||||||
<group>
|
<group>
|
||||||
<layout>hbox</layout>
|
<layout>hbox</layout>
|
||||||
<text>
|
<text>
|
||||||
|
@ -250,7 +238,7 @@ command interface /autopilot/route-manager/input:
|
||||||
</input>
|
</input>
|
||||||
|
|
||||||
</group>
|
</group>
|
||||||
|
-->
|
||||||
<group>
|
<group>
|
||||||
<layout>hbox</layout>
|
<layout>hbox</layout>
|
||||||
<text>
|
<text>
|
||||||
|
@ -306,7 +294,7 @@ command interface /autopilot/route-manager/input:
|
||||||
</text>
|
</text>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<list>
|
<waypointlist>
|
||||||
<name>list</name>
|
<name>list</name>
|
||||||
<halign>fill</halign>
|
<halign>fill</halign>
|
||||||
<valign>fill</valign>
|
<valign>fill</valign>
|
||||||
|
@ -317,7 +305,7 @@ command interface /autopilot/route-manager/input:
|
||||||
<command>dialog-apply</command>
|
<command>dialog-apply</command>
|
||||||
<object-name>list</object-name>
|
<object-name>list</object-name>
|
||||||
</binding>
|
</binding>
|
||||||
</list>
|
</waypointlist>
|
||||||
|
|
||||||
<group>
|
<group>
|
||||||
<layout>hbox</layout>
|
<layout>hbox</layout>
|
||||||
|
@ -379,12 +367,40 @@ command interface /autopilot/route-manager/input:
|
||||||
|
|
||||||
<button>
|
<button>
|
||||||
<legend>Remove</legend>
|
<legend>Remove</legend>
|
||||||
<equal>true</equal>
|
<enable>
|
||||||
|
<greater-than>
|
||||||
|
<property>/sim/gui/dialogs/route-manager/selection</property>
|
||||||
|
<value>-1</value>
|
||||||
|
</greater-than>
|
||||||
|
</enable>
|
||||||
<binding>
|
<binding>
|
||||||
<command>nasal</command>
|
<command>nasal</command>
|
||||||
<script>remove()</script>
|
<script>remove()</script>
|
||||||
</binding>
|
</binding>
|
||||||
</button>
|
</button>
|
||||||
|
<!--
|
||||||
|
<button>
|
||||||
|
<legend>Auto-route</legend>
|
||||||
|
<equal>true</equal>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>auto_route()</script>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
-->
|
||||||
|
<button>
|
||||||
|
<legend>Jump To</legend>
|
||||||
|
<enable>
|
||||||
|
<greater-than>
|
||||||
|
<property>/sim/gui/dialogs/route-manager/selection</property>
|
||||||
|
<value>-1</value>
|
||||||
|
</greater-than>
|
||||||
|
</enable>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>jump_to()</script>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
|
||||||
<button>
|
<button>
|
||||||
<legend>Activate</legend>
|
<legend>Activate</legend>
|
||||||
|
|
Loading…
Add table
Reference in a new issue