diff --git a/application/editormode.h b/application/editormode.h index d2ccab4e..117566e9 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -1411,6 +1411,7 @@ class editor_mode : public application_mode, private editor_track::observer std::vector lay_pieces(std::vector const &Points, editor_track::snap_target const &End, double &Length, std::string &Error) const; alignment::result lay_shape(std::vector const &Points, glm::dvec2 const &Startdirection, glm::dvec2 const &Enddirection, alignment::design &Design) const; void render_switch_ui(); + void render_switch_timbers(); void render_rail_profile_hint(TTrack &Track); bool start_switch_placement(); void finish_switch_placement(); @@ -1780,6 +1781,9 @@ class editor_mode : public application_mode, private editor_track::observer void select_tracks(std::vector const &Tracks); // changes each track which can be changed, in one step of the undo; false from Change: the track stays as it was std::size_t tracks_apply(std::vector const &Tracks, std::function const &Change, bool const Rebuild, char const *What); + // the model of the timbers, with the fastenings where it has them, set on all the switches and crossings of the scenery, in one + // step of the undo; empty: the one of eu07.ini. returns: the tracks changed + std::size_t set_switch_timbers(std::string const &Model); int track_property_index(std::string const &Key) const; std::size_t track_property_apply(int const Property, std::vector const &Tracks, std::string const &Text); void track_field_settle(); diff --git a/application/editormodeselftest.cpp b/application/editormodeselftest.cpp index e163b632..cb8095d4 100644 --- a/application/editormodeselftest.cpp +++ b/application/editormodeselftest.cpp @@ -68,6 +68,7 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c // railtime lays out the rails of every track, as when its geometry is made, and logs how long it took // throw <0|1> sets every switch to the path and moves its blades there at once // crossings [name] logs where rails of tracks cross rails of other tracks and of what kind (acute, obtuse, middle acute or obtuse, wide), checks that each acute crossing has one partner and one nose +// switchtimbers the model of the timbers set on all the switches and crossings, as the buttons of the switch tool do it // frogkey name [on|off] sets or clears the frogs key of a switch (one undo step); logs the key, whether it is written, the frog and the crossings // geomhash [name] logs the number of vertices and a hash of the drawn geometry of each rail track (rails, trackbed, cut faces), to compare builds; exact: the bits of every value, userdata and tread materials too // sweep =... model, params (separated by commas), lateral, height, side (origin, near, far, diff --git a/application/editormodeselftestrails.cpp b/application/editormodeselftestrails.cpp index 86d69280..ee1e7b4f 100644 --- a/application/editormodeselftestrails.cpp +++ b/application/editormodeselftestrails.cpp @@ -324,6 +324,15 @@ editor_mode::selftest_result editor_mode::selftest_rails(std::string const &comm WriteLog(format("SELFTEST geom total: tracks %d, vertices %zu, hash %016llx, exact %016llx", tracks, vertices, static_cast(total), static_cast(exacttotal))); return selftest_result::handled; } + if (command == "switchtimbers") + { + std::string model; + words >> model; + if (model == "none") + model.clear(); + WriteLog(format("SELFTEST switchtimbers %s: %zu tracks", model.c_str(), set_switch_timbers(model))); + return selftest_result::handled; + } if (command == "frogkey") { std::string name, value; diff --git a/application/editormodeswitchtool.cpp b/application/editormodeswitchtool.cpp index 169dde34..41f163a5 100644 --- a/application/editormodeswitchtool.cpp +++ b/application/editormodeswitchtool.cpp @@ -19,6 +19,7 @@ http://mozilla.org/MPL/2.0/. #include "simulation/simulation.h" #include "utilities/translation.h" #include "world/Track.h" +#include "world/TrackSleepers.h" #include "imgui/imgui.h" #include @@ -390,6 +391,7 @@ void editor_mode::render_switch_ui() arm_switch(); } item_tooltip("Looks for the switches of the scenery, to use their shapes as the templates"); + render_switch_timbers(); ImGui::TreePop(); } ImGui::PopID(); @@ -405,6 +407,35 @@ void editor_mode::render_switch_ui() item_tooltip("Own switch templates: diverging tracks of straights, arcs and transition curves, double switches"); } +// the timbers of all the switches and crossings of the scenery at once: a button for each model of timbers of the scenery data +void editor_mode::render_switch_timbers() +{ + ImGui::TextDisabled("%s", STR_C("Timbers of all the switches")); + auto first{true}; + auto const button = [&](std::string const &Model, std::string const &Label) { + if (false == first) + ImGui::SameLine(); + first = false; + if (ImGui::Button((Label + "##switchtimbers" + Model).c_str())) + m_switch.status = format(STR_C("Timbers %s set on %d tracks"), Label.c_str(), static_cast(set_switch_timbers(Model))); + item_tooltip("Sets the model of the timbers, with the fastenings where it has them, on all the switches and crossings of the scenery, in one step of the undo"); + }; + for (auto const &model : track_sleepers::pack_models()) + if (model.timber) + button(model.name, model.name.substr(model.name.find_last_of('/') + 1)); + button({}, STR_C("As in eu07.ini")); +} + +std::size_t editor_mode::set_switch_timbers(std::string const &Model) +{ + std::vector tracks; + for (auto *track : simulation::Paths.sequence()) + if (track != nullptr && false == track->m_editorremoved && (track->iCategoryFlag & 15) == 1 && (track->eType == tt_Switch || false == track->m_crossings.empty()) + && track->m_timber_model_name != Model) + tracks.push_back(track); + return tracks_apply(tracks, [&](TTrack &Track) { Track.m_timber_model_name = Model; return true; }, true, "Timber model"); +} + // a track with no rail profile, as the sceneries of the older editors have them: the templates of all the rails are offered. // the profile set at once on all the tracks laid with the same rails and no profile, so a scenery is put right in a few clicks void editor_mode::render_rail_profile_hint(TTrack &Track) diff --git a/lang/editor_pl.po b/lang/editor_pl.po index 5f29c7e4..df157d80 100644 --- a/lang/editor_pl.po +++ b/lang/editor_pl.po @@ -10378,3 +10378,15 @@ msgstr "Odczytaj ponownie" msgid "Pick a memory cell from the list to set what's in it" msgstr "Wybierz komórkę pamięci z listy, aby ustawić jej zawartość" + +msgid "Timbers of all the switches" +msgstr "Podrozjazdnice wszystkich rozjazdów" + +msgid "Timbers %s set on %d tracks" +msgstr "Podrozjazdnice %s ustawione na %d torach" + +msgid "As in eu07.ini" +msgstr "Jak w eu07.ini" + +msgid "Sets the model of the timbers, with the fastenings where it has them, on all the switches and crossings of the scenery, in one step of the undo" +msgstr "Ustawia model podrozjazdnic, razem z przytwierdzeniami tam, gdzie je ma, na wszystkich rozjazdach i skrzyżowaniach scenerii, jednym krokiem cofania"