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:
+89
-31
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
-- 1. Configuration & Constants
|
-- 1. Configuration & Constants
|
||||||
local APP_VERSION_TEXT = "v1.0.67"
|
local APP_VERSION_TEXT = "v1.0.68"
|
||||||
|
|
||||||
local CONFIG = {
|
local CONFIG = {
|
||||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
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
|
if inst.id == "create:station" or inst.id == "create:destination" then
|
||||||
local text = (inst.data and inst.data.text) or inst.text
|
local text = (inst.data and inst.data.text) or inst.text
|
||||||
if type(text) == "string" and text ~= "" then
|
if type(text) == "string" and text ~= "" then
|
||||||
table.insert(stations, {
|
local lower = text:lower()
|
||||||
index = i,
|
if not lower:find("nan") and text:find("%S") then
|
||||||
name = text,
|
table.insert(stations, {
|
||||||
isDestination = inst.id == "create:destination"
|
index = i,
|
||||||
})
|
name = text
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2626,9 +2628,6 @@ function Display.render()
|
|||||||
drawRight(1, "SCHEDULE:", COLORS.SUCCESS)
|
drawRight(1, "SCHEDULE:", COLORS.SUCCESS)
|
||||||
drawRight(2, "Train: " .. State.currentTrain.id, COLORS.INFO)
|
drawRight(2, "Train: " .. State.currentTrain.id, COLORS.INFO)
|
||||||
local scheduleStations = Utils.extractAllStationsFromSchedule(State.currentTrain.schedule)
|
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
|
local stationLineY = 4
|
||||||
|
|
||||||
if State.currentTrain.schedule == nil then
|
if State.currentTrain.schedule == nil then
|
||||||
@@ -2639,31 +2638,90 @@ function Display.render()
|
|||||||
stationLineY = stationLineY + 1
|
stationLineY = stationLineY + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if #scheduleStations == 0 then
|
local totalStations = #scheduleStations
|
||||||
|
if totalStations == 0 then
|
||||||
drawRight(stationLineY, "(No station entries)", COLORS.WARNING)
|
drawRight(stationLineY, "(No station entries)", COLORS.WARNING)
|
||||||
else
|
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
|
for idx, st in ipairs(scheduleStations) do
|
||||||
if stationLineY > h then break end
|
|
||||||
local stBase = Utils.getBaseName(st.name)
|
local stBase = Utils.getBaseName(st.name)
|
||||||
local stCode = Utils.getStationCode(st.name)
|
local stCode = Utils.getStationCode(st.name)
|
||||||
local isCurrentStation = false
|
local isBaseMatch = (currentBase and currentBase ~= "" and stBase == currentBase)
|
||||||
if currentStationBase and currentStationBase ~= "" and stBase == currentStationBase then
|
or (currentCode and currentCode ~= "" and stCode == currentCode)
|
||||||
isCurrentStation = true
|
or Utils.isFuzzyMatch(State.stationName, st.name)
|
||||||
elseif currentStationCode and currentStationCode ~= "" and stCode == currentStationCode then
|
if isBaseMatch and matchPlatform(st.name, currentPlatform) then
|
||||||
isCurrentStation = true
|
currentIdx = idx
|
||||||
elseif Utils.isFuzzyMatch(State.stationName, st.name) then
|
break
|
||||||
isCurrentStation = true
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if isCurrentStation then
|
if currentIdx == nil then
|
||||||
reachedCurrent = true
|
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
|
||||||
|
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 prefix = " "
|
||||||
local lineColor = COLORS.INFO
|
local lineColor = COLORS.INFO
|
||||||
if isCurrentStation then
|
if isCurrent then
|
||||||
prefix = "> "
|
prefix = "> "
|
||||||
lineColor = COLORS.SUCCESS
|
lineColor = COLORS.SUCCESS
|
||||||
|
elseif isNext then
|
||||||
|
prefix = "~ "
|
||||||
|
lineColor = colors.orange
|
||||||
|
elseif isEnd then
|
||||||
|
prefix = " "
|
||||||
|
lineColor = COLORS.WARNING
|
||||||
elseif reachedCurrent then
|
elseif reachedCurrent then
|
||||||
prefix = " "
|
prefix = " "
|
||||||
lineColor = colors.lightGray
|
lineColor = colors.lightGray
|
||||||
@@ -2672,18 +2730,18 @@ function Display.render()
|
|||||||
lineColor = COLORS.INFO
|
lineColor = COLORS.INFO
|
||||||
end
|
end
|
||||||
|
|
||||||
local suffix = ""
|
local tag = ""
|
||||||
if st.isDestination then
|
if isCurrent then
|
||||||
suffix = " [END]"
|
tag = " <<"
|
||||||
lineColor = COLORS.WARNING
|
end
|
||||||
|
if isNext then
|
||||||
|
tag = tag .. " [NEXT]"
|
||||||
|
end
|
||||||
|
if isEnd then
|
||||||
|
tag = tag .. " [END]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local displayName = st.name
|
drawRight(stationLineY, prefix .. st.name .. tag, lineColor)
|
||||||
if isCurrentStation then
|
|
||||||
displayName = displayName .. " <<"
|
|
||||||
end
|
|
||||||
|
|
||||||
drawRight(stationLineY, prefix .. displayName .. suffix, lineColor)
|
|
||||||
stationLineY = stationLineY + 1
|
stationLineY = stationLineY + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user