diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 119349f7..5e955a78 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -727,7 +727,18 @@ var canvas_MCDU_base = { me["FUELPRED"].hide(); me["PROG"].hide(); me["PERFTO"].hide(); - me["arrowsDepArr"].hide(); + me["arrowsDepArr"].show(); + me["arrow1L"].hide(); + me["arrow2L"].hide(); + me["arrow3L"].hide(); + me["arrow4L"].hide(); + me["arrow5L"].hide(); + me["arrow1R"].hide(); + me["arrow2R"].hide(); + me["arrow3R"].hide(); + me["arrow4R"].hide(); + me["arrow5R"].show(); + me["arrow5R"].setColor(getprop("/MCDUC/colors/blu/r"),getprop("/MCDUC/colors/blu/g"),getprop("/MCDUC/colors/blu/b")); me["PERFAPPR"].hide(); me["PERFGA"].hide(); me["Simple_Title"].show(); @@ -742,8 +753,8 @@ var canvas_MCDU_base = { me["Simple_L0S"].hide(); me.showLeftS(1, 1, 1, -1, 1, 1); me.showLeftArrow(-1, -1, 1, -1, -1, -1); - me.showRight(-1, 1, -1, -1, -1, 1); - me.showRightS(-1, -1, -1, -1, -1, 1); + me.showRight(-1, 1, -1, 1, 1, 1); + me.showRightS(-1, -1, -1, 1, 1, 1); me.showRightArrow(-1, -1, -1, -1, -1, 1); me.fontLeft(default, default, default, default, symbol, default); @@ -752,31 +763,59 @@ var canvas_MCDU_base = { me.fontRightS(default, default, default, default, default, default); me.fontSizeLeft(normal, normal, normal, normal, small, normal); - me.fontSizeRight(normal, normal, normal, normal, normal, normal); + me.fontSizeRight(normal, normal, normal, small, normal, normal); me.colorLeft("grn", "blu", "blu", "wht", "blu", "grn"); me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); me.colorLeftArrow("wht", "blu", "blu", "wht", "wht", "wht"); - me.colorRight("wht", "grn", "wht", "wht", "wht", "wht"); - me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRight("wht", "grn", "wht", "grn", "blu", "wht"); + me.colorRightS("wht", "wht", "wht", "wht", "grn", "wht"); me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); + + me["Simple_L5"].setText("[ ]"); + me["Simple_L6"].setText("+4.0/+0.0"); + me["Simple_L1S"].setText(" ENG"); + me["Simple_L2S"].setText(" ACTIVE NAV DATA BASE"); + me["Simple_L3S"].setText(" SECOND NAV DATA BASE"); + me["Simple_L5S"].setText("CHG CODE"); + me["Simple_L6S"].setText("IDLE/PERF"); + me["Simple_R6"].setText("STATUS/XLOAD "); + me["Simple_R6S"].setText("SOFTWARE "); + me["Simple_R4S"].setText("PILOT STORED "); + me["Simple_R4"].setText("00RTES 00RWYS "); + me["Simple_R5"].setText("DELETE ALL "); + pageSwitch[i].setBoolValue(1); } me["Simple_L1"].setText(sprintf("%s", engType.getValue())); me["Simple_L2"].setText(sprintf("%s", " " ~ database1.getValue())); me["Simple_L3"].setText(sprintf("%s", " " ~ database2.getValue())); - me["Simple_L5"].setText("[ ]"); - me["Simple_L6"].setText("+4.0/+0.0"); - me["Simple_L1S"].setText(" ENG"); - me["Simple_L2S"].setText(" ACTIVE NAV DATA BASE"); - me["Simple_L3S"].setText(" SECOND NAV DATA BASE"); - me["Simple_L5S"].setText("CHG CODE"); - me["Simple_L6S"].setText("IDLE/PERF"); me["Simple_R2"].setText(sprintf("%s", databaseCode.getValue() ~ " ")); - me["Simple_R6"].setText("STATUS/XLOAD "); - me["Simple_R6S"].setText("SOFTWARE "); + + if (fmgc.WaypointDatabase.getCount() >= 1) { + me["Simple_R4"].show(); + me["Simple_R5"].show(); + me["Simple_R4S"].show(); + me["Simple_R5S"].show(); + me["arrow5R"].show(); + me["Simple_R5S"].setText(sprintf("%02.0f", fmgc.WaypointDatabase.getCount()) ~ "WPTS 00NAVS "); + } else { + me["Simple_R4"].hide(); + me["Simple_R5"].hide(); + me["Simple_R4S"].hide(); + me["Simple_R5S"].hide(); + me["arrow5R"].hide(); + } + + if (getprop("/FMGC/status/phase") == 0 or getprop("/FMGC/status/phase") == 7) { + me["Simple_L5"].show(); + me["Simple_L5S"].show(); + } else { + me["Simple_L5"].hide(); + me["Simple_L5S"].hide(); + } } else if (page == "DATA") { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); diff --git a/Nasal/FMGC/flightplan-waypoints.nas b/Nasal/FMGC/flightplan-waypoints.nas index b51c272e..c05a270b 100644 --- a/Nasal/FMGC/flightplan-waypoints.nas +++ b/Nasal/FMGC/flightplan-waypoints.nas @@ -1,6 +1,12 @@ # A3XX FMGC Waypoint database # Copyright (c) 2020 Josh Davidson (Octal450) and Jonathan Redpath (legoboyvdlp) +var nilTree = { + "latitude": 0, + "longitude": 0, + "ident": "", +}; + var WaypointDatabase = { waypointsVec: [], # addWP - adds pilot waypoint to waypoints vector @@ -36,7 +42,14 @@ var WaypointDatabase = { }, # delete - empties waypoints vector delete: func() { - me.waypointsVec = []; + var noDel = 0; + for (var i = 0; i < me.getSize(); i = i + 1) { + if (me.waypointsVec[i] != nil) { + if (fmgc.flightPlanController.flightplans[2].indexOfWP(me.waypointsVec[i].wpGhost) == -1) { # docs says only checks active and secondary + me.waypointsVec[i] = nil; + } + } + } }, # deleteAtIndex - delete at specific index. Set to nil, so it still exists in vector deleteAtIndex: func(index) { @@ -84,9 +97,7 @@ var WaypointDatabase = { }, # write - write to file, as a delimited string write: func() { - var path = getprop("/sim/fg-home") ~ "/Export/savedWaypoints.txt"; - var file = io.open(path, "wb"); # open in write mode - + var path = getprop("/sim/fg-home") ~ "/Export/savedWaypoints.xml"; var tree = { "waypoints": { @@ -99,12 +110,13 @@ var WaypointDatabase = { if (me.waypointsVec[i] != nil) { node.getChild("waypoints").addChild(me.waypointsVec[i].tree); debug.dump(me.waypointsVec[i].tree); + } else { + node.getChild("waypoints").addChild(nilTree); } } debug.dump(node); - io.writexml(file, node); # write the data - io.close(file); # close (and flush) the file stream + io.writexml(path, node); # write the data }, }; diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index de7074a8..8ff74362 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -404,7 +404,7 @@ var flightPlanController = { } }, - insertFix: func(text, index, plan, override = 0, overrideIndex = -1) { # override - means always choose [0] + insertFix: func(text, index, plan, override = 0, overrideIndex = -1) { if (index == 0) { return 1; } @@ -437,30 +437,6 @@ var flightPlanController = { } }, - insertLatLonFix: func(text, index, plan) { - if (index == 0) { - return 1; - } - - 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) { - return 1; - } - var waypoint = pilotWaypoint.new({lat: latDecimal, lon: lonDecimal}, "LL"); - var addDb = WaypointDatabase.addWP(waypoint); - if (addDb != 2) { - return addDb; - } - me.flightplans[plan].insertWP(waypoint.wpGhost, index); - me.addDiscontinuity(index + 1, plan); - me.flightPlanChanged(plan); - return 2; - }, - insertNavaid: func(text, index, plan, override = 0, overrideIndex = -1) { if (index == 0) { return 1; @@ -510,6 +486,32 @@ var flightPlanController = { } }, + insertLatLonFix: func(text, index, plan) { + if (index == 0) { + return 1; + } + + 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) { + return 1; + } + + var waypoint = pilotWaypoint.new({lat: latDecimal, lon: lonDecimal}, "LL"); + var addDb = WaypointDatabase.addWP(waypoint); + if (addDb != 2) { + return addDb; + } + + me.flightplans[plan].insertWP(waypoint.wpGhost, index); + me.addDiscontinuity(index + 1, plan); + me.flightPlanChanged(plan); + return 2; + }, + # getWPforPBD - parse scratchpad text to find waypoint ghost for PBD # args: text, index, plan # text: scratchpad text diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 3478ea7d..fe18b4f3 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -538,6 +538,8 @@ var rskbutton = func(btn, i) { initInputA("R5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("R5",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "STATUS") { + statusInput("R5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("R5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") { diff --git a/Nasal/MCDU/STATUS.nas b/Nasal/MCDU/STATUS.nas index 4bd342b3..afe40e20 100644 --- a/Nasal/MCDU/STATUS.nas +++ b/Nasal/MCDU/STATUS.nas @@ -5,5 +5,7 @@ var statusInput = func(key, i) { if (key == "L3") { fmgc.switchDatabase(); + } elsif (key == "R5") { + fmgc.WaypointDatabase.delete(); } }