Skip to content

Commit

Permalink
Gui: Airbase dialog can now search for icao. But not name.
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaiVChr committed Sep 24, 2023
1 parent 36da466 commit 11eafa8
Showing 1 changed file with 67 additions and 13 deletions.
80 changes: 67 additions & 13 deletions gui/dialogs/airbases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<nasal>
<!-- Generalize all this, turn into helpers and load defaults via XML -->
<open><![CDATA[
setprop("/sim/gui/dialogs/airports/show-helipads", 0);
var update_info = func(open = 0) {
var info = airportinfo(airport_id);
if (!contains(airbases.db, info.id)) return;
Expand Down Expand Up @@ -255,6 +256,25 @@
}
canvas.register_callback(update_info); # FIXME: this is a workaround to run dialog-specific code in the canvas block
var res = props.globals.getNode("/sim/gui/dialogs/airports/search-result",1);
setprop("/sim/gui/dialogs/airports/list-me", "");
append(listeners, setlistener("/sim/gui/dialogs/airports/list-me", func{
res.removeChildren("value");
var searcher = getprop("/sim/gui/dialogs/airports/list-me");
if (searcher != nil and searcher != "") {
var listMil = findAirportsByICAO(searcher);
val = 0;
foreach (var base ; listMil) {
if (!contains(airbases.db, base.id)) continue;
var icao = base.id;
var name = base.name;
var present = name~" ("~icao~")";
setprop("/sim/gui/dialogs/airports/search-result/value["~val~"]", present);
val += 1;
}
}
}));
]]>
</open>
<close><![CDATA[
Expand Down Expand Up @@ -284,20 +304,20 @@
<default-padding>4</default-padding>

<text>
<label>Airport:</label>
<label>ICAO:</label>
</text>

<!--input>
<input>
<name>input</name>
<pref-width>120</pref-width>
<halign>fill</halign>
<stretch>true</stretch>
<property>/sim/gui/dialogs/airports/list</property>
<property>/sim/gui/dialogs/airports/search-me</property>
<binding>
<command>dialog-apply</command>
<object-name>input</object-name>
</binding>
</input-->
</input>

<!--
Expand All @@ -323,7 +343,7 @@
</binding>
</button>
-->
<!--button>
<button>
<legend>Search</legend>
<default>true</default>
<binding>
Expand All @@ -340,7 +360,7 @@
<script>
var apt_type = "airport:";
var heli_type = "heliport:";
var search_term = getprop("/sim/gui/dialogs/airports/list");
var search_term = getprop("/sim/gui/dialogs/airports/search-me");

# strip off airport type prefix
if (string.match(search_term,heli_type)) {
Expand All @@ -358,14 +378,14 @@
else {
new_value = apt_type ~ search_term;
}
setprop("/sim/gui/dialogs/airports/list", new_value);
setprop("/sim/gui/dialogs/airports/list-me", search_term);
</script>
</binding>
<binding>
<command>dialog-update</command>
<object-name>airport-list</object-name>
</binding>
</button-->
</button>

<button>
<legend>&lt;100nm</legend>
Expand Down Expand Up @@ -433,15 +453,48 @@
</binding>
</button>

<checkbox>
<!--button>
<legend>&lt;300nm</legend>
<binding>
<command>property-assign</command>
<property>/sim/gui/dialogs/airports/mode</property>
<value>100nm</value>
</binding>
<binding>
<command>nasal</command>
<script>
# change airport type to heliport if checkbox is set
var apt_type = "airport";
if (getprop("/sim/gui/dialogs/airports/show-helipads")) {
apt_type = "heliport";
}
var airports = findAirportsWithinRange(300,apt_type);
var list = dlg.getNode("close-airports", 1);
list.removeChildren("value");
forindex (var idx; airports) {
if (!contains(airbases.db, airports[idx].id)) continue;
list.getNode("value["~ idx ~ "]", 1).setValue(airports[idx].name ~ " (" ~ airports[idx].id ~ ")");
}
</script>
</binding>
<binding>
<command>dialog-update</command>
<object-name>close-airport-list</object-name>
</binding>
</button-->

<!--checkbox>
<name>show-helipads</name>
<label>Helipads</label>
<property>/sim/gui/dialogs/airports/show-helipads</property>
<binding>
<command>dialog-apply</command>
<object-name>show-helipads</object-name>
</binding>
</checkbox>
</checkbox-->

</group>

Expand Down Expand Up @@ -475,7 +528,7 @@
</binding>
</list>

<airport-list>
<list>
<row>0</row><col>0</col>
<visible>
<equals>
Expand All @@ -489,7 +542,8 @@
<halign>fill</halign>
<valign>fill</valign>
<stretch>true</stretch>
<property>/sim/gui/dialogs/airports/list</property>
<property>/sim/gui/dialogs/airports/search-me</property>
<properties>/sim/gui/dialogs/airports/search-result</properties>
<binding>
<command>dialog-apply</command>
<object-name>airport-list</object-name>
Expand All @@ -498,7 +552,7 @@
<command>nasal</command>
<script>listbox()</script>
</binding>
</airport-list>
</list>

</group>

Expand Down

0 comments on commit 11eafa8

Please sign in to comment.