Mass: add reading support for 0.8 BL placement.

Then, it's UI design time, followed by writing support.
This commit is contained in:
Guillaume Jacquemin 2022-03-12 09:34:19 +01:00
parent d61977d758
commit be06c2d552
7 changed files with 186 additions and 0 deletions

View file

@ -129,6 +129,7 @@ add_executable(MassBuilderSaveTool WIN32
MassManager/MassManager.cpp
Mass/Accessory.h
Mass/ArmourPart.h
Mass/BulletLauncherAttachment.h
Mass/CustomStyle.h
Mass/Decal.h
Mass/Joints.h
@ -145,6 +146,8 @@ add_executable(MassBuilderSaveTool WIN32
Maps/Accessories.h
Maps/ArmourSets.h
Maps/ArmourSlots.hpp
Maps/BulletLauncherAttachmentStyles.hpp
Maps/BulletLauncherSockets.hpp
Maps/DamageTypes.hpp
Maps/EffectColourModes.hpp
Maps/LastMissionId.h

View file

@ -0,0 +1,22 @@
// 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(NotFound, "NotARealValue"_s)
c(ActiveOne, "enuBLAttachmentStyle::NewEnumerator0"_s)
c(ActiveOnePerSlot, "enuBLAttachmentStyle::NewEnumerator1"_s)
c(AllEquipped, "enuBLAttachmentStyle::NewEnumerator2"_s)
#endif

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(Auto, "None"_s)
c(Shoulders, "Shoulder"_s)
c(Body, "Body"_s)
c(Backpack, "Backpack"_s)
c(Hip, "Hip"_s)
c(LowerLegs, "LowerLeg"_s)
#endif

View file

@ -0,0 +1,46 @@
#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/String.h>
#include <Magnum/Magnum.h>
#include <Magnum/Math/Vector3.h>
using namespace Corrade;
using namespace Magnum;
enum class BulletLauncherAttachmentStyle {
#define c(enumerator, enumstr) enumerator,
#include "../Maps/BulletLauncherAttachmentStyles.hpp"
#undef c
};
enum class BulletLauncherSocket {
#define c(enumerator, enumstr) enumerator,
#include "../Maps/BulletLauncherSockets.hpp"
#undef c
};
struct BulletLauncherAttachment {
BulletLauncherSocket socket = BulletLauncherSocket::Auto;
Vector3 relativeLocation;
Vector3 offsetLocation;
Vector3 relativeRotation;
Vector3 offsetRotation;
Vector3 relativeScale;
};

View file

@ -139,6 +139,11 @@ void Mass::refreshValues() {
return;
}
getBulletLauncherAttachments();
if(_state == State::Invalid) {
return;
}
getArmourCustomStyles();
if(_state == State::Invalid) {
return;

View file

@ -28,6 +28,7 @@
#include <Magnum/Math/Vector3.h>
#include "Joints.h"
#include "BulletLauncherAttachment.h"
#include "CustomStyle.h"
#include "Decal.h"
#include "Accessory.h"
@ -92,6 +93,11 @@ class Mass {
void getArmourParts();
auto writeArmourPart(ArmourSlot slot) -> bool;
auto bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle&;
auto bulletLauncherAttachments() -> Containers::ArrayView<BulletLauncherAttachment>;
void getBulletLauncherAttachments();
auto writeBulletLauncherAttachments() -> bool;
auto armourCustomStyles() -> Containers::ArrayView<CustomStyle>;
void getArmourCustomStyles();
auto writeArmourCustomStyle(UnsignedLong index) -> bool;
@ -176,6 +182,8 @@ class Mass {
struct {
Containers::StaticArray<38, ArmourPart> parts;
Containers::StaticArray<16, CustomStyle> customStyles;
BulletLauncherAttachmentStyle blAttachmentStyle = BulletLauncherAttachmentStyle::NotFound;
Containers::StaticArray<4, BulletLauncherAttachment> blAttachment;
} _armour;
struct {

View file

@ -21,6 +21,7 @@
#include "../UESaveFile/Types/GenericStructProperty.h"
#include "../UESaveFile/Types/IntProperty.h"
#include "../UESaveFile/Types/StringProperty.h"
#include "../UESaveFile/Types/VectorStructProperty.h"
#include "Mass.h"
@ -162,6 +163,83 @@ auto Mass::writeArmourPart(ArmourSlot slot) -> bool {
return true;
}
auto Mass::bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle& {
return _armour.blAttachmentStyle;
}
auto Mass::bulletLauncherAttachments() -> Containers::ArrayView<BulletLauncherAttachment> {
return _armour.blAttachment;
}
void Mass::getBulletLauncherAttachments() {
auto unit_data = _mass->at<GenericStructProperty>("UnitData"_s);
if(!unit_data) {
_state = State::Invalid;
return;
}
auto attach_style_prop = _mass->at<ByteProperty>("WeaponBLAttachmentStyle_65_5943FCE8406F18D2C3F69285EB23A699"_s);
auto attach_array = _mass->at<ArrayProperty>("WeaponBLAttachment_61_442D08F547510A4CEE1501BBAF297BA0"_s);
if(!attach_style_prop && !attach_array) {
_armour.blAttachmentStyle = BulletLauncherAttachmentStyle::NotFound;
return;
}
if(attach_style_prop && !attach_array) {
_armour.blAttachmentStyle = BulletLauncherAttachmentStyle::NotFound;
_state = State::Invalid;
return;
}
if(attach_array->items.size() != _weapons.bulletLaunchers.size() &&
attach_array->items.size() != _armour.blAttachment.size())
{
for(UnsignedInt i = 0; i < attach_array->items.size(); i++) {
auto attachment_prop = attach_array->at<GenericStructProperty>(i);
auto& attachment = _armour.blAttachment[i];
Containers::StringView socket = attachment_prop->at<StringProperty>("Socket_9_B9DBF30D4A1F0032A2BE2F8B342B35A9"_s)->value;
#define c(enumerator, strenum) if(socket == (strenum)) { attachment.socket = BulletLauncherSocket::enumerator; } else
#include "../Maps/BulletLauncherSockets.hpp"
#undef c
{
Utility::Error{} << "Invalid BL attachment socket.";
_state = State::Invalid;
return;
}
auto rel_loc_prop = attachment_prop->at<VectorStructProperty>("RelativeLocation_10_2F6E75DF4C40622658340E9A22D38B02"_s);
attachment.relativeLocation = Vector3{rel_loc_prop->x, rel_loc_prop->y, rel_loc_prop->z};
auto off_loc_prop = attachment_prop->at<VectorStructProperty>("OffsetLocation_11_F42B3DA3436948FF85752DB33722382F"_s);
attachment.offsetLocation = Vector3{off_loc_prop->x, off_loc_prop->y, off_loc_prop->z};
auto rel_rot_prop = attachment_prop->at<VectorStructProperty>("RelativeRotation_12_578140464621245132CFF2A2AD85E735"_s);
attachment.relativeRotation = Vector3{rel_rot_prop->x, rel_rot_prop->y, rel_rot_prop->z};
auto off_rot_prop = attachment_prop->at<VectorStructProperty>("OffsetRotation_13_B5980BCD47905D842D1490A1A520B064"_s);
attachment.offsetRotation = Vector3{off_rot_prop->x, off_rot_prop->y, off_rot_prop->z};
auto rel_scale_prop = attachment_prop->at<VectorStructProperty>("RelativeScale_16_37BC80EF42699F79533F7AA7B3094E38"_s);
attachment.relativeScale = Vector3{rel_scale_prop->x, rel_scale_prop->y, rel_scale_prop->z};
}
}
if(attach_style_prop) {
Containers::StringView attach_style = attach_style_prop->enumValue;
#define c(enumerator, strenum) if(attach_style == (strenum)) { _armour.blAttachmentStyle = BulletLauncherAttachmentStyle::enumerator; } else
#include "../Maps/BulletLauncherAttachmentStyles.hpp"
#undef c
{
Utility::Error{} << "Unknown BL attachment style enumerator.";
}
}
else {
_armour.blAttachmentStyle = BulletLauncherAttachmentStyle::ActiveOne;
}
}
auto Mass::writeBulletLauncherAttachments() -> bool {
return false;
}
auto Mass::armourCustomStyles() -> Containers::ArrayView<CustomStyle> {
return _armour.customStyles;
}