mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-26 18:14:55 +01:00
feat(editor): buttons in the switch tool setting a model of timbers on all the switches and crossings of the scenery at once, one for each model of timbers of the scenery data and one for the model of eu07.ini, in one step of the undo; the selftest switchtimbers does the same
This commit is contained in:
@@ -1411,6 +1411,7 @@ class editor_mode : public application_mode, private editor_track::observer
|
||||
std::vector<segment_data> lay_pieces(std::vector<glm::dvec3> const &Points, editor_track::snap_target const &End, double &Length, std::string &Error) const;
|
||||
alignment::result lay_shape(std::vector<glm::dvec3> 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<TTrack *> 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<TTrack *> const &Tracks, std::function<bool(TTrack &)> 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<TTrack *> const &Tracks, std::string const &Text);
|
||||
void track_field_settle();
|
||||
|
||||
@@ -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 <model|none> 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 <key>=<value>... model, params (separated by commas), lateral, height, side (origin, near, far,
|
||||
|
||||
@@ -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<unsigned long long>(total), static_cast<unsigned long long>(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;
|
||||
|
||||
@@ -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 <algorithm>
|
||||
@@ -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<int>(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<TTrack *> 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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user