18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-22 06:44:58 +01:00

feat(editor): picking a drive or its side in the Switch mode panel changes the drive of the selected switch at once, no drive takes it away, each as one undo step; self-test command drivechoice; Polish translation

This commit is contained in:
maj00r
2026-10-11 20:46:20 +02:00
parent b4a1cb03b3
commit 080e308d5e
4 changed files with 34 additions and 1 deletions

View File

@@ -1408,6 +1408,7 @@ class editor_mode : public application_mode, private editor_track::observer
std::vector<standing_template> standing_templates(std::function<bool(std::string const &)> const &Accept) const;
bool find_switch_drive(TTrack const &Switch, standing_template &Drive, int &Family, int &Index);
bool replace_switch_drive(TTrack &Switch, int Family, bool Flip);
void apply_switch_drive_choice(TTrack &Switch);
bool switch_drive_spot(TTrack const &Switch, glm::dvec3 &Location, double &Yaw, glm::dvec2 &Tilt, bool &Rightswitch) const;
void switch_drive_captured(TTrack const &Track);
void switch_drives_committed(std::vector<TTrack *> const &Tracks);

View File

@@ -405,6 +405,19 @@ void editor_mode::selftest_step()
m_switch.drive_side = side;
WriteLog("SELFTEST switchdrive: " + (index >= 0 && index < static_cast<int>(m_switch.drives.size()) ? m_switch.drives[index].name : std::string{"none"}));
}
else if (command == "drivechoice")
{
int index{-1}, side{0};
words >> index >> side;
scan_switch_drives();
m_switch.drive = index;
m_switch.drive_side = side;
m_switch.status.clear();
auto *track{selected_track()};
if (track != nullptr && track->eType == tt_Switch && false == track->m_editorremoved)
apply_switch_drive_choice(*track);
WriteLog("SELFTEST drivechoice: " + (track != nullptr ? track->name() : std::string{"no switch"}) + ", " + m_switch.status);
}
else if (command == "drives")
{
std::string name;

View File

@@ -6814,6 +6814,20 @@ bool editor_mode::find_switch_drive(TTrack const &Switch, standing_template &Dri
return true;
}
void editor_mode::apply_switch_drive_choice(TTrack &Switch)
{
if (m_switch.drive >= 0)
{
place_switch_drive(Switch);
return;
}
standing_template found;
int family{-1};
int variant{0};
if (find_switch_drive(Switch, found, family, variant) && remove_templates({found.instance}) > 0)
m_switch.status = format(STR_C("Switch %s without a drive now"), Switch.name().c_str());
}
bool editor_mode::flip_switch_drive(TTrack &Switch)
{
return replace_switch_drive(Switch, -1, true);
@@ -7562,7 +7576,9 @@ void editor_mode::render_switch_ui()
ImGui::InputTextWithHint(STR_C("Name##switchname"), switch_name_for_new().c_str(), tool.name, sizeof(tool.name));
ImGui::PopItemWidth();
item_tooltip("Name of the next switch, its drive events are named after it; empty: the next free z1, z2...; a number at the end goes up with each switch");
render_switch_drive_choice();
if (render_switch_drive_choice())
if (auto *track{selected_track()}; track != nullptr && track->eType == tt_Switch && false == track->m_editorremoved)
apply_switch_drive_choice(*track);
if (false == tool.status.empty())
ImGui::TextColored(ImVec4(1.0f, 0.7f, 0.2f, 1.0f), "%s", tool.status.c_str());
if (ImGui::SmallButton(STR_C("Collect from the scenery")))

View File

@@ -5452,3 +5452,6 @@ msgstr "Zwrotnica %s: napęd %s, teraz po prawej"
msgid "Switch %s: the drive %s, on the left now"
msgstr "Zwrotnica %s: napęd %s, teraz po lewej"
msgid "Switch %s without a drive now"
msgstr "Zwrotnica %s jest teraz bez napędu"