Improved speed indication

The speed indicator is now shown on 4 lines:
Line 1: ATC target speed (blue arrow pointing down)
Line 2: Train velocity (black line)
Line 3: Speed limit (if any) (red line)
Line 4: Next speed limit (red arrow pointing up)
This commit is contained in:
ywang 2020-12-19 19:40:13 +01:00
parent d6acadf018
commit 5659134c8c
7 changed files with 28 additions and 27 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

View File

@ -195,7 +195,8 @@ function advtrains.hud_train_format(train, flip)
local st = {} local st = {}
if train.debug then st = {train.debug} end if train.debug then st = {train.debug} end
local ht = ("[combine:100x66:0,0=(%s):50,0=(%s):0,22=(%s):50,22=(%s):0,44=(%s):50,44=(%s)"):format( local ht = ("[combine:100x110:0,0=(%s):50,0=(%s):0,22=(%s):50,22=(%s):0,44=(%s):50,44=(%s):0,66=advtrains_hud_speed_bg.png"
..":%d,77=(advtrains_hud_speed_ind.png%s)"):format(
("advtrains_hud_blue.png^advtrains_hud_%s.png"):format(flip and "r" or "f"), ("advtrains_hud_blue.png^advtrains_hud_%s.png"):format(flip and "r" or "f"),
levers[tlev or 32767] or "advtrains_hud_gray.png^advtrains_hud_na.png", levers[tlev or 32767] or "advtrains_hud_gray.png^advtrains_hud_na.png",
(train.tarvelocity or train.atc_command) (train.tarvelocity or train.atc_command)
@ -203,36 +204,36 @@ function advtrains.hud_train_format(train, flip)
or (train.ctrl.lzb and "advtrains_hud_red.png^advtrains_hud_lzb.png" or "advtrains_hud_gray.png^advtrains_hud_man.png"), or (train.ctrl.lzb and "advtrains_hud_red.png^advtrains_hud_lzb.png" or "advtrains_hud_gray.png^advtrains_hud_man.png"),
train.is_shunt and "advtrains_hud_orange.png^advtrains_hud_shunt.png" or "advtrains_hud_gray.png^advtrains_hud_shunt.png", train.is_shunt and "advtrains_hud_orange.png^advtrains_hud_shunt.png" or "advtrains_hud_gray.png^advtrains_hud_shunt.png",
train.door_open == -1 and "advtrains_hud_blue.png^advtrains_hud_l_right.png" or "advtrains_hud_gray.png^advtrains_hud_l_right.png", train.door_open == -1 and "advtrains_hud_blue.png^advtrains_hud_l_right.png" or "advtrains_hud_gray.png^advtrains_hud_l_right.png",
train.door_open == 1 and "advtrains_hud_blue.png^advtrains_hud_r.png" or "advtrains_hud_gray.png^advtrains_hud_r.png") train.door_open == 1 and "advtrains_hud_blue.png^advtrains_hud_r.png" or "advtrains_hud_gray.png^advtrains_hud_r.png",
vel*4.85, (res and res>=0) and "" or "^[resize\\:3x22")
local velstr = function(vel, name) local si = {}
return ("%s%02d m/s (%02d km/h)"):format( if max < 20 then
name and (attrans(name).." ") or "",vel,advtrains.ms_to_kmh(vel)) si[#si+1] = ("%d,77=(advtrains_hud_speed_max.png^[resize\\:%dx22)"):format(max*5,100-max*5)
end end
st[#st+1] = velstr(vel, "Speed:") if res and res>=0 then
if max then st[#st+1] = velstr(max, "Max. Speed:") end si[#si+1] = ("%d,88=advtrains_hud_speed_limit.png"):format(res*4.85)
if res then st[#st+1] = res == 0 end
and attrans("OVERRUN RED SIGNAL! Examine situation and reverse train to move again.") if train.tarvelocity then
or velstr(res, "Restriction:") end si[#si+1] = ("%d,66=advtrains_hud_speed_atc.png"):format(train.tarvelocity*4.85)
if train.tarvelocity or train.atc_command then
st[#st+1] = ("ATC: %s%s%s"):format(
train.tarvelocity and (velstr(train.tarvelocity).." ") or "",
train.atc_delay and advtrains.abs_ceil(train.atc_delay).."s " or "",
train.atc_command or "")
end end
local lzb = train.lzb local lzb = train.lzb
if lzb and lzb.oncoming then
local i = 1 for i = 1, #lzb.oncoming do
while i<=#lzb.oncoming do
local k = lzb.oncoming[i] local k = lzb.oncoming[i]
st[#st+1] = "LZB: speed limit ["..(k.spd or "E")..("] in %.1f m"):format(k.idx-train.index) if k.spd and k.spd >= 0 then
if k.spd == 0 then si[#si+1] = ("%d,102=advtrains_hud_speed_next.png"):format(k.spd*4.85)
break break
end end
i=i+1 end
end end
return table.concat(st,"\n"), ht if res and res == 0 then
st[#st+1] = attrans("OVERRUN RED SIGNAL! Examine situation and reverse train to move again.")
end
if train.atc_command then
st[#st+1] = ("ATC: %s%s"):format(train.atc_delay and advtrains.abs_ceil(train.atc_delay).."s " or "", train.atc_command or "")
end
return table.concat(st,"\n"), #si>0 and ht..":"..table.concat(si,":") or ht
end end