18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 00:22:42 +01:00

feat(editor): the first steps in the inspector, one way to start, the line laid summed up

The first steps of the editor, after the first-run pass at 1920x1080 and 1366x768 (P1 of the plan of the
editor's interface):

- The tutorial no longer opens by itself as a window over the middle of the view (at 1366x768 over all
  of it, its close button under the tool row). With nothing selected, the inspector shows a compact
  "First steps" card: the lesson of the tool in use, its steps to try ticked as they're reached, the
  links "Show the lesson", "The camera" (the first lesson) and "Hide" (the setting first_steps, which
  the checkbox of the window now names "Show the first steps in the inspector"). Opened, the window of
  the lesson goes into the corner of the view by the inspector, below the rows of the menu and the
  tools; moved, it stays between them and the status line, as high as that room at most, the lesson
  scrolled inside. Its close button is always within reach.
- The lesson follows the tool: the select tool of Tracks opens "Laying track" until its steps are done,
  so a new scenery opened in Tracks starts there, not with the camera, which stays the first page and a
  link of the card.
- An empty scenery in Tracks with nothing selected: "The scenery has no tracks yet" and one highlighted
  button, "Lay the first track (L)"; the tutorial is the card under it, a "Tutorial" link when the card
  is hidden. With tracks, the select tool keeps its hints and a plain "Lay a track (L)".
- "Without terrain", the answer to the question of the terrain at the first L, turns off the terrain
  made of the terrain model by itself: under the tracks as they're laid (the checkbox of the layers) and
  around the camera within the download area (the checkbox of the terrain panel), stops putting the
  squares of the area into the cache, a square on its way giving way at once, and drops the squares
  waiting. Kept on, the model went on being asked for, and offline the log filled with "NMT square ...
  not fetched: WinHTTP error"; now nothing is asked for after the answer.
  "Load the terrain" turns both on again. The squares of the area go to the cache, and the aerial photos
  ask for the model to lie on, only while some terrain is made of the model by itself. The question
  stands in the middle of the view, the window of the lesson waiting meanwhile. The warning of no ground
  under the mouse shows only while the pointer is over the view and the terrain is to be there.
- The tooltip of the line being laid names the panel the rest of its warnings are in ("listed in the
  tool options"): the translation of the text before said "in the panel on the right", the panel is on
  the left.
- While the pointer is over a panel, the line being laid stays as it was: the point of the cursor, the
  free end it snaps to and its height aren't taken from where the pointer is under the panel, which
  added a leg there with curves and warnings of its own. A drag begun in the view goes on over a panel.
- After Enter the inspector sums up the line laid: its tracks, length and curves, those below the norms
  in orange, and what comes next, "A switch (T)" and "Save (Ctrl+S)". It stays while the last track is
  the selection the laying left; a click on a track shows the sheet of that track. The switch tool with
  nothing clicked shows the same, not the sheet of the last track laid.
- A switch the switch tool refuses is told in its panel and by the cursor, no longer in the status line
  and the layers window as well, where it stayed after the next switch was laid. Why a branch couldn't
  lead into a free end goes into the panel with the rest; a switch laid takes the note by the cursor
  away.
- The panel of the lay tool fits one screen at 1366x768: what the tool is for is the tooltip of the
  title of its card, the paragraph of the radius at the bends the tooltip of its "?" (which still opens
  the lesson), "This speed also on from a track with a speed of its own" is under More settings; the
  mode, the speed and the height stay up front.
- The layout made on the first start: the side columns 22% of the width, at least 300 px, at most the
  400 and 460 px they had and 30%; at 1366 px the view has about 766 px instead of 557. The tool options
  take 60% of the left column, and in a window under 800 px high the layers are a tab beside them, the
  tool options shown, so the panel of a tool has the whole column. The line of the keys of the
  surroundings goes on under itself at the edge of the panel. Layouts kept in imgui.ini are left as they
  are.
- The names of the period of the day, the season and the weather in Weather and time, and the type of a
  node in the inspector of the surroundings, go through the translations ("(day)", "(autumn)",
  "(scattered)", "Typ: track" before). The degree sign of the air temperature is written as its UTF-8
  bytes: CMakeLists.txt sets COMPILE_OPTIONS of eu07 and eu07_core after add_compile_options("/utf-8"),
  which drops /utf-8, so MSVC writes the "°" of a literal as the single byte 0xB0 of the ANSI code page,
  not UTF-8, and ImGui drew '?'.
- Self-tests: the expectations statuslacks, refusal, statusline, laycursor and terrain, the command
  nmtquestion, and the cases fs_1_preview_over_panel, fs_2_switch_refusal_cleared and
  fs_3_without_terrain.

lang/editor_pl.po: the Polish of the new texts (the card of the first steps, the summary of the line laid,
"Lay the first track", the names of the periods, seasons and weathers and of the node types), the entries
of the texts replaced given their new English ("Show the first steps in the inspector", "and %zu more,
listed in the tool options", "Lay the first track  (L)" in place of "Or start with:"), and "(do
transmisji)" in place of the English "(stream)" of the drawn cursor.
This commit is contained in:
maj00r
2026-11-23 12:08:36 +01:00
parent a1f1ba4262
commit cd20d8ec94
19 changed files with 810 additions and 90 deletions
+96 -2
View File
@@ -10,7 +10,9 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "application/editormode.h"
#include "application/editormodeselftest.h"
#include "application/editoruilayer.h"
#include "editor/editorFormat.hpp"
#include "editor/editorSettings.hpp"
#include "editor/editorIncludeInfo.hpp"
#include "editor/editorSwitchStore.hpp"
#include "scene/scenelayers.h"
@@ -345,6 +347,95 @@ void expect_status(std::string const &What, std::istringstream &Words, std::stri
expectation(Status.find(wanted) != std::string::npos, What, "\"" + Status + "\"", "a status holding \"" + wanted + "\"");
}
// expect statuslacks <text>: the status of the switch tool doesn't hold the text, the rest of the line
void expect_status_lacks(std::string const &What, std::istringstream &Words, std::string const &Status)
{
std::string unwanted;
std::getline(Words >> std::ws, unwanted);
if (unwanted.empty())
{
expectation(false, What, "malformed", "the text the status lacks");
return;
}
expectation(Status.find(unwanted) == std::string::npos, What, "\"" + Status + "\"", "a status without \"" + unwanted + "\"");
}
// expect refusal <holds|lacks> <text>, expect statusline <holds|lacks> <text>: what the cursor tells while it's shown, or the status
// line of the editor, holds the text, the rest of the line, or doesn't
void expect_told(std::string const &What, std::istringstream &Words, std::string const &Told)
{
std::string state;
std::string text;
Words >> state;
std::getline(Words >> std::ws, text);
if ((state != "holds" && state != "lacks") || text.empty())
{
expectation(false, What, "malformed", "holds or lacks and the text");
return;
}
auto const holds{Told.find(text) != std::string::npos};
expectation(holds == (state == "holds"), What, "\"" + Told + "\"", (state == "holds" ? "a text holding \"" : "a text without \"") + text + "\"");
}
// expect laycursor <x> <z> <tolerance>: the point the line of the lay tool goes to from its last point clicked, in the plan
void expect_lay_cursor(std::string const &What, std::istringstream &Words, glm::dvec3 const &Mouse)
{
double x{0.0};
double z{0.0};
double tolerance{0.0};
Words >> x >> z >> tolerance;
if (malformed(What, Words))
return;
auto const distance{glm::length(glm::dvec2{Mouse.x - x, Mouse.z - z})};
expectation(distance <= tolerance, What, format("%.3f %.3f", Mouse.x, Mouse.z), format("%.3f %.3f within %.3f", x, z, tolerance));
}
// expect terrain <grow|area|prompt> <0|1>: the terrain model made under the tracks as they're laid, or around the camera within the
// download area, the question of the terrain of a new scenery open
void expect_terrain(std::string const &What, std::istringstream &Words, std::map<std::string, bool> const &States)
{
std::string key;
int wanted{0};
Words >> key >> wanted;
if (malformed(What, Words))
return;
auto const state{States.find(key)};
if (state == States.end())
{
expectation(false, What, "no state " + key, "grow, area or prompt");
return;
}
expectation(state->second == (wanted != 0), What, state->second ? "1" : "0", std::to_string(wanted));
}
// what the editor shows, for the expectations of what the user sees
struct shown_state
{
std::string status; // of the switch tool
std::string refusal; // by the cursor, while it's shown
std::string status_line;
glm::dvec3 lay_cursor{0.0};
std::map<std::string, bool> terrain; // grow, area, prompt
};
// the expectations of what the editor shows; false: no expectation of the kind
bool expect_shown(std::string const &Kind, std::string const &What, std::istringstream &Words, shown_state const &Shown)
{
if (Kind == "statuslacks")
expect_status_lacks(What, Words, Shown.status);
else if (Kind == "refusal")
expect_told(What, Words, Shown.refusal);
else if (Kind == "statusline")
expect_told(What, Words, Shown.status_line);
else if (Kind == "laycursor")
expect_lay_cursor(What, Words, Shown.lay_cursor);
else if (Kind == "terrain")
expect_terrain(What, Words, Shown.terrain);
else
return false;
return true;
}
// expect steps <count>: the steps Ctrl+Z takes back, the ones made together counted once
void expect_steps(std::string const &What, std::istringstream &Words, std::size_t const Steps)
{
@@ -403,7 +494,10 @@ editor_mode::selftest_result editor_mode::selftest_expect(std::string const &com
expect_findings(what, words, m_norms.results());
else if (kind == "steps")
expect_steps(what, words, static_cast<std::size_t>(std::ranges::count_if(m_history, [](EditorSnapshot const &Step) { return false == Step.joined; })));
else
expectation(false, what, "no expectation " + kind, "cant, joint, records, speed, gauge, track, route, norms, findings, height, lift, includes, status or steps");
else if (false == expect_shown(kind, what, words,
{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}}}))
expectation(false, what, "no expectation " + kind,
"cant, joint, records, speed, gauge, track, route, norms, findings, height, lift, includes, status, statuslacks, refusal, statusline, laycursor, terrain or steps");
return selftest_result::handled;
}