mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 18:47:06 +01:00
Merge branch 'ui/editor-lay-flow' into feat/editor-turnout-catalogue
This commit is contained in:
@@ -138,6 +138,8 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c
|
||||
// angles at the joints, loops, the turning wasted and the sharpest curve logged; case: that one alone
|
||||
// layspeed <km/h> <own 0|1> the speed set for the laying, and whether it goes also on from a track with its own
|
||||
// laymode <straights|curve>, laytrace <radii 0..3> <straights between 0|1> as the panel of the laying sets them
|
||||
// laysettings <0|1> the settings of the lay tool opened under the line of their summary, or folded into it, as a
|
||||
// click on that line does while the points are clicked
|
||||
// endcurves logs every free end of the rails: where, the way out and the curvature its track goes on with
|
||||
// curvejoint <x> <z> logs the paths meeting at the end nearest the point, the curvature of each and its jump from the ones before to the ones after
|
||||
// cantcheck <label> logs each jump of the cant at a joint of plain tracks, and the steepest ramp of the cant on a path
|
||||
|
||||
@@ -485,6 +485,15 @@ editor_mode::selftest_result editor_mode::selftest_join(std::string const &comma
|
||||
WriteLog("SELFTEST laymode: " + std::string{m_lay.mode == lay_mode::curve ? "curve" : "straights"});
|
||||
return selftest_result::handled;
|
||||
}
|
||||
if (command == "laysettings")
|
||||
{
|
||||
// as a click on the line of their summary while the points are clicked: the settings shown under it, or folded into it again
|
||||
int open{0};
|
||||
words >> open;
|
||||
m_lay.settings_open = open != 0;
|
||||
WriteLog(format("SELFTEST laysettings %d", open));
|
||||
return selftest_result::handled;
|
||||
}
|
||||
if (command == "laytrace")
|
||||
{
|
||||
int straights{1};
|
||||
|
||||
@@ -148,8 +148,8 @@ editor_mode::selftest_result editor_mode::selftest_terrain(std::string const &co
|
||||
}
|
||||
if (command == "nmtsettings")
|
||||
{
|
||||
// as the terrain panel changes them, kept with the editor the next frame (keep_nmt_settings); the terrain while laying at
|
||||
// once, as its chip keeps it
|
||||
// as the terrain panel changes them, kept with the editor the next frame (keep_nmt_settings); the terrain while laying and
|
||||
// the area for the run only, the settings of the tester's own editor left as they are
|
||||
auto &state{m_nmt_state};
|
||||
std::string key;
|
||||
double value{0.0};
|
||||
@@ -170,11 +170,7 @@ editor_mode::selftest_result editor_mode::selftest_terrain(std::string const &co
|
||||
else if (key == "fitted")
|
||||
state.fitted = value != 0.0;
|
||||
else if (key == "grow")
|
||||
{
|
||||
state.grow = value != 0.0;
|
||||
EditorSettings.terrain_while_laying(state.grow);
|
||||
EditorSettings.save();
|
||||
}
|
||||
state.grow = value != 0.0; // for the run only, as area: the setting isn't touched, so the tester's own file stays as it was
|
||||
else if (key == "area")
|
||||
m_area_terrain.run_only = value != 0.0; // for the run only: the setting isn't touched, so no save keeps it
|
||||
}
|
||||
|
||||
@@ -209,13 +209,16 @@ class record
|
||||
fail(std::format("'{}' isn't a profile of the norms", text));
|
||||
return norms::profile_id::plk;
|
||||
}
|
||||
// the rest of the line as it is written, the blanks between the words kept as one
|
||||
// the rest of the line as it is written, from its next word to its last, the blanks between the words as they are: joined with one
|
||||
// blank, a reason of two blanks came back changed after a save and a load
|
||||
std::string rest()
|
||||
{
|
||||
std::string result;
|
||||
for (; false == done(); ++m_at)
|
||||
result += (result.empty() ? "" : " ") + std::string{m_words[m_at]};
|
||||
return result;
|
||||
if (done())
|
||||
return {};
|
||||
auto const first{m_words[m_at]};
|
||||
auto const last{m_words.back()};
|
||||
m_at = m_words.size();
|
||||
return std::string(first.data(), static_cast<std::size_t>(last.data() + last.size() - first.data()));
|
||||
}
|
||||
void finish()
|
||||
{
|
||||
@@ -458,6 +461,15 @@ read_result read(std::string_view const Text)
|
||||
continue;
|
||||
}
|
||||
record words{text};
|
||||
// the section kept for the anchors is written back as it was read, its blank lines and its comments too
|
||||
if (in == section::anchors)
|
||||
{
|
||||
if (words.peek() == "end" && words_of(text).size() == 1)
|
||||
in = section::top;
|
||||
else
|
||||
project.anchors.emplace_back(text);
|
||||
continue;
|
||||
}
|
||||
if (words.empty() || words.peek().front() == '#')
|
||||
continue;
|
||||
if (false == versioned)
|
||||
@@ -481,14 +493,6 @@ read_result read(std::string_view const Text)
|
||||
continue;
|
||||
}
|
||||
auto const keyword{words.peek()};
|
||||
if (in == section::anchors)
|
||||
{
|
||||
if (keyword == "end" && words_of(text).size() == 1)
|
||||
in = section::top;
|
||||
else
|
||||
project.anchors.emplace_back(text);
|
||||
continue;
|
||||
}
|
||||
words.next("");
|
||||
if (in == section::turnouts)
|
||||
{
|
||||
|
||||
@@ -217,7 +217,15 @@ class reader
|
||||
m_output.files.push_back(std::move(file));
|
||||
return;
|
||||
}
|
||||
// a file including itself, on its own or through others, would never end
|
||||
// a file including itself, on its own or through others, would never end: not read again while it's being read
|
||||
if (auto const reading{std::ranges::find_if(m_frames, [this, &file](frame const &Frame) { return same_file(m_output.files[Frame.file].name, file.name); })};
|
||||
reading != m_frames.end())
|
||||
{
|
||||
file.missing = true;
|
||||
m_output.problems.push_back(file.name + " includes itself, included from " + m_output.files[Parent].name + " line " + std::to_string(Line));
|
||||
m_output.files.push_back(std::move(file));
|
||||
return;
|
||||
}
|
||||
if (m_frames.size() >= kDepth)
|
||||
{
|
||||
file.missing = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Laying flow: the panel of the lay tool goes through its states, each with its step at its top. Nothing clicked: its settings shown.
|
||||
# Points clicked: the settings folded to the line of their summary. The line laid with Enter: told in one line over the settings
|
||||
# Points clicked: the settings folded to the line of their summary, opened by a click on it and folded again. The line laid with Enter: told in one line over the settings
|
||||
# shown again. Taken back with Ctrl+Z: ready, the line laid no more told. The same in the mode of a curve traced. The points go on
|
||||
# the empty ground between the turntable tt1 and the curves (x 220..270), the camera straight above them
|
||||
wait 5
|
||||
@@ -16,6 +16,12 @@ expect laypanel clicking folded
|
||||
layp 235 165 250 185
|
||||
wait 2
|
||||
expect laypanel clicking folded
|
||||
laysettings 1
|
||||
wait 2
|
||||
expect laypanel clicking shown
|
||||
laysettings 0
|
||||
wait 2
|
||||
expect laypanel clicking folded
|
||||
layenter
|
||||
wait 2
|
||||
expect laypanel laid shown
|
||||
|
||||
@@ -145,6 +145,13 @@ TEST_CASE("project file: the golden file read and written back comes out the sam
|
||||
CHECK(project.anchors.empty());
|
||||
REQUIRE(project.legacy.size() == 3);
|
||||
CHECK(project.legacy[1].why == "a compound curve");
|
||||
// the reason as it was written, its blanks kept, read and written back the same
|
||||
auto spaced{golden};
|
||||
spaced.replace(spaced.find("why a compound curve"), 20, "why a compound curve");
|
||||
auto const reason{project::read(spaced)};
|
||||
REQUIRE_MESSAGE(reason.project.has_value(), notes_of(reason));
|
||||
CHECK(reason.project->legacy[1].why == "a compound curve");
|
||||
CHECK(project::write(*reason.project) == spaced);
|
||||
CHECK(project.legacy[1].lines == std::vector<std::string>{"alignment 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000", "", "end"});
|
||||
CHECK(project.legacy[2].mark == 'r');
|
||||
// the line ends of windows read the same
|
||||
@@ -224,6 +231,13 @@ TEST_CASE("project file: the section kept for the anchors is written back as it
|
||||
REQUIRE_MESSAGE(read.project.has_value(), notes_of(read));
|
||||
CHECK(read.project->anchors == std::vector<std::string>{"anchor 1 line 1 chainage 120.5 offset -3.2"});
|
||||
CHECK(project::write(*read.project) == text);
|
||||
// its blank lines and its comments kept too, as the rest of the section
|
||||
auto commented{text};
|
||||
commented.replace(commented.find("anchors\n"), 8, "anchors\n\n# by hand\n \n");
|
||||
auto const kept{project::read(commented)};
|
||||
REQUIRE_MESSAGE(kept.project.has_value(), notes_of(kept));
|
||||
CHECK(kept.project->anchors == std::vector<std::string>{"", "# by hand", " ", "anchor 1 line 1 chainage 120.5 offset -3.2"});
|
||||
CHECK(project::write(*kept.project) == commented);
|
||||
// a record the turnouts haven't
|
||||
auto turnouts{text};
|
||||
turnouts.replace(turnouts.find("turnouts\nend\n"), 13, "turnouts\nturnout 1 type Rz%2060E1-500-1:12 at 0 0 0\nend\n");
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "doctest.h"
|
||||
#include "editor/project/scenarioIndex.hpp"
|
||||
#include "editor/project/sceneryText.hpp"
|
||||
#include "scratch.h"
|
||||
|
||||
#include <format>
|
||||
#include <string>
|
||||
@@ -114,6 +115,18 @@ TEST_CASE("scenario index: the scenery read as the simulator reads it, the inclu
|
||||
CHECK_FALSE(missing.uses_map());
|
||||
}
|
||||
|
||||
TEST_CASE("scenario index: a file including itself, on its own or through another one, is told and not read again") {
|
||||
test::scratch_folder const folder{"scenery_text_cycle"};
|
||||
folder.write("petla.scn", "node -1 0 a memcell 0 0 0 endmemcell\ninclude petla/druga.scm end\n");
|
||||
folder.write("petla/druga.scm", "node -1 0 b memcell 0 0 0 endmemcell\ninclude PETLA.scn end\n");
|
||||
auto const scenery{scenery_text::read(folder.root(), "petla.scn")};
|
||||
REQUIRE(scenery.problems.size() == 1);
|
||||
CHECK(scenery.problems.front() == "PETLA.scn includes itself, included from petla/druga.scm line 2");
|
||||
REQUIRE(scenery.files.size() == 3);
|
||||
CHECK(scenery.files[2].missing);
|
||||
CHECK(std::ranges::count(scenery.statements, std::string{"node"}, &scenery_text::statement::keyword) == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("scenario index: the words of the text as the parser splits them") {
|
||||
auto const tokens{scenery_text::split("node -1 0 a;track // a comment\n\"two words\" /* a\ncomment */ endtrack//glued\nx")};
|
||||
REQUIRE(tokens.size() == 8);
|
||||
|
||||
Reference in New Issue
Block a user