summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kurator/src/ScenarioEditor.cpp42
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()}});