From 979a3d1ce48304c484b9dc5bf37906f4262c7a18 Mon Sep 17 00:00:00 2001 From: maj00r Date: Sun, 18 Oct 2026 01:50:56 +0200 Subject: [PATCH] feat(editor): switch templates for the rail of the selected track, their names translated, shorter hints - the template list shows the templates of the rail the selected track is laid with (railprofile s60/uic60: 60E1, s49: 49E1, s42: S42), a box shows them all - the words of the catalogue names are translated (movable nose, long, gauge, blades outside), the kind of a slip or a crossing its type says already is left out - shorter hints of the switch tool, of More and of the missing drives --- application/editormode.h | 1 + application/editormodeswitchdrive.cpp | 2 +- application/editormodeswitchtool.cpp | 66 ++++++++++++++++++++++----- application/editormodeviewport.cpp | 2 +- lang/editor_pl.po | 65 ++++++++++++++++++-------- 5 files changed, 102 insertions(+), 34 deletions(-) diff --git a/application/editormode.h b/application/editormode.h index 4e2e33f2..4418d035 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -1026,6 +1026,7 @@ class editor_mode : public application_mode, private editor_track::observer double slide_typed{0.0}; int connection{-1}; int connection_kind{0}; // the kind of connection chosen last, taken again when the connections are chosen + bool rail_only{true}; // the templates listed only for the rail of the selected track, where its rail profile tells it int connection_second{-1}; double connection_radius{0.0}; double connection_gap{6.0}; diff --git a/application/editormodeswitchdrive.cpp b/application/editormodeswitchdrive.cpp index 56507c15..af2a5c3e 100644 --- a/application/editormodeswitchdrive.cpp +++ b/application/editormodeswitchdrive.cpp @@ -289,7 +289,7 @@ bool editor_mode::render_switch_drive_choice() scan_switch_drives(); if (tool.drives.empty()) { - ImGui::TextDisabled("%s", STR_C("No switch drive models in the scenery data")); + ImGui::TextDisabled("%s", STR_C("No switch drive models")); return false; } auto const label = [&](int const Index) { return Index < 0 ? std::string{STR_C("no drive")} : tool.drives[Index].name; }; diff --git a/application/editormodeswitchtool.cpp b/application/editormodeswitchtool.cpp index 2b2f2714..de4ed558 100644 --- a/application/editormodeswitchtool.cpp +++ b/application/editormodeswitchtool.cpp @@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/. #include "application/editormode.h" #include "application/editormodeshared.h" #include "editor/editorConnections.hpp" +#include "editor/editorFormat.hpp" #include "utilities/translation.h" #include "world/Track.h" @@ -45,13 +46,43 @@ bool of_kind(editor_track::switch_template const &Template, int const Kind) } } +// the rail of the switch templates fitting the track, by the rail profile it's laid with; empty where the profile doesn't tell +std::string rail_of(TTrack const *Track) +{ + if (Track == nullptr || (Track->iCategoryFlag & 15) != 1) + return {}; + auto const &profile{Track->m_profile1.first}; + if (profile == "s60" || profile == "uic60") + return "60E1"; + if (profile == "s49") + return "49E1"; + if (profile == "s42") + return "S42"; + return {}; +} + +// the name of the template in the language of the editor: the words of the catalogue translated, the kind of a slip or +// a crossing left out where its type says it +std::string translated(std::string Title) +{ + auto const replace = [&](std::string const &From, std::string const &To) { + for (auto at{Title.find(From)}; at != std::string::npos; at = Title.find(From, at + To.size())) + Title.replace(at, From.size(), To); + }; + for (auto const *redundant : {" single slip", " double slip", " crossing"}) + replace(redundant, ""); + for (auto const *word : {"the blades outside of the diamond", "movable nose", "gauge", "long"}) + replace(word, STR(word)); + return Title; +} + } // namespace std::string editor_mode::switch_template_label(editor_track::switch_template const &Template) { if (Template.source != nullptr) return STR("Scenery: ") + Template.title() + " (" + std::to_string(Template.count) + "x)"; - return (Template.own ? STR("Own: ") : std::string{"PLK: "}) + Template.title(); + return (Template.own ? STR("Own: ") : std::string{"PLK: "}) + translated(Template.title()); } editor_mode::switch_kind editor_mode::current_switch_kind() const @@ -101,10 +132,10 @@ void editor_mode::render_switch_ui() char const *label; char const *tooltip; }; - choice const choices[] = {{switch_kind::single, "Switch", "A switch put into a straight or a curve"}, - {switch_kind::slip, "Slip switch", "A single or double slip switch at a crossing of two straights"}, + choice const choices[] = {{switch_kind::single, "Switch", "A switch in a straight or a curve"}, + {switch_kind::slip, "Slip switch", "Rkp or Rkpd at a crossing of two straights"}, {switch_kind::crossing, "Crossing", "A crossing of two straights"}, - {switch_kind::connection, "Connection", "Switches laid whole between two tracks: a crossover, a double or a scissors crossover, a switch ladder"}}; + {switch_kind::connection, "Connection", "Crossover, double, scissors, ladder"}}; ImGui::TextDisabled("%s", STR_C("What to place")); auto first{true}; for (auto const &entry : choices) @@ -138,26 +169,37 @@ void editor_mode::render_switch_ui() char const *how{nullptr}; switch (kind) { - case switch_kind::slip: how = "Click at a crossing of two straights; a single slip on the side of the joined tracks"; break; - case switch_kind::crossing: how = "Click at a crossing of two straights"; break; + case switch_kind::slip: how = "Click a crossing of two straights"; break; + case switch_kind::crossing: how = "Click a crossing of two straights"; break; case switch_kind::connection: - how = tool.connection == static_cast(connection::kind::double_crossover) ? "Press on a straight and drag onto the other track. While dragging: Shift+wheel another kind, Ctrl+wheel R of the aligning curve, Alt+wheel where they meet" : - "Press on a straight and drag onto the other track. While dragging: Shift+wheel another kind, Ctrl+wheel R of the aligning curve"; + how = tool.connection == static_cast(connection::kind::double_crossover) ? "Drag from a straight onto the other track. Shift+wheel: kind, Ctrl+wheel: R, Alt+wheel: where they meet" : + "Drag from a straight onto the other track. Shift+wheel: kind, Ctrl+wheel: R"; break; - default: how = "Click a straight or a curve, then press on it and drag: along for the direction, sideways for the side"; break; + default: how = "Click a track and drag: along for the direction, sideways for the side"; break; } ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.8f, 0.3f, 1.0f)); ImGui::TextWrapped("%s", STR_C(how)); ImGui::PopStyleColor(); - // the templates of the kind, by their names; the lengths and the rest of the label in the tooltip + // the templates of the kind, by their names, for the rail of the selected track unless all are asked for; the lengths + // and the rest of the label in the tooltip ImGui::TextDisabled("%s", STR_C(kind == switch_kind::connection ? "The first switch" : "Template")); - auto const listed{static_cast(std::count_if(tool.templates.begin(), tool.templates.end(), [&](editor_track::switch_template const &Template) { return of_kind(Template, static_cast(kind)); }))}; + auto const rail{rail_of(selected_track())}; + if (false == rail.empty()) + { + ImGui::SameLine(); + ImGui::Checkbox(format(STR_C("Rail of the track: %s##railonly"), rail.c_str()).c_str(), &tool.rail_only); + item_tooltip("Only the templates of the rail the selected track is laid with"); + } + auto const shown = [&](editor_track::switch_template const &Template) { + return of_kind(Template, static_cast(kind)) && (rail.empty() || false == tool.rail_only || Template.source != nullptr || Template.rail == rail || Template.rail == "-"); + }; + auto const listed{static_cast(std::count_if(tool.templates.begin(), tool.templates.end(), shown))}; ImGui::BeginChild("##switchtemplates", ImVec2(0.0f, std::min(240.0f, (listed + 0.5f) * ImGui::GetTextLineHeightWithSpacing() + 8.0f)), true); for (int i = 0; i < static_cast(tool.templates.size()); ++i) { auto const &entry{tool.templates[i]}; - if (false == of_kind(entry, static_cast(kind))) + if (false == shown(entry)) continue; if (ImGui::Selectable((switch_template_label(entry) + "##switch" + std::to_string(i)).c_str(), tool.armed == i)) { diff --git a/application/editormodeviewport.cpp b/application/editormodeviewport.cpp index 6d371e8e..c75e0a77 100644 --- a/application/editormodeviewport.cpp +++ b/application/editormodeviewport.cpp @@ -174,7 +174,7 @@ void editor_mode::work_area_tools(std::vector &Buttons) auto const advanced{m_track_tab == track_tab::turntable || m_track_tab == track_tab::signals || m_track_tab == track_tab::lineside || m_track_tab == track_tab::profile || m_track_tab == track_tab::speed || m_track_tab == track_tab::joints || m_gauge.open}; auto const more{EditorSettings.track_tools_more()}; - Buttons.push_back({icon::more, more ? STR_C("Less") : STR_C("More"), nullptr, STR_C("Turntables, signals, objects along the track, trainsets and the checks of a line laid: profile, speed, joints, structure gauge"), more, [more]() { + Buttons.push_back({icon::more, more ? STR_C("Less") : STR_C("More"), nullptr, STR_C("Turntable, signals, objects, trainset, profile, speed, joints, gauge"), more, [more]() { EditorSettings.track_tools_more(false == more); EditorSettings.save(); }, true}); diff --git a/lang/editor_pl.po b/lang/editor_pl.po index 7384ba55..0685469c 100644 --- a/lang/editor_pl.po +++ b/lang/editor_pl.po @@ -6941,32 +6941,16 @@ msgstr "Skrzyżowanie" msgid "Connection" msgstr "Połączenie" -msgid "A switch put into a straight or a curve" -msgstr "Rozjazd wstawiany w prostą albo łuk" -msgid "A single or double slip switch at a crossing of two straights" -msgstr "Rozjazd krzyżowy pojedynczy albo podwójny, na skrzyżowaniu dwóch prostych" msgid "A crossing of two straights" msgstr "Skrzyżowanie dwóch prostych" -msgid "Switches laid whole between two tracks: a crossover, a double or a scissors crossover, a switch ladder" -msgstr "Rozjazdy układane w całości między dwoma torami: przejście, przejście podwójne, nożycowe, drabinka rozjazdów" -msgid "Click at a crossing of two straights; a single slip on the side of the joined tracks" -msgstr "Kliknij skrzyżowanie dwóch prostych; rozjazd pojedynczy po stronie łączonych torów" -msgid "Click at a crossing of two straights" -msgstr "Kliknij skrzyżowanie dwóch prostych" -msgid "Press on a straight and drag onto the other track. While dragging: Shift+wheel another kind, Ctrl+wheel R of the aligning curve, Alt+wheel where they meet" -msgstr "Wciśnij LPM na prostej i przeciągnij na drugi tor. W trakcie: Shift+kółko inny rodzaj, Ctrl+kółko R łuku dopasowującego, Alt+kółko miejsce spotkania" -msgid "Press on a straight and drag onto the other track. While dragging: Shift+wheel another kind, Ctrl+wheel R of the aligning curve" -msgstr "Wciśnij LPM na prostej i przeciągnij na drugi tor. W trakcie: Shift+kółko inny rodzaj, Ctrl+kółko R łuku dopasowującego" -msgid "Click a straight or a curve, then press on it and drag: along for the direction, sideways for the side" -msgstr "Kliknij prostą albo łuk, potem wciśnij na nim i przeciągnij: wzdłuż wybiera kierunek, w bok stronę toru zwrotnego" msgid "The first switch" msgstr "Pierwszy rozjazd" @@ -6977,11 +6961,7 @@ msgstr "Wzorzec" msgid "Details##switchdetails" msgstr "Szczegóły##switchdetails" -msgid "No switch drive models in the scenery data" -msgstr "Brak modeli napędów zwrotnic w danych scenerii" -msgid "Turntables, signals, objects along the track, trainsets and the checks of a line laid: profile, speed, joints, structure gauge" -msgstr "Obrotnice, sygnalizatory, obiekty wzdłuż toru, składy i sprawdzanie ułożonej linii: profil, prędkość, styki, skrajnia" msgid "Press on a straight" msgstr "Wciśnij na prostej" @@ -6991,3 +6971,48 @@ msgstr "i przeciągnij na drugi tor" msgid "at a crossing of two straights" msgstr "na skrzyżowaniu dwóch prostych" + +msgid "A switch in a straight or a curve" +msgstr "Rozjazd w prostej albo łuku" + +msgid "Rkp or Rkpd at a crossing of two straights" +msgstr "Rkp albo Rkpd na skrzyżowaniu dwóch prostych" + +msgid "Crossover, double, scissors, ladder" +msgstr "Przejście, podwójne, nożyce, ulica zwrotnicowa" + +msgid "Click a crossing of two straights" +msgstr "Kliknij skrzyżowanie dwóch prostych" + +msgid "Drag from a straight onto the other track. Shift+wheel: kind, Ctrl+wheel: R, Alt+wheel: where they meet" +msgstr "Przeciągnij z prostej na drugi tor. Shift+kółko: rodzaj, Ctrl+kółko: R, Alt+kółko: miejsce spotkania" + +msgid "Drag from a straight onto the other track. Shift+wheel: kind, Ctrl+wheel: R" +msgstr "Przeciągnij z prostej na drugi tor. Shift+kółko: rodzaj, Ctrl+kółko: R" + +msgid "Click a track and drag: along for the direction, sideways for the side" +msgstr "Kliknij tor i przeciągnij: wzdłuż kierunek, w bok strona" + +msgid "Turntable, signals, objects, trainset, profile, speed, joints, gauge" +msgstr "Obrotnica, sygnalizatory, obiekty, skład, profil, prędkość, styki, skrajnia" + +msgid "No switch drive models" +msgstr "Brak modeli napędów" + +msgid "the blades outside of the diamond" +msgstr "iglice zewnętrzne" + +msgid "movable nose" +msgstr "ruchomy dziób" + +msgid "gauge" +msgstr "rozstaw" + +msgid "long" +msgstr "wydłużony" + +msgid "Rail of the track: %s##railonly" +msgstr "Szyna toru: %s##railonly" + +msgid "Only the templates of the rail the selected track is laid with" +msgstr "Tylko wzorce na szynę, z której jest zaznaczony tor"