diff options
author | 1F616EMO <root@1f616emo.xyz> | 2024-09-08 07:19:32 +0800 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2024-11-09 22:03:02 +0100 |
commit | ca4084df86527d98c738fb1f731ffdaa32936c91 (patch) | |
tree | efdb7eb9531f6bf78820a9b1ebfbd4a733e94283 /advtrains_interlocking/tcb_ts_ui.lua | |
parent | 6d3c5a5f38d66a74c7b2bc219ee16f258ba50a2b (diff) | |
download | advtrains-ca4084df86527d98c738fb1f731ffdaa32936c91.tar.gz advtrains-ca4084df86527d98c738fb1f731ffdaa32936c91.tar.bz2 advtrains-ca4084df86527d98c738fb1f731ffdaa32936c91.zip |
Allow manually sorting of signal soutes
This patch adds two buttons to the signal UI for swapping routes in the list of routes. To prevent conflicts, this operation is only possible when there is no route set.
Diffstat (limited to 'advtrains_interlocking/tcb_ts_ui.lua')
-rwxr-xr-x | advtrains_interlocking/tcb_ts_ui.lua | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua index 96edadb..264834c 100755 --- a/advtrains_interlocking/tcb_ts_ui.lua +++ b/advtrains_interlocking/tcb_ts_ui.lua @@ -657,14 +657,22 @@ function advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte, calle strtab[#strtab+1] = clr .. minetest.formspec_escape(route.name) end form = form.."label[0.5,2.5;Routes:]" - form = form.."textlist[0.5,3;5,3;rtelist;"..table.concat(strtab, ",").."]" + form = form.."textlist[0.5,3;5,3;rtelist;"..table.concat(strtab, ",") if sel_rte then + form = form .. ";" .. sel_rte .."]" form = form.."button[0.5,6; 5,1;setroute;Set Route]" form = form.."button[0.5,7;2,1;dsproute;Show]" if hasprivs then form = form.."button[3.5,7;2,1;editroute;Edit]" + if sel_rte > 1 then + form = form .. "button[5.5,4;0.5,0.3;moveup;↑]" + end + if sel_rte < #strtab then + form = form .. "button[5.5,4.7;0.5,0.3;movedown;↓]" + end end else + form = form .. "]" if tcbs.ars_disabled then form = form.."label[0.5,6 ;NOTE: ARS is disabled.]" form = form.."label[0.5,6.5;Routes are not automatically set.]" @@ -815,6 +823,20 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if fields.noauto then tcbs.route_auto = false end + + if sel_rte and tcbs.routes[sel_rte]and not tcbs.routeset then + if fields.moveup then + if tcbs.routes[sel_rte - 1] then + tcbs.routes[sel_rte - 1], tcbs.routes[sel_rte] = tcbs.routes[sel_rte], tcbs.routes[sel_rte - 1] + sel_rte = sel_rte - 1 + end + elseif fields.movedown then + if tcbs.routes[sel_rte + 1] then + tcbs.routes[sel_rte + 1], tcbs.routes[sel_rte] = tcbs.routes[sel_rte], tcbs.routes[sel_rte + 1] + sel_rte = sel_rte + 1 + end + end + end advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte, true) return |