From 6bc4169e89730d85a45ad63e522353554810de45 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sat, 28 Mar 2020 15:53:50 +0000 Subject: [PATCH] DIRTO improved - added tmpy conflict with dirto error messages --- Models/Instruments/MCDU/MCDU.nas | 33 ++++++--- Nasal/FMGC/flightplan.nas | 37 +++++----- Nasal/MCDU/ARRIVAL.nas | 85 ++++++++++++++-------- Nasal/MCDU/DEPARTURE.nas | 83 ++++++++++++++-------- Nasal/MCDU/DIRTO.nas | 116 +++++++++++++++++++++++++++++-- Nasal/MCDU/LATREV.nas | 11 ++- Nasal/MCDU/MCDU.nas | 21 ++++-- Nasal/MCDU/VERTREV.nas | 7 +- 8 files changed, 296 insertions(+), 97 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index e02f5bc8..5a2fa37e 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -3609,8 +3609,20 @@ var canvas_MCDU_base = { me["Simple_PageNum"].setText("X/X"); me["Simple_PageNum"].hide(); me["Simple_Title"].show(); - me["ArrowLeft"].hide(); - me["ArrowRight"].hide(); + me["ArrowLeft"].show(); + me["ArrowRight"].show(); + me["Simple_L1_Arrow"].hide(); + me["Simple_L2_Arrow"].hide(); + me["Simple_L3_Arrow"].hide(); + me["Simple_L4_Arrow"].hide(); + me["Simple_L5_Arrow"].hide(); + me["Simple_L6_Arrow"].show(); + me["Simple_R1_Arrow"].hide(); + me["Simple_R2_Arrow"].hide(); + me["Simple_R3_Arrow"].hide(); + me["Simple_R4_Arrow"].hide(); + me["Simple_R5_Arrow"].hide(); + me["Simple_R6_Arrow"].hide(); me.fontLeft(default, default, default, default, default, default); me.fontLeftS(default, default, default, default, default, default); @@ -3621,13 +3633,13 @@ var canvas_MCDU_base = { me.fontSizeRight(normal, normal, normal, normal, normal, normal); me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); - me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); if (myDirTo[i] != nil) { - me["Simple_Title"].setText(sprintf("%s", myDirTo[i].title)); - + me["Simple_Title"].setText(sprintf("%s", myDirTo[i].title[0])); + me["Simple_Title"].setColor(getprop("MCDUC/colors/" ~ myDirTo[i].titleColour ~ "/r"), getprop("MCDUC/colors/" ~ myDirTo[i].titleColour ~ "/g"), getprop("MCDUC/colors/" ~ myDirTo[i].titleColour ~ "/b")); forindex (var matrixArrow; myDirTo[i].arrowsMatrix) { if (matrixArrow == 0) { var sign = "L"; @@ -3635,14 +3647,19 @@ var canvas_MCDU_base = { var sign = "R"; } forindex (var item; myDirTo[i].arrowsMatrix[matrixArrow]) { + if (item == 5) { + me["Simple_L6_Arrow"].setColor(getprop("MCDUC/colors/" ~ myDirTo[i].arrowsColour[0][5] ~ "/r"), getprop("MCDUC/colors/" ~ myDirTo[i].arrowsColour[0][5] ~ "/g"), getprop("MCDUC/colors/" ~ myDirTo[i].arrowsColour[0][5] ~ "/b")); + continue; + } if (myDirTo[i].arrowsMatrix[matrixArrow][item] == 1) { - me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show(); + me["arrow" ~ (item + 1) ~ sign].show(); + me["arrow" ~ (item + 1) ~ sign].setColor(getprop("MCDUC/colors/" ~ myDirTo[i].arrowsColour[matrixArrow][item] ~ "/r"), getprop("MCDUC/colors/" ~ myDirTo[i].arrowsColour[matrixArrow][item] ~ "/g"), getprop("MCDUC/colors/" ~ myDirTo[i].arrowsColour[matrixArrow][item] ~ "/b")); } else { - me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide(); + me["arrow" ~ (item + 1) ~ sign].hide(); } } } - me.colorLeftArrow(myDirTo[i].arrowsColour[0][0],myDirTo[i].arrowsColour[0][1],myDirTo[i].arrowsColour[0][2],myDirTo[i].arrowsColour[0][3],myDirTo[i].arrowsColour[0][4],myDirTo[i].arrowsColour[0][5]); + forindex (var matrixFont; myDirTo[i].fontMatrix) { diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 3b18bbf7..df1eb21a 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -69,6 +69,9 @@ var flightPlanController = { me.resetFlightplan(n); me.flightplans[n] = me.flightplans[2].clone(); me.temporaryFlag[n] = 1; + if (canvas_mcdu.myDirTo[n] != nil) { + canvas_mcdu.myDirTo[n].updateTmpy(); + } me.flightPlanChanged(n); }, @@ -82,6 +85,9 @@ var flightPlanController = { } me.resetFlightplan(n); me.temporaryFlag[n] = 0; + if (canvas_mcdu.myDirTo[n] != nil) { + canvas_mcdu.myDirTo[n].updateTmpy(); + } }, updateAirports: func(dep, arr, plan) { @@ -336,6 +342,12 @@ var flightPlanController = { }, scratchpad: func(text, index, plan) { # return 0 not in database, 1 not allowed, 2 success + if (mcdu.dirToFlag) { + setprop("MCDU[" ~ plan ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ plan ~ "]/scratchpad", "DIR TO IN PROGRESS"); + return; + } + if (!fmgc.flightPlanController.temporaryFlag[plan]) { if (text == "CLR" and me.flightplans[2].getWP(index).wp_name == "DISCONTINUITY") { var thePlan = 2; @@ -394,7 +406,9 @@ var flightPlanController = { wpDistance[n][wpt].setValue(waypointHashStore.courseAndDistanceFrom(curAircraftPos)[1]); if (wpt == 1) { - me._arrivalDist += courseDistanceFrom[1]; # distance to next waypoint, therafter to end of flightplan + if (me.flightplans[n].getWP(wpt).wp_name != "DISCONTINUITY" and and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt" and wpt <= me.arrivalIndex[n]) { + me._arrivalDist += courseDistanceFrom[1]; # distance to next waypoint, therafter to end of flightplan + } } if (left(wpID[n][wpt].getValue(), 4) == FMGCarr.getValue() and wpt != 0) { @@ -404,27 +418,13 @@ var flightPlanController = { } if (wpt > 0) { - if (me.flightplans[n].getWP(wpt).id == "DISCONTINUITY") { - if (me.flightplans[n].getWP(wpt - 1).id == "DISCONTINUITY") { - if (wpt >= 2) { - geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 2).lat, me.flightplans[n].getWP(wpt - 2).lon); - } - } else { - geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 1).lat, me.flightplans[n].getWP(wpt - 1).lon); - } - } elsif (me.flightplans[n].getWP(wpt - 1).id == "DISCONTINUITY") { - if (wpt >= 2) { - geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 2).lat, me.flightplans[n].getWP(wpt - 2).lon); - } - } else { - geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 1).lat, me.flightplans[n].getWP(wpt - 1).lon); - } + geoPosPrev.set_latlon(me.flightplans[n].getWP(wpt - 1).lat, me.flightplans[n].getWP(wpt - 1).lon); courseDistanceFromPrev = waypointHashStore.courseAndDistanceFrom(geoPosPrev); wpCoursePrev[n][wpt].setValue(courseDistanceFromPrev[0]); wpDistancePrev[n][wpt].setValue(courseDistanceFromPrev[1]); if (wpt > 1) { - if (me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt" and wpt <= me.arrivalIndex[n]) { + if (me.flightplans[n].getWP(wpt - 1).wp_name != "DISCONTINUITY" and me.flightplans[n].getWP(wpt).wp_name != "DISCONTINUITY" and me.flightplans[n].getWP(wpt - 1).wp_type != "vectors" and me.flightplans[n].getWP(wpt - 1).wp_type != "hdgToAlt" and me.flightplans[n].getWP(wpt).wp_type != "vectors" and me.flightplans[n].getWP(wpt).wp_type != "hdgToAlt" and wpt <= me.arrivalIndex[n]) { me._arrivalDist += courseDistanceFromPrev[1]; # todo - buggy. Neglect discontinuity } } @@ -502,6 +502,9 @@ var flightPlanController = { if (canvas_mcdu.myFpln[i] != nil) { canvas_mcdu.myFpln[i].updatePlan(); } + if (canvas_mcdu.myDirTo[i] != nil) { + canvas_mcdu.myDirTo[i].updateFromFpln(); + } } }, }; diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas index a6daedcc..f504f244 100644 --- a/Nasal/MCDU/ARRIVAL.nas +++ b/Nasal/MCDU/ARRIVAL.nas @@ -388,10 +388,15 @@ var arrivalPage = { }, makeTmpy: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); - me.L6 = [" F-PLN", " TMPY", "yel"]; - me.arrowsColour[0][5] = "yel"; - canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + if (!dirToFlag) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + me.L6 = [" F-PLN", " TMPY", "yel"]; + me.arrowsColour[0][5] = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } else { + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ i ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } }, scrollUp: func() { @@ -455,28 +460,38 @@ var arrivalPage = { arrPushbuttonLeft: func(index) { if (me.activePage == 0) { if (size(me.approaches) >= (index - 1) and index != 2) { - me.selectedApproach = me.arrAirport[0].getIAP(me.approaches[index - 3 + me.scrollApproach]); - me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].destination_runway = me.arrAirport[0].runways[me.selectedApproach.runways[0]]; - fmgc.flightPlanController.flightplans[me.computer].approach = me.selectedApproach; - me.updateActiveApproach(); - me.updateApproaches(); - fmgc.flightPlanController.flightPlanChanged(me.computer); - me.scrollRight(); + if (!dirToFlag) { + me.selectedApproach = me.arrAirport[0].getIAP(me.approaches[index - 3 + me.scrollApproach]); + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].destination_runway = me.arrAirport[0].runways[me.selectedApproach.runways[0]]; + fmgc.flightPlanController.flightplans[me.computer].approach = me.selectedApproach; + me.updateActiveApproach(); + me.updateApproaches(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + me.scrollRight(); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } else { notAllowed(me.computer); } } else { if (size(me.stars) >= (index - 1)) { - me.selectedSTAR = me.stars[index - 2 + me.scrollStars]; - me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].star = me.arrAirport[0].getStar(me.selectedSTAR); - me.updateActiveSTARs(); - me.updateSTARs(); - me.hasPressNoTrans = 0; - me.updateTransitions(); - me.updateActiveTransitions(); - fmgc.flightPlanController.flightPlanChanged(me.computer); + if (!dirToFlag) { + me.selectedSTAR = me.stars[index - 2 + me.scrollStars]; + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].star = me.arrAirport[0].getStar(me.selectedSTAR); + me.updateActiveSTARs(); + me.updateSTARs(); + me.hasPressNoTrans = 0; + me.updateTransitions(); + me.updateActiveTransitions(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } else { notAllowed(me.computer); } @@ -484,16 +499,26 @@ var arrivalPage = { }, arrPushbuttonRight: func(index) { if (index == 2 and size(me.transitions) == 0) { - me.hasPressNoTrans = 1; - me.updateActiveTransitions(); - me.updateTransitions(); + if (!dirToFlag) { + me.hasPressNoTrans = 1; + me.updateActiveTransitions(); + me.updateTransitions(); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } elsif (size(me.transitions) >= (index - 1)) { - me.selectedTransition = me.transitions[index - 2]; - me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].star_trans = me.selectedTransition; - me.updateActiveTransitions(); - me.updateTransitions(); - fmgc.flightPlanController.flightPlanChanged(me.computer); + if (!dirToFlag) { + me.selectedTransition = me.transitions[index - 2]; + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].star_trans = me.selectedTransition; + me.updateActiveTransitions(); + me.updateTransitions(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } else { notAllowed(me.computer); } diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index 2b1b8412..6eec9002 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -391,10 +391,15 @@ var departurePage = { }, makeTmpy: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); - me.L6 = [" F-PLN", " TMPY", "yel"]; - me.arrowsColour[0][5] = "yel"; - canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + if (!dirToFlag) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + me.L6 = [" F-PLN", " TMPY", "yel"]; + me.arrowsColour[0][5] = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } else { + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ i ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } }, scrollUp: func() { @@ -458,27 +463,37 @@ var departurePage = { depPushbuttonLeft: func(index) { if (me.activePage == 0) { if (size(me.runways) >= (index - 1)) { - me.selectedRunway = me.depAirport[0].runway(me.runways[index - 2 + me.scrollRwy]); - me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].departure_runway = me.selectedRunway; - me.updateActiveRunway(); - me.updateRunways(); - fmgc.flightPlanController.flightPlanChanged(me.computer); - me.scrollRight(); + if (!dirToFlag) { + me.selectedRunway = me.depAirport[0].runway(me.runways[index - 2 + me.scrollRwy]); + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].departure_runway = me.selectedRunway; + me.updateActiveRunway(); + me.updateRunways(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + me.scrollRight(); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } else { notAllowed(me.computer); } } else { if (size(me.sids) >= (index - 1)) { - me.selectedSID = me.sids[index - 2 + me.scrollSids]; - me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].sid = me.selectedSID; - me.updateActiveSIDs(); - me.updateSIDs(); - me.hasPressNoTrans = 0; - me.updateTransitions(); - me.updateActiveTransitions(); - fmgc.flightPlanController.flightPlanChanged(me.computer); + if (!dirToFlag) { + me.selectedSID = me.sids[index - 2 + me.scrollSids]; + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].sid = me.selectedSID; + me.updateActiveSIDs(); + me.updateSIDs(); + me.hasPressNoTrans = 0; + me.updateTransitions(); + me.updateActiveTransitions(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } else { notAllowed(me.computer); } @@ -486,16 +501,26 @@ var departurePage = { }, depPushbuttonRight: func(index) { if (index == 2 and size(me.transitions) == 0) { - me.hasPressNoTrans = 1; - me.updateActiveTransitions(); - me.updateTransitions(); + if (!dirToFlag) { + me.hasPressNoTrans = 1; + me.updateActiveTransitions(); + me.updateTransitions(); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } elsif (size(me.transitions) >= (index - 1)) { - me.selectedTransition = me.transitions[index - 2]; - me.makeTmpy(); - fmgc.flightPlanController.flightplans[me.computer].sid = me.depAirport[0].getSid(me.selectedSID).transition(me.selectedTransition); - me.updateActiveTransitions(); - me.updateTransitions(); - fmgc.flightPlanController.flightPlanChanged(me.computer); + if (!dirToFlag) { + me.selectedTransition = me.transitions[index - 2]; + me.makeTmpy(); + fmgc.flightPlanController.flightplans[me.computer].sid = me.depAirport[0].getSid(me.selectedSID).transition(me.selectedTransition); + me.updateActiveTransitions(); + me.updateTransitions(); + fmgc.flightPlanController.flightPlanChanged(me.computer); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } } else { notAllowed(me.computer); } diff --git a/Nasal/MCDU/DIRTO.nas b/Nasal/MCDU/DIRTO.nas index 825a314a..5a38c3cb 100644 --- a/Nasal/MCDU/DIRTO.nas +++ b/Nasal/MCDU/DIRTO.nas @@ -1,3 +1,5 @@ +var dirToFlag = 0; + var dirTo = { title: [nil], subtitle: [nil, nil], @@ -16,6 +18,8 @@ var dirTo = { R4: [nil, nil, "ack"], R5: [nil, nil, "ack"], R6: [nil, nil, "ack"], + scroll: 0, + vector: [], index: nil, computer: nil, new: func(computer) { @@ -29,22 +33,122 @@ var dirTo = { }, _setupPageWithData: func() { me.title = ["DIR TO"]; + me.titleColour = "wht"; me.L1 = [" [ ]", " WAYPOINT", "blu"]; me.L2 = [nil, " F-PLN WPTS", "blu"]; - me.L6 = [" ERASE", " DIR TO", "yel"]; - me.R1 = ["---- --- ", "UTC DIST ", "wht"]; + me.L3 = [nil, nil, "blu"]; + me.L4 = [nil, nil, "blu"]; + me.L5 = [nil, nil, "blu"]; + me.L6 = [" ERASE", " DIR TO", "yel"]; + me.R1 = ["---- --- ", "UTC DIST ", "wht"]; me.R2 = ["DIRECT TO ", nil, "blu"]; - me.R3 = ["ABEAM PTS ", "WITH ", "blu"]; - me.R4 = ["[ ] ", "RADIAL IN ", "blu"]; - me.R5 = ["[ ] ", "RADIAL OUT ", "blu"]; - me.arrowsMatrix = [[0, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 0]]; + me.R3 = ["ABEAM PTS ", "WITH ", "blu"]; + me.R4 = ["[ ] ", "RADIAL IN ", "blu"]; + me.R5 = ["[ ] ", "RADIAL OUT ", "blu"]; + me.R6 = ["INSERT* ", "DIR TO ", "yel"]; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 1, 0, 1, 0, 0]]; me.arrowsColour = [["ack", "blu", "blu", "blu", "blu", "yel"], ["ack", "blu", "ack", "blu", "ack", "ack"]]; me.fontMatrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0]]; + me.updateFromFpln(); + me.updateTmpy(); canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, makeTmpy: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); } + dirToFlag = 1; + }, + insertDirTo: func() { + dirToFlag = 0; + }, + updateTmpy: func() { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.L6 = [" ERASE", " DIR TO", "yel"]; + me.R6 = ["INSERT ", "DIR TO ", "yel"]; + me.arrowsMatrix[0][5] = 1; + me.L1[2] = "yel"; + me.R2[2] = "yel"; + me.titleColour = "yel"; + } else { + me.L6 = [nil, nil, "yel"]; + me.R6 = [nil, nil, "yel"]; + me.arrowsMatrix[0][5] = 0; + me.L1[2] = "blu"; + me.R2[2] = "blu"; + me.titleColour = "wht"; + } + }, + updateFromFpln: func() { + if (canvas_mcdu.myFpln[me.computer] == nil) { + canvas_mcdu.myFpln[i] = fplnPage.new(2, me.computer); + } + var x = 0; + me.vector = []; + for (var i = 1 + (me.scroll - 1); i < size(canvas_mcdu.myFpln[me.computer].planList) - 2; i = i + 1) { + if (canvas_mcdu.myFpln[me.computer].planList[i].wp.wp_name == "DISCONTINUITY" or canvas_mcdu.myFpln[me.computer].planList[i].wp.wp_type == "hdgToAlt") { continue; } + if (fmgc.flightPlanController.temporaryFlag[me.computer] and canvas_mcdu.myFpln[me.computer].planList[i].index > fmgc.flightPlanController.arrivalIndex[me.computer]) { + continue; + } elsif (!fmgc.flightPlanController.temporaryFlag[me.computer] and canvas_mcdu.myFpln[me.computer].planList[i].index > fmgc.flightPlanController.arrivalIndex[2]) { + continue; + } + append(me.vector, " " ~ canvas_mcdu.myFpln[me.computer].planList[i].wp.wp_name); + x += 1; + if (x == 4) { break; } + } + + if (size(me.vector) > 0) { + me.L2[0] = me.vector[0]; + me.arrowsMatrix[0][1] = 1; + } else { + me.L2[0] = nil; + me.arrowsMatrix[0][1] = 0; + } + if (size(me.vector) > 1) { + me.L3[0] = me.vector[1]; + me.arrowsMatrix[0][2] = 1; + } else { + me.L3[0] = nil; + me.arrowsMatrix[0][2] = 0; + } + if (size(me.vector) > 2) { + me.L4[0] = me.vector[2]; + me.arrowsMatrix[0][3] = 1; + } else { + me.L4[0] = nil; + me.arrowsMatrix[0][3] = 0; + } + if (size(me.vector) > 3) { + me.L5[0] = me.vector[3]; + me.arrowsMatrix[0][4] = 1; + } else { + me.L5[0] = nil; + me.arrowsMatrix[0][4] = 0; + } + me.updateTmpy(); + }, + scrollUp: func() { + if (size(canvas_mcdu.myFpln[me.computer].planList) > 4) { + me.scroll += 1; + if (me.scroll > size(canvas_mcdu.myFpln[me.computer].planList) - 6) { + me.scroll = 0; + } + } else { + me.scroll = 0; + } + me.updateFromFpln(); + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + scrollDn: func() { + if (size(canvas_mcdu.myFpln[me.computer].planList) > 4) { + me.scroll -= 1; + if (me.scroll < 0) { + me.scroll = size(canvas_mcdu.myFpln[me.computer].planList) - 6; + } + } else { + me.scroll = 0; + } + me.updateFromFpln(); + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, }; \ No newline at end of file diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas index 0100ef22..3a692c43 100644 --- a/Nasal/MCDU/LATREV.nas +++ b/Nasal/MCDU/LATREV.nas @@ -105,7 +105,9 @@ var latRev = { } elsif (size(me.id) == 5) { me.wpt = findFixesByID(me.id); } - me.subtitle = [dmsToString(sprintf(me.wpt[0].lat), "lat"), dmsToString(sprintf(me.wpt[0].lon), "lon")]; + if (me.wpt[0] != nil) { + me.subtitle = [dmsToString(sprintf(me.wpt[0].lat), "lat"), dmsToString(sprintf(me.wpt[0].lon), "lon")]; + } me.L3 = [" HOLD", nil, "wht"]; me.L4 = [" ALTN", " ENABLE", "blu"]; me.L6 = [" RETURN", nil, "wht"]; @@ -121,7 +123,12 @@ var latRev = { }, makeTmpy: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + if (!dirToFlag) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } me._checkTmpy(); } }, diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index e1fc3831..38fec01d 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -474,6 +474,8 @@ var arrowbutton = func(btn, i) { canvas_mcdu.myDeparture[i].scrollUp(); } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].scrollUp(); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DIRTO") { + canvas_mcdu.myDirTo[i].scrollUp(); } } else if (btn == "down") { if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") { @@ -482,6 +484,8 @@ var arrowbutton = func(btn, i) { canvas_mcdu.myDeparture[i].scrollDn(); } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].scrollDn(); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DIRTO") { + canvas_mcdu.myDirTo[i].scrollDn(); } } } @@ -526,10 +530,19 @@ var pagebutton = func(btn, i) { } else if (btn == "fuel-pred") { setprop("MCDU[" ~ i ~ "]/page", "FUELPRED"); } else if (btn == "dirto") { - if (canvas_mcdu.myDirTo[i] == nil) { - canvas_mcdu.myDirTo[i] = dirTo.new(i); - } - setprop("MCDU[" ~ i ~ "]/page", "DIRTO"); + if (fmgc.flightPlanController.active.getBoolValue()) { + if (fmgc.flightPlanController.temporaryFlag[i] and !dirToFlag) { + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ i ~ "]/scratchpad", "INSRT / ERASE TMPY FIRST"); + return; + } elsif (canvas_mcdu.myDirTo[i] == nil) { + canvas_mcdu.myDirTo[i] = dirTo.new(i); + } + setprop("MCDU[" ~ i ~ "]/page", "DIRTO"); + } else { + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ i ~ "]/scratchpad", "ERROR. INITIALIZE ROUTE"); # Should be ERROR:, but the : character doesn't show in our MCDU font right now... + } } } } diff --git a/Nasal/MCDU/VERTREV.nas b/Nasal/MCDU/VERTREV.nas index 2b7ff972..1dd68b85 100644 --- a/Nasal/MCDU/VERTREV.nas +++ b/Nasal/MCDU/VERTREV.nas @@ -98,7 +98,12 @@ var vertRev = { }, makeTmpy: func() { if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { - fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + if (!dirToFlag) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + } else { + setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); + setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + } me._checkTmpy(); } },