From 8f70c1f1d3b184283948d358a9d2e69f493e90ae Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Tue, 4 Aug 2026 13:13:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=91=E8=BD=A6=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=BF=87=E9=95=BF=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C=E6=98=BE=E7=A4=BA=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20UI=20=E6=BA=A2=E5=87=BA=E9=87=8D=E5=8F=A0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- station_broadcast.lua | 79 ++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/station_broadcast.lua b/station_broadcast.lua index 7094131..77525aa 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.59" +local APP_VERSION_TEXT = "v1.0.60" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group", @@ -252,8 +252,19 @@ function Utils.promptSlaveIdentity() State.inConfig = true while true do local availBeeps = Utils.getAvailableDepartureBeeps() - local availStr = table.concat(availBeeps, ", ") - if #availStr > 40 then availStr = availStr:sub(1, 37) .. "..." end + local availLines = {} + local currentLine = "" + for i, beep in ipairs(availBeeps) do + if #currentLine + #beep + 2 > 48 then + table.insert(availLines, currentLine) + currentLine = beep .. ", " + else + currentLine = currentLine .. beep .. ", " + end + end + if #currentLine > 0 then + table.insert(availLines, currentLine:sub(1, -3)) + end term.setBackgroundColor(colors.black) term.setTextColor(colors.white) @@ -274,10 +285,14 @@ function Utils.promptSlaveIdentity() term.setCursorPos(1, 10) term.setTextColor(colors.gray) term.write("Available beeps:") - term.setCursorPos(1, 11) - term.write(availStr) + local nextY = 11 + for _, l in ipairs(availLines) do + term.setCursorPos(1, nextY) + term.write(l) + nextY = nextY + 1 + end term.setTextColor(colors.white) - term.setCursorPos(1, 13) + term.setCursorPos(1, nextY) term.write("Departure beep (e.g. fc1): ") term.setCursorPos(30, 6) @@ -287,25 +302,25 @@ function Utils.promptSlaveIdentity() term.setCursorPos(31, 8) local stationPlatform = Utils.trim(read() or "") - term.setCursorPos(32, 13) + term.setCursorPos(32, nextY) local departureBeep = Utils.trim(read() or "") if departureBeep == "" then departureBeep = "fc1" end if stationCode == "" or stationPlatform == "" then - term.setCursorPos(1, 15) + term.setCursorPos(1, nextY + 2) term.setTextColor(colors.red) term.write("Both station code and platform are required.") - term.setCursorPos(1, 16) + term.setCursorPos(1, nextY + 3) term.setTextColor(colors.lightGray) term.write("Press any key to retry...") os.pullEvent("key") else local ok = Utils.saveStationIdentity(stationCode, stationPlatform, departureBeep) if ok then - term.setCursorPos(1, 12) + term.setCursorPos(1, nextY + 2) term.setTextColor(colors.green) term.write("Saved to " .. CONFIG.STATION_IDENTITY_FILE) - term.setCursorPos(1, 14) + term.setCursorPos(1, nextY + 3) term.setTextColor(colors.lightGray) term.write("Press any key to continue...") os.pullEvent("key") @@ -315,10 +330,10 @@ function Utils.promptSlaveIdentity() State.inConfig = false return true end - term.setCursorPos(1, 12) + term.setCursorPos(1, nextY + 2) term.setTextColor(colors.red) term.write("Failed to save " .. CONFIG.STATION_IDENTITY_FILE) - term.setCursorPos(1, 14) + term.setCursorPos(1, nextY + 3) term.setTextColor(colors.lightGray) term.write("Press any key to retry...") os.pullEvent("key") @@ -335,8 +350,19 @@ function Utils.promptConfig() while true do local availBeeps = Utils.getAvailableDepartureBeeps() - local availStr = table.concat(availBeeps, ", ") - if #availStr > 40 then availStr = availStr:sub(1, 37) .. "..." end + local availLines = {} + local currentLine = "" + for i, beep in ipairs(availBeeps) do + if #currentLine + #beep + 2 > 48 then + table.insert(availLines, currentLine) + currentLine = beep .. ", " + else + currentLine = currentLine .. beep .. ", " + end + end + if #currentLine > 0 then + table.insert(availLines, currentLine:sub(1, -3)) + end term.setBackgroundColor(colors.black) term.setTextColor(colors.white) @@ -362,11 +388,16 @@ function Utils.promptConfig() term.setCursorPos(1, 10) term.setTextColor(colors.gray) term.write("Available beeps:") - term.setCursorPos(1, 11) - term.write(availStr) + local nextY = 11 + for _, l in ipairs(availLines) do + term.setCursorPos(1, nextY) + term.write(l) + nextY = nextY + 1 + end term.setTextColor(colors.white) - term.setCursorPos(1, 13) - term.write("Departure beep [" .. currentBeep .. "]: ") + term.setCursorPos(1, nextY) + local promptBeepStr = "Departure beep [" .. currentBeep .. "]: " + term.write(promptBeepStr) term.setCursorPos(30, 6) term.setTextColor(colors.cyan) @@ -377,17 +408,17 @@ function Utils.promptConfig() local platformInput = Utils.trim(read() or "") if platformInput == "" then platformInput = currentPlatform end - term.setCursorPos(32, 13) + term.setCursorPos(#promptBeepStr + 1, nextY) local beepInput = Utils.trim(read() or "") if beepInput == "" then beepInput = currentBeep end local ok = Utils.saveStationIdentity(codeInput, platformInput, beepInput) if ok then Utils.refreshStationIdentity() - term.setCursorPos(1, 15) + term.setCursorPos(1, nextY + 2) term.setTextColor(colors.green) term.write("Configuration saved.") - term.setCursorPos(1, 16) + term.setCursorPos(1, nextY + 3) term.setTextColor(colors.lightGray) term.write("Press any key to return...") os.pullEvent("key") @@ -397,10 +428,10 @@ function Utils.promptConfig() State.inConfig = false break else - term.setCursorPos(1, 15) + term.setCursorPos(1, nextY + 2) term.setTextColor(colors.red) term.write("Failed to save configuration.") - term.setCursorPos(1, 16) + term.setCursorPos(1, nextY + 3) term.setTextColor(colors.lightGray) term.write("Press any key to retry...") os.pullEvent("key")