mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-02 17:29:14 +01:00
Editor: brace ImGui clipper loops, rename scenery wizard file name field
This commit is contained in:
@@ -1529,52 +1529,54 @@ 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)
|
|
||||||
{
|
{
|
||||||
auto const i{rows[row]};
|
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; ++row)
|
||||||
auto &candidate{candidates[i]};
|
|
||||||
auto const &anchor{candidate.binding.anchors.front()};
|
|
||||||
ImGui::PushID(i);
|
|
||||||
if (candidate.bound)
|
|
||||||
ImGui::TextDisabled(STR_C("[bound]"));
|
|
||||||
else
|
|
||||||
ImGui::Checkbox("##chosen", &candidate.chosen);
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Selectable(candidate.binding.label.c_str(), false, ImGuiSelectableFlags_None, ImVec2(ImGui::CalcTextSize(candidate.binding.label.c_str()).x, 0.f)) && anchor.at.track != nullptr)
|
|
||||||
focus_track(*anchor.at.track, anchor.at.path, anchor.foot);
|
|
||||||
if (ImGui::IsItemHovered())
|
|
||||||
{
|
{
|
||||||
state.hovered = i;
|
auto const i{rows[row]};
|
||||||
std::string text{format(STR_C("%s, %s\n%.2f m %s of the axis, %.2f m above the rail top\n%s"), infra::name(candidate.binding.type), anchor.at.track != nullptr ? anchor.at.track->name().c_str() : "-", std::abs(candidate.offset),
|
auto &candidate{candidates[i]};
|
||||||
candidate.offset >= 0.0 ? "right" : "left", anchor.height, candidate.reason.c_str())};
|
auto const &anchor{candidate.binding.anchors.front()};
|
||||||
|
ImGui::PushID(i);
|
||||||
|
if (candidate.bound)
|
||||||
|
ImGui::TextDisabled(STR_C("[bound]"));
|
||||||
|
else
|
||||||
|
ImGui::Checkbox("##chosen", &candidate.chosen);
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Selectable(candidate.binding.label.c_str(), false, ImGuiSelectableFlags_None, ImVec2(ImGui::CalcTextSize(candidate.binding.label.c_str()).x, 0.f)) && anchor.at.track != nullptr)
|
||||||
|
focus_track(*anchor.at.track, anchor.at.path, anchor.foot);
|
||||||
|
if (ImGui::IsItemHovered())
|
||||||
|
{
|
||||||
|
state.hovered = i;
|
||||||
|
std::string text{format(STR_C("%s, %s\n%.2f m %s of the axis, %.2f m above the rail top\n%s"), infra::name(candidate.binding.type), anchor.at.track != nullptr ? anchor.at.track->name().c_str() : "-", std::abs(candidate.offset),
|
||||||
|
candidate.offset >= 0.0 ? "right" : "left", anchor.height, candidate.reason.c_str())};
|
||||||
|
if (candidate.reader != nullptr)
|
||||||
|
text += format(STR_C("\nRead by the path %s: event %s, getvalues of the memory cell %s"), candidate.reader->name().c_str(), candidate.event.c_str(), candidate.cell.c_str()) +
|
||||||
|
(candidate.loose ? STR(" (written loose, the path takes it by the name)") : std::string{});
|
||||||
|
if (candidate.nearer != nullptr)
|
||||||
|
text += format(STR_C("\nThe path %s is nearer, but it doesn't read the object"), candidate.nearer->name().c_str());
|
||||||
|
if (candidate.unread)
|
||||||
|
text += STR("\nNo path reads the memory cell of the signal");
|
||||||
|
text += STR("\nClick to look at it");
|
||||||
|
ImGui::SetTooltip("%s", text.c_str());
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextDisabled("%s %+.1f m", infra::name(candidate.binding.type), candidate.offset);
|
||||||
if (candidate.reader != nullptr)
|
if (candidate.reader != nullptr)
|
||||||
text += format(STR_C("\nRead by the path %s: event %s, getvalues of the memory cell %s"), candidate.reader->name().c_str(), candidate.event.c_str(), candidate.cell.c_str()) +
|
{
|
||||||
(candidate.loose ? STR(" (written loose, the path takes it by the name)") : std::string{});
|
ImGui::SameLine();
|
||||||
|
ImGui::TextColored(readcolour, STR_C("read by %s"), candidate.reader->name().c_str());
|
||||||
|
}
|
||||||
if (candidate.nearer != nullptr)
|
if (candidate.nearer != nullptr)
|
||||||
text += format(STR_C("\nThe path %s is nearer, but it doesn't read the object"), candidate.nearer->name().c_str());
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextColored(warncolour, STR_C("(nearer: %s)"), candidate.nearer->name().c_str());
|
||||||
|
}
|
||||||
if (candidate.unread)
|
if (candidate.unread)
|
||||||
text += STR("\nNo path reads the memory cell of the signal");
|
{
|
||||||
text += STR("\nClick to look at it");
|
ImGui::SameLine();
|
||||||
ImGui::SetTooltip("%s", text.c_str());
|
ImGui::TextColored(warncolour, "%s", STR_C("not read"));
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextDisabled("%s %+.1f m", infra::name(candidate.binding.type), candidate.offset);
|
|
||||||
if (candidate.reader != nullptr)
|
|
||||||
{
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextColored(readcolour, STR_C("read by %s"), candidate.reader->name().c_str());
|
|
||||||
}
|
|
||||||
if (candidate.nearer != nullptr)
|
|
||||||
{
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextColored(warncolour, STR_C("(nearer: %s)"), candidate.nearer->name().c_str());
|
|
||||||
}
|
|
||||||
if (candidate.unread)
|
|
||||||
{
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextColored(warncolour, "%s", STR_C("not read"));
|
|
||||||
}
|
|
||||||
ImGui::PopID();
|
|
||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
@@ -1606,18 +1608,20 @@ 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)
|
|
||||||
{
|
{
|
||||||
auto const index{along[row]};
|
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; ++row)
|
||||||
auto const &binding{m_bindings[index]};
|
{
|
||||||
ImGui::PushID(static_cast<int>(index));
|
auto const index{along[row]};
|
||||||
if (ImGui::SmallButton(STR_C("unbind")))
|
auto const &binding{m_bindings[index]};
|
||||||
unbind = index;
|
ImGui::PushID(static_cast<int>(index));
|
||||||
ImGui::SameLine();
|
if (ImGui::SmallButton(STR_C("unbind")))
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(binding.lost ? IM_COL32(255, 80, 70, 255) : colour(binding.group)));
|
unbind = index;
|
||||||
ImGui::Text("%s%s", binding.label.c_str(), binding.lost ? STR_C(" (no path to follow)") : "");
|
ImGui::SameLine();
|
||||||
ImGui::PopStyleColor();
|
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(binding.lost ? IM_COL32(255, 80, 70, 255) : colour(binding.group)));
|
||||||
ImGui::PopID();
|
ImGui::Text("%s%s", binding.label.c_str(), binding.lost ? STR_C(" (no path to follow)") : "");
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
if (unbind)
|
if (unbind)
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user