1
0
Fork 0
fgdata/Aircraft/Instruments-3d/FG1000/Nasal/IntersectionInfo/IntersectionInfoController.nas

96 lines
3.1 KiB
Text
Raw Normal View History

# IntersectionInfo Controller
var IntersectionInfoController =
{
new : func (page, svg)
{
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();
},
};