Compare commits

..

3 commits

Author SHA1 Message Date
28db82c8a9 Weapon,Mass,SaveTool: refactor some more code. 2022-02-09 14:17:05 +01:00
9f324c30fd Delete WeaponTypes.h.
It's not needed anymore.
2022-02-09 13:54:44 +01:00
41cd92352d Mass: refactor and optimise some parts. 2022-02-09 13:41:55 +01:00
14 changed files with 492 additions and 200 deletions

View file

@ -124,15 +124,24 @@ add_executable(MassBuilderSaveTool WIN32
Profile/ResourceIDs.h Profile/ResourceIDs.h
MassManager/MassManager.h MassManager/MassManager.h
MassManager/MassManager.cpp MassManager/MassManager.cpp
Mass/Accessory.h
Mass/ArmourPart.h
Mass/CustomStyle.h
Mass/Decal.h
Mass/Joints.h
Mass/Mass.h Mass/Mass.h
Mass/Mass.cpp Mass/Mass.cpp
Mass/Weapon.h
Mass/Weapon.cpp
Mass/WeaponPart.h
Maps/Accessories.h Maps/Accessories.h
Maps/ArmourSets.h Maps/ArmourSets.h
Maps/ArmourSlots.h Maps/ArmourSlots.h
Maps/DamageTypes.hpp
Maps/LastMissionId.h Maps/LastMissionId.h
Maps/StoryProgress.h Maps/StoryProgress.h
Maps/StyleNames.h Maps/StyleNames.h
Maps/WeaponTypes.h Maps/WeaponTypes.hpp
ToastQueue/ToastQueue.h ToastQueue/ToastQueue.h
ToastQueue/ToastQueue.cpp ToastQueue/ToastQueue.cpp
FontAwesome/IconsFontAwesome5.h FontAwesome/IconsFontAwesome5.h

24
src/Maps/DamageTypes.hpp Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
#ifdef c
c(Physical, "enuDamageProperty::NewEnumerator0")
c(Piercing, "enuDamageProperty::NewEnumerator1")
c(Heat, "enuDamageProperty::NewEnumerator2")
c(Freeze, "enuDamageProperty::NewEnumerator3")
c(Shock, "enuDamageProperty::NewEnumerator4")
c(Plasma, "enuDamageProperty::NewEnumerator5")
#endif

24
src/Maps/WeaponTypes.hpp Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
#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

36
src/Mass/Accessory.h Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StaticArray.h>
#include <Magnum/Magnum.h>
#include <Magnum/Math/Vector3.h>
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};
};

View file

@ -17,13 +17,22 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string> #include <string>
#include <unordered_map>
static const std::unordered_map<std::string, const char*> weapon_types{ #include <Corrade/Containers/StaticArray.h>
{"enuWeaponTypes::NewEnumerator0", "Melee weapon"},
{"enuWeaponTypes::NewEnumerator5", "Shield"}, #include <Magnum/Types.h>
{"enuWeaponTypes::NewEnumerator1", "Bullet shooter"},
{"enuWeaponTypes::NewEnumerator2", "Energy shooter"}, #include "Decal.h"
{"enuWeaponTypes::NewEnumerator3", "Bullet launcher"}, #include "Accessory.h"
{"enuWeaponTypes::NewEnumerator4", "Energy launcher"},
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};
}; };

39
src/Mass/CustomStyle.h Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
#include <string>
#include <Magnum/Magnum.h>
#include <Magnum/Math/Color.h>
#include <Magnum/Math/Vector2.h>
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;
};

38
src/Mass/Decal.h Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
#include <string>
#include <Magnum/Magnum.h>
#include <Magnum/Math/Color.h>
#include <Magnum/Math/Vector2.h>
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;
};

32
src/Mass/Joints.h Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
#include <Magnum/Types.h>
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;
};

View file

@ -1063,7 +1063,14 @@ void Mass::getWeaponType(const char* prop_name, Containers::ArrayView<Weapon> we
auto& weapon = weapon_array[i]; auto& weapon = weapon_array[i];
weapon.name = weapon_prop->at<StringProperty>("Name_13_7BF0D31F4E50C50C47231BB36A485D92")->value; weapon.name = weapon_prop->at<StringProperty>("Name_13_7BF0D31F4E50C50C47231BB36A485D92")->value;
weapon.type = weapon_prop->at<ByteProperty>("Type_2_35ABA8C3406F8D9BBF14A89CD6BCE976")->enumValue; auto& weapon_type = weapon_prop->at<ByteProperty>("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<ArrayProperty>("Element_6_8E4617CC4B2C1F1490435599784EC6E0"); auto parts_prop = weapon_prop->at<ArrayProperty>("Element_6_8E4617CC4B2C1F1490435599784EC6E0");
weapon.parts = Containers::Array<WeaponPart>{ValueInit, parts_prop->items.size()}; weapon.parts = Containers::Array<WeaponPart>{ValueInit, parts_prop->items.size()};
@ -1117,7 +1124,14 @@ void Mass::getWeaponType(const char* prop_name, Containers::ArrayView<Weapon> we
getCustomStyles(weapon.customStyles, custom_styles); getCustomStyles(weapon.customStyles, custom_styles);
weapon.attached = weapon_prop->at<BoolProperty>("Attach_15_D00AABBD4AD6A04778D56D81E51927B3")->value; weapon.attached = weapon_prop->at<BoolProperty>("Attach_15_D00AABBD4AD6A04778D56D81E51927B3")->value;
weapon.damageType = weapon_prop->at<ByteProperty>("DamageType_18_E1FFA53540591A9087EC698117A65C83")->enumValue; auto& damage_type = weapon_prop->at<ByteProperty>("DamageType_18_E1FFA53540591A9087EC698117A65C83")->enumValue;
#define c(enumerator, strenum) if(damage_type == (strenum)) { weapon.damageType = DamageType::enumerator; } else
#include "../Maps/DamageTypes.hpp"
#undef c
{
_state = State::Invalid;
Utility::Warning{} << "Invalid damage type enum value in getWeaponType().";
}
weapon.dualWield = weapon_prop->at<BoolProperty>("DualWield_20_B2EB2CEA4A6A233DC7575996B6DD1222")->value; weapon.dualWield = weapon_prop->at<BoolProperty>("DualWield_20_B2EB2CEA4A6A233DC7575996B6DD1222")->value;
weapon.effectColourMode = weapon_prop->at<ByteProperty>("ColorEfxMode_24_D254BCF943E852BF9ADB8AAA8FD80014")->enumValue; weapon.effectColourMode = weapon_prop->at<ByteProperty>("ColorEfxMode_24_D254BCF943E852BF9ADB8AAA8FD80014")->enumValue;
auto effect_colour = weapon_prop->at<ColourStructProperty>("ColorEfx_26_D921B62946C493E487455A831F4520AC"); auto effect_colour = weapon_prop->at<ColourStructProperty>("ColorEfx_26_D921B62946C493E487455A831F4520AC");
@ -1148,7 +1162,13 @@ auto Mass::writeWeaponType(const char* prop_name, Containers::ArrayView<Weapon>
auto& weapon = weapon_array[i]; auto& weapon = weapon_array[i];
weapon_prop->at<StringProperty>("Name_13_7BF0D31F4E50C50C47231BB36A485D92")->value = weapon.name; weapon_prop->at<StringProperty>("Name_13_7BF0D31F4E50C50C47231BB36A485D92")->value = weapon.name;
weapon_prop->at<ByteProperty>("Type_2_35ABA8C3406F8D9BBF14A89CD6BCE976")->enumValue = weapon.type; switch(weapon.type) {
#define c(enumerator, strenum, name) case WeaponType::enumerator: weapon_prop->at<ByteProperty>("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<ArrayProperty>("Element_6_8E4617CC4B2C1F1490435599784EC6E0"); auto parts_prop = weapon_prop->at<ArrayProperty>("Element_6_8E4617CC4B2C1F1490435599784EC6E0");
if(parts_prop->items.size() != weapon.parts.size()) { if(parts_prop->items.size() != weapon.parts.size()) {
@ -1231,7 +1251,13 @@ auto Mass::writeWeaponType(const char* prop_name, Containers::ArrayView<Weapon>
} }
weapon_prop->at<BoolProperty>("Attach_15_D00AABBD4AD6A04778D56D81E51927B3")->value = weapon.attached; weapon_prop->at<BoolProperty>("Attach_15_D00AABBD4AD6A04778D56D81E51927B3")->value = weapon.attached;
weapon_prop->at<ByteProperty>("DamageType_18_E1FFA53540591A9087EC698117A65C83")->enumValue = weapon.damageType; switch(weapon.damageType) {
#define c(enumerator, strenum) case DamageType::enumerator: weapon_prop->at<ByteProperty>("DamageType_18_E1FFA53540591A9087EC698117A65C83")->enumValue = strenum; break;
#include "../Maps/DamageTypes.hpp"
#undef c
default:
Utility::Warning{} << "Invalid damage type enum value in writeWeaponType().";
}
weapon_prop->at<BoolProperty>("DualWield_20_B2EB2CEA4A6A233DC7575996B6DD1222")->value = weapon.dualWield; weapon_prop->at<BoolProperty>("DualWield_20_B2EB2CEA4A6A233DC7575996B6DD1222")->value = weapon.dualWield;
weapon_prop->at<ByteProperty>("ColorEfxMode_24_D254BCF943E852BF9ADB8AAA8FD80014")->enumValue = weapon.effectColourMode; weapon_prop->at<ByteProperty>("ColorEfxMode_24_D254BCF943E852BF9ADB8AAA8FD80014")->enumValue = weapon.effectColourMode;
auto effect_colour = weapon_prop->at<ColourStructProperty>("ColorEfx_26_D921B62946C493E487455A831F4520AC"); auto effect_colour = weapon_prop->at<ColourStructProperty>("ColorEfx_26_D921B62946C493E487455A831F4520AC");

View file

@ -27,6 +27,14 @@
#include <Magnum/Math/Vector2.h> #include <Magnum/Math/Vector2.h>
#include <Magnum/Math/Vector3.h> #include <Magnum/Math/Vector3.h>
#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" #include "../UESaveFile/UESaveFile.h"
using namespace Corrade; using namespace Corrade;
@ -34,120 +42,6 @@ using namespace Magnum;
struct ArrayProperty; 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<WeaponPart>{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<WeaponPart>{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<WeaponPart> 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 { class Mass {
public: public:
enum class State : UnsignedByte { enum class State : UnsignedByte {

49
src/Mass/Weapon.cpp Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
#include "Weapon.h"
Weapon::Weapon(const Weapon& other) {
name = other.name;
type = other.type;
parts = Containers::Array<WeaponPart>{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<WeaponPart>{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;
}

70
src/Mass/Weapon.h Normal file
View file

@ -0,0 +1,70 @@
#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 <https://www.gnu.org/licenses/>.
#include <string>
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h>
#include <Magnum/Magnum.h>
#include <Magnum/Math/Color.h>
#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,
};
enum class DamageType {
Physical = 0,
Piercing = 1,
Plasma = 5,
Heat = 2,
Freeze = 3,
Shock = 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<WeaponPart> parts;
Containers::StaticArray<16, CustomStyle> customStyles{ValueInit};
bool attached = false;
DamageType damageType = DamageType::Physical;
bool dualWield = false;
std::string effectColourMode;
Color4 effectColour{0.0f};
};

35
src/Mass/WeaponPart.h Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StaticArray.h>
#include <Magnum/Types.h>
#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};
};

View file

@ -22,7 +22,6 @@
#include "../Maps/ArmourSets.h" #include "../Maps/ArmourSets.h"
#include "../Maps/ArmourSlots.h" #include "../Maps/ArmourSlots.h"
#include "../Maps/StyleNames.h" #include "../Maps/StyleNames.h"
#include "../Maps/WeaponTypes.h"
#include "../FontAwesome/IconsFontAwesome5.h" #include "../FontAwesome/IconsFontAwesome5.h"
@ -790,63 +789,66 @@ void SaveTool::drawWeapons() {
ImGui::Separator(); ImGui::Separator();
if(drawUnsafeWidget([](){ return ImGui::Button(ICON_FA_SAVE " Save changes to weapon category"); })) { if(drawUnsafeWidget([](){ return ImGui::Button(ICON_FA_SAVE " Save changes to weapon category"); })) {
if(current_weapon->type == "enuWeaponTypes::NewEnumerator0") { switch(current_weapon->type) {
case WeaponType::Melee:
if(!_currentMass->writeMeleeWeapons()) { if(!_currentMass->writeMeleeWeapons()) {
_queue.addToast(Toast::Type::Error, "Couldn't save melee weapons"); _queue.addToast(Toast::Type::Error, "Couldn't save melee weapons");
} }
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator5") { case WeaponType::Shield:
if(!_currentMass->writeShields()) { if(!_currentMass->writeShields()) {
_queue.addToast(Toast::Type::Error, "Couldn't save shields"); _queue.addToast(Toast::Type::Error, "Couldn't save shields");
} }
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator1") { case WeaponType::BulletShooter:
if(!_currentMass->writeBulletShooters()) { if(!_currentMass->writeBulletShooters()) {
_queue.addToast(Toast::Type::Error, "Couldn't save bullet shooters"); _queue.addToast(Toast::Type::Error, "Couldn't save bullet shooters");
} }
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator2") { case WeaponType::EnergyShooter:
if(!_currentMass->writeEnergyShooters()) { if(!_currentMass->writeEnergyShooters()) {
_queue.addToast(Toast::Type::Error, "Couldn't save energy shooters"); _queue.addToast(Toast::Type::Error, "Couldn't save energy shooters");
} }
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator3") { case WeaponType::BulletLauncher:
if(!_currentMass->writeBulletLaunchers()) { if(!_currentMass->writeBulletLaunchers()) {
_queue.addToast(Toast::Type::Error, "Couldn't save bullet launchers"); _queue.addToast(Toast::Type::Error, "Couldn't save bullet launchers");
} }
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator4") { case WeaponType::EnergyLauncher:
if(!_currentMass->writeEnergyLaunchers()) { if(!_currentMass->writeEnergyLaunchers()) {
_queue.addToast(Toast::Type::Error, "Couldn't save energy launchers"); _queue.addToast(Toast::Type::Error, "Couldn't save energy launchers");
} }
} break;
else { default:
_queue.addToast(Toast::Type::Error, "Unknown weapon type"); _queue.addToast(Toast::Type::Error, "Unknown weapon type");
} }
} }
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button(ICON_FA_UNDO_ALT " Reset weapon category")) { if(ImGui::Button(ICON_FA_UNDO_ALT " Reset weapon category")) {
if(current_weapon->type == "enuWeaponTypes::NewEnumerator0") { switch(current_weapon->type) {
case WeaponType::Melee:
_currentMass->getMeleeWeapons(); _currentMass->getMeleeWeapons();
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator5") { case WeaponType::Shield:
_currentMass->getShields(); _currentMass->getShields();
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator1") { case WeaponType::BulletShooter:
_currentMass->getBulletShooters(); _currentMass->getBulletShooters();
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator2") { case WeaponType::EnergyShooter:
_currentMass->getEnergyShooters(); _currentMass->getEnergyShooters();
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator3") { case WeaponType::BulletLauncher:
_currentMass->getBulletLaunchers(); _currentMass->getBulletLaunchers();
} break;
else if(current_weapon->type == "enuWeaponTypes::NewEnumerator4") { case WeaponType::EnergyLauncher:
_currentMass->getEnergyLaunchers(); _currentMass->getEnergyLaunchers();
} break;
else { default:
_queue.addToast(Toast::Type::Error, "Unknown weapon type"); _queue.addToast(Toast::Type::Error, "Unknown weapon type");
} }
} }
@ -860,7 +862,12 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
} }
ImGui::AlignTextToFramePadding(); 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(); ImGui::SameLine();
@ -880,12 +887,12 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Equipped:"); ImGui::TextUnformatted("Equipped:");
if(weapon.type != "enuWeaponTypes::NewEnumerator5") { if(weapon.type != WeaponType::Shield) {
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Damage type:"); ImGui::TextUnformatted("Damage type:");
} }
if(weapon.type == "enuWeaponTypes::NewEnumerator0") { if(weapon.type == WeaponType::Melee) {
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Dual-wield:"); ImGui::TextUnformatted("Dual-wield:");
@ -902,37 +909,37 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::BeginGroup(); ImGui::BeginGroup();
ImGui::Checkbox("##EquippedCheckbox", &weapon.attached); ImGui::Checkbox("##EquippedCheckbox", &weapon.attached);
if(weapon.type != "enuWeaponTypes::NewEnumerator5") { if(weapon.type != WeaponType::Shield) {
if(weapon.type == "enuWeaponTypes::NewEnumerator0" && if(weapon.type == WeaponType::Melee &&
ImGui::RadioButton("Physical##NoElement", weapon.damageType == "enuDamageProperty::NewEnumerator0")) ImGui::RadioButton("Physical##NoElement", weapon.damageType == DamageType::Physical))
{ {
weapon.damageType = "enuDamageProperty::NewEnumerator0"; weapon.damageType = DamageType::Physical;
} }
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")) ImGui::RadioButton("Piercing##NoElement", weapon.damageType == DamageType::Piercing))
{ {
weapon.damageType = "enuDamageProperty::NewEnumerator1"; weapon.damageType = DamageType::Piercing;
} }
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")) ImGui::RadioButton("Plasma##NoElement", weapon.damageType == DamageType::Plasma))
{ {
weapon.damageType = "enuDamageProperty::NewEnumerator5"; weapon.damageType = DamageType::Plasma;
} }
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::RadioButton("Heat##Heat", weapon.damageType == "enuDamageProperty::NewEnumerator2")) { if(ImGui::RadioButton("Heat##Heat", weapon.damageType == DamageType::Heat)) {
weapon.damageType = "enuDamageProperty::NewEnumerator2"; weapon.damageType = DamageType::Heat;
} }
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::RadioButton("Freeze##Freeze", weapon.damageType == "enuDamageProperty::NewEnumerator3")) { if(ImGui::RadioButton("Freeze##Freeze", weapon.damageType == DamageType::Freeze)) {
weapon.damageType = "enuDamageProperty::NewEnumerator3"; weapon.damageType = DamageType::Freeze;
} }
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::RadioButton("Shock##Shock", weapon.damageType == "enuDamageProperty::NewEnumerator4")) { if(ImGui::RadioButton("Shock##Shock", weapon.damageType == DamageType::Freeze)) {
weapon.damageType = "enuDamageProperty::NewEnumerator4"; weapon.damageType = DamageType::Freeze;
} }
} }
if(weapon.type == "enuWeaponTypes::NewEnumerator0") { if(weapon.type == WeaponType::Melee) {
ImGui::Checkbox("##DualWield", &weapon.dualWield); ImGui::Checkbox("##DualWield", &weapon.dualWield);
if(ImGui::RadioButton("Default##Default", weapon.effectColourMode == "enuWeaponEffectColorMode::NewEnumerator0")) { if(ImGui::RadioButton("Default##Default", weapon.effectColourMode == "enuWeaponEffectColorMode::NewEnumerator0")) {