feat(display): 标注终点站[END]与下一站[NEXT]并修复多项显示bug

- 修复所有站误标[END]:原来用instruction.id判断是错误的,Create中每个停靠站都是create:destination;现在改为用Utils.getDestination()匹配或取列表最后一个站作为终点站
- 过滤包含NaN的无效站点名
- 当前站匹配:先尝试『站名+站台号』严格匹配(避免CB-03 5和CB-03 6同时高亮,匹配不到再退化到站名匹配
- 新增『下一站』标识:~前缀 + 橙色 + [NEXT]后缀
- 新增『终点站』标识:黄色 + [END]后缀
- 当前站:>前缀 + 绿色 + << 标记
- 未到达站:*前缀 + 白色
- 已过站:浅灰色
- 版本号升级至 v1.0.68
This commit is contained in:
2026-08-16 12:01:04 +08:00
parent 1d99634957
commit 1b958c25df
+89 -31
View File
@@ -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