18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 09:36:48 +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
+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()