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
|
|
|
# FG1000 MFD
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
var MFDPages = [
|
2017-12-27 19:51:54 +00:00
|
|
|
"NavigationMap",
|
2017-12-10 22:15:21 +00:00
|
|
|
"TrafficMap",
|
|
|
|
"Stormscope",
|
|
|
|
"WeatherDataLink",
|
2018-01-13 18:53:06 +00:00
|
|
|
"TAWSB",
|
2017-12-10 22:15:21 +00:00
|
|
|
"AirportInfo",
|
|
|
|
"AirportDirectory",
|
|
|
|
"AirportDeparture",
|
|
|
|
"AirportArrival",
|
|
|
|
"AirportApproach",
|
|
|
|
"AirportWeather",
|
|
|
|
"IntersectionInfo",
|
|
|
|
"NDBInfo",
|
|
|
|
"VORInfo",
|
|
|
|
"UserWPTInfo",
|
|
|
|
"TripPlanning",
|
|
|
|
"Utility",
|
|
|
|
"GPSStatus",
|
|
|
|
"XMRadio",
|
|
|
|
"XMInfo",
|
|
|
|
"SystemStatus",
|
|
|
|
"ActiveFlightPlanWide",
|
|
|
|
"ActiveFlightPlanNarrow",
|
|
|
|
"FlightPlanCatalog",
|
|
|
|
"StoredFlightPlan",
|
|
|
|
"Checklist1",
|
|
|
|
"Checklist2",
|
|
|
|
"Checklist3",
|
|
|
|
"Checklist4",
|
|
|
|
"Checklist5",
|
|
|
|
"NearestAirports",
|
|
|
|
"NearestIntersections",
|
|
|
|
"NearestNDB",
|
|
|
|
"NearestVOR",
|
|
|
|
"NearestUserWPT",
|
|
|
|
"NearestFrequencies",
|
2018-01-26 19:06:06 +00:00
|
|
|
"NearestAirspaces",
|
|
|
|
"DirectTo", # display at the top of the stack
|
2018-02-05 19:33:28 +00:00
|
|
|
"Surround",
|
2017-12-10 22:15:21 +00:00
|
|
|
];
|
|
|
|
|
2018-02-09 15:01:33 +00:00
|
|
|
var nasal_dir = getprop("/sim/fg-root") ~ "/Aircraft/Instruments-3d/FG1000/Nasal/";
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
foreach (var page; MFDPages) {
|
2018-02-05 19:33:28 +00:00
|
|
|
io.load_nasal(nasal_dir ~ "MFDPages/" ~ page ~ '/' ~ page ~ '.nas', "fg1000");
|
|
|
|
io.load_nasal(nasal_dir ~ "MFDPages/" ~ page ~ '/' ~ page ~ 'Styles.nas', "fg1000");
|
|
|
|
io.load_nasal(nasal_dir ~ "MFDPages/" ~ page ~ '/' ~ page ~ 'Options.nas', "fg1000");
|
|
|
|
io.load_nasal(nasal_dir ~ "MFDPages/" ~ page ~ '/' ~ page ~ 'Controller.nas', "fg1000");
|
2017-12-10 22:15:21 +00:00
|
|
|
}
|
2017-11-24 23:04:46 +00:00
|
|
|
|
2018-02-26 21:24:21 +00:00
|
|
|
var MFDDisplay =
|
2017-11-24 23:04:46 +00:00
|
|
|
{
|
2018-02-09 15:01:33 +00:00
|
|
|
new : func (fg1000instance, EIS_Class, EIS_SVG, myCanvas, device_id=1)
|
2017-11-24 23:04:46 +00:00
|
|
|
{
|
2017-12-31 16:10:52 +00:00
|
|
|
var obj = {
|
2018-02-26 21:24:21 +00:00
|
|
|
parents : [ MFDDisplay ],
|
2017-12-31 16:10:52 +00:00
|
|
|
EIS : nil,
|
|
|
|
NavigationMap: nil,
|
2018-01-08 21:39:39 +00:00
|
|
|
Surround : nil,
|
2018-02-04 21:40:37 +00:00
|
|
|
_pageList : {},
|
2018-02-09 15:01:33 +00:00
|
|
|
_fg1000 : fg1000instance,
|
|
|
|
_canvas : myCanvas,
|
2017-12-31 16:10:52 +00:00
|
|
|
};
|
2017-11-24 23:04:46 +00:00
|
|
|
|
2018-02-09 15:01:33 +00:00
|
|
|
obj.ConfigStore = obj._fg1000.getConfigStore();
|
2018-01-18 19:37:50 +00:00
|
|
|
|
2017-11-24 23:04:46 +00:00
|
|
|
obj._svg = myCanvas.createGroup("softkeys");
|
2018-01-14 20:46:50 +00:00
|
|
|
obj._svg.set("clip-frame", canvas.Element.LOCAL);
|
|
|
|
obj._svg.set("clip", "rect(0px, 1024px, 768px, 0px)");
|
2017-12-10 22:15:21 +00:00
|
|
|
|
|
|
|
var fontmapper = func (family, weight) {
|
|
|
|
#if( family == "Liberation Sans" and weight == "narrow" ) {
|
|
|
|
return "LiberationFonts/LiberationSansNarrow-Regular.ttf";
|
|
|
|
#}
|
|
|
|
# If we don't return anything the default font is used
|
|
|
|
};
|
|
|
|
|
2018-02-05 19:33:28 +00:00
|
|
|
canvas.parsesvg(obj._svg,
|
2018-02-09 15:01:33 +00:00
|
|
|
EIS_SVG,
|
2018-02-05 19:33:28 +00:00
|
|
|
{'font-mapper': fontmapper});
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
foreach (var page; MFDPages) {
|
2018-02-05 19:33:28 +00:00
|
|
|
var svg_file ='/Aircraft/Instruments-3d/FG1000/MFDPages/' ~ page ~ '.svg';
|
2017-12-10 22:15:21 +00:00
|
|
|
if (resolvepath(svg_file) != "") {
|
|
|
|
# Load an SVG file if available.
|
|
|
|
canvas.parsesvg(obj._svg,
|
|
|
|
svg_file,
|
|
|
|
{'font-mapper': fontmapper});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-24 23:04:46 +00:00
|
|
|
obj._MFDDevice = canvas.PFD_Device.new(obj._svg, 12, "SoftKey", myCanvas, "MFD");
|
2018-02-04 21:40:37 +00:00
|
|
|
obj._MFDDevice.device_id = device_id;
|
2017-11-24 23:04:46 +00:00
|
|
|
obj._MFDDevice.RegisterWithEmesary();
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
# Surround dynamic elements
|
|
|
|
obj._pageTitle = obj._svg.getElementById("PageTitle");
|
|
|
|
|
2018-01-05 16:37:39 +00:00
|
|
|
# Controller for the header and display on the bottom left which allows selection
|
2017-11-24 23:04:46 +00:00
|
|
|
# of page groups and individual pages using the FMS controller.
|
2018-01-05 16:37:39 +00:00
|
|
|
obj.Surround = fg1000.Surround.new(obj, myCanvas, obj._MFDDevice, obj._svg);
|
2018-01-26 19:06:06 +00:00
|
|
|
obj.SurroundController = obj.Surround.getController();
|
2017-11-24 23:04:46 +00:00
|
|
|
|
2018-01-03 20:24:41 +00:00
|
|
|
# Engine Information System. A special case as it's always displayed on the MFD.
|
2018-02-09 15:01:33 +00:00
|
|
|
# Note that it is passed in on the constructor
|
|
|
|
obj.EIS = EIS_Class.new(obj, myCanvas, obj._MFDDevice, obj._svg);
|
2018-01-26 19:06:06 +00:00
|
|
|
obj.addPage("EIS", obj.EIS);
|
2018-01-03 20:24:41 +00:00
|
|
|
|
2017-12-31 16:10:52 +00:00
|
|
|
# The NavigationMap page is a special case, as it is displayed with the Nearest... pages as an overlay
|
2018-01-26 19:06:06 +00:00
|
|
|
obj.NavigationMap = fg1000.NavigationMap.new(obj, myCanvas, obj._MFDDevice, obj._svg);
|
|
|
|
obj.addPage("NavigationMap", obj.NavigationMap);
|
2017-12-31 16:10:52 +00:00
|
|
|
obj.NavigationMap.topMenu(obj._MFDDevice, obj.NavigationMap, nil);
|
|
|
|
|
2018-01-26 19:06:06 +00:00
|
|
|
# Now load the other pages normally;
|
2017-12-10 22:15:21 +00:00
|
|
|
foreach (var page; MFDPages) {
|
2018-01-05 16:37:39 +00:00
|
|
|
if ((page != "NavigationMap") and (page != "EIS")) {
|
2018-01-26 19:06:06 +00:00
|
|
|
#var code = "obj.Surround.addPage(\"" ~ page ~ "\", fg1000." ~ page ~ ".new(obj, myCanvas, obj._MFDDevice, obj._svg));";
|
|
|
|
var code = "obj.addPage(\"" ~ page ~ "\", fg1000." ~ page ~ ".new(obj, myCanvas, obj._MFDDevice, obj._svg));";
|
2017-12-31 16:10:52 +00:00
|
|
|
var addPageFn = compile(code);
|
|
|
|
addPageFn();
|
|
|
|
}
|
2017-12-10 22:15:21 +00:00
|
|
|
}
|
2017-11-24 23:04:46 +00:00
|
|
|
|
2018-01-05 16:37:39 +00:00
|
|
|
# Display the Surround, EIS and NavMap and the appropriate top level on startup.
|
|
|
|
obj.Surround.setVisible(1);
|
2018-01-03 20:24:41 +00:00
|
|
|
obj.EIS.setVisible(1);
|
|
|
|
obj.EIS.ondisplay();
|
2017-12-27 19:51:54 +00:00
|
|
|
obj._MFDDevice.selectPage(obj.NavigationMap);
|
2017-11-24 23:04:46 +00:00
|
|
|
|
|
|
|
return obj;
|
|
|
|
},
|
2018-01-13 18:53:06 +00:00
|
|
|
getDevice : func () {
|
|
|
|
return me._MFDDevice;
|
|
|
|
},
|
2017-11-24 23:04:46 +00:00
|
|
|
del: func()
|
|
|
|
{
|
2017-12-27 19:51:54 +00:00
|
|
|
me._MFDDevice.current_page.offdisplay();
|
|
|
|
me._MFDDevice.DeRegisterWithEmesary();
|
2018-01-13 18:53:06 +00:00
|
|
|
me.SurroundController.del();
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
},
|
|
|
|
setPageTitle: func(title)
|
|
|
|
{
|
|
|
|
me._pageTitle.setText(title);
|
2018-01-26 19:06:06 +00:00
|
|
|
},
|
|
|
|
addPage : func(name, page)
|
|
|
|
{
|
|
|
|
me._pageList[name] = page;
|
|
|
|
},
|
|
|
|
|
|
|
|
getPage : func(name)
|
|
|
|
{
|
|
|
|
return me._pageList[name];
|
|
|
|
},
|
2018-02-04 21:40:37 +00:00
|
|
|
|
|
|
|
getDeviceID : func() {
|
|
|
|
return me._MFDDevice.device_id;
|
|
|
|
},
|
2018-02-09 15:01:33 +00:00
|
|
|
|
|
|
|
getCanvas : func() {
|
|
|
|
return me._canvas;
|
|
|
|
}
|
2017-11-24 23:04:46 +00:00
|
|
|
};
|