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

fix(editor): the assumptions go into the project of the model, and back into the scenery only while it isn't saved

The earlier fix kept the //$u line in the scenery whenever the editing is on the model, so ps_2_setup_project found the
assumptions in the scenery where the project should hold them alone. They are taken out of the scenery again as before; when
the scenery or the project of the model then fails to be saved, they go back into the scenery with its next save and stay
there until the project is saved.
This commit is contained in:
maj00r
2026-11-24 20:11:50 +01:00
parent 98e66d6228
commit 5363f65fc8
3 changed files with 38 additions and 8 deletions
+5
View File
@@ -326,6 +326,8 @@ class editor_mode : public application_mode, private editor_track::observer, pri
bool m_setup_read{false}; // read for the scenery open
bool m_setup_changed{false}; // to be written with the scenery
bool m_setup_marked{false}; // the scenery holds //$u lines
bool m_setup_moving{false}; // the assumptions given to the project of the model, which isn't saved yet
bool m_setup_unsaved{false}; // the project of the model failed to be saved with them: the scenery keeps them till it is
bool m_setup_window{false};
std::string m_setup_told; // what the change of them found among the lines laid before
bool m_setup_checking{false}; // the lines of the scenery being checked against the assumptions changed
@@ -339,6 +341,9 @@ class editor_mode : public application_mode, private editor_track::observer, pri
// the norms checked against, the rail and the usual switch of the switch tool
void setup_defaults(project_setup::setup const &Setup);
void setup_store();
void setup_keep_in_scenery();
// the project of the model saved, or not, after the scenery: where the assumptions are kept
void setup_project_saved(bool const Saved);
bool render_setup_card();
void render_setup_window();
void render_setup_line();
+3
View File
@@ -708,6 +708,7 @@ void editor_mode::model_saved(bool const Success)
if (false == Success)
{
model().written.clear();
setup_project_saved(false);
return;
}
// the tracks written, by their lines, each with the file it went into
@@ -733,8 +734,10 @@ void editor_mode::model_saved(bool const Success)
{
ui()->set_status(format(STR_C("The project of the map isn't saved: %s"), error.c_str()), true);
WriteLog("Editor: the project of the map isn't saved: " + error, logtype::generic);
setup_project_saved(false);
return;
}
setup_project_saved(true);
WriteLog(format("Editor: the project of the map saved, %zu lines, %zu tracks of them written now", model().session.network().lines().size(), [&] {
std::size_t count{0};
for (auto const &entry : lines)
+30 -8
View File
@@ -154,15 +154,15 @@ void editor_mode::setup_store()
scene::Layers.mark(scene::layer_handle{1}, "//$u", {});
m_setup_marked = false;
};
auto const kept_in_scenery = [this, &line]() {
scene::Layers.mark(scene::layer_handle{1}, "//$u", {"# the assumptions of the project: what the editor lays the tracks to", line});
m_setup_marked = true;
};
if (model_setup())
{
// the project of the model is written after the scenery, and may fail to be: the scenery keeps the line as well, the project's
// one read first. Taken out of it, the assumptions were gone with a project not saved
kept_in_scenery();
// the project of the model is written after the scenery, and may fail to be: model_saved() puts them back into the scenery then,
// and they stay there till the project is saved
m_setup_moving = true;
if (m_setup_unsaved)
setup_keep_in_scenery();
else
moved_out();
return;
}
std::error_code error;
@@ -182,7 +182,29 @@ void editor_mode::setup_store()
WriteLog("Editor: the assumptions of the project not written into its file: " + why, logtype::generic);
}
}
kept_in_scenery();
setup_keep_in_scenery();
}
void editor_mode::setup_keep_in_scenery()
{
if (false == m_setup.has_value())
return;
scene::Layers.mark(scene::layer_handle{1}, "//$u", {"# the assumptions of the project: what the editor lays the tracks to", project_setup::record(*m_setup)});
m_setup_marked = true;
}
void editor_mode::setup_project_saved(bool const Saved)
{
if (false == m_setup_moving)
return;
m_setup_moving = false;
m_setup_unsaved = false == Saved;
// not saved: the assumptions go back into the scenery, written with its next save, rather than be in neither of them; saved while the
// scenery holds them still: taken out of it with the next save
if (false == Saved)
setup_keep_in_scenery();
if (false == Saved || m_setup_marked)
m_setup_changed = true;
}
bool editor_mode::render_setup_card()