mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 21:15:20 +01:00
feat(editor): the switch tool a step at a time, the template chosen as a line
The panel of the switch tool goes by states as the lay tool's does, each with its step at the top (editor-lay-flow.md, second part): - Ready: "Press on a straight and drag along it and to the side" (a slip, a crossing and a connection with steps of their own). What to place as one bar, [Switch | Slip | Crossing], in place of the tiles in two rows. The rail of the track, or the rails [60E1 49E1 S42] where it doesn't tell its rail, and the speed on the diverging track as chips beside "Diverging speed (km/h)"; the template they pick as one line, "Rz 60E1-300-1:9, 50 km/h", its tooltip the lengths and the rest of its label, a pencil at its end opening the list of the templates and All templates under it. The gestures of placing are in the card and in the bar under the view, no longer rows in the panel; the template editor among More settings. - Dragging: "Let go to insert" and one line, "27.1 m, left, 40 km/h"; what keeps the switch from being laid (the rules a switch bent into a curve or laid on from a free end breaks) in one line in red, the switch moved back onto its straight or into its curve and the branch that doesn't fit into a track in orange. - Placed: "Switch z1 inserted, Ctrl+Z undoes" while the switch is the one the last step of the history laid, else "Switch z1: drag it along its track to move it". The sketch, its length and side in its tooltip; the speed chips and the template as the line with the pencil, as when placing; Flip the side. A switch with no drive says so with what puts one there; the name, the record, the angle, the drive, the frog and the check rails, the slide along its track and the note of the inspector are under Details, folded. What the tool told of it besides the step under it all. - Refused: the reason in red right under the step, the rest of a long one in its tooltip. The drive of the switch is drawn by a function of its own (render_switch_drive), no longer a lambda of the panel. The status of the switch tool is told in red while it's the refusal last told (m_switch.refusal), the expectations of the self-tests read it as before. The bar under the view keeps the gestures of the view first, "List in the panel" after them. Self-test: expect switchpanel <ready|dragging|placed|selected>, and the case lf_2_switch_panel_states: ready after a switch refused, placed after one laid, selected after another one laid since. lang/editor_pl.po: the Polish of the new texts.
This commit is contained in:
@@ -466,8 +466,8 @@ void expect_selected(std::string const &What, std::istringstream &Words, std::op
|
||||
expectation(glm::distance(*Selected, wanted) <= tolerance, What, format("%.3f %.3f %.3f", Selected->x, Selected->y, Selected->z), format("%.3f %.3f %.3f within %.3f", wanted.x, wanted.y, wanted.z, tolerance));
|
||||
}
|
||||
|
||||
// expect laypanel <state> <shown|folded>: the state the panel of the lay tool is in, as the step at its top tells it, and whether its
|
||||
// settings are shown or folded to the line of their summary
|
||||
// expect laypanel <state> <shown|folded>, expect switchpanel <state>: the state the panel of the tool is in, as the step at its top
|
||||
// tells it, and whether the settings of the lay tool are shown or folded to the line of their summary
|
||||
void expect_panel(std::string const &What, std::istringstream &Words, std::string const &Got)
|
||||
{
|
||||
std::string wanted;
|
||||
@@ -493,6 +493,7 @@ struct shown_state
|
||||
std::map<std::string, bool> windows; // shortcuts, settings, weather, orthophoto
|
||||
std::optional<glm::dvec3> selected; // where the node selected stands
|
||||
std::string lay_panel; // the state of the panel of the lay tool and whether its settings are shown
|
||||
std::string switch_panel; // the state of the panel of the switch tool
|
||||
};
|
||||
|
||||
// the expectations of what the editor shows; false: no expectation of the kind
|
||||
@@ -516,6 +517,8 @@ bool expect_shown(std::string const &Kind, std::string const &What, std::istring
|
||||
expect_selected(What, Words, Shown.selected);
|
||||
else if (Kind == "laypanel")
|
||||
expect_panel(What, Words, Shown.lay_panel);
|
||||
else if (Kind == "switchpanel")
|
||||
expect_panel(What, Words, Shown.switch_panel);
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
@@ -584,13 +587,13 @@ editor_mode::selftest_result editor_mode::selftest_expect(std::string const &com
|
||||
shown_state shown{m_switch.status, ui()->refusal_shown(), ui()->status_line(), m_lay.mouse,
|
||||
{{"grow", m_nmt_state.grow}, {"area", EditorSettings.terrain_model().area}, {"prompt", m_nmt_state.prompt}}, tool_name(ui()->mode()),
|
||||
{{"shortcuts", m_shortcuts_open}, {"settings", m_settings_open}, {"weather", m_environment_open}, {"orthophoto", m_orthophoto_window}}, std::nullopt,
|
||||
shown_lay_panel()};
|
||||
shown_lay_panel(), shown_switch_panel()};
|
||||
if (m_node != nullptr)
|
||||
shown.selected = m_node->location();
|
||||
if (false == expect_shown(kind, what, words, shown))
|
||||
expectation(false, what, "no expectation " + kind,
|
||||
"cant, joint, records, speed, gauge, track, route, norms, findings, height, lift, includes, status, statuslacks, refusal, statusline, laycursor, terrain, tool, window, "
|
||||
"selected, laypanel or steps");
|
||||
"selected, laypanel, switchpanel or steps");
|
||||
}
|
||||
return selftest_result::handled;
|
||||
}
|
||||
@@ -603,3 +606,13 @@ std::string editor_mode::shown_lay_panel() const
|
||||
auto const shown{panel == lay_state::ready || panel == lay_state::laid || m_lay.settings_open};
|
||||
return std::string{states[static_cast<int>(panel)]} + (shown ? " shown" : " folded");
|
||||
}
|
||||
|
||||
std::string editor_mode::shown_switch_panel() const
|
||||
{
|
||||
if (m_switch.placing)
|
||||
return "dragging";
|
||||
auto const *track{selected_track()};
|
||||
if (track == nullptr || track->eType != tt_Switch)
|
||||
return "ready";
|
||||
return just_laid(track) ? "placed" : "selected";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user