MassBuilderSaveTool/src/Mass/Mass.h

213 lines
6.9 KiB
C
Raw Normal View History

#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/>.
2021-09-27 17:52:47 +02:00
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.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 "Joints.h"
#include "BulletLauncherAttachment.h"
#include "CustomStyle.h"
#include "Decal.h"
#include "Accessory.h"
#include "ArmourPart.h"
#include "WeaponPart.h"
#include "Weapon.h"
2021-09-27 17:52:47 +02:00
#include "../UESaveFile/UESaveFile.h"
2021-06-20 14:06:36 +02:00
using namespace Corrade;
2021-06-20 14:06:36 +02:00
using namespace Magnum;
struct ArrayProperty;
class Mass {
public:
explicit Mass(Containers::StringView path);
Mass(const Mass&) = delete;
Mass& operator=(const Mass&) = delete;
Mass(Mass&&) = default;
Mass& operator=(Mass&&) = default;
2022-12-03 16:49:39 +01:00
Containers::StringView lastError();
2022-12-03 16:49:39 +01:00
static Containers::Optional<Containers::String> getNameFromFile(Containers::StringView path);
void refreshValues();
2022-12-03 16:49:39 +01:00
Containers::StringView filename();
2022-12-03 16:49:39 +01:00
Containers::StringView name();
bool setName(Containers::StringView new_name);
enum class State : UnsignedByte {
Empty, Invalid, Valid
};
2022-12-03 16:49:39 +01:00
State state();
2022-12-03 16:49:39 +01:00
bool dirty() const;
2021-09-27 17:52:47 +02:00
void setDirty(bool dirty = true);
2022-12-03 16:49:39 +01:00
Joints& jointSliders();
void getJointSliders();
2022-12-03 16:49:39 +01:00
bool writeJointSliders();
2022-12-03 16:49:39 +01:00
Containers::ArrayView<Int> frameStyles();
void getFrameStyles();
2022-12-03 16:49:39 +01:00
bool writeFrameStyles();
2022-12-03 16:49:39 +01:00
Color4& eyeFlareColour();
void getEyeFlareColour();
2022-12-03 16:49:39 +01:00
bool writeEyeFlareColour();
2021-09-27 17:52:47 +02:00
2022-12-03 16:49:39 +01:00
Containers::ArrayView<CustomStyle> frameCustomStyles();
void getFrameCustomStyles();
2022-12-03 16:49:39 +01:00
bool writeFrameCustomStyle(UnsignedLong index);
2022-12-03 16:49:39 +01:00
Containers::ArrayView<ArmourPart> armourParts();
void getArmourParts();
2022-12-03 16:49:39 +01:00
bool writeArmourPart(ArmourSlot slot);
2022-12-03 16:49:39 +01:00
BulletLauncherAttachmentStyle& bulletLauncherAttachmentStyle();
Containers::ArrayView<BulletLauncherAttachment> bulletLauncherAttachments();
void getBulletLauncherAttachments();
2022-12-03 16:49:39 +01:00
bool writeBulletLauncherAttachments();
2022-12-03 16:49:39 +01:00
Containers::ArrayView<CustomStyle> armourCustomStyles();
void getArmourCustomStyles();
2022-12-03 16:49:39 +01:00
bool writeArmourCustomStyle(UnsignedLong index);
2022-12-03 16:49:39 +01:00
Containers::ArrayView<Weapon> meleeWeapons();
void getMeleeWeapons();
2022-12-03 16:49:39 +01:00
bool writeMeleeWeapons();
2022-12-03 16:49:39 +01:00
Containers::ArrayView<Weapon> shields();
void getShields();
2022-12-03 16:49:39 +01:00
bool writeShields();
2022-12-03 16:49:39 +01:00
Containers::ArrayView<Weapon> bulletShooters();
void getBulletShooters();
2022-12-03 16:49:39 +01:00
bool writeBulletShooters();
2022-12-03 16:49:39 +01:00
Containers::ArrayView<Weapon> energyShooters();
void getEnergyShooters();
2022-12-03 16:49:39 +01:00
bool writeEnergyShooters();
2022-12-03 16:49:39 +01:00
Containers::ArrayView<Weapon> bulletLaunchers();
void getBulletLaunchers();
2022-12-03 16:49:39 +01:00
bool writeBulletLaunchers();
2022-12-03 16:49:39 +01:00
Containers::ArrayView<Weapon> energyLaunchers();
void getEnergyLaunchers();
2022-12-03 16:49:39 +01:00
bool writeEnergyLaunchers();
2022-12-03 16:49:39 +01:00
Containers::ArrayView<CustomStyle> globalStyles();
void getGlobalStyles();
2022-12-03 16:49:39 +01:00
bool writeGlobalStyle(UnsignedLong index);
void getTuning();
2022-12-03 16:49:39 +01:00
Int& engine();
Containers::ArrayView<Int> gears();
2022-12-03 16:49:39 +01:00
Int& os();
Containers::ArrayView<Int> modules();
2022-12-03 16:49:39 +01:00
Int& architecture();
Containers::ArrayView<Int> techs();
2022-12-03 16:49:39 +01:00
Containers::StringView account();
bool updateAccount(Containers::StringView new_account);
private:
2021-10-17 15:28:54 +02:00
void getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array);
2022-12-03 16:49:39 +01:00
bool writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array);
void getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
void writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
void getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accessory_array);
void writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array);
void getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array);
2022-12-03 16:49:39 +01:00
bool writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array);
void getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id,
Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids);
2021-09-27 17:52:47 +02:00
Containers::Optional<UESaveFile> _mass;
Containers::String _lastError;
Containers::String _folder;
Containers::String _filename;
State _state = State::Empty;
2021-09-27 17:52:47 +02:00
bool _dirty = false;
Containers::Optional<Containers::String> _name = Containers::NullOpt;
2021-09-27 17:52:47 +02:00
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 {
Containers::StaticArray<38, ArmourPart> parts;
2021-10-02 14:51:39 +02:00
Containers::StaticArray<16, CustomStyle> customStyles;
BulletLauncherAttachmentStyle blAttachmentStyle = BulletLauncherAttachmentStyle::NotFound;
Containers::StaticArray<4, BulletLauncherAttachment> blAttachment;
2021-09-27 17:52:47 +02:00
} _armour;
struct {
2021-10-16 11:36:31 +02:00
Containers::StaticArray<8, Weapon> melee;
2021-09-27 17:52:47 +02:00
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::Array<CustomStyle> _globalStyles;
2021-09-27 17:52:47 +02:00
struct {
Int engineId;
Containers::StaticArray<7, Int> gearIds;
Int osId;
Containers::StaticArray<7, Int> moduleIds;
Int archId;
Containers::StaticArray<7, Int> techIds;
} _tuning;
Containers::String _account;
};