17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-05 21:49:10 +01:00

Editor: brace ImGui clipper loops, rename scenery wizard file name field

This commit is contained in:
2026-10-10 19:55:50 +02:00
parent 21445507cc
commit 7d331ee65a
3 changed files with 59 additions and 55 deletions

View File

@@ -1529,6 +1529,7 @@ void editor_mode::render_infra_candidates()
ImGuiListClipper clipper; ImGuiListClipper clipper;
clipper.Begin(static_cast<int>(rows.size())); clipper.Begin(static_cast<int>(rows.size()));
while (clipper.Step()) while (clipper.Step())
{
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; ++row) for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; ++row)
{ {
auto const i{rows[row]}; auto const i{rows[row]};
@@ -1576,6 +1577,7 @@ void editor_mode::render_infra_candidates()
} }
ImGui::PopID(); ImGui::PopID();
} }
}
ImGui::TreePop(); ImGui::TreePop();
} }
ImGui::EndChild(); ImGui::EndChild();
@@ -1606,6 +1608,7 @@ void editor_mode::render_infra_bound()
ImGuiListClipper clipper; ImGuiListClipper clipper;
clipper.Begin(static_cast<int>(along.size())); clipper.Begin(static_cast<int>(along.size()));
while (clipper.Step()) while (clipper.Step())
{
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; ++row) for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; ++row)
{ {
auto const index{along[row]}; auto const index{along[row]};
@@ -1619,6 +1622,7 @@ void editor_mode::render_infra_bound()
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::PopID(); ImGui::PopID();
} }
}
ImGui::EndChild(); ImGui::EndChild();
if (unbind) if (unbind)
infra_unbind({*unbind}); infra_unbind({*unbind});

View File

@@ -274,8 +274,8 @@ void ui::scenerywizard_panel::render_form()
ImGui::Spacing(); ImGui::Spacing();
ImGui::SetNextItemWidth(-1.f); ImGui::SetNextItemWidth(-1.f);
ImGui::InputTextWithHint("##name", STR_C("file name, e.g. my_line"), m_name, sizeof(m_name), ImGuiInputTextFlags_CharsNoBlank); ImGui::InputTextWithHint("##name", STR_C("file name, e.g. my_line"), m_filename, sizeof(m_filename), ImGuiInputTextFlags_CharsNoBlank);
std::string name{m_name}; std::string name{m_filename};
std::transform(name.begin(), name.end(), name.begin(), [](unsigned char const Character) { return static_cast<char>(std::tolower(Character)); }); std::transform(name.begin(), name.end(), name.begin(), [](unsigned char const Character) { return static_cast<char>(std::tolower(Character)); });
auto const path{Global.asCurrentSceneryPath + name + ".scn"}; auto const path{Global.asCurrentSceneryPath + name + ".scn"};
auto const named{valid_name(name)}; auto const named{valid_name(name)};
@@ -352,7 +352,7 @@ void ui::scenerywizard_panel::render_form()
bool ui::scenerywizard_panel::create_scenery() bool ui::scenerywizard_panel::create_scenery()
{ {
std::string name{m_name}; std::string name{m_filename};
std::transform(name.begin(), name.end(), name.begin(), [](unsigned char const Character) { return static_cast<char>(std::tolower(Character)); }); std::transform(name.begin(), name.end(), name.begin(), [](unsigned char const Character) { return static_cast<char>(std::tolower(Character)); });
auto const file{name + ".scn"}; auto const file{name + ".scn"};
std::ofstream output(Global.asCurrentSceneryPath + file, std::ios::binary); std::ofstream output(Global.asCurrentSceneryPath + file, std::ios::binary);

View File

@@ -61,7 +61,7 @@ class scenerywizard_panel : public ui_panel
bool m_picked{false}; bool m_picked{false};
glm::dvec2 m_point{0.0}; glm::dvec2 m_point{0.0};
char m_name[64]{}; char m_filename[64]{};
char m_title[128]{}; char m_title[128]{};
char m_latlon[64]{}; char m_latlon[64]{};
std::string m_status; std::string m_status;