From 41cd92352d635e2d588d1c4fc9b3c904be1e4f8b Mon Sep 17 00:00:00 2001 From: William JCM Date: Wed, 9 Feb 2022 13:36:33 +0100 Subject: [PATCH] Mass: refactor and optimise some parts. --- src/CMakeLists.txt | 9 ++ src/Maps/WeaponTypes.hpp | 24 +++++ src/Mass/Accessory.h | 36 ++++++++ src/Mass/ArmourPart.h | 38 ++++++++ src/Mass/CustomStyle.h | 39 ++++++++ src/Mass/Decal.h | 38 ++++++++ src/Mass/Joints.h | 32 +++++++ src/Mass/Mass.cpp | 17 +++- src/Mass/Mass.h | 122 ++----------------------- src/Mass/Weapon.cpp | 49 ++++++++++ src/Mass/Weapon.h | 61 +++++++++++++ src/Mass/WeaponPart.h | 35 ++++++++ src/SaveTool/SaveTool_MassViewer.cpp | 128 ++++++++++++++------------- 13 files changed, 452 insertions(+), 176 deletions(-) create mode 100644 src/Maps/WeaponTypes.hpp create mode 100644 src/Mass/Accessory.h create mode 100644 src/Mass/ArmourPart.h create mode 100644 src/Mass/CustomStyle.h create mode 100644 src/Mass/Decal.h create mode 100644 src/Mass/Joints.h create mode 100644 src/Mass/Weapon.cpp create mode 100644 src/Mass/Weapon.h create mode 100644 src/Mass/WeaponPart.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06b6d29..90c2be5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -124,8 +124,16 @@ add_executable(MassBuilderSaveTool WIN32 Profile/ResourceIDs.h MassManager/MassManager.h MassManager/MassManager.cpp + Mass/Accessory.h + Mass/ArmourPart.h + Mass/CustomStyle.h + Mass/Decal.h + Mass/Joints.h Mass/Mass.h Mass/Mass.cpp + Mass/Weapon.h + Mass/Weapon.cpp + Mass/WeaponPart.h Maps/Accessories.h Maps/ArmourSets.h Maps/ArmourSlots.h @@ -133,6 +141,7 @@ add_executable(MassBuilderSaveTool WIN32 Maps/StoryProgress.h Maps/StyleNames.h Maps/WeaponTypes.h + Maps/WeaponTypes.hpp ToastQueue/ToastQueue.h ToastQueue/ToastQueue.cpp FontAwesome/IconsFontAwesome5.h diff --git a/src/Maps/WeaponTypes.hpp b/src/Maps/WeaponTypes.hpp new file mode 100644 index 0000000..baa31d6 --- /dev/null +++ b/src/Maps/WeaponTypes.hpp @@ -0,0 +1,24 @@ +// MassBuilderSaveTool +// Copyright (C) 2021-2022 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifdef c +c(Melee, "enuWeaponTypes::NewEnumerator0", "Melee weapon") +c(BulletShooter, "enuWeaponTypes::NewEnumerator1", "Bullet shooter") +c(EnergyShooter, "enuWeaponTypes::NewEnumerator2", "Energy shooter") +c(BulletLauncher, "enuWeaponTypes::NewEnumerator3", "Bullet launcher") +c(EnergyLauncher, "enuWeaponTypes::NewEnumerator4", "Energy launcher") +c(Shield, "enuWeaponTypes::NewEnumerator5", "Shield") +#endif diff --git a/src/Mass/Accessory.h b/src/Mass/Accessory.h new file mode 100644 index 0000000..cca271d --- /dev/null +++ b/src/Mass/Accessory.h @@ -0,0 +1,36 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2022 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include + +#include +#include + +using namespace Corrade; +using namespace Magnum; + +struct Accessory { + Int attachIndex = -1; + Int id = -1; + Containers::StaticArray<2, Int> styles{ValueInit}; + Vector3 relativePosition{0.0f}; + Vector3 relativePositionOffset{0.0f}; + Vector3 relativeRotation{0.0f}; + Vector3 relativeRotationOffset{0.0f}; + Vector3 localScale{1.0f}; +}; diff --git a/src/Mass/ArmourPart.h b/src/Mass/ArmourPart.h new file mode 100644 index 0000000..833f768 --- /dev/null +++ b/src/Mass/ArmourPart.h @@ -0,0 +1,38 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2022 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include + +#include + +#include + +#include "Decal.h" +#include "Accessory.h" + +using namespace Corrade; +using namespace Magnum; + +struct ArmourPart { + std::string slot; + Int id = 0; + Containers::StaticArray<4, Int> styles{ValueInit}; + UnsignedInt demoDecals = 8; + Containers::StaticArray<8, Decal> decals{ValueInit}; + Containers::StaticArray<8, Accessory> accessories{ValueInit}; +}; diff --git a/src/Mass/CustomStyle.h b/src/Mass/CustomStyle.h new file mode 100644 index 0000000..cee5cf9 --- /dev/null +++ b/src/Mass/CustomStyle.h @@ -0,0 +1,39 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2022 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include + +#include +#include +#include + +using namespace Magnum; + +struct CustomStyle { + std::string name; + Color4 colour{0.0f}; + Float metallic = 0.5f; + Float gloss = 0.5f; + bool glow = false; + + Int patternId = 0; + Float opacity = 0.5f; + Vector2 offset{0.5f}; + Float rotation = 0.0f; + Float scale = 0.5f; +}; diff --git a/src/Mass/Decal.h b/src/Mass/Decal.h new file mode 100644 index 0000000..487f813 --- /dev/null +++ b/src/Mass/Decal.h @@ -0,0 +1,38 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2022 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include + +#include +#include +#include + +using namespace Magnum; + +struct Decal { + Int id = -1; + Color4 colour{0.0f}; + Vector3 position{0.0f}; + Vector3 uAxis{0.0f}; + Vector3 vAxis{0.0f}; + Vector2 offset{0.5f}; + Float scale = 0.5f; + Float rotation = 0.0f; + bool flip = false; + bool wrap = false; +}; diff --git a/src/Mass/Joints.h b/src/Mass/Joints.h new file mode 100644 index 0000000..8cc58c2 --- /dev/null +++ b/src/Mass/Joints.h @@ -0,0 +1,32 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2022 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include + +using namespace Magnum; + +struct Joints { + Float neck = 0.0f; + Float body = 0.0f; + Float shoulders = 0.0f; + Float hips = 0.0f; + Float upperArms = 0.0f; + Float lowerArms = 0.0f; + Float upperLegs = 0.0f; + Float lowerLegs = 0.0f; +}; diff --git a/src/Mass/Mass.cpp b/src/Mass/Mass.cpp index 93c3c64..eff9fdd 100644 --- a/src/Mass/Mass.cpp +++ b/src/Mass/Mass.cpp @@ -1063,7 +1063,14 @@ void Mass::getWeaponType(const char* prop_name, Containers::ArrayView we auto& weapon = weapon_array[i]; weapon.name = weapon_prop->at("Name_13_7BF0D31F4E50C50C47231BB36A485D92")->value; - weapon.type = weapon_prop->at("Type_2_35ABA8C3406F8D9BBF14A89CD6BCE976")->enumValue; + std::string& weapon_type = weapon_prop->at("Type_2_35ABA8C3406F8D9BBF14A89CD6BCE976")->enumValue; + #define c(enumerator, strenum, name) if(weapon_type == (strenum)) { weapon.type = WeaponType::enumerator; } else + #include "../Maps/WeaponTypes.hpp" + #undef c + { + _state = State::Invalid; + Utility::Warning{} << "Invalid weapon type enum value in getWeaponType()."; + } auto parts_prop = weapon_prop->at("Element_6_8E4617CC4B2C1F1490435599784EC6E0"); weapon.parts = Containers::Array{ValueInit, parts_prop->items.size()}; @@ -1148,7 +1155,13 @@ auto Mass::writeWeaponType(const char* prop_name, Containers::ArrayView auto& weapon = weapon_array[i]; weapon_prop->at("Name_13_7BF0D31F4E50C50C47231BB36A485D92")->value = weapon.name; - weapon_prop->at("Type_2_35ABA8C3406F8D9BBF14A89CD6BCE976")->enumValue = weapon.type; + switch(weapon.type) { + #define c(enumerator, strenum, name) case WeaponType::enumerator: weapon_prop->at("Type_2_35ABA8C3406F8D9BBF14A89CD6BCE976")->enumValue = strenum; break; + #include "../Maps/WeaponTypes.hpp" + #undef c + default: + Utility::Warning{} << "Invalid weapon type enum value in writeWeaponType()."; + } auto parts_prop = weapon_prop->at("Element_6_8E4617CC4B2C1F1490435599784EC6E0"); if(parts_prop->items.size() != weapon.parts.size()) { diff --git a/src/Mass/Mass.h b/src/Mass/Mass.h index 815455d..450680e 100644 --- a/src/Mass/Mass.h +++ b/src/Mass/Mass.h @@ -27,6 +27,14 @@ #include #include +#include "Joints.h" +#include "CustomStyle.h" +#include "Decal.h" +#include "Accessory.h" +#include "ArmourPart.h" +#include "WeaponPart.h" +#include "Weapon.h" + #include "../UESaveFile/UESaveFile.h" using namespace Corrade; @@ -34,120 +42,6 @@ using namespace Magnum; struct ArrayProperty; -struct Joints { - Float neck = 0.0f; - Float body = 0.0f; - Float shoulders = 0.0f; - Float hips = 0.0f; - Float upperArms = 0.0f; - Float lowerArms = 0.0f; - Float upperLegs = 0.0f; - Float lowerLegs = 0.0f; -}; - -struct CustomStyle { - std::string name; - Color4 colour{0.0f}; - Float metallic = 0.5f; - Float gloss = 0.5f; - bool glow = false; - - Int patternId = 0; - Float opacity = 0.5f; - Vector2 offset{0.5f}; - Float rotation = 0.0f; - Float scale = 0.5f; -}; - -struct Decal { - Int id = -1; - Color4 colour{0.0f}; - Vector3 position{0.0f}; - Vector3 uAxis{0.0f}; - Vector3 vAxis{0.0f}; - Vector2 offset{0.5f}; - Float scale = 0.5f; - Float rotation = 0.0f; - bool flip = false; - bool wrap = false; -}; - -struct Accessory { - Int attachIndex = -1; - Int id = -1; - Containers::StaticArray<2, Int> styles{ValueInit}; - Vector3 relativePosition{0.0f}; - Vector3 relativePositionOffset{0.0f}; - Vector3 relativeRotation{0.0f}; - Vector3 relativeRotationOffset{0.0f}; - Vector3 localScale{1.0f}; -}; - -struct ArmourPart { - std::string slot; - Int id = 0; - Containers::StaticArray<4, Int> styles{ValueInit}; - UnsignedInt demoDecals = 8; - Containers::StaticArray<8, Decal> decals{ValueInit}; - Containers::StaticArray<8, Accessory> accessories{ValueInit}; -}; - -struct WeaponPart { - Int id = 0; - Containers::StaticArray<4, Int> styles{ValueInit}; - UnsignedInt demoDecals = 8; - Containers::StaticArray<8, Decal> decals{ValueInit}; - Containers::StaticArray<8, Accessory> accessories{ValueInit}; -}; - -struct Weapon { - Weapon() = default; - - Weapon(const Weapon& other) { - name = other.name; - type = other.type; - parts = Containers::Array{other.parts.size()}; - for(UnsignedInt i = 0; i < parts.size(); i++) { - parts[i] = other.parts[i]; - } - customStyles = other.customStyles; - attached = other.attached; - damageType = other.damageType; - dualWield = other.dualWield; - effectColourMode = other.effectColourMode; - effectColour = other.effectColour; - } - Weapon& operator=(const Weapon& other) { - name = other.name; - type = other.type; - parts = Containers::Array{other.parts.size()}; - for(UnsignedInt i = 0; i < parts.size(); i++) { - parts[i] = other.parts[i]; - } - customStyles = other.customStyles; - attached = other.attached; - damageType = other.damageType; - dualWield = other.dualWield; - effectColourMode = other.effectColourMode; - effectColour = other.effectColour; - - return *this; - } - - Weapon(Weapon&& other) = default; - Weapon& operator=(Weapon&& other) = default; - - std::string name; - std::string type; - Containers::Array parts; - Containers::StaticArray<16, CustomStyle> customStyles{ValueInit}; - bool attached = false; - std::string damageType; - bool dualWield = false; - std::string effectColourMode; - Color4 effectColour{0.0f}; -}; - class Mass { public: enum class State : UnsignedByte { diff --git a/src/Mass/Weapon.cpp b/src/Mass/Weapon.cpp new file mode 100644 index 0000000..5864282 --- /dev/null +++ b/src/Mass/Weapon.cpp @@ -0,0 +1,49 @@ +// MassBuilderSaveTool +// Copyright (C) 2021-2022 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "Weapon.h" + +Weapon::Weapon(const Weapon& other) { + name = other.name; + type = other.type; + parts = Containers::Array{other.parts.size()}; + for(UnsignedInt i = 0; i < parts.size(); i++) { + parts[i] = other.parts[i]; + } + customStyles = other.customStyles; + attached = other.attached; + damageType = other.damageType; + dualWield = other.dualWield; + effectColourMode = other.effectColourMode; + effectColour = other.effectColour; +} + +Weapon& Weapon::operator=(const Weapon& other) { + name = other.name; + type = other.type; + parts = Containers::Array{other.parts.size()}; + for(UnsignedInt i = 0; i < parts.size(); i++) { + parts[i] = other.parts[i]; + } + customStyles = other.customStyles; + attached = other.attached; + damageType = other.damageType; + dualWield = other.dualWield; + effectColourMode = other.effectColourMode; + effectColour = other.effectColour; + + return *this; +} diff --git a/src/Mass/Weapon.h b/src/Mass/Weapon.h new file mode 100644 index 0000000..ee7eddd --- /dev/null +++ b/src/Mass/Weapon.h @@ -0,0 +1,61 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2022 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include + +#include +#include + +#include +#include + +#include "WeaponPart.h" +#include "CustomStyle.h" + +using namespace Corrade; +using namespace Magnum; + +enum class WeaponType { + Melee = 0, + Shield = 5, + BulletShooter = 1, + EnergyShooter = 2, + BulletLauncher = 3, + EnergyLauncher = 4, +}; + +struct Weapon { + + Weapon() = default; + + Weapon(const Weapon& other); + Weapon& operator=(const Weapon& other); + + Weapon(Weapon&& other) = default; + Weapon& operator=(Weapon&& other) = default; + + std::string name; + WeaponType type = WeaponType::Melee; + Containers::Array parts; + Containers::StaticArray<16, CustomStyle> customStyles{ValueInit}; + bool attached = false; + std::string damageType; + bool dualWield = false; + std::string effectColourMode; + Color4 effectColour{0.0f}; +}; diff --git a/src/Mass/WeaponPart.h b/src/Mass/WeaponPart.h new file mode 100644 index 0000000..a6cb1a4 --- /dev/null +++ b/src/Mass/WeaponPart.h @@ -0,0 +1,35 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2022 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include + +#include + +#include "Decal.h" +#include "Accessory.h" + +using namespace Corrade; +using namespace Magnum; + +struct WeaponPart { + Int id = 0; + Containers::StaticArray<4, Int> styles{ValueInit}; + UnsignedInt demoDecals = 8; + Containers::StaticArray<8, Decal> decals{ValueInit}; + Containers::StaticArray<8, Accessory> accessories{ValueInit}; +}; diff --git a/src/SaveTool/SaveTool_MassViewer.cpp b/src/SaveTool/SaveTool_MassViewer.cpp index 3078d60..9dd28f9 100644 --- a/src/SaveTool/SaveTool_MassViewer.cpp +++ b/src/SaveTool/SaveTool_MassViewer.cpp @@ -790,64 +790,67 @@ void SaveTool::drawWeapons() { ImGui::Separator(); if(drawUnsafeWidget([](){ return ImGui::Button(ICON_FA_SAVE " Save changes to weapon category"); })) { - if(current_weapon->type == "enuWeaponTypes::NewEnumerator0") { - if(!_currentMass->writeMeleeWeapons()) { - _queue.addToast(Toast::Type::Error, "Couldn't save melee weapons"); - } - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator5") { - if(!_currentMass->writeShields()) { - _queue.addToast(Toast::Type::Error, "Couldn't save shields"); - } - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator1") { - if(!_currentMass->writeBulletShooters()) { - _queue.addToast(Toast::Type::Error, "Couldn't save bullet shooters"); - } - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator2") { - if(!_currentMass->writeEnergyShooters()) { - _queue.addToast(Toast::Type::Error, "Couldn't save energy shooters"); - } - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator3") { - if(!_currentMass->writeBulletLaunchers()) { - _queue.addToast(Toast::Type::Error, "Couldn't save bullet launchers"); - } - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator4") { - if(!_currentMass->writeEnergyLaunchers()) { - _queue.addToast(Toast::Type::Error, "Couldn't save energy launchers"); - } - } - else { - _queue.addToast(Toast::Type::Error, "Unknown weapon type"); + switch(current_weapon->type) { + case WeaponType::Melee: + if(!_currentMass->writeMeleeWeapons()) { + _queue.addToast(Toast::Type::Error, "Couldn't save melee weapons"); + } + break; + case WeaponType::Shield: + if(!_currentMass->writeShields()) { + _queue.addToast(Toast::Type::Error, "Couldn't save shields"); + } + break; + case WeaponType::BulletShooter: + if(!_currentMass->writeBulletShooters()) { + _queue.addToast(Toast::Type::Error, "Couldn't save bullet shooters"); + } + break; + case WeaponType::EnergyShooter: + if(!_currentMass->writeEnergyShooters()) { + _queue.addToast(Toast::Type::Error, "Couldn't save energy shooters"); + } + break; + case WeaponType::BulletLauncher: + if(!_currentMass->writeBulletLaunchers()) { + _queue.addToast(Toast::Type::Error, "Couldn't save bullet launchers"); + } + break; + case WeaponType::EnergyLauncher: + if(!_currentMass->writeEnergyLaunchers()) { + _queue.addToast(Toast::Type::Error, "Couldn't save energy launchers"); + } + break; + default: + _queue.addToast(Toast::Type::Error, "Unknown weapon type"); + } } ImGui::SameLine(); if(ImGui::Button(ICON_FA_UNDO_ALT " Reset weapon category")) { - if(current_weapon->type == "enuWeaponTypes::NewEnumerator0") { - _currentMass->getMeleeWeapons(); - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator5") { - _currentMass->getShields(); - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator1") { - _currentMass->getBulletShooters(); - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator2") { - _currentMass->getEnergyShooters(); - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator3") { - _currentMass->getBulletLaunchers(); - } - else if(current_weapon->type == "enuWeaponTypes::NewEnumerator4") { - _currentMass->getEnergyLaunchers(); - } - else { - _queue.addToast(Toast::Type::Error, "Unknown weapon type"); + switch(current_weapon->type) { + case WeaponType::Melee: + _currentMass->getMeleeWeapons(); + break; + case WeaponType::Shield: + _currentMass->getShields(); + break; + case WeaponType::BulletShooter: + _currentMass->getBulletShooters(); + break; + case WeaponType::EnergyShooter: + _currentMass->getEnergyShooters(); + break; + case WeaponType::BulletLauncher: + _currentMass->getBulletLaunchers(); + break; + case WeaponType::EnergyLauncher: + _currentMass->getEnergyLaunchers(); + break; + default: + _queue.addToast(Toast::Type::Error, "Unknown weapon type"); } } @@ -860,7 +863,12 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) { } ImGui::AlignTextToFramePadding(); - ImGui::Text("%s: %s", weapon_types.at(weapon.type), weapon.name.c_str()); + const char* labels[] { + #define c(enumerator, strenum, name) name, + #include "../Maps/WeaponTypes.hpp" + #undef c + }; + ImGui::Text("%s: %s", labels[UnsignedInt(weapon.type)], weapon.name.c_str()); ImGui::SameLine(); @@ -880,12 +888,12 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) { ImGui::AlignTextToFramePadding(); ImGui::TextUnformatted("Equipped:"); - if(weapon.type != "enuWeaponTypes::NewEnumerator5") { + if(weapon.type != WeaponType::Shield) { ImGui::AlignTextToFramePadding(); ImGui::TextUnformatted("Damage type:"); } - if(weapon.type == "enuWeaponTypes::NewEnumerator0") { + if(weapon.type == WeaponType::Melee) { ImGui::AlignTextToFramePadding(); ImGui::TextUnformatted("Dual-wield:"); @@ -902,18 +910,18 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) { ImGui::BeginGroup(); ImGui::Checkbox("##EquippedCheckbox", &weapon.attached); - if(weapon.type != "enuWeaponTypes::NewEnumerator5") { - if(weapon.type == "enuWeaponTypes::NewEnumerator0" && + if(weapon.type != WeaponType::Shield) { + if(weapon.type == WeaponType::Melee && ImGui::RadioButton("Physical##NoElement", weapon.damageType == "enuDamageProperty::NewEnumerator0")) { weapon.damageType = "enuDamageProperty::NewEnumerator0"; } - else if((weapon.type == "enuWeaponTypes::NewEnumerator1" || weapon.type == "enuWeaponTypes::NewEnumerator3") && + else if((weapon.type == WeaponType::BulletShooter || weapon.type == WeaponType::BulletLauncher) && ImGui::RadioButton("Piercing##NoElement", weapon.damageType == "enuDamageProperty::NewEnumerator1")) { weapon.damageType = "enuDamageProperty::NewEnumerator1"; } - else if((weapon.type == "enuWeaponTypes::NewEnumerator2" || weapon.type == "enuWeaponTypes::NewEnumerator4") && + else if((weapon.type == WeaponType::EnergyShooter || weapon.type == WeaponType::EnergyLauncher) && ImGui::RadioButton("Plasma##NoElement", weapon.damageType == "enuDamageProperty::NewEnumerator5")) { weapon.damageType = "enuDamageProperty::NewEnumerator5"; @@ -932,7 +940,7 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) { } } - if(weapon.type == "enuWeaponTypes::NewEnumerator0") { + if(weapon.type == WeaponType::Melee) { ImGui::Checkbox("##DualWield", &weapon.dualWield); if(ImGui::RadioButton("Default##Default", weapon.effectColourMode == "enuWeaponEffectColorMode::NewEnumerator0")) {