17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 15:39:20 +02:00

feat(editor): the vehicle tool places trainsets: what is placed on a named track is written to the scenery on save as trainset <timetable> <track> <offset> <speed>, with reversed when it faces against the track, listed until the save with x to leave one out; the timetable and the starting speed are set in the panel, a tick turns writing off for a vehicle only to drive; the starter WMB10 is only added when nothing was placed; self-test command trainset

This commit is contained in:
maj00r
2026-10-12 02:00:50 +02:00
parent c9f381a9c9
commit 653d206a54
8 changed files with 153 additions and 19 deletions

View File

@@ -2937,11 +2937,24 @@ bool editor_mode::save()
auto const terrainadded{false == rootstatements.empty()};
auto const controls{turntable_controls(rootstatements)};
std::vector<std::string> trailing;
starter_trainset(trailing);
std::erase_if(m_vehicle.trainsets, [](auto const &Trainset) {
auto const *track{simulation::Paths.find(Trainset.track)};
return track == nullptr || track->m_editorremoved;
});
auto const placed{m_vehicle.trainsets.size()};
for (auto const &trainset : m_vehicle.trainsets)
trailing.insert(trailing.end(), trainset.lines.begin(), trainset.lines.end());
if (placed == 0)
starter_trainset(trailing);
auto const result = scene::Layers.save(rootstatements, trailing);
if (result.success && controls)
m_turntable_included = true;
if (result.success && trailing.size() == 3)
if (result.success && placed > 0)
{
m_vehicle.trainsets.clear();
m_vehicle.status = format(STR_C("%d trainset(s) written to the scenery"), static_cast<int>(placed));
}
if (result.success && placed == 0 && trailing.size() == 3)
{
std::istringstream header{trailing.front()};
std::string keyword;
@@ -4613,7 +4626,7 @@ void editor_mode::render_first_steps()
"T: switch. Click a straight, then press on it and drag: along sets the direction, sideways the side",
"Ctrl+Z takes a step back, Backspace while laying takes back the last piece",
"Ctrl+S saves the scenery",
"Drive it: Vehicle in the toolbar, pick a locomotive from the list, LMB on the track, then Place and drive"};
"Drive it: Trainset in the toolbar, pick a locomotive from the list, LMB on the track, then Place and drive"};
ImGui::SetNextWindowSize(ImVec2(440.0f * Global.ui_scale, 0.0f), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowPos(ImVec2(8.0f, ImGui::GetIO().DisplaySize.y - 8.0f), ImGuiCond_FirstUseEver, ImVec2(0.0f, 1.0f));
ImGui::SetNextWindowBgAlpha(1.0f);