diff options
author | Aki <please@ignore.pl> | 2023-01-14 15:51:03 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-01-14 15:51:03 +0100 |
commit | 8d6a25b6c0a4df86547cef828c14d6df95c2ac94 (patch) | |
tree | 0401dc02d0794a81115993ee9da0ae0ec7637cb1 | |
parent | c583337927c3dff61d7a3cf19aa4fda96c4d0e96 (diff) | |
download | kurator-8d6a25b6c0a4df86547cef828c14d6df95c2ac94.zip kurator-8d6a25b6c0a4df86547cef828c14d6df95c2ac94.tar.gz kurator-8d6a25b6c0a4df86547cef828c14d6df95c2ac94.tar.bz2 |
Reworked GUI of group editor to be table-based
-rw-r--r-- | kurator/src/ScenarioEditor.cpp | 42 |
1 files 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 <limits> #include <memory> #include <utility> @@ -92,17 +93,36 @@ bool groups_editor(std::shared_ptr<universe::Repository> repo, std::vector<Group>& 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<float>::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()}}); |