mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-19 08:29:18 +02:00
feat(editor): every switch laid in the editor gets the key frogs, a box in the Switch panel sets or clears it as one undo step; the editor rebuilds the tracks crossing a changed or removed one; self-test commands frog, crossings, frogkey and geomhash; Polish translation
This commit is contained in:
@@ -145,6 +145,7 @@ editor_track::state editor_track::capture(TTrack const &Track)
|
||||
result.material1 = Track.m_material1;
|
||||
result.material2 = Track.m_material2;
|
||||
result.material3 = Track.SwitchExtension ? Track.SwitchExtension->m_material3 : null_handle;
|
||||
result.frogs = Track.SwitchExtension && Track.SwitchExtension->m_frogs;
|
||||
result.texlength = Track.fTexLength;
|
||||
result.texheight = texture_height(Track);
|
||||
result.texwidth = Track.fTexWidth;
|
||||
@@ -234,6 +235,7 @@ void editor_track::apply(TTrack &Track, state const &State)
|
||||
{
|
||||
Track.SwitchExtension->fVelocity = State.switchvelocity;
|
||||
Track.SwitchExtension->m_material3 = State.material3;
|
||||
Track.SwitchExtension->m_frogs = State.frogs;
|
||||
}
|
||||
Track.fTrackWidth = State.width;
|
||||
Track.fTrackWidth2 = State.width;
|
||||
@@ -2404,6 +2406,7 @@ TTrack *editor_track::create_switch(switch_template const &Template, std::vector
|
||||
write_ending(text, Style);
|
||||
track = load_path(text.str(), Style, Name);
|
||||
}
|
||||
track->SwitchExtension->m_frogs = true;
|
||||
track->m_paths.assign(Paths.begin(), Paths.begin() + 2);
|
||||
return track;
|
||||
}
|
||||
@@ -2820,12 +2823,34 @@ void editor_track::retire(TTrack &Track)
|
||||
update_transition(*neighbour);
|
||||
rebuild_geometry(*neighbour);
|
||||
}
|
||||
auto crossings{Track.m_crossings};
|
||||
for (auto *crossing : Track.m_crossings)
|
||||
for (auto *neighbour : neighbours(*crossing))
|
||||
if (std::find(crossings.begin(), crossings.end(), neighbour) == crossings.end())
|
||||
crossings.push_back(neighbour);
|
||||
for (auto *crossing : crossings)
|
||||
if (crossing != &Track && false == crossing->m_editorremoved)
|
||||
rebuild_geometry(*crossing);
|
||||
if (s_observer != nullptr)
|
||||
s_observer->track_retired(Track);
|
||||
}
|
||||
|
||||
void editor_track::rebuild_geometry(TTrack &Track)
|
||||
{
|
||||
auto §ion{simulation::Region->section(Track.location())};
|
||||
Track.rebuild_geometry(section.m_geometrycreated ? section.m_geometrybank : gfx::geometrybank_handle{});
|
||||
auto const rebuild = [](TTrack &Path) {
|
||||
auto §ion{simulation::Region->section(Path.location())};
|
||||
Path.rebuild_geometry(section.m_geometrycreated ? section.m_geometrybank : gfx::geometrybank_handle{});
|
||||
};
|
||||
auto crossings{Track.m_crossings};
|
||||
rebuild(Track);
|
||||
for (auto *crossing : Track.m_crossings)
|
||||
if (std::find(crossings.begin(), crossings.end(), crossing) == crossings.end())
|
||||
crossings.push_back(crossing);
|
||||
for (std::size_t i = 0, count = crossings.size(); i < count; ++i)
|
||||
for (auto *neighbour : neighbours(*crossings[i]))
|
||||
if (std::find(crossings.begin(), crossings.end(), neighbour) == crossings.end())
|
||||
crossings.push_back(neighbour);
|
||||
for (auto *crossing : crossings)
|
||||
if (crossing != &Track && false == crossing->m_editorremoved)
|
||||
rebuild(*crossing);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user