From 1b958c25df94cff8b8a48e61d5fe24c35bb45270 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Sun, 16 Aug 2026 12:01:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(display):=20=E6=A0=87=E6=B3=A8=E7=BB=88?= =?UTF-8?q?=E7=82=B9=E7=AB=99[END]=E4=B8=8E=E4=B8=8B=E4=B8=80=E7=AB=99[NEX?= =?UTF-8?q?T]=E5=B9=B6=E4=BF=AE=E5=A4=8D=E5=A4=9A=E9=A1=B9=E6=98=BE?= =?UTF-8?q?=E7=A4=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复所有站误标[END]:原来用instruction.id判断是错误的,Create中每个停靠站都是create:destination;现在改为用Utils.getDestination()匹配或取列表最后一个站作为终点站 - 过滤包含NaN的无效站点名 - 当前站匹配:先尝试『站名+站台号』严格匹配(避免CB-03 5和CB-03 6同时高亮,匹配不到再退化到站名匹配 - 新增『下一站』标识:~前缀 + 橙色 + [NEXT]后缀 - 新增『终点站』标识:黄色 + [END]后缀 - 当前站:>前缀 + 绿色 + << 标记 - 未到达站:*前缀 + 白色 - 已过站:浅灰色 - 版本号升级至 v1.0.68 --- station_broadcast.lua | 120 +++++++++++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 31 deletions(-) diff --git a/station_broadcast.lua b/station_broadcast.lua index 372e1c6..deffaee 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.67" +local APP_VERSION_TEXT = "v1.0.68" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group", @@ -1030,11 +1030,13 @@ function Utils.extractAllStationsFromSchedule(schedule) if inst.id == "create:station" or inst.id == "create:destination" then local text = (inst.data and inst.data.text) or inst.text if type(text) == "string" and text ~= "" then - table.insert(stations, { - index = i, - name = text, - isDestination = inst.id == "create:destination" - }) + local lower = text:lower() + if not lower:find("nan") and text:find("%S") then + table.insert(stations, { + index = i, + name = text + }) + end end end end @@ -2626,9 +2628,6 @@ function Display.render() drawRight(1, "SCHEDULE:", COLORS.SUCCESS) drawRight(2, "Train: " .. State.currentTrain.id, COLORS.INFO) local scheduleStations = Utils.extractAllStationsFromSchedule(State.currentTrain.schedule) - local currentStationBase = Utils.getBaseName(State.stationName) - local currentStationCode = Utils.getStationCode(State.stationName) - local reachedCurrent = false local stationLineY = 4 if State.currentTrain.schedule == nil then @@ -2639,31 +2638,90 @@ function Display.render() stationLineY = stationLineY + 1 end - if #scheduleStations == 0 then + local totalStations = #scheduleStations + if totalStations == 0 then drawRight(stationLineY, "(No station entries)", COLORS.WARNING) else + local destName = Utils.getDestination(State.currentTrain.schedule) + local destBase = Utils.getBaseName(destName) + local destCode = Utils.getStationCode(destName) + + local currentBase = Utils.getBaseName(State.stationName) + local currentCode = Utils.getStationCode(State.stationName) + local currentPlatform = tostring(State.stationPlatform or "") + + local function matchPlatform(aName, bPlatform) + if not bPlatform or bPlatform == "" then return true end + local pA = Utils.getPlatformNumber(aName, "") + return pA == "" or tostring(pA) == tostring(bPlatform) + end + + local currentIdx = nil for idx, st in ipairs(scheduleStations) do - if stationLineY > h then break end local stBase = Utils.getBaseName(st.name) local stCode = Utils.getStationCode(st.name) - local isCurrentStation = false - if currentStationBase and currentStationBase ~= "" and stBase == currentStationBase then - isCurrentStation = true - elseif currentStationCode and currentStationCode ~= "" and stCode == currentStationCode then - isCurrentStation = true - elseif Utils.isFuzzyMatch(State.stationName, st.name) then - isCurrentStation = true + local isBaseMatch = (currentBase and currentBase ~= "" and stBase == currentBase) + or (currentCode and currentCode ~= "" and stCode == currentCode) + or Utils.isFuzzyMatch(State.stationName, st.name) + if isBaseMatch and matchPlatform(st.name, currentPlatform) then + currentIdx = idx + break end + end - if isCurrentStation then - reachedCurrent = true + if currentIdx == nil then + for idx, st in ipairs(scheduleStations) do + local stBase = Utils.getBaseName(st.name) + local stCode = Utils.getStationCode(st.name) + if (currentBase and currentBase ~= "" and stBase == currentBase) + or (currentCode and currentCode ~= "" and stCode == currentCode) + or Utils.isFuzzyMatch(State.stationName, st.name) then + currentIdx = idx + break + end end + end + + local nextIdx = nil + if currentIdx and currentIdx < totalStations then + nextIdx = currentIdx + 1 + end + + local endIdx = nil + for idx = totalStations, 1, -1 do + local st = scheduleStations[idx] + local stBase = Utils.getBaseName(st.name) + local stCode = Utils.getStationCode(st.name) + if (destBase and destBase ~= "" and stBase == destBase) + or (destCode and destCode ~= "" and stCode == destCode) + or Utils.isFuzzyMatch(destName, st.name) then + endIdx = idx + break + end + end + if endIdx == nil then + endIdx = totalStations + end + + for idx, st in ipairs(scheduleStations) do + if stationLineY > h then break end + local isCurrent = (idx == currentIdx) + local isNext = (idx == nextIdx) + local isEnd = (idx == endIdx) + + local reachedCurrent = currentIdx ~= nil and idx < currentIdx local prefix = " " local lineColor = COLORS.INFO - if isCurrentStation then + if isCurrent then prefix = "> " lineColor = COLORS.SUCCESS + elseif isNext then + prefix = "~ " + lineColor = colors.orange + elseif isEnd then + prefix = " " + lineColor = COLORS.WARNING elseif reachedCurrent then prefix = " " lineColor = colors.lightGray @@ -2672,18 +2730,18 @@ function Display.render() lineColor = COLORS.INFO end - local suffix = "" - if st.isDestination then - suffix = " [END]" - lineColor = COLORS.WARNING + local tag = "" + if isCurrent then + tag = " <<" + end + if isNext then + tag = tag .. " [NEXT]" + end + if isEnd then + tag = tag .. " [END]" end - local displayName = st.name - if isCurrentStation then - displayName = displayName .. " <<" - end - - drawRight(stationLineY, prefix .. displayName .. suffix, lineColor) + drawRight(stationLineY, prefix .. st.name .. tag, lineColor) stationLineY = stationLineY + 1 end end