diff --git a/.gitignore b/.gitignore index e9dc65c..9469749 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ list.txt CloudServer/node_modules/ CloudServer/tmp/ -CloudServer/server-data.json \ No newline at end of file +CloudServer/server-data.json +Audio/general/ +Audio/music/ +Audio/station/ \ No newline at end of file diff --git a/Audio/Station/ch-01-01.wav b/Audio/Station/ch-01-01.wav deleted file mode 100644 index 0ca1342..0000000 Binary files a/Audio/Station/ch-01-01.wav and /dev/null differ diff --git a/Audio/Station/ch-01-02.wav b/Audio/Station/ch-01-02.wav deleted file mode 100644 index 2053384..0000000 Binary files a/Audio/Station/ch-01-02.wav and /dev/null differ diff --git a/Audio/Station/ch-01-03.wav b/Audio/Station/ch-01-03.wav deleted file mode 100644 index 893d3c6..0000000 Binary files a/Audio/Station/ch-01-03.wav and /dev/null differ diff --git a/Audio/Station/en-01-01.wav b/Audio/Station/en-01-01.wav deleted file mode 100644 index c5dd8f5..0000000 Binary files a/Audio/Station/en-01-01.wav and /dev/null differ diff --git a/Audio/Station/en-01-02.wav b/Audio/Station/en-01-02.wav deleted file mode 100644 index 9b0612a..0000000 Binary files a/Audio/Station/en-01-02.wav and /dev/null differ diff --git a/Audio/Station/en-01-03.wav b/Audio/Station/en-01-03.wav deleted file mode 100644 index 5761ab3..0000000 Binary files a/Audio/Station/en-01-03.wav and /dev/null differ diff --git a/Audio/ch-1.wav b/Audio/ch-1.wav deleted file mode 100644 index 2451f7c..0000000 Binary files a/Audio/ch-1.wav and /dev/null differ diff --git a/Audio/ch-10.wav b/Audio/ch-10.wav deleted file mode 100644 index 610a821..0000000 Binary files a/Audio/ch-10.wav and /dev/null differ diff --git a/Audio/ch-2.wav b/Audio/ch-2.wav deleted file mode 100644 index aa1529f..0000000 Binary files a/Audio/ch-2.wav and /dev/null differ diff --git a/Audio/ch-3.wav b/Audio/ch-3.wav deleted file mode 100644 index 20ec396..0000000 Binary files a/Audio/ch-3.wav and /dev/null differ diff --git a/Audio/ch-4.wav b/Audio/ch-4.wav deleted file mode 100644 index d66b768..0000000 Binary files a/Audio/ch-4.wav and /dev/null differ diff --git a/Audio/ch-5.wav b/Audio/ch-5.wav deleted file mode 100644 index ed56889..0000000 Binary files a/Audio/ch-5.wav and /dev/null differ diff --git a/Audio/ch-6.wav b/Audio/ch-6.wav deleted file mode 100644 index f2dc3fe..0000000 Binary files a/Audio/ch-6.wav and /dev/null differ diff --git a/Audio/ch-7.wav b/Audio/ch-7.wav deleted file mode 100644 index b62227c..0000000 Binary files a/Audio/ch-7.wav and /dev/null differ diff --git a/Audio/ch-8.wav b/Audio/ch-8.wav deleted file mode 100644 index 4d264f1..0000000 Binary files a/Audio/ch-8.wav and /dev/null differ diff --git a/Audio/ch-9.wav b/Audio/ch-9.wav deleted file mode 100644 index 5dd2360..0000000 Binary files a/Audio/ch-9.wav and /dev/null differ diff --git a/Audio/ch-fc1.wav b/Audio/ch-fc1.wav deleted file mode 100644 index 3b5c9f2..0000000 Binary files a/Audio/ch-fc1.wav and /dev/null differ diff --git a/Audio/ch-fc2.wav b/Audio/ch-fc2.wav deleted file mode 100644 index c39f357..0000000 Binary files a/Audio/ch-fc2.wav and /dev/null differ diff --git a/Audio/ch-fc3.wav b/Audio/ch-fc3.wav deleted file mode 100644 index bfe945b..0000000 Binary files a/Audio/ch-fc3.wav and /dev/null differ diff --git a/Audio/ch-jz1.wav b/Audio/ch-jz1.wav deleted file mode 100644 index 31a9685..0000000 Binary files a/Audio/ch-jz1.wav and /dev/null differ diff --git a/Audio/ch-jz2.wav b/Audio/ch-jz2.wav deleted file mode 100644 index f01c00e..0000000 Binary files a/Audio/ch-jz2.wav and /dev/null differ diff --git a/Audio/ch-jz3.wav b/Audio/ch-jz3.wav deleted file mode 100644 index e836e5b..0000000 Binary files a/Audio/ch-jz3.wav and /dev/null differ diff --git a/Audio/ch-jz4.wav b/Audio/ch-jz4.wav deleted file mode 100644 index 526b0dc..0000000 Binary files a/Audio/ch-jz4.wav and /dev/null differ diff --git a/Audio/ch-pt.wav b/Audio/ch-pt.wav deleted file mode 100644 index 7a80797..0000000 Binary files a/Audio/ch-pt.wav and /dev/null differ diff --git a/Audio/ch-tj.wav b/Audio/ch-tj.wav deleted file mode 100644 index 4e5867a..0000000 Binary files a/Audio/ch-tj.wav and /dev/null differ diff --git a/Audio/ch-zt.wav b/Audio/ch-zt.wav deleted file mode 100644 index 69d99b6..0000000 Binary files a/Audio/ch-zt.wav and /dev/null differ diff --git a/Audio/en-1.wav b/Audio/en-1.wav deleted file mode 100644 index 9e86eb0..0000000 Binary files a/Audio/en-1.wav and /dev/null differ diff --git a/Audio/en-10.wav b/Audio/en-10.wav deleted file mode 100644 index f58ffc5..0000000 Binary files a/Audio/en-10.wav and /dev/null differ diff --git a/Audio/en-11.wav b/Audio/en-11.wav deleted file mode 100644 index b51b757..0000000 Binary files a/Audio/en-11.wav and /dev/null differ diff --git a/Audio/en-12.wav b/Audio/en-12.wav deleted file mode 100644 index 5b2b568..0000000 Binary files a/Audio/en-12.wav and /dev/null differ diff --git a/Audio/en-13.wav b/Audio/en-13.wav deleted file mode 100644 index 2be648e..0000000 Binary files a/Audio/en-13.wav and /dev/null differ diff --git a/Audio/en-14.wav b/Audio/en-14.wav deleted file mode 100644 index 76a0e9b..0000000 Binary files a/Audio/en-14.wav and /dev/null differ diff --git a/Audio/en-15.wav b/Audio/en-15.wav deleted file mode 100644 index 23f0a92..0000000 Binary files a/Audio/en-15.wav and /dev/null differ diff --git a/Audio/en-16.wav b/Audio/en-16.wav deleted file mode 100644 index 2dec113..0000000 Binary files a/Audio/en-16.wav and /dev/null differ diff --git a/Audio/en-17.wav b/Audio/en-17.wav deleted file mode 100644 index ec889af..0000000 Binary files a/Audio/en-17.wav and /dev/null differ diff --git a/Audio/en-18.wav b/Audio/en-18.wav deleted file mode 100644 index 375f031..0000000 Binary files a/Audio/en-18.wav and /dev/null differ diff --git a/Audio/en-19.wav b/Audio/en-19.wav deleted file mode 100644 index a60df78..0000000 Binary files a/Audio/en-19.wav and /dev/null differ diff --git a/Audio/en-2.wav b/Audio/en-2.wav deleted file mode 100644 index c53e123..0000000 Binary files a/Audio/en-2.wav and /dev/null differ diff --git a/Audio/en-20.wav b/Audio/en-20.wav deleted file mode 100644 index aae07d0..0000000 Binary files a/Audio/en-20.wav and /dev/null differ diff --git a/Audio/en-21.wav b/Audio/en-21.wav deleted file mode 100644 index 7df73bd..0000000 Binary files a/Audio/en-21.wav and /dev/null differ diff --git a/Audio/en-22.wav b/Audio/en-22.wav deleted file mode 100644 index e4665d5..0000000 Binary files a/Audio/en-22.wav and /dev/null differ diff --git a/Audio/en-23.wav b/Audio/en-23.wav deleted file mode 100644 index 3162452..0000000 Binary files a/Audio/en-23.wav and /dev/null differ diff --git a/Audio/en-24.wav b/Audio/en-24.wav deleted file mode 100644 index 413b725..0000000 Binary files a/Audio/en-24.wav and /dev/null differ diff --git a/Audio/en-25.wav b/Audio/en-25.wav deleted file mode 100644 index b2d57cf..0000000 Binary files a/Audio/en-25.wav and /dev/null differ diff --git a/Audio/en-26.wav b/Audio/en-26.wav deleted file mode 100644 index 46d49ca..0000000 Binary files a/Audio/en-26.wav and /dev/null differ diff --git a/Audio/en-27.wav b/Audio/en-27.wav deleted file mode 100644 index c84a901..0000000 Binary files a/Audio/en-27.wav and /dev/null differ diff --git a/Audio/en-28.wav b/Audio/en-28.wav deleted file mode 100644 index b86f4f7..0000000 Binary files a/Audio/en-28.wav and /dev/null differ diff --git a/Audio/en-29.wav b/Audio/en-29.wav deleted file mode 100644 index 18b8610..0000000 Binary files a/Audio/en-29.wav and /dev/null differ diff --git a/Audio/en-3.wav b/Audio/en-3.wav deleted file mode 100644 index 78a0176..0000000 Binary files a/Audio/en-3.wav and /dev/null differ diff --git a/Audio/en-30.wav b/Audio/en-30.wav deleted file mode 100644 index c073d56..0000000 Binary files a/Audio/en-30.wav and /dev/null differ diff --git a/Audio/en-31.wav b/Audio/en-31.wav deleted file mode 100644 index bcfc3f8..0000000 Binary files a/Audio/en-31.wav and /dev/null differ diff --git a/Audio/en-32.wav b/Audio/en-32.wav deleted file mode 100644 index c253d06..0000000 Binary files a/Audio/en-32.wav and /dev/null differ diff --git a/Audio/en-4.wav b/Audio/en-4.wav deleted file mode 100644 index 29d210d..0000000 Binary files a/Audio/en-4.wav and /dev/null differ diff --git a/Audio/en-5.wav b/Audio/en-5.wav deleted file mode 100644 index f3aa451..0000000 Binary files a/Audio/en-5.wav and /dev/null differ diff --git a/Audio/en-6.wav b/Audio/en-6.wav deleted file mode 100644 index 171b6bf..0000000 Binary files a/Audio/en-6.wav and /dev/null differ diff --git a/Audio/en-7.wav b/Audio/en-7.wav deleted file mode 100644 index cf2c50a..0000000 Binary files a/Audio/en-7.wav and /dev/null differ diff --git a/Audio/en-8.wav b/Audio/en-8.wav deleted file mode 100644 index 6176509..0000000 Binary files a/Audio/en-8.wav and /dev/null differ diff --git a/Audio/en-9.wav b/Audio/en-9.wav deleted file mode 100644 index bd0354d..0000000 Binary files a/Audio/en-9.wav and /dev/null differ diff --git a/Audio/en-fc1.wav b/Audio/en-fc1.wav deleted file mode 100644 index 3d8f0af..0000000 Binary files a/Audio/en-fc1.wav and /dev/null differ diff --git a/Audio/en-fc2.wav b/Audio/en-fc2.wav deleted file mode 100644 index de1520c..0000000 Binary files a/Audio/en-fc2.wav and /dev/null differ diff --git a/Audio/en-fc3.wav b/Audio/en-fc3.wav deleted file mode 100644 index 877cea2..0000000 Binary files a/Audio/en-fc3.wav and /dev/null differ diff --git a/Audio/en-fc4.wav b/Audio/en-fc4.wav deleted file mode 100644 index 8f48389..0000000 Binary files a/Audio/en-fc4.wav and /dev/null differ diff --git a/Audio/en-jz1.wav b/Audio/en-jz1.wav deleted file mode 100644 index 162058c..0000000 Binary files a/Audio/en-jz1.wav and /dev/null differ diff --git a/Audio/en-jz2.wav b/Audio/en-jz2.wav deleted file mode 100644 index 2dc747c..0000000 Binary files a/Audio/en-jz2.wav and /dev/null differ diff --git a/Audio/en-jz3.wav b/Audio/en-jz3.wav deleted file mode 100644 index c097a5e..0000000 Binary files a/Audio/en-jz3.wav and /dev/null differ diff --git a/Audio/en-jz4.wav b/Audio/en-jz4.wav deleted file mode 100644 index d040618..0000000 Binary files a/Audio/en-jz4.wav and /dev/null differ diff --git a/Audio/en-pt.wav b/Audio/en-pt.wav deleted file mode 100644 index 315f82d..0000000 Binary files a/Audio/en-pt.wav and /dev/null differ diff --git a/Audio/en-tj.wav b/Audio/en-tj.wav deleted file mode 100644 index 2276af5..0000000 Binary files a/Audio/en-tj.wav and /dev/null differ diff --git a/Audio/en-zt.wav b/Audio/en-zt.wav deleted file mode 100644 index 50b09f5..0000000 Binary files a/Audio/en-zt.wav and /dev/null differ diff --git a/Audio/fcts.pkf b/Audio/fcts.pkf deleted file mode 100644 index d3789cc..0000000 Binary files a/Audio/fcts.pkf and /dev/null differ diff --git a/Audio/voice/ch-1.wav b/Audio/voice/ch-1.wav new file mode 100644 index 0000000..d8988c3 Binary files /dev/null and b/Audio/voice/ch-1.wav differ diff --git a/Audio/voice/ch-10.wav b/Audio/voice/ch-10.wav new file mode 100644 index 0000000..88a5303 Binary files /dev/null and b/Audio/voice/ch-10.wav differ diff --git a/Audio/voice/ch-2.wav b/Audio/voice/ch-2.wav new file mode 100644 index 0000000..2510523 Binary files /dev/null and b/Audio/voice/ch-2.wav differ diff --git a/Audio/voice/ch-3.wav b/Audio/voice/ch-3.wav new file mode 100644 index 0000000..e0e981a Binary files /dev/null and b/Audio/voice/ch-3.wav differ diff --git a/Audio/voice/ch-4.wav b/Audio/voice/ch-4.wav new file mode 100644 index 0000000..7c7833b Binary files /dev/null and b/Audio/voice/ch-4.wav differ diff --git a/Audio/voice/ch-5.wav b/Audio/voice/ch-5.wav new file mode 100644 index 0000000..86b4ba3 Binary files /dev/null and b/Audio/voice/ch-5.wav differ diff --git a/Audio/voice/ch-6.wav b/Audio/voice/ch-6.wav new file mode 100644 index 0000000..c02017b Binary files /dev/null and b/Audio/voice/ch-6.wav differ diff --git a/Audio/voice/ch-7.wav b/Audio/voice/ch-7.wav new file mode 100644 index 0000000..b694fde Binary files /dev/null and b/Audio/voice/ch-7.wav differ diff --git a/Audio/voice/ch-8.wav b/Audio/voice/ch-8.wav new file mode 100644 index 0000000..e1b4d77 Binary files /dev/null and b/Audio/voice/ch-8.wav differ diff --git a/Audio/voice/ch-9.wav b/Audio/voice/ch-9.wav new file mode 100644 index 0000000..4157153 Binary files /dev/null and b/Audio/voice/ch-9.wav differ diff --git a/Audio/voice/ch-doorwarn.wav b/Audio/voice/ch-doorwarn.wav new file mode 100644 index 0000000..b92cc4d Binary files /dev/null and b/Audio/voice/ch-doorwarn.wav differ diff --git a/Audio/voice/ch-line.wav b/Audio/voice/ch-line.wav new file mode 100644 index 0000000..2a89fd7 Binary files /dev/null and b/Audio/voice/ch-line.wav differ diff --git a/Audio/voice/ch-nextsta.wav b/Audio/voice/ch-nextsta.wav new file mode 100644 index 0000000..088337e Binary files /dev/null and b/Audio/voice/ch-nextsta.wav differ diff --git a/Audio/voice/ch-station.wav b/Audio/voice/ch-station.wav new file mode 100644 index 0000000..3fa07c7 Binary files /dev/null and b/Audio/voice/ch-station.wav differ diff --git a/Audio/voice/ch-tain.wav b/Audio/voice/ch-tain.wav new file mode 100644 index 0000000..198c6e5 Binary files /dev/null and b/Audio/voice/ch-tain.wav differ diff --git a/Audio/voice/ch-to.wav b/Audio/voice/ch-to.wav new file mode 100644 index 0000000..e9fd2bf Binary files /dev/null and b/Audio/voice/ch-to.wav differ diff --git a/Audio/voice/ch-warn.wav b/Audio/voice/ch-warn.wav new file mode 100644 index 0000000..849e666 Binary files /dev/null and b/Audio/voice/ch-warn.wav differ diff --git a/Audio/voice/ch-zt.wav b/Audio/voice/ch-zt.wav new file mode 100644 index 0000000..d33b71c Binary files /dev/null and b/Audio/voice/ch-zt.wav differ diff --git a/Audio/fcts.wav b/Audio/voice/fcts.wav similarity index 100% rename from Audio/fcts.wav rename to Audio/voice/fcts.wav diff --git a/Audio/voice/ja-1.wav b/Audio/voice/ja-1.wav new file mode 100644 index 0000000..b3955c5 Binary files /dev/null and b/Audio/voice/ja-1.wav differ diff --git a/Audio/voice/ja-10.wav b/Audio/voice/ja-10.wav new file mode 100644 index 0000000..1c29953 Binary files /dev/null and b/Audio/voice/ja-10.wav differ diff --git a/Audio/voice/ja-2.wav b/Audio/voice/ja-2.wav new file mode 100644 index 0000000..c2c575a Binary files /dev/null and b/Audio/voice/ja-2.wav differ diff --git a/Audio/voice/ja-3.wav b/Audio/voice/ja-3.wav new file mode 100644 index 0000000..9ec1320 Binary files /dev/null and b/Audio/voice/ja-3.wav differ diff --git a/Audio/voice/ja-4.wav b/Audio/voice/ja-4.wav new file mode 100644 index 0000000..3278e1c Binary files /dev/null and b/Audio/voice/ja-4.wav differ diff --git a/Audio/voice/ja-5.wav b/Audio/voice/ja-5.wav new file mode 100644 index 0000000..6863a6c Binary files /dev/null and b/Audio/voice/ja-5.wav differ diff --git a/Audio/voice/ja-6.wav b/Audio/voice/ja-6.wav new file mode 100644 index 0000000..7bb50f4 Binary files /dev/null and b/Audio/voice/ja-6.wav differ diff --git a/Audio/voice/ja-7.wav b/Audio/voice/ja-7.wav new file mode 100644 index 0000000..85a16d2 Binary files /dev/null and b/Audio/voice/ja-7.wav differ diff --git a/Audio/voice/ja-8.wav b/Audio/voice/ja-8.wav new file mode 100644 index 0000000..fb6390c Binary files /dev/null and b/Audio/voice/ja-8.wav differ diff --git a/Audio/voice/ja-9.wav b/Audio/voice/ja-9.wav new file mode 100644 index 0000000..8019d05 Binary files /dev/null and b/Audio/voice/ja-9.wav differ diff --git a/Audio/voice/ja-doorwarn.wav b/Audio/voice/ja-doorwarn.wav new file mode 100644 index 0000000..31d0474 Binary files /dev/null and b/Audio/voice/ja-doorwarn.wav differ diff --git a/Audio/voice/ja-nextsta.wav b/Audio/voice/ja-nextsta.wav new file mode 100644 index 0000000..1553ccc Binary files /dev/null and b/Audio/voice/ja-nextsta.wav differ diff --git a/Audio/voice/ja-to.wav b/Audio/voice/ja-to.wav new file mode 100644 index 0000000..e14ee00 Binary files /dev/null and b/Audio/voice/ja-to.wav differ diff --git a/Audio/voice/ja-warn.wav b/Audio/voice/ja-warn.wav new file mode 100644 index 0000000..51113bc Binary files /dev/null and b/Audio/voice/ja-warn.wav differ diff --git a/Audio/voice/ja-xl.wav b/Audio/voice/ja-xl.wav new file mode 100644 index 0000000..2a7184d Binary files /dev/null and b/Audio/voice/ja-xl.wav differ diff --git a/Audio/voice/ja-zt.wav b/Audio/voice/ja-zt.wav new file mode 100644 index 0000000..9e1870a Binary files /dev/null and b/Audio/voice/ja-zt.wav differ diff --git a/Audio/ksts.wav b/Audio/voice/ksts.wav similarity index 100% rename from Audio/ksts.wav rename to Audio/voice/ksts.wav diff --git a/CloudServer/server.js b/CloudServer/server.js index cac7ec3..f12f792 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -1764,10 +1764,11 @@ function handleTrainArrival(ws, data) { const trainId = data.trainId; const stationName = getCorrectStationName(data.stationName); const stationCode = data.stationCode; - const platform = data.platform || '1'; - const lineCode = data.lineCode || 'UNK'; - const destCode = data.destCode || 'UNK'; - const nextCode = data.nextCode || 'UNK'; + const platform = data.stationPlatform || data.platform || '1'; + + const lineCode = data.lineCode || (stationCode ? stationCode.split('-')[0] : 'UNK'); + const destCode = data.destCode || getStationCodeFromName(data.destination) || 'UNK'; + const nextCode = data.nextCode || getStationCodeFromName(data.nextStation) || 'UNK'; const existingIndex = activeTrains.findIndex(t => t.trainId === trainId); const trainData = { @@ -1824,7 +1825,7 @@ function handleTrainDeparture(ws, data) { const trainId = data.trainId; const stationName = getCorrectStationName(data.stationName); const stationCode = data.stationCode; - const beep = data.beep || 'fc1'; + const beep = data.departureBeep || data.beep || 'fc1'; const existingIndex = activeTrains.findIndex(t => t.trainId === trainId); if (existingIndex >= 0) { diff --git a/station_broadcast.lua b/station_broadcast.lua index 4260ba1..54abe49 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -2,7 +2,7 @@ -- ============================================================================ -- 1. Configuration & Constants -- ============================================================================ -local APP_VERSION_TEXT = "v1.0.14" +local APP_VERSION_TEXT = "v1.0.15" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group", @@ -210,6 +210,8 @@ function Utils.promptSlaveIdentity() term.write("Station code (e.g. cb-03): ") term.setCursorPos(1, 8) term.write("Platform number (e.g. 6): ") + term.setCursorPos(1, 10) + term.write("Departure beep (e.g. fc1): ") term.setCursorPos(30, 6) term.setTextColor(colors.cyan) @@ -218,21 +220,25 @@ function Utils.promptSlaveIdentity() term.setCursorPos(31, 8) local stationPlatform = Utils.trim(read() or "") + term.setCursorPos(32, 10) + local departureBeep = Utils.trim(read() or "") + if departureBeep == "" then departureBeep = "fc1" end + if stationCode == "" or stationPlatform == "" then - term.setCursorPos(1, 10) + term.setCursorPos(1, 12) term.setTextColor(colors.red) term.write("Both station code and platform are required.") - term.setCursorPos(1, 12) + term.setCursorPos(1, 14) term.setTextColor(colors.lightGray) term.write("Press any key to retry...") os.pullEvent("key") else - local ok = Utils.saveStationIdentity(stationCode, stationPlatform, nil) + local ok = Utils.saveStationIdentity(stationCode, stationPlatform, departureBeep) if ok then - term.setCursorPos(1, 10) + term.setCursorPos(1, 12) term.setTextColor(colors.green) term.write("Saved to " .. CONFIG.STATION_IDENTITY_FILE) - term.setCursorPos(1, 12) + term.setCursorPos(1, 14) term.setTextColor(colors.lightGray) term.write("Press any key to continue...") os.pullEvent("key") @@ -241,10 +247,79 @@ function Utils.promptSlaveIdentity() term.clear() return true end - term.setCursorPos(1, 10) + term.setCursorPos(1, 12) term.setTextColor(colors.red) term.write("Failed to save " .. CONFIG.STATION_IDENTITY_FILE) + term.setCursorPos(1, 14) + term.setTextColor(colors.lightGray) + term.write("Press any key to retry...") + os.pullEvent("key") + end + end +end + +function Utils.promptConfig() + local manual = Utils.loadStationIdentity() + local currentCode = manual.station_code or State.stationCode or "" + local currentPlatform = manual.station_platform or State.stationPlatform or "1" + local currentBeep = manual.departure_beep or State.departureBeep or "fc1" + + while true do + term.setBackgroundColor(colors.black) + term.setTextColor(colors.white) + term.clear() + term.setCursorPos(1, 1) + term.setTextColor(colors.yellow) + term.write("Station Broadcast Configuration") + term.setCursorPos(1, 3) + term.setTextColor(colors.white) + if Peripherals.station then + term.write("Physical Station detected. Code/Platform are auto-synced.") + term.setCursorPos(1, 4) + term.write("You can override them here if needed.") + else + term.write("Slave node mode.") + end + + term.setCursorPos(1, 6) + term.write("Station code [" .. currentCode .. "]: ") + term.setCursorPos(1, 8) + term.write("Platform number [" .. currentPlatform .. "]: ") + term.setCursorPos(1, 10) + term.write("Departure beep [" .. currentBeep .. "]: ") + + term.setCursorPos(30, 6) + term.setTextColor(colors.cyan) + local codeInput = Utils.trim(read() or ""):lower() + if codeInput == "" then codeInput = currentCode end + + term.setCursorPos(31, 8) + local platformInput = Utils.trim(read() or "") + if platformInput == "" then platformInput = currentPlatform end + + term.setCursorPos(32, 10) + 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, 12) + term.setTextColor(colors.green) + term.write("Configuration saved.") + term.setCursorPos(1, 14) + term.setTextColor(colors.lightGray) + term.write("Press any key to return...") + os.pullEvent("key") + term.setBackgroundColor(colors.black) + term.setTextColor(colors.white) + term.clear() + break + else + term.setCursorPos(1, 12) + term.setTextColor(colors.red) + term.write("Failed to save configuration.") + term.setCursorPos(1, 14) term.setTextColor(colors.lightGray) term.write("Press any key to retry...") os.pullEvent("key") @@ -1977,7 +2052,7 @@ function Display.renderTerminal() term.setBackgroundColor(colors.gray) term.setTextColor(colors.white) term.clearLine() - local title = " Station Broadcast Console (" .. State.stationName .. " " .. tostring(State.stationCode) .. "/P" .. tostring(State.stationPlatform) .. " / " .. APP_VERSION_TEXT .. ") " + local title = " Station Broadcast (" .. State.stationName .. " " .. tostring(State.stationCode) .. "/P" .. tostring(State.stationPlatform) .. ") [C: Config] " term.setCursorPos(math.floor((w - #title)/2) + 1, 1) term.write(title) term.setBackgroundColor(colors.black) @@ -2070,6 +2145,8 @@ function Input.listener() State.logScrollOffset = 0 elseif param1 == keys["end"] then State.logScrollOffset = math.max(0, #State.logs - maxLogs) + elseif param1 == keys.c then + Utils.promptConfig() end Display.renderTerminal() Display.render()