From da252c8a18fe2ce88066c051f6df588639377792 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Fri, 26 Jan 2018 19:06:06 +0000 Subject: [PATCH] Initial Direct To page - non-functional. --- .../Instruments-3d/FG1000/Models/DirectTo.svg | 617 ++++++++++++++++++ .../ActiveFlightPlanNarrow.nas | 6 +- .../ActiveFlightPlanWide.nas | 6 +- .../Nasal/AirportApproach/AirportApproach.nas | 6 +- .../Nasal/AirportArrival/AirportArrival.nas | 6 +- .../AirportDeparture/AirportDeparture.nas | 6 +- .../AirportDirectory/AirportDirectory.nas | 6 +- .../FG1000/Nasal/AirportInfo/AirportInfo.nas | 16 +- .../AirportInfo/AirportInfoController.nas | 22 +- .../Nasal/AirportWeather/AirportWeather.nas | 6 +- .../FG1000/Nasal/Checklist1/Checklist1.nas | 6 +- .../FG1000/Nasal/Checklist2/Checklist2.nas | 6 +- .../FG1000/Nasal/Checklist3/Checklist3.nas | 6 +- .../FG1000/Nasal/Checklist4/Checklist4.nas | 6 +- .../FG1000/Nasal/Checklist5/Checklist5.nas | 6 +- .../FG1000/Nasal/DirectTo/DirectTo.nas | 157 +++++ .../Nasal/DirectTo/DirectToController.nas | 240 +++++++ .../FG1000/Nasal/DirectTo/DirectToOptions.nas | 28 + .../FG1000/Nasal/DirectTo/DirectToStyles.nas | 28 + .../Instruments-3d/FG1000/Nasal/EIS/EIS.nas | 6 +- .../FlightPlanCatalog/FlightPlanCatalog.nas | 6 +- .../FG1000/Nasal/GPSStatus/GPSStatus.nas | 6 +- .../Nasal/Interfaces/NavDataInterface.nas | 25 +- .../IntersectionInfo/IntersectionInfo.nas | 6 +- Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas | 27 +- .../Instruments-3d/FG1000/Nasal/MFDPage.nas | 17 +- .../FG1000/Nasal/MFDPageController.nas | 18 +- .../FG1000/Nasal/NDBInfo/NDBInfo.nas | 6 +- .../Nasal/NavigationMap/NavigationMap.nas | 48 +- .../Nasal/NearestAirports/NearestAirports.nas | 18 +- .../NearestAirportsController.nas | 4 +- .../NearestAirspaces/NearestAirspaces.nas | 6 +- .../NearestFrequencies/NearestFrequencies.nas | 6 +- .../NearestIntersections.nas | 6 +- .../FG1000/Nasal/NearestNDB/NearestNDB.nas | 6 +- .../Nasal/NearestUserWPT/NearestUserWPT.nas | 6 +- .../FG1000/Nasal/NearestVOR/NearestVOR.nas | 6 +- .../StoredFlightPlan/StoredFlightPlan.nas | 6 +- .../FG1000/Nasal/Stormscope/Stormscope.nas | 6 +- .../FG1000/Nasal/Surround/Surround.nas | 16 +- .../Nasal/Surround/SurroundController.nas | 7 +- .../Nasal/SystemStatus/SystemStatus.nas | 6 +- .../FG1000/Nasal/TAWSB/TAWSB.nas | 6 +- .../Nasal/TemplatePage/TemplatePage.nas | 6 +- .../FG1000/Nasal/TrafficMap/TrafficMap.nas | 22 +- .../Nasal/TripPlanning/TripPlanning.nas | 6 +- .../FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas | 6 +- .../FG1000/Nasal/Utility/Utility.nas | 6 +- .../FG1000/Nasal/VORInfo/VORInfo.nas | 6 +- .../Nasal/WeatherDataLink/WeatherDataLink.nas | 6 +- .../FG1000/Nasal/XMInfo/XMInfo.nas | 6 +- .../FG1000/Nasal/XMRadio/XMRadio.nas | 6 +- Aircraft/Instruments-3d/FG1000/Nasal/gui.nas | 3 +- Nasal/canvas/MFD_Generic.nas | 7 + 54 files changed, 1340 insertions(+), 190 deletions(-) create mode 100644 Aircraft/Instruments-3d/FG1000/Models/DirectTo.svg create mode 100644 Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectTo.nas create mode 100644 Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToController.nas create mode 100644 Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToOptions.nas create mode 100644 Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToStyles.nas diff --git a/Aircraft/Instruments-3d/FG1000/Models/DirectTo.svg b/Aircraft/Instruments-3d/FG1000/Models/DirectTo.svg new file mode 100644 index 000000000..6f7eecdbb --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/Models/DirectTo.svg @@ -0,0 +1,617 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + IDENT, FACILITY, CITY + + MAP + + LOCATION + KSFO + SAN FRANCISCO INTERNATIONAL + CITY + REGION + K + S + F + O + DIRECT TO + + 00000 + + VNV + 0 + 0 + 0 + 0 + 0 + ft + - + 00 + 0 + 0 + BRG + 189 + 12.3 + DIS + + + COURSE + 000 + + ACTIVATE? + 0 + 0 + 0 + nm + nm + + Zoom nm + + NORTH UP + + + diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrow.nas b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrow.nas index c269e56c6..00e42116c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrow.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrow.nas @@ -12,7 +12,7 @@ var ActiveFlightPlanNarrow = obj.topMenu(device, obj, nil); - obj.controller = fg1000.ActiveFlightPlanNarrowController.new(obj, svg); + obj.setController(fg1000.ActiveFlightPlanNarrowController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var ActiveFlightPlanNarrow = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWide.nas b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWide.nas index 5ee89ef24..0245fceb0 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWide.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWide.nas @@ -12,7 +12,7 @@ var ActiveFlightPlanWide = obj.topMenu(device, obj, nil); - obj.controller = fg1000.ActiveFlightPlanWideController.new(obj, svg); + obj.setController(fg1000.ActiveFlightPlanWideController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var ActiveFlightPlanWide = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproach.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproach.nas index a710ae3ad..36c631e79 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproach.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproach.nas @@ -12,7 +12,7 @@ var AirportApproach = obj.topMenu(device, obj, nil); - obj.controller = fg1000.AirportApproachController.new(obj, svg); + obj.setController(fg1000.AirportApproachController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var AirportApproach = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrival.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrival.nas index 2a399b6c4..ff3f2d72c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrival.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrival.nas @@ -12,7 +12,7 @@ var AirportArrival = obj.topMenu(device, obj, nil); - obj.controller = fg1000.AirportArrivalController.new(obj, svg); + obj.setController(fg1000.AirportArrivalController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var AirportArrival = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDeparture.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDeparture.nas index 0e7e4efbf..b2c1fccb6 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDeparture.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDeparture.nas @@ -12,7 +12,7 @@ var AirportDeparture = obj.topMenu(device, obj, nil); - obj.controller = fg1000.AirportDepartureController.new(obj, svg); + obj.setController(fg1000.AirportDepartureController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var AirportDeparture = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectory.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectory.nas index 59bfc10fc..eedcd75d4 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectory.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectory.nas @@ -12,7 +12,7 @@ var AirportDirectory = obj.topMenu(device, obj, nil); - obj.controller = fg1000.AirportDirectoryController.new(obj, svg); + obj.setController(fg1000.AirportDirectoryController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var AirportDirectory = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfo.nas index 2709c161b..d993a6d48 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfo.nas @@ -40,10 +40,10 @@ var AirportInfo = # .size is the number of characters of data entry # .chars is the set of characters, used to scroll through using the small # FMS knob. - obj.airportEntry = PFD.DataEntryElement.new(obj.pageName, svg, "ID", "", 4, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + obj.airportEntry = PFD.DataEntryElement.new(obj.pageName, svg, "ID", "", 4, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); # TODO: Implement search by name - not currently supported. - # obj.airportNameEntry = PFD.DataEntryElement.new(obj.pageName, svg, "Name", ???, "ABCDEFGHIJKLMNOPQRSTUVWXYZ "); + # obj.airportNameEntry = PFD.DataEntryElement.new(obj.pageName, svg, "Name", ???, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "); obj.runwaySelect = PFD.ScrollElement.new(obj.pageName, svg, "Runway", ["36","18"]); # Dummy values @@ -62,7 +62,6 @@ var AirportInfo = # The Airport Chart obj.AirportChart = obj._group.createChild("map"); obj.AirportChart.setController("Static position", "main"); - var controller = obj.AirportChart.getController(); # Initialize a range and screen resolution. Setting a range # to 4nm means we pick up a good set of surrounding fixes @@ -86,8 +85,7 @@ var AirportInfo = type.vis ); } - - obj.controller = fg1000.AirportInfoController.new(obj, svg); + obj.setController(fg1000.AirportInfoController.new(obj, svg)); obj.topMenu(device, obj, nil); @@ -95,7 +93,8 @@ var AirportInfo = }, displayAirport : func(apt_info) { # Display a given airport - me.AirportChart.getController().setPosition(apt_info.lat,apt_info.lon); + me.AirportChart.getController().setPosition(apt_info.lat, apt_info.lon); + me.AirportChart.update(); me.airportEntry.setValue(apt_info.id); me.setTextElement("Usage", "PUBLIC"); me.setTextElement("Name", string.uc(apt_info.name)); @@ -183,6 +182,7 @@ var AirportInfo = setZoom : func(zoom, label) { # Set the zoom level for the airport chart display me.AirportChart.setScreenRange(zoom); + me.AirportChart.update(); me.setTextElement("Zoom", label); }, @@ -203,12 +203,12 @@ var AirportInfo = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, # Softkey menus topMenu : func(device, pg, menuitem) { diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfoController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfoController.nas index 0f8881f60..f4612af95 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfoController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfoController.nas @@ -189,8 +189,21 @@ var AirportInfoController = # Initial airport is our current location. # Needs to be done here as the data provider may not be set up when # we are created. - var current_apt = me.getAirport("airport"); - me.setAirport(current_apt.id); + + # Use Emesary to get the airport + var notification = notifications.PFDEventNotification.new( + "MFD", + 1, + notifications.PFDEventNotification.NavData, + {Id: "NearestAirports", Value: id}); + + var response = me._transmitter.NotifyAll(notification); + var retval = notification.EventParameter.Value; + + if ((! me._transmitter.IsFailed(response)) and (size(retval) > 0)) { + var current_apt = retval[0]; + me.setAirport(current_apt.id); + } } }, offdisplay : func() { @@ -206,9 +219,10 @@ var AirportInfoController = {Id: "AirportByID", Value: id}); var response = me._transmitter.NotifyAll(notification); + var retval = notification.EventParameter.Value; - if (! me._transmitter.IsFailed(response)) { - return notification.EventParameter.Value; + if ((! me._transmitter.IsFailed(response)) and (size(retval) > 0)) { + return retval[0]; } else { return nil; } diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeather.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeather.nas index 66596a61f..23d59eb03 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeather.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeather.nas @@ -12,7 +12,7 @@ var AirportWeather = obj.topMenu(device, obj, nil); - obj.controller = fg1000.AirportWeatherController.new(obj, svg); + obj.setController(fg1000.AirportWeatherController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var AirportWeather = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1.nas index 314b8ed9c..622e61d02 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1.nas @@ -12,7 +12,7 @@ var Checklist1 = obj.topMenu(device, obj, nil); - obj.controller = fg1000.Checklist1Controller.new(obj, svg); + obj.setController(fg1000.Checklist1Controller.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var Checklist1 = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2.nas index 58d6cbfb8..847da61b6 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2.nas @@ -12,7 +12,7 @@ var Checklist2 = obj.topMenu(device, obj, nil); - obj.controller = fg1000.Checklist2Controller.new(obj, svg); + obj.setController(fg1000.Checklist2Controller.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var Checklist2 = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3.nas index fb7eb61f1..c240da458 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3.nas @@ -12,7 +12,7 @@ var Checklist3 = obj.topMenu(device, obj, nil); - obj.controller = fg1000.Checklist3Controller.new(obj, svg); + obj.setController(fg1000.Checklist3Controller.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var Checklist3 = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4.nas index c935fd6bd..cff76f1bd 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4.nas @@ -12,7 +12,7 @@ var Checklist4 = obj.topMenu(device, obj, nil); - obj.controller = fg1000.Checklist4Controller.new(obj, svg); + obj.setController(fg1000.Checklist4Controller.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var Checklist4 = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5.nas index 002f096d7..63b28ee2a 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5.nas @@ -12,7 +12,7 @@ var Checklist5 = obj.topMenu(device, obj, nil); - obj.controller = fg1000.Checklist5Controller.new(obj, svg); + obj.setController(fg1000.Checklist5Controller.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var Checklist5 = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectTo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectTo.nas new file mode 100644 index 000000000..ce15cdd4d --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectTo.nas @@ -0,0 +1,157 @@ +# DirectTo page +# +# Technically this is supposed to be an overlay page, sitting on top of +# whatever page the user was on already. However, to simplify implementation, +# we will assume that the user was on the Map page, and simply display the +# NavigationMap page underneath. + +var DirectTo = +{ + new : func (mfd, myCanvas, device, svg) + { + var obj = { + parents : [ + DirectTo, + MFDPage.new(mfd, myCanvas, device, svg, "DirectTo", "DIRECT TO") + ], + symbols : {}, + }; + + obj.crsrIdx = 0; + + # Dynamic text elements in the SVG file. In the SVG these have an "DirectTo" prefix. + textelements = [ + "Name", + "City", + "Region", + "LocationBRG", + "LocationDIS", + "RangeDisplay" + ]; + + obj.addTextElements(textelements); + + obj._SVGGroup.setInt("z-index", 9); + + # Data Entry information. Keyed from the name of the element, which must + # be one of the textelements above. Each data element maps to a set of + # text elements in the SVG of the form [PageName][TextElement]{0...n}, each + # representing a single character for data entry. + # + # .size is the number of characters of data entry + # .chars is the set of characters, used to scroll through using the small + # FMS knob. + obj.IDEntry = PFD.DataEntryElement.new(obj.pageName, svg, "ID", "", 4, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + obj.VNVAltEntry = PFD.DataEntryElement.new(obj.pageName, svg, "VNVAlt", "", 5, "0123456789"); + obj.VNVOffsetEntry = PFD.DataEntryElement.new(obj.pageName, svg, "VNVOffset", "", 2, "0123456789"); + obj.CourseEntry = PFD.DataEntryElement.new(obj.pageName, svg, "Course", "", 3, "0123456789"); + obj.Activate = PFD.TextElement.new(obj.pageName, svg, "Activate", "ACTIVATE"); + + # The Airport Chart + obj.DirectToChart = obj._group.createChild("map"); + obj.DirectToChart.setInt("z-index", 100); + + obj.DirectToChart.setController("Static position", "main"); + + + # Initialize a range and screen resolution. Setting a range + # to 15nm means we pick up a good set of surrounding fixes + # We will use the screen range for zooming. + obj.DirectToChart.setRange(8.0); + obj.DirectToChart.setScreenRange(300/2.0); + obj.DirectToChart.setTranslation(1045, 485); + obj.DirectToChart.set("clip-frame", canvas.Element.LOCAL); + obj.DirectToChart.set("clip", "rect(-160px, 160px, 160px, -160px)"); + + var r = func(name,vis=1,zindex=nil) return caller(0)[0]; + foreach(var type; [r('APT'),r('DME'),r('VOR'),r('NDB'),r('FIX')] ) { + obj.DirectToChart.addLayer(canvas.SymbolLayer, + type.name, + 10, + obj.Styles.getStyle(type.name), + obj.Options.getOption(type.name), + type.vis ); + } + + foreach(var type; [ r('STAMEN')]) { + obj.DirectToChart.addLayer(factory: canvas.OverlayLayer, type_arg: type.name, + priority: 9, + style: obj.Styles.getStyle(type.name), + options: obj.Options.getOption(type.name), + visible: 1); + } + + + + obj.setController(fg1000.DirectToController.new(obj, svg)); + return obj; + }, + displayDestination : func(destination) { + + if (destination != nil) { + # Display a given location + debug.dump(destination); + me.DirectToChart.setVisible(1); + me.DirectToChart.getController().setPosition(destination.lat,destination.lon); + me.setTextElement("Name", string.uc(destination.name)); + me.setTextElement("City", "CITY"); + me.setTextElement("Region", "REGION"); + me.setTextElement("LocationBRG", "" ~ sprintf("%03d", destination.course)); + me.setTextElement("LocationDIS", sprintf("%d", destination.range_nm) ~ "nm"); + + me.IDEntry.setValue(destination.id); + me.VNVAltEntry.setValue("00000"); + me.VNVOffsetEntry.setValue("00"); + me.CourseEntry.setValue("" ~ sprintf("%03d", destination.course)); + } else { + me.DirectToChart.setVisible(1); + me.setTextElement("Name", ""); + me.setTextElement("City", ""); + me.setTextElement("Region", ""); + me.setTextElement("LocationBRG", "_"); + me.setTextElement("LocationDIS", "_"); + + me.IDEntry.setValue("____"); + me.VNVAltEntry.setValue("00000"); + me.VNVOffsetEntry.setValue("00"); + me.CourseEntry.setValue(0); + } + }, + setRange : func(range, label) { + me.DirectToChart.setRange(range); + me.DirectToChart.update(); + me.setTextElement("RangeDisplay", label); + }, + # Clear any cursor, highlights. Used when exiting from CRSR mode + resetCRSR : func() { + me.airportEntry.unhighlightElement(); + me.runwaySelect.unhighlightElement(); + me.freqSelect.hideCRSR(); + }, + + offdisplay : func() { + me._group.setVisible(0); + me.getController().offdisplay(); + me.mfd.NavigationMap.offdisplay(0); + }, + ondisplay : func() { + me._group.setVisible(1); + # Display a false title, as underneath we're showing the navigation map. + me.mfd.setPageTitle("MAP - NAVIGATION MAP"); + me.getController().ondisplay(); + + # The DirectTo pages displays over the NavigationMap. This is a hack + # as the page should just magically sit ontop of whatever page the user was + # on. However, we also need to disable the NavMap's own controller so there's + # no confusion. + me.mfd.NavigationMap.ondisplay(0); + }, + + # When the Direct To display is enabled, nothing is displayed on the softkeys. + topMenu : func(device, pg, menuitem) { + pg.clearMenu(); + pg.resetMenuColors(); + device.updateMenus(); + }, + +}; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToController.nas new file mode 100644 index 000000000..dbb199e45 --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToController.nas @@ -0,0 +1,240 @@ +# DirectTo Controller +var DirectToController = +{ + # Vertical ranges, and labels. + # Unlike some other map displays, we keep the range constant at 4nm an change + # the ScreenRange to zoom in. Otherwise as we zoom in, the center of the + # runways moves out of the range of the display and they are not drawn. + # Ranges are scaled to the display height with range 1 displaying 4nm vertically. + # 2000nm = 12,152,000ft. + RANGES : [{range: 500/6076.12, label: "500ft"}, + {range: 750/6076.12, label: "750ft"}, + {range: 1000/6076.12, label: "1000ft"}, + {range: 1500/6076.12, label: "1500ft"}, + {range: 2000/6076.12, label: "2000ft"}, + {range: 0.5, label: "0.5nm"}, + {range: 0.75, label: "0.75nm"}, + {range: 1, label: "1nm"}, + {range: 2, label: "2nm"}, + {range: 3, label: "3nm"}, + {range: 4, label: "4nm"}, + {range: 6, label: "6nm"}, + {range: 8, label: "8nm"}, + {range: 10, label: "10nm"}, + {range: 12, label: "12nm"}, + {range: 15, label: "15nm"}, + {range: 20, label: "20nm"}, + {range: 25, label: "25nm"}, + {range: 30, label: "30nm"}, + {range: 40, label: "40nm"}, + {range: 50, label: "50nm"}, + {range: 75, label: "75nm"}, + {range: 100, label: "100nm"}, + {range: 200, label: "200nm"}, + {range: 500, label: "500nm"}, + {range: 1000, label: "1000nm"}, + {range: 1500, label: "1500nm"}, + {range: 2000, label: "2000nm"}, ], + + new : func (page, svg) + { + var obj = { parents : [ DirectToController, MFDPageController.new(page)] }; + obj.id = ""; + obj.page = page; + obj.current_zoom = 7; + + obj.setZoom(obj.current_zoom); + + obj._cursorElements = [ + obj.page.IDEntry, + obj.page.VNVAltEntry, + obj.page.VNVOffsetEntry, + obj.page.CourseEntry, + obj.page.Activate + ]; + + # -1 indicates nothing selected at present + obj._selectedElement = -1; + + return obj; + }, + + setCursorElement : func(value) { + + if (me._selectedElement != -1) { + # Unhighlight the current element, if one is highlighted + me._cursorElements[me._selectedElement ].unhighlightElement(); + } + + if (value < 0) value = 0; + if (value > (size(me._cursorElements) -1)) value = size(me._cursorElements) -1; + me._selectedElement = value; + me._cursorElements[me._selectedElement].highlightElement(); + }, + + nextCursorElement : func(value) { + var incr_or_decr = (value > 0) ? 1 : -1; + me.setCursorElement(me._selectedElement + incr_or_decr); + }, + + # Control functions for Input + zoomIn : func() { + me.setZoom(me.current_zoom -1); + }, + zoomOut : func() { + me.setZoom(me.current_zoom +1); + }, + handleRange : func(val) + { + var incr_or_decr = (val > 0) ? 1 : -1; + me.setZoom(me.current_zoom + incr_or_decr); + }, + setZoom : func(zoom) { + if ((zoom < 0) or (zoom > (size(me.RANGES) - 1))) return; + me.current_zoom = zoom; + me.page.setRange(me.RANGES[zoom].range, me.RANGES[zoom].label); + }, + handleCRSR : func() { + # No effect, but shouldn't be passed to underlying page? + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._selectedElement == -1) { + # TODO: handle display of waypoint submenu on anti-clockwise initial rotation! + # If no element is selected, then the inner FMS knob selects the ID field + me.nextCursorElement(1); + } + + me._cursorElements[me._selectedElement].incrSmall(value); + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSOuter : func(value) { + if (me._selectedElement == -1) { + # If no element is selected, then the Outer FMS knob has no effect + return emesary.Transmitter.ReceiptStatus_Finished; + } + + if (me._cursorElements[me._selectedElement].isInEdit()) { + me._cursorElements[me._selectedElement].incrLarge(value); + } else { + me.nextCursorElement(value); + } + + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleEnter : func(value) { + if (me._selectedElement == -1) { + # If no element is selected, then the ENT key has no effect + return emesary.Transmitter.ReceiptStatus_Finished; + } + + # If we're on the Activate button, then set up the DirectTo and hide the + # page. We're finished + if (me._cursorElements[me._selectedElement] == me.page.Activate) { + var mappage = me._page.getMFD().getPage("NavigationMap"); + assert(mappage != nil, "Unable to find NavigationMap page"); + me._page.getDevice().selectPage(mappage); + return emesary.Transmitter.ReceiptStatus_Finished; + } + + # If we're editing an element, complete the data entry. + if (me._cursorElements[me._selectedElement].isInEdit()) { + me._cursorElements[me._selectedElement].enterElement(); + } + + if (me._cursorElements[me._selectedElement] == me.page.IDEntry) { + # We've finished entering an ID, so load it. + var destination = me.getDestination(me.page.IDEntry.getValue()); + if (destination != nil) { + + # set the course and distance to the destination if required + var (course, dist) = courseAndDistance(destination); + var d = { + id: destination.id, + name: destination.name, + lat: destination.lat, + lon: destination.lon, + course : course, + range_nm : dist, + }; + me.page.displayDestination(d); + } + } + + # Determine where to highlight next. In most cases, we go straight to ACTIVATE. + # The exception is the VNV Alt field which goes to the VNV Distance field; + if (me._cursorElements[me._selectedElement] == me.page.VNVAltEntry) { + # VNV DIS entry is the next element + me.nextCursorElement(1); + } else { + # ACTIVATE is the last element of the group + me.setCursorElement(size(me._cursorElements) - 1); + } + + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleClear : func(value) { + var mappage = me._page.getMFD().getPage("NavigationMap"); + assert(mappage != nil, "Unable to find NavigationMap page"); + me._page.getDevice().selectPage(mappage); + return emesary.Transmitter.ReceiptStatus_Finished; + }, + + handleSoftKey : func(key) { + # DirectTo has no softkeys, but if the user presses one from the underlying + # page we should switch outselves off. + me.page.setVisible(0); + return emesary.Transmitter.ReceiptStatus_OK; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + for (var i = 0; i < size(me._cursorElements); i = i+1) { + me._cursorElements[i].unhighlightElement(); + } + + me.setCursorElement(0); + + me.page.IDEntry.setValue("KHAF"); + + var destination = me.getDestination(me.page.IDEntry.getValue()); + if (destination != nil) { + + # set the course and distance to the destination if required + var (course, dist) = courseAndDistance(destination); + var d = { + id: destination.id, + name: destination.name, + lat: destination.lat, + lon: destination.lon, + course : course, + range_nm : dist, + }; + me.page.displayDestination(d); + } + + + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + + getDestination : func(id) { + # Use Emesary to get the destination + var notification = notifications.PFDEventNotification.new( + "MFD", + 1, + notifications.PFDEventNotification.NavData, + {Id: "NavDataByID", Value: id}); + + var response = me._transmitter.NotifyAll(notification); + var retval = notification.EventParameter.Value; + + if ((! me._transmitter.IsFailed(response)) and (size(retval) > 0)) { + return retval[0]; + } else { + return nil; + } + }, +}; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToOptions.nas b/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToOptions.nas new file mode 100644 index 000000000..a3ac03ee6 --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToOptions.nas @@ -0,0 +1,28 @@ +# DirectTo Options +var DirectToOptions = +{ + new : func() { + var obj = { parents : [DirectToOptions] }; + obj.Options= {}; + obj.loadOptions(); + return obj; + }, + + getOption : func(type) { + return me.Options[type]; + }, + + setOption : func(type, name, value) { + me.Options[type][name] = value; + }, + + loadOptions : func() { + me.clearOptions(); + me.Options.APS = {}; + }, + + clearOptions : func() { + me.Options = {}; + }, + +}; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToStyles.nas b/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToStyles.nas new file mode 100644 index 000000000..53e2cce92 --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/Nasal/DirectTo/DirectToStyles.nas @@ -0,0 +1,28 @@ +# DirectTo Styles +var DirectToStyles = +{ + new : func() { + var obj = { parents : [ DirectToStyles ]}; + obj.Styles = {}; + obj.loadStyles(); + return obj; + }, + + getStyle : func(type) { + return me.Styles[type]; + }, + + setStyle : func(type, name, value) { + me.Styles[type][name] = value; + }, + + loadStyles : func() { + me. clearStyles(); + me.Styles.XXX = {}; + }, + + clearStyles : func() { + me.Styles = {}; + }, + +}; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/EIS/EIS.nas b/Aircraft/Instruments-3d/FG1000/Nasal/EIS/EIS.nas index 7942dc373..4bba6adce 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/EIS/EIS.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/EIS/EIS.nas @@ -10,7 +10,7 @@ var EIS = ], }; - obj.controller = fg1000.EISController.new(obj, svg); + obj.setController(fg1000.EISController.new(obj, svg)); obj.addTextElements(["RPMDisplay", "MBusVolts", "EBusVolts", "EngineHours"]); @@ -109,11 +109,11 @@ var EIS = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); - me.controller.ondisplay(); + me.getController().ondisplay(); }, diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalog.nas b/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalog.nas index 0b47192f8..b88e329b9 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalog.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalog.nas @@ -12,7 +12,7 @@ var FlightPlanCatalog = obj.topMenu(device, obj, nil); - obj.controller = fg1000.FlightPlanCatalogController.new(obj, svg); + obj.setController(fg1000.FlightPlanCatalogController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var FlightPlanCatalog = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatus.nas b/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatus.nas index d050a87e2..0d49c55fa 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatus.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatus.nas @@ -12,7 +12,7 @@ var GPSStatus = obj.topMenu(device, obj, nil); - obj.controller = fg1000.GPSStatusController.new(obj, svg); + obj.setController(fg1000.GPSStatusController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var GPSStatus = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/NavDataInterface.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/NavDataInterface.nas index ef85254ad..13ef1341d 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/NavDataInterface.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/NavDataInterface.nas @@ -37,13 +37,29 @@ getNearestAirports : func() return apts; }, -# Find a specific airport by ID +# Find a specific airport by ID. Return an array of airport objects getAirportById : func(id) { - var apt = airportinfo(id); + var apt = findAirportsByICAO(id, "airport"); return apt; }, +# Find an arbritrary piece of nav data by ID. This searches based on the +# current location and returns an array of objects that match the id. +getNavDataById : func (id) +{ + # Check for airport first + var navdata = findAirportsByICAO(id, "airport"); + + # Check for Navaids. + if (size(navdata) == 0) navdata = findNavaidsByID(id); + + # Check for fix. + if (size(navdata) == 0) navdata = findFixesByID(id); + + return navdata; +}, + RegisterWithEmesary : func() { if (me._recipient == nil){ @@ -68,6 +84,11 @@ RegisterWithEmesary : func() notification.EventParameter.Value = apt; return emesary.Transmitter.ReceiptStatus_Finished; } + if (id == "NavDataByID") { + var navdata = controller.getNavDataById(notification.EventParameter.Value); + notification.EventParameter.Value = navdata; + return emesary.Transmitter.ReceiptStatus_Finished; + } } } return emesary.Transmitter.ReceiptStatus_NotProcessed; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfo.nas index d14a31e7b..39a07343a 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfo.nas @@ -12,7 +12,7 @@ var IntersectionInfo = obj.topMenu(device, obj, nil); - obj.controller = fg1000.IntersectionInfoController.new(obj, svg); + obj.setController(fg1000.IntersectionInfoController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var IntersectionInfo = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas index 2682546b6..aba5f35e9 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas @@ -52,7 +52,8 @@ var MFDPages = [ "NearestVOR", "NearestUserWPT", "NearestFrequencies", - "NearestAirspaces" + "NearestAirspaces", + "DirectTo", # display at the top of the stack ]; foreach (var page; MFDPages) { @@ -71,6 +72,7 @@ var MFD = EIS : nil, NavigationMap: nil, Surround : nil, + _pageList : {} }; obj.ConfigStore = fg1000.ConfigStore.new(); @@ -109,18 +111,22 @@ var MFD = # Controller for the header and display on the bottom left which allows selection # of page groups and individual pages using the FMS controller. obj.Surround = fg1000.Surround.new(obj, myCanvas, obj._MFDDevice, obj._svg); - obj.SurroundController = obj.Surround.controller; + obj.SurroundController = obj.Surround.getController(); # Engine Information System. A special case as it's always displayed on the MFD. - obj.EIS = obj.Surround.addPage("EIS", fg1000.EIS.new(obj, myCanvas, obj._MFDDevice, obj._svg)); + obj.EIS = fg1000.EIS.new(obj, myCanvas, obj._MFDDevice, obj._svg); + obj.addPage("EIS", obj.EIS); # The NavigationMap page is a special case, as it is displayed with the Nearest... pages as an overlay - obj.NavigationMap = obj.Surround.addPage("NavigationMap", fg1000.NavigationMap.new(obj, myCanvas, obj._MFDDevice, obj._svg)); + obj.NavigationMap = fg1000.NavigationMap.new(obj, myCanvas, obj._MFDDevice, obj._svg); + obj.addPage("NavigationMap", obj.NavigationMap); obj.NavigationMap.topMenu(obj._MFDDevice, obj.NavigationMap, nil); + # Now load the other pages normally; foreach (var page; MFDPages) { if ((page != "NavigationMap") and (page != "EIS")) { - var code = "obj.Surround.addPage(\"" ~ page ~ "\", fg1000." ~ page ~ ".new(obj, myCanvas, obj._MFDDevice, obj._svg));"; + #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));"; var addPageFn = compile(code); addPageFn(); } @@ -147,5 +153,14 @@ var MFD = setPageTitle: func(title) { me._pageTitle.setText(title); - } + }, + addPage : func(name, page) + { + me._pageList[name] = page; + }, + + getPage : func(name) + { + return me._pageList[name]; + }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas index 224ecf4a5..7a8784fc4 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas @@ -25,6 +25,7 @@ new : func (mfd, myCanvas, device, SVGGroup, pageName, title) _SVGGroup : SVGGroup, parents : [ MFDPage, device.addPage(title, pageName ~ "Group") ], _symbols : {}, + _controller : nil, }; obj.device = device; @@ -37,7 +38,7 @@ new : func (mfd, myCanvas, device, SVGGroup, pageName, title) createStylesAndOptions(); # Need to display this underneath the softkeys, EIS, header. - obj._group.set("z-index", -10.0); + obj._group.setInt("z-index", -10.0); obj._group.setVisible(0); return obj; @@ -75,4 +76,18 @@ resetMenuColors : func() { } }, +getController : func() { + return me._controller; +}, +setController : func (controller) { + me._controller = controller; +}, + +getDevice : func() { + return me.device; +}, +getMFD : func() { + return me.mfd; +}, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPageController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPageController.nas index 94959acea..eaf52aa52 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPageController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPageController.nas @@ -52,10 +52,23 @@ handleComFreqTransferHold : func (value) { return me.page.mfd.SurroundController handleComVol : func (value) { return me.page.mfd.SurroundController.handleComVol(value); }, handleComVolToggle : func (value) { return me.page.mfd.SurroundController.handleComVolToggle(value); }, -handleDTO : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; }, +# DTO button brings up the DirectTo Page. +handleDTO : func (value) { + var dtopage = me._page.getMFD().getPage("DirectTo"); + assert(dtopage != nil, "Unable to find the DirectTo page."); + me._page.getDevice().selectPage(dtopage); + return emesary.Transmitter.ReceiptStatus_Finished; +}, handleFPL : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; }, handleClear : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; }, -handleClearHold : func (value) { return me.page.mfd.SurroundController.handleClearHold(value); }, + +# Holding the Clear button goes straight to the Navigation Map page. +handleClearHold : func (value) { + var mappage = me._page.getMFD().getPage("NavigationMap"); + assert(mappage != nil, "Unable to find NavigationMap page"); + me._page.getDevice().selectPage(mappage); + return emesary.Transmitter.ReceiptStatus_Finished; +}, # By default, the FMS knobs will select a new page. handleFMSOuter : func (value) { return me.page.mfd.SurroundController.handleFMSOuter(value); }, @@ -153,7 +166,6 @@ RegisterWithEmesary : func() me._transmitter.Register(me._recipient); me._registered = 1; - }, DeRegisterWithEmesary : func() diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfo.nas index c0b17c46f..08ad929df 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfo.nas @@ -12,7 +12,7 @@ var NDBInfo = obj.topMenu(device, obj, nil); - obj.controller = fg1000.NDBInfoController.new(obj, svg); + obj.setController(fg1000.NDBInfoController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var NDBInfo = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMap.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMap.nas index 20edc6cb0..71101c923 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMap.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMap.nas @@ -56,22 +56,28 @@ var NavigationMap = var r = func(name,vis=1,zindex=nil) return caller(0)[0]; # TODO: we'll need some z-indexing here, right now it's just random foreach(var type; [r('GRID'),r('DTO',0),r('TFC',0),r('APT'),r('DME'),r('VOR'),r('NDB'),r('FIX',0),r('RTE'),r('WPT'),r('FLT'),r('WXR',0),r('APS')] ) { - obj.MFDMap.addLayer(factory: canvas.SymbolLayer, type_arg: type.name, - visible: type.vis, priority: 4, - style: obj.Styles.getStyle(type.name), - options: obj.Options.getOption(type.name) ); + obj.MFDMap.addLayer( + factory: canvas.SymbolLayer, + type_arg: type.name, + priority: 4, + style: obj.Styles.getStyle(type.name), + options: obj.Options.getOption(type.name), + visible: type.vis); } foreach(var type; [ r('STAMEN_terrain'),r('STAMEN'), r('OpenAIP') ]) { - obj.MFDMap.addLayer(factory: canvas.OverlayLayer, type_arg: type.name, - visible: 0, priority: 1, - style: obj.Styles.getStyle(type.name), - options: obj.Options.getOption(type.name) ); + obj.MFDMap.addLayer( + factory: canvas.OverlayLayer, + type_arg: type.name, + priority: 1, + style: obj.Styles.getStyle(type.name), + options: obj.Options.getOption(type.name), + visible: 0); } #obj.topMenu(device, obj, nil); - obj.controller = fg1000.NavigationMapController.new(obj, svg); + obj.setController(fg1000.NavigationMapController.new(obj, svg)); return obj; }, @@ -93,7 +99,7 @@ var NavigationMap = setScreenRange : func(range) { me.MFDMap.setScreenRange(range); }, - offdisplay : func() { + offdisplay : func(controller=1) { me._group.setVisible(0); # Reset the menu colours. Shouldn't have to do this here, but @@ -103,9 +109,9 @@ var NavigationMap = 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); } - me.controller.offdisplay(); + if (controller == 1) me.getController().offdisplay(); }, - ondisplay : func() { + ondisplay : func(controller=1) { me._group.setVisible(1); # Center the map's origin, modified to take into account the surround. @@ -118,7 +124,7 @@ var NavigationMap = me._labelsPartial.setVisible(0); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + if (controller == 1) me.getController().ondisplay(); }, # Display functions when we're displaying the NavigationMap as part of another @@ -133,11 +139,11 @@ var NavigationMap = me._labelsFull.setVisible(0); me._labelsPartial.setVisible(1); - #me.controller.ondisplayPartial(); + #me.getController().ondisplayPartial(); }, offdisplayPartial : func() { me._group.setVisible(0); - #me.controller.offdisplayPartial(); + #me.getController().offdisplayPartial(); }, # Softkey assigments. For some pages (notably the NEAREST pages) @@ -150,7 +156,7 @@ var NavigationMap = pg.resetMenuColors(); pg.addMenuItem(0, "ENGINE", pg, pg.mfd.EIS.engineMenu); pg.addMenuItem(2, "MAP", pg, pg.mfd.NavigationMap.mapMenu); - pg.addMenuItem(8, "DCLTR", pg, func(dev, pg, mi) { pg.mfd.NavigationMap.controller.incrDCLTR(dev, mi); } ); + pg.addMenuItem(8, "DCLTR", pg, func(dev, pg, mi) { pg.getController().incrDCLTR(dev, mi); } ); #pg.addMenuItem(9, "SHW CHRT", pg); # Optional #pg.addMenuItem(10, "CHKLIST", pg); # Optional device.updateMenus(); @@ -160,22 +166,22 @@ var NavigationMap = pg.clearMenu(); pg.resetMenuColors(); pg.addMenuItem(0, "TRAFFIC", pg, - func(dev, pg, mi) { pg.mfd.NavigationMap.controller.toggleLayer("TFC"); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().toggleLayer("TFC"); device.updateMenus(); }, # callback func(svg, mi) { pg.mfd.NavigationMap.display_toggle(device, svg, mi, "TFC"); } ); pg.addMenuItem(1, "PROFILE", pg); pg.addMenuItem(2, "TOPO", pg, - func(dev, pg, mi) { pg.mfd.NavigationMap.controller.toggleLayer("STAMEN"); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().toggleLayer("STAMEN"); device.updateMenus(); }, # callback func(svg, mi) { pg.mfd.NavigationMap.display_toggle(device, svg, mi, "STAMEN"); } ); pg.addMenuItem(3, "TERRAIN", pg, - func(dev, pg, mi) { pg.mfd.NavigationMap.controller.toggleLayer("STAMEN_terrain"); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().toggleLayer("STAMEN_terrain"); device.updateMenus(); }, # callback func(svg, mi) { pg.mfd.NavigationMap.display_toggle(device, svg, mi, "STAMEN_terrain"); } ); - pg.addMenuItem(4, "AIRWAYS", pg, func(dev, pg, mi) { pg.mfd.NavigationMap.controller.incrAIRWAYS(dev, mi); } ); + pg.addMenuItem(4, "AIRWAYS", pg, func(dev, pg, mi) { pg.getController().incrAIRWAYS(dev, mi); } ); #pg.addMenuItem(5, "STRMSCP", pg); Optional #pg.addMenuItem(6, "PRECIP", pg); Optional, or NEXRAD #pg.addMenuItem(7, "XM LTNG", pg); Optional, or DL LTNG @@ -189,7 +195,7 @@ var NavigationMap = # 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); - if (me.controller.isEnabled(layer)) { + if (me.getController().isEnabled(layer)) { device.svg.getElementById(bg_name).setColorFill(0.5,0.5,0.5); svg.setColor(0.0,0.0,0.0); } else { diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirports.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirports.nas index 511e840ca..20c32ed83 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirports.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirports.nas @@ -10,7 +10,7 @@ var NearestAirports = ], }; - obj.controller = fg1000.NearestAirportsController.new(obj, svg); + obj.setController(fg1000.NearestAirportsController.new(obj, svg)); # Dynamic elements. There are 4 different sets of dynamic elements: # @@ -70,7 +70,7 @@ var NearestAirports = # Indicate which group is selected by colour of the softkeys display_toggle : func(device, svg, mi, group) { var bg_name = sprintf("SoftKey%d-bg",mi.menu_id); - if (me.controller.getSelectedGroup() == group) { + if (me.getController().getSelectedGroup() == group) { device.svg.getElementById(bg_name).setColorFill(0.5,0.5,0.5); svg.setColor(0.0,0.0,0.0); } else { @@ -107,10 +107,10 @@ var NearestAirports = # there's not currently an obvious other location to do so. me.resetMenuColors(); - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { - me.controller.ondisplay(); + me.getController().ondisplay(); # The Nearest... pages use the underlying navigation map. me.mfd.NavigationMap.ondisplayPartial(); @@ -212,7 +212,7 @@ var NearestAirports = me.approachSelect.setValues(approachList); # Display the DTO line to the airport - me.mfd.NavigationMap.controller.setDTOLineTarget(apt.lat, apt.lon); + me.mfd.NavigationMap.getController().setDTOLineTarget(apt.lat, apt.lon); }, updateRunwayInfo : func(rwy_info) { if (rwy_info != nil ) { @@ -243,22 +243,22 @@ var NearestAirports = pg.addMenuItem(0, "ENGINE", pg, pg.mfd.EIS.engineMenu); pg.addMenuItem(2, "MAP", pg, pg.mfd.NavigationMap.mapMenu); pg.addMenuItem(4, "APT", pg, - func(dev, pg, mi) { pg.controller.selectAirports(); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().selectAirports(); device.updateMenus(); }, # callback func(svg, mi) { pg.display_toggle(device, svg, mi, NearestAirportsController.UIGROUP.APT); } ); pg.addMenuItem(5, "RNWY", pg, - func(dev, pg, mi) { pg.controller.selectRunways(); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().selectRunways(); device.updateMenus(); }, # callback func(svg, mi) { pg.display_toggle(device, svg, mi, NearestAirportsController.UIGROUP.RNWY); } ); pg.addMenuItem(6, "FREQ", pg, - func(dev, pg, mi) { pg.controller.selectFrequencies(); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().selectFrequencies(); device.updateMenus(); }, # callback func(svg, mi) { pg.display_toggle(device, svg, mi, NearestAirportsController.UIGROUP.FREQ); } ); pg.addMenuItem(7, "APR", pg, - func(dev, pg, mi) { pg.controller.selectApproaches(); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().selectApproaches(); device.updateMenus(); }, # callback func(svg, mi) { pg.display_toggle(device, svg, mi, NearestAirportsController.UIGROUP.APR); } ); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirportsController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirportsController.nas index c4a90f674..83d561b51 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirportsController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirportsController.nas @@ -168,10 +168,10 @@ var NearestAirportsController = me._currentGroup = NearestAirportsController.UIGROUP.NONE; me.RegisterWithEmesary(); me.getAirports(); - me.page.mfd.NavigationMap.controller.enableDTO(1); + me.page.mfd.NavigationMap.getController().enableDTO(1); }, offdisplay : func() { - me.page.mfd.NavigationMap.controller.enableDTO(0); + me.page.mfd.NavigationMap.getController().enableDTO(0); me.DeRegisterWithEmesary(); }, diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspaces.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspaces.nas index 8d23f4657..3c2c2fce4 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspaces.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspaces.nas @@ -12,7 +12,7 @@ var NearestAirspaces = obj.topMenu(device, obj, nil); - obj.controller = fg1000.NearestAirspacesController.new(obj, svg); + obj.setController(fg1000.NearestAirspacesController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var NearestAirspaces = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequencies.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequencies.nas index 6fe93fb27..c6507a565 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequencies.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequencies.nas @@ -12,7 +12,7 @@ var NearestFrequencies = obj.topMenu(device, obj, nil); - obj.controller = fg1000.NearestFrequenciesController.new(obj, svg); + obj.setController(fg1000.NearestFrequenciesController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var NearestFrequencies = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersections.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersections.nas index 8cc203b35..048a23e73 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersections.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersections.nas @@ -12,7 +12,7 @@ var NearestIntersections = obj.topMenu(device, obj, nil); - obj.controller = fg1000.NearestIntersectionsController.new(obj, svg); + obj.setController(fg1000.NearestIntersectionsController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var NearestIntersections = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDB.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDB.nas index 1d5defba2..705bf9422 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDB.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDB.nas @@ -12,7 +12,7 @@ var NearestNDB = obj.topMenu(device, obj, nil); - obj.controller = fg1000.NearestNDBController.new(obj, svg); + obj.setController(fg1000.NearestNDBController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var NearestNDB = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPT.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPT.nas index 00c1d617f..46a463992 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPT.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPT.nas @@ -12,7 +12,7 @@ var NearestUserWPT = obj.topMenu(device, obj, nil); - obj.controller = fg1000.NearestUserWPTController.new(obj, svg); + obj.setController(fg1000.NearestUserWPTController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var NearestUserWPT = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVOR.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVOR.nas index 62aed5fad..ef71a9bec 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVOR.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVOR.nas @@ -12,7 +12,7 @@ var NearestVOR = obj.topMenu(device, obj, nil); - obj.controller = fg1000.NearestVORController.new(obj, svg); + obj.setController(fg1000.NearestVORController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var NearestVOR = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlan.nas b/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlan.nas index af3197424..6a6d1759f 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlan.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlan.nas @@ -12,7 +12,7 @@ var StoredFlightPlan = obj.topMenu(device, obj, nil); - obj.controller = fg1000.StoredFlightPlanController.new(obj, svg); + obj.setController(fg1000.StoredFlightPlanController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var StoredFlightPlan = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/Stormscope.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/Stormscope.nas index 58cdd3e5f..f5a61a1c2 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/Stormscope.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/Stormscope.nas @@ -12,7 +12,7 @@ var Stormscope = obj.topMenu(device, obj, nil); - obj.controller = fg1000.StormscopeController.new(obj, svg); + obj.setController(fg1000.StormscopeController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var Stormscope = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Surround/Surround.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Surround/Surround.nas index a541f623a..54e43a725 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Surround/Surround.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Surround/Surround.nas @@ -99,8 +99,6 @@ var Surround = obj._selectedPageGroup = 0; obj._selectedPage = 0; - # List of pages to be controllers. Keys are the pages in PAGE_GROUPS; - obj._pageList = {}; obj._elements = {}; foreach (var pageGroup; PAGE_GROUPS) { @@ -128,7 +126,7 @@ var Surround = obj.hideMenu(); - obj.controller = fg1000.SurroundController.new(obj, svg); + obj.setController(fg1000.SurroundController.new(obj, svg)); return obj; }, @@ -241,21 +239,17 @@ var Surround = } }, - addPage : func(name, page) + getCurrentPage : func() { - me._pageList[name] = page; - }, - - getPage : func(name) - { - return me._pageList[name]; + var currentpage = PAGE_GROUPS[me._selectedPageGroup].pages[me._selectedPage]; + return me.getMFD().getPage(currentpage); }, # Function to change a page based on the selection loadPage : func() { var pageToLoad = PAGE_GROUPS[me._selectedPageGroup].pages[me._selectedPage]; - var page = me._pageList[pageToLoad]; + var page = me.getMFD().getPage(pageToLoad); assert(page != nil, "Unable to find page " ~ pageToLoad); me.device.selectPage(page); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Surround/SurroundController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Surround/SurroundController.nas index ea15cfc0c..3ae954a51 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Surround/SurroundController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Surround/SurroundController.nas @@ -318,11 +318,6 @@ var SurroundController = handleComVolToggle : func (value) { }, - # Holding the Clear button goes straight to the Navigation Map page. - handleClearHold : func (value) { - me._page.device.selectPage(me._page.getPage("NavigationMap")); - }, - # These methods are slightly unusual in that they are called by other # controllers when the CRSR is not active. Hence they aren't referenced # in the RegisterWithEmesary call below. @@ -352,7 +347,7 @@ var SurroundController = transmitter = emesary.GlobalTransmitter; if (me._recipient == nil){ - me._recipient = emesary.Recipient.new("PageGroupController_" ~ me._page.device.designation); + me._recipient = emesary.Recipient.new("SurroundController_" ~ me._page.device.designation); var pfd_obj = me._page.device; var controller = me; me._recipient.Receive = func(notification) diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatus.nas b/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatus.nas index ba54d12cf..0d6a4065c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatus.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatus.nas @@ -12,7 +12,7 @@ var SystemStatus = obj.topMenu(device, obj, nil); - obj.controller = fg1000.SystemStatusController.new(obj, svg); + obj.setController(fg1000.SystemStatusController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var SystemStatus = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TAWSB/TAWSB.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TAWSB/TAWSB.nas index 83b62b2e8..93242ab5d 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TAWSB/TAWSB.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TAWSB/TAWSB.nas @@ -12,7 +12,7 @@ var TAWSB = obj.topMenu(device, obj, nil); - obj.controller = fg1000.TAWSBController.new(obj, svg); + obj.setController(fg1000.TAWSBController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var TAWSB = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/TemplatePage.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/TemplatePage.nas index 0d882ec8b..f4c012202 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/TemplatePage.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/TemplatePage.nas @@ -12,7 +12,7 @@ var Template = obj.topMenu(device, obj, nil); - obj.controller = fg1000.TemplateController.new(obj, svg); + obj.setController(fg1000.TemplateController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var Template = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMap.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMap.nas index 2fbf42634..59fdfcd8b 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMap.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMap.nas @@ -54,24 +54,24 @@ var TrafficMap = type.vis ); } - obj.controller = fg1000.TrafficMapController.new(obj, svg); + obj.setController(fg1000.TrafficMapController.new(obj, svg)); var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); pg.addMenuItem(4, "STANDBY", pg, - func(dev, pg, mi) { pg.controller.setOperate(0); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().setOperate(0); device.updateMenus(); }, # callback func(svg, mi) { display_toggle(device, svg, mi, "STANDBY"); } ); pg.addMenuItem(5, "OPERATE", pg, - func(dev, pg, mi) { pg.controller.setOperate(1); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().setOperate(1); device.updateMenus(); }, # callback func(svg, mi) { display_toggle(device, svg, mi, "OPERATE"); } ); pg.addMenuItem(6, "TEST", pg, func(dev, pg, mi) { printf("Traffic Map TEST mode not implemented yet."); }, nil); pg.addMenuItem(7, "FLT ID", pg, - func(dev, pg, mi) { pg.controller.toggleFlightID(); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().toggleFlightID(); device.updateMenus(); }, # callback func(svg, mi) { display_toggle(device, svg, mi, "FLT ID"); } ); @@ -83,21 +83,21 @@ var TrafficMap = pg.clearMenu(); resetMenuColors(device); pg.addMenuItem(4, "ABOVE", pg, - func(dev, pg, mi) { pg.controller.setAlt("ABOVE"); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().setAlt("ABOVE"); device.updateMenus(); }, # callback func(svg, mi) { display_toggle(device, svg, mi, "ABOVE"); } ); pg.addMenuItem(5, "NORMAL", pg, - func(dev, pg, mi) { pg.controller.setAlt("NORMAL"); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().setAlt("NORMAL"); device.updateMenus(); }, # callback func(svg, mi) { display_toggle(device, svg, mi, "NORMAL"); } ); pg.addMenuItem(6, "BELOW", pg, - func(dev, pg, mi) { pg.controller.setAlt("BELOW"); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().setAlt("BELOW"); device.updateMenus(); }, # callback func(svg, mi) { display_toggle(device, svg, mi, "BELOW"); } ); pg.addMenuItem(7, "UNREST", pg, - func(dev, pg, mi) { pg.controller.setAlt("UNREST"); device.updateMenus(); }, # callback + func(dev, pg, mi) { pg.getController().setAlt("UNREST"); device.updateMenus(); }, # callback func(svg, mi) { display_toggle(device, svg, mi, "UNREST"); } ); @@ -110,7 +110,7 @@ var TrafficMap = # on whether a particular layer is enabled or not. var display_toggle = func(device, svg, mi, layer) { var bg_name = sprintf("SoftKey%d-bg",mi.menu_id); - if (obj.controller.isEnabled(layer)) { + if (obj.getController().isEnabled(layer)) { device.svg.getElementById(bg_name).setColorFill(0.5,0.5,0.5); svg.setColor(0.0,0.0,0.0); } else { @@ -170,11 +170,11 @@ var TrafficMap = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanning.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanning.nas index 42bcbdab9..02dd4d3e3 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanning.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanning.nas @@ -12,7 +12,7 @@ var TripPlanning = obj.topMenu(device, obj, nil); - obj.controller = fg1000.TripPlanningController.new(obj, svg); + obj.setController(fg1000.TripPlanningController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var TripPlanning = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas index 7632fe547..3205f22ae 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas @@ -12,7 +12,7 @@ var UserWPTInfo = obj.topMenu(device, obj, nil); - obj.controller = fg1000.UserWPTInfoController.new(obj, svg); + obj.setController(fg1000.UserWPTInfoController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var UserWPTInfo = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Utility/Utility.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Utility/Utility.nas index d4751dce1..60c413eb9 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Utility/Utility.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Utility/Utility.nas @@ -12,7 +12,7 @@ var Utility = obj.topMenu(device, obj, nil); - obj.controller = fg1000.UtilityController.new(obj, svg); + obj.setController(fg1000.UtilityController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var Utility = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfo.nas index 4c672ac61..18b311840 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfo.nas @@ -12,7 +12,7 @@ var VORInfo = obj.topMenu(device, obj, nil); - obj.controller = fg1000.VORInfoController.new(obj, svg); + obj.setController(fg1000.VORInfoController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var VORInfo = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLink.nas b/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLink.nas index 85cd318f1..22b7a0b0a 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLink.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLink.nas @@ -12,7 +12,7 @@ var WeatherDataLink = obj.topMenu(device, obj, nil); - obj.controller = fg1000.WeatherDataLinkController.new(obj, svg); + obj.setController(fg1000.WeatherDataLinkController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var WeatherDataLink = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfo.nas index 1c6e4d683..1f46e0446 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfo.nas @@ -12,7 +12,7 @@ var XMInfo = obj.topMenu(device, obj, nil); - obj.controller = fg1000.XMInfoController.new(obj, svg); + obj.setController(fg1000.XMInfoController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var XMInfo = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadio.nas b/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadio.nas index dffc59527..e001cc490 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadio.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadio.nas @@ -12,7 +12,7 @@ var XMRadio = obj.topMenu(device, obj, nil); - obj.controller = fg1000.XMRadioController.new(obj, svg); + obj.setController(fg1000.XMRadioController.new(obj, svg)); return obj; }, @@ -26,12 +26,12 @@ var XMRadio = 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); } - me.controller.offdisplay(); + me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); - me.controller.ondisplay(); + me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { pg.clearMenu(); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/gui.nas b/Aircraft/Instruments-3d/FG1000/Nasal/gui.nas index bf2e601a2..7c950a7ce 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/gui.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/gui.nas @@ -99,6 +99,7 @@ var MFDGUI = # creating the top-level/root group which will contain all other elements/group obj.myCanvas = obj.window.createCanvas(); + obj.myCanvas.set("name", "MFD"); obj.root = obj.myCanvas.createGroup(); var nasal_dir = getprop("/sim/fg-root") ~ "/Aircraft/Instruments-3d/FG1000/Nasal/"; @@ -119,7 +120,7 @@ var MFDGUI = # produces sharper results and perhaps better performance obj.mfd = fg1000.MFD.new(obj.myCanvas); obj.mfd._svg.setTranslation(186,45); - obj.mfd._svg.set("z-index", 150); + #obj.mfd._svg.set("z-index", 150); } else { # If we're using some scaling factor, then we create it as an image raster # which scales everything for us nicely. diff --git a/Nasal/canvas/MFD_Generic.nas b/Nasal/canvas/MFD_Generic.nas index 7940fcb78..98791620d 100644 --- a/Nasal/canvas/MFD_Generic.nas +++ b/Nasal/canvas/MFD_Generic.nas @@ -332,6 +332,13 @@ var PFD_Device = p.setVisible(1); me.current_page = p; }, + + # Return the current selected page. + getCurrentPage : func() + { + return me.current_page; + }, + # # ensure that the menus are display correctly for the current page. updateMenus : func