aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorywang <yw05@forksworld.de>2021-01-10 11:40:03 +0100
committerywang <yw05@forksworld.de>2021-01-20 17:12:25 +0100
commitef21e70479d31973e47988a2246870ddc429226a (patch)
tree6516ced0a61d6b5f99d637e7728b453a4c1d654b
parent371b5ac5032d2528913519e0d0d8e129c9ac3118 (diff)
downloadadvtrains-release-2.2.1.tar.gz
advtrains-release-2.2.1.tar.bz2
advtrains-release-2.2.1.zip
Use graphical indication for more elements; improve 7-segment displayrelease-2.2.1
-rw-r--r--advtrains/textures/advtrains_hud_arrow.pngbin92 -> 91 bytes
-rw-r--r--advtrains/textures/advtrains_hud_atc.pngbin714 -> 528 bytes
-rw-r--r--advtrains/textures/advtrains_hud_b.pngbin355 -> 0 bytes
-rw-r--r--advtrains/textures/advtrains_hud_emg.pngbin718 -> 0 bytes
-rw-r--r--advtrains/textures/advtrains_hud_forward.pngbin1147 -> 0 bytes
-rw-r--r--advtrains/textures/advtrains_hud_left_door.pngbin1032 -> 0 bytes
-rw-r--r--advtrains/textures/advtrains_hud_lzb.pngbin618 -> 398 bytes
-rw-r--r--advtrains/textures/advtrains_hud_n.pngbin376 -> 0 bytes
-rw-r--r--advtrains/textures/advtrains_hud_p.pngbin274 -> 0 bytes
-rw-r--r--advtrains/textures/advtrains_hud_r.pngbin322 -> 0 bytes
-rw-r--r--advtrains/textures/advtrains_hud_reverse.pngbin1256 -> 0 bytes
-rw-r--r--advtrains/textures/advtrains_hud_right_door.pngbin1295 -> 0 bytes
-rw-r--r--advtrains/textures/advtrains_hud_shunt.pngbin793 -> 476 bytes
-rw-r--r--advtrains/trainhud.lua89
14 files changed, 54 insertions, 35 deletions
diff --git a/advtrains/textures/advtrains_hud_arrow.png b/advtrains/textures/advtrains_hud_arrow.png
index 51f5b42..71d75b0 100644
--- a/advtrains/textures/advtrains_hud_arrow.png
+++ b/advtrains/textures/advtrains_hud_arrow.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_atc.png b/advtrains/textures/advtrains_hud_atc.png
index 06c6c1c..e033653 100644
--- a/advtrains/textures/advtrains_hud_atc.png
+++ b/advtrains/textures/advtrains_hud_atc.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_b.png b/advtrains/textures/advtrains_hud_b.png
deleted file mode 100644
index 64908a7..0000000
--- a/advtrains/textures/advtrains_hud_b.png
+++ /dev/null
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_emg.png b/advtrains/textures/advtrains_hud_emg.png
deleted file mode 100644
index 5739883..0000000
--- a/advtrains/textures/advtrains_hud_emg.png
+++ /dev/null
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_forward.png b/advtrains/textures/advtrains_hud_forward.png
deleted file mode 100644
index 0f12090..0000000
--- a/advtrains/textures/advtrains_hud_forward.png
+++ /dev/null
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_left_door.png b/advtrains/textures/advtrains_hud_left_door.png
deleted file mode 100644
index 51b2447..0000000
--- a/advtrains/textures/advtrains_hud_left_door.png
+++ /dev/null
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_lzb.png b/advtrains/textures/advtrains_hud_lzb.png
index 950de64..e1b5f70 100644
--- a/advtrains/textures/advtrains_hud_lzb.png
+++ b/advtrains/textures/advtrains_hud_lzb.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_n.png b/advtrains/textures/advtrains_hud_n.png
deleted file mode 100644
index bd05f12..0000000
--- a/advtrains/textures/advtrains_hud_n.png
+++ /dev/null
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_p.png b/advtrains/textures/advtrains_hud_p.png
deleted file mode 100644
index f853b78..0000000
--- a/advtrains/textures/advtrains_hud_p.png
+++ /dev/null
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_r.png b/advtrains/textures/advtrains_hud_r.png
deleted file mode 100644
index b357cab..0000000
--- a/advtrains/textures/advtrains_hud_r.png
+++ /dev/null
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_reverse.png b/advtrains/textures/advtrains_hud_reverse.png
deleted file mode 100644
index 1e2a6f8..0000000
--- a/advtrains/textures/advtrains_hud_reverse.png
+++ /dev/null
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_right_door.png b/advtrains/textures/advtrains_hud_right_door.png
deleted file mode 100644
index 2c0293a..0000000
--- a/advtrains/textures/advtrains_hud_right_door.png
+++ /dev/null
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_shunt.png b/advtrains/textures/advtrains_hud_shunt.png
index 6517e42..f4d27a5 100644
--- a/advtrains/textures/advtrains_hud_shunt.png
+++ b/advtrains/textures/advtrains_hud_shunt.png
Binary files differ
diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua
index ab08b83..db32824 100644
--- a/advtrains/trainhud.lua
+++ b/advtrains/trainhud.lua
@@ -184,32 +184,14 @@ function advtrains.hud_train_format(train, flip)
local vel = advtrains.abs_ceil(train.velocity)
local vel_kmh=advtrains.abs_ceil(advtrains.ms_to_kmh(train.velocity))
- local levers = {[0] = "emg","b","r","n","p"}
- local lvrcolor = {[0] = "red", "orange", "orange", "cyan", "cyan"}
local tlev=train.lever or 1
if train.velocity==0 and not train.active_control then tlev=1 end
+ local ht = {"[combine:440x110:0,0=(advtrains_hud_bg.png^[resize\\:440x110)"}
local st = {}
if train.debug then st = {train.debug} end
- local ht = {"[combine:300x150:0,0=(advtrains_hud_bg.png^[resize\\:300x150)"}
- ht[#ht+1] = "100,0=(advtrains_hud_" .. (flip and "reverse" or "forward") .. ".png^[resize\\:100x20^[makealpha\\:#000000)"
- ht[#ht+1] = "200,0=(advtrains_hud_" .. (levers[tlev] or "bg") .. ".png^[resize\\:100x20^[multiply\\:" .. (lvrcolor[tlev] or "#000000") .. "^[makealpha\\:#000000)"
- if train.tarvelocity or train.atc_command then
- ht[#ht+1] = "100,20=(advtrains_hud_atc.png^[resize\\:100x20^[makealpha\\:#000000)"
- end
- if train.ctrl.lzb then
- ht[#ht+1] = "200,20=(advtrains_hud_lzb.png^[resize\\:100x20^[multiply\\:red^[makealpha\\:#000000)"
- end
- if train.is_shunt then
- ht[#ht+1] = "100,40=(advtrains_hud_shunt.png^[resize\\:100x20^[makealpha\\:#000000)"
- end
- if train.door_open == -1 then
- ht[#ht+1] = "100,60=(advtrains_hud_left_door.png^[resize\\:100x20^[makealpha\\:#000000)"
- elseif train.door_open == 1 then
- ht[#ht+1] = "200,60=(advtrains_hud_right_door.png^[resize\\:100x24^[makealpha\\:#000000)"
- end
- -- speed indication(s)
+ -- seven-segment display
local function sevenseg(digit, x, y, w, h, m)
--[[
-1-
@@ -246,34 +228,71 @@ function advtrains.hud_train_format(train, flip)
end
end
end
- sevenseg(math.floor(vel/10), 5, 5, 20, 10, "[colorize\\:red\\:255")
- sevenseg(vel%10, 55, 5, 20, 10, "[colorize\\:red\\:255")
+
+ -- lever
+ ht[#ht+1] = "275,10=(advtrains_hud_bg.png^[colorize\\:cyan^[resize\\:5x18)"
+ ht[#ht+1] = "275,28=(advtrains_hud_bg.png^[colorize\\:white^[resize\\:5x18)"
+ ht[#ht+1] = "275,46=(advtrains_hud_bg.png^[colorize\\:orange^[resize\\:5x36)"
+ ht[#ht+1] = "275,82=(advtrains_hud_bg.png^[colorize\\:red^[resize\\:5x18)"
+ ht[#ht+1] = "292,16=(advtrains_hud_bg.png^[colorize\\:darkslategray^[resize\\:6x78)"
+ ht[#ht+1] = sformat("280,%s=(advtrains_hud_bg.png^[colorize\\:gray^[resize\\:30x18)",18*(4-tlev)+10)
+ -- reverser
+ ht[#ht+1] = sformat("245,10=(advtrains_hud_arrow.png^[transformFY%s)", flip and "" or "^[multiply\\:cyan")
+ ht[#ht+1] = sformat("245,85=(advtrains_hud_arrow.png%s)", flip and "^[multiply\\:orange" or "")
+ ht[#ht+1] = "250,35=(advtrains_hud_bg.png^[colorize\\:darkslategray^[resize\\:5x40)"
+ ht[#ht+1] = sformat("240,%s=(advtrains_hud_bg.png^[resize\\:25x15^[colorize\\:gray)", flip and 65 or 30)
+ -- train control/safety indication
+ if train.tarvelocity or train.atc_command then
+ ht[#ht+1] = "10,10=(advtrains_hud_atc.png^[resize\\:30x30^[multiply\\:cyan)"
+ end
+ if train.ctrl.lzb then
+ ht[#ht+1] = "50,10=(advtrains_hud_lzb.png^[resize\\:30x30^[multiply\\:red)"
+ end
+ if train.is_shunt then
+ ht[#ht+1] = "90,10=(advtrains_hud_shunt.png^[resize\\:30x30^[multiply\\:orange)"
+ end
+ -- door
+ ht[#ht+1] = "187,10=(advtrains_hud_bg.png^[resize\\:26x30^[colorize\\:white)"
+ ht[#ht+1] = "189,12=(advtrains_hud_bg.png^[resize\\:22x11)"
+ ht[#ht+1] = sformat("170,10=(advtrains_hud_bg.png^[resize\\:15x30^[colorize\\:%s)", train.door_open==-1 and "white" or "darkslategray")
+ ht[#ht+1] = "172,12=(advtrains_hud_bg.png^[resize\\:11x11)"
+ ht[#ht+1] = sformat("215,10=(advtrains_hud_bg.png^[resize\\:15x30^[colorize\\:%s)", train.door_open==1 and "white" or "darkslategray")
+ ht[#ht+1] = "217,12=(advtrains_hud_bg.png^[resize\\:11x11)"
+ -- speed indication(s)
+ sevenseg(math.floor(vel/10), 320, 10, 30, 10, "[colorize\\:red\\:255")
+ sevenseg(vel%10, 380, 10, 30, 10, "[colorize\\:red\\:255")
for i = 1, vel, 1 do
- ht[#ht+1] = sformat("%d,100=(advtrains_hud_bg.png^[resize\\:11x30^[colorize\\:white)", i*14-3)
+ ht[#ht+1] = sformat("%d,65=(advtrains_hud_bg.png^[resize\\:8x20^[colorize\\:white)", i*11-1)
end
for i = max+1, 20, 1 do
- ht[#ht+1] = sformat("%d,100=(advtrains_hud_bg.png^[resize\\:11x30^[colorize\\:darkslategray)", i*14-3)
+ ht[#ht+1] = sformat("%d,65=(advtrains_hud_bg.png^[resize\\:8x20^[colorize\\:darkslategray)", i*11-1)
end
if res and res > 0 then
- ht[#ht+1] = sformat("%d,95=(advtrains_hud_bg.png^[resize\\:3x40^[colorize\\:red\\:255)", 8+res*14)
+ ht[#ht+1] = sformat("%d,60=(advtrains_hud_bg.png^[resize\\:3x30^[colorize\\:red\\:255)", 7+res*11)
end
if train.tarvelocity then
- ht[#ht+1] = sformat("%d,130=(advtrains_hud_arrow.png^[multiply\\:cyan^[transformFY^[makealpha\\:#000000)", 2+train.tarvelocity*14)
+ ht[#ht+1] = sformat("%d,85=(advtrains_hud_arrow.png^[multiply\\:cyan^[transformFY^[makealpha\\:#000000)", 1+train.tarvelocity*11)
end
local lzb = train.lzb
if lzb and lzb.oncoming then
local oc = lzb.oncoming
for i = 1, #oc do
local spd = oc[i].spd
- if not spd then
- ht[#ht+1] = "203,43=(advtrains_hud_bg.png^[resize\\:14x14^[colorize\\:lime\\:255)"
- elseif spd == 0 then
- ht[#ht+1] = "283,43=(advtrains_hud_bg.png^[resize\\:14x14^[colorize\\:red\\:255)"
- elseif tonumber(spd) then
- ht[#ht+1] = "243,43=(advtrains_hud_bg.png^[resize\\:14x14^[colorize\\:orange\\:255)"
- ht[#ht+1] = sformat("%d,85=(advtrains_hud_arrow.png^[multiply\\:red^[makealpha\\:#000000)", 2+spd*14)
+ local c = not spd and "lime" or (type(spd) == "number" and (spd == 0) and "red" or "orange") or nil
+ if c then
+ ht[#ht+1] = sformat("130,10=(advtrains_hud_bg.png^[resize\\:30x5^[colorize\\:%s)",c)
+ ht[#ht+1] = sformat("130,35=(advtrains_hud_bg.png^[resize\\:30x5^[colorize\\:%s)",c)
+ if spd and spd~=0 then
+ ht[#ht+1] = sformat("%d,50=(advtrains_hud_arrow.png^[multiply\\:red^[makealpha\\:#000000)", 1+spd*11)
+ end
+ local floor = math.floor
+ local dist = floor(((oc[i].idx or train.index)-train.index))
+ dist = math.max(0, math.min(999, dist))
+ for j = 1, 3, 1 do
+ sevenseg(floor((dist/10^(3-j))%10), 119+j*11, 18, 4, 2, "[colorize\\:"..c)
+ end
+ break
end
- break
end
end
@@ -291,7 +310,7 @@ end
local _, texture = advtrains.hud_train_format { -- dummy train object to demonstrate the train hud
max_speed = 15, speed_restriction = 15, velocity = 15, tarvelocity = 12,
active_control = true, lever = 3, ctrl = {lzb = true}, is_shunt = true,
- door_open = 1, lzb = {oncoming = {{spd=6}}}
+ door_open = 1, lzb = {oncoming = {{spd=6, idx=125.7}}}, index = 0,
}
minetest.register_node("advtrains:hud_demo",{