2017-11-24 23:04:46 +00:00
|
|
|
# FG1000 MFD
|
|
|
|
|
2017-12-27 19:51:54 +00:00
|
|
|
print("##############");
|
|
|
|
print("# FG1000 MFD #");
|
|
|
|
print("##############\n");
|
|
|
|
|
|
|
|
io.include("constants.nas");
|
|
|
|
|
2017-11-24 23:04:46 +00:00
|
|
|
var nasal_dir = getprop("/sim/fg-root") ~ "/Aircraft/Instruments-3d/FG1000/Nasal/";
|
|
|
|
|
2017-12-27 19:51:54 +00:00
|
|
|
io.load_nasal(nasal_dir ~ '/MFDPage.nas', "fg1000");
|
2018-01-08 21:39:39 +00:00
|
|
|
io.load_nasal(nasal_dir ~ '/MFDPageController.nas', "fg1000");
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
var MFDPages = [
|
2018-01-05 16:37:39 +00:00
|
|
|
"Surround",
|
2017-12-27 19:51:54 +00:00
|
|
|
"NavigationMap",
|
2018-01-03 20:24:41 +00:00
|
|
|
"EIS",
|
2017-12-10 22:15:21 +00:00
|
|
|
"TrafficMap",
|
|
|
|
"Stormscope",
|
|
|
|
"WeatherDataLink",
|
|
|
|
"TAWS",
|
|
|
|
"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",
|
|
|
|
"NearestAirspaces"
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach (var page; MFDPages) {
|
|
|
|
io.load_nasal(nasal_dir ~ page ~ '/' ~ page ~ '.nas', "fg1000");
|
|
|
|
io.load_nasal(nasal_dir ~ page ~ '/' ~ page ~ 'Styles.nas', "fg1000");
|
|
|
|
io.load_nasal(nasal_dir ~ page ~ '/' ~ page ~ 'Options.nas', "fg1000");
|
|
|
|
io.load_nasal(nasal_dir ~ page ~ '/' ~ page ~ 'Controller.nas', "fg1000");
|
|
|
|
}
|
2017-11-24 23:04:46 +00:00
|
|
|
|
|
|
|
var MFD =
|
|
|
|
{
|
|
|
|
new : func (myCanvas)
|
|
|
|
{
|
2017-12-31 16:10:52 +00:00
|
|
|
var obj = {
|
|
|
|
parents : [ MFD ],
|
|
|
|
EIS : nil,
|
|
|
|
NavigationMap: nil,
|
2018-01-08 21:39:39 +00:00
|
|
|
Surround : nil,
|
2017-12-31 16:10:52 +00:00
|
|
|
};
|
2017-11-24 23:04:46 +00:00
|
|
|
|
|
|
|
obj._svg = myCanvas.createGroup("softkeys");
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
foreach (var page; MFDPages) {
|
|
|
|
var svg_file ='/Aircraft/Instruments-3d/FG1000/Models/' ~ page ~ '.svg';
|
|
|
|
if (resolvepath(svg_file) != "") {
|
|
|
|
# Load an SVG file if available.
|
|
|
|
canvas.parsesvg(obj._svg,
|
|
|
|
svg_file,
|
|
|
|
{'font-mapper': fontmapper});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas.parsesvg(obj._svg,
|
|
|
|
'/Aircraft/Instruments-3d/FG1000/Models/MFD.svg',
|
|
|
|
{'font-mapper': fontmapper});
|
2017-11-24 23:04:46 +00:00
|
|
|
|
|
|
|
obj._MFDDevice = canvas.PFD_Device.new(obj._svg, 12, "SoftKey", myCanvas, "MFD");
|
|
|
|
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);
|
|
|
|
obj._pageGroupController = obj.Surround.controller;
|
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-01-05 16:37:39 +00:00
|
|
|
obj.EIS = obj.Surround.addPage("EIS", fg1000.EIS.new(obj, myCanvas, obj._MFDDevice, obj._svg));
|
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-05 16:37:39 +00:00
|
|
|
obj.NavigationMap = obj.Surround.addPage("NavigationMap", fg1000.NavigationMap.new(obj, myCanvas, obj._MFDDevice, obj._svg));
|
2017-12-31 16:10:52 +00:00
|
|
|
obj.NavigationMap.topMenu(obj._MFDDevice, obj.NavigationMap, nil);
|
|
|
|
|
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")) {
|
|
|
|
var code = "obj.Surround.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
|
|
|
|
2018-01-03 20:24:41 +00:00
|
|
|
|
2017-11-24 23:04:46 +00:00
|
|
|
# Add a wheel controller., which we will attach to the zoom.
|
|
|
|
myCanvas.addEventListener("wheel", func(e)
|
|
|
|
{
|
|
|
|
if (e.deltaY >0) {
|
2017-12-27 19:51:54 +00:00
|
|
|
obj._MFDDevice.current_page.controller.handleFMSInner(1);
|
2017-11-24 23:04:46 +00:00
|
|
|
} else {
|
2017-12-27 19:51:54 +00:00
|
|
|
obj._MFDDevice.current_page.controller.handleFMSInner(-1);
|
2017-11-24 23:04:46 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
},
|
|
|
|
del: func()
|
|
|
|
{
|
2017-12-27 19:51:54 +00:00
|
|
|
me._MFDDevice.current_page.offdisplay();
|
|
|
|
me._MFDDevice.DeRegisterWithEmesary();
|
2018-01-05 16:37:39 +00:00
|
|
|
me._pageGroupController.del();
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
},
|
|
|
|
setPageTitle: func(title)
|
|
|
|
{
|
|
|
|
me._pageTitle.setText(title);
|
2017-11-24 23:04:46 +00:00
|
|
|
}
|
|
|
|
};
|