diff --git a/A320-main.xml b/A320-main.xml index 374652f3..b9040e43 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1911,6 +1911,7 @@ Aircraft/A320-family/Nasal/FMGC/FMGC-c.nas + Aircraft/A320-family/Nasal/MCDU/DUPLICATE.nas Aircraft/A320-family/Nasal/MCDU/DIRTO.nas Aircraft/A320-family/Nasal/MCDU/LATREV.nas Aircraft/A320-family/Nasal/MCDU/VERTREV.nas diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 2af58c60..22a897f9 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -163,17 +163,27 @@ var flightPlanController = { me.addDiscontinuity(3, plan); me.deleteWP(0, plan); } else { + var timesToDelete = me.flightplans[plan].indexOfWP(waypointGhost); # delete four times, so on last iteration it equals one and then goes to zero, leave it without subtracting one + print(timesToDelete); + while (timesToDelete > 1) { + print(timesToDelete); + me.deleteWP(1, plan, 1); + timesToDelete -= 1; + print(timesToDelete); + } me.insertTP(plan); - #todo + # we want to delete the intermediate waypoints up to but not including the waypoint. Leave index 0, we delete it later. + # example - waypoint dirto is index 5, we want to delete indexes 1 -> 4. 5 - 1 = 4. + # so four individual deletions. Delete index 1 four times. } me.flightPlanChanged(plan); var curAircraftPosDirTo = geo.aircraft_position(); canvas_mcdu.myDirTo[plan].updateDist(me.flightplans[plan].getWP(1).courseAndDistanceFrom(curAircraftPosDirTo)[1]); }, - deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate + deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate. s = 1, means don't add discontinuity ever var wp = wpID[n][index].getValue(); - if (wp != FMGCdep.getValue() and wp != FMGCarr.getValue() and me.flightplans[n].getPlanSize() > 2) { + if (left(wp, 4) != FMGCdep.getValue() and left(wp, 4) != FMGCarr.getValue() and me.flightplans[n].getPlanSize() > 2) { if (me.flightplans[n].getWP(index).id != "DISCONTINUITY" and a == 0) { # if it is a discont, don't make a new one me.flightplans[n].deleteWP(index); if (me.flightplans[n].getWP(index) != nil and s == 0) { diff --git a/Nasal/MCDU/DIRTO.nas b/Nasal/MCDU/DIRTO.nas index 052ff8b1..d41c7250 100644 --- a/Nasal/MCDU/DIRTO.nas +++ b/Nasal/MCDU/DIRTO.nas @@ -236,6 +236,9 @@ var dirTo = { setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); setprop("MCDU[" ~ me.computer ~ "]/scratchpad", ""); }, + leftFieldBtn: func(index) { + print("DA TOVARISHCH" ~ index); + }, fieldL6: func() { if (fmgc.flightPlanController.temporaryFlag[me.computer] and dirToFlag) { dirToFlag = 0; diff --git a/Nasal/MCDU/DUPLICATE.nas b/Nasal/MCDU/DUPLICATE.nas new file mode 100644 index 00000000..d782724f --- /dev/null +++ b/Nasal/MCDU/DUPLICATE.nas @@ -0,0 +1,149 @@ +var duplicateNamesPage = { + title: 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"], + vector: nil, + type: nil, + computer: nil, + enableScroll: 0, + scroll: 0, + distances: nil, + new: func(vector, index, type, computer) { + var fp = {parents:[duplicateNamesPage]}; + fp.vector = vector; + fp.index = index; + fp.type = type; # 0 = other, 1 = navaid + fp.computer = computer; + fp._setupPageWithData(); + fp.distances = []; + return fp; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + me.title = "DUPLICATE NAMES"; + 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"]]; + me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + + me.distances = []; + for (var i = 0; i < size(me.vector); i += 1) { + append(me.distances, math.round(courseAndDistance(me.vector[i])[1])); + } + + me.C1[1] = "LAT/LONG"; + me.R1[1] = "FREQ"; + if (size(me.vector) >= 1) { + me.L1 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[0 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][0] = 1; + me.arrowsColour[0][0] = "blu"; + me.C1 = [" " ~ decimalToShortString(me.vector[0 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[0 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.type == 1) { + if (me.vector[0 + me.scroll].frequency != nil) { + me.R1 = [sprintf("%7.2f", me.vector[0 + me.scroll].frequency / 100), "FREQ", "grn"]; + } + } + } + if (size(me.vector) >= 2) { + me.L2 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[1 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][1] = 1; + me.arrowsColour[0][1] = "blu"; + me.C2 = [" " ~ decimalToShortString(me.vector[1 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[1 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.type == 1) { + if (me.vector[1 + me.scroll].frequency != nil) { + me.R2 = [sprintf("%7.2f", me.vector[1 + me.scroll].frequency / 100), "FREQ", "grn"]; + } + } + } + if (size(me.vector) >= 3) { + me.L3 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[2 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][2] = 1; + me.arrowsColour[0][2] = "blu"; + me.C3 = [" " ~ decimalToShortString(me.vector[2 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[2 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.type == 1) { + if (me.vector[2 + me.scroll].frequency != nil) { + me.R3 = [sprintf("%7.2f", me.vector[2 + me.scroll].frequency / 100), "FREQ", "grn"]; + } + } + } + if (size(me.vector) >= 4) { + me.L4 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[3 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][3] = 1; + me.arrowsColour[0][3] = "blu"; + me.C4 = [" " ~ decimalToShortString(me.vector[3 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[3 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.type == 1) { + if (me.vector[3 + me.scroll].frequency != nil) { + me.R4 = [sprintf("%7.2f", me.vector[3 + me.scroll].frequency / 100), "FREQ", "grn"]; + } + } + } + if (size(me.vector) >= 5) { + me.L5 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[4 + me.scroll] ~ "NM", "blu"]; + me.arrowsMatrix[0][4] = 1; + me.arrowsColour[0][4] = "blu"; + me.C5 = [" " ~ decimalToShortString(me.vector[4 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[4 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; + if (me.type == 1) { + if (me.vector[4 + me.scroll].frequency != nil) { + me.R5 = [sprintf("%7.2f", me.vector[4 + me.scroll].frequency / 100), "FREQ", "grn"]; + } + } + } + if (size(me.vector) > 5) { me.enableScroll = 1; } + + me.L6 = [" RETURN", nil, "wht"]; + }, + scrollUp: func() { + if (me.enableScroll) { + me.scroll += 1; + if (me.scroll > size(me.vector) - 5) { + me.scroll = 0; + } + } + }, + scrollDn: func() { + if (me.enableScroll) { + me.scroll -= 1; + if (me.scroll < 0) { + me.scroll = size(me.vector) - 5; + } + } + }, + pushButtonLeft: func(indexSelect) { + if (!dirToFlag) { + if (size(me.vector[0].id) == 5) { + fmgc.flightPlanController.insertFix(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); + setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } elsif (size(me.vector[0].id) == 4) { + fmgc.flightPlanController.insertAirport(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); + setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } elsif (size(me.vector[0].id) == 3 or size(me.vector[0].id)== 2) { + fmgc.flightPlanController.insertNavaid(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); + setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } + } else { + canvas_mcdu.myDirTo[me.computer].fieldL1(me.vector[0].id, 1, indexSelect - 1); + setprop("MCDU[" ~ me.computer ~ "]/page", "DIRTO"); + } + }, +}; \ No newline at end of file diff --git a/Nasal/MCDU/F-PLN-rework.nas b/Nasal/MCDU/F-PLN-rework.nas index a2acc163..b54d0156 100644 --- a/Nasal/MCDU/F-PLN-rework.nas +++ b/Nasal/MCDU/F-PLN-rework.nas @@ -413,157 +413,6 @@ var notInDataBase = func(i) { setprop("MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE"); } - -var duplicateNamesPage = { - title: 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"], - vector: nil, - type: nil, - computer: nil, - enableScroll: 0, - scroll: 0, - distances: nil, - new: func(vector, index, type, computer) { - var fp = {parents:[duplicateNamesPage]}; - fp.vector = vector; - fp.index = index; - fp.type = type; # 0 = other, 1 = navaid - fp.computer = computer; - fp._setupPageWithData(); - fp.distances = []; - return fp; - }, - del: func() { - return nil; - }, - _setupPageWithData: func() { - me.title = "DUPLICATE NAMES"; - 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"]]; - me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - me.distances = []; - for (var i = 0; i < size(me.vector); i += 1) { - append(me.distances, math.round(courseAndDistance(me.vector[i])[1])); - } - - me.C1[1] = "LAT/LONG"; - me.R1[1] = "FREQ"; - if (size(me.vector) >= 1) { - me.L1 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[0 + me.scroll] ~ "NM", "blu"]; - me.arrowsMatrix[0][0] = 1; - me.arrowsColour[0][0] = "blu"; - me.C1 = [" " ~ decimalToShortString(me.vector[0 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[0 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.type == 1) { - if (me.vector[0 + me.scroll].frequency != nil) { - me.R1 = [sprintf("%7.2f", me.vector[0 + me.scroll].frequency / 100), "FREQ", "grn"]; - } - } - } - if (size(me.vector) >= 2) { - me.L2 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[1 + me.scroll] ~ "NM", "blu"]; - me.arrowsMatrix[0][1] = 1; - me.arrowsColour[0][1] = "blu"; - me.C2 = [" " ~ decimalToShortString(me.vector[1 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[1 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.type == 1) { - if (me.vector[1 + me.scroll].frequency != nil) { - me.R2 = [sprintf("%7.2f", me.vector[1 + me.scroll].frequency / 100), "FREQ", "grn"]; - } - } - } - if (size(me.vector) >= 3) { - me.L3 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[2 + me.scroll] ~ "NM", "blu"]; - me.arrowsMatrix[0][2] = 1; - me.arrowsColour[0][2] = "blu"; - me.C3 = [" " ~ decimalToShortString(me.vector[2 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[2 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.type == 1) { - if (me.vector[2 + me.scroll].frequency != nil) { - me.R3 = [sprintf("%7.2f", me.vector[2 + me.scroll].frequency / 100), "FREQ", "grn"]; - } - } - } - if (size(me.vector) >= 4) { - me.L4 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[3 + me.scroll] ~ "NM", "blu"]; - me.arrowsMatrix[0][3] = 1; - me.arrowsColour[0][3] = "blu"; - me.C4 = [" " ~ decimalToShortString(me.vector[3 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[3 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.type == 1) { - if (me.vector[3 + me.scroll].frequency != nil) { - me.R4 = [sprintf("%7.2f", me.vector[3 + me.scroll].frequency / 100), "FREQ", "grn"]; - } - } - } - if (size(me.vector) >= 5) { - me.L5 = [" " ~ me.vector[0 + me.scroll].id, " " ~ me.distances[4 + me.scroll] ~ "NM", "blu"]; - me.arrowsMatrix[0][4] = 1; - me.arrowsColour[0][4] = "blu"; - me.C5 = [" " ~ decimalToShortString(me.vector[4 + me.scroll].lat, "lat") ~ "/" ~ decimalToShortString(me.vector[4 + me.scroll].lon, "lon"), "LAT/LONG", "grn"]; - if (me.type == 1) { - if (me.vector[4 + me.scroll].frequency != nil) { - me.R5 = [sprintf("%7.2f", me.vector[4 + me.scroll].frequency / 100), "FREQ", "grn"]; - } - } - } - if (size(me.vector) > 5) { me.enableScroll = 1; } - - me.L6 = [" RETURN", nil, "wht"]; - }, - scrollUp: func() { - if (me.enableScroll) { - me.scroll += 1; - if (me.scroll > size(me.vector) - 5) { - me.scroll = 0; - } - } - }, - scrollDn: func() { - if (me.enableScroll) { - me.scroll -= 1; - if (me.scroll < 0) { - me.scroll = size(me.vector) - 5; - } - } - }, - pushButtonLeft: func(indexSelect) { - if (!dirToFlag) { - if (size(me.vector[0].id) == 5) { - fmgc.flightPlanController.insertFix(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); - setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); - } elsif (size(me.vector[0].id) == 4) { - fmgc.flightPlanController.insertAirport(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); - setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); - } elsif (size(me.vector[0].id) == 3 or size(me.vector[0].id)== 2) { - fmgc.flightPlanController.insertNavaid(me.vector[0].id, me.index, me.computer, 1, indexSelect - 1); - setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); - } - } else { - canvas_mcdu.myDirTo[me.computer].fieldL1(me.vector[0].id, 1, indexSelect - 1); - setprop("MCDU[" ~ me.computer ~ "]/page", "DIRTO"); - } - }, -}; - var decimalToShortString = func(dms, type) { var degrees = split(".", sprintf(dms))[0]; if (type == "lat") { diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas index 3a692c43..6ecb9633 100644 --- a/Nasal/MCDU/LATREV.nas +++ b/Nasal/MCDU/LATREV.nas @@ -144,7 +144,9 @@ var latRev = { setprop("/MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); fmgc.flightPlanController.flightPlanChanged(me.computer); - setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + if (getprop("/MCDU[" ~ me.computer ~ "]/page") != "DUPLICATENAMES") { + setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); + } } }, }; diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 2d348f15..29f8b7d5 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -157,7 +157,9 @@ var lskbutton = func(btn, i) { canvas_mcdu.myDeparture[i].depPushbuttonLeft(2); } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonLeft(2); - } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DIRTO") { + canvas_mcdu.myDirTo[i].leftFieldBtn(2); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(2); } else { notAllowed(i); @@ -183,7 +185,9 @@ var lskbutton = func(btn, i) { canvas_mcdu.myDeparture[i].depPushbuttonLeft(3); } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonLeft(3); - } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DIRTO") { + canvas_mcdu.myDirTo[i].leftFieldBtn(3); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(3); } else { notAllowed(i); @@ -205,7 +209,9 @@ var lskbutton = func(btn, i) { canvas_mcdu.myDeparture[i].depPushbuttonLeft(4); } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonLeft(4); - } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DIRTO") { + canvas_mcdu.myDirTo[i].leftFieldBtn(4); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(4); } else { notAllowed(i); @@ -237,7 +243,9 @@ var lskbutton = func(btn, i) { canvas_mcdu.myDeparture[i].depPushbuttonLeft(5); } else if (getprop("MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonLeft(5); - } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DIRTO") { + canvas_mcdu.myDirTo[i].leftFieldBtn(5); + } else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(5); } else { notAllowed(i);