2019-12-30 21:24:00 +00:00
|
|
|
var departurePage = {
|
|
|
|
title: [nil, nil, nil],
|
|
|
|
subtitle: [nil, nil],
|
|
|
|
fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]],
|
|
|
|
arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]],
|
|
|
|
arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]],
|
|
|
|
L1: [nil, nil, "ack"], # content, title, colour
|
|
|
|
L2: [nil, nil, "ack"],
|
|
|
|
L3: [nil, nil, "ack"],
|
|
|
|
L4: [nil, nil, "ack"],
|
|
|
|
L5: [nil, nil, "ack"],
|
|
|
|
L6: [nil, nil, "ack"],
|
|
|
|
C1: [nil, nil, "ack"],
|
|
|
|
C2: [nil, nil, "ack"],
|
|
|
|
C3: [nil, nil, "ack"],
|
|
|
|
C4: [nil, nil, "ack"],
|
|
|
|
C5: [nil, nil, "ack"],
|
|
|
|
C6: [nil, nil, "ack"],
|
|
|
|
R1: [nil, nil, "ack"],
|
|
|
|
R2: [nil, nil, "ack"],
|
|
|
|
R3: [nil, nil, "ack"],
|
|
|
|
R4: [nil, nil, "ack"],
|
|
|
|
R5: [nil, nil, "ack"],
|
|
|
|
R6: [nil, nil, "ack"],
|
|
|
|
depAirport: nil,
|
|
|
|
runways: nil,
|
|
|
|
selectedRunway: nil,
|
|
|
|
sids: nil,
|
|
|
|
computer: nil,
|
|
|
|
enableScroll: 0,
|
2019-12-31 17:48:23 +00:00
|
|
|
scroll: 0,
|
2019-12-30 21:24:00 +00:00
|
|
|
_runways: nil,
|
|
|
|
_sids: nil,
|
|
|
|
new: func(icao, computer) {
|
|
|
|
var lr = {parents:[departurePage]};
|
|
|
|
lr.id = icao;
|
|
|
|
lr.computer = computer;
|
|
|
|
lr._setupPageWithData();
|
|
|
|
lr.updateRunways();
|
2019-12-31 17:48:23 +00:00
|
|
|
if (fmgc.fp[2].departure_runway != nil) {
|
|
|
|
lr.selectedRunway = fmgc.fp[2].departure_runway;
|
|
|
|
}
|
2019-12-30 21:24:00 +00:00
|
|
|
lr.updateActiveRunway();
|
|
|
|
return lr;
|
|
|
|
},
|
|
|
|
del: func() {
|
|
|
|
return nil;
|
|
|
|
},
|
|
|
|
_setupPageWithData: func() {
|
|
|
|
me.title = ["DEPARTURE", " FROM ", left(me.id, 4)];
|
|
|
|
if (!TMPYActive[me.computer].getBoolValue()) {
|
|
|
|
me.L6 = [" RETURN END", nil, "wht"];
|
|
|
|
} else {
|
|
|
|
me.L6 = [" F-PLN", " TMPY", "yel"];
|
|
|
|
me.arrowsColour[0][5] = "yel";
|
|
|
|
}
|
|
|
|
|
|
|
|
me.C1 = ["------- ", "SID", "wht"];
|
|
|
|
me.R1 = ["-------", "TRANS ", "wht"];
|
|
|
|
me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]];
|
|
|
|
me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]];
|
|
|
|
me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]];
|
|
|
|
},
|
|
|
|
updateActiveRunway: func() {
|
|
|
|
if (me.selectedRunway != nil) {
|
|
|
|
if (fmgc.fp[2].departure_runway != nil) {
|
|
|
|
if (fmgc.fp[2].departure_runway.id == me.selectedRunway.id) {
|
2019-12-31 17:48:23 +00:00
|
|
|
me.L1 = [fmgc.fp[2].departure_runway.id, " RWY", "grn"];
|
2019-12-30 21:24:00 +00:00
|
|
|
} elsif (fmgc.fp[me.computer].departure_runway != nil) {
|
|
|
|
me.L1 = [fmgc.fp[me.computer].departure_runway.id, " RWY", "yel"];
|
|
|
|
} else {
|
|
|
|
me.L1 = ["---", " RWY", "wht"];
|
|
|
|
}
|
|
|
|
} elsif (fmgc.fp[me.computer].departure_runway != nil) {
|
|
|
|
me.L1 = [fmgc.fp[me.computer].departure_runway.id, " RWY", "yel"];
|
|
|
|
} else {
|
|
|
|
me.L1 = ["---", " RWY", "wht"];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
me.L1 = ["---", " RWY", "wht"];
|
|
|
|
}
|
|
|
|
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
|
|
|
|
},
|
|
|
|
updateRunways: func() {
|
|
|
|
me.depAirport = findAirportsByICAO(left(me.id, 4));
|
|
|
|
me._runways = keys(me.depAirport[0].runways);
|
|
|
|
me.runways = sort(me._runways,func(a,b) cmp(a,b));
|
|
|
|
|
|
|
|
me.fourRunways = [nil, nil, nil, nil];
|
|
|
|
|
|
|
|
if (size(me.runways) >= 1) {
|
2019-12-31 17:48:23 +00:00
|
|
|
me.L2 = [" " ~ me.runways[0 + me.scroll], nil, "blu"];
|
|
|
|
me.C2 = [math.round(me.depAirport[0].runways[me.runways[0 + me.scroll]].length) ~ "M", nil, "blu"];
|
|
|
|
me.R2 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[0 + me.scroll]].heading), nil, "blu"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.arrowsMatrix[0][1] = 1;
|
|
|
|
me.arrowsColour[0][1] = "blu";
|
|
|
|
}
|
|
|
|
if (size(me.runways) >= 2) {
|
2019-12-31 17:48:23 +00:00
|
|
|
me.L3 = [" " ~ me.runways[1 + me.scroll], nil, "blu"];
|
|
|
|
me.C3 = [math.round(me.depAirport[0].runways[me.runways[1 + me.scroll]].length) ~ "M", nil, "blu"];
|
|
|
|
me.R3 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[1 + me.scroll]].heading), nil, "blu"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.arrowsMatrix[0][2] = 1;
|
|
|
|
me.arrowsColour[0][2] = "blu";
|
|
|
|
}
|
|
|
|
if (size(me.runways) >= 3) {
|
2019-12-31 17:48:23 +00:00
|
|
|
me.L4 = [" " ~ me.runways[2 + me.scroll], nil, "blu"];
|
|
|
|
me.C4 = [math.round(me.depAirport[0].runways[me.runways[2 + me.scroll]].length) ~ "M", nil, "blu"];
|
|
|
|
me.R4 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[2 + me.scroll]].heading), nil, "blu"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.arrowsMatrix[0][3] = 1;
|
|
|
|
me.arrowsColour[0][3] = "blu";
|
|
|
|
}
|
|
|
|
if (size(me.runways) >= 4) {
|
2019-12-31 17:48:23 +00:00
|
|
|
me.L5 = [" " ~ me.runways[3 + me.scroll], nil, "blu"];
|
|
|
|
me.C5 = [math.round(me.depAirport[0].runways[me.runways[3 + me.scroll]].length) ~ "M", nil, "blu"];
|
|
|
|
me.R5 = ["CRS" ~ math.round(me.depAirport[0].runways[me.runways[3 + me.scroll]].heading), nil, "blu"];
|
2019-12-30 21:24:00 +00:00
|
|
|
me.arrowsMatrix[0][4] = 1;
|
|
|
|
me.arrowsColour[0][4] = "blu";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size(me.runways) > 4) {
|
|
|
|
me.enableScroll = 1;
|
|
|
|
}
|
|
|
|
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
|
|
|
|
},
|
|
|
|
makeTmpy: func() {
|
|
|
|
if (!TMPYActive[me.computer].getBoolValue()) {
|
|
|
|
fmgc.flightplan.initTempFP(me.computer, 2);
|
|
|
|
me.L6 = [" F-PLN", " TMPY", "yel"];
|
|
|
|
me.arrowsColour[0][5] = "yel";
|
|
|
|
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
|
|
|
|
}
|
|
|
|
},
|
2019-12-31 17:48:23 +00:00
|
|
|
scrollUp: func() {
|
|
|
|
if (me.enableScroll) {
|
|
|
|
me.scroll += 1;
|
|
|
|
if (me.scroll > size(me.runways) - 4) {
|
|
|
|
me.scroll = 0;
|
|
|
|
}
|
|
|
|
me.updateRunways();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scrollDn: func() {
|
|
|
|
if (me.enableScroll) {
|
|
|
|
me.scroll -= 1;
|
|
|
|
if (me.scroll < 0) {
|
|
|
|
me.scroll = size(me.runways) - 4;
|
|
|
|
}
|
|
|
|
me.updateRunways();
|
|
|
|
}
|
|
|
|
},
|
2019-12-30 21:24:00 +00:00
|
|
|
depPushbuttonLeft: func(index) {
|
|
|
|
if (size(me.runways) >= (index - 1)) {
|
2019-12-31 17:48:23 +00:00
|
|
|
me.selectedRunway = me.depAirport[0].runway(me.runways[index - 2 + me.scroll]);
|
2019-12-30 21:24:00 +00:00
|
|
|
me.makeTmpy();
|
|
|
|
fmgc.fp[me.computer].departure_runway = me.selectedRunway;
|
|
|
|
me.updateActiveRunway();
|
|
|
|
fmgc.flightplan.checkWPOutputs(me.computer);
|
|
|
|
} else {
|
|
|
|
notAllowed(me.computer);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|