1
0
Fork 0

DIRTO now works!

This commit is contained in:
legoboyvdlp R 2020-03-31 16:33:28 +01:00
parent 964443258b
commit 2fcfbcb180
4 changed files with 165 additions and 30 deletions

View file

@ -153,7 +153,22 @@ var flightPlanController = {
},
insertTP: func(n) {
me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "T-P"), 0);
me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "T-P"), 1);
},
directTo: func(waypointGhost, plan) {
if (me.flightplans[plan].indexOfWP(waypointGhost) == -1) {
me.insertTP(plan);
me.flightplans[plan].insertWP(createWPFrom(waypointGhost), 2);
me.addDiscontinuity(3, plan);
me.deleteWP(0, plan);
var curAircraftPosDirTo = geo.aircraft_position();
canvas_mcdu.myDirTo[plan].updateDist(me.flightplans[plan].getWP(1).courseAndDistanceFrom(curAircraftPosDirTo)[1]);
} else {
me.insertTP(plan);
#todo
}
me.flightPlanChanged(plan);
},
deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate
@ -218,10 +233,10 @@ var flightPlanController = {
}
}
} elsif (size(airport) >= 1) {
if (canvas_mcdu.myDeparture[plan] != nil) {
canvas_mcdu.myDeparture[plan].del();
if (canvas_mcdu.myDuplicate[plan] != nil) {
canvas_mcdu.myDuplicate[plan].del();
}
canvas_mcdu.myDeparture[plan] = nil;
canvas_mcdu.myDuplicate[plan] = nil;
canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(airport, index, 0, plan);
setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES");
return 2;
@ -269,10 +284,10 @@ var flightPlanController = {
}
}
} elsif (size(fix) >= 1) {
if (canvas_mcdu.myDeparture[plan] != nil) {
canvas_mcdu.myDeparture[plan].del();
if (canvas_mcdu.myDuplicate[plan] != nil) {
canvas_mcdu.myDuplicate[plan].del();
}
canvas_mcdu.myDeparture[plan] = nil;
canvas_mcdu.myDuplicate[plan] = nil;
canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(fix, index, 0, plan);
setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES");
return 2;
@ -350,10 +365,10 @@ var flightPlanController = {
}
}
} elsif (size(navaid) >= 1) {
if (canvas_mcdu.myDeparture[plan] != nil) {
canvas_mcdu.myDeparture[plan].del();
if (canvas_mcdu.myDuplicate[plan] != nil) {
canvas_mcdu.myDuplicate[plan].del();
}
canvas_mcdu.myDeparture[plan] = nil;
canvas_mcdu.myDuplicate[plan] = nil;
canvas_mcdu.myDuplicate[plan] = mcdu.duplicateNamesPage.new(navaid, index, 1, plan);
setprop("MCDU[" ~ plan ~ "]/page", "DUPLICATENAMES");
return 2;

View file

@ -44,7 +44,7 @@ var dirTo = {
me.R3 = ["ABEAM PTS ", "WITH ", "blu"];
me.R4 = ["[ ] ", "RADIAL IN ", "blu"];
me.R5 = ["[ ] ", "RADIAL OUT ", "blu"];
me.arrowsMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0]];
me.arrowsMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]];
me.arrowsColour = [["ack", "blu", "blu", "blu", "blu", "ack"], ["ack", "blu", "blu", "ack", "ack", "ack"]];
me.fontMatrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0]];
me.updateFromFpln();
@ -64,16 +64,12 @@ var dirTo = {
if (fmgc.flightPlanController.temporaryFlag[me.computer]) {
me.L1[2] = "yel";
me.R2[2] = "yel";
me.R3[2] = "yel";
me.arrowsColour[1][1] = "yel";
me.arrowsColour[1][2] = "yel";
me.arrowsMatrix[1][2] = 1;
me.titleColour = "yel";
} else {
me.L1[2] = "blu";
me.R2[2] = "blu";
me.R3[2] = "blu";
me.arrowsColour[1][1] = "blu";
me.arrowsColour[1][2] = "blu";
me.arrowsMatrix[1][2] = 0;
me.titleColour = "wht";
}
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
@ -85,8 +81,8 @@ var dirTo = {
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; }
for (var i = 1 + (me.scroll); 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_name == "VECTORS" or canvas_mcdu.myFpln[me.computer].planList[i].wp.wp_name == "T-P" 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]) {
@ -151,4 +147,114 @@ var dirTo = {
me.updateFromFpln();
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
},
fieldL1: func(text, override = 0, overrideIndex = -1) {
me.makeTmpy();
me.L1[0] = text;
if (size(text) == 16) {
# lat lon
var lat = split("/", text)[0];
var lon = split("/", text)[1];
var latDecimal = mcdu.stringToDegrees(lat, "lat");
var lonDecimal = mcdu.stringToDegrees(lon, "lon");
if (latDecimal > 90 or latDecimal < -90 or lonDecimal > 180 or lonDecimal < -180) {
notAllowed(me.computer);
}
var myWpLatLon = createWP(latDecimal, lonDecimal, "LL" ~ 01);
fmgc.flightPlanController.directTo(myWpLatLon, me.computer);
} elsif (size(text) == 5) {
# fix
var fix = findFixesByID(text);
if (size(fix) == 0) {
notInDataBase(me.computer);
}
if (size(fix) == 1 or override) {
if (!override) {
fmgc.flightPlanController.directTo(fix[0], me.computer);
} else {
fmgc.flightPlanController.directTo(fix[overrideIndex], me.computer);
}
} elsif (size(fix) >= 1) {
if (canvas_mcdu.myDuplicate[me.computer] != nil) {
canvas_mcdu.myDuplicate[me.computer].del();
}
canvas_mcdu.myDuplicate[me.computer] = nil;
canvas_mcdu.myDuplicate[me.computer] = mcdu.duplicateNamesPage.new(fix, 0, 0, me.computer);
setprop("MCDU[" ~ me.computer ~ "]/page", "DUPLICATENAMES");
}
} elsif (size(text) == 4) {
# airport
var airport = findAirportsByICAO(text);
if (size(airport) == 0) {
notInDataBase(me.computer);
}
if (size(airport) == 1 or override) {
if (!override) {
fmgc.flightPlanController.directTo(airport[0], me.computer);
} else {
fmgc.flightPlanController.directTo(airport[overrideIndex], me.computer);
}
} elsif (size(airport) >= 1) {
if (canvas_mcdu.myDuplicate[me.computer] != nil) {
canvas_mcdu.myDuplicate[me.computer].del();
}
canvas_mcdu.myDuplicate[me.computer] = nil;
canvas_mcdu.myDuplicate[me.computer] = mcdu.duplicateNamesPage.new(airport, 0, 0, me.computer);
setprop("MCDU[" ~ me.computer ~ "]/page", "DUPLICATENAMES");
}
} elsif (size(text) == 3 or size(text) == 2) {
# navaid
var navaid = findNavaidsByID(text);
if (size(navaid) == 0) {
notInDataBase(me.computer);
}
if (size(navaid) == 1 or override) {
if (!override) {
fmgc.flightPlanController.directTo(navaid[0], me.computer);
} else {
fmgc.flightPlanController.directTo(navaid[overrideIndex], me.computer);
}
} elsif (size(navaid) >= 1) {
if (canvas_mcdu.myDuplicate[me.computer] != nil) {
canvas_mcdu.myDuplicate[me.computer].del();
}
canvas_mcdu.myDuplicate[me.computer] = nil;
canvas_mcdu.myDuplicate[me.computer] = mcdu.duplicateNamesPage.new(navaid, 0, 0, me.computer);
setprop("MCDU[" ~ me.computer ~ "]/page", "DUPLICATENAMES");
}
} else {
notAllowed(me.computer);
}
setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", "");
setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "");
},
fieldL6: func() {
if (fmgc.flightPlanController.temporaryFlag[me.computer] and dirToFlag) {
dirToFlag = 0;
fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 0);
} else {
notAllowed(me.computer);
}
me.L1 = [" [ ]", " WAYPOINT", "blu"];
},
fieldR6: func() {
if (fmgc.flightPlanController.temporaryFlag[me.computer] and dirToFlag) {
dirToFlag = 0;
fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 1);
} else {
notAllowed(me.computer);
}
me.L1 = [" [ ]", " WAYPOINT", "blu"];
},
updateDist: func(dist) {
me.R1 = ["---- " ~ sprintf("%.0f", dist) ~ " ", "UTC DIST ", "wht"];
},
};

View file

@ -10,7 +10,9 @@ var fplnItem = {
},
updateLeftText: func() {
if (me.wp != nil) {
if (me.wp.wp_name != "DISCONTINUITY") {
if (me.wp.wp_name == "T-P") {
return ["T-P", nil, me.colour];
} elsif (me.wp.wp_name != "DISCONTINUITY") {
var wptName = split("-", me.wp.wp_name);
if (wptName[0] == "VECTORS") {
return ["MANUAL", nil, me.colour];
@ -382,6 +384,7 @@ var fplnPage = { # this one is only created once, and then updated - remember th
pushButtonRight: func(index) {
if (index == 6) {
if (fmgc.flightPlanController.temporaryFlag[me.computer]) {
if (dirToFlag) { dirToFlag = 0; }
fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 1);
} else {
notAllowed(me.computer);
@ -543,15 +546,20 @@ var duplicateNamesPage = {
}
},
pushButtonLeft: func(indexSelect) {
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");
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");
}
},
};

View file

@ -123,7 +123,9 @@ var lskbutton = func(btn, i) {
setprop("MCDU[" ~ i ~ "]/page", "DEPARTURE");
} else if (getprop("MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("MCDU[" ~ i ~ "]/page") == "F-PLNB") {
canvas_mcdu.myFpln[i].pushButtonLeft(1);
} else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") {
} else if (getprop("MCDU[" ~ i ~ "]/page") == "DIRTO") {
canvas_mcdu.myDirTo[i].fieldL1(getprop("MCDU[" ~ i ~ "]/scratchpad"));
} else if (getprop("MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") {
canvas_mcdu.myDuplicate[i].pushButtonLeft(1);
} else {
notAllowed(i);
@ -265,6 +267,8 @@ var lskbutton = func(btn, i) {
} else {
setprop("MCDU[" ~ i ~ "]/page", "LATREV");
}
} else if (getprop("MCDU[" ~ i ~ "]/page") == "DIRTO") {
canvas_mcdu.myDirTo[i].fieldL6();
} else {
notAllowed(i);
}
@ -416,6 +420,8 @@ var rskbutton = func(btn, i) {
canvas_mcdu.myFpln[i].pushButtonRight(6);
} else if (getprop("MCDU[" ~ i ~ "]/page") == "VERTREV") {
setprop("MCDU/[" ~ i ~ "]/page", "F-PLNA");
} else if (getprop("MCDU[" ~ i ~ "]/page") == "DIRTO") {
canvas_mcdu.myDirTo[i].fieldR6();
} else {
notAllowed(i);
}