aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains/textures/advtrains_hud_jp_ars.pngbin0 -> 249 bytes
-rw-r--r--advtrains/textures/advtrains_hud_jp_atc.pngbin0 -> 136 bytes
-rw-r--r--advtrains/textures/advtrains_hud_jp_autocouple.pngbin0 -> 200 bytes
-rw-r--r--advtrains/textures/advtrains_hud_jp_forward.pngbin0 -> 104 bytes
-rw-r--r--advtrains/textures/advtrains_hud_jp_lzb.pngbin0 -> 190 bytes
-rw-r--r--advtrains/textures/advtrains_hud_jp_reverse.pngbin0 -> 118 bytes
-rw-r--r--advtrains/textures/advtrains_hud_jp_shunt.pngbin0 -> 156 bytes
-rw-r--r--advtrains/trainhud.lua80
-rw-r--r--advtrains/trainhud_presets.lua117
9 files changed, 130 insertions, 67 deletions
diff --git a/advtrains/textures/advtrains_hud_jp_ars.png b/advtrains/textures/advtrains_hud_jp_ars.png
new file mode 100644
index 0000000..d090474
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_jp_ars.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_jp_atc.png b/advtrains/textures/advtrains_hud_jp_atc.png
new file mode 100644
index 0000000..bedc00d
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_jp_atc.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_jp_autocouple.png b/advtrains/textures/advtrains_hud_jp_autocouple.png
new file mode 100644
index 0000000..09be074
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_jp_autocouple.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_jp_forward.png b/advtrains/textures/advtrains_hud_jp_forward.png
new file mode 100644
index 0000000..60a4659
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_jp_forward.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_jp_lzb.png b/advtrains/textures/advtrains_hud_jp_lzb.png
new file mode 100644
index 0000000..968669b
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_jp_lzb.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_jp_reverse.png b/advtrains/textures/advtrains_hud_jp_reverse.png
new file mode 100644
index 0000000..3b08077
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_jp_reverse.png
Binary files differ
diff --git a/advtrains/textures/advtrains_hud_jp_shunt.png b/advtrains/textures/advtrains_hud_jp_shunt.png
new file mode 100644
index 0000000..6761bf8
--- /dev/null
+++ b/advtrains/textures/advtrains_hud_jp_shunt.png
Binary files differ
diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua
index bb5841f..eb21e5b 100644
--- a/advtrains/trainhud.lua
+++ b/advtrains/trainhud.lua
@@ -89,7 +89,7 @@ end
function advtrains.update_driver_hud(pname, train, flip, thud, ghud, nointext)
local inside=nointext and "" or (train.text_inside or "").."\n"
local ft = (thud or advtrains.hud.dtext)(train, flip)
- local ht, gs = (ghud or advtrains.hud.dgraphical)(train, flip)
+ local ht, gs = (ghud or advtrains.hud.presets.default)(train, flip)
advtrains.set_trainhud(pname, inside..ft, ht, gs)
end
function advtrains.clear_driver_hud(pname)
@@ -320,79 +320,25 @@ function advtrains.hud.speed_horizontal(train, x, y, w, h, m)
return table.concat(st, ":")
end
-function advtrains.hud.dgraphical(train, flip)
- if not train then return "" end
- local sformat = string.format -- this appears to be faster than (...):format
-
- local max = train.max_speed or 10
- local vel = advtrains.abs_ceil(train.velocity)
- local res = train.speed_restriction
- local tar = train.tarvelocity
-
- local ht = {"[combine:450x120:0,0=(advtrains_hud_bg.png^[resize\\:450x120)"}
- if train.debug then st = {train.debug} end
-
- ht[#ht+1] = advtrains.hud.lever(advtrains.hud.leverof(train), 275, 10, 5, 30, 100)
- -- reverser
- ht[#ht+1] = sformat("245,10=(advtrains_hud_arrow.png^[transformFY%s)", flip and "" or "^[multiply\\:cyan")
- ht[#ht+1] = sformat("245,95=(advtrains_hud_arrow.png%s)", flip and "^[multiply\\:orange" or "")
- ht[#ht+1] = "250,35=(advtrains_hud_bg.png^[colorize\\:darkslategray^[resize\\:5x50)"
- ht[#ht+1] = sformat("240,%s=(advtrains_hud_bg.png^[resize\\:25x15^[colorize\\:gray)", flip and 75 or 30)
- -- first row
- ht[#ht+1] = sformat("10,10=(advtrains_hud_ars.png^[multiply\\:%s)", (not (advtrains.interlocking and train.ars_disable)) and "cyan" or "darkslategray")
- ht[#ht+1] = sformat("50,10=(advtrains_hud_lzb.png^[multiply\\:%s)", train.hud_lzb_effect_tmr and "red" or "darkslategray")
- ht[#ht+1] = sformat("90,10=(advtrains_hud_shunt.png^[multiply\\:%s)", train.is_shunt and "orange" or "darkslategray")
- ht[#ht+1] = sformat("145,10=(advtrains_hud_autocouple.png^[multiply\\:%s)", train.autocouple and "orange" or "darkslategray")
- -- second row
- local lzb = train.lzb
- local noupcoming = true
- if lzb and lzb.checkpoints then
- local oc = lzb.checkpoints
+function advtrains.hud.getlzb(train)
+ if train.lzb and train.lzb.checkpoints then
+ local oc = train.lzb.checkpoints
for i = 1, #oc do
local spd = oc[i].speed
- spd = advtrains.speed.min(spd, train.speed_restriction)
- if spd == -1 then spd = nil end
- local c = not spd and "lime" or (type(spd) == "number" and (spd == 0) and "red" or "orange") or nil
- if c then
- if spd then
- ht[#ht+1] = advtrains.hud.number(spd, 2, 10, 45, 5, 2, 2, c, "darkslategray")
- ht[#ht+1] = sformat("10,67=(advtrains_hud_ms.png^[multiply\\:%s)", c)
- else
- ht[#ht+1] = advtrains.hud.number(88, 2, 10, 45, 5, 2, 2, "darkslategray")
- ht[#ht+1] = "10,67=(advtrains_hud_ms.png^[multiply\\:darkslategray)"
- end
- local floor = math.floor
- local dist = floor(((oc[i].index or train.index)-train.index))
- dist = math.max(0, math.min(999, dist))
- ht[#ht+1] = advtrains.hud.number(dist, 3, 35, 45, 9, 4, 2, c, "darkslategray")
- noupcoming = false
- break
+ spd = advtrains.speed.min(spd,train.speed_restriction)
+ local dist = math.floor((oc[i].index or train.index)-train.index)
+ if spd == -1 or spd == nil then
+ return -1, dist
+ elseif type(spd) == "number" and spd >= 0 then
+ return spd, dist
end
end
end
- if noupcoming then
- ht[#ht+1] = advtrains.hud.number(88, 2, 10, 45, 5, 2, 2, "darkslategray")
- ht[#ht+1] = "10,67=(advtrains_hud_ms.png^[multiply\\:darkslategray)"
- ht[#ht+1] = advtrains.hud.number(888, 3, 35, 45, 9, 4, 2, "darkslategray")
- end
- ht[#ht+1] = sformat("100,45=(advtrains_hud_atc.png^[multiply\\:%s)", (train.tarvelocity or train.atc_command) and "cyan" or "darkslategray")
- if tar and tar >= 0 then
- local tc = math.min(max, tar)
- ht[#ht+1] = advtrains.hud.number(tar, 2, 135, 45, 5, 2, 2, "cyan", "darkslategray")
- ht[#ht+1] = "135,67=(advtrains_hud_ms.png^[multiply\\:cyan)"
- else
- ht[#ht+1] = advtrains.hud.number(88, 2, 135, 45, 5, 2, 2, "darkslategray")
- ht[#ht+1] = "135,67=(advtrains_hud_ms.png^[multiply\\:darkslategray)"
- end
- ht[#ht+1] = advtrains.hud.door(train.door_open, 167, 45, 60, 30, 2)
- -- speed indications
- ht[#ht+1] = advtrains.hud.number(vel, 2, 320, 10, 35, 10, 10, "red")
- ht[#ht+1] = advtrains.hud.speed_horizontal(train, 10, 80, 217, 30, 3)
-
- return table.concat(ht,":"), 120
end
-local texture = advtrains.hud.dgraphical { -- dummy train object to demonstrate the train hud
+dofile(advtrains.modpath.."/trainhud_presets.lua")
+
+local texture = advtrains.hud.presets.default { -- dummy train object to demonstrate the train hud
max_speed = 17, speed_restriction = 15, velocity = 14, tarvelocity = 12,
active_control = true, lever = 3, ctrl = {lzb = true}, is_shunt = true,
door_open = 1, lzb = {checkpoints = {{speed=6, index=125.7}}}, index = 0,
diff --git a/advtrains/trainhud_presets.lua b/advtrains/trainhud_presets.lua
new file mode 100644
index 0000000..66aa9e5
--- /dev/null
+++ b/advtrains/trainhud_presets.lua
@@ -0,0 +1,117 @@
+advtrains.hud.presets = {}
+
+function advtrains.hud.presets.default(train, flip)
+ if not train then return "" end
+ local sformat = string.format -- this appears to be faster than (...):format
+
+ local max = train.max_speed or 10
+ local vel = advtrains.abs_ceil(train.velocity)
+ local res = train.speed_restriction
+ local tar = train.tarvelocity
+
+ local ht = {"[combine:450x120:0,0=(advtrains_hud_bg.png^[resize\\:450x120)"}
+ if train.debug then st = {train.debug} end
+
+ ht[#ht+1] = advtrains.hud.lever(advtrains.hud.leverof(train), 275, 10, 5, 30, 100)
+ -- reverser
+ ht[#ht+1] = sformat("245,10=(advtrains_hud_arrow.png^[transformFY%s)", flip and "" or "^[multiply\\:cyan")
+ ht[#ht+1] = sformat("245,95=(advtrains_hud_arrow.png%s)", flip and "^[multiply\\:orange" or "")
+ ht[#ht+1] = "250,35=(advtrains_hud_bg.png^[colorize\\:darkslategray^[resize\\:5x50)"
+ ht[#ht+1] = sformat("240,%s=(advtrains_hud_bg.png^[resize\\:25x15^[colorize\\:gray)", flip and 75 or 30)
+ -- first row
+ ht[#ht+1] = sformat("10,10=(advtrains_hud_ars.png^[multiply\\:%s)", (not (advtrains.interlocking and train.ars_disable)) and "cyan" or "darkslategray")
+ ht[#ht+1] = sformat("50,10=(advtrains_hud_lzb.png^[multiply\\:%s)", train.hud_lzb_effect_tmr and "red" or "darkslategray")
+ ht[#ht+1] = sformat("90,10=(advtrains_hud_shunt.png^[multiply\\:%s)", train.is_shunt and "orange" or "darkslategray")
+ ht[#ht+1] = sformat("145,10=(advtrains_hud_autocouple.png^[multiply\\:%s)", train.autocouple and "orange" or "darkslategray")
+ -- second row
+ local asp, dist = advtrains.hud.getlzb(train)
+ if dist then
+ local color
+ if asp >= 0 then
+ color = (asp > 0) and "orange" or "red"
+ ht[#ht+1] = advtrains.hud.number(asp, 2, 10, 45, 5, 2, 2, color, "darkslategray")
+ ht[#ht+1] = sformat("10,67=(advtrains_hud_ms.png^[multiply\\:%s)", color)
+ else
+ color = "lime"
+ ht[#ht+1] = advtrains.hud.number(88, 2, 10, 45, 5, 2, 2, "darkslategray")
+ ht[#ht+1] = "10,67=(advtrains_hud_ms.png^[multiply\\:darkslategray)"
+ end
+ ht[#ht+1] = advtrains.hud.number(dist, 3, 35, 45, 9, 4, 2, color, "darkslategray")
+ else
+ ht[#ht+1] = advtrains.hud.number(88, 2, 10, 45, 5, 2, 2, "darkslategray")
+ ht[#ht+1] = "10,67=(advtrains_hud_ms.png^[multiply\\:darkslategray)"
+ ht[#ht+1] = advtrains.hud.number(888, 3, 35, 45, 9, 4, 2, "darkslategray")
+ end
+ ht[#ht+1] = sformat("100,45=(advtrains_hud_atc.png^[multiply\\:%s)", (train.tarvelocity or train.atc_command) and "cyan" or "darkslategray")
+ if tar and tar >= 0 then
+ local tc = math.min(max, tar)
+ ht[#ht+1] = advtrains.hud.number(tar, 2, 135, 45, 5, 2, 2, "cyan", "darkslategray")
+ ht[#ht+1] = "135,67=(advtrains_hud_ms.png^[multiply\\:cyan)"
+ else
+ ht[#ht+1] = advtrains.hud.number(88, 2, 135, 45, 5, 2, 2, "darkslategray")
+ ht[#ht+1] = "135,67=(advtrains_hud_ms.png^[multiply\\:darkslategray)"
+ end
+ ht[#ht+1] = advtrains.hud.door(train.door_open, 167, 45, 60, 30, 2)
+ -- speed indications
+ ht[#ht+1] = advtrains.hud.number(vel, 2, 320, 10, 35, 10, 10, "red")
+ ht[#ht+1] = advtrains.hud.speed_horizontal(train, 10, 80, 217, 30, 3)
+
+ return table.concat(ht,":"), 120
+end
+
+function advtrains.hud.presets.japan(train, flip)
+ if not train then return "" end
+ local sformat = string.format -- this appears to be faster than (...):format
+
+ local max = train.max_speed or 10
+ local vel = advtrains.abs_ceil(train.velocity)
+ local res = train.speed_restriction
+ local tar = train.tarvelocity
+
+ local ht = {"[combine:340x130:0,0=(advtrains_hud_bg.png^[resize\\:340x130)"}
+
+ ht[#ht+1] = advtrains.hud.number(vel, 2, 5, 5, 30, 10, 10, "red")
+ ht[#ht+1] = advtrains.hud.speed_horizontal(train, 5, 100, 217, 25, 3)
+ ht[#ht+1] = advtrains.hud.lever(advtrains.hud.leverof(train), 122, 5, 3, 20, 90)
+
+ ht[#ht+1] = sformat("151,5=(advtrains_hud_jp_forward.png^[multiply\\:%s)", flip and "darkslategray" or "orange")
+ ht[#ht+1] = sformat("188,5=(advtrains_hud_jp_reverse.png^[multiply\\:%s)", flip and "orange" or "darkslategray")
+
+ ht[#ht+1] = advtrains.hud.door(train.door_open, 151, 30, 72, 39, 2)
+
+ local asp, dist = advtrains.hud.getlzb(train)
+ if dist then
+ local color
+ if asp >= 0 then
+ color = (asp > 0) and "orange" or "red"
+ ht[#ht+1] = advtrains.hud.number(asp, 2, 151, 74, 5, 2, 2, color, "darkslategray")
+ ht[#ht+1] = sformat("151,92=(advtrains_hud_ms.png^[multiply\\:%s)", color)
+ else
+ color = "lime"
+ ht[#ht+1] = advtrains.hud.number(88, 2, 151, 74, 5, 2, 2, "darkslategray")
+ ht[#ht+1] = "151,92=(advtrains_hud_ms.png^[multiply\\:darkslategray)"
+ end
+ ht[#ht+1] = advtrains.hud.number(dist, 3, 177, 74, 10, 2, 2, color, "darkslategray")
+ else
+ ht[#ht+1] = advtrains.hud.number(88, 2, 151, 74, 5, 2, 2, "darkslategray")
+ ht[#ht+1] = "151,92=(advtrains_hud_ms.png^[multiply\\:darkslategray)"
+ ht[#ht+1] = advtrains.hud.number(888, 3, 177, 74, 10, 2, 2, "darkslategray")
+ end
+
+ ht[#ht+1] = sformat("235,5=(advtrains_hud_jp_atc.png^[multiply\\:%s)", (train.tarvelocity or train.atc_command) and "orange" or "darkslategray")
+ ht[#ht+1] = sformat("235,30=(advtrains_hud_jp_ars.png^[multiply\\:%s)", (not (advtrains.interlocking and train.ars_disable)) and "orange" or "darkslategray")
+ ht[#ht+1] = sformat("235,55=(advtrains_hud_jp_lzb.png^[multiply\\:%s)", train.hud_lzb_effect_tmr and "orange" or "darkslategray")
+ ht[#ht+1] = sformat("235,80=(advtrains_hud_jp_shunt.png^[multiply\\:%s)", train.is_shunt and "orange" or "darkslategray")
+ ht[#ht+1] = sformat("235,105=(advtrains_hud_jp_autocouple.png^[multiply\\:%s)", train.autocouple and "orange" or "darkslategray")
+
+ if tar and tar >= 0 then
+ local tc = math.min(max, tar)
+ ht[#ht+1] = advtrains.hud.number(tar, 2, 288, 7, 5, 2, 2, "orange", "darkslategray")
+ ht[#ht+1] = "310,15=(advtrains_hud_ms.png^[multiply\\:orange)"
+ else
+ ht[#ht+1] = advtrains.hud.number(88, 2, 288, 7, 5, 2, 2, "darkslategray")
+ ht[#ht+1] = "310,15=(advtrains_hud_ms.png^[multiply\\:darkslategray)"
+ end
+
+ return table.concat(ht,":"), 130
+end