From 2b40a3617309205b3985ab71385d177e3aff9896 Mon Sep 17 00:00:00 2001 From: maj00r Date: Thu, 22 Oct 2026 12:13:22 +0200 Subject: [PATCH] feat(editor): the switch numbering of the signalling mode renames the switch in the objects of the scenery naming it, as the lanterns of the switches --- application/editormodesrk.cpp | 31 +++++++++++++++++++++++++++++-- lang/editor_pl.po | 10 ++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/application/editormodesrk.cpp b/application/editormodesrk.cpp index 90ad37a1..52b05daa 100644 --- a/application/editormodesrk.cpp +++ b/application/editormodesrk.cpp @@ -542,7 +542,7 @@ void srk_tool::render_options() if (ImGui::Button(STR_C("Number the switches"), ImVec2(-1.0f, 0.0f))) number_switches(); item_tooltip("Numbers the switches 1, 2, 3... along the station and names them after its code, as on the lines of PKP PLK: bpd_1, " - "the parts of a slip bpd_15a to bpd_15d. The drives follow their switches, events written by hand keep the old names. One step of undo"); + "the parts of a slip bpd_15a to bpd_15d. The drives and the objects naming a switch follow it, events written by hand keep the old names. One step of undo"); step_heading(2, STR_C("Track circuits")); if (main_button(STR_C("Set the track circuits"), ImVec2(-1.0f, tall_button_height()))) set_circuits(); @@ -678,6 +678,24 @@ void srk_tool::number_switches() if (false == units[index].record.empty()) bases[units[index].record] = station::switch_name(code, static_cast(index) + 1, 0, 1); switch_store::rename(parts, bases); + // the objects of the scenery naming a switch, as the lanterns of rainsted/lwzm.inc, follow it + std::map renamed; + for (auto const &[track, name] : names) + if (track->name() != name) + renamed[ToLower(track->name())] = name; + std::vector>> following; + for (auto &standing : m_templates.standing_templates([](std::string const &) { return true; })) + { + auto changed{false}; + for (auto &value : standing.values) + if (auto const found{renamed.find(ToLower(value))}; found != renamed.end()) + { + value = found->second; + changed = true; + } + if (changed) + following.emplace_back(standing.instance, std::move(standing.values)); + } // the names go round among the switches: a switch whose name another one gets gives it up first for (auto const &entry : names) if (entry.first->name() != entry.second && std::any_of(names.begin(), names.end(), [&](auto const &Other) { return Other.first != entry.first && Other.second == entry.first->name(); })) @@ -698,8 +716,17 @@ void srk_tool::number_switches() } if (before.empty()) before.emplace_back(units.front().parts.front(), editor_track::capture(*units.front().parts.front())); - m_history.push_track_snapshot(std::move(before)); + auto const followed{following.size()}; + if (following.empty()) + m_history.push_track_snapshot(std::move(before)); + else + { + std::string error; + m_signals.signal_batch({{}, {}, {}, std::move(following)}, std::move(before), {}, error); + } m_status = format(STR_P("%zu switch numbered", "%zu switches numbered", units.size()), units.size()); + if (followed > 0) + m_status += ", " + format(STR_P("%zu object of the scenery follows them", "%zu objects of the scenery follow them", followed), followed); } void srk_tool::set_circuits() diff --git a/lang/editor_pl.po b/lang/editor_pl.po index 229924d2..b1e39a85 100644 --- a/lang/editor_pl.po +++ b/lang/editor_pl.po @@ -10389,8 +10389,8 @@ msgstr "Od wschodniego końca stacji" msgid "Number the switches" msgstr "Ponumeruj rozjazdy" -msgid "Numbers the switches 1, 2, 3... along the station and names them after its code, as on the lines of PKP PLK: bpd_1, the parts of a slip bpd_15a to bpd_15d. The drives follow their switches, events written by hand keep the old names. One step of undo" -msgstr "Numeruje rozjazdy 1, 2, 3... wzdłuż stacji i nazywa je od jej skrótu, jak na liniach PKP PLK: bpd_1, części rozjazdu krzyżowego bpd_15a do bpd_15d. Napędy idą za swoimi rozjazdami, eventy pisane ręcznie zostają przy starych nazwach. Jeden krok cofania" +msgid "Numbers the switches 1, 2, 3... along the station and names them after its code, as on the lines of PKP PLK: bpd_1, the parts of a slip bpd_15a to bpd_15d. The drives and the objects naming a switch follow it, events written by hand keep the old names. One step of undo" +msgstr "Numeruje rozjazdy 1, 2, 3... wzdłuż stacji i nazywa je od jej skrótu, jak na liniach PKP PLK: bpd_1, części rozjazdu krzyżowego bpd_15a do bpd_15d. Napędy i obiekty z nazwą rozjazdu, jak latarnie zwrotnicowe, idą za nim, eventy pisane ręcznie zostają przy starych nazwach. Jeden krok cofania" msgid "Give the station its code first: the switches are named after it" msgstr "Najpierw wpisz skrót stacji: od niego biorą się nazwy rozjazdów" @@ -10536,3 +10536,9 @@ msgstr[0] "%zu odstęp" msgstr[1] "%zu odstępy" msgstr[2] "%zu odstępów" +msgid "%zu object of the scenery follows them" +msgid_plural "%zu objects of the scenery follow them" +msgstr[0] "%zu obiekt scenerii idzie za nimi" +msgstr[1] "%zu obiekty scenerii idą za nimi" +msgstr[2] "%zu obiektów scenerii idzie za nimi" +