2021-06-11 19:24:52 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// MassBuilderSaveTool
|
|
|
|
// Copyright (C) 2021 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>
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
#include <Corrade/Containers/Optional.h>
|
|
|
|
#include <Corrade/Containers/Pointer.h>
|
2021-08-28 20:21:13 +02:00
|
|
|
#include <Corrade/Containers/StaticArray.h>
|
|
|
|
|
2021-06-20 14:06:36 +02:00
|
|
|
#include <Magnum/Magnum.h>
|
2021-09-27 17:52:47 +02:00
|
|
|
#include <Magnum/Math/Color.h>
|
|
|
|
#include <Magnum/Math/Vector2.h>
|
|
|
|
#include <Magnum/Math/Vector3.h>
|
|
|
|
|
|
|
|
#include "../UESaveFile/UESaveFile.h"
|
2021-06-20 14:06:36 +02:00
|
|
|
|
2021-08-28 20:21:13 +02:00
|
|
|
using namespace Corrade;
|
2021-06-20 14:06:36 +02:00
|
|
|
using namespace Magnum;
|
|
|
|
|
2021-09-10 16:13:29 +02:00
|
|
|
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;
|
|
|
|
};
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
struct CustomStyle {
|
|
|
|
std::string name;
|
|
|
|
Color4 colour{0.0f};
|
2021-10-05 10:10:18 +02:00
|
|
|
Float metallic = 0.5f;
|
|
|
|
Float gloss = 0.5f;
|
2021-09-27 21:55:05 +02:00
|
|
|
bool glow = false;
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
Int patternId = 0;
|
2021-09-29 11:07:10 +02:00
|
|
|
Float opacity = 0.5f;
|
2021-10-05 10:10:18 +02:00
|
|
|
Vector2 offset{0.5f};
|
2021-09-27 17:52:47 +02:00
|
|
|
Float rotation = 0.0f;
|
2021-10-05 10:10:18 +02:00
|
|
|
Float scale = 0.5f;
|
2021-09-27 17:52:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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};
|
|
|
|
};
|
|
|
|
|
2021-10-02 19:22:52 +02:00
|
|
|
struct ArmourPart {
|
2021-09-27 17:52:47 +02:00
|
|
|
std::string slot;
|
|
|
|
Int id = 0;
|
|
|
|
Containers::StaticArray<4, Int> styles{ValueInit};
|
2021-10-12 16:35:49 +02:00
|
|
|
UnsignedInt demoDecals = 8;
|
2021-09-27 17:52:47 +02:00
|
|
|
Containers::StaticArray<8, Decal> decals{ValueInit};
|
|
|
|
Containers::StaticArray<8, Accessory> accessories{ValueInit};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WeaponPart {
|
|
|
|
Int id = 0;
|
|
|
|
Containers::StaticArray<4, Int> styles{ValueInit};
|
|
|
|
Containers::StaticArray<8, Decal> decals{ValueInit};
|
|
|
|
Containers::StaticArray<8, Accessory> accessories{ValueInit};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Weapon {
|
|
|
|
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};
|
|
|
|
};
|
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
class Mass {
|
|
|
|
public:
|
2021-08-28 20:20:09 +02:00
|
|
|
enum class State : UnsignedByte {
|
|
|
|
Empty, Invalid, Valid
|
|
|
|
};
|
|
|
|
|
2021-08-19 20:33:59 +02:00
|
|
|
explicit Mass(const std::string& path);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
|
|
|
Mass(const Mass&) = delete;
|
|
|
|
Mass& operator=(const Mass&) = delete;
|
|
|
|
|
|
|
|
Mass(Mass&&) = default;
|
|
|
|
Mass& operator=(Mass&&) = default;
|
|
|
|
|
|
|
|
static auto lastError() -> std::string const&;
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
static auto getNameFromFile(const std::string& path) -> Containers::Optional<std::string>;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-08-28 20:20:09 +02:00
|
|
|
void refreshValues();
|
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
auto filename() -> std::string const&;
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto name() -> Containers::Optional<std::string> const&;
|
|
|
|
auto setName(std::string new_name) -> bool;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-08-28 20:20:09 +02:00
|
|
|
auto state() -> State;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
auto demo() const -> bool;
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto dirty() const -> bool;
|
|
|
|
void setDirty(bool dirty = true);
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
auto jointSliders() -> Joints&;
|
|
|
|
void getJointSliders();
|
|
|
|
auto writeJointSliders() -> bool;
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-08-28 20:21:13 +02:00
|
|
|
auto frameStyles() -> Containers::StaticArrayView<4, Int>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getFrameStyles();
|
|
|
|
auto writeFrameStyles() -> bool;
|
2021-08-28 20:21:13 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
auto eyeFlareColour() -> Color4&;
|
|
|
|
void getEyeFlareColour();
|
|
|
|
auto writeEyeFlareColour() -> bool;
|
2021-09-27 17:52:47 +02:00
|
|
|
|
2021-10-02 14:52:48 +02:00
|
|
|
auto frameCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getFrameCustomStyles();
|
|
|
|
auto writeFrameCustomStyle(UnsignedLong index) -> bool;
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2021-10-03 16:32:47 +02:00
|
|
|
auto armourParts() -> Containers::StaticArrayView<38, ArmourPart>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getArmourParts();
|
2021-10-11 17:17:14 +02:00
|
|
|
auto writeArmourPart(UnsignedLong index) -> bool;
|
2021-10-03 16:32:47 +02:00
|
|
|
|
2021-10-02 14:52:48 +02:00
|
|
|
auto armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getArmourCustomStyles();
|
|
|
|
auto writeArmourCustomStyle(UnsignedLong index) -> bool;
|
2021-10-02 14:52:48 +02:00
|
|
|
|
|
|
|
auto globalStyles() -> Containers::StaticArrayView<16, CustomStyle>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getGlobalStyles();
|
|
|
|
auto writeGlobalStyle(UnsignedLong index) -> bool;
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
auto updateSteamId(const std::string& steam_id) -> bool;
|
|
|
|
|
|
|
|
private:
|
2021-10-02 14:52:48 +02:00
|
|
|
auto setCustomStyle(const CustomStyle& style, UnsignedLong index, const char* prop_name) -> bool;
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
Containers::Optional<UESaveFile> _mass;
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
static std::string _lastError;
|
|
|
|
|
2021-08-19 20:33:59 +02:00
|
|
|
std::string _folder;
|
|
|
|
std::string _filename;
|
2021-08-28 20:20:09 +02:00
|
|
|
State _state = State::Empty;
|
2021-10-04 18:18:53 +02:00
|
|
|
bool _demo = false;
|
2021-08-28 20:21:13 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
bool _dirty = false;
|
|
|
|
|
|
|
|
Containers::Optional<std::string> _name = Containers::NullOpt;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
Joints joints{};
|
|
|
|
|
|
|
|
Containers::StaticArray<4, Int> styles{ValueInit};
|
|
|
|
|
|
|
|
Color4 eyeFlare{0.0f};
|
|
|
|
|
2021-10-02 14:51:39 +02:00
|
|
|
Containers::StaticArray<16, CustomStyle> customStyles;
|
2021-09-27 17:52:47 +02:00
|
|
|
} _frame;
|
|
|
|
|
|
|
|
struct {
|
2021-10-02 19:22:52 +02:00
|
|
|
Containers::StaticArray<38, ArmourPart> parts;
|
2021-09-27 17:52:47 +02:00
|
|
|
|
2021-10-02 14:51:39 +02:00
|
|
|
Containers::StaticArray<16, CustomStyle> customStyles;
|
2021-09-27 17:52:47 +02:00
|
|
|
} _armour;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
Containers::StaticArray<8, Weapon> meleeWeapons;
|
|
|
|
Containers::StaticArray<1, Weapon> shields;
|
|
|
|
Containers::StaticArray<4, Weapon> bulletShooters;
|
|
|
|
Containers::StaticArray<4, Weapon> energyShooters;
|
|
|
|
Containers::StaticArray<4, Weapon> bulletLaunchers;
|
|
|
|
Containers::StaticArray<4, Weapon> energyLaunchers;
|
|
|
|
} _weapons;
|
|
|
|
|
|
|
|
Containers::StaticArray<16, CustomStyle> _globalStyles;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
Int engineId;
|
|
|
|
Containers::StaticArray<7, Int> gearIds;
|
|
|
|
|
|
|
|
Int osId;
|
|
|
|
Containers::StaticArray<7, Int> moduleIds;
|
|
|
|
|
|
|
|
Int archId;
|
|
|
|
Containers::StaticArray<7, Int> techIds;
|
|
|
|
} _tuning;
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
std::string _steamId;
|
2021-06-11 19:24:52 +02:00
|
|
|
};
|