18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 03:37:09 +01:00

feat(editor): the project of the map opened with the scenery and written with it, behind a setting of the editing on the model

The first part of E4a (editor-tracks-domain.md §3, §9, §14): the domain model of E2 and the project file of E3 brought into the
running editor, behind a setting, "Editing on the model (trial)" in the settings of the editor, off by default. Off, nothing of it
runs and the editor is as it was.

- editor/project/projectSession: the project of the map open in the editor, no scene. open() reads the project file of the map, or
  makes it of the //$ lines the first time (open_project of E3), and compares the tracks the generator wrote with the files as they
  are now: a track changed or gone outside the editor marks its line changed by hand. trial() tries a command on a copy of the network
  and tells the lines it lays anew or takes away (differences()), nothing changed; execute() carries it out, the lines of Overwrite
  no longer taken for changed by hand with it. A command kept is a step of the model's history with a token, which the editor's step of
  it takes back and brings again (undo(Token), redo(Token)): only the latest step kept, or taken back, can be, so the two histories
  can't go out of step; the marks of a change by hand go with the step. record_written() records the tracks of a line as the scenery
  save wrote them, save() writes the project with the network as it is, the records of the lines gone taken out.
- The setting on, the project of the map (the file of the scenery opened, <map>.eu07proj next to it) is opened with the scenery and
  written with it. The scenery save asks for the text of each track it writes (scene::node_layers::path_writer): a track the generator
  made, as long as nothing else changed it, is written as the generator made it (the numbers in the shortest form which reads back to
  the same double, not the 15 digits of the export), and its checksum recorded; one changed by the other tools is written by its own
  export and its line marked changed by hand. The tracks of the lines of the project are found in the scene by their names, with the
  text the file has for each (scene::node_layers::source() tells the file and the placement of a node).

Tests: U: a map opened gets its project file; a command refused, tried or carried out, changes nothing and isn't a step; a command
tried changes nothing, carried out tells its lines (new, split, a curve changed, deleted); the steps taken back and brought again by
their tokens in the order of the history, another token refused, a command after an undo dropping the step taken back, the
identifiers not given again; the tracks of two lines written and recorded, a reopen finding nothing changed and the line the same to
the bit as the model laid it, a speed edited in the file marking its line alone, deleting it writing over it too, the mark taken off by
a command writing over it and back with its undo, the records of a line deleted gone with it at the save.

Self-test: modelediting <0|1> (the setting for the run, not kept), expect modellines, expect projectfile <present|absent|lines n>.

lang/editor_pl.po: the Polish of the new texts.
This commit is contained in:
maj00r
2026-11-23 15:51:00 +01:00
parent 84dca7cccb
commit a7a641944f
14 changed files with 1006 additions and 2 deletions
+22
View File
@@ -987,6 +987,7 @@ void editor_mode::nullify_history_pointers(scene::basic_node *node)
infra_forget(node);
for (auto *tool : m_tools)
tool->forget(node);
model_forget(node);
auto const followed = [node](infra::object_state const &State) { return State.saved.node == node; };
for (auto &s : m_history)
@@ -1798,6 +1799,8 @@ bool editor_mode::update()
render_orthophoto_window();
draw_selection_overlay();
render_context_menu();
// the track geometry edited through the model: the project of the map
model_update();
steps.step("windows");
// --- ImGui: Editor Settings & History windows ---
@@ -1857,6 +1860,23 @@ void editor_mode::render_settings()
ImGui::SeparatorText(STR_C("Terrain"));
render_terrain_loading();
// the tracks laid and edited through the model of the track geometry, a trial: off, as the editor was
ImGui::SeparatorText(STR_C("Tracks"));
{
bool model{EditorSettings.model_editing()};
if (ImGui::Checkbox(STR_C("Editing on the model (trial)"), &model))
{
EditorSettings.model_editing(model);
EditorSettings.save();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("%s", STR_C("A line laid in the straights, or applied by the route design, becomes a line of the model of the track geometry: its tracks are made by the model, "
"its edits checked against the norms and refused with the reasons, the project of the map kept next to it.\n"
"The tracks there were stay as they are, edited the old way. Off, the editor works as it did"));
if (auto const error{model_error()}; model && false == error.empty())
ImGui::TextColored(ImVec4(1.0f, 0.6f, 0.2f, 1.0f), "%s", format(STR_C("The project of the map can't be opened: %s"), error.c_str()).c_str());
}
// as the history of the changes has it
ImGui::SeparatorText(STR_C("Surroundings"));
if (begin_fields("##settingsplacement", 0.45f))
@@ -3415,6 +3435,8 @@ bool editor_mode::save()
if (placed == 0)
starter_trainset(trailing);
auto const result = scene::Layers.save(rootstatements, trailing, statements);
// the project of the map after the scenery: the tracks of its lines as they were written
model_saved(result.success);
if (result.success && controls)
m_turntable_included = true;
if (result.success && noses)