18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 04:47:06 +01:00

Merge feat/editor-legacy-takeover into feat/editor-model-turnouts-ui

# Conflicts:
#	editor/project/projectSession.cpp
This commit is contained in:
maj00r
2026-11-24 19:15:20 +01:00
48 changed files with 747 additions and 183 deletions
+15 -1
View File
@@ -15,6 +15,9 @@ http://mozilla.org/MPL/2.0/.
#include <algorithm>
#include <fstream>
#include <iterator>
#include <set>
#include <string>
#include <vector>
namespace project
{
@@ -177,7 +180,17 @@ void session::record_written(layout::line_id const Line, std::vector<written_pie
void session::record_written(layout::line_id const Line, std::vector<written_piece> const &Pieces)
{
// the records of the line, of whatever kind and file, give way to the ones written now
// the scenery writes only the tracks changed since it was saved: the records of the other tracks the line still has stay as they
// were, or after a track moved and moved back the line would keep a record of that one track alone, and own only it when opened
std::set<std::string> current;
for (auto const &piece : generate(Line).pieces)
current.insert(piece.name);
auto const written_now = [&Pieces](std::string const &Name) { return std::ranges::any_of(Pieces, [&Name](written_piece const &Piece) { return Piece.name == Name; }); };
std::vector<generated_node> kept;
for (auto const &node : m_project.generated)
if (node.kind == "track" && node.line == Line && current.contains(node.name) && false == written_now(node.name))
kept.push_back(node);
// the other records of the line, of whatever kind and file, give way to the ones written now
std::erase_if(m_project.generated, [&](generated_node const &Node) { return Node.line == Line; });
for (auto const &piece : Pieces)
{
@@ -189,6 +202,7 @@ void session::record_written(layout::line_id const Line, std::vector<written_pie
node.sum = checksum(piece.text);
m_project.generated.push_back(std::move(node));
}
m_project.generated.insert(m_project.generated.end(), kept.begin(), kept.end());
// written again by the editor: the author decided
m_project.hand_changed.erase(Line);
}