mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-02 05:49:13 +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:
@@ -6865,7 +6865,21 @@ void editor_mode::on_mouse_button(int const Button, int const Action, int const
|
||||
if (m_extend.active)
|
||||
finish_extend();
|
||||
if (m_switch.placing)
|
||||
finish_switch_placement();
|
||||
{
|
||||
// a press let go with no drag places no switch, a click on the ground with no track there selects nothing
|
||||
auto const &io{ImGui::GetIO()};
|
||||
if (glm::length(glm::vec2{io.MousePos.x, io.MousePos.y} - m_switch.pressed_at) <= 10.0f)
|
||||
{
|
||||
m_switch.placing = false;
|
||||
if (m_switch.free)
|
||||
{
|
||||
m_switch.free = false;
|
||||
track_click_select(nullptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
finish_switch_placement();
|
||||
}
|
||||
if (m_turntable.placing)
|
||||
turntable_finish_placement();
|
||||
if (m_signal.placing || m_signal.moving)
|
||||
|
||||
Reference in New Issue
Block a user