From 475fd505859b7841e29de725d4c1c39db7ad4ee5 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Wed, 27 Dec 2017 19:51:54 +0000 Subject: [PATCH] PFD UI Elements and NearestAirports page --- .../FG1000/Models/AirportInfo.svg | 58 +- Aircraft/Instruments-3d/FG1000/Models/MFD.svg | 11 +- .../Instruments-3d/FG1000/Models/NavMap.svg | 102 --- .../FG1000/Models/NavigationMap.svg | 170 +++++ .../FG1000/Models/NearestAirports.svg | 616 ++++++++++++++++++ .../ActiveFlightPlanNarrow.nas | 28 +- .../ActiveFlightPlanNarrowController.nas | 88 ++- .../ActiveFlightPlanWide.nas | 28 +- .../ActiveFlightPlanWideController.nas | 88 ++- .../Nasal/AirportApproach/AirportApproach.nas | 28 +- .../AirportApproachController.nas | 88 ++- .../Nasal/AirportArrival/AirportArrival.nas | 28 +- .../AirportArrivalController.nas | 88 ++- .../AirportDeparture/AirportDeparture.nas | 28 +- .../AirportDepartureController.nas | 88 ++- .../AirportDirectory/AirportDirectory.nas | 28 +- .../AirportDirectoryController.nas | 88 ++- .../FG1000/Nasal/AirportInfo/AirportInfo.nas | 281 ++++---- .../AirportInfo/AirportInfoController.nas | 140 ++-- .../Nasal/AirportWeather/AirportWeather.nas | 28 +- .../AirportWeatherController.nas | 88 ++- .../FG1000/Nasal/Checklist1/Checklist1.nas | 28 +- .../Nasal/Checklist1/Checklist1Controller.nas | 88 ++- .../FG1000/Nasal/Checklist2/Checklist2.nas | 28 +- .../Nasal/Checklist2/Checklist2Controller.nas | 88 ++- .../FG1000/Nasal/Checklist3/Checklist3.nas | 28 +- .../Nasal/Checklist3/Checklist3Controller.nas | 88 ++- .../FG1000/Nasal/Checklist4/Checklist4.nas | 28 +- .../Nasal/Checklist4/Checklist4Controller.nas | 88 ++- .../FG1000/Nasal/Checklist5/Checklist5.nas | 28 +- .../Nasal/Checklist5/Checklist5Controller.nas | 88 ++- .../FlightPlanCatalog/FlightPlanCatalog.nas | 28 +- .../FlightPlanCatalogController.nas | 88 ++- .../FG1000/Nasal/GPSStatus/GPSStatus.nas | 28 +- .../Nasal/GPSStatus/GPSStatusController.nas | 88 ++- .../IntersectionInfo/IntersectionInfo.nas | 28 +- .../IntersectionInfoController.nas | 88 ++- Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas | 72 +- .../Instruments-3d/FG1000/Nasal/MFDPage.nas | 68 ++ .../FG1000/Nasal/NDBInfo/NDBInfo.nas | 28 +- .../Nasal/NDBInfo/NDBInfoController.nas | 88 ++- .../NavigationMap.nas} | 69 +- .../NavigationMapController.nas} | 83 ++- .../NavigationMapOptions.nas} | 4 +- .../NavigationMapStyles.nas} | 4 +- .../Nasal/NearestAirports/NearestAirports.nas | 245 +++++-- .../NearestAirportsController.nas | 201 ++++++ .../NearestAirspaces/NearestAirspaces.nas | 28 +- .../NearestAirspacesController.nas | 88 ++- .../NearestFrequencies/NearestFrequencies.nas | 28 +- .../NearestFrequenciesController.nas | 88 ++- .../NearestIntersections.nas | 28 +- .../NearestIntersectionsController.nas | 88 ++- .../FG1000/Nasal/NearestNDB/NearestNDB.nas | 28 +- .../Nasal/NearestNDB/NearestNDBController.nas | 88 ++- .../Nasal/NearestUserWPT/NearestUserWPT.nas | 28 +- .../NearestUserWPTController.nas | 88 ++- .../FG1000/Nasal/NearestVOR/NearestVOR.nas | 28 +- .../Nasal/NearestVOR/NearestVORController.nas | 88 ++- .../FG1000/Nasal/PageGroupController.nas | 46 +- .../StoredFlightPlan/StoredFlightPlan.nas | 28 +- .../StoredFlightPlanController.nas | 88 ++- .../FG1000/Nasal/Stormscope/Stormscope.nas | 28 +- .../Nasal/Stormscope/StormscopeController.nas | 88 ++- .../Nasal/SystemStatus/SystemStatus.nas | 28 +- .../SystemStatus/SystemStatusController.nas | 88 ++- .../Instruments-3d/FG1000/Nasal/TAWS/TAWS.nas | 28 +- .../FG1000/Nasal/TAWS/TAWSController.nas | 88 ++- .../FG1000/Nasal/TemplatePage/Controller.nas | 88 ++- .../Nasal/TemplatePage/TemplatePage.nas | 29 +- .../FG1000/Nasal/TrafficMap/TrafficMap.nas | 12 +- .../Nasal/TrafficMap/TrafficMapController.nas | 8 +- .../Nasal/TripPlanning/TripPlanning.nas | 28 +- .../TripPlanning/TripPlanningController.nas | 88 ++- .../FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas | 28 +- .../UserWPTInfo/UserWPTInfoController.nas | 88 ++- .../FG1000/Nasal/Utility/Utility.nas | 28 +- .../Nasal/Utility/UtilityController.nas | 88 ++- .../FG1000/Nasal/VORInfo/VORInfo.nas | 28 +- .../Nasal/VORInfo/VORInfoController.nas | 88 ++- .../Nasal/WeatherDataLink/WeatherDataLink.nas | 28 +- .../WeatherDataLinkController.nas | 88 ++- .../FG1000/Nasal/XMInfo/XMInfo.nas | 28 +- .../FG1000/Nasal/XMInfo/XMInfoController.nas | 88 ++- .../FG1000/Nasal/XMRadio/XMRadio.nas | 28 +- .../Nasal/XMRadio/XMRadioController.nas | 88 ++- .../Instruments-3d/FG1000/Nasal/constants.nas | 116 ++++ .../Instruments-3d/FG1000/Nasal/createpgs.pl | 4 +- Nasal/canvas/PFD/ArrowElement.nas | 41 ++ Nasal/canvas/PFD/DataEntryElement.nas | 200 ++++++ Nasal/canvas/PFD/DefaultStyle.nas | 13 + Nasal/canvas/PFD/GroupElement.nas | 155 +++++ Nasal/canvas/PFD/ScrollElement.nas | 118 ++++ Nasal/canvas/PFD/TextElement.nas | 62 ++ Nasal/canvas/PFD/UIElement.nas | 29 + Nasal/canvas/api.nas | 4 + gui/dialogs/fg1000.xml | 37 +- 97 files changed, 5713 insertions(+), 1201 deletions(-) delete mode 100644 Aircraft/Instruments-3d/FG1000/Models/NavMap.svg create mode 100644 Aircraft/Instruments-3d/FG1000/Models/NavigationMap.svg create mode 100644 Aircraft/Instruments-3d/FG1000/Models/NearestAirports.svg create mode 100644 Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas rename Aircraft/Instruments-3d/FG1000/Nasal/{NavMap/NavMap.nas => NavigationMap/NavigationMap.nas} (79%) rename Aircraft/Instruments-3d/FG1000/Nasal/{NavMap/NavMapController.nas => NavigationMap/NavigationMapController.nas} (74%) rename Aircraft/Instruments-3d/FG1000/Nasal/{NavMap/NavMapOptions.nas => NavigationMap/NavigationMapOptions.nas} (83%) rename Aircraft/Instruments-3d/FG1000/Nasal/{NavMap/NavMapStyles.nas => NavigationMap/NavigationMapStyles.nas} (95%) create mode 100644 Aircraft/Instruments-3d/FG1000/Nasal/constants.nas create mode 100644 Nasal/canvas/PFD/ArrowElement.nas create mode 100644 Nasal/canvas/PFD/DataEntryElement.nas create mode 100644 Nasal/canvas/PFD/DefaultStyle.nas create mode 100644 Nasal/canvas/PFD/GroupElement.nas create mode 100644 Nasal/canvas/PFD/ScrollElement.nas create mode 100644 Nasal/canvas/PFD/TextElement.nas create mode 100644 Nasal/canvas/PFD/UIElement.nas diff --git a/Aircraft/Instruments-3d/FG1000/Models/AirportInfo.svg b/Aircraft/Instruments-3d/FG1000/Models/AirportInfo.svg index 4b1232c3d..c4c3588f3 100644 --- a/Aircraft/Instruments-3d/FG1000/Models/AirportInfo.svg +++ b/Aircraft/Instruments-3d/FG1000/Models/AirportInfo.svg @@ -23,9 +23,9 @@ borderopacity="0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="7.9999999" - inkscape:cx="707.7778" - inkscape:cy="620.40408" + inkscape:zoom="1.6236979" + inkscape:cx="512" + inkscape:cy="384" inkscape:document-units="px" inkscape:current-layer="AirportInfoGroup" showgrid="true" @@ -534,7 +534,7 @@ @@ -542,7 +542,7 @@ inkscape:label="#path4222" sodipodi:nodetypes="cccc" inkscape:connector-curvature="0" - id="RwySelectorRight" + id="AirportInfoRunwayRight" d="m 799.96999,356.83804 0,9.08226 4.41338,-4.48437 z" style="fill:#404040;fill-opacity:1;fill-rule:evenodd;stroke:#404040;stroke-width:0.88437384px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> 2nm + K + S + F + O diff --git a/Aircraft/Instruments-3d/FG1000/Models/MFD.svg b/Aircraft/Instruments-3d/FG1000/Models/MFD.svg index e28469a7a..94850366d 100644 --- a/Aircraft/Instruments-3d/FG1000/Models/MFD.svg +++ b/Aircraft/Instruments-3d/FG1000/Models/MFD.svg @@ -23,9 +23,9 @@ borderopacity="0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="0.70710678" - inkscape:cx="558.90157" - inkscape:cy="71.595861" + inkscape:zoom="1" + inkscape:cx="713.25502" + inkscape:cy="157.72368" inkscape:document-units="px" inkscape:current-layer="layer2" showgrid="true" @@ -952,7 +952,8 @@ inkscape:groupmode="layer" id="layer2" inkscape:label="PageGroup" - style="display:inline"> + style="display:inline" + sodipodi:insensitive="true"> - - - - - - - - - - - image/svg+xml - - - - - - - - - - Zoom nm - - - diff --git a/Aircraft/Instruments-3d/FG1000/Models/NavigationMap.svg b/Aircraft/Instruments-3d/FG1000/Models/NavigationMap.svg new file mode 100644 index 000000000..35a97d14b --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/Models/NavigationMap.svg @@ -0,0 +1,170 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + Zoom nm + + NORTH UP + + + + + Zoom nm + + NORTH UP + + + diff --git a/Aircraft/Instruments-3d/FG1000/Models/NearestAirports.svg b/Aircraft/Instruments-3d/FG1000/Models/NearestAirports.svg new file mode 100644 index 000000000..4cce557d5 --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/Models/NearestAirports.svg @@ -0,0 +1,616 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + NEAREST AIRPORTS + + RUNWAYS + + FREQUENCIES + 17-35 + KSFO + HARD SURFACE + PCL FREQUENCY - 122.90 + TOWER + 119.875 + TOWER + 119.875 + TOWER + 119.875 + + + 359 + 200nm + + KSFO + 359 + 200nm + + KSFO + 359 + 200nm + + KSFO + 359 + 200nm + + KSFO + 359 + 200nm + + + + INFORMATION + + SAN FRANCISCO INTERNATIONAL + 123ft + + + APPROACHES + TOWER + TOWER + TOWER + + + diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrow.nas b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrow.nas index 9daf521b3..5c5467792 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrow.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrow.nas @@ -4,28 +4,12 @@ var ActiveFlightPlanNarrow = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "FPL - ACTIVE FLIGHT PLAN", - _group : myCanvas.createGroup("ActiveFlightPlanNarrowLayer"), - parents : [ NavMap, device.addPage("ActiveFlightPlanNarrow", "ActiveFlightPlanNarrowGroup") ], - symbols : {}, + parents : [ + ActiveFlightPlanNarrow, + MFDPage.new(mfd, myCanvas, device, svg, "ActiveFlightPlanNarrow", "FPL - ACTIVE FLIGHT PLAN") + ], }; - obj.Styles = fg1000.ActiveFlightPlanNarrowStyles.new(); - obj.Options = fg1000.ActiveFlightPlanNarrowOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.ActiveFlightPlanNarrowController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var ActiveFlightPlanNarrow = topMenu(device, obj, nil); + obj.controller = fg1000.ActiveFlightPlanNarrowController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrowController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrowController.nas index d9d991b80..3a0e6346e 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrowController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanNarrow/ActiveFlightPlanNarrowController.nas @@ -3,7 +3,93 @@ var ActiveFlightPlanNarrowController = { new : func (page, svg) { - var obj = { parents : [ ActiveFlightPlanNarrowController ] }; + var obj = { + parents : [ ActiveFlightPlanNarrowController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWide.nas b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWide.nas index 363020b98..f831746ae 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWide.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWide.nas @@ -4,28 +4,12 @@ var ActiveFlightPlanWide = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "FPL - ACTIVE FLIGHT PLAN", - _group : myCanvas.createGroup("ActiveFlightPlanWideLayer"), - parents : [ NavMap, device.addPage("ActiveFlightPlanWide", "ActiveFlightPlanWideGroup") ], - symbols : {}, + parents : [ + ActiveFlightPlanWide, + MFDPage.new(mfd, myCanvas, device, svg, "ActiveFlightPlanWide", "FPL - ACTIVE FLIGHT PLAN") + ], }; - obj.Styles = fg1000.ActiveFlightPlanWideStyles.new(); - obj.Options = fg1000.ActiveFlightPlanWideOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.ActiveFlightPlanWideController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var ActiveFlightPlanWide = topMenu(device, obj, nil); + obj.controller = fg1000.ActiveFlightPlanWideController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWideController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWideController.nas index 69be6527f..f414135b1 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWideController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/ActiveFlightPlanWide/ActiveFlightPlanWideController.nas @@ -3,7 +3,93 @@ var ActiveFlightPlanWideController = { new : func (page, svg) { - var obj = { parents : [ ActiveFlightPlanWideController ] }; + var obj = { + parents : [ ActiveFlightPlanWideController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproach.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproach.nas index 1ab860d98..2a7567983 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproach.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproach.nas @@ -4,28 +4,12 @@ var AirportApproach = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - AIRPORT APPROACH INFORMATION", - _group : myCanvas.createGroup("AirportApproachLayer"), - parents : [ NavMap, device.addPage("AirportApproach", "AirportApproachGroup") ], - symbols : {}, + parents : [ + AirportApproach, + MFDPage.new(mfd, myCanvas, device, svg, "AirportApproach", "WPT - AIRPORT APPROACH INFORMATION") + ], }; - obj.Styles = fg1000.AirportApproachStyles.new(); - obj.Options = fg1000.AirportApproachOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.AirportApproachController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var AirportApproach = topMenu(device, obj, nil); + obj.controller = fg1000.AirportApproachController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproachController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproachController.nas index 89fd7a273..340fe430c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproachController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportApproach/AirportApproachController.nas @@ -3,7 +3,93 @@ var AirportApproachController = { new : func (page, svg) { - var obj = { parents : [ AirportApproachController ] }; + var obj = { + parents : [ AirportApproachController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrival.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrival.nas index ce905c057..f3d9174f8 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrival.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrival.nas @@ -4,28 +4,12 @@ var AirportArrival = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - AIRPORT ARRIVAL INFORMATION", - _group : myCanvas.createGroup("AirportArrivalLayer"), - parents : [ NavMap, device.addPage("AirportArrival", "AirportArrivalGroup") ], - symbols : {}, + parents : [ + AirportArrival, + MFDPage.new(mfd, myCanvas, device, svg, "AirportArrival", "WPT - AIRPORT ARRIVAL INFORMATION") + ], }; - obj.Styles = fg1000.AirportArrivalStyles.new(); - obj.Options = fg1000.AirportArrivalOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.AirportArrivalController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var AirportArrival = topMenu(device, obj, nil); + obj.controller = fg1000.AirportArrivalController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrivalController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrivalController.nas index 734c6ca85..94beb3302 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrivalController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportArrival/AirportArrivalController.nas @@ -3,7 +3,93 @@ var AirportArrivalController = { new : func (page, svg) { - var obj = { parents : [ AirportArrivalController ] }; + var obj = { + parents : [ AirportArrivalController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDeparture.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDeparture.nas index 327a145bf..ee0c25cec 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDeparture.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDeparture.nas @@ -4,28 +4,12 @@ var AirportDeparture = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - AIRPORT DEPARTURE INFORMATION", - _group : myCanvas.createGroup("AirportDepartureLayer"), - parents : [ NavMap, device.addPage("AirportDeparture", "AirportDepartureGroup") ], - symbols : {}, + parents : [ + AirportDeparture, + MFDPage.new(mfd, myCanvas, device, svg, "AirportDeparture", "WPT - AIRPORT DEPARTURE INFORMATION") + ], }; - obj.Styles = fg1000.AirportDepartureStyles.new(); - obj.Options = fg1000.AirportDepartureOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.AirportDepartureController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var AirportDeparture = topMenu(device, obj, nil); + obj.controller = fg1000.AirportDepartureController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDepartureController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDepartureController.nas index 6a249fe8a..5490a5c1f 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDepartureController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDeparture/AirportDepartureController.nas @@ -3,7 +3,93 @@ var AirportDepartureController = { new : func (page, svg) { - var obj = { parents : [ AirportDepartureController ] }; + var obj = { + parents : [ AirportDepartureController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectory.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectory.nas index 1b47d8f04..31eb9927e 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectory.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectory.nas @@ -4,28 +4,12 @@ var AirportDirectory = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - AIRPORT DIRECTORY", - _group : myCanvas.createGroup("AirportDirectoryLayer"), - parents : [ NavMap, device.addPage("AirportDirectory", "AirportDirectoryGroup") ], - symbols : {}, + parents : [ + AirportDirectory, + MFDPage.new(mfd, myCanvas, device, svg, "AirportDirectory", "WPT - AIRPORT DIRECTORY") + ], }; - obj.Styles = fg1000.AirportDirectoryStyles.new(); - obj.Options = fg1000.AirportDirectoryOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.AirportDirectoryController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var AirportDirectory = topMenu(device, obj, nil); + obj.controller = fg1000.AirportDirectoryController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectoryController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectoryController.nas index ee28f4935..967a6c644 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectoryController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportDirectory/AirportDirectoryController.nas @@ -3,7 +3,93 @@ var AirportDirectoryController = { new : func (page, svg) { - var obj = { parents : [ AirportDirectoryController ] }; + var obj = { + parents : [ AirportDirectoryController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfo.nas index 4afc03b03..ad9d8a5d2 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfo.nas @@ -1,42 +1,20 @@ # AirportInfo var AirportInfo = { - SURFACE_TYPES : { - 1 : "HARD SURFACE", # Asphalt - 2 : "HARD SURFACE", # Concrete - 3 : "TURF", - 4 : "DIRT", - 5 : "GRAVEL", - # Helipads - 6 : "HARD SURFACE", # Asphalt - 7 : "HARD SURFACE", # Concrete - 8 : "TURF", - 9 : "DIRT", - 0 : "GRAVEL", - }, - - new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - AIRPORT INFORMATION", - _group : myCanvas.createGroup("AirportInfoLayer"), - parents : [ AirportInfo, device.addPage("AirportInfo", "AirportInfoGroup") ], + parents : [ + AirportInfo, + MFDPage.new(mfd, myCanvas, device, svg, "AirportInfo", "WPT - AIRPORT INFORMATION") + ], symbols : {}, }; - obj.Styles = fg1000.AirportInfoStyles.new(); - obj.Options = fg1000.AirportInfoOptions.new(); - obj.device = device; - obj.mfd = mfd; - - # Need to display this underneath the softkeys, EIS, header. - obj._group.set("z-index", -10.0); - obj._group.setVisible(0); + obj.crsrIdx = 0; # Dynamic text elements in the SVG file. In the SVG these have an "AirportInfo" prefix. - var textelements = [ - "ID", + textelements = [ "Usage", "Name", "City", @@ -46,7 +24,6 @@ var AirportInfo = "Lon", "Fuel", "TZ", - "Runway", "RwyDimensions", "RwySurface", "RwyLighting", @@ -61,10 +38,36 @@ var AirportInfo = "Zoom" ]; - foreach (var element; textelements) { - obj.symbols[element] = svg.getElementById("AirportInfo" ~ element); - obj.symbols[element].setText(""); - } + obj.addTextElements(textelements); + + # 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.airportEntry = PFD.DataEntryElement.new(obj.pageName, svg, "ID", "", 4, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + + # TODO: Implement search by name - not currently supported. + # obj.airportNameEntry = PFD.DataEntryElement.new(obj.pageName, svg, "Name", ???, "ABCDEFGHIJKLMNOPQRSTUVWXYZ "); + + obj.runwaySelect = PFD.ScrollElement.new(obj.pageName, svg, "Runway", ["36","18"]); # Dummy values + + obj.cursorElements = [ + obj.airportEntry, +# obj.getTextElement("Name"), + obj.runwaySelect, + obj.getTextElement("Freq1"), + obj.getTextElement("Freq2"), + obj.getTextElement("Freq3"), + obj.getTextElement("Freq4"), + obj.getTextElement("Freq5"), + obj.getTextElement("Freq6"), + obj.getTextElement("Freq7"), + obj.getTextElement("Freq8") + ]; # The Airport Chart obj.AirportChart = obj._group.createChild("map"); @@ -131,6 +134,140 @@ var AirportInfo = return obj; }, + displayAirport : func(apt_info) { + # Display a given airport + me.AirportChart.getController().setPosition(apt_info.lat,apt_info.lon); + me.airportEntry.setValue(apt_info.id); + me.setTextElement("Usage", "PUBLIC"); + me.setTextElement("Name", string.uc(apt_info.name)); + me.setTextElement("City", "CITY"); + me.setTextElement("Region", "REGION"); + me.setTextElement("Alt", sprintf("%ift", M2FT * apt_info.elevation)); + + if (apt_info.lat < 0.0) { + me.setTextElement("Lat", sprintf("S %.4f", -apt_info.lat)); + } else { + me.setTextElement("Lat", sprintf("N %.4f", apt_info.lat)); + } + + if (apt_info.lon < 0.0) { + me.setTextElement("Lon", sprintf("W%3.4f", -apt_info.lon)); + } else { + me.setTextElement("Lon", sprintf("E%3.4f", apt_info.lon)); + } + + me.setTextElement("Fuel", "AVGAS, AVTUR"); + me.setTextElement("TZ", "UTC-6"); + + # Set up the runways list, but ignoring reciprocals so we don't get + # runways displayed twice. + var rwys = []; + var recips = {}; + foreach(var rwy; keys(apt_info.runways)) { + var rwy_info = apt_info.runways[rwy]; + if (recips[rwy_info.id] == nil) { + var lbl = rwy_info.id ~ "-" ~ rwy_info.reciprocal.id; + append(rwys, lbl); + recips[rwy_info.reciprocal.id] = 1; + } + } + + me.runwaySelect.setValues(rwys); + if (size(rwys) > 0) { + me.displayRunway(apt_info.runways[keys(apt_info.runways)[0]]); + } else { + me.displayRunway(nil); + } + + # Display the comms frequencies for this airport + var fcount = 1; + + if (size(apt_info.comms()) > 0) { + # Airport has one or more frequencies assigned to it. + var freqs = {}; + var comms = apt_info.comms(); + + foreach (var c; comms) { + freqs[c.ident] = sprintf("%.3f", c.frequency);; + } + + foreach (var c; sort(keys(freqs), string.icmp)) { + me.setTextElement("FreqLabel" ~ fcount, c); + me.setTextElement("Freq" ~ fcount, freqs[c]); + fcount += 1; + } + } + + while (fcount < 9) { + # zero remaining comms channels + me.setTextElement("FreqLabel" ~ fcount, ""); + me.setTextElement("Freq" ~ fcount, ""); + fcount += 1; + } + }, + displayRunway : func(rwy_info) { + if (rwy_info == nil) { + me.setTextElement("RwyDimensions", ""); + me.setTextElement("RwySurface", ""); + } else { + var dim = sprintf("%ift x %ift", 3.28 * rwy_info.length, 3.28 * rwy_info.width); + me.setTextElement("RwyDimensions", dim); + + me.setTextElement("RwySurface", SURFACE_TYPES[rwy_info.surface]); + #me.setTextElement("RwyLighting", rwy_info.surface); + } + }, + setZoom : func(zoom, label) { + # Set the zoom level for the airport chart display + me.AirportChart.setScreenRange(zoom); + me.setTextElement("Zoom", label); + }, + moveCRSR : func(val) { + var incr_or_decr = (val > 0) ? 1 : -1; + + if (me.cursorElements[me.crsrIdx].isInEdit()) { + # We're editing an element, so let the element handle the movement itself + me.cursorElements[me.crsrIdx].incrLarge(val); + } else { + # We're not currently editing an element, so move to the next cursor position. + me.cursorElements[me.crsrIdx].unhighlightElement(); + print("Old cursor index " ~ me.crsrIdx); + me.crsrIdx = math.mod(me.crsrIdx + incr_or_decr, size(me.cursorElements)); + + while ((me.cursorElements[me.crsrIdx].getValue() == nil) or + (me.cursorElements[me.crsrIdx].getValue() == "" )) { + # Handle case where we have blank frequencies by skipping them. + me.crsrIdx = math.mod(me.crsrIdx + incr_or_decr, size(me.cursorElements)); + } + + print("New cursor index " ~ me.crsrIdx ~ " " ~ size(me.cursorElements)); + me.cursorElements[me.crsrIdx].highlightElement(); + } + }, + incrSmall : func(val) { + me.cursorElements[me.crsrIdx].incrSmall(val); + var ret = {}; + ret.name = me.cursorElements[me.crsrIdx].getName(); + ret.value = me.cursorElements[me.crsrIdx].getValue(); + return ret; + }, + handleEnter : func() { + me.cursorElements[me.crsrIdx].enterElement(); + var ret = {}; + ret.name = me.cursorElements[me.crsrIdx].getName(); + ret.value = me.cursorElements[me.crsrIdx].getValue(); + return ret; + }, + handleClear : func() { + me.cursorElements[me.crsrIdx].clearElement(); + }, + showCRSR : func() { + me.cursorElements[me.crsrIdx].highlightElement(); + }, + hideCRSR : func() { + me.cursorElements[me.crsrIdx].unhighlightElement(); + me.crsrIdx = 0; + }, offdisplay : func() { me._group.setVisible(0); @@ -148,82 +285,4 @@ var AirportInfo = me.mfd.setPageTitle(me.title); me.controller.ondisplay(); }, - displayAirport : func(apt_info) { - # Display a given airport - me.AirportChart.getController().setPosition(apt_info.lat,apt_info.lon); - me.symbols["ID"].setText(apt_info.id); - me.symbols["Usage"].setText("PUBLIC"); - me.symbols["Name"].setText(string.uc(apt_info.name)); - me.symbols["City"].setText("CITY"); - me.symbols["Region"].setText("REGION"); - me.symbols["Alt"].setText(sprintf("%ift", 3.28 * apt_info.elevation)); - - if (apt_info.lat < 0.0) { - me.symbols["Lat"].setText(sprintf("S %.4f", -apt_info.lat)); - } else { - me.symbols["Lat"].setText(sprintf("N %.4f", apt_info.lat)); - } - - if (apt_info.lon < 0.0) { - me.symbols["Lon"].setText(sprintf("W%3.4f", -apt_info.lon)); - } else { - me.symbols["Lon"].setText(sprintf("E%3.4f", apt_info.lon)); - } - - me.symbols["Fuel"].setText("AVGAS"); - me.symbols["TZ"].setText("UTC-6"); - - # Display the comms frequencies for this airport - var fcount = 1; - - if (size(apt_info.comms()) > 0) { - # Airport has one or more frequencies assigned to it. - var freqs = {}; - var comms = apt_info.comms(); - - foreach (var c; comms) { - freqs[c.ident] = sprintf("%.3f", c.frequency);; - } - - foreach (var c; sort(keys(freqs), string.icmp)) { - me.symbols["FreqLabel" ~ fcount].setText(c); - me.symbols["Freq" ~ fcount].setText(freqs[c]); - fcount += 1; - } - } - - while (fcount < 9) { - # zero remaining comms channels - me.symbols["FreqLabel" ~ fcount].setText(""); - me.symbols["Freq" ~ fcount].setText(""); - fcount += 1; - } - }, - displayRunway : func(rwy_info) { - var lbl = rwy_info.id ~ "-" ~ rwy_info.reciprocal.id; - me.symbols["Runway"].setText(lbl); - - var dim = sprintf("%ift x %ift", 3.28 * rwy_info.length, 3.28 * rwy_info.width); - me.symbols["RwyDimensions"].setText(dim); - - me.symbols["RwySurface"].setText(me.SURFACE_TYPES[rwy_info.surface]); - #me.symbols["RwyLighting"].setText(rwy_info.surface); - }, - setZoom : func(zoom, label) { - # Set the zoom level for the airport chart display - me.AirportChart.setScreenRange(zoom); - me.symbols["Zoom"].setText(label); - }, - highlightElement : func(element) { - var sym = me.symbols[element]; - sym.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX); - sym.setColorFill(fg1000.HIGHLIGHT_COLOR); - sym.setColor(fg1000.HIGHLIGHT_TEXT_COLOR); - }, - unhighlightElement : func(element) { - var sym = me.symbols[element]; - sym.setDrawMode(canvas.Text.TEXT); - sym.setColor(fg1000.NORMAL_TEXT_COLOR); - }, - }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfoController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfoController.nas index 726026584..0a75fd09f 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfoController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportInfo/AirportInfoController.nas @@ -22,33 +22,16 @@ var AirportInfoController = {range: 0.5, label: "8nm"}, {range: 0.4, label: "10nm"} ], - CRSR_ELEMENTS : [ - "ID", - "Name", - "Runway", - "Freq1", - "Freq2", - "Freq3", - "Freq4", - "Freq5", - "Freq6", - "Freq7", - "Freq8", - ], - new : func (page, svg) { var obj = { parents : [ AirportInfoController ] }; obj.airport = ""; obj.runway = ""; - obj.runway_index = -1; + obj.runwayIdx = -1; obj.info = nil; obj.page = page; - obj.crsr_toggle = 0; - obj.crsrIdx = 0; + obj.crsrToggle = 0; obj.current_zoom = 7; - obj.current_id_entry = ""; - # Emesary obj._recipient = nil; @@ -63,45 +46,23 @@ var AirportInfoController = setAirport : func(id) { if (id == me.airport) return; - me.airport = id; - me.info= airportinfo(id); - me.page.displayAirport(me.info); + var apt = airportinfo(id); - # Display the first runway. - me.setRunway(0); + if (apt != nil) { + me.airport = id; + me.info= airportinfo(id); + } + + # Reset airport display. We do this irrespective of whether the id + # is valid, as it allows us to clear any bad user input from the ID field + me.page.displayAirport(me.info); }, - setRunway : func(runway_index) + setRunway : func(runwayID) { - if (runway_index == me.runway_index) return; - var rwys = keys(me.info.runways); - if (runway_index < 0) runway_index = 0; - if (runway_index > (size(rwys) - 1)) runway_index = size(rwys) - 1; - me.runway_index = runway_index; - me.page.displayRunway(me.info.runways[rwys[runway_index]]); - }, - incrRunway : func(value) - { - var incr_or_decr = (value > 0) ? 1 : -1; - me.setRunway(me.runway_index + incr_or_decr); + me.page.displayRunway(me.info.runways[runwayID]); }, # Control functions for Input - incrAirportID : func(value) - { - var incr_or_decr = (value > 0) ? 1 : -1; - if (me.current_id_entry == "") { - me.current_id_entry = "A"; - } else { - var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - var fixed = substr(me.current_id_entry, 0, size(current_id_entry) - 2); - var lastchar = substr(me.current_id_entry, -1); - var char = math.mod(find(lastchar, alphabet) + incr_or_decr, 26); - var nextchar = substr(alphabet, char, 1); - me.current_id_entry = fixed + nextchar; - } - }, - - zoomIn : func() { me.setZoom(me.current_zoom -1); }, @@ -118,53 +79,60 @@ var AirportInfoController = me.current_zoom = zoom; me.page.setZoom(me.RANGES[zoom].range * fg1000.MAP_PARTIAL.HEIGHT, me.RANGES[zoom].label); }, - showCRSR : func() { - me.page.highlightElement(me.CRSR_ELEMENTS[me.crsrIdx]); - }, - hideCRSR : func() { - me.page.unhighlightElement(me.CRSR_ELEMENTS[me.crsrIdx]); - me.crsrIdx = 0; - }, - moveCRSR : func(val) { - var incr_or_decr = (val > 0) ? 1 : -1; - - me.page.unhighlightElement(me.CRSR_ELEMENTS[me.crsrIdx]); - me.crsrIdx = math.mod(me.crsrIdx + incr_or_decr, size(me.CRSR_ELEMENTS) -1); - me.page.highlightElement(me.CRSR_ELEMENTS[me.crsrIdx]); - }, handleCRSR : func() { - me.crsr_toggle = (! me.crsr_toggle); - print("CRSR pressed " ~ me.crsr_toggle); - if (me.crsr_toggle) { - me.showCRSR(); + me.crsrToggle = (! me.crsrToggle); + if (me.crsrToggle) { + me.page.showCRSR(); } else { - me.hideCRSR(); + me.page.hideCRSR(); } return emesary.Transmitter.ReceiptStatus_Finished; }, handleFMSInner : func(value) { - if (me.crsr_toggle == 1) { - print("FMSInner for AirportInfoController called " ~ me.crsr_toggle); - if (me.CRSR_ELEMENTS[me.crsrIdx] == "Runway") { - me.incrRunway(value); - } - if (me.CRSR_ELEMENTS[me.crsrIdx] == "ID") { - me.incrAirportID(value); + if (me.crsrToggle == 1) { + var select = me.page.incrSmall(value); + if ((select.name == "AirportInfoRunway") and (select.value != nil)) { + # Selection values are of the form "06L-12R". We need to set the + # runway to the left half. + var idx = find("-", select.value); + if (idx != -1) { + var rwy = substr(select.value, 0, idx); + me.setRunway(rwy); + } } + return emesary.Transmitter.ReceiptStatus_Finished; } else { return me.page.mfd._pageGroupController.handleFMSInner(value); } }, handleFMSOuter : func(value) { - if (me.crsr_toggle == 1) { - print("FMSOuter for AirportInfoController called " ~ me.crsr_toggle); - me.moveCRSR(value); + if (me.crsrToggle == 1) { + me.page.moveCRSR(value); return emesary.Transmitter.ReceiptStatus_Finished; } else { return me.page.mfd._pageGroupController.handleFMSOuter(value); } }, + handleEnter : func(value) { + if (me.crsrToggle == 1) { + var select = me.page.handleEnter(); + if (select.name == "AirportInfoID") me.setAirport(select.value); + if (substr(select.name, 0, 15) == "AirportInfoFreq") print("Enter pressed on frequency " ~ select.value); + + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + handleClear : func(value) { + if (me.crsrToggle == 1) { + # Cancel any data entry + me.page.handleClear(); + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, RegisterWithEmesary : func(transmitter = nil){ if (transmitter == nil) transmitter = emesary.GlobalTransmitter; @@ -183,10 +151,12 @@ var AirportInfoController = var id = notification.EventParameter.Id; var value = notification.EventParameter.Value; #printf("Button pressed " ~ id ~ " " ~ value); - if (id == fg1000.MFD.FASCIA.FMS_CRSR) return controller.handleCRSR(); - if (id == fg1000.MFD.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); - if (id == fg1000.MFD.FASCIA.FMS_INNER) return controller.handleFMSInner(value); - if (id == fg1000.MFD.FASCIA.RANGE) return controller.zoom(value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.RANGE) return controller.zoom(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + if (id == fg1000.FASCIA.CLR) return controller.handleClear(value); } } return emesary.Transmitter.ReceiptStatus_NotProcessed; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeather.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeather.nas index bac4635dc..75aadf0aa 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeather.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeather.nas @@ -4,28 +4,12 @@ var AirportWeather = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - WEATHER INFORMATION", - _group : myCanvas.createGroup("AirportWeatherLayer"), - parents : [ NavMap, device.addPage("AirportWeather", "AirportWeatherGroup") ], - symbols : {}, + parents : [ + AirportWeather, + MFDPage.new(mfd, myCanvas, device, svg, "AirportWeather", "WPT - WEATHER INFORMATION") + ], }; - obj.Styles = fg1000.AirportWeatherStyles.new(); - obj.Options = fg1000.AirportWeatherOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.AirportWeatherController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var AirportWeather = topMenu(device, obj, nil); + obj.controller = fg1000.AirportWeatherController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeatherController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeatherController.nas index 34f8064c7..d8fd19877 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeatherController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/AirportWeather/AirportWeatherController.nas @@ -3,7 +3,93 @@ var AirportWeatherController = { new : func (page, svg) { - var obj = { parents : [ AirportWeatherController ] }; + var obj = { + parents : [ AirportWeatherController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1.nas index 6bb899fbd..c886838e4 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1.nas @@ -4,28 +4,12 @@ var Checklist1 = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "LST - CHECKLIST 1", - _group : myCanvas.createGroup("Checklist1Layer"), - parents : [ NavMap, device.addPage("Checklist1", "Checklist1Group") ], - symbols : {}, + parents : [ + Checklist1, + MFDPage.new(mfd, myCanvas, device, svg, "Checklist1", "LST - CHECKLIST 1") + ], }; - obj.Styles = fg1000.Checklist1Styles.new(); - obj.Options = fg1000.Checklist1Options.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.Checklist1Controller.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var Checklist1 = topMenu(device, obj, nil); + obj.controller = fg1000.Checklist1Controller.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1Controller.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1Controller.nas index 689af50f3..eb67639d0 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1Controller.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist1/Checklist1Controller.nas @@ -3,7 +3,93 @@ var Checklist1Controller = { new : func (page, svg) { - var obj = { parents : [ Checklist1Controller ] }; + var obj = { + parents : [ Checklist1Controller ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2.nas index 11a8a99de..d4fb64b6c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2.nas @@ -4,28 +4,12 @@ var Checklist2 = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "LST - CHECKLIST 2", - _group : myCanvas.createGroup("Checklist2Layer"), - parents : [ NavMap, device.addPage("Checklist2", "Checklist2Group") ], - symbols : {}, + parents : [ + Checklist2, + MFDPage.new(mfd, myCanvas, device, svg, "Checklist2", "LST - CHECKLIST 2") + ], }; - obj.Styles = fg1000.Checklist2Styles.new(); - obj.Options = fg1000.Checklist2Options.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.Checklist2Controller.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var Checklist2 = topMenu(device, obj, nil); + obj.controller = fg1000.Checklist2Controller.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2Controller.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2Controller.nas index d12198607..9ef02fe7b 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2Controller.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist2/Checklist2Controller.nas @@ -3,7 +3,93 @@ var Checklist2Controller = { new : func (page, svg) { - var obj = { parents : [ Checklist2Controller ] }; + var obj = { + parents : [ Checklist2Controller ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3.nas index c8ceb6642..848b292a1 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3.nas @@ -4,28 +4,12 @@ var Checklist3 = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "LST - CHECKLIST 3", - _group : myCanvas.createGroup("Checklist3Layer"), - parents : [ NavMap, device.addPage("Checklist3", "Checklist3Group") ], - symbols : {}, + parents : [ + Checklist3, + MFDPage.new(mfd, myCanvas, device, svg, "Checklist3", "LST - CHECKLIST 3") + ], }; - obj.Styles = fg1000.Checklist3Styles.new(); - obj.Options = fg1000.Checklist3Options.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.Checklist3Controller.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var Checklist3 = topMenu(device, obj, nil); + obj.controller = fg1000.Checklist3Controller.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3Controller.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3Controller.nas index 51058021e..187d22f81 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3Controller.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist3/Checklist3Controller.nas @@ -3,7 +3,93 @@ var Checklist3Controller = { new : func (page, svg) { - var obj = { parents : [ Checklist3Controller ] }; + var obj = { + parents : [ Checklist3Controller ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4.nas index 47b91a160..f86d89d82 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4.nas @@ -4,28 +4,12 @@ var Checklist4 = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "LST - CHECKLIST 4", - _group : myCanvas.createGroup("Checklist4Layer"), - parents : [ NavMap, device.addPage("Checklist4", "Checklist4Group") ], - symbols : {}, + parents : [ + Checklist4, + MFDPage.new(mfd, myCanvas, device, svg, "Checklist4", "LST - CHECKLIST 4") + ], }; - obj.Styles = fg1000.Checklist4Styles.new(); - obj.Options = fg1000.Checklist4Options.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.Checklist4Controller.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var Checklist4 = topMenu(device, obj, nil); + obj.controller = fg1000.Checklist4Controller.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4Controller.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4Controller.nas index 1eb3fc358..f791bf389 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4Controller.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist4/Checklist4Controller.nas @@ -3,7 +3,93 @@ var Checklist4Controller = { new : func (page, svg) { - var obj = { parents : [ Checklist4Controller ] }; + var obj = { + parents : [ Checklist4Controller ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5.nas index d3579dce5..049f8d443 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5.nas @@ -4,28 +4,12 @@ var Checklist5 = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "LST - CHECKLIST 5", - _group : myCanvas.createGroup("Checklist5Layer"), - parents : [ NavMap, device.addPage("Checklist5", "Checklist5Group") ], - symbols : {}, + parents : [ + Checklist5, + MFDPage.new(mfd, myCanvas, device, svg, "Checklist5", "LST - CHECKLIST 5") + ], }; - obj.Styles = fg1000.Checklist5Styles.new(); - obj.Options = fg1000.Checklist5Options.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.Checklist5Controller.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var Checklist5 = topMenu(device, obj, nil); + obj.controller = fg1000.Checklist5Controller.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5Controller.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5Controller.nas index 21686874c..e68042966 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5Controller.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Checklist5/Checklist5Controller.nas @@ -3,7 +3,93 @@ var Checklist5Controller = { new : func (page, svg) { - var obj = { parents : [ Checklist5Controller ] }; + var obj = { + parents : [ Checklist5Controller ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalog.nas b/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalog.nas index 5dafc933a..41305b4ab 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalog.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalog.nas @@ -4,28 +4,12 @@ var FlightPlanCatalog = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "FPL - FLIGHT PLAN CATALOG", - _group : myCanvas.createGroup("FlightPlanCatalogLayer"), - parents : [ NavMap, device.addPage("FlightPlanCatalog", "FlightPlanCatalogGroup") ], - symbols : {}, + parents : [ + FlightPlanCatalog, + MFDPage.new(mfd, myCanvas, device, svg, "FlightPlanCatalog", "FPL - FLIGHT PLAN CATALOG") + ], }; - obj.Styles = fg1000.FlightPlanCatalogStyles.new(); - obj.Options = fg1000.FlightPlanCatalogOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.FlightPlanCatalogController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var FlightPlanCatalog = topMenu(device, obj, nil); + obj.controller = fg1000.FlightPlanCatalogController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalogController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalogController.nas index 1d22d9b64..05809854e 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalogController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/FlightPlanCatalog/FlightPlanCatalogController.nas @@ -3,7 +3,93 @@ var FlightPlanCatalogController = { new : func (page, svg) { - var obj = { parents : [ FlightPlanCatalogController ] }; + var obj = { + parents : [ FlightPlanCatalogController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatus.nas b/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatus.nas index 59d8d788f..b78411e28 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatus.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatus.nas @@ -4,28 +4,12 @@ var GPSStatus = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "AUX - GPS STATUS", - _group : myCanvas.createGroup("GPSStatusLayer"), - parents : [ NavMap, device.addPage("GPSStatus", "GPSStatusGroup") ], - symbols : {}, + parents : [ + GPSStatus, + MFDPage.new(mfd, myCanvas, device, svg, "GPSStatus", "AUX - GPS STATUS") + ], }; - obj.Styles = fg1000.GPSStatusStyles.new(); - obj.Options = fg1000.GPSStatusOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.GPSStatusController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var GPSStatus = topMenu(device, obj, nil); + obj.controller = fg1000.GPSStatusController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatusController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatusController.nas index 252c3b059..dc326fa82 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatusController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/GPSStatus/GPSStatusController.nas @@ -3,7 +3,93 @@ var GPSStatusController = { new : func (page, svg) { - var obj = { parents : [ GPSStatusController ] }; + var obj = { + parents : [ GPSStatusController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfo.nas index 825d023e0..31dc5594d 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfo.nas @@ -4,28 +4,12 @@ var IntersectionInfo = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - INTERSECTION INFORMATION", - _group : myCanvas.createGroup("IntersectionInfoLayer"), - parents : [ NavMap, device.addPage("IntersectionInfo", "IntersectionInfoGroup") ], - symbols : {}, + parents : [ + IntersectionInfo, + MFDPage.new(mfd, myCanvas, device, svg, "IntersectionInfo", "WPT - INTERSECTION INFORMATION") + ], }; - obj.Styles = fg1000.IntersectionInfoStyles.new(); - obj.Options = fg1000.IntersectionInfoOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.IntersectionInfoController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var IntersectionInfo = topMenu(device, obj, nil); + obj.controller = fg1000.IntersectionInfoController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfoController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfoController.nas index 6046bc92b..c119c0606 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfoController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfoController.nas @@ -3,7 +3,93 @@ var IntersectionInfoController = { new : func (page, svg) { - var obj = { parents : [ IntersectionInfoController ] }; + var obj = { + parents : [ IntersectionInfoController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas index 986cdd03c..f90a4f49c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFD.nas @@ -1,9 +1,17 @@ # FG1000 MFD +print("##############"); +print("# FG1000 MFD #"); +print("##############\n"); + +io.include("constants.nas"); + var nasal_dir = getprop("/sim/fg-root") ~ "/Aircraft/Instruments-3d/FG1000/Nasal/"; +io.load_nasal(nasal_dir ~ '/MFDPage.nas', "fg1000"); + var MFDPages = [ - "NavMap", + "NavigationMap", "TrafficMap", "Stormscope", "WeatherDataLink", @@ -53,58 +61,9 @@ io.load_nasal(nasal_dir ~ 'EIS.nas', "fg1000"); io.load_nasal(nasal_dir ~ 'Drivers/EISDriver.nas', "fg1000"); io.load_nasal(nasal_dir ~ 'PageGroupController.nas', "fg1000"); -# Constants to define the display area, for placement of elements. We -# could try to do something with a layout, but the position and size of -# elements is fixed. Can't be member variables of MFD as they are -# self-referential. - -var DISPLAY = { WIDTH : 1024, HEIGHT : 768 }; -var HEADER_HEIGHT = 56; -var FOOTER_HEIGHT = 25; -var EIS_WIDTH = 150; - -# Size of data display on the right hand side of the MFD -var DATA_DISPLAY = { - WIDTH : 300, - HEIGHT : DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT, - X : DISPLAY.WIDTH - 300, - Y : HEADER_HEIGHT, -}; - -# Map dimensions when the data display is not present -var MAP_FULL = { - CENTER : { X : ((DISPLAY.WIDTH - EIS_WIDTH) / 2 + EIS_WIDTH), - Y : ((DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT) / 2 + HEADER_HEIGHT), }, - X : EIS_WIDTH, - Y : HEADER_HEIGHT, - WIDTH : DISPLAY.WIDTH - EIS_WIDTH, - HEIGHT : DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT, -}; - -# Map dimensions when the data display is present -var MAP_PARTIAL = { - X : EIS_WIDTH, - Y : HEADER_HEIGHT, - WIDTH : DISPLAY.WIDTH - EIS_WIDTH - DATA_DISPLAY.WIDTH, - HEIGHT : DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT, - CENTER : { X : ((DISPLAY.WIDTH - EIS_WIDTH - DATA_DISPLAY.WIDTH) / 2 + EIS_WIDTH), - Y : ((DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT) / 2 + HEADER_HEIGHT), }, -}; - -var HIGHLIGHT_COLOR = "#80ffff"; -var HIGHLIGHT_TEXT_COLOR = "#000000"; -var NORMAL_TEXT_COLOR = "#80ffff"; var MFD = { - # Constants for the hard-buttons on the fascia - FASCIA : { - FMS_OUTER : 0, - FMS_INNER : 1, - RANGE : 2, - FMS_CRSR : 3, - }, - new : func (myCanvas) { var obj = { parents : [ MFD ] }; @@ -152,16 +111,19 @@ var MFD = addPageFn(); } + # The NavigationMap page is a special case, as it is displayed with the Nearest... pages as an overlay + obj.NavigationMap = obj._pageGroupController.getPage("NavigationMap"); + # Display the NavMap and the appropriate top level on startup. - obj._MFDDevice.selectPage(obj._pageGroupController.getPage("NavMap")); + obj._MFDDevice.selectPage(obj.NavigationMap); # Add a wheel controller., which we will attach to the zoom. myCanvas.addEventListener("wheel", func(e) { if (e.deltaY >0) { - obj._MFDDevice.current_page.controller.zoomIn(); + obj._MFDDevice.current_page.controller.handleFMSInner(1); } else { - obj._MFDDevice.current_page.controller.zoomOut(); + obj._MFDDevice.current_page.controller.handleFMSInner(-1); } }); @@ -177,7 +139,9 @@ var MFD = }, del: func() { - me.getCurrentPage().DeRegisterWithEmesary(); + me._MFDDevice.current_page.offdisplay(); + me._MFDDevice.DeRegisterWithEmesary(); + }, setPageTitle: func(title) { diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas new file mode 100644 index 000000000..7544fad3e --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas @@ -0,0 +1,68 @@ +# FG1000 MFD Page base class + +# Load the PFD UI Elements +var mfd_dir = getprop("/sim/fg-root") ~ "/Nasal/canvas/PFD/"; +var loadPFDFile = func(file) io.load_nasal(mfd_dir ~ file, "PFD"); + +loadPFDFile("DefaultStyle.nas"); +loadPFDFile("UIElement.nas"); +loadPFDFile("TextElement.nas"); +loadPFDFile("ArrowElement.nas"); +loadPFDFile("GroupElement.nas"); +loadPFDFile("ScrollElement.nas"); +loadPFDFile("DataEntryElement.nas"); + +var MFDPage = +{ + +new : func (mfd, myCanvas, device, SVGGroup, pageName, title) +{ + var obj = { + pageName : pageName, + _group : myCanvas.createGroup(pageName ~ "Layer"), + _SVGGroup : SVGGroup, + parents : [ MFDPage, device.addPage(title, pageName ~ "Group") ], + _symbols : {}, + }; + + obj.device = device; + obj.mfd = mfd; + + # Pick up Style, Options and Controller + var code = "obj.Styles = fg1000." ~ pageName ~ "Styles.new(); " ~ + "obj.Options = fg1000." ~ pageName ~ "Options.new();"; + var createStylesAndOptions = compile(code); + createStylesAndOptions(); + + # Need to display this underneath the softkeys, EIS, header. + obj._group.set("z-index", -10.0); + obj._group.setVisible(0); + + return obj; +}, + +addTextElements : func(symbols) { + foreach (var s; symbols) { + me._symbols[s] = PFD.TextElement.new(me.pageName, me._SVGGroup, s); + } +}, + +getTextElement : func(symbolName) { + return me._symbols[symbolName]; + assert(sym != nil, "Unknown text element " ~ symbolName ~ " (check your addTextElements call?)"); +}, + +getTextValue : func(symbolName) { + var sym = me._symbols[symbolName]; + assert(sym != nil, "Unknown text element " ~ symbolName ~ " (check your addTextElements call?)"); + return sym.getValue(); +}, + +setTextElement : func(symbolName, value) { + var sym = me._symbols[symbolName]; + assert(sym != nil, "Unknown text element " ~ symbolName ~ " (check your addTextElements call?)"); + if (value == nil ) value = ""; + sym.setValue(value); +} + +}; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfo.nas index 4e46f96dc..29776992c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfo.nas @@ -4,28 +4,12 @@ var NDBInfo = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - NDB INFORMATION", - _group : myCanvas.createGroup("NDBInfoLayer"), - parents : [ NavMap, device.addPage("NDBInfo", "NDBInfoGroup") ], - symbols : {}, + parents : [ + NDBInfo, + MFDPage.new(mfd, myCanvas, device, svg, "NDBInfo", "WPT - NDB INFORMATION") + ], }; - obj.Styles = fg1000.NDBInfoStyles.new(); - obj.Options = fg1000.NDBInfoOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.NDBInfoController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var NDBInfo = topMenu(device, obj, nil); + obj.controller = fg1000.NDBInfoController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfoController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfoController.nas index 12370b4ba..20dfc8609 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfoController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NDBInfo/NDBInfoController.nas @@ -3,7 +3,93 @@ var NDBInfoController = { new : func (page, svg) { - var obj = { parents : [ NDBInfoController ] }; + var obj = { + parents : [ NDBInfoController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMap.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMap.nas similarity index 79% rename from Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMap.nas rename to Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMap.nas index 6378ddc6b..9c0b3101a 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMap.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMap.nas @@ -1,26 +1,30 @@ # Navigation Map -var NavMap = +var NavigationMap = { new : func (mfd, myCanvas, device, svg) { var obj = { - title : "MAP - NAVIGATION MAP", - _group : myCanvas.createGroup("NavigationMapLayer"), - parents : [ NavMap, device.addPage("NavigationMap", "NavigationMapGroup") ] + parents : [ + NavigationMap, + MFDPage.new(mfd, myCanvas, device, svg, "NavigationMap", "MAP - NAVIGATION MAP") + ], }; - obj.Styles = fg1000.NavMapStyles.new(); - obj.Options = fg1000.NavMapOptions.new(); obj.MFDMap = obj._group.createChild("map"); - obj.device = device; - obj.mfd = mfd; + obj.MFDMap.setScreenRange(689/2.0); - # Need to display this underneath the softkeys, EIS, header. - obj._group.set("z-index", -10.0); - obj._group.setVisible(0); + # Labels for map range and orientation. Two sets - one for the full display + # and another for the partial display. + obj.addTextElements(["RangeDisplay", "Orientation"]); + obj.addTextElements(["RangeDisplayPartial", "OrientationPartial"]); + obj._labelsFull = svg.getElementById("NavigationMapGroupFull"); + assert(obj._labelsFull != nil, "Unable to find NavigationMapGroupFull"); - # Initialize the controller: + obj._labelsPartial = svg.getElementById("NavigationMapGroupPartial"); + assert(obj._labelsPartial != nil, "Unable to find NavigationMapGroupPartial"); + + # Initialize the controllers: var ctrl_ns = canvas.Map.Controller.get("Aircraft position"); var source = ctrl_ns.SOURCES["current-pos"]; if (source == nil) { @@ -64,8 +68,6 @@ var NavMap = options: obj.Options.getOption(type.name) ); } - obj.controller = fg1000.NavMapController.new(obj, svg, "RangeDisplay", 8); - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -182,6 +184,8 @@ var NavMap = topMenu(device, obj, nil); + obj.controller = fg1000.NavigationMapController.new(obj, svg); + return obj; }, toggleLayerVisible : func(name) { @@ -190,8 +194,14 @@ var NavMap = setLayerVisible : func(name,n=1) { me.MFDMap.getLayer(name).setVisible(n); }, - setRange : func(range) { + setRange : func(range, label) { me.MFDMap.setRange(range); + me.setTextElement("RangeDisplay", label); + me.setTextElement("RangeDisplayPartial", label); + }, + setOrientation : func(orientation) { + me.setTextElement("Orientation", orientation); + me.setTextElement("OrientationPartial", orientation); }, setScreenRange : func(range) { me.MFDMap.setScreenRange(range); @@ -210,7 +220,36 @@ var NavMap = }, ondisplay : func() { me._group.setVisible(1); + + # Center the map's origin, modified to take into account the surround. + me.MFDMap.setTranslation( + fg1000.MAP_FULL.CENTER.X, + fg1000.MAP_FULL.CENTER.Y + ); + + me._labelsFull.setVisible(1); + me._labelsPartial.setVisible(0); + me.mfd.setPageTitle(me.title); me.controller.ondisplay(); }, + + # Display functions when we're displaying the NavigationMap as part of another + # page - e.g. NearestAirports. + ondisplayPartial : func() { + me._group.setVisible(1); + me.MFDMap.setTranslation( + fg1000.MAP_PARTIAL.CENTER.X, + fg1000.MAP_PARTIAL.CENTER.Y + ); + + me._labelsFull.setVisible(0); + me._labelsPartial.setVisible(1); + + me.controller.ondisplayPartial(); + }, + offdisplayPartial : func() { + me._group.setVisible(0); + me.controller.offdisplayPartial(); + }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMapController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMapController.nas similarity index 74% rename from Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMapController.nas rename to Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMapController.nas index 9dda952e9..9a63b3c7c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMapController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMapController.nas @@ -1,5 +1,5 @@ # Navigation Map Controller -var NavMapController = +var NavigationMapController = { # Vertical ranges, and labels. # 28 ranges from 500ft to 2000nm, measuring the vertical map distance. @@ -34,6 +34,13 @@ var NavMapController = {range: 1500, label: "1500nm"}, {range: 2000, label: "2000nm"}, ], + ORIENTATIONS : [ + { label: "NORTH UP" }, + { label: "TRK UP" }, + { label: "DTK UP" }, + { label: "HDG UP" }, + ], + # Layer display configuration: # enabled - whether this layer has been enabled by the user # declutter - the maximum declutter level (0-3) that this layer is visible in @@ -71,19 +78,20 @@ var NavMapController = # Airways levels. AIRWAYS : [ "AIRWAYS", "AIRWY ON", "AIRWY LO", "AIRWY HI"], - new : func (page, svg, zoom_label, current_zoom) + + new : func (page, svg) { - var obj = { parents : [ NavMapController ] }; - obj.current_zoom = current_zoom; + var obj = { parents : [ NavigationMapController ] }; + obj.current_zoom = 8; obj.declutter = 0; obj.airways = 0; obj.page = page; - obj.page.setScreenRange(689/2.0); - obj.label = svg.getElementById(zoom_label); obj.setZoom(obj.current_zoom); + obj.setOrientation(obj.ORIENTATIONS[0]); # Emesary obj._recipient = nil; + obj._zoomRecipient = nil; return obj; }, @@ -104,10 +112,12 @@ var NavMapController = # Ranges above represent vertical ranges, but the display is a rectangle, so # we need to use the diagonal range of the 1024 x 689, which is 617px. # 617px is 1.8 x 689/2, so we need to increase the range values by x1.8 - me.page.setRange(me.RANGES[zoom].range); - me.label.setText(me.RANGES[zoom].label); + me.page.setRange(me.RANGES[zoom].range, me.RANGES[zoom].label); me.updateVisibility(); }, + setOrientation : func(orientation) { + me.page.setOrientation(orientation.label); + }, updateVisibility : func() { # Determine which layers should be visible. foreach (var layer_name; keys(me.LAYER_RANGES)) { @@ -164,7 +174,7 @@ var NavMapController = # bottom right of the screen return me.page.mfd._pageGroupController.handleFMSOuter(value); }, - RegisterWithEmesary : func(transmitter = nil){ + RegisterWithEmesary : func(transmitter = nil) { if (transmitter == nil) transmitter = emesary.GlobalTransmitter; @@ -182,9 +192,9 @@ var NavMapController = var id = notification.EventParameter.Id; var value = notification.EventParameter.Value; #printf("Button pressed " ~ id ~ " " ~ value); - if (id == fg1000.MFD.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); - if (id == fg1000.MFD.FASCIA.FMS_INNER) return controller.handleFMSInner(value); - if (id == fg1000.MFD.FASCIA.RANGE) return controller.zoom(value); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.RANGE) return controller.zoom(value); } } return emesary.Transmitter.ReceiptStatus_NotProcessed; @@ -193,7 +203,7 @@ var NavMapController = transmitter.Register(me._recipient); me.transmitter = transmitter; }, - DeRegisterWithEmesary : func(transmitter = nil){ + DeRegisterWithEmesary : func(transmitter = nil) { # remove registration from transmitter; but keep the recipient once it is created. if (me.transmitter != nil) me.transmitter.DeRegister(me._recipient); @@ -206,4 +216,51 @@ var NavMapController = offdisplay : func() { me.DeRegisterWithEmesary(); }, + + # Set controller for cases where the NavigationMap is displayed as part of + # another page, e.g. NearestAirports + # + # In this case we are only interested in a subset of the buttons to control + # the map. + + RegisterZoomWithEmesary : func(transmitter = nil) { + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._zoomRecipient == nil){ + me._zoomRecipient = emesary.Recipient.new("NavMapController_" ~ me.page.device.designation); + var pfd_obj = me.page.device; + var controller = me; + me._zoomRecipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.RANGE) return controller.zoom(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._zoomRecipient); + me.zoomTransmitter = transmitter; + }, + DeRegisterZoomWithEmesary : func(transmitter = nil) { + # remove registration from transmitter; but keep the recipient once it is created. + if (me.zoomTransmitter != nil) + me.zoomTransmitter.DeRegister(me._zoomRecipient); + me.zoomTransmitter = nil; + }, + + ondisplayPartial : func() { + me.RegisterZoomWithEmesary(); + }, + offdisplayPartial : func() { + me.DeRegisterZoomWithEmesary(); + }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMapOptions.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMapOptions.nas similarity index 83% rename from Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMapOptions.nas rename to Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMapOptions.nas index f7f1d4188..50dcb28d5 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMapOptions.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMapOptions.nas @@ -1,8 +1,8 @@ # Navigation Map Options -var NavMapOptions = +var NavigationMapOptions = { new : func() { - var obj = { parents : [NavMapOptions] }; + var obj = { parents : [NavigationMapOptions] }; obj.Options= {}; obj.loadOptions(); return obj; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMapStyles.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMapStyles.nas similarity index 95% rename from Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMapStyles.nas rename to Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMapStyles.nas index aa775ee58..2c72fa045 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap/NavMapStyles.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NavigationMap/NavigationMapStyles.nas @@ -1,8 +1,8 @@ # Navigation Map Styles -var NavMapStyles = +var NavigationMapStyles = { new : func() { - var obj = { parents : [ NavMapStyles ]}; + var obj = { parents : [ NavigationMapStyles ]}; obj.Styles = {}; obj.loadStyles(); return obj; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirports.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirports.nas index c9a88e451..002d90b00 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirports.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirports.nas @@ -4,75 +4,228 @@ var NearestAirports = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "NRST - NEAREST AIRPORTS", - _group : myCanvas.createGroup("NearestAirportsLayer"), - parents : [ NavMap, device.addPage("NearestAirports", "NearestAirportsGroup") ], - symbols : {}, + parents : [ + NearestAirports, + MFDPage.new(mfd, myCanvas, device, svg, "NearestAirports", "NRST - NEAREST AIRPORTS") + ], }; - obj.Styles = fg1000.NearestAirportsStyles.new(); - obj.Options = fg1000.NearestAirportsOptions.new(); - obj.device = device; - obj.mfd = mfd; - obj.controller = fg1000.NearestAirportsController.new(obj, svg); - # Dynamic elements - var elements = [ + # Dynamic elements. There are 4 different sets of dynamic elements: + # + # Nearest Airports - this is a scrolling list of up to 25 airports within 200nm, shown 5 at a time. + # Runways - just a single scroll element + # Frequencies - 3 displayed in a scrolling list + # Approaches - 3 displayed in a scrolling list + # + # Selection is via softkeys, the FMS knob, or via the page menu. - ]; + obj.airportSelect = PFD.GroupElement.new( + obj.pageName, + svg, + [ "Arrow", "ID", "CRS", "DST"], + 5, + "Arrow", + 1 + ); - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } + obj.runwaySelect = PFD.ScrollElement.new(obj.pageName, svg, "RunwayID", [36,18]); # Dummy values + + obj.freqSelect = PFD.GroupElement.new( + obj.pageName, + svg, + ["FreqLabel", "Freq"], + 3, + "Freq" + ); + + obj.approachSelect = PFD.GroupElement.new( + obj.pageName, + svg, + ["Approach"], + 3, + "Approach" + ); + + # Other dynamic text elements + obj.addTextElements(["Name", "Alt", "RunwaySurface", "RunwayDimensions"]); var topMenu = func(device, pg, menuitem) { pg.clearMenu(); - resetMenuColors(device); + pg.resetMenuColors(device); + pg.addMenuItem(4, "APT", pg, + func(dev, pg, mi) { pg.controller.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(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(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(svg, mi) { pg.display_toggle(device, svg, mi, NearestAirportsController.UIGROUP.APR); } + ); + device.updateMenus(); }; - # Display map toggle softkeys which change color depending - # 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)) { - device.svg.getElementById(bg_name).setColorFill(0.5,0.5,0.5); - svg.setColor(0.0,0.0,0.0); - } else { - device.svg.getElementById(bg_name).setColorFill(0.0,0.0,0.0); - svg.setColor(1.0,1.0,1.0); - } - svg.setText(mi.title); - svg.setVisible(1); # display function - }; - - # Function to undo any colors set by display_toggle when loading a new menu - var resetMenuColors = func(device) { - for(var i = 0; i < 12; i +=1) { - var name = sprintf("SoftKey%d",i); - device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0); - device.svg.getElementById(name).setColor(1.0,1.0,1.0); - } - } topMenu(device, obj, nil); return obj; }, + + # 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) { + device.svg.getElementById(bg_name).setColorFill(0.5,0.5,0.5); + svg.setColor(0.0,0.0,0.0); + } else { + device.svg.getElementById(bg_name).setColorFill(0.0,0.0,0.0); + svg.setColor(1.0,1.0,1.0); + } + svg.setText(mi.title); + svg.setVisible(1); # display function + }, + + # Function to highlight the APT softkey - used when CRSR is pressed to indicate + # that we're editing the airports selection. + selectAirports : func() { + me.resetMenuColors(me.device); + var bg_name = sprintf("SoftKey%d-bg",4); + var tname = sprintf("SoftKey%d",4); + me.device.svg.getElementById(bg_name).setColorFill(0.5,0.5,0.5); + me.device.svg.getElementById(tname).setColor(0.0,0.0,0.0); + }, + + # Clear any cursor, highlights. Used when exiting from CRSR mode + resetCRSR : func() { + me.runwaySelect.unhighlightElement(); + me.freqSelect.hideCRSR(); + me.approachSelect.hideCRSR(); + me.resetMenuColors(me.device); + }, + + # Function to undo any colors set by display_toggle when loading a new menu + resetMenuColors : func(device) { + for(var i = 0; i < 12; i +=1) { + var name = sprintf("SoftKey%d",i); + device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0); + device.svg.getElementById(name).setColor(1.0,1.0,1.0); + } + }, + offdisplay : func() { - me._group.setVisible(0); + # The Nearest... pages use the underlying navigation map. + me.mfd.NavigationMap.offdisplayPartial(); # Reset the menu colours. Shouldn't have to do this here, but # there's not currently an obvious other location to do so. - for(var i = 0; i < 12; i +=1) { - var name = sprintf("SoftKey%d",i); - me.device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0); - me.device.svg.getElementById(name).setColor(1.0,1.0,1.0); - } + me.resetMenuColors(me.device); + + me.controller.offdisplay(); }, ondisplay : func() { - me._group.setVisible(1); + me.controller.ondisplay(); + + # The Nearest... pages use the underlying navigation map. + me.mfd.NavigationMap.ondisplayPartial(); + me.mfd.setPageTitle(me.title); + + }, + updateAirports : func(apts) { + + var airportlist = []; + for (var i = 0; i < size(apts); i = i + 1) { + var apt = apts[i]; + var crsAndDst = courseAndDistance(apt); + var crs = sprintf("%i", crsAndDst[0]); + var dst = sprintf("%.1fnm", crsAndDst[1]); + + # Convert into something we can pass straight to the UIGroup. + append(airportlist, { + Arrow : apt.id, + ID: apt.id, + CRS: crs, + DST: dst, + }); + } + + me.airportSelect.setValues(airportlist); + + if (size(airportlist) > 0) { + me.updateAirportData(apts[0]); + me.airportSelect.showCRSR(); + } else { + me.airportSelect.hideCRSR(); + me.setTextElement("Name", "NONE WITHIN 200NM"); + me.setTextElement("Alt", ""); + } + }, + updateAirportData : func(apt) { + me.setTextElement("Name", apt.name); + me.setTextElement("Alt", sprintf("%ift", M2FT * apt.elevation)); + + var runwaylist = keys(apt.runways); + + if (size(runwaylist) > 0) { + me.runwaySelect.setValues(runwaylist); + me.updateRunwayInfo(apt.runways[runwaylist[0]]); + } else { + me.runwaySelect.setValues([""]); + me.updateRunwayInfo(nil); + } + + var freqarray = []; + var apt_comms = apt.comms(); + if (size(apt_comms) > 0) { + # Airport has one or more frequencies assigned to it. + var freqs = {}; + foreach (var c; apt_comms) { + freqs[c.ident] = sprintf("%.3f", c.frequency);; + } + + foreach (var c; sort(keys(freqs), string.icmp)) { + append(freqarray, {FreqLabel: c, Freq: freqs[c]}); + } + } + + me.freqSelect.setValues(freqarray); + + # Approaches + var approachList = apt.getApproachList(); + me.approachSelect.setValues(approachList); + }, + updateRunwayInfo : func(rwy_info) { + if (rwy_info != nil ) { + var dim = sprintf("%ift x %ift", 3.28 * rwy_info.length, 3.28 * rwy_info.width); + me.setTextElement("RunwayDimensions", dim); + me.setTextElement("RunwaySurface", SURFACE_TYPES[rwy_info.surface]); + } else { + me.setTextElement("RunwayDimensions", ""); + me.setTextElement("RunwaySurface", ""); + } + }, + getSelectedAirportID : func() { + return me.airportSelect.getValue(); + }, + getSelectedRunway : func() { + return me.runwaySelect.getValue(); + }, + getSelectedFreq : func() { + return me.freqSelect.getValue(); + }, + getSelectedApproach : func() { + return me.approachSelect.getValue(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirportsController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirportsController.nas index ec1e2c56c..ebea9b706 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirportsController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirports/NearestAirportsController.nas @@ -1,9 +1,210 @@ # NearestAirports Controller var NearestAirportsController = { + UIGROUP : { + NONE : 0, # No group currently selected, + APT : 1, + RNWY : 2, + FREQ : 3, + APR : 4, + }, + new : func (page, svg) { var obj = { parents : [ NearestAirportsController ] }; + + # Current active UI group. + obj.page = page; + obj._currentGroup = NearestAirportsController.UIGROUP.NONE; + obj._crsrToggle = 0; + + # Emesary + obj._recipient = nil; + return obj; }, + + getAirports : func() { + # Find the airports within 200nm and display them. + + # To make this more efficient for areas with a high density of airports, we'll try + # small radii first. + + var radius = 0; + var apts = []; + + while ((radius <= 200) and (size(apts) < 25)) { + radius = radius + 50; + apts = findAirportsWithinRange(radius); + } + + if (size(apts) > 25) { + apts = subvec(apts, 0, 25); + } + me.page.updateAirports(apts); + }, + selectAirports : func() { + me.selectGroup(NearestAirportsController.UIGROUP.APT) + }, + selectRunways : func() { + me.selectGroup(NearestAirportsController.UIGROUP.RNWY); + }, + selectFrequencies : func() { + me.selectGroup(NearestAirportsController.UIGROUP.FREQ); + }, + selectApproaches : func() { + me.selectGroup(NearestAirportsController.UIGROUP.APR); + }, + getSelectedGroup : func() { + return me._currentGroup; + }, + selectGroup : func(grp) { + me._currentGroup = grp; + # The current Airport is always highlighted - we're either changing it directly, + # or viewing the selected airport. + if (grp == NearestAirportsController.UIGROUP.RNWY) me.page.runwaySelect.highlightElement() else me.page.runwaySelect.unhighlightElement(); + if (grp == NearestAirportsController.UIGROUP.FREQ) me.page.freqSelect.showCRSR() else me.page.freqSelect.hideCRSR(); + if (grp == NearestAirportsController.UIGROUP.APR) me.page.approachSelect.showCRSR() else me.page.approachSelect.hideCRSR(); + me._crsrToggle = 1; + }, + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + me.page.selectAirports(); + me.selectAirports(); + } else { + # Hide the cursor and reset any highlighting + me.page.resetCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + + if (me._currentGroup == NearestAirportsController.UIGROUP.APT) { + me.page.airportSelect.incrSmall(value); + var apt_id = me.page.getSelectedAirportID(); + var apt_info = airportinfo(apt_id); + me.page.updateAirportData(apt_info); + } + + if (me._currentGroup == NearestAirportsController.UIGROUP.RNWY) { + me.page.runwaySelect.incrSmall(value); + # Need to manually update the runway information + var apt_id = me.page.airportSelect.getValue(); + var rwy = me.page.runwaySelect.getValue(); + + if ((rwy != nil) and (rwy != "")) { + var apt_info = airportinfo(apt_id); + var rwy_info = apt_info.runways[rwy]; + me.page.updateRunwayInfo(rwy_info); + } + } + + if (me._currentGroup == NearestAirportsController.UIGROUP.FREQ) me.page.freqSelect.incrSmall(value); + if (me._currentGroup == NearestAirportsController.UIGROUP.APR) me.page.approachSelect.incrSmall(value); + + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return me.page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + + # The large knob only affects the Airport selection in cursor mode. + # Question-mark over whether it does this when other groups + # are selected. Assumption now is that it doesn't - otherwise it would + # be too easy to nudge it while trying to scroll through runways/approaches etc. + + if (me._currentGroup == NearestAirportsController.UIGROUP.APT) { + me.page.airportSelect.incrLarge(value); + var apt_id = me.page.getSelectedAirportID(); + var apt_info = airportinfo(apt_id); + me.page.updateAirportData(apt_info); + } + + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return me.page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + if (me._currentGroup == NearestAirportsController.UIGROUP.APT) { + # If the airport group is selected, the ENT key selects the next airport + me.page.airportSelect.incrLarge(value); + var apt_id = me.page.getSelectedAirportID(); + var apt_info = airportinfo(apt_id); + me.page.updateAirportData(apt_info); + } + + if (me._currentGroup == NearestAirportsController.UIGROUP.RNWY) { + # No effect if runways are selected + } + + if (me._currentGroup == NearestAirportsController.UIGROUP.FREQ) { + # TODO Select the current COM frequency. + var freq = me.page.getSelectedFreq(); + if (freq != nil) print("NearestAirportController.handleEnter frequency selection " ~ freq); + } + + if (me._currentGroup == NearestAirportsController.UIGROUP.APR) { + # TODO Select the current Approach + var appr = me.page.getSelectedApproach(); + if (appr != nil) print("NearestAirportController.handleEnter Approach selection " ~ appr); + } + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me.page.device.designation); + var pfd_obj = me.page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me._currentGroup = NearestAirportsController.UIGROUP.NONE; + me.RegisterWithEmesary(); + me.getAirports(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspaces.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspaces.nas index a98a251a3..93b3fe0b5 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspaces.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspaces.nas @@ -4,28 +4,12 @@ var NearestAirspaces = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "NRST - NEAREST AIRSPACES", - _group : myCanvas.createGroup("NearestAirspacesLayer"), - parents : [ NavMap, device.addPage("NearestAirspaces", "NearestAirspacesGroup") ], - symbols : {}, + parents : [ + NearestAirspaces, + MFDPage.new(mfd, myCanvas, device, svg, "NearestAirspaces", "NRST - NEAREST AIRSPACES") + ], }; - obj.Styles = fg1000.NearestAirspacesStyles.new(); - obj.Options = fg1000.NearestAirspacesOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.NearestAirspacesController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var NearestAirspaces = topMenu(device, obj, nil); + obj.controller = fg1000.NearestAirspacesController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspacesController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspacesController.nas index ef3d757f8..420966e7c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspacesController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestAirspaces/NearestAirspacesController.nas @@ -3,7 +3,93 @@ var NearestAirspacesController = { new : func (page, svg) { - var obj = { parents : [ NearestAirspacesController ] }; + var obj = { + parents : [ NearestAirspacesController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequencies.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequencies.nas index 66dfb2616..2b884e648 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequencies.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequencies.nas @@ -4,28 +4,12 @@ var NearestFrequencies = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "NRST - NEAREST FREQUENCIES", - _group : myCanvas.createGroup("NearestFrequenciesLayer"), - parents : [ NavMap, device.addPage("NearestFrequencies", "NearestFrequenciesGroup") ], - symbols : {}, + parents : [ + NearestFrequencies, + MFDPage.new(mfd, myCanvas, device, svg, "NearestFrequencies", "NRST - NEAREST FREQUENCIES") + ], }; - obj.Styles = fg1000.NearestFrequenciesStyles.new(); - obj.Options = fg1000.NearestFrequenciesOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.NearestFrequenciesController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var NearestFrequencies = topMenu(device, obj, nil); + obj.controller = fg1000.NearestFrequenciesController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequenciesController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequenciesController.nas index da8f498da..cf62534cc 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequenciesController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestFrequencies/NearestFrequenciesController.nas @@ -3,7 +3,93 @@ var NearestFrequenciesController = { new : func (page, svg) { - var obj = { parents : [ NearestFrequenciesController ] }; + var obj = { + parents : [ NearestFrequenciesController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersections.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersections.nas index 528735a24..b34da927c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersections.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersections.nas @@ -4,28 +4,12 @@ var NearestIntersections = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "NRST - NEAREST INTERSECTIONS", - _group : myCanvas.createGroup("NearestIntersectionsLayer"), - parents : [ NavMap, device.addPage("NearestIntersections", "NearestIntersectionsGroup") ], - symbols : {}, + parents : [ + NearestIntersections, + MFDPage.new(mfd, myCanvas, device, svg, "NearestIntersections", "NRST - NEAREST INTERSECTIONS") + ], }; - obj.Styles = fg1000.NearestIntersectionsStyles.new(); - obj.Options = fg1000.NearestIntersectionsOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.NearestIntersectionsController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var NearestIntersections = topMenu(device, obj, nil); + obj.controller = fg1000.NearestIntersectionsController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersectionsController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersectionsController.nas index 9036318d1..d1611a18b 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersectionsController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestIntersections/NearestIntersectionsController.nas @@ -3,7 +3,93 @@ var NearestIntersectionsController = { new : func (page, svg) { - var obj = { parents : [ NearestIntersectionsController ] }; + var obj = { + parents : [ NearestIntersectionsController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDB.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDB.nas index 8bfd7b5da..7997616d1 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDB.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDB.nas @@ -4,28 +4,12 @@ var NearestNDB = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "NRST - NEAREST NDB", - _group : myCanvas.createGroup("NearestNDBLayer"), - parents : [ NavMap, device.addPage("NearestNDB", "NearestNDBGroup") ], - symbols : {}, + parents : [ + NearestNDB, + MFDPage.new(mfd, myCanvas, device, svg, "NearestNDB", "NRST - NEAREST NDB") + ], }; - obj.Styles = fg1000.NearestNDBStyles.new(); - obj.Options = fg1000.NearestNDBOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.NearestNDBController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var NearestNDB = topMenu(device, obj, nil); + obj.controller = fg1000.NearestNDBController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDBController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDBController.nas index 398f81406..0f3bede9c 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDBController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestNDB/NearestNDBController.nas @@ -3,7 +3,93 @@ var NearestNDBController = { new : func (page, svg) { - var obj = { parents : [ NearestNDBController ] }; + var obj = { + parents : [ NearestNDBController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPT.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPT.nas index b4b65b264..8261c2d9b 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPT.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPT.nas @@ -4,28 +4,12 @@ var NearestUserWPT = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "NRST - NEAREST USER WPTS", - _group : myCanvas.createGroup("NearestUserWPTLayer"), - parents : [ NavMap, device.addPage("NearestUserWPT", "NearestUserWPTGroup") ], - symbols : {}, + parents : [ + NearestUserWPT, + MFDPage.new(mfd, myCanvas, device, svg, "NearestUserWPT", "NRST - NEAREST USER WPTS") + ], }; - obj.Styles = fg1000.NearestUserWPTStyles.new(); - obj.Options = fg1000.NearestUserWPTOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.NearestUserWPTController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var NearestUserWPT = topMenu(device, obj, nil); + obj.controller = fg1000.NearestUserWPTController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPTController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPTController.nas index db81ba472..7acb48935 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPTController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestUserWPT/NearestUserWPTController.nas @@ -3,7 +3,93 @@ var NearestUserWPTController = { new : func (page, svg) { - var obj = { parents : [ NearestUserWPTController ] }; + var obj = { + parents : [ NearestUserWPTController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVOR.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVOR.nas index c3be32294..936b3cedc 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVOR.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVOR.nas @@ -4,28 +4,12 @@ var NearestVOR = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "NRST - NEAREST VOR", - _group : myCanvas.createGroup("NearestVORLayer"), - parents : [ NavMap, device.addPage("NearestVOR", "NearestVORGroup") ], - symbols : {}, + parents : [ + NearestVOR, + MFDPage.new(mfd, myCanvas, device, svg, "NearestVOR", "NRST - NEAREST VOR") + ], }; - obj.Styles = fg1000.NearestVORStyles.new(); - obj.Options = fg1000.NearestVOROptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.NearestVORController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var NearestVOR = topMenu(device, obj, nil); + obj.controller = fg1000.NearestVORController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVORController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVORController.nas index ce5a4eac3..2f9c624c8 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVORController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NearestVOR/NearestVORController.nas @@ -3,7 +3,93 @@ var NearestVORController = { new : func (page, svg) { - var obj = { parents : [ NearestVORController ] }; + var obj = { + parents : [ NearestVORController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/PageGroupController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/PageGroupController.nas index 1bf407cd5..a2c87399d 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/PageGroupController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/PageGroupController.nas @@ -6,7 +6,7 @@ var PAGE_GROUPS = [ { label: "MapPageGroupLabel", group: "MapPageGroup", - pages: [ "NavMap", "TrafficMap", "Stormscope", "WeatherDataLink", "TAWSB"], + pages: [ "NavigationMap", "TrafficMap", "Stormscope", "WeatherDataLink", "TAWSB"], }, { label: "WPTGroupLabel", group: "WPTPageGroup", @@ -48,6 +48,22 @@ var PageGroupController = # List of pages to be controllers. Keys are the pages in PAGE_GROUPS; obj._pageList = {}; + obj._elements = {}; + + foreach (var pageGroup; PAGE_GROUPS) { + var group = svg.getElementById(pageGroup.group); + var label = svg.getElementById(pageGroup.label); + assert(group != nil, "Unable to find element " ~ pageGroup.group); + assert(label != nil, "Unable to find element " ~ pageGroup.label); + obj._elements[pageGroup.group] = group; + obj._elements[pageGroup.label] = label; + + foreach(var pg; pageGroup.pages) { + var page = svg.getElementById(pg); + assert(page != nil, "Unable to find element " ~ pg); + obj._elements[pg] = page; + } + } # Timers to control when to hide the menu after inactivity, and when to load # a new page. @@ -75,8 +91,8 @@ var PageGroupController = { foreach(var pageGroup; PAGE_GROUPS) { - me._svg.getElementById(pageGroup.group).setVisible(0); - me._svg.getElementById(pageGroup.label).setVisible(0); + me._elements[pageGroup.group].setVisible(0); + me._elements[pageGroup.label].setVisible(0); } me._menuVisible = 0; }, @@ -87,13 +103,9 @@ var PageGroupController = var pageToLoad = PAGE_GROUPS[me._selectedPageGroup].pages[me._selectedPage]; var page = me._pageList[pageToLoad]; - if (page != nil) { - me._device.selectPage(page); - } else { - printf("Unable to find page " ~ pageToLoad); - } + assert(page != nil, "Unable to find page " ~ pageToLoad); + me._device.selectPage(page); }, - showMenu : func() { foreach(var pageGroup; PAGE_GROUPS) @@ -101,26 +113,26 @@ var PageGroupController = if (PAGE_GROUPS[me._selectedPageGroup].label == pageGroup.label) { # Display the page group and highlight the label - me._svg.getElementById(pageGroup.group).setVisible(1); - me._svg.getElementById(pageGroup.label).setVisible(1); - me._svg.getElementById(pageGroup.label).setColor(0.7,0.7,1.0); + me._elements[pageGroup.group].setVisible(1); + me._elements[pageGroup.label].setVisible(1); + me._elements[pageGroup.label].setColor(0.7,0.7,1.0); foreach (var page; pageGroup.pages) { # Highlight the current page. if (pageGroup.pages[me._selectedPage] == page) { - me._svg.getElementById(page).setColor(0.7,0.7,1.0); + me._elements[page].setColor(0.7,0.7,1.0); } else { - me._svg.getElementById(page).setColor(0.7,0.7,0.7); + me._elements[page].setColor(0.7,0.7,0.7); } } } else { # Hide the pagegroup and unhighlight the label on the bottom - me._svg.getElementById(pageGroup.group).setVisible(0); - me._svg.getElementById(pageGroup.label).setVisible(1); - me._svg.getElementById(pageGroup.label).setColor(0.7,0.7,0.7); + me._elements[pageGroup.group].setVisible(0); + me._elements[pageGroup.label].setVisible(1); + me._elements[pageGroup.label].setColor(0.7,0.7,0.7); } } me._menuVisible = 1; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlan.nas b/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlan.nas index e876f0fd9..2a3b4b12e 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlan.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlan.nas @@ -4,28 +4,12 @@ var StoredFlightPlan = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "FPL - STORED FLIGHT PLAN", - _group : myCanvas.createGroup("StoredFlightPlanLayer"), - parents : [ NavMap, device.addPage("StoredFlightPlan", "StoredFlightPlanGroup") ], - symbols : {}, + parents : [ + StoredFlightPlan, + MFDPage.new(mfd, myCanvas, device, svg, "StoredFlightPlan", "FPL - STORED FLIGHT PLAN") + ], }; - obj.Styles = fg1000.StoredFlightPlanStyles.new(); - obj.Options = fg1000.StoredFlightPlanOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.StoredFlightPlanController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var StoredFlightPlan = topMenu(device, obj, nil); + obj.controller = fg1000.StoredFlightPlanController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlanController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlanController.nas index ec900e42b..b41745a61 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlanController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/StoredFlightPlan/StoredFlightPlanController.nas @@ -3,7 +3,93 @@ var StoredFlightPlanController = { new : func (page, svg) { - var obj = { parents : [ StoredFlightPlanController ] }; + var obj = { + parents : [ StoredFlightPlanController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/Stormscope.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/Stormscope.nas index 7970ef55b..929aec76a 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/Stormscope.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/Stormscope.nas @@ -4,28 +4,12 @@ var Stormscope = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "MAP - STORMSCOPE", - _group : myCanvas.createGroup("StormscopeLayer"), - parents : [ NavMap, device.addPage("Stormscope", "StormscopeGroup") ], - symbols : {}, + parents : [ + Stormscope, + MFDPage.new(mfd, myCanvas, device, svg, "Stormscope", "MAP - STORMSCOPE") + ], }; - obj.Styles = fg1000.StormscopeStyles.new(); - obj.Options = fg1000.StormscopeOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.StormscopeController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var Stormscope = topMenu(device, obj, nil); + obj.controller = fg1000.StormscopeController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/StormscopeController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/StormscopeController.nas index 2adfd6bf2..0e5f17738 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/StormscopeController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Stormscope/StormscopeController.nas @@ -3,7 +3,93 @@ var StormscopeController = { new : func (page, svg) { - var obj = { parents : [ StormscopeController ] }; + var obj = { + parents : [ StormscopeController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatus.nas b/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatus.nas index fdb751b92..5833274bf 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatus.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatus.nas @@ -4,28 +4,12 @@ var SystemStatus = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "AUX - SYSTEM STATUS", - _group : myCanvas.createGroup("SystemStatusLayer"), - parents : [ NavMap, device.addPage("SystemStatus", "SystemStatusGroup") ], - symbols : {}, + parents : [ + SystemStatus, + MFDPage.new(mfd, myCanvas, device, svg, "SystemStatus", "AUX - SYSTEM STATUS") + ], }; - obj.Styles = fg1000.SystemStatusStyles.new(); - obj.Options = fg1000.SystemStatusOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.SystemStatusController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var SystemStatus = topMenu(device, obj, nil); + obj.controller = fg1000.SystemStatusController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatusController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatusController.nas index 3dcf15cab..3825e12a1 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatusController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/SystemStatus/SystemStatusController.nas @@ -3,7 +3,93 @@ var SystemStatusController = { new : func (page, svg) { - var obj = { parents : [ SystemStatusController ] }; + var obj = { + parents : [ SystemStatusController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TAWS/TAWS.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TAWS/TAWS.nas index 7b6fa2cb7..f57fc23da 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TAWS/TAWS.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TAWS/TAWS.nas @@ -4,28 +4,12 @@ var TAWS = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "MAP - TAWS", - _group : myCanvas.createGroup("TAWSLayer"), - parents : [ NavMap, device.addPage("TAWS", "TAWSGroup") ], - symbols : {}, + parents : [ + TAWS, + MFDPage.new(mfd, myCanvas, device, svg, "TAWS", "MAP - TAWS") + ], }; - obj.Styles = fg1000.TAWSStyles.new(); - obj.Options = fg1000.TAWSOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.TAWSController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var TAWS = topMenu(device, obj, nil); + obj.controller = fg1000.TAWSController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ var TAWS = 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TAWS/TAWSController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TAWS/TAWSController.nas index b024bb532..8bf714687 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TAWS/TAWSController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TAWS/TAWSController.nas @@ -3,7 +3,93 @@ var TAWSController = { new : func (page, svg) { - var obj = { parents : [ TAWSController ] }; + var obj = { + parents : [ TAWSController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/Controller.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/Controller.nas index 17a9647b2..19ed6a477 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/Controller.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/Controller.nas @@ -3,7 +3,93 @@ var TemplateController = { new : func (page, svg) { - var obj = { parents : [ TemplateController ] }; + var obj = { + parents : [ TemplateController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/TemplatePage.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/TemplatePage.nas index 787b78c52..fc949c7ba 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/TemplatePage.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TemplatePage/TemplatePage.nas @@ -4,29 +4,12 @@ var Template = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "TemplateTitle", - _group : myCanvas.createGroup("TemplateLayer"), - parents : [ Template, device.addPage("Template", "TemplateGroup") ], - symbols : {}, + parents : [ + Template, + MFDPage.new(mfd, myCanvas, device, svg, "Template", "TemplateTitle") + ], }; - obj.Styles = fg1000.TemplateStyles.new(); - obj.Options = fg1000.TemplateOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.TemplateController.new(obj, svg); - - # Dynamic text elements in the SVG file. In the SVG these have an "AirportInfo" prefix. - var textelements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - obj.symbols[element].setText(""); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -59,6 +42,8 @@ var Template = topMenu(device, obj, nil); + obj.controller = fg1000.TemplateController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -71,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMap.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMap.nas index 0dc0c6e69..4b5515b88 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMap.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMap.nas @@ -7,16 +7,10 @@ var TrafficMap = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "MAP - TRAFFIC MAP", - _group : myCanvas.createGroup("TrafficMapLayer"), - parents : [ TrafficMap, device.addPage("TrafficMap", "TrafficMapGroup") ] + parents : [ TrafficMap, MFDPage.new(mfd, myCanvas, device, svg, "TrafficMap", "MAP - TRAFFIC MAP") ] }; - obj.Styles = fg1000.TrafficMapStyles.new(); - obj.Options = fg1000.TrafficMapOptions.new(); obj.mapgroup = obj._group.createChild("map"); - obj.device = device; - obj.mfd = mfd; # Dynamic text elements obj.op_label = svg.getElementById("TrafficMapOpMode"); @@ -24,10 +18,6 @@ var TrafficMap = obj.outer_label = svg.getElementById("TrafficMapOuterRange"); obj.inner_label = svg.getElementById("TrafficMapInnerRange"); - # Need to display this underneath the softkeys, EIS, header. - obj._group.set("z-index", -10.0); - obj._group.setVisible(0); - # Initialize the controller: var ctrl_ns = canvas.Map.Controller.get("Aircraft position"); var source = ctrl_ns.SOURCES["current-pos"]; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMapController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMapController.nas index 6b56b565a..88cae8a49 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMapController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TrafficMap/TrafficMapController.nas @@ -33,7 +33,7 @@ var TrafficMapController = # Emesary obj._recipient = nil; - + obj.setZoom(obj.range); return obj; }, @@ -121,9 +121,9 @@ var TrafficMapController = var id = notification.EventParameter.Id; var value = notification.EventParameter.Value; #printf("Button pressed " ~ id ~ " " ~ value); - if (id == fg1000.MFD.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); - if (id == fg1000.MFD.FASCIA.FMS_INNER) return controller.handleFMSInner(value); - if (id == fg1000.MFD.FASCIA.RANGE) return controller.zoom(value); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.RANGE) return controller.zoom(value); } } return emesary.Transmitter.ReceiptStatus_NotProcessed; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanning.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanning.nas index 3da8870b4..69f45b9ff 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanning.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanning.nas @@ -4,28 +4,12 @@ var TripPlanning = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "AUX - TRIP PLANNING", - _group : myCanvas.createGroup("TripPlanningLayer"), - parents : [ NavMap, device.addPage("TripPlanning", "TripPlanningGroup") ], - symbols : {}, + parents : [ + TripPlanning, + MFDPage.new(mfd, myCanvas, device, svg, "TripPlanning", "AUX - TRIP PLANNING") + ], }; - obj.Styles = fg1000.TripPlanningStyles.new(); - obj.Options = fg1000.TripPlanningOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.TripPlanningController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var TripPlanning = topMenu(device, obj, nil); + obj.controller = fg1000.TripPlanningController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanningController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanningController.nas index 86bade2d5..2dd24617e 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanningController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/TripPlanning/TripPlanningController.nas @@ -3,7 +3,93 @@ var TripPlanningController = { new : func (page, svg) { - var obj = { parents : [ TripPlanningController ] }; + var obj = { + parents : [ TripPlanningController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas index f6e7d08df..157f0ea0f 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfo.nas @@ -4,28 +4,12 @@ var UserWPTInfo = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - USER WPT INFORMATION", - _group : myCanvas.createGroup("UserWPTInfoLayer"), - parents : [ NavMap, device.addPage("UserWPTInfo", "UserWPTInfoGroup") ], - symbols : {}, + parents : [ + UserWPTInfo, + MFDPage.new(mfd, myCanvas, device, svg, "UserWPTInfo", "WPT - USER WPT INFORMATION") + ], }; - obj.Styles = fg1000.UserWPTInfoStyles.new(); - obj.Options = fg1000.UserWPTInfoOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.UserWPTInfoController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var UserWPTInfo = topMenu(device, obj, nil); + obj.controller = fg1000.UserWPTInfoController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfoController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfoController.nas index d94d599fc..1860c7f19 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfoController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/UserWPTInfo/UserWPTInfoController.nas @@ -3,7 +3,93 @@ var UserWPTInfoController = { new : func (page, svg) { - var obj = { parents : [ UserWPTInfoController ] }; + var obj = { + parents : [ UserWPTInfoController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Utility/Utility.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Utility/Utility.nas index fac7f5830..c07c4f259 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Utility/Utility.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Utility/Utility.nas @@ -4,28 +4,12 @@ var Utility = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "AUX - UTILITY", - _group : myCanvas.createGroup("UtilityLayer"), - parents : [ NavMap, device.addPage("Utility", "UtilityGroup") ], - symbols : {}, + parents : [ + Utility, + MFDPage.new(mfd, myCanvas, device, svg, "Utility", "AUX - UTILITY") + ], }; - obj.Styles = fg1000.UtilityStyles.new(); - obj.Options = fg1000.UtilityOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.UtilityController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var Utility = topMenu(device, obj, nil); + obj.controller = fg1000.UtilityController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Utility/UtilityController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Utility/UtilityController.nas index 463fd0730..1f9220015 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Utility/UtilityController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Utility/UtilityController.nas @@ -3,7 +3,93 @@ var UtilityController = { new : func (page, svg) { - var obj = { parents : [ UtilityController ] }; + var obj = { + parents : [ UtilityController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfo.nas index 630b89e3f..3a0f98225 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfo.nas @@ -4,28 +4,12 @@ var VORInfo = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "WPT - VOR INFORMATION", - _group : myCanvas.createGroup("VORInfoLayer"), - parents : [ NavMap, device.addPage("VORInfo", "VORInfoGroup") ], - symbols : {}, + parents : [ + VORInfo, + MFDPage.new(mfd, myCanvas, device, svg, "VORInfo", "WPT - VOR INFORMATION") + ], }; - obj.Styles = fg1000.VORInfoStyles.new(); - obj.Options = fg1000.VORInfoOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.VORInfoController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var VORInfo = topMenu(device, obj, nil); + obj.controller = fg1000.VORInfoController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfoController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfoController.nas index e7c9b4eff..17b3adbb4 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfoController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/VORInfo/VORInfoController.nas @@ -3,7 +3,93 @@ var VORInfoController = { new : func (page, svg) { - var obj = { parents : [ VORInfoController ] }; + var obj = { + parents : [ VORInfoController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLink.nas b/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLink.nas index 347c31c21..bf9b68aae 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLink.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLink.nas @@ -4,28 +4,12 @@ var WeatherDataLink = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "MAP - WEATHER DATA LINK", - _group : myCanvas.createGroup("WeatherDataLinkLayer"), - parents : [ NavMap, device.addPage("WeatherDataLink", "WeatherDataLinkGroup") ], - symbols : {}, + parents : [ + WeatherDataLink, + MFDPage.new(mfd, myCanvas, device, svg, "WeatherDataLink", "MAP - WEATHER DATA LINK") + ], }; - obj.Styles = fg1000.WeatherDataLinkStyles.new(); - obj.Options = fg1000.WeatherDataLinkOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.WeatherDataLinkController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var WeatherDataLink = topMenu(device, obj, nil); + obj.controller = fg1000.WeatherDataLinkController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLinkController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLinkController.nas index 3e99749b6..977ae9e33 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLinkController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/WeatherDataLink/WeatherDataLinkController.nas @@ -3,7 +3,93 @@ var WeatherDataLinkController = { new : func (page, svg) { - var obj = { parents : [ WeatherDataLinkController ] }; + var obj = { + parents : [ WeatherDataLinkController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfo.nas index 69a442bd1..4ec564c66 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfo.nas @@ -4,28 +4,12 @@ var XMInfo = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "AUX - XM INFORMATION", - _group : myCanvas.createGroup("XMInfoLayer"), - parents : [ NavMap, device.addPage("XMInfo", "XMInfoGroup") ], - symbols : {}, + parents : [ + XMInfo, + MFDPage.new(mfd, myCanvas, device, svg, "XMInfo", "AUX - XM INFORMATION") + ], }; - obj.Styles = fg1000.XMInfoStyles.new(); - obj.Options = fg1000.XMInfoOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.XMInfoController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var XMInfo = topMenu(device, obj, nil); + obj.controller = fg1000.XMInfoController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfoController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfoController.nas index 109a86a74..765eb4a00 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfoController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/XMInfo/XMInfoController.nas @@ -3,7 +3,93 @@ var XMInfoController = { new : func (page, svg) { - var obj = { parents : [ XMInfoController ] }; + var obj = { + parents : [ XMInfoController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadio.nas b/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadio.nas index 810498291..26c514678 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadio.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadio.nas @@ -4,28 +4,12 @@ var XMRadio = new : func (mfd, myCanvas, device, svg) { var obj = { - title : "AUX - XM RADIO", - _group : myCanvas.createGroup("XMRadioLayer"), - parents : [ NavMap, device.addPage("XMRadio", "XMRadioGroup") ], - symbols : {}, + parents : [ + XMRadio, + MFDPage.new(mfd, myCanvas, device, svg, "XMRadio", "AUX - XM RADIO") + ], }; - obj.Styles = fg1000.XMRadioStyles.new(); - obj.Options = fg1000.XMRadioOptions.new(); - obj.device = device; - obj.mfd = mfd; - - obj.controller = fg1000.XMRadioController.new(obj, svg); - - # Dynamic elements - var elements = [ - - ]; - - foreach (var element; elements) { - obj.symbols[element] = svg.getElementById(element); - } - var topMenu = func(device, pg, menuitem) { pg.clearMenu(); resetMenuColors(device); @@ -58,6 +42,8 @@ var XMRadio = topMenu(device, obj, nil); + obj.controller = fg1000.XMRadioController.new(obj, svg); + return obj; }, offdisplay : func() { @@ -70,9 +56,11 @@ 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(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + me.controller.ondisplay(); }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadioController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadioController.nas index 0a84b239c..08f6b19ad 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadioController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/XMRadio/XMRadioController.nas @@ -3,7 +3,93 @@ var XMRadioController = { new : func (page, svg) { - var obj = { parents : [ XMRadioController ] }; + var obj = { + parents : [ XMRadioController ], + _crsrToggle : 0, + _recipient : nil, + _page : page, + }; + return obj; }, + + + # Input Handling + handleCRSR : func() { + me._crsrToggle = (! me._crsrToggle); + if (me._crsrToggle) { + } else { + me._page.hideCRSR(); + } + return emesary.Transmitter.ReceiptStatus_Finished; + }, + handleFMSInner : func(value) { + if (me._crsrToggle == 1) { + # Scroll through whatever is the current list + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSInner(value); + } + }, + handleFMSOuter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + # Pass to the page group controller to display and scroll through the page group menu + return me._page.mfd._pageGroupController.handleFMSOuter(value); + } + }, + handleEnter : func(value) { + if (me._crsrToggle == 1) { + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + RegisterWithEmesary : func(transmitter = nil){ + if (transmitter == nil) + transmitter = emesary.GlobalTransmitter; + + if (me._recipient == nil){ + me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me._page.device.designation); + var pfd_obj = me._page.device; + var controller = me; + me._recipient.Receive = func(notification) + { + if (notification.Device_Id == pfd_obj.device_id + and notification.NotificationType == notifications.PFDEventNotification.DefaultType) { + if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed + and notification.EventParameter != nil) + { + var id = notification.EventParameter.Id; + var value = notification.EventParameter.Value; + #printf("Button pressed " ~ id ~ " " ~ value); + if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(); + if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value); + if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value); + if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value); + } + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + } + transmitter.Register(me._recipient); + me.transmitter = transmitter; + }, + DeRegisterWithEmesary : func(transmitter = nil){ + # remove registration from transmitter; but keep the recipient once it is created. + if (me.transmitter != nil) + me.transmitter.DeRegister(me._recipient); + me.transmitter = nil; + }, + + # Reset controller if required when the page is displayed or hidden + ondisplay : func() { + me.RegisterWithEmesary(); + }, + offdisplay : func() { + me.DeRegisterWithEmesary(); + }, + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/constants.nas b/Aircraft/Instruments-3d/FG1000/Nasal/constants.nas new file mode 100644 index 000000000..03fc4f6dc --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/Nasal/constants.nas @@ -0,0 +1,116 @@ +# Constants to define the display area, for placement of elements. We +# could try to do something with a layout, but the position and size of +# elements is fixed. Can't be member variables of MFD as they are +# self-referential. + +var DISPLAY = { WIDTH : 1024, HEIGHT : 768 }; +var HEADER_HEIGHT = 56; +var FOOTER_HEIGHT = 25; +var EIS_WIDTH = 150; + +# Size of data display on the right hand side of the MFD +var DATA_DISPLAY = { + WIDTH : 300, + HEIGHT : DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT, + X : DISPLAY.WIDTH - 300, + Y : HEADER_HEIGHT, +}; + +# Map dimensions when the data display is not present +var MAP_FULL = { + CENTER : { X : ((DISPLAY.WIDTH - EIS_WIDTH) / 2 + EIS_WIDTH), + Y : ((DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT) / 2 + HEADER_HEIGHT), }, + X : EIS_WIDTH, + Y : HEADER_HEIGHT, + WIDTH : DISPLAY.WIDTH - EIS_WIDTH, + HEIGHT : DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT, +}; + +# Map dimensions when the data display is present +var MAP_PARTIAL = { + X : EIS_WIDTH, + Y : HEADER_HEIGHT, + WIDTH : DISPLAY.WIDTH - EIS_WIDTH - DATA_DISPLAY.WIDTH, + HEIGHT : DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT, + CENTER : { X : ((DISPLAY.WIDTH - EIS_WIDTH - DATA_DISPLAY.WIDTH) / 2 + EIS_WIDTH), + Y : ((DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT) / 2 + HEADER_HEIGHT), }, +}; + +# When the CRSR is selecting fields, this is the period for changing the +# cursor color between normal and highlight (defined below) +# Constants for the hard-buttons on the fascia +FASCIA = { + NAV_VOL : 0, + NAV_VOL_TOGGLE : 1, + NAV_FREQ_TRANSFER :2, + NAV_OUTER : 3, + NAV_INNER : 4, + NAV_TOGGLE : 5, + HEADING : 6, + HEADING_PRESS : 7, + + # Joystick + RANGE : 8, + JOYSTICK_HORIZONTAL : 9, + JOYSTICK_VERTICAL : 10, + + #CRS/BARO + BARO : 11, + CRS : 12, + CRS_CENTER : 13, + + COM_OUTER : 14, + COM_INNER : 15, + COM_TOGGLE : 16, + + COM_FREQ_TRANSFER : 17, + COM_FREQ_TRANSFER_HOLD :18, # Auto-tunes to 121.2 when pressed for 2 seconds + + COM_VOL: 19, + COM_VOL_TOGGLE: 20, + + DTO : 21, + FPL : 22, + CLR : 23, + CLR_HOLD: 24, # Holding the CLR button for 2 seconds on the MFD displays the Nav Map + + FMS_OUTER : 25, + FMS_INNER : 26, + FMS_CRSR : 27, + + MENU : 28, + PROC : 29, + ENT : 30, + + ALT_OUTER : 31, + ALT_INNER : 32, + + # Autopilot controls + AP : 33, + HDG : 34, + NAV : 35, + APR : 36, + VS : 37, + FLC : 38, + FD : 39, + ALT : 40, + VNV : 41, + BC : 42, + NOSE_UP : 43, + NOSE_DOWN : 44, + +}; + +var SURFACE_TYPES = { + 1 : "HARD SURFACE", # Asphalt + 2 : "HARD SURFACE", # Concrete + 3 : "TURF", + 4 : "DIRT", + 5 : "GRAVEL", + # Helipads + 6 : "HARD SURFACE", # Asphalt + 7 : "HARD SURFACE", # Concrete + 8 : "TURF", + 9 : "DIRT", + 0 : "GRAVEL", +}; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/createpgs.pl b/Aircraft/Instruments-3d/FG1000/Nasal/createpgs.pl index 584163af0..548ea36dd 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/createpgs.pl +++ b/Aircraft/Instruments-3d/FG1000/Nasal/createpgs.pl @@ -5,7 +5,7 @@ use warnings; my %pages = ("Stormscope" => "MAP - STORMSCOPE", "WeatherDataLink" => "MAP - WEATHER DATA LINK", "TAWS" => "MAP - TAWS", -"AirportInfo" => "WPT - AIRPORT INFORMATION", +#"AirportInfo" => "WPT - AIRPORT INFORMATION", "AirportDirectory" => "WPT - AIRPORT DIRECTORY", "AirportDeparture" => "WPT - AIRPORT DEPARTURE INFORMATION", "AirportArrival" => "WPT - AIRPORT ARRIVAL INFORMATION", @@ -30,7 +30,7 @@ my %pages = ("Stormscope" => "MAP - STORMSCOPE", "Checklist3" => "LST - CHECKLIST 3", "Checklist4" => "LST - CHECKLIST 4", "Checklist5" => "LST - CHECKLIST 5", -"NearestAirports" => "NRST - NEAREST AIRPORTS", +#"NearestAirports" => "NRST - NEAREST AIRPORTS", "NearestIntersections" => "NRST - NEAREST INTERSECTIONS", "NearestNDB" => "NRST - NEAREST NDB", "NearestVOR" => "NRST - NEAREST VOR", diff --git a/Nasal/canvas/PFD/ArrowElement.nas b/Nasal/canvas/PFD/ArrowElement.nas new file mode 100644 index 000000000..d203bc0c7 --- /dev/null +++ b/Nasal/canvas/PFD/ArrowElement.nas @@ -0,0 +1,41 @@ +# PFD UI Element - Arrow UI Element. Can have values set and retrieved +# and has a separate arrow icon to indicate selection +var ArrowElement = +{ + new : func (pagename, svg, name, value, style=nil) + { + var obj = { + parents : [ ArrowElement, PFD.UIElement ], + _name : pagename ~ name, + _value : value, + _style : style, + }; + + if (style == nil) obj._style = PFD.DefaultStyle; + + obj._symbol = svg.getElementById(obj._name); + assert(obj._symbol != nil, "Unable to find element " ~ obj._name); + + obj.unhighlightElement(); + + return obj; + }, + + getName : func() { return me._name; }, + getValue : func() { return me._value; }, + setValue : func(value) { me._value = value; }, + setVisible : func(vis) { me._symbol.setVisible(vis); }, + highlightElement : func() { + me._symbol.setVisible(1); + }, + unhighlightElement : func() { + me._symbol.setVisible(0); + }, + isEditable : func () { return 0; }, + isInEdit : func() { return 0; }, + enterElement : func() { return me.getValue(); }, + clearElement : func() { }, + editElement : func() { }, + incrSmall : func(value) { }, + incrLarge : func(value) { }, +}; diff --git a/Nasal/canvas/PFD/DataEntryElement.nas b/Nasal/canvas/PFD/DataEntryElement.nas new file mode 100644 index 000000000..0db0cabff --- /dev/null +++ b/Nasal/canvas/PFD/DataEntryElement.nas @@ -0,0 +1,200 @@ +# PFD DataEntryElement - Data Entry UI Element. +# +# Uses the FMS Knobs to enter a text value with a given length and character set. +# +# To use, there must be an element called [PageName][ElementName] which will +# be used for the complete string, and a set of [PageName][ElementName]{0...n} +# elements, each consisting of a single character for input. +# +var DataEntryElement = +{ + new : func (pagename, svg, name, value, size, charSet, style=nil) + { + var obj = { + parents : [ DataEntryElement, PFD.UIElement ], + _name : pagename ~ name, + _size : size, + _charSet : charSet, + _dataEntryPos : -1, + _dataEntrySymbol : [], + _style : style, + }; + + if (style == nil) obj._style = PFD.DefaultStyle; + + obj._symbol = svg.getElementById(obj._name); + assert(obj._symbol != nil, "Unable to find element" ~ obj._name); + obj.setValue(value); + + for (var i = 0; i < size; i = i + 1) { + var nodeName = obj._name ~ i; + append(obj._dataEntrySymbol, svg.getElementById(nodeName)); + assert(obj._dataEntrySymbol[i] != nil, "Unable to find element " ~ nodeName); + obj._dataEntrySymbol[i].setVisible(0); + } + + # State and timer for flashing highlighting of elements + obj._highlighted = 0; + obj._highlightedChar = 0; + obj._flashTimer = nil; + obj._flashCharTimer = nil; + + return obj; + }, + + getName : func() { return me._name; }, + getValue : func() { return me._symbol.getText(); }, + setValue : func(value) { me._symbol.setText(value); }, + setVisible : func(vis) { + me._symbol.setVisible(vis); + + # Only ever hide the character entry symbols, as they are displayed + # only when editing + if (vis == 0) { + for (var i = 0; i < me._size; i = i + 1) me._dataEntrySymbol[i].setVisible(0); + } + }, + _flashElement : func() { + if (me._highlighted == 0) { + me._symbol.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX); + me._symbol.setColorFill(me._style.HIGHLIGHT_COLOR); + me._symbol.setColor(me._style.HIGHLIGHT_TEXT_COLOR); + me._highlighted = 1; + } else { + me._symbol.setDrawMode(canvas.Text.TEXT); + me._symbol.setColor(me._style.NORMAL_TEXT_COLOR); + me._highlighted = 0; + } + }, + highlightElement : func() { + me._flashElement(); + me._flashTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashElement); + me._flashTimer.start(); + }, + unhighlightElement : func() { + if (me._flashTimer != nil) me._flashTimer.stop(); + me._flashTimer = nil; + + # Reset the highlight to a non-highlighted state. + me._highlighted = 1; + me._flashElement(); + }, + + _flashCharElement : func() { + if (me._highlighted == 0) { + me._dataEntrySymbol[me._dataEntryPos].setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX); + me._dataEntrySymbol[me._dataEntryPos].setColorFill(me._style.HIGHLIGHT_COLOR); + me._dataEntrySymbol[me._dataEntryPos].setColor(me._style.HIGHLIGHT_TEXT_COLOR); + me._highlightedChar = 1; + } else { + me._dataEntrySymbol[me._dataEntryPos].setDrawMode(canvas.Text.TEXT); + me._dataEntrySymbol[me._dataEntryPos].setColor(me._style.NORMAL_TEXT_COLOR); + me._highlightedChar = 0; + } + }, + highlightCharElement : func() { + me._flashCharElement(); + me._flashCharTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashCharElement); + me._flashCharTimer.start(); + }, + unhighlightCharElement : func() { + if (me._flashCharTimer != nil) me._flashCharTimer.stop(); + me._flashCharTimer = nil; + + # Reset the highlight to a non-highlighted state. + me._highlightedChar = 1; + me._flashCharElement(); + }, + isEditable : func () { return 1; }, + isInEdit : func() { return (me._dataEntryPos != -1); }, + + enterElement : func() { + # Handle pressing enter to confirm this element. + # - Hiding the per-character entry fields + # - concatenating the data that's been entered into a string + # - displaying the string in the (highlighted) top level element + # + # Also pass back the string to the caller. + + var val = ""; + + for (var i = 0; i < me._size; i = i + 1) { + if (me._dataEntrySymbol[i].getText() != "_") { + val = val ~ me._dataEntrySymbol[i].getText(); + } + me._dataEntrySymbol[i].setVisible(0); + } + + me._symbol.setText(val); + me._symbol.setVisible(1); + me.highlightElement(); + me._dataEntryPos = -1; + return val; + }, + clearElement : func() { + # Cancel editing this element by + # - Hiding the per-character entry fields + # - Highlighting the top level element + + for (var i = 0; i < me._size; i = i + 1) { + me._dataEntrySymbol[i].setVisible(0); + } + + me._symbol.setVisible(1); + me.highlightElement(); + me._dataEntryPos = -1; + }, + incrSmall : func(value) { + # Change the value of this element, or start editing it if we're not already + # doing so. + + if (me._dataEntryPos == -1) { + # Start editing by hiding the top level element, and displaying and + # resetting the character entry fields. + me._dataEntryPos = 0; + + me._symbol.setVisible(0); + + for (var i = 0; i < me._size; i = i + 1) { + me._dataEntrySymbol[i].setText("_"); + me._dataEntrySymbol[i].setVisible(1); + } + + # Highlight the first character element to indicate we're editing it + me.highlightCharElement(); + } else { + var charSym = me._dataEntrySymbol[me._dataEntryPos]; + var incr_or_decr = (value > 0) ? 1 : -1; + + # Change the value of the data element + var val = charSym.getText(); + + if (val == "_") { + # Not previously set, so set to the first or last characterset entry + # depending on direction + if (incr_or_decr > 0) { + charSym.setText(chr(me._charSet[0])); + } else { + charSym.setText(chr(me._charSet[size(me._charSet) -1])); + } + } else { + var curIdx = find(val, me._charSet); + + if (curIdx == -1) die("Failed to find character " ~ val ~ " in dataEntryElement " ~ element); + curIdx = math.mod(curIdx + incr_or_decr, size(me._charSet)); + charSym.setText(chr(me._charSet[curIdx])); + } + } + }, + incrLarge : func(value) { + # Change the cursor position within a data element + var incr_or_decr = (value > 0) ? 1 : -1; + + if ((me._dataEntryPos == 0) and (incr_or_decr == -1)) return; # Don't scroll off the start + if ((me._dataEntryPos == me._size -1) and (incr_or_decr == 1)) return; # Don't scroll off the end + + me.unhighlightCharElement(); + me._dataEntryPos = me._dataEntryPos + incr_or_decr; + me.highlightCharElement(); + }, +}; diff --git a/Nasal/canvas/PFD/DefaultStyle.nas b/Nasal/canvas/PFD/DefaultStyle.nas new file mode 100644 index 000000000..13d1a6500 --- /dev/null +++ b/Nasal/canvas/PFD/DefaultStyle.nas @@ -0,0 +1,13 @@ +# Default Styles for the MFD Elements +var DefaultStyle = { + CURSOR_BLINK_PERIOD : 0.5, + + HIGHLIGHT_COLOR : "#80ffff", + HIGHLIGHT_TEXT_COLOR : "#000000", + + NORMAL_TEXT_COLOR : "#80ffff", + + # Colors for the horizontal scroll arrows for ScrollElement + SCROLL_AVAILABLE : "#80ffff", + SCROLL_UNAVAILABLE : "#eeeeee" +}; diff --git a/Nasal/canvas/PFD/GroupElement.nas b/Nasal/canvas/PFD/GroupElement.nas new file mode 100644 index 000000000..5e516b8b9 --- /dev/null +++ b/Nasal/canvas/PFD/GroupElement.nas @@ -0,0 +1,155 @@ +# UIGroup.nas. A group of UI Elements that can be scrolled through +var GroupElement = +{ + +new : func (pageName, svg, elementNames, size, highlightElement, arrow=0, style=nil) +{ + var obj = { + parents : [ GroupElement ], + _pageName : pageName, + _svg : svg, + _style : style, + + # A hash mapping keys to the element name prefix of an SVG element + _elementNames : elementNames, + + # The size of the group. For each of the ._elementNames hash values there + # must be an SVG Element [pageName][elementName]{0...pageSize} + _size : size, + + # Current size of the selectable elements. + _currentSize : 0, + + # ElementName to be highlighted. Must be an hash value from ._elementNames + _highlightElement : highlightElement, + + # Whether this is an arrow'd list. If so then highlightElement will be + # hidden/shown for highlighting purposes. + _arrow : arrow, + + _elements : [], + _crsrIndex : -1, # Cursor index into the elements array + }; + + if (style == nil) obj._style = PFD.DefaultStyle; + + for (var i = 0; i < size; i = i + 1) { + if (obj._arrow == 1) { + append(obj._elements, PFD.ArrowElement.new(pageName, svg, highlightElement ~ i, i, obj._style)); + } else { + append(obj._elements, PFD.TextElement.new(pageName, svg, highlightElement ~ i, i, obj._style)); + } + } + + return obj; +}, + +# Set the values of the group. values_array is an array of hashes, each of which +# has keys that match those of ._elementNames +setValues : func (values_array) { + + # Determine how many of these we display + me._currentSize = math.min(me._size, size(values_array)); + + for (var i = 0; i < me._currentSize; i = i + 1) { + var values = values_array[i]; + foreach (var k; keys(values)) { + if (k == me._highlightElement) { + me._elements[i].unhighlightElement(); + me._elements[i].setValue(values[k]); + } else { + var name = me._pageName ~ k ~ i; + var element = me._svg.getElementById(name); + assert(element != nil, "Unable to find element " ~ name); + element.setVisible(1); + element.setText(values[k]); + } + } + } + + # Hide any further elements + if (me._currentSize < me._size) { + for (var i = me._currentSize; i < me._size; i = i + 1) { + foreach (var k; me._elementNames) { + if (k == me._highlightElement) { + me._elements[i].setVisible(0); + } else { + me._svg.getElementById(k ~ i).setVisible(0); + } + } + } + } +}, + + +# Methods to add dynamic elements to the group. Must be called in the +# scroll order, as they are simply appended to the end of the list of elements! +addArrowElement : func(name, value) { + append(me._elements, ArrowElement.new(me._pageName, me._svg, name, value)); +}, +addTextElement : func(name, value) { + append(me._elements, TextElement.new(me._pageName, me._svg, name, value)); +}, + +showCRSR : func() { + if (me._currentSize == 0) return; + me._crsrIndex = 0; + me._elements[me._crsrIndex].highlightElement(); +}, +hideCRSR : func() { + if (me._crsrIndex == -1) return; + me._elements[me._crsrIndex].unhighlightElement(); + me.setCRSR(-1); +}, +setCRSR : func(index) { + me._crsrIndex = math.min(index, me._currentSize -1); +}, +getCursorElementName : func() { + if (me._crsrIndex == -1) return nil; + return me._elements[me._crsrIndex].name; +}, +isCursorOnDataEntryElement : func() { + if (me._crsrIndex == -1) return 0; + return isa(me._elements[me._crsrIndex], DataEntryElement); +}, +enterElement : func() { + if (me._crsrIndex == -1) return; + return me._elements[me._crsrIndex].enterElement(); +}, +getValue : func() { + if (me._crsrIndex == -1) return nil; + return me._elements[me._crsrIndex].getValue(); +}, +clearElement : func() { + if (me._crsrIndex == -1) return; + me._elements[me._crsrIndex].clearElement(); +}, +incrSmall : func(value) { + if (me._crsrIndex == -1) return; + var incr_or_decr = (value > 0) ? 1 : -1; + if (me._elements[me._crsrIndex].isInEdit()) { + # We're editing, so pass to the element. + #print("Moving cursor to next character entry"); + me._elements[me._crsrIndex].incrSmall(); + } else { + # Move to next selection element + me._elements[me._crsrIndex].unhighlightElement(); + me._crsrIndex = math.mod(me._crsrIndex + incr_or_decr, me._currentSize); + me._elements[me._crsrIndex].highlightElement(); + } +}, +incrLarge : func(val) { + if (me._crsrIndex == -1) return; + var incr_or_decr = (val > 0) ? 1 : -1; + if (me._elements[me._crsrIndex].isInEdit()) { + # We're editing, so pass to the element. + #print("Moving cursor to next character entry"); + me._elements[me._crsrIndex].incrLarge(); + } else { + # Move to next selection element + me._elements[me._crsrIndex].unhighlightElement(); + me._crsrIndex = math.mod(me._crsrIndex + incr_or_decr, me._currentSize); + me._elements[me._crsrIndex].highlightElement(); + } +}, +}; diff --git a/Nasal/canvas/PFD/ScrollElement.nas b/Nasal/canvas/PFD/ScrollElement.nas new file mode 100644 index 000000000..b16776963 --- /dev/null +++ b/Nasal/canvas/PFD/ScrollElement.nas @@ -0,0 +1,118 @@ +# PFD UI Element - Scrolling UI Text Element. +# Has a set of values and arrows left & right to indicate whether there are +# further data items to scroll through. +var ScrollElement = +{ + + new : func (pageName, svg, name, values, initialIndex=0, style=nil) + { + var obj = { + parents : [ ScrollElement, PFD.UIElement ], + _name : pageName ~ name, + _values : values, + _index : 0, + _style : style, + }; + + if (style == nil) obj._style = PFD.DefaultStyle; + + obj._symbol = svg.getElementById(obj._name); + assert(obj._symbol != nil, "Unable to find element " ~ obj._name); + + obj._leftsymbol = svg.getElementById(obj._name ~ "Left"); + assert(obj._leftsymbol != nil, "Unable to find element " ~ obj._name ~ "Left"); + + obj._rightsymbol = svg.getElementById(obj._name ~ "Right"); + assert(obj._rightsymbol != nil, "Unable to find element " ~ obj._name ~ "Right"); + + obj._index = initialIndex; + assert(initialIndex < size(values) , "Initial index " ~ initialIndex ~ " extends past end of value array"); + + # State and timer for flashing highlighting of elements + obj._highlighted = 0; + obj._flashTimer = nil; + + obj.updateValues(); + + return obj; + }, + + updateValues : func() { + if (me._index == 0 ) { + me._leftsymbol.setColorFill(me._style.SCROLL_UNAVAILABLE); + me._leftsymbol.setColor(me._style.SCROLL_UNAVAILABLE); + } else { + me._leftsymbol.setColorFill(me._style.SCROLL_AVAILABLE); + me._leftsymbol.setColor(me._style.SCROLL_AVAILABLE); + } + + if ((size(me._values) > 0) and (me._index < (size(me._values) -1))) { + me._rightsymbol.setColorFill(me._style.SCROLL_AVAILABLE); + me._rightsymbol.setColor(me._style.SCROLL_AVAILABLE); + } else { + me._rightsymbol.setColorFill(me._style.SCROLL_UNAVAILABLE); + me._rightsymbol.setColor(me._style.SCROLL_UNAVAILABLE); + } + + me._symbol.setText(me._values[me._index]); + }, + + getName : func() { return me._name; }, + getValue : func() { return me._symbol.getText(); }, + setValue : func(value) { + var idx = find(value, me._values); + if (idx != -1) { + me._index = idx; + me._symbol.setText(value); + } + }, + setValues : func(values) { + me._values = values; + me._index = 0; + me.updateValues(); + }, + setVisible : func(vis) { + me._symbol.setVisible(vis); + me._leftsymbol.setVisible(vis); + me._rightsymbol.setVisible(vis); + }, + _flashElement : func() { + if (me._highlighted == 0) { + me._symbol.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX); + me._symbol.setColorFill(me._style.HIGHLIGHT_COLOR); + me._symbol.setColor(me._style.HIGHLIGHT_TEXT_COLOR); + me._highlighted = 1; + } else { + me._symbol.setDrawMode(canvas.Text.TEXT); + me._symbol.setColor(me._style.NORMAL_TEXT_COLOR); + me._highlighted = 0; + } + }, + highlightElement : func() { + me._flashElement(); + me._flashTimer = maketimer(0.5, me, me._flashElement); + me._flashTimer.start(); + }, + unhighlightElement : func() { + if (me._flashTimer != nil) me._flashTimer.stop(); + me._flashTimer = nil; + + # Reset the highlight to a non-highlighted state. + me._highlighted = 1; + me._flashElement(); + }, + isEditable : func () { return 0; }, + isInEdit : func() { return 0; }, + enterElement : func() { return me.getValue(); }, + clearElement : func() { }, + editElement : func() { }, + incrSmall : func(value) { + # Increment the scroll value; + var incr_or_decr = (value > 0) ? 1 : -1; + if ((me._index + incr_or_decr) < 0) return; + if ((me._index + incr_or_decr) > (size(me._values) -1)) return; + me._index = me._index + incr_or_decr; + me.updateValues(); + }, + incrLarge : func(value) { }, +}; diff --git a/Nasal/canvas/PFD/TextElement.nas b/Nasal/canvas/PFD/TextElement.nas new file mode 100644 index 000000000..503523625 --- /dev/null +++ b/Nasal/canvas/PFD/TextElement.nas @@ -0,0 +1,62 @@ +# PFD UI Element - Text UI Element. Can have values set and retrieved +var TextElement = +{ + new : func (pagename, svg, name, value="", style=nil) + { + var obj = { + parents : [ TextElement, PFD.UIElement ], + _name : pagename ~ name, + _edit : 0, + _style : style, + }; + + if (style == nil) obj._style = PFD.DefaultStyle; + + obj._symbol = svg.getElementById(obj._name); + if (obj._symbol == nil) die("Unable to find element " ~ obj._name); + obj.setValue(value); + + # State and timer for flashing highlighting of elements + obj._highlighted = 0; + obj._flashTimer = nil; + + return obj; + }, + + getName : func() { return me._name; }, + getValue : func() { return me._symbol.getText(); }, + setValue : func(value) { me._symbol.setText(value); }, + setVisible : func(vis) { me._symbol.setVisible(vis); }, + _flashElement : func() { + if (me._highlighted == 0) { + me._symbol.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX); + me._symbol.setColorFill(me._style.HIGHLIGHT_COLOR); + me._symbol.setColor(me._style.HIGHLIGHT_TEXT_COLOR); + me._highlighted = 1; + } else { + me._symbol.setDrawMode(canvas.Text.TEXT); + me._symbol.setColor(me._style.NORMAL_TEXT_COLOR); + me._highlighted = 0; + } + }, + highlightElement : func() { + me._flashElement(); + me._flashTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashElement); + me._flashTimer.start(); + }, + unhighlightElement : func() { + if (me._flashTimer != nil) me._flashTimer.stop(); + me._flashTimer = nil; + + # Reset the highlight to a non-highlighted state. + me._highlighted = 1; + me._flashElement(); + }, + isEditable : func () { return 0; }, + isInEdit : func() { return 0; }, + enterElement : func() { return me.getValue(); }, + clearElement : func() { }, + editElement : func() { }, + incrSmall : func(value) { }, + incrLarge : func(value) { }, +}; diff --git a/Nasal/canvas/PFD/UIElement.nas b/Nasal/canvas/PFD/UIElement.nas new file mode 100644 index 000000000..9ff752a4f --- /dev/null +++ b/Nasal/canvas/PFD/UIElement.nas @@ -0,0 +1,29 @@ +# MFD UI Element - abstract class +var UIElement = +{ + new : func (name, value) + { + var obj = { + parents : [ UIElement ], + _name : name, + _edit : 0, + _value : value, + }; + + return obj; + }, + + getName : func() { return me._name; }, + setValue : func(value) { me._value = value; }, + getValue : func() { return me._value; }, + highlightElement : func() { }, + unhighlightElement : func() { }, + isEditable : func () { return 0; }, + isInEdit : func() { return me._edit; }, + enterElement : func() { me._edit = 0; return me._value; }, + clearElement : func() { me._edit = 0; }, + editElement : func() { me._edit = 1; }, + setVisible : func(vis) { }, + incrSmall : func(value) { }, + incrLarge : func(value) { }, +}; diff --git a/Nasal/canvas/api.nas b/Nasal/canvas/api.nas index 60b053250..3b222896a 100644 --- a/Nasal/canvas/api.nas +++ b/Nasal/canvas/api.nas @@ -617,6 +617,10 @@ var Text = { { me.set("text", typeof(text) == 'scalar' ? text : ""); }, + getText: func() + { + return me.get("text"); + }, # enable reduced property I/O update function enableUpdate: func () { diff --git a/gui/dialogs/fg1000.xml b/gui/dialogs/fg1000.xml index 4bd9e9611..9577c33d4 100644 --- a/gui/dialogs/fg1000.xml +++ b/gui/dialogs/fg1000.xml @@ -382,48 +382,51 @@ ); append(listeners, softkey_listener); - #append(listeners, setlistener("/sim/gui/dialogs/fg1000/fms-incr-large-pressed", func(v) { mfd._pageGroupController.incrFMSOuter(); } )); - #append(listeners, setlistener("/sim/gui/dialogs/fg1000/fms-incr-small-pressed", func(v) { mfd._pageGroupController.incrFMSInner(); } )); - #append(listeners, setlistener("/sim/gui/dialogs/fg1000/fms-decr-large-pressed", func(v) { mfd._pageGroupController.decrFMSOuter(); } )); - #append(listeners, setlistener("/sim/gui/dialogs/fg1000/fms-decr-small-pressed", func(v) { mfd._pageGroupController.decrFMSInner(); } )); - append(listeners, setlistener("/sim/gui/dialogs/fg1000/fms-incr-large-pressed", func(v) { - var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.MFD.FASCIA.FMS_OUTER, Value: 1.0 }); + var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.FASCIA.FMS_OUTER, Value: 1.0 }); emesary.GlobalTransmitter.NotifyAll(notification); } )); append(listeners, setlistener("/sim/gui/dialogs/fg1000/fms-incr-small-pressed", func(v) { - var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.MFD.FASCIA.FMS_INNER, Value: 1.0 }); + var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.FASCIA.FMS_INNER, Value: 1.0 }); emesary.GlobalTransmitter.NotifyAll(notification); } )); append(listeners, setlistener("/sim/gui/dialogs/fg1000/fms-decr-large-pressed", func(v) { - var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.MFD.FASCIA.FMS_OUTER, Value: -1.0 }); + var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.FASCIA.FMS_OUTER, Value: -1.0 }); emesary.GlobalTransmitter.NotifyAll(notification); } )); append(listeners, setlistener("/sim/gui/dialogs/fg1000/fms-decr-small-pressed", func(v) { - var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.MFD.FASCIA.FMS_INNER, Value: -1.0 }); + var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.FASCIA.FMS_INNER, Value: -1.0 }); emesary.GlobalTransmitter.NotifyAll(notification); } )); append(listeners, setlistener("/sim/gui/dialogs/fg1000/range-decr-pressed", func(v) { - var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.MFD.FASCIA.RANGE, Value: -1.0 }); + var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.FASCIA.RANGE, Value: -1.0 }); emesary.GlobalTransmitter.NotifyAll(notification); } )); append(listeners, setlistener("/sim/gui/dialogs/fg1000/range-incr-pressed", func(v) { - var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.MFD.FASCIA.RANGE, Value: 1.0 }); + var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.FASCIA.RANGE, Value: 1.0 }); emesary.GlobalTransmitter.NotifyAll(notification); } )); append(listeners, setlistener("/sim/gui/dialogs/fg1000/crsr-pressed", func(v) { - var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.MFD.FASCIA.FMS_CRSR, Value: 1.0 }); + var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.FASCIA.FMS_CRSR, Value: 1.0 }); emesary.GlobalTransmitter.NotifyAll(notification); } )); + append(listeners, setlistener("/sim/gui/dialogs/fg1000/ent-pressed", func(v) { + var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.FASCIA.ENT, Value: 1.0 }); + emesary.GlobalTransmitter.NotifyAll(notification); + } )); + append(listeners, setlistener("/sim/gui/dialogs/fg1000/clr-pressed", func(v) { + var notification = notifications.PFDEventNotification.new("MFD", 1, notifications.PFDEventNotification.HardKeyPushed, { Id: fg1000.FASCIA.CLR, Value: 1.0 }); + emesary.GlobalTransmitter.NotifyAll(notification); + } )); ]]> @@ -824,6 +827,11 @@ 25 CLR CLR + + property-assign + /sim/gui/dialogs/fg1000/clr-pressed + 1 +