aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorywang <yw05@forksworld.de>2020-12-19 19:40:13 +0100
committerywang <yw05@forksworld.de>2020-12-19 19:40:13 +0100
commit5659134c8c88bd4c54e76da3e8db570917722fac (patch)
tree3a9f461fe9fe338b6271c5c350aa65e634a43e35
parentd6acadf018c54d4a41c9f4d854b82f7f4cf099bc (diff)
downloadadvtrains-5659134c8c88bd4c54e76da3e8db570917722fac.tar.gz
advtrains-5659134c8c88bd4c54e76da3e8db570917722fac.tar.bz2
advtrains-5659134c8c88bd4c54e76da3e8db570917722fac.zip
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)
-rw-r--r--advtrains/textures/advtrains_hud_speed_atc.pngbin0 -> 139 bytes
-rw-r--r--advtrains/textures/advtrains_hud_speed_bg.pngbin0 -> 101 bytes
-rw-r--r--advtrains/textures/advtrains_hud_speed_ind.pngbin0 -> 67 bytes
-rw-r--r--advtrains/textures/advtrains_hud_speed_limit.pngbin0 -> 82 bytes
-rw-r--r--advtrains/textures/advtrains_hud_speed_max.pngbin0 -> 75 bytes
-rw-r--r--advtrains/textures/advtrains_hud_speed_next.pngbin0 -> 144 bytes
-rw-r--r--advtrains/trainhud.lua55
7 files changed, 28 insertions, 27 deletions
diff --git a/advtrains/textures/advtrains_hud_speed_atc.png b/advtrains/textures/advtrains_hud_speed_atc.png
new file mode 100644
index 0000000..81f7901
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_speed_atc.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_speed_bg.png b/advtrains/textures/advtrains_hud_speed_bg.png
new file mode 100644
index 0000000..e91fbb1
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_speed_bg.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_speed_ind.png b/advtrains/textures/advtrains_hud_speed_ind.png
new file mode 100644
index 0000000..5e27891
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_speed_ind.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_speed_limit.png b/advtrains/textures/advtrains_hud_speed_limit.png
new file mode 100644
index 0000000..2dd3998
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_speed_limit.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_speed_max.png b/advtrains/textures/advtrains_hud_speed_max.png
new file mode 100644
index 0000000..3ea0909
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_speed_max.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_speed_next.png b/advtrains/textures/advtrains_hud_speed_next.png
new file mode 100644
index 0000000..e562437
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_speed_next.png
Binary files differ
diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua
index 2471225..255324e 100644
--- a/advtrains/trainhud.lua
+++ b/advtrains/trainhud.lua
@@ -195,7 +195,8 @@ function advtrains.hud_train_format(train, flip)
local st = {}
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"),
levers[tlev or 32767] or "advtrains_hud_gray.png^advtrains_hud_na.png",
(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"),
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_r.png" or "advtrains_hud_gray.png^advtrains_hud_r.png")
-
- local velstr = function(vel, name)
- return ("%s%02d m/s (%02d km/h)"):format(
- name and (attrans(name).." ") or "",vel,advtrains.ms_to_kmh(vel))
+ 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 si = {}
+ if max < 20 then
+ si[#si+1] = ("%d,77=(advtrains_hud_speed_max.png^[resize\\:%dx22)"):format(max*5,100-max*5)
end
- st[#st+1] = velstr(vel, "Speed:")
- if max then st[#st+1] = velstr(max, "Max. Speed:") end
- if res then st[#st+1] = res == 0
- and attrans("OVERRUN RED SIGNAL! Examine situation and reverse train to move again.")
- or velstr(res, "Restriction:") end
-
- 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 "")
+ if res and res>=0 then
+ si[#si+1] = ("%d,88=advtrains_hud_speed_limit.png"):format(res*4.85)
+ end
+ if train.tarvelocity then
+ si[#si+1] = ("%d,66=advtrains_hud_speed_atc.png"):format(train.tarvelocity*4.85)
end
-
local lzb = train.lzb
-
- local i = 1
- while i<=#lzb.oncoming do
- 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 == 0 then
- break
+ if lzb and lzb.oncoming then
+ for i = 1, #lzb.oncoming do
+ local k = lzb.oncoming[i]
+ if k.spd and k.spd >= 0 then
+ si[#si+1] = ("%d,102=advtrains_hud_speed_next.png"):format(k.spd*4.85)
+ break
+ end
end
- i=i+1
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