2021-06-11 19:24:52 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// MassBuilderSaveTool
|
2024-03-08 20:25:32 +01:00
|
|
|
// Copyright (C) 2021-2024 Guillaume Jacquemin
|
2021-06-11 19:24:52 +02:00
|
|
|
//
|
|
|
|
// 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>
|
2021-08-28 20:21:13 +02:00
|
|
|
#include <Corrade/Containers/StaticArray.h>
|
2022-03-04 21:18:55 +01:00
|
|
|
#include <Corrade/Containers/String.h>
|
|
|
|
#include <Corrade/Containers/StringView.h>
|
2021-08-28 20:21:13 +02:00
|
|
|
|
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>
|
|
|
|
|
2022-02-09 13:36:33 +01:00
|
|
|
#include "Joints.h"
|
2022-03-12 09:34:19 +01:00
|
|
|
#include "BulletLauncherAttachment.h"
|
2022-02-09 13:36:33 +01:00
|
|
|
#include "CustomStyle.h"
|
|
|
|
#include "Decal.h"
|
|
|
|
#include "Accessory.h"
|
|
|
|
#include "ArmourPart.h"
|
|
|
|
#include "WeaponPart.h"
|
|
|
|
#include "Weapon.h"
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
#include "../Gvas/File.h"
|
|
|
|
#include "../Gvas/Types/Types.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;
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
namespace mbst { namespace GameObjects {
|
2021-10-17 10:52:57 +02:00
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
class Mass {
|
|
|
|
public:
|
2022-03-09 11:04:19 +01:00
|
|
|
explicit Mass(Containers::StringView 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;
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto lastError() -> Containers::StringView ;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
static auto getNameFromFile(Containers::StringView path) -> Containers::Optional<Containers::String>;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-08-28 20:20:09 +02:00
|
|
|
void refreshValues();
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto filename() -> Containers::StringView;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto name() -> Containers::StringView;
|
2022-12-03 16:49:39 +01:00
|
|
|
bool setName(Containers::StringView new_name);
|
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
enum class State: std::uint8_t {
|
2022-12-03 16:49:39 +01:00
|
|
|
Empty, Invalid, Valid
|
|
|
|
};
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto state() -> State;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
bool dirty() const;
|
2021-09-27 17:52:47 +02:00
|
|
|
void setDirty(bool dirty = true);
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto jointSliders() -> Joints&;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getJointSliders();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeJointSliders();
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto frameStyles() -> Containers::ArrayView<std::int32_t>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getFrameStyles();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeFrameStyles();
|
2021-08-28 20:21:13 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto eyeFlareColour() -> Color4&;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getEyeFlareColour();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeEyeFlareColour();
|
2021-09-27 17:52:47 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto frameCustomStyles() -> Containers::ArrayView<CustomStyle>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getFrameCustomStyles();
|
2022-12-05 11:32:18 +01:00
|
|
|
bool writeFrameCustomStyle(std::size_t index);
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto armourParts() -> Containers::ArrayView<ArmourPart>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getArmourParts();
|
2023-11-29 12:33:26 +01:00
|
|
|
bool writeArmourPart(ArmourPart::Slot slot);
|
2021-10-03 16:32:47 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle&;
|
|
|
|
auto bulletLauncherAttachments() -> Containers::ArrayView<BulletLauncherAttachment>;
|
2022-03-12 09:34:19 +01:00
|
|
|
void getBulletLauncherAttachments();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeBulletLauncherAttachments();
|
2022-03-12 09:34:19 +01:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto armourCustomStyles() -> Containers::ArrayView<CustomStyle>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getArmourCustomStyles();
|
2022-12-05 11:32:18 +01:00
|
|
|
bool writeArmourCustomStyle(std::size_t index);
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto meleeWeapons() -> Containers::ArrayView<Weapon>;
|
2021-10-17 08:37:12 +02:00
|
|
|
void getMeleeWeapons();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeMeleeWeapons();
|
2021-10-17 08:37:12 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto shields() -> Containers::ArrayView<Weapon>;
|
2021-10-17 08:37:12 +02:00
|
|
|
void getShields();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeShields();
|
2021-10-17 08:37:12 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto bulletShooters() -> Containers::ArrayView<Weapon>;
|
2021-10-17 08:37:12 +02:00
|
|
|
void getBulletShooters();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeBulletShooters();
|
2021-10-17 08:37:12 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto energyShooters() -> Containers::ArrayView<Weapon>;
|
2021-10-17 08:37:12 +02:00
|
|
|
void getEnergyShooters();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeEnergyShooters();
|
2021-10-17 08:37:12 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto bulletLaunchers() -> Containers::ArrayView<Weapon>;
|
2021-10-17 08:37:12 +02:00
|
|
|
void getBulletLaunchers();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeBulletLaunchers();
|
2021-10-17 08:37:12 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto energyLaunchers() -> Containers::ArrayView<Weapon>;
|
2021-10-17 08:37:12 +02:00
|
|
|
void getEnergyLaunchers();
|
2022-12-03 16:49:39 +01:00
|
|
|
bool writeEnergyLaunchers();
|
2021-10-17 08:37:12 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto globalStyles() -> Containers::ArrayView<CustomStyle>;
|
2021-10-04 18:18:53 +02:00
|
|
|
void getGlobalStyles();
|
2022-12-05 11:32:18 +01:00
|
|
|
bool writeGlobalStyle(std::size_t index);
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2021-12-02 15:27:00 +01:00
|
|
|
void getTuning();
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto engine() -> std::int32_t&;
|
|
|
|
auto gears() -> Containers::ArrayView<std::int32_t>;
|
2021-12-02 15:27:00 +01:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto os() -> std::int32_t&;
|
|
|
|
auto modules() -> Containers::ArrayView<std::int32_t>;
|
2021-12-02 15:27:00 +01:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto architecture() -> std::int32_t&;
|
|
|
|
auto techs() -> Containers::ArrayView<std::int32_t>;
|
2021-12-02 15:27:00 +01:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto account() -> Containers::StringView;
|
2022-12-03 16:49:39 +01:00
|
|
|
bool updateAccount(Containers::StringView new_account);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
|
|
|
private:
|
2023-11-29 12:33:26 +01:00
|
|
|
void getCustomStyles(Containers::ArrayView<CustomStyle> styles, Gvas::Types::ArrayProperty* style_array);
|
|
|
|
bool writeCustomStyle(const CustomStyle& style, std::size_t index, Gvas::Types::ArrayProperty* style_array);
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
void getDecals(Containers::ArrayView<Decal> decals, Gvas::Types::ArrayProperty* decal_array);
|
|
|
|
void writeDecals(Containers::ArrayView<Decal> decals, Gvas::Types::ArrayProperty* decal_array);
|
2022-02-17 20:01:59 +01:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
void getAccessories(Containers::ArrayView<Accessory> accessories, Gvas::Types::ArrayProperty* accessory_array);
|
|
|
|
void writeAccessories(Containers::ArrayView<Accessory> accessories, Gvas::Types::ArrayProperty* accs_array);
|
2021-10-18 14:53:35 +02:00
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
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);
|
2021-10-17 08:37:12 +02:00
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
void getTuningCategory(Containers::StringView big_node_prop_name, std::int32_t& big_node_id,
|
|
|
|
Containers::StringView small_nodes_prop_name,
|
|
|
|
Containers::ArrayView<std::int32_t> small_nodes_ids);
|
2021-12-02 15:27:00 +01:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
Containers::Optional<Gvas::File> _mass;
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
Containers::String _lastError;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
Containers::String _folder;
|
|
|
|
Containers::String _filename;
|
2021-08-28 20:20:09 +02:00
|
|
|
State _state = State::Empty;
|
2021-08-28 20:21:13 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
bool _dirty = false;
|
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
Containers::Optional<Containers::String> _name = Containers::NullOpt;
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
Joints joints{};
|
2022-12-05 11:32:18 +01:00
|
|
|
Containers::StaticArray<4, std::int32_t> styles{ValueInit};
|
2021-09-27 17:52:47 +02:00
|
|
|
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-10-02 14:51:39 +02:00
|
|
|
Containers::StaticArray<16, CustomStyle> customStyles;
|
2022-03-12 09:34:19 +01:00
|
|
|
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;
|
|
|
|
|
2022-02-17 20:01:59 +01:00
|
|
|
Containers::Array<CustomStyle> _globalStyles;
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
struct {
|
2022-12-05 11:32:18 +01:00
|
|
|
std::int32_t engineId;
|
|
|
|
Containers::StaticArray<7, std::int32_t> gearIds;
|
2021-09-27 17:52:47 +02:00
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
std::int32_t osId;
|
|
|
|
Containers::StaticArray<7, std::int32_t> moduleIds;
|
2021-09-27 17:52:47 +02:00
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
std::int32_t archId;
|
|
|
|
Containers::StaticArray<7, std::int32_t> techIds;
|
2021-09-27 17:52:47 +02:00
|
|
|
} _tuning;
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
Containers::String _account;
|
2021-06-11 19:24:52 +02:00
|
|
|
};
|
2023-11-29 12:33:26 +01:00
|
|
|
|
|
|
|
}}
|