17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-03 01:30:16 +01:00

feat(editor): a switch laid with no track there, and no switch laid by a click: a press on the ground with a switch armed lays the switch there, its start where it was pressed, the direction of its main track taken from the drag once it's 4 m long and held, the drag sideways then giving the side of the diverging track, back by the start the direction free again; pressed by a free end within 5 m it goes on from that end in its direction and grade, joined to it. Its ends are left free to lay on from, styled after the track it goes on from or as the lay tool lays its tracks (editor_track::create_switch with a path_style). A press let go within 10 pixels places no switch, a slip at a crossing included, which was laid at once on the press: it's laid once dragged, its straights shown meanwhile. The hints and the panel tell of both. Selftest switchfree: Rz 60E1-300-1:9 on the ground with its four ends free, from the free end of a straight joined and walked through; a click on a straight laid none, a drag laid z1

This commit is contained in:
maj00r
2026-10-27 19:33:23 +01:00
parent 1340017be3
commit f8a12107a0
12 changed files with 342 additions and 15 deletions

View File

@@ -1727,6 +1727,9 @@ std::vector<editor_mode::key_hint> editor_mode::track_key_hints(bool const All)
hints.push_back({"Ctrl+wheel", "radius"});
hints.insert(hints.end(), {{"Release", "build"}, {"Esc", "cancel"}});
}
else if (m_switch.placing && m_switch.free)
hints = m_switch.free_end.track != nullptr ? std::vector<key_hint>{{"Drag sideways", "side of the diverging track"}, {"Esc", "cancel"}}
: std::vector<key_hint>{{"Drag along", "the direction of the main track, held from 4 m on"}, {"Drag sideways", "side of the diverging track"}, {"Back to the start", "the direction free again"}, {"Esc", "cancel"}};
else if (m_switch.placing)
hints = m_switch.connection >= 0 && false == m_switch.curved ?
std::vector<key_hint>{{"Drag onto the other track", "the connection there"}, {"Shift+wheel", "another kind"}, {"Ctrl+wheel", "R of the aligning curve"}, {"Alt+wheel", "where a double crossover meets"}, {"Esc", "cancel"}} :
@@ -1739,8 +1742,8 @@ std::vector<editor_mode::key_hint> editor_mode::track_key_hints(bool const All)
{
case switch_kind::connection: hints = {{"Press on a straight", "and drag onto the other track"}, {"Shift+wheel", "another kind"}, {"Ctrl+wheel", "R of the aligning curve"}}; break;
case switch_kind::slip:
case switch_kind::crossing: hints = {{"LMB", "at a crossing of two straights"}}; break;
default: hints = {{"LMB on a track", "the straight or the curve for the switch"}}; break;
case switch_kind::crossing: hints = {{"Press+drag at a crossing", "of two straights"}}; break;
default: hints = {{"LMB on a track", "the straight or the curve for the switch"}, {"Press+drag on the ground", "a switch with no track, on from a free end near it"}}; break;
}
if (selected != nullptr)
{
@@ -2472,7 +2475,7 @@ void editor_mode::draw_build_overlay() const
{
marker = plan.replaces->location();
colour = overlay_color::highlight;
text = STR_C("Click: this double slip is replaced by the one chosen");
text = STR_C("Press and drag: this double slip is replaced by the one chosen");
}
else if (valid)
{
@@ -2485,7 +2488,7 @@ void editor_mode::draw_build_overlay() const
}
marker = {plan.crossing.x, line.start.y + line.grade * plan.alongfirst, plan.crossing.y};
colour = overlay_color::highlight;
text = plan.note.empty() ? std::string{STR_C("Click: it goes here")} : plan.note;
text = plan.note.empty() ? std::string{STR_C("Press and drag: it goes here")} : plan.note;
}
ImVec2 screen;
if (projection.project(marker, screen))