diff options
author | Aki <please@ignore.pl> | 2023-01-11 00:30:25 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-01-11 00:30:25 +0100 |
commit | 586adb53ecbbf4eff924fd145cd0f5a72797e021 (patch) | |
tree | 09f7bf743cc9bc6eb5ad6087570d41f98ebfec86 | |
parent | 0e91fc6a8e14eebb5a89b260f66e5e74b42074bb (diff) | |
download | kurator-586adb53ecbbf4eff924fd145cd0f5a72797e021.zip kurator-586adb53ecbbf4eff924fd145cd0f5a72797e021.tar.gz kurator-586adb53ecbbf4eff924fd145cd0f5a72797e021.tar.bz2 |
Created a naive loadout editor interface
-rw-r--r-- | kurator/src/ScenarioEditor.cpp | 39 | ||||
-rw-r--r-- | kurator/src/ScenarioEditor.h | 12 |
2 files changed, 51 insertions, 0 deletions
diff --git a/kurator/src/ScenarioEditor.cpp b/kurator/src/ScenarioEditor.cpp index 45e594f..29e275e 100644 --- a/kurator/src/ScenarioEditor.cpp +++ b/kurator/src/ScenarioEditor.cpp @@ -8,6 +8,7 @@ #include <kurator/campaign/Scenario.h> #include <kurator/campaign/scenarios.h> +#include <kurator/universe.h> #include "Battle.h" #include "Session.h" @@ -26,6 +27,8 @@ ScenarioEditor::ScenarioEditor(std::shared_ptr<Session> _session) : distance {12000} { regenerate(); + loadout_editor.repo = universe::load_json("resources/universe"); + loadout_editor.loadout.type = loadout_editor.repo->ship_type("Anvil"); // access to default or first? } @@ -33,6 +36,7 @@ void ScenarioEditor::update(float) { frame.update(); + loadout_editor.show(); if (ImGui::Begin("Scenario Editor")) { bool update = false; update |= ImGui::SliderInt("Teams", &teams, 2, 6); @@ -79,4 +83,39 @@ ScenarioEditor::regenerate() } +void +LoadoutEditor::show() +{ + ImGui::PushID(this); + if (ImGui::Begin("Loadout Editor")) { + if (ImGui::BeginCombo("Ship Type", loadout.type.name.c_str())) { + repo->for_ship_types([&](const auto& type){ + if (ImGui::Selectable(type.name.c_str(), loadout.type.name == type.name)) + loadout.type = type; + }); + ImGui::EndCombo(); + } + auto it = loadout.turrets.begin(); + while (it != loadout.turrets.end()) { + ImGui::PushID(it - loadout.turrets.begin()); + const bool removed = ImGui::Button("-"); + ImGui::SameLine(); + if (ImGui::BeginCombo("Turret Type", it->name.c_str())) { + repo->for_turret_types([&](const auto& type){ + if (ImGui::Selectable(type.name.c_str(), it->name == type.name)) + *it = type; + }); + ImGui::EndCombo(); + } + it = removed ? loadout.turrets.erase(it) : std::next(it); + ImGui::PopID(); + } + if (ImGui::Button("Add Turret")) + loadout.turrets.push_back(repo->turret_type("ChargeLaser")); // access to default or first? + } + ImGui::End(); + ImGui::PopID(); +} + + } // namespace kurator
\ No newline at end of file diff --git a/kurator/src/ScenarioEditor.h b/kurator/src/ScenarioEditor.h index cec4783..d8a7a72 100644 --- a/kurator/src/ScenarioEditor.h +++ b/kurator/src/ScenarioEditor.h @@ -2,6 +2,9 @@ #include <memory> +#include <kurator/campaign/Loadout.h> +#include <kurator/universe/Repository.h> + #include "Scene.h" #include "SceneFrame.h" #include "Session.h" @@ -11,6 +14,14 @@ namespace kurator { +struct LoadoutEditor +{ + std::shared_ptr<universe::Repository> repo; + campaign::Loadout loadout; + void show(); +}; + + class ScenarioEditor : public Scene { public: @@ -28,6 +39,7 @@ private: float distance; std::shared_ptr<Scene> battle; SceneFrame frame; + LoadoutEditor loadout_editor; }; |