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:
@@ -829,6 +829,14 @@ editor_mode::track_intent editor_mode::track_intent_at(int const Mods)
|
||||
return make(kind::switch_at, "Press and drag: a switch here, along sets its direction, sideways its side");
|
||||
}
|
||||
}
|
||||
// a press on the ground lays a switch with no track there, going on from a free end within reach
|
||||
if (m_hover.track == nullptr && free_switch_offered())
|
||||
{
|
||||
auto const end{free_switch_end(ground)};
|
||||
intent.position = end.track != nullptr ? end.position : ground;
|
||||
return make(kind::switch_free, end.track != nullptr ? "Press and drag: a switch going on from this free end, sideways its side"
|
||||
: "Press and drag: a switch with no track, along the direction of its main track, then sideways its side");
|
||||
}
|
||||
if (m_track_tab == track_tab::lineside && m_fouling.tab().open)
|
||||
if (auto const hit{m_fouling.hit()}; hit.has_value())
|
||||
{
|
||||
@@ -1022,7 +1030,20 @@ void editor_mode::track_press(track_intent const &Intent)
|
||||
m_route.grip = Intent.index;
|
||||
handle_drag_start(Intent.position);
|
||||
return;
|
||||
case kind::switch_at: start_switch_placement(); return;
|
||||
case kind::switch_at:
|
||||
{
|
||||
auto const &io{ImGui::GetIO()};
|
||||
m_switch.pressed_at = {io.MousePos.x, io.MousePos.y};
|
||||
start_switch_placement();
|
||||
return;
|
||||
}
|
||||
case kind::switch_free:
|
||||
{
|
||||
auto const &io{ImGui::GetIO()};
|
||||
m_switch.pressed_at = {io.MousePos.x, io.MousePos.y};
|
||||
start_free_switch(Intent.position);
|
||||
return;
|
||||
}
|
||||
case kind::kilometrage:
|
||||
if (Intent.track != nullptr)
|
||||
m_km.pick(*Intent.track, Intent.position);
|
||||
@@ -1099,6 +1120,7 @@ void editor_mode::draw_track_intent() const
|
||||
case kind::route_vertex:
|
||||
case kind::route_grip: drawlist->AddCircle(at, 13.0f, overlay_color::marked, 24, 2.5f); break;
|
||||
case kind::switch_at:
|
||||
case kind::switch_free:
|
||||
case kind::straight_tool:
|
||||
drawlist->AddCircleFilled(at, 4.0f, overlay_color::grip);
|
||||
drawlist->AddCircle(at, 11.0f, overlay_color::grip, 20, 2.0f);
|
||||
|
||||
Reference in New Issue
Block a user