From d42f1bcf1a7ec18d392671be54636e7cad8b788b Mon Sep 17 00:00:00 2001 From: orwell Date: Wed, 13 Nov 2024 20:51:04 +0100 Subject: Route edit UI: option to copy route in place --- advtrains_interlocking/route_ui.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/advtrains_interlocking/route_ui.lua b/advtrains_interlocking/route_ui.lua index 478e8dc..89580a8 100644 --- a/advtrains_interlocking/route_ui.lua +++ b/advtrains_interlocking/route_ui.lua @@ -106,7 +106,7 @@ function atil.show_route_edit_form(pname, sigd, routeid) end form = form.."button[0.5,6;1,1;prev;<<<]" - form = form.."button[1.5,6;1,1;back;Back]" + form = form.."button[1.5,6;1,1;back;"..routeid.."/"..#tcbs.routes.."]" form = form.."button[2.5,6;1,1;next;>>>]" @@ -114,6 +114,8 @@ function atil.show_route_edit_form(pname, sigd, routeid) form = form.."button[3.5,6;2,1;noautogen;Clr Autogen]" end form = form.."button[5.5,6;3,1;delete;Delete Route]" + form = form.."button[0.5,7;3,1;back;Back to signal]" + form = form.."button[3.5,7;2,1;clone;Clone Route]" form = form.."button[5.5,7;3,1;newfrom;New From Route]" --atdebug(route.ars) @@ -186,6 +188,16 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) table.remove(tcbs.routes, routeid) advtrains.interlocking.show_signalling_form(sigd, pname) end + + if fields.clone then + -- if something set the route in the meantime, make sure this doesn't break. + atil.route.update_route(sigd, tcbs, nil, true) + local rcopy = table.copy(route) + rcopy.name = route.name.."_copy" + rcopy.smartroute_generated = nil + table.insert(tcbs.routes, routeid+1, rcopy) + advtrains.interlocking.show_signalling_form(sigd, pname) + end if fields.newfrom then advtrains.interlocking.init_route_prog(pname, sigd, route) -- cgit v1.2.3