From 8d6a25b6c0a4df86547cef828c14d6df95c2ac94 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 14 Jan 2023 15:51:03 +0100 Subject: Reworked GUI of group editor to be table-based --- kurator/src/ScenarioEditor.cpp | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/kurator/src/ScenarioEditor.cpp b/kurator/src/ScenarioEditor.cpp index 76f384e..e05b715 100644 --- a/kurator/src/ScenarioEditor.cpp +++ b/kurator/src/ScenarioEditor.cpp @@ -1,5 +1,6 @@ #include "ScenarioEditor.h" +#include #include #include @@ -92,17 +93,36 @@ bool groups_editor(std::shared_ptr repo, std::vector& groups) { bool changed = false; - auto it = groups.begin(); - while (it != groups.end()) { - ImGui::PushID(it - groups.begin()); - const bool removed = ImGui::Button("-"); - ImGui::SameLine(); - changed |= loadout_editor(repo, it->loadout); - changed |= removed; - for (auto jt = it->counts.begin(); jt != it->counts.end(); ++jt) - changed |= ImGui::SliderInt(TextFormat("Team %d", jt - it->counts.begin() + 1), &(*jt), 0, 10); - it = removed ? groups.erase(it) : std::next(it); - ImGui::PopID(); + if (ImGui::BeginTable("Groups", 1 + 6)) { + ImGui::TableSetupColumn("Group", ImGuiTableColumnFlags_WidthFixed); + for (int n = 1; n <= 6; ++n) + ImGui::TableSetupColumn(TextFormat("Team %d", n)); + ImGui::TableHeadersRow(); + auto it = groups.begin(); + while (it != groups.end()) { + ImGui::PushID(it - groups.begin()); + ImGui::TableNextColumn(); + const bool removed = ImGui::Button("-"); + changed |= removed; + ImGui::SameLine(); + if (ImGui::Button("Edit")) + ImGui::OpenPopup("Layout Editor"); + if (ImGui::BeginPopup("Layout Editor")) { + changed |= loadout_editor(repo, it->loadout); + ImGui::EndPopup(); + } + for (auto jt = it->counts.begin(); jt != it->counts.end(); ++jt) { + ImGui::TableNextColumn(); + ImGui::PushID(jt - it->counts.begin()); + ImGui::PushItemWidth(-std::numeric_limits::min()); + changed |= ImGui::DragInt("##Count", &(*jt), 0.2f, 0, 20); + ImGui::PopItemWidth(); + ImGui::PopID(); + } + it = removed ? groups.erase(it) : std::next(it); + ImGui::PopID(); + } + ImGui::EndTable(); } if (ImGui::Button("Add Group")) { groups.push_back(Group{{repo->ship_type()}}); -- cgit v1.1