| 1 |
# Copyright 2018 Stuart Buchanan |
| 2 |
# This file is part of FlightGear. |
| 3 |
# |
| 4 |
# FlightGear is free software: you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation, either version 2 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# FlightGear is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with FlightGear. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
# |
| 17 |
# FG1000 PFD |
| 18 |
|
| 19 |
var PFDDisplay = |
| 20 |
{ |
| 21 |
new : func (fg1000instance, EIS_Class, EIS_SVG, SVG_Path, myCanvas, device_id=1) |
| 22 |
{ |
| 23 |
var obj = { |
| 24 |
parents : [ PFDDisplay ], |
| 25 |
EIS : nil, |
| 26 |
PFDInstruments : nil, |
| 27 |
Surround : nil, |
| 28 |
NearestAirports : nil, |
| 29 |
_pageList : {}, |
| 30 |
_fg1000 : fg1000instance, |
| 31 |
_canvas : myCanvas, |
| 32 |
}; |
| 33 |
|
| 34 |
var nasal_dir = getprop("/sim/fg-root") ~ "/Aircraft/Instruments-3d/FG1000/Nasal/"; |
| 35 |
io.load_nasal(nasal_dir ~ "MFDPages/PFDInstruments/PFDInstruments.nas", "fg1000"); |
| 36 |
io.load_nasal(nasal_dir ~ "MFDPages/PFDInstruments/PFDInstrumentsStyles.nas", "fg1000"); |
| 37 |
io.load_nasal(nasal_dir ~ "MFDPages/PFDInstruments/PFDInstrumentsOptions.nas", "fg1000"); |
| 38 |
io.load_nasal(nasal_dir ~ "MFDPages/PFDInstruments/PFDInstrumentsController.nas", "fg1000"); |
| 39 |
|
| 40 |
io.load_nasal(nasal_dir ~ "MFDPages/DirectTo/DirectTo.nas", "fg1000"); |
| 41 |
io.load_nasal(nasal_dir ~ "MFDPages/DirectTo/DirectToController.nas", "fg1000"); |
| 42 |
|
| 43 |
io.load_nasal(nasal_dir ~ "MFDPages/NearestAirportsPFD/NearestAirportsPFD.nas", "fg1000"); |
| 44 |
io.load_nasal(nasal_dir ~ "MFDPages/NearestAirportsPFD/NearestAirportsPFDStyles.nas", "fg1000"); |
| 45 |
io.load_nasal(nasal_dir ~ "MFDPages/NearestAirportsPFD/NearestAirportsPFDOptions.nas", "fg1000"); |
| 46 |
io.load_nasal(nasal_dir ~ "MFDPages/NearestAirportsPFD/NearestAirportsPFDController.nas", "fg1000"); |
| 47 |
|
| 48 |
obj.ConfigStore = obj._fg1000.getConfigStore(); |
| 49 |
|
| 50 |
obj._svg = myCanvas.createGroup("softkeys"); |
| 51 |
obj._svg.set("clip-frame", canvas.Element.LOCAL); |
| 52 |
obj._svg.set("clip", "rect(0px, 1024px, 768px, 0px)"); |
| 53 |
|
| 54 |
var fontmapper = func (family, weight) { |
| 55 |
#if( family == "Liberation Sans" and weight == "narrow" ) { |
| 56 |
return "LiberationFonts/LiberationSansNarrow-Regular.ttf"; |
| 57 |
#} |
| 58 |
# If we don't return anything the default font is used |
| 59 |
}; |
| 60 |
|
| 61 |
canvas.parsesvg(obj._svg, |
| 62 |
EIS_SVG, |
| 63 |
{'font-mapper': fontmapper}); |
| 64 |
|
| 65 |
|
| 66 |
canvas.parsesvg(obj._svg, |
| 67 |
SVG_Path ~ '/PFDInstruments.svg', |
| 68 |
{'font-mapper': fontmapper}); |
| 69 |
|
| 70 |
canvas.parsesvg(obj._svg, |
| 71 |
SVG_Path ~ '/FlightPlanPFD.svg', |
| 72 |
{'font-mapper': fontmapper}); |
| 73 |
|
| 74 |
|
| 75 |
canvas.parsesvg(obj._svg, |
| 76 |
SVG_Path ~ '/DirectToPFD.svg', |
| 77 |
{'font-mapper': fontmapper}); |
| 78 |
|
| 79 |
canvas.parsesvg(obj._svg, |
| 80 |
SVG_Path ~ '/NearestAirportsPFD.svg', |
| 81 |
{'font-mapper': fontmapper}); |
| 82 |
|
| 83 |
canvas.parsesvg(obj._svg, |
| 84 |
SVG_Path ~ '/NearestAirportsInfoPFD.svg', |
| 85 |
{'font-mapper': fontmapper}); |
| 86 |
|
| 87 |
canvas.parsesvg(obj._svg, |
| 88 |
SVG_Path ~ '/SurroundPFD.svg', |
| 89 |
{'font-mapper': fontmapper}); |
| 90 |
|
| 91 |
|
| 92 |
obj._MFDDevice = canvas.PFD_Device.new(obj._svg, 12, "SoftKey", myCanvas, "PFD"); |
| 93 |
obj._MFDDevice.device_id = device_id; |
| 94 |
|
| 95 |
# DirectTo "Page" loaded first so that it receives any Emesary notifications |
| 96 |
# _before_ the actual page. |
| 97 |
obj._DTO = fg1000.DirectTo.new(obj, myCanvas, obj._MFDDevice, obj._svg); |
| 98 |
obj._DTO.getController().RegisterWithEmesary(); |
| 99 |
|
| 100 |
obj.NearestAirports = fg1000.NearestAirportsPFD.new(obj, myCanvas, obj._MFDDevice, obj._svg); |
| 101 |
|
| 102 |
obj._MFDDevice.RegisterWithEmesary(); |
| 103 |
|
| 104 |
# Surround dynamic elements |
| 105 |
obj._pageTitle = obj._svg.getElementById("PageTitle"); |
| 106 |
|
| 107 |
# Controller for the header and display on the bottom left which allows selection |
| 108 |
# of page groups and individual pages using the FMS controller. |
| 109 |
obj.Surround = fg1000.Surround.new(obj, myCanvas, obj._MFDDevice, obj._svg, 1); |
| 110 |
obj.SurroundController = obj.Surround.getController(); |
| 111 |
|
| 112 |
obj.PFDInstruments = fg1000.PFDInstruments.new(obj, myCanvas, obj._MFDDevice, obj._svg); |
| 113 |
obj.addPage("PFDInstruments", obj.PFDInstruments); |
| 114 |
obj.PFDInstruments.topMenu(obj._MFDDevice, obj.PFDInstruments, nil); |
| 115 |
|
| 116 |
# Display the Surround, and PFD Instruments |
| 117 |
obj.Surround.setVisible(1); |
| 118 |
obj._MFDDevice.selectPage(obj.PFDInstruments); |
| 119 |
|
| 120 |
return obj; |
| 121 |
}, |
| 122 |
getDevice : func () { |
| 123 |
return me._MFDDevice; |
| 124 |
}, |
| 125 |
del: func() |
| 126 |
{ |
| 127 |
me._MFDDevice.current_page.offdisplay(); |
| 128 |
me._MFDDevice.DeRegisterWithEmesary(); |
| 129 |
me.SurroundController.del(); |
| 130 |
}, |
| 131 |
setPageTitle: func(title) |
| 132 |
{ |
| 133 |
me._pageTitle.setText(title); |
| 134 |
}, |
| 135 |
addPage : func(name, page) |
| 136 |
{ |
| 137 |
me._pageList[name] = page; |
| 138 |
}, |
| 139 |
|
| 140 |
getPage : func(name) |
| 141 |
{ |
| 142 |
return me._pageList[name]; |
| 143 |
}, |
| 144 |
|
| 145 |
getDeviceID : func() { |
| 146 |
return me._MFDDevice.device_id; |
| 147 |
}, |
| 148 |
|
| 149 |
getCanvas : func() { |
| 150 |
return me._canvas; |
| 151 |
} |
| 152 |
}; |