2018-02-09 18:55:53 +00:00
|
|
|
# Copyright 2018 Stuart Buchanan
|
|
|
|
# This file is part of FlightGear.
|
|
|
|
#
|
|
|
|
# Foobar is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# FlightGear is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with FlightGear. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
2017-11-24 23:04:46 +00:00
|
|
|
# Navigation Map
|
2017-12-27 19:51:54 +00:00
|
|
|
var NavigationMap =
|
2017-11-24 23:04:46 +00:00
|
|
|
{
|
2017-12-10 22:15:21 +00:00
|
|
|
new : func (mfd, myCanvas, device, svg)
|
2017-11-24 23:04:46 +00:00
|
|
|
{
|
|
|
|
var obj = {
|
2017-12-27 19:51:54 +00:00
|
|
|
parents : [
|
|
|
|
NavigationMap,
|
|
|
|
MFDPage.new(mfd, myCanvas, device, svg, "NavigationMap", "MAP - NAVIGATION MAP")
|
|
|
|
],
|
2017-11-24 23:04:46 +00:00
|
|
|
};
|
|
|
|
|
2018-03-17 22:04:41 +00:00
|
|
|
obj.MFDMap = fg1000.NavMap.new(
|
|
|
|
obj,
|
|
|
|
obj.getElement("NavMap"),
|
|
|
|
[fg1000.MAP_FULL.CENTER.X, fg1000.MAP_FULL.CENTER.Y],
|
|
|
|
"",
|
|
|
|
zindex=-10);
|
2018-01-26 19:06:06 +00:00
|
|
|
obj.setController(fg1000.NavigationMapController.new(obj, svg));
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2017-11-24 23:04:46 +00:00
|
|
|
return obj;
|
|
|
|
},
|
2018-03-17 22:04:41 +00:00
|
|
|
|
2018-01-26 19:06:06 +00:00
|
|
|
offdisplay : func(controller=1) {
|
2017-11-24 23:04:46 +00:00
|
|
|
me._group.setVisible(0);
|
2018-03-17 22:04:41 +00:00
|
|
|
me.getElement("NavMap").setVisible(0);
|
|
|
|
me.getElement("NavMap-bg").setVisible(0);
|
|
|
|
me.MFDMap.setVisible(0);
|
2017-11-24 23:04:46 +00:00
|
|
|
|
|
|
|
# Reset the menu colours. Shouldn't have to do this here, but
|
|
|
|
# there's not currently an obvious other location to do so.
|
|
|
|
for(var i = 0; i < 12; i +=1) {
|
|
|
|
var name = sprintf("SoftKey%d",i);
|
|
|
|
me.device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0);
|
|
|
|
me.device.svg.getElementById(name).setColor(1.0,1.0,1.0);
|
|
|
|
}
|
2018-01-26 19:06:06 +00:00
|
|
|
if (controller == 1) me.getController().offdisplay();
|
2017-11-24 23:04:46 +00:00
|
|
|
},
|
2018-01-26 19:06:06 +00:00
|
|
|
ondisplay : func(controller=1) {
|
2017-11-24 23:04:46 +00:00
|
|
|
me._group.setVisible(1);
|
2018-03-17 22:04:41 +00:00
|
|
|
me.getElement("Group").setVisible(1);
|
|
|
|
me.getElement("NavMap").setVisible(1);
|
|
|
|
me.getElement("NavMap-bg").setVisible(1);
|
|
|
|
me.getElement("Legend").setVisible(1);
|
|
|
|
me.MFDMap.setVisible(1);
|
2017-12-27 19:51:54 +00:00
|
|
|
|
|
|
|
# Center the map's origin, modified to take into account the surround.
|
2018-03-17 22:04:41 +00:00
|
|
|
me.getElement("NavMap").setTranslation(
|
2017-12-27 19:51:54 +00:00
|
|
|
fg1000.MAP_FULL.CENTER.X,
|
|
|
|
fg1000.MAP_FULL.CENTER.Y
|
|
|
|
);
|
|
|
|
|
2018-03-17 22:04:41 +00:00
|
|
|
me.getElement("Legend").setTranslation(0,0);
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
me.mfd.setPageTitle(me.title);
|
2018-01-26 19:06:06 +00:00
|
|
|
if (controller == 1) me.getController().ondisplay();
|
2017-11-24 23:04:46 +00:00
|
|
|
},
|
2017-12-27 19:51:54 +00:00
|
|
|
|
|
|
|
# Display functions when we're displaying the NavigationMap as part of another
|
|
|
|
# page - e.g. NearestAirports.
|
|
|
|
ondisplayPartial : func() {
|
|
|
|
me._group.setVisible(1);
|
2018-03-17 22:04:41 +00:00
|
|
|
me.getElement("Group").setVisible(1);
|
|
|
|
me.getElement("NavMap").setVisible(1);
|
|
|
|
me.getElement("NavMap-bg").setVisible(1);
|
|
|
|
me.getElement("Legend").setVisible(1);
|
|
|
|
me.MFDMap.setVisible(1);
|
|
|
|
|
|
|
|
# Center the map's origin, modified to take into account the surround.
|
|
|
|
me.getElement("NavMap").setTranslation(
|
2017-12-27 19:51:54 +00:00
|
|
|
fg1000.MAP_PARTIAL.CENTER.X,
|
|
|
|
fg1000.MAP_PARTIAL.CENTER.Y
|
|
|
|
);
|
|
|
|
|
2018-03-17 22:04:41 +00:00
|
|
|
me.getElement("Legend").setTranslation(-300,0);
|
2017-12-27 19:51:54 +00:00
|
|
|
},
|
|
|
|
offdisplayPartial : func() {
|
|
|
|
me._group.setVisible(0);
|
2018-03-17 22:04:41 +00:00
|
|
|
me.getElement("Group").setVisible(0);
|
|
|
|
me.getElement("NavMap").setVisible(0);
|
|
|
|
me.getElement("NavMap-bg").setVisible(0);
|
|
|
|
me.getElement("Legend").setVisible(0);
|
|
|
|
me.MFDMap.setVisible(0);
|
2018-01-26 19:06:06 +00:00
|
|
|
#me.getController().offdisplayPartial();
|
2017-12-27 19:51:54 +00:00
|
|
|
},
|
2017-12-31 16:10:52 +00:00
|
|
|
|
|
|
|
# Softkey assigments. For some pages (notably the NEAREST pages)
|
|
|
|
# the MAP softkey is available as key 2:
|
|
|
|
# pg.addMenuItem(2, "MAP", pg, pg.mfd.NavigationMap.mapMenu);
|
|
|
|
|
|
|
|
|
|
|
|
topMenu : func(device, pg, menuitem) {
|
|
|
|
pg.clearMenu();
|
|
|
|
pg.resetMenuColors();
|
|
|
|
pg.addMenuItem(0, "ENGINE", pg, pg.mfd.EIS.engineMenu);
|
|
|
|
pg.addMenuItem(2, "MAP", pg, pg.mfd.NavigationMap.mapMenu);
|
2018-03-17 22:04:41 +00:00
|
|
|
pg.addMenuItem(8, "DCLTR", pg, func(dev, pg, mi) { pg.mfd.NavigationMap.MFDMap.incrDCLTR(dev, mi); } );
|
2017-12-31 16:10:52 +00:00
|
|
|
#pg.addMenuItem(9, "SHW CHRT", pg); # Optional
|
|
|
|
#pg.addMenuItem(10, "CHKLIST", pg); # Optional
|
|
|
|
device.updateMenus();
|
|
|
|
},
|
|
|
|
|
|
|
|
mapMenu : func(device, pg, menuitem) {
|
|
|
|
pg.clearMenu();
|
|
|
|
pg.resetMenuColors();
|
|
|
|
pg.addMenuItem(0, "TRAFFIC", pg,
|
2018-03-17 22:04:41 +00:00
|
|
|
func(dev, pg, mi) { pg.mfd.NavigationMap.MFDMap.toggleLayer("TFC"); device.updateMenus(); }, # callback
|
2017-12-31 16:10:52 +00:00
|
|
|
func(svg, mi) { pg.mfd.NavigationMap.display_toggle(device, svg, mi, "TFC"); }
|
|
|
|
);
|
|
|
|
|
|
|
|
pg.addMenuItem(1, "PROFILE", pg);
|
|
|
|
pg.addMenuItem(2, "TOPO", pg,
|
2018-03-17 22:04:41 +00:00
|
|
|
func(dev, pg, mi) { pg.mfd.NavigationMap.MFDMap.toggleLayer("STAMEN"); device.updateMenus(); }, # callback
|
2017-12-31 16:10:52 +00:00
|
|
|
func(svg, mi) { pg.mfd.NavigationMap.display_toggle(device, svg, mi, "STAMEN"); }
|
|
|
|
);
|
|
|
|
|
|
|
|
pg.addMenuItem(3, "TERRAIN", pg,
|
2018-03-17 22:04:41 +00:00
|
|
|
func(dev, pg, mi) { pg.mfd.NavigationMap.MFDMap.toggleLayer("STAMEN_terrain"); device.updateMenus(); }, # callback
|
2017-12-31 16:10:52 +00:00
|
|
|
func(svg, mi) { pg.mfd.NavigationMap.display_toggle(device, svg, mi, "STAMEN_terrain"); }
|
|
|
|
);
|
|
|
|
|
2018-03-17 22:04:41 +00:00
|
|
|
pg.addMenuItem(4, "AIRWAYS", pg, func(dev, pg, mi) { pg.mfd.NavigationMap.MFDMap.incrAIRWAYS(dev, mi); } );
|
2017-12-31 16:10:52 +00:00
|
|
|
#pg.addMenuItem(5, "STRMSCP", pg); Optional
|
|
|
|
#pg.addMenuItem(6, "PRECIP", pg); Optional, or NEXRAD
|
|
|
|
#pg.addMenuItem(7, "XM LTNG", pg); Optional, or DL LTNG
|
|
|
|
#pg.addMenuItem(8, "METAR", pg);
|
|
|
|
#pg.addMenuItem(9, "LEGEND", pg); Optional - only available with NEXRAD/XM LTNG/METAR/PROFILE selected
|
|
|
|
pg.addMenuItem(10, "BACK", pg, pg.topMenu); # Or should this just be the next button?
|
|
|
|
device.updateMenus();
|
|
|
|
},
|
|
|
|
|
|
|
|
# Display map toggle softkeys which change color depending
|
|
|
|
# on whether a particular layer is enabled or not.
|
|
|
|
display_toggle : func(device, svg, mi, layer) {
|
|
|
|
var bg_name = sprintf("SoftKey%d-bg",mi.menu_id);
|
2018-03-17 22:04:41 +00:00
|
|
|
if (me.MFDMap.isEnabled(layer)) {
|
2017-12-31 16:10:52 +00:00
|
|
|
device.svg.getElementById(bg_name).setColorFill(0.5,0.5,0.5);
|
|
|
|
svg.setColor(0.0,0.0,0.0);
|
|
|
|
} else {
|
|
|
|
device.svg.getElementById(bg_name).setColorFill(0.0,0.0,0.0);
|
|
|
|
svg.setColor(1.0,1.0,1.0);
|
|
|
|
}
|
|
|
|
svg.setText(mi.title);
|
|
|
|
svg.setVisible(1); # display function
|
|
|
|
},
|
|
|
|
|
2017-11-24 23:04:46 +00:00
|
|
|
};
|