summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kurator/src/ScenarioEditor.cpp47
1 files changed, 28 insertions, 19 deletions
diff --git a/kurator/src/ScenarioEditor.cpp b/kurator/src/ScenarioEditor.cpp
index 2df55c9..b657230 100644
--- a/kurator/src/ScenarioEditor.cpp
+++ b/kurator/src/ScenarioEditor.cpp
@@ -21,6 +21,7 @@ namespace kurator
bool groups_editor(std::shared_ptr<universe::Repository> repo, std::vector<Group>& groups);
bool loadout_editor(std::shared_ptr<universe::Repository> repo, campaign::Loadout& loadout);
+bool ship_type_combo(const char* id, std::shared_ptr<universe::Repository> repo, universe::ShipType& type);
ScenarioEditor::ScenarioEditor(std::shared_ptr<Session> _session) :
@@ -135,24 +136,7 @@ groups_editor(std::shared_ptr<universe::Repository> repo, std::vector<Group>& gr
bool
loadout_editor(std::shared_ptr<universe::Repository> repo, campaign::Loadout& loadout)
{
- bool changed = false;
- 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;
- changed = true;
- }
- if (ImGui::IsItemHovered()) {
- ImGui::BeginTooltip();
- ImGui::Text("Shield: %.0f", type.base_shield_points);
- ImGui::Text("Armour: %.0f", type.base_armour_points);
- ImGui::Text("Structure: %.0f", type.base_structure_points);
- ImGui::Text("Speed: %.0f m/s", type.max_speed);
- ImGui::EndTooltip();
- }
- });
- ImGui::EndCombo();
- }
+ bool changed = ship_type_combo("Ship Type", repo, loadout.type);
ImGui::Indent();
auto it = loadout.turrets.begin();
while (it != loadout.turrets.end()) {
@@ -181,4 +165,29 @@ loadout_editor(std::shared_ptr<universe::Repository> repo, campaign::Loadout& lo
}
-} // namespace kurator \ No newline at end of file
+bool
+ship_type_combo(const char* id, std::shared_ptr<universe::Repository> repo, universe::ShipType& type)
+{
+ bool changed = false;
+ if (ImGui::BeginCombo(id, type.name.c_str())) {
+ repo->for_ship_types([&](const auto& opt){
+ if (ImGui::Selectable(opt.name.c_str(), opt.name == type.name)) {
+ type = opt;
+ changed = true;
+ }
+ if (ImGui::IsItemHovered()) {
+ ImGui::BeginTooltip();
+ ImGui::Text("Shield: %.0f", opt.base_shield_points);
+ ImGui::Text("Armour: %.0f", opt.base_armour_points);
+ ImGui::Text("Structure: %.0f", opt.base_structure_points);
+ ImGui::Text("Speed: %.0f m/s", opt.max_speed);
+ ImGui::EndTooltip();
+ }
+ });
+ ImGui::EndCombo();
+ }
+ return changed;
+}
+
+
+} // namespace kurator