aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
authorY. Wang <yw05@forksworld.de>2022-12-18 11:01:26 +0100
committerY. Wang <yw05@forksworld.de>2023-03-23 20:06:02 +0100
commit67efae9c9ad6f93aaa418d512c4ae1817eed6d24 (patch)
tree5959e058eed2c9b50909622fac6521e9aa964ad4 /advtrains_interlocking
parent640d72929d67a516cc870986bd27ed0408eb684d (diff)
downloadadvtrains-67efae9c9ad6f93aaa418d512c4ae1817eed6d24.tar.gz
advtrains-67efae9c9ad6f93aaa418d512c4ae1817eed6d24.tar.bz2
advtrains-67efae9c9ad6f93aaa418d512c4ae1817eed6d24.zip
Adjust signal aspect formspecs to be of similar size
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/distant_ui.lua8
-rw-r--r--advtrains_interlocking/signal_api.lua14
-rw-r--r--advtrains_interlocking/signal_aspect_ui.lua57
3 files changed, 43 insertions, 36 deletions
diff --git a/advtrains_interlocking/distant_ui.lua b/advtrains_interlocking/distant_ui.lua
index e1e14b7..a7ff406 100644
--- a/advtrains_interlocking/distant_ui.lua
+++ b/advtrains_interlocking/distant_ui.lua
@@ -3,7 +3,7 @@ local D = advtrains.distant
local I = advtrains.interlocking
function advtrains.interlocking.show_distant_signal_form(pos, pname)
- local form = {"size[7,7]"}
+ local form = {"size[7,6.5]"}
form[#form+1] = advtrains.interlocking.make_signal_formspec_tabheader(pname, pos, 7, 3)
local main, set_by = D.get_main(pos)
if main then
@@ -31,9 +31,9 @@ function advtrains.interlocking.show_distant_signal_form(pos, pname)
dstlist[#dstlist+1] = minetest.pos_to_string(advtrains.decode_pos(pos))
end
form[#form+1] = F.S_label(0.5, 2.5, "This signal has the following distant signals:")
- form[#form+1] = F.textlist(0.5, 3, 4.5, 3.5, "dstlist", dstlist)
- form[#form+1] = F.image_button_exit(5.5, 3.5, 1, 1, "cdb_add.png", "dst_add", "")
- form[#form+1] = F.image_button_exit(5.5, 5, 1, 1, "cdb_clear.png", "dst_del", "")
+ form[#form+1] = F.textlist(0.5, 3, 4.5, 3, "dstlist", dstlist)
+ form[#form+1] = F.image_button_exit(5.5, 3.25, 1, 1, "cdb_add.png", "dst_add", "")
+ form[#form+1] = F.image_button_exit(5.5, 4.75, 1, 1, "cdb_clear.png", "dst_del", "")
minetest.show_formspec(pname, "advtrains:distant_" .. minetest.pos_to_string(pos), table.concat(form))
end
diff --git a/advtrains_interlocking/signal_api.lua b/advtrains_interlocking/signal_api.lua
index 54202f0..8bb92bf 100644
--- a/advtrains_interlocking/signal_api.lua
+++ b/advtrains_interlocking/signal_api.lua
@@ -137,14 +137,18 @@ function advtrains.interlocking.show_ip_form(pos, pname, only_notset)
if not minetest.check_player_privs(pname, "interlocking") then
return
end
- local form = "size[7,5]label[0.5,0.5;Signal at "..minetest.pos_to_string(pos).."]"
- form = form .. advtrains.interlocking.make_signal_formspec_tabheader(pname, pos, 7, 2)
+ local form = "size[7,6.5]label[0.5,0.5;Signal at "..minetest.pos_to_string(pos).."]"
+ local node = advtrains.ndb.get_node(pos)
+ local ndef = minetest.registered_nodes[node.name] or {}
+ if ndef.advtrains and ndef.advtrains.set_aspect then
+ form = form .. advtrains.interlocking.make_signal_formspec_tabheader(pname, pos, 7, 2)
+ end
advtrains.interlocking.db.check_for_duplicate_ip(pos)
local pts, connid = advtrains.interlocking.db.get_ip_by_signalpos(pos)
if pts then
form = form.."label[0.5,1.5;Influence point is set at "..pts.."/"..connid.."]"
- form = form.."button_exit[0.5,2.5; 5,1;set;Move]"
- form = form.."button_exit[0.5,3.5; 5,1;clear;Clear]"
+ form = form.."button_exit[0.5,4.25; 6,1;set;Move]"
+ form = form.."button_exit[0.5,5.25; 6,1;clear;Clear]"
local ipos = minetest.string_to_pos(pts)
ipmarker(ipos, connid)
else
@@ -152,7 +156,7 @@ function advtrains.interlocking.show_ip_form(pos, pname, only_notset)
form = form.."label[0.5,2.0;It is recommended to set an influence point.]"
form = form.."label[0.5,2.5;This is the point where trains will obey the signal.]"
- form = form.."button_exit[0.5,3.5; 5,1;set;Set]"
+ form = form.."button_exit[0.5,5.25; 6,1;set;Set]"
end
if not only_notset or not pts then
minetest.show_formspec(pname, "at_il_ipassign_"..minetest.pos_to_string(pos), form)
diff --git a/advtrains_interlocking/signal_aspect_ui.lua b/advtrains_interlocking/signal_aspect_ui.lua
index ccedb01..6de21e6 100644
--- a/advtrains_interlocking/signal_aspect_ui.lua
+++ b/advtrains_interlocking/signal_aspect_ui.lua
@@ -52,16 +52,8 @@ local function describe_supported_aspects_t1(suppasp, isasp)
t.main_current = selid
if suppasp.shunt == nil then
- selid = 1
- if isasp and isasp.shunt then
- selid = 2
- end
- entries = {
- describe_t1_shunt_aspect(false),
- describe_t1_shunt_aspect(true),
- }
- t.shunt = entries
- t.shunt_current = selid
+ t.shunt = true
+ t.shunt_current = isasp and isasp.shunt
end
entries = {}
@@ -83,8 +75,12 @@ local signal_tabheader_map = {}
local function make_signal_formspec_tabheader(pname, pos, width, selid)
signal_tabheader_map[pname] = pos
+ local firstlabel = attrans("Signal aspect")
+ if advtrains.interlocking.db.get_sigd_for_signal(pos) then
+ firstlabel = attrans("Routesetting")
+ end
local options = {
- attrans("Signal aspect"),
+ firstlabel,
attrans("Influence point"),
attrans("Distant signalling"),
}
@@ -112,7 +108,7 @@ advtrains.interlocking.make_signal_formspec_tabheader = make_signal_formspec_tab
advtrains.interlocking.handle_signal_formspec_tabheader_fields = handle_signal_formspec_tabheader_fields
local function make_signal_aspect_selector_t1(suppasp, purpose, isasp)
- local form = {"size[7,7.25]"}
+ local form = {"size[7,6.5]"}
local t = describe_supported_aspects_t1(suppasp, isasp)
if type(purpose) == "table" then
form[#form+1] = make_signal_formspec_tabheader(purpose.pname, purpose.pos, 7, 1)
@@ -124,22 +120,21 @@ local function make_signal_aspect_selector_t1(suppasp, purpose, isasp)
form[#form+1] = F.S_label(0.5, 1.5, "Main aspect")
form[#form+1] = F.dropdown(0.5, 2, 6, "main", t.main, t.main_current, true)
- form[#form+1] = F.S_label(0.5, 3, "Shunt aspect")
+ form[#form+1] = F.S_label(0.5, 3, "Distant aspect")
+ form[#form+1] = F.dropdown(0.5, 3.5, 6, "dst", t.dst, t.dst_current, true)
+
if t.shunt then
- form[#form+1] = F.dropdown(0.5, 3.5, 6, "shunt_free", t.shunt, t.shunt_current, true)
+ form[#form+1] = F.S_checkbox(0.5, 4.25, "shunt", t.shunt_current, "Allow shunting")
else
- form[#form+1] = F.S_label(0.5, 3.5, "The shunt aspect cannot be changed")
+ form[#form+1] = F.S_label(0.5, 4.5, "The shunt aspect cannot be changed.")
end
- form[#form+1] = F.S_label(0.5, 4.5, "Distant aspect")
- form[#form+1] = F.dropdown(0.5, 5, 6, "dst", t.dst, t.dst_current, true)
-
- form[#form+1] = F.S_button_exit(0.5, 6, 6, 1, "save", "Save signal aspect")
+ form[#form+1] = F.S_button_exit(0.5, 5.25, 6, 1, "save", "Save signal aspect")
return table.concat(form)
end
local function make_signal_aspect_selector_t2(suppasp, purpose, isasp)
- local form = {"size[7,4]"}
+ local form = {"size[7,6.5]"}
local def = advtrains.interlocking.aspects.get_type2_definition(suppasp.group)
if not def then
return nil
@@ -159,8 +154,13 @@ local function make_signal_aspect_selector_t2(suppasp, purpose, isasp)
end
entries[idx] = spv.label
end
- form[#form+1] = F.dropdown(0.5, 1.5, 6, "asp", entries, selid, true)
- form[#form+1] = F.S_button_exit(0.5, 2.5, 6, 1, "save", "Save signal aspect")
+ form[#form+1] = F.S_label(0.5, 1.5, "Signal group: @1", def.label)
+ form[#form+1] = F.dropdown(0.5, 2, 6, "asp", entries, selid, true)
+ form[#form+1] = F.S_label(0.5, 3, "Aspect in effect:")
+ form[#form+1] = F.label(0.5, 3.5, describe_t1_main_aspect(isasp.main))
+ form[#form+1] = F.label(0.5, 4, describe_t1_distant_aspect(isasp.dst))
+ form[#form+1] = F.label(0.5, 4.5, describe_t1_shunt_aspect(isasp.shunt))
+ form[#form+1] = F.S_button_exit(0.5, 5.25, 6, 1, "save", "Save signal aspect")
return table.concat(form)
end
@@ -205,7 +205,7 @@ local function usebool(sup, val, free)
end
end
-local function get_aspect_from_formspec_t1(suppasp, fields)
+local function get_aspect_from_formspec_t1(suppasp, fields, psl)
local maini = tonumber(fields.main)
if not maini then return end
local dsti = tonumber(fields.dst)
@@ -213,12 +213,12 @@ local function get_aspect_from_formspec_t1(suppasp, fields)
return {
main = suppasp.main[maini],
dst = suppasp.dst[dsti],
- shunt = usebool(suppasp.shunt, fields.shunt_free, "2"),
+ shunt = usebool(suppasp.shunt, psl.shunt, "true"),
info = {},
}
end
-local function get_aspect_from_formspec_t2(suppasp, fields)
+local function get_aspect_from_formspec_t2(suppasp, fields, psl)
local asp = advtrains.interlocking.aspects.type2_to_type1(suppasp, tonumber(fields.asp))
return asp
end
@@ -232,12 +232,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if handle_signal_formspec_tabheader_fields(pname, fields) then
return true
end
+ if fields.shunt then
+ psl.shunt = fields.shunt
+ end
if fields.save then
local asp
if suppasp.type == 2 then
- asp = get_aspect_from_formspec_t2(suppasp, fields)
+ asp = get_aspect_from_formspec_t2(suppasp, fields, psl)
else
- asp = get_aspect_from_formspec_t1(suppasp, fields)
+ asp = get_aspect_from_formspec_t1(suppasp, fields, psl)
end
if asp then
psl.callback(pname, asp)