aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authorY. Wang <yw05@forksworld.de>2022-06-10 22:21:54 +0200
committerY. Wang <yw05@forksworld.de>2023-03-23 20:06:02 +0100
commitd1a0d8f2654d6ee64c1a43de7958b1eadfaff6b0 (patch)
treec92dd8067cc78c478ed1c077f4f72d2a6513afac /advtrains
parent220563012d2aa2c753c791fa9faa38346f1355a5 (diff)
downloadadvtrains-d1a0d8f2654d6ee64c1a43de7958b1eadfaff6b0.tar.gz
advtrains-d1a0d8f2654d6ee64c1a43de7958b1eadfaff6b0.tar.bz2
advtrains-d1a0d8f2654d6ee64c1a43de7958b1eadfaff6b0.zip
Use tabs to switch between signaling and IP forms
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/formspec.lua36
1 files changed, 31 insertions, 5 deletions
diff --git a/advtrains/formspec.lua b/advtrains/formspec.lua
index 91e300d..aa5aa69 100644
--- a/advtrains/formspec.lua
+++ b/advtrains/formspec.lua
@@ -1,6 +1,14 @@
local sformat = string.format
local fsescape = minetest.formspec_escape
+local function make_list(entries)
+ local t = {}
+ for k, v in ipairs(entries) do
+ t[k] = fsescape(v)
+ end
+ return table.concat(t, ",")
+end
+
local function f_button_exit(x, y, w, h, id, text)
return sformat("button_exit[%f,%f;%f,%f;%s;%s]", x, y, w, h, id, text)
end
@@ -10,12 +18,8 @@ local function S_button_exit(x, y, w, h, id, ...)
end
local function f_dropdown(x, y, w, id, entries, sel, indexed)
- local t = {}
- for k, v in pairs(entries) do
- t[k] = fsescape(v)
- end
return sformat("dropdown[%f,%f;%f;%s;%s;%d%s]",
- x, y, w, id, table.concat(t, ","),
+ x, y, w, id, make_list(entries),
sel or 1,
indexed and ";true" or "")
end
@@ -28,10 +32,32 @@ local function S_label(x, y, ...)
return f_label(x, y, attrans(...))
end
+local function f_tabheader(x, y, w, h, id, entries, sel, transparent, border)
+ local st = {string.format("%f,%f",x, y)}
+ if h then
+ if w then
+ st[#st+1] = string.format("%f,%f", w, h)
+ else
+ st[#st+1] = tostring(h)
+ end
+ end
+ st[#st+1] = tostring(id)
+ st[#st+1] = make_list(entries)
+ st[#st+1] = tostring(sel)
+ if transparent ~= nil then
+ st[#st+1] = tostring(transparent)
+ if border ~= nil then
+ st[#st+1] = tostring(border)
+ end
+ end
+ return string.format("tabheader[%s]", table.concat(st, ";"))
+end
+
return {
button_exit = f_button_exit,
S_button_exit = S_button_exit,
dropdown = f_dropdown,
label = f_label,
S_label = S_label,
+ tabheader = f_tabheader,
}