Merge branch 'master' of D:\Git_New\fgdata
This commit is contained in:
commit
ade5dce37a
5 changed files with 648 additions and 384 deletions
|
@ -324,6 +324,7 @@ var Element = {
|
|||
# Class for a group element on a canvas
|
||||
#
|
||||
var Group = {
|
||||
# public:
|
||||
new: func(node, id)
|
||||
{
|
||||
return { parents: [Group, Element.new(node, id)] };
|
||||
|
@ -342,6 +343,17 @@ var Group = {
|
|||
|
||||
return factory([me._node, type], id);
|
||||
},
|
||||
# Get a vector of all child elements
|
||||
getChildren: func()
|
||||
{
|
||||
var children = [];
|
||||
|
||||
foreach(var c; me._node.getChildren())
|
||||
if( me._isElementNode(c) )
|
||||
append(children, me._wrapElement(c));
|
||||
|
||||
return children;
|
||||
},
|
||||
# Get first child with given id (breadth-first search)
|
||||
#
|
||||
# @note Use with care as it can take several miliseconds (for me eg. ~2ms).
|
||||
|
@ -361,15 +373,11 @@ var Group = {
|
|||
{
|
||||
var node_id = node.getNode("id");
|
||||
if( node_id != nil and node_id.getValue() == id )
|
||||
# Create element from existing node
|
||||
return me._element_factories[ node.getName() ](node, nil);
|
||||
return me._wrapElement(node);
|
||||
}
|
||||
|
||||
foreach(var c; node.getChildren())
|
||||
# element nodes have type NONE and valid element names (those in the the
|
||||
# factor list)
|
||||
if( c.getType() == "NONE"
|
||||
and me._element_factories[ c.getName() ] != nil )
|
||||
if( me._isElementNode(c) )
|
||||
append(stack, c);
|
||||
}
|
||||
},
|
||||
|
@ -379,6 +387,19 @@ var Group = {
|
|||
foreach(var type; keys(me._element_factories))
|
||||
me._node.removeChildren(type, 0);
|
||||
return me;
|
||||
},
|
||||
# private:
|
||||
_isElementNode: func(el)
|
||||
{
|
||||
# element nodes have type NONE and valid element names (those in the factory
|
||||
# list)
|
||||
return el.getType() == "NONE"
|
||||
and me._element_factories[ el.getName() ] != nil;
|
||||
},
|
||||
_wrapElement: func(node)
|
||||
{
|
||||
# Create element from existing node
|
||||
return me._element_factories[ node.getName() ](node, nil);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -27,9 +27,8 @@
|
|||
|
||||
<!-- Location menu -->
|
||||
<location>Location</location>
|
||||
<position-on-ground>Position Aircraft On Ground</position-on-ground>
|
||||
<position-in-air>Position Aircraft In Air</position-in-air>
|
||||
<goto-airport>Select Airport From List</goto-airport>
|
||||
<goto-airport>Select Airport</goto-airport>
|
||||
<random-attitude>Random Attitude</random-attitude>
|
||||
<tower-position>Tower Position</tower-position>
|
||||
|
||||
|
|
|
@ -31,20 +31,90 @@
|
|||
|
||||
<nasal>
|
||||
<open>
|
||||
var id = "";
|
||||
var node = props.globals.getNode("/sim/gui/dialogs/airports", 1);
|
||||
if (node.getNode("list") == nil)
|
||||
node.getNode("list", 1).setValue("");
|
||||
var airport_id = getprop("/sim/presets/airport-id");
|
||||
setprop("/sim/gui/dialogs/airports/selected-airport/rwy", "");
|
||||
setprop("/sim/gui/dialogs/airports/selected-airport/parkpos", "");
|
||||
|
||||
node = node.getNode("list");
|
||||
if (airport_id == nil) { airport_id = "KSFO"; }
|
||||
|
||||
var dlg = props.globals.getNode("/sim/gui/dialogs/airports", 1);
|
||||
var avail_runways = dlg.getNode("available-runways", 1);
|
||||
var avail_parking = dlg.getNode("available-parking", 1);
|
||||
|
||||
if (dlg.getNode("list") == nil)
|
||||
dlg.getNode("list", 1).setValue("");
|
||||
|
||||
var airportlist = dlg.getNode("list");
|
||||
|
||||
var mode = {
|
||||
runway: dlg.getNode("use_runway", 1),
|
||||
bestrunway: dlg.getNode("use_best_runway", 1),
|
||||
parkpos: dlg.getNode("use_parkpos", 1)
|
||||
};
|
||||
|
||||
var set_radio = func(m) {
|
||||
foreach (k; keys(mode)) {
|
||||
mode[k].setBoolValue(m == k);
|
||||
}
|
||||
}
|
||||
|
||||
var initialized = 0;
|
||||
foreach (k; keys(mode)) {
|
||||
if (mode[k].getType() == "NONE" or initialized) {
|
||||
mode[k].setBoolValue(0);
|
||||
} else {
|
||||
initialized += mode[k].getBoolValue();
|
||||
}
|
||||
}
|
||||
if (!initialized) {
|
||||
set_radio("bestrunway");
|
||||
}
|
||||
|
||||
var update_info = func {
|
||||
var info = airportinfo(airport_id);
|
||||
setprop("/sim/gui/dialogs/airports/selected-airport/id", airport_id);
|
||||
setprop("/sim/gui/dialogs/airports/selected-airport/name", info.name ~ " (" ~ airport_id ~ ")");
|
||||
setprop("/sim/gui/dialogs/airports/selected-airport/location", sprintf("%.3f / %.3f", info.lon, info.lat));
|
||||
setprop("/sim/gui/dialogs/airports/selected-airport/lon", info.lon);
|
||||
setprop("/sim/gui/dialogs/airports/selected-airport/elevation-ft", 3.28 * info.elevation);
|
||||
|
||||
var longest_runway = 0;
|
||||
var runway_string = "";
|
||||
var runways = info.runways;
|
||||
|
||||
avail_runways.removeChildren("value");
|
||||
avail_parking.removeChildren("value");
|
||||
var runway_keys = sort(keys(runways), string.icmp);
|
||||
var i = 0;
|
||||
|
||||
foreach(var rwy; runway_keys) {
|
||||
runway_string = runway_string ~ rwy ~ " ";
|
||||
longest_runway = math.max(longest_runway, runways[rwy].length * 3.28);
|
||||
avail_runways.getNode("value[" ~ i ~ "]", 1).setValue(rwy);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
foreach (var park; info.parking()) {
|
||||
avail_parking.getNode("value[" ~ i ~ "]", 1).setValue(park.name);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
setprop("/sim/gui/dialogs/airports/selected-airport/longest-runway", longest_runway);
|
||||
|
||||
gui.dialog_update("airports", "runway-list");
|
||||
gui.dialog_update("airports", "parking-list");
|
||||
}
|
||||
|
||||
var listbox = func {
|
||||
id = pop(split(" ", node.getValue()));
|
||||
id = substr(id, 1, size(id) - 2); # strip parentheses
|
||||
airport_id = pop(split(" ", airportlist.getValue()));
|
||||
airport_id = substr(airport_id, 1, size(airport_id) - 2); # strip parentheses
|
||||
|
||||
update_info();
|
||||
}
|
||||
|
||||
var apply = func {
|
||||
setprop("/sim/presets/airport-id", id);
|
||||
setprop("/sim/presets/airport-id", airport_id);
|
||||
setprop("/sim/presets/longitude-deg", -9999);
|
||||
setprop("/sim/presets/latitude-deg", -9999);
|
||||
setprop("/sim/presets/altitude-ft", -9999);
|
||||
|
@ -53,29 +123,28 @@
|
|||
setprop("/sim/presets/offset-azimuth-deg", 0);
|
||||
setprop("/sim/presets/glideslope-deg", 0);
|
||||
setprop("/sim/presets/heading-deg", 0);
|
||||
|
||||
if (mode["bestrunway"].getBoolValue()) {
|
||||
setprop("/sim/presets/runway", "");
|
||||
setprop("/sim/presets/parkpos", "");
|
||||
} else if (mode["runway"].getBoolValue()) {
|
||||
setprop("/sim/presets/runway", getprop("/sim/gui/dialogs/airports/selected-airport/rwy"));
|
||||
setprop("/sim/presets/parkpos", "");
|
||||
} else {
|
||||
setprop("/sim/presets/runway", "");
|
||||
setprop("/sim/presets/parkpos", getprop("/sim/gui/dialogs/airports/selected-airport/parkpos"));
|
||||
}
|
||||
|
||||
}
|
||||
</open>
|
||||
</nasal>
|
||||
|
||||
<airport-list>
|
||||
<name>airport-list</name>
|
||||
<pref-width>440</pref-width>
|
||||
<pref-height>360</pref-height>
|
||||
<halign>fill</halign>
|
||||
<valign>fill</valign>
|
||||
<stretch>true</stretch>
|
||||
<property>/sim/gui/dialogs/airports/list</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>airport-list</object-name>
|
||||
</binding>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>listbox()</script>
|
||||
</binding>
|
||||
</airport-list>
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<default-padding>4</default-padding>
|
||||
|
||||
<group>
|
||||
<layout>vbox</layout>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
|
@ -83,12 +152,11 @@
|
|||
|
||||
<text>
|
||||
<label>Airport:</label>
|
||||
<pref-width>60</pref-width>
|
||||
</text>
|
||||
|
||||
<input>
|
||||
<name>input</name>
|
||||
<pref-width>280</pref-width>
|
||||
<pref-width>200</pref-width>
|
||||
<halign>fill</halign>
|
||||
<stretch>true</stretch>
|
||||
<property>/sim/gui/dialogs/airports/list</property>
|
||||
|
@ -102,8 +170,26 @@
|
|||
</binding>
|
||||
</input>
|
||||
|
||||
<button>
|
||||
<legend>Clear</legend>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/sim/gui/dialogs/airports/list</property>
|
||||
<value></value>
|
||||
</binding>
|
||||
<binding>
|
||||
<command>dialog-update</command>
|
||||
<object-name>input</object-name>
|
||||
</binding>
|
||||
<binding>
|
||||
<command>dialog-update</command>
|
||||
<object-name>airport-list</object-name>
|
||||
</binding>
|
||||
</button>
|
||||
|
||||
<button>
|
||||
<legend>Search</legend>
|
||||
<default>true</default>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>input</object-name>
|
||||
|
@ -113,6 +199,472 @@
|
|||
<object-name>airport-list</object-name>
|
||||
</binding>
|
||||
</button>
|
||||
|
||||
</group>
|
||||
|
||||
<airport-list>
|
||||
<name>airport-list</name>
|
||||
<pref-width>300</pref-width>
|
||||
<pref-height>260</pref-height>
|
||||
<halign>fill</halign>
|
||||
<valign>fill</valign>
|
||||
<stretch>true</stretch>
|
||||
<property>/sim/gui/dialogs/airports/list</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>airport-list</object-name>
|
||||
</binding>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>listbox()</script>
|
||||
</binding>
|
||||
</airport-list>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
<layout>table</layout>
|
||||
|
||||
<text>
|
||||
<row>0</row>
|
||||
<col>0</col>
|
||||
<width>200</width>
|
||||
<halign>right</halign>
|
||||
<label>Airport:</label>
|
||||
</text>
|
||||
<text>
|
||||
<row>0</row>
|
||||
<col>1</col>
|
||||
<colspan>3</colspan>
|
||||
<halign>left</halign>
|
||||
<live>true</live>
|
||||
<property>/sim/gui/dialogs/airports/selected-airport/name</property>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>0</col>
|
||||
<halign>right</halign>
|
||||
<label>Lon/Lat:</label>
|
||||
</text>
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>1</col>
|
||||
<halign>left</halign>
|
||||
<live>true</live>
|
||||
<property>/sim/gui/dialogs/airports/selected-airport/location</property>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>3</col>
|
||||
<halign>right</halign>
|
||||
<label>Elevation (ft):</label>
|
||||
</text>
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>4</col>
|
||||
<halign>left</halign>
|
||||
<live>true</live>
|
||||
<format>%.0f</format>
|
||||
<property>/sim/gui/dialogs/airports/selected-airport/elevation-ft</property>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<row>2</row>
|
||||
<col>0</col>
|
||||
<halign>right</halign>
|
||||
<label>Longest runway (ft):</label>
|
||||
</text>
|
||||
<text>
|
||||
<row>2</row>
|
||||
<col>1</col>
|
||||
<halign>left</halign>
|
||||
<live>true</live>
|
||||
<format>%.0f</format>
|
||||
<property>/sim/gui/dialogs/airports/selected-airport/longest-runway</property>
|
||||
</text>
|
||||
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
<layout>table</layout>
|
||||
<halign>center</halign>
|
||||
|
||||
<radio>
|
||||
<row>2</row><col>0</col>
|
||||
<property>/sim/gui/dialogs/airports/use_best_runway</property>
|
||||
<live>true</live>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>set_radio("bestrunway")</script>
|
||||
</binding>
|
||||
</radio>
|
||||
|
||||
<text>
|
||||
<row>2</row><col>1</col>
|
||||
<halign>right</halign>
|
||||
<label>Best runway</label>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/airports/use_best_runway</property>
|
||||
</enable>
|
||||
</text>
|
||||
<text>
|
||||
<row>2</row><col>2</col>
|
||||
<halign>right</halign>
|
||||
<label>(based on wind)</label>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/airports/use_best_runway</property>
|
||||
</enable>
|
||||
</text>
|
||||
|
||||
<radio>
|
||||
<row>3</row><col>0</col>
|
||||
<property>/sim/gui/dialogs/airports/use_runway</property>
|
||||
<live>true</live>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>set_radio("runway")</script>
|
||||
</binding>
|
||||
</radio>
|
||||
|
||||
<text>
|
||||
<row>3</row><col>1</col>
|
||||
<halign>right</halign>
|
||||
<label>Runway:</label>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/airports/use_runway</property>
|
||||
</enable>
|
||||
</text>
|
||||
|
||||
<combo>
|
||||
<name>runway-list</name>
|
||||
<row>3</row><col>2</col>
|
||||
<pref-width>85</pref-width>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/airports/use_runway</property>
|
||||
</enable>
|
||||
<property>/sim/gui/dialogs/airports/selected-airport/rwy</property>
|
||||
<editable>false</editable>
|
||||
<properties>sim/gui/dialogs/airports/available-runways</properties>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>runway-list</object-name>
|
||||
</binding>
|
||||
</combo>
|
||||
|
||||
<radio>
|
||||
<row>4</row><col>0</col>
|
||||
<property>/sim/gui/dialogs/airports/use_parkpos</property>
|
||||
<live>true</live>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>set_radio("parkpos")</script>
|
||||
</binding>
|
||||
</radio>
|
||||
|
||||
<text>
|
||||
<row>4</row><col>1</col>
|
||||
<halign>right</halign>
|
||||
<label>Parking:</label>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/airports/use_parkpos</property>
|
||||
</enable>
|
||||
</text>
|
||||
|
||||
<combo>
|
||||
<name>parking-list</name>
|
||||
<row>4</row><col>2</col>
|
||||
<pref-width>85</pref-width>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/airports/use_parkpos</property>
|
||||
</enable>
|
||||
<property>/sim/gui/dialogs/airports/selected-airport/parkpos</property>
|
||||
<editable>false</editable>
|
||||
<properties>sim/gui/dialogs/airports/available-parking</properties>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>parking-list</object-name>
|
||||
</binding>
|
||||
</combo>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
|
||||
<vrule/>
|
||||
|
||||
<group>
|
||||
<layout>vbox</layout>
|
||||
|
||||
<canvas>
|
||||
<name>map-dialog</name>
|
||||
<valign>fill</valign>
|
||||
<halign>fill</halign>
|
||||
<stretch>true</stretch>
|
||||
<pref-width>600</pref-width>
|
||||
<pref-height>400</pref-height>
|
||||
<view n="0">600</view>
|
||||
<view n="1">400</view>
|
||||
|
||||
<nasal>
|
||||
|
||||
|
||||
<load><![CDATA[
|
||||
var Runway = {
|
||||
new: func(rwy)
|
||||
{
|
||||
return {
|
||||
parents: [Runway],
|
||||
rwy: rwy
|
||||
};
|
||||
},
|
||||
pointOffCenterline: func(pos, off = 0)
|
||||
{
|
||||
var coord = geo.Coord.new();
|
||||
coord.set_latlon(me.rwy.lat, me.rwy.lon);
|
||||
coord.apply_course_distance(me.rwy.heading, pos - 0.5 * me.rwy.length);
|
||||
|
||||
if( off )
|
||||
coord.apply_course_distance(me.rwy.heading + 90, off);
|
||||
|
||||
return ["N" ~ coord.lat(), "E" ~ coord.lon()];
|
||||
}
|
||||
};
|
||||
|
||||
var AirportMap = {
|
||||
new: func(apt)
|
||||
{
|
||||
return {
|
||||
parents: [AirportMap],
|
||||
_apt: apt
|
||||
};
|
||||
},
|
||||
build: func(layer_runways)
|
||||
{
|
||||
var rws_done = {};
|
||||
|
||||
me.grp_apt = layer_runways.createChild("group", "apt-" ~ me._apt.id);
|
||||
var selected_rwy = getprop("/sim/gui/dialogs/airports/selected-airport/rwy");
|
||||
|
||||
foreach(var rw; keys(me._apt.runways))
|
||||
{
|
||||
var is_heli = substr(rw, 0, 1) == "H";
|
||||
var rw_dir = is_heli ? nil : int(substr(rw, 0, 2));
|
||||
|
||||
var rw_rec = "";
|
||||
var thresh_rec = 0;
|
||||
if( rw_dir != nil )
|
||||
{
|
||||
rw_rec = sprintf("%02d", math.mod(rw_dir - 18, 36));
|
||||
if( size(rw) == 3 )
|
||||
{
|
||||
var map_rec = {
|
||||
"R": "L",
|
||||
"L": "R",
|
||||
"C": "C"
|
||||
};
|
||||
rw_rec ~= map_rec[substr(rw, 2)];
|
||||
}
|
||||
|
||||
if( rws_done[rw_rec] != nil )
|
||||
continue;
|
||||
|
||||
var rw_rec = me._apt.runways[rw_rec];
|
||||
if( rw_rec != nil )
|
||||
thresh_rec = rw_rec.threshold;
|
||||
}
|
||||
|
||||
rws_done[rw] = 1;
|
||||
|
||||
rw = me._apt.runways[rw];
|
||||
var icon_rw =
|
||||
me.grp_apt.createChild("path", "runway")
|
||||
.setStrokeLineWidth(0.5)
|
||||
.setColor(1.0,1.0,1.0)
|
||||
.setColorFill(0.2, 0.2, 0.2);
|
||||
|
||||
var rwy = Runway.new(rw);
|
||||
var beg_thr = rwy.pointOffCenterline(rw.threshold);
|
||||
var beg_thr1 = rwy.pointOffCenterline(rw.threshold, 0.5 * rw.width);
|
||||
var beg_thr2 = rwy.pointOffCenterline(rw.threshold, -0.5 * rw.width);
|
||||
var beg1 = rwy.pointOffCenterline(0, 0.5 * rw.width);
|
||||
var beg2 = rwy.pointOffCenterline(0, -0.5 * rw.width);
|
||||
|
||||
var end_thr = rwy.pointOffCenterline(rw.length - thresh_rec);
|
||||
var end_thr1 = rwy.pointOffCenterline(rw.length - thresh_rec, 0.5 * rw.width);
|
||||
var end_thr2 = rwy.pointOffCenterline(rw.length - thresh_rec, -0.5 * rw.width);
|
||||
var end1 = rwy.pointOffCenterline(rw.length, 0.5 * rw.width);
|
||||
var end2 = rwy.pointOffCenterline(rw.length, -0.5 * rw.width);
|
||||
|
||||
icon_rw.setDataGeo
|
||||
(
|
||||
[ canvas.Path.VG_MOVE_TO,
|
||||
canvas.Path.VG_LINE_TO,
|
||||
canvas.Path.VG_LINE_TO,
|
||||
canvas.Path.VG_LINE_TO,
|
||||
canvas.Path.VG_CLOSE_PATH ],
|
||||
[ beg1[0], beg1[1],
|
||||
beg2[0], beg2[1],
|
||||
end2[0], end2[1],
|
||||
end1[0], end1[1] ]
|
||||
);
|
||||
|
||||
if( rw.length / rw.width > 3 and !is_heli )
|
||||
{
|
||||
# only runways which are much longer than wide are
|
||||
# real runways, otherwise it's probably a heliport.
|
||||
var icon_cl =
|
||||
me.grp_apt.createChild("path", "centerline")
|
||||
.setStrokeLineWidth(0.5)
|
||||
.setColor(1,1,1)
|
||||
.setStrokeDashArray([15, 10]);
|
||||
|
||||
icon_cl.setDataGeo
|
||||
(
|
||||
[ canvas.Path.VG_MOVE_TO,
|
||||
canvas.Path.VG_LINE_TO ],
|
||||
[ beg_thr[0], beg_thr[1],
|
||||
end_thr[0], end_thr[1] ]
|
||||
);
|
||||
|
||||
var icon_thr =
|
||||
me.grp_apt.createChild("path", "threshold")
|
||||
.setStrokeLineWidth(1.5)
|
||||
.setColor(1,1,1);
|
||||
|
||||
icon_thr.setDataGeo
|
||||
(
|
||||
[ canvas.Path.VG_MOVE_TO,
|
||||
canvas.Path.VG_LINE_TO,
|
||||
canvas.Path.VG_MOVE_TO,
|
||||
canvas.Path.VG_LINE_TO ],
|
||||
[ beg_thr1[0], beg_thr1[1],
|
||||
beg_thr2[0], beg_thr2[1],
|
||||
end_thr1[0], end_thr1[1],
|
||||
end_thr2[0], end_thr2[1] ]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var park; me._apt.parking())
|
||||
{
|
||||
var icon_park =
|
||||
me.grp_apt.createChild("text")
|
||||
.setDrawMode( canvas.Text.ALIGNMENT
|
||||
+ canvas.Text.TEXT )
|
||||
.setText(park.name)
|
||||
.setFont("LiberationFonts/LiberationMono-Bold.ttf")
|
||||
.setGeoPosition(park.lat, park.lon)
|
||||
.setFontSize(15, 1.3);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var my_canvas = canvas.get(cmdarg());
|
||||
my_canvas.setColorBackground(0.2, 0.5, 0.2, 0.5);
|
||||
|
||||
var root = my_canvas.createGroup();
|
||||
|
||||
var map = root.createChild("map", "map-test")
|
||||
.setTranslation(300, 200);
|
||||
|
||||
var layer_runways = map.createChild("group", "runways");
|
||||
var icon_tower =
|
||||
map.createChild("path", "tower")
|
||||
.setStrokeLineWidth(1)
|
||||
.setScale(1.5)
|
||||
.setColor(0.2,0.2,1.0)
|
||||
.moveTo(-3, 0)
|
||||
.vert(-10)
|
||||
.line(-3, -10)
|
||||
.horiz(12)
|
||||
.line(-3, 10)
|
||||
.vert(10);
|
||||
|
||||
var updateMap = func() {
|
||||
var id = getprop("/sim/gui/dialogs/airports/selected-airport/id");
|
||||
|
||||
if (id != "") {
|
||||
var apt = airportinfo(id);
|
||||
var airport = AirportMap.new(apt);
|
||||
airport.build(layer_runways);
|
||||
|
||||
var pos = apt.tower();
|
||||
icon_tower.setGeoPosition(pos.lat, pos.lon);
|
||||
map._node.getNode("ref-lat", 1).setDoubleValue(apt.lat);
|
||||
map._node.getNode("ref-lon", 1).setDoubleValue(apt.lon);
|
||||
map._node.getNode("hdg", 1).setDoubleValue(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
var ranges = [0.1, 0.25, 0.5, 1, 2.5, 5];
|
||||
|
||||
var updateZoom = func()
|
||||
{
|
||||
var z = getprop("/sim/gui/dialogs/airports/zoom");
|
||||
if( z == nil )
|
||||
z = 0;
|
||||
var zoom = ranges[4 - z];
|
||||
map._node.getNode("range", 1).setDoubleValue(zoom);
|
||||
|
||||
settimer(updateZoom, 0.5, 1);
|
||||
};
|
||||
|
||||
var aptlistener = setlistener("/sim/gui/dialogs/airports/selected-airport/id", updateMap);
|
||||
|
||||
update_info();
|
||||
updateZoom();
|
||||
]]>
|
||||
</load>
|
||||
<close>
|
||||
removelistener(aptlistener);
|
||||
</close>
|
||||
</nasal>
|
||||
</canvas>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
|
||||
<button>
|
||||
<name>zoomout</name>
|
||||
<legend>-</legend>
|
||||
<pref-width>22</pref-width>
|
||||
<pref-height>22</pref-height>
|
||||
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>/sim/gui/dialogs/airports/zoom</property>
|
||||
<min>0</min>
|
||||
<step>-1</step>
|
||||
</binding>
|
||||
</button>
|
||||
|
||||
<text>
|
||||
<label>MMM</label>
|
||||
<format>Zoom %d</format>
|
||||
<property>/sim/gui/dialogs/airports/zoom</property>
|
||||
<live>true</live>
|
||||
</text>
|
||||
|
||||
<button>
|
||||
<name>zoomin</name>
|
||||
<legend>+</legend>
|
||||
<pref-width>22</pref-width>
|
||||
<pref-height>22</pref-height>
|
||||
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>//sim/gui/dialogs/airports/zoom</property>
|
||||
<step>1</step>
|
||||
<max>4</max>
|
||||
</binding>
|
||||
</button>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
@ -120,12 +672,12 @@
|
|||
<group>
|
||||
<layout>hbox</layout>
|
||||
<default-padding>10</default-padding>
|
||||
|
||||
<empty><stretch>true</stretch></empty>
|
||||
|
||||
<button>
|
||||
<legend>Apply</legend>
|
||||
<legend>OK</legend>
|
||||
<equal>true</equal>
|
||||
<default>true</default>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>airport-list</object-name>
|
||||
|
@ -137,12 +689,15 @@
|
|||
<binding>
|
||||
<command>presets-commit</command>
|
||||
</binding>
|
||||
<binding>
|
||||
<command>dialog-close</command>
|
||||
</binding>
|
||||
</button>
|
||||
|
||||
<empty><stretch>true</stretch></empty>
|
||||
|
||||
<button>
|
||||
<legend>Close</legend>
|
||||
<legend>Cancel</legend>
|
||||
<equal>true</equal>
|
||||
<key>Esc</key>
|
||||
<binding>
|
||||
|
|
|
@ -1,303 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<PropertyList>
|
||||
<name>location-on-ground</name>
|
||||
<layout>vbox</layout>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<empty><stretch>1</stretch></empty>
|
||||
|
||||
<text>
|
||||
<label>Position Aircraft On Ground</label>
|
||||
</text>
|
||||
|
||||
<empty><stretch>1</stretch></empty>
|
||||
|
||||
<button>
|
||||
<pref-width>16</pref-width>
|
||||
<pref-height>16</pref-height>
|
||||
<legend></legend>
|
||||
<keynum>27</keynum>
|
||||
<border>2</border>
|
||||
<binding>
|
||||
<command>dialog-close</command>
|
||||
</binding>
|
||||
</button>
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<nasal>
|
||||
<open>
|
||||
var dlg = props.globals.getNode("/sim/gui/dialogs/location-on-ground", 1);
|
||||
var apt = dlg.getNode("airport", 1);
|
||||
var aptname = dlg.getNode("airport-name", 1);
|
||||
apt.setValue(getprop("/sim/presets/airport-id"));
|
||||
var rwy = dlg.getNode("runway", 1);
|
||||
rwy.setValue("");
|
||||
var parkpos = dlg.getNode("parkpos", 1);
|
||||
parkpos.setValue("");
|
||||
|
||||
var mode = {
|
||||
runway: dlg.getNode("use_runway", 1),
|
||||
bestrunway: dlg.getNode("use_best_runway", 1),
|
||||
parkpos: dlg.getNode("use_parkpos", 1)
|
||||
};
|
||||
|
||||
var set_radio = func(m) {
|
||||
foreach (k; keys(mode)) {
|
||||
mode[k].setBoolValue(m == k);
|
||||
}
|
||||
}
|
||||
|
||||
var initialized = 0;
|
||||
foreach (k; keys(mode)) {
|
||||
if (mode[k].getType() == "NONE" or initialized) {
|
||||
mode[k].setBoolValue(0);
|
||||
} else {
|
||||
initialized += mode[k].getBoolValue();
|
||||
}
|
||||
}
|
||||
if (!initialized) {
|
||||
set_radio("bestrunway");
|
||||
}
|
||||
|
||||
var runways = dlg.getNode("available-runways", 1);
|
||||
var parking = dlg.getNode("available-parking", 1);
|
||||
|
||||
var updateAirport = func {
|
||||
var icao = apt.getValue();
|
||||
runways.removeChildren("value");
|
||||
parking.removeChildren("value");
|
||||
|
||||
var a = airportinfo(icao);
|
||||
if (a == nil) {
|
||||
aptname.setValue("");
|
||||
return;
|
||||
}
|
||||
|
||||
aptname.setValue(a.name);
|
||||
var i=0;
|
||||
foreach (var rwy; keys(a.runways)) {
|
||||
runways.getNode("value[" ~ i ~ "]", 1).setValue(rwy);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
foreach (var park; a.parking()) {
|
||||
parking.getNode("value[" ~ i ~ "]", 1).setValue(park.name);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
gui.dialog_update("location-on-ground");
|
||||
}
|
||||
|
||||
updateAirport();
|
||||
</open>
|
||||
</nasal>
|
||||
|
||||
<group>
|
||||
<layout>table</layout>
|
||||
<halign>center</halign>
|
||||
|
||||
<text>
|
||||
<row>0</row><col>1</col>
|
||||
<halign>right</halign>
|
||||
<label>Airport:</label>
|
||||
</text>
|
||||
|
||||
<input>
|
||||
<row>0</row><col>2</col>
|
||||
<live>true</live>
|
||||
<property>/sim/gui/dialogs/location-on-ground/airport</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
updateAirport();
|
||||
</script>
|
||||
</binding>
|
||||
</input>
|
||||
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>1</col>
|
||||
<format>%s</format>
|
||||
<property>/sim/gui/dialogs/location-on-ground/airport-name</property>
|
||||
<live>true</live>
|
||||
<stretch>true</stretch>
|
||||
<halign>fill</halign>
|
||||
</text>
|
||||
|
||||
<radio>
|
||||
<row>2</row><col>0</col>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_best_runway</property>
|
||||
<live>true</live>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>set_radio("bestrunway")</script>
|
||||
</binding>
|
||||
</radio>
|
||||
|
||||
<text>
|
||||
<row>2</row><col>1</col>
|
||||
<halign>right</halign>
|
||||
<label>Best runway</label>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_best_runway</property>
|
||||
</enable>
|
||||
</text>
|
||||
<text>
|
||||
<row>2</row><col>2</col>
|
||||
<halign>right</halign>
|
||||
<label>(based on wind)</label>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_best_runway</property>
|
||||
</enable>
|
||||
</text>
|
||||
|
||||
<radio>
|
||||
<row>3</row><col>0</col>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_runway</property>
|
||||
<live>true</live>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>set_radio("runway")</script>
|
||||
</binding>
|
||||
</radio>
|
||||
|
||||
<text>
|
||||
<row>3</row><col>1</col>
|
||||
<halign>right</halign>
|
||||
<label>Runway:</label>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_runway</property>
|
||||
</enable>
|
||||
</text>
|
||||
|
||||
<combo>
|
||||
<name>runway</name>
|
||||
<row>3</row><col>2</col>
|
||||
<pref-width>85</pref-width>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_runway</property>
|
||||
</enable>
|
||||
<property>sim/gui/dialogs/location-on-ground/runway</property>
|
||||
<editable>false</editable>
|
||||
<properties>sim/gui/dialogs/location-on-ground/available-runways</properties>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>runway</object-name>
|
||||
</binding>
|
||||
</combo>
|
||||
|
||||
<radio>
|
||||
<row>4</row><col>0</col>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_parkpos</property>
|
||||
<live>true</live>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>set_radio("parkpos")</script>
|
||||
</binding>
|
||||
</radio>
|
||||
|
||||
<text>
|
||||
<row>4</row><col>1</col>
|
||||
<halign>right</halign>
|
||||
<label>Parking:</label>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_parkpos</property>
|
||||
</enable>
|
||||
</text>
|
||||
|
||||
<combo>
|
||||
<name>parking</name>
|
||||
<row>4</row><col>2</col>
|
||||
<pref-width>85</pref-width>
|
||||
<enable>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_parkpos</property>
|
||||
</enable>
|
||||
<property>/sim/gui/dialogs/location-on-ground/parkpos</property>
|
||||
<editable>false</editable>
|
||||
<properties>sim/gui/dialogs/location-on-ground/available-parking</properties>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>parking</object-name>
|
||||
</binding>
|
||||
</combo>
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<default-padding>10</default-padding>
|
||||
<empty><stretch>true</stretch></empty>
|
||||
|
||||
<button>
|
||||
<legend>OK</legend>
|
||||
<default>true</default>
|
||||
<equal>true</equal>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
<enable>
|
||||
<not>
|
||||
<and>
|
||||
<property>/sim/gui/dialogs/location-on-ground/use_runway</property>
|
||||
<equals>
|
||||
<property>/sim/gui/dialogs/location-on-ground/runway</property>
|
||||
<value></value>
|
||||
</equals>
|
||||
</and>
|
||||
</not>
|
||||
</enable>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
setprop("/sim/presets/airport-id", apt.getValue());
|
||||
if (mode["bestrunway"].getBoolValue()) {
|
||||
setprop("/sim/presets/runway", "");
|
||||
setprop("/sim/presets/parkpos", "");
|
||||
} else if (mode["runway"].getBoolValue()) {
|
||||
setprop("/sim/presets/runway", rwy.getValue());
|
||||
setprop("/sim/presets/parkpos", "");
|
||||
} else {
|
||||
setprop("/sim/presets/runway", "");
|
||||
setprop("/sim/presets/parkpos", parkpos.getValue());
|
||||
}
|
||||
setprop("/sim/presets/longitude-deg", -9999);
|
||||
setprop("/sim/presets/latitude-deg", -9999);
|
||||
setprop("/sim/presets/altitude-ft", -9999);
|
||||
setprop("/sim/presets/airspeed-kt", 0);
|
||||
setprop("/sim/presets/offset-distance-nm", 0);
|
||||
setprop("/sim/presets/offset-azimuth-nm", 0);
|
||||
setprop("/sim/presets/glideslope-deg", 0);
|
||||
setprop("/sim/presets/heading-deg", 9999);
|
||||
</script>
|
||||
</binding>
|
||||
<binding>
|
||||
<command>presets-commit</command>
|
||||
</binding>
|
||||
<binding>
|
||||
<command>dialog-close</command>
|
||||
</binding>
|
||||
</button>
|
||||
|
||||
<empty><stretch>true</stretch></empty>
|
||||
|
||||
<button>
|
||||
<legend>Cancel</legend>
|
||||
<equal>true</equal>
|
||||
<key>Esc</key>
|
||||
<binding>
|
||||
<command>dialog-close</command>
|
||||
</binding>
|
||||
</button>
|
||||
|
||||
<empty><stretch>true</stretch></empty>
|
||||
</group>
|
||||
</PropertyList>
|
|
@ -172,14 +172,6 @@
|
|||
<menu>
|
||||
<name>location</name>
|
||||
|
||||
<item>
|
||||
<name>position-on-ground</name>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>location-on-ground</dialog-name>
|
||||
</binding>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<name>position-in-air</name>
|
||||
<binding>
|
||||
|
|
Loading…
Add table
Reference in a new issue