From 3c8402dbbccfb3fae8cec54b7eb03befbd1c314d Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Sun, 31 May 2020 14:15:53 -0400 Subject: [PATCH] Basic text entry logic (clb only) --- Nasal/MCDU/INITA.nas | 6 ++-- Nasal/MCDU/MCDU.nas | 44 +++++++++++++-------------- Nasal/MCDU/WINDCLB.nas | 67 +++++++++++++++++++++++++++++++++++------ Nasal/MCDU/WINDHIST.nas | 50 +++++++++++++++++------------- 4 files changed, 110 insertions(+), 57 deletions(-) diff --git a/Nasal/MCDU/INITA.nas b/Nasal/MCDU/INITA.nas index e5bc7490..8e162b3b 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -223,11 +223,9 @@ var initInputA = func(key, i) { } else if (key == "R3") { setprop("MCDU[" ~ i ~ "]/page", "IRSINIT"); } else if (key == "R4") { - if (canvas_mcdu.myCLBWIND[i] != nil) { - canvas_mcdu.myCLBWIND[i].del(); + if (canvas_mcdu.myCLBWIND[i] == nil) { + canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); } - canvas_mcdu.myCLBWIND[i] = nil; - canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (key == "R5") { if (scratchpad == "CLR") { diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 72b0cbd1..07161dc3 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -207,6 +207,8 @@ var lskbutton = func(btn, i) { initInputIRS("L1",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("L1",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(1); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PROGTO") { progTOInput("L1",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PROGCLB") { @@ -250,6 +252,8 @@ var lskbutton = func(btn, i) { } else if (btn == "2") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("L2",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(2); } else if (getprop("MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("L2",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") { @@ -288,6 +292,8 @@ var lskbutton = func(btn, i) { initInputB("L3",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "FUELPRED") { fuelPredInput("L3",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(3); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("L3",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") { @@ -331,6 +337,8 @@ var lskbutton = func(btn, i) { initInputB("L4",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "FUELPRED") { fuelPredInput("L4",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(4); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("L4",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") { @@ -359,6 +367,8 @@ var lskbutton = func(btn, i) { initInputB("L5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "FUELPRED") { fuelPredInput("L5",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("L5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFCLB") { @@ -405,11 +415,9 @@ var lskbutton = func(btn, i) { } else if (getprop("MCDU[" ~ i ~ "]/page") == "IRSINIT") { initInputIRS("L6",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDHIST") { - if (canvas_mcdu.myCLBWIND[i] != nil) { - canvas_mcdu.myCLBWIND[i].del(); + if (canvas_mcdu.myCLBWIND[i] == nil) { + canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); } - canvas_mcdu.myCLBWIND[i] = nil; - canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ROUTESELECTION") { initInputROUTESEL("L6",i); @@ -454,11 +462,9 @@ var rskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("R1",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { - if (canvas_mcdu.myHISTWIND[i] != nil) { - canvas_mcdu.myHISTWIND[i].del(); + if (canvas_mcdu.myHISTWIND[i] == nil) { + canvas_mcdu.myHISTWIND[i] = windHISTPage.new(i); } - canvas_mcdu.myHISTWIND[i] = nil; - canvas_mcdu.myHISTWIND[i] = windHISTPage.new(i); setprop("MCDU[" ~ i ~ "]/page", "WINDHIST"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("R1",i); @@ -551,17 +557,13 @@ var rskbutton = func(btn, i) { fuelPredInput("R4",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { if (canvas_mcdu.myCLBWIND[i] == nil) { - canvas_mcdu.myCLBWIND[i].del(); + canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); } - canvas_mcdu.myCLBWIND[i] = nil; - canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { - if (canvas_mcdu.myCRZWIND[i] != nil) { - canvas_mcdu.myCRZWIND[i].del(); + if (canvas_mcdu.myCRZWIND[i] == nil) { + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, ""); } - canvas_mcdu.myCRZWIND[i] = nil; - canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, ""); setprop("MCDU[" ~ i ~ "]/page", "WINDCRZ"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("R4",i); @@ -586,18 +588,14 @@ var rskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("R5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { - if (canvas_mcdu.myCRZWIND[i] != nil) { - canvas_mcdu.myCRZWIND[i].del(); + if (canvas_mcdu.myCRZWIND[i] == nil) { + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, ""); } - canvas_mcdu.myCRZWIND[i] = nil; - canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, ""); setprop("MCDU[" ~ i ~ "]/page", "WINDCRZ"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { - if (canvas_mcdu.myDESWIND[i] != nil) { - canvas_mcdu.myDESWIND[i].del(); + if (canvas_mcdu.myDESWIND[i] == nil) { + canvas_mcdu.myDESWIND[i] = windDESPage.new(i, ""); } - canvas_mcdu.myDESWIND[i] = nil; - canvas_mcdu.myDESWIND[i] = windDESPage.new(i, ""); setprop("MCDU[" ~ i ~ "]/page", "WINDDES"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "STATUS") { statusInput("R5",i); diff --git a/Nasal/MCDU/WINDCLB.nas b/Nasal/MCDU/WINDCLB.nas index 75b31d1c..9e1bed20 100644 --- a/Nasal/MCDU/WINDCLB.nas +++ b/Nasal/MCDU/WINDCLB.nas @@ -45,42 +45,72 @@ var windCLBPage = { me.title = "CLIMB WIND"; #me.title = "DRAFT CLIMB WIND"; me.titleColour = "wht"; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 1, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "ack"], ["wht", "ack", "ack", "ack", "wht", "ack"]]; + me.fontMatrix = [[1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]; if (size(me.windList) >= 5) { - me.L5 = ["[ ]/[ ]/[ ]", nil, "blu"]; + if (me.windList[4] != nil) { + me.L5 = [me.windList[4][0] ~ "/" ~ me.windList[4][1] ~ "/" ~ me.windList[4][2], nil, "blu"]; + me.fontMatrix[0][4] = 0; + } else { + me.L5 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][4] = 1; + } } else { me.L5 = [nil, nil, "ack"]; } if (size(me.windList) >= 4) { - me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + if (me.windList[3] != nil) { + me.L4 = [me.windList[3][0] ~ "/" ~ me.windList[3][1] ~ "/" ~ me.windList[3][2], nil, "blu"]; + me.fontMatrix[0][3] = 0; + } else { + me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][3] = 1; + } } else { me.L4 = [nil, nil, "ack"]; } if (size(me.windList) >= 3) { - me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + if (me.windList[2] != nil) { + me.L3 = [me.windList[2][0] ~ "/" ~ me.windList[2][1] ~ "/" ~ me.windList[2][2], nil, "blu"]; + me.fontMatrix[0][2] = 0; + } else { + me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][2] = 1; + } } else { me.L3 = [nil, nil, "ack"]; } if (size(me.windList) >= 2) { - me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + if (me.windList[1] != nil) { + me.L2 = [me.windList[1][0] ~ "/" ~ me.windList[1][1] ~ "/" ~ me.windList[1][2], nil, "blu"]; + me.fontMatrix[0][1] = 0; + } else { + me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][1] = 1; + } } else { me.L2 = [nil, nil, "ack"]; } if (size(me.windList) >= 1) { - me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + if (me.windList[0] != nil) { + me.L1 = [me.windList[0][0] ~ "/" ~ me.windList[0][1] ~ "/" ~ me.windList[0][2], "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 0; + } else { + me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 1; + } } me.R1 = [" HISTORY ", "WIND ", "wht"]; me.R3 = [" REQUEST ", "WIND ", "amb"]; me.R5 = [" PHASE ", "NEXT ", "wht"]; - - me.arrowsMatrix = [[0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 1, 0]]; - me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "ack"], ["wht", "ack", "ack", "ack", "wht", "ack"]]; - me.fontMatrix = [[1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, makeTmpy: func() { @@ -112,5 +142,24 @@ var windCLBPage = { #draft title canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); } + }, + pushButtonLeft: func(index) { + if (size(me.windList) >= index) { + if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) == 13) { + var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad); + me.windList[index - 1] = [winds[0], winds[1], winds[2]]; + mcdu_scratchpad.scratchpads[me.computer].empty(); + if (index != 5) { + append(me.windList, nil); + } + me._setupPageWithData(); + me.makeTmpy(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } } }; \ No newline at end of file diff --git a/Nasal/MCDU/WINDHIST.nas b/Nasal/MCDU/WINDHIST.nas index e902a294..2f79b9bd 100644 --- a/Nasal/MCDU/WINDHIST.nas +++ b/Nasal/MCDU/WINDHIST.nas @@ -33,7 +33,7 @@ var windHISTPage = { var whp = {parents:[windHISTPage]}; whp.computer = computer; whp._setupPageWithData(); - #whp.updateTmpy(); + whp.updateTmpy(); return whp; }, del: func() { @@ -71,27 +71,35 @@ var windHISTPage = { canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, makeTmpy: func() { - # if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { -# fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); -# } + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + } }, updateTmpy: func() { - # if (fmgc.flightPlanController.temporaryFlag[me.computer]) { -# me.L1[2] = "yel"; -# me.L2[2] = "yel"; -# me.L6 = [" F-PLN", " TMPY", "yel"]; -# me.R6 = ["INSERT* ", " TMPY", "yel"]; -# me.arrowsColour[0][5] = "yel"; -# me.titleColour = "yel"; -# canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); -# } else { -# me.L1[2] = "blu"; -# me.L2[2] = "blu"; -# me.L6 = [" RETURN", nil, "wht"]; -# me.R6 = [nil, nil, "ack"]; -# me.arrowsColour[0][5] = "wht"; -# me.titleColour = "wht"; -# canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); -# } + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.L1[2] = "yel"; + me.L2[2] = "yel"; + me.L3[2] = "yel"; + me.L4[2] = "yel"; + me.L5[2] = "yel"; + me.C1[2] = "yel"; + me.C2[2] = "yel"; + me.C3[2] = "yel"; + me.C4[2] = "yel"; + me.C5[2] = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } else { + me.L1[2] = "blu"; + me.L2[2] = "blu"; + me.L3[2] = "blu"; + me.L4[2] = "blu"; + me.L5[2] = "blu"; + me.C1[2] = "blu"; + me.C2[2] = "blu"; + me.C3[2] = "blu"; + me.C4[2] = "blu"; + me.C5[2] = "blu"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } } }; \ No newline at end of file