Compare commits

..

8 commits

14 changed files with 215 additions and 70 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

@ -28,44 +28,9 @@ using namespace Corrade;
using namespace Magnum;
enum class ArmourSlot {
Face = 0,
UpperHead = 1,
LowerHead = 2,
Neck = 3,
UpperBody = 4,
MiddleBody = 5,
LowerBody = 6,
FrontWaist = 7,
LeftFrontSkirt = 8,
RightFrontSkirt = 9,
LeftSideSkirt = 10,
RightSideSkirt = 11,
LeftBackSkirt = 12,
RightBackSkirt = 13,
BackWaist = 14,
LeftShoulder = 15,
RightShoulder = 16,
LeftUpperArm = 17,
RightUpperArm = 18,
LeftElbow = 19,
RightElbow = 20,
LeftLowerArm = 21,
RightLowerArm = 22,
Backpack = 23,
LeftHand = 24,
RightHand = 25,
LeftUpperLeg = 26,
RightUpperLeg = 27,
LeftKnee = 28,
RightKnee = 29,
LeftLowerLeg = 30,
RightLowerLeg = 31,
LeftAnkle = 32,
RightAnkle = 33,
LeftHeel = 34,
RightHeel = 35,
LeftFoot = 36,
RightFoot = 37,
#define c(enumerator, enumstr, name) enumerator,
#include "../Maps/ArmourSlots.hpp"
#undef c
};
struct ArmourPart {

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

@ -98,13 +98,13 @@ void Mass::refreshValues() {
}
}
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
auto unit_data = _mass->at<GenericStructProperty>("UnitData"_s);
if(!unit_data) {
_state = State::Invalid;
return;
}
auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB");
auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB"_s);
if(!name_prop) {
_name = Containers::NullOpt;
@ -139,6 +139,11 @@ void Mass::refreshValues() {
return;
}
getBulletLauncherAttachments();
if(_state == State::Invalid) {
return;
}
getArmourCustomStyles();
if(_state == State::Invalid) {
return;
@ -184,7 +189,7 @@ void Mass::refreshValues() {
return;
}
auto account_prop = _mass->at<StringProperty>("Account");
auto account_prop = _mass->at<StringProperty>("Account"_s);
if(!account_prop) {
_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;
}

View file

@ -29,28 +29,19 @@
using namespace Corrade;
using namespace Magnum;
#define c(enumerator, ...) enumerator,
enum class WeaponType {
Melee = 0,
Shield = 5,
BulletShooter = 1,
EnergyShooter = 2,
BulletLauncher = 3,
EnergyLauncher = 4,
#include "../Maps/WeaponTypes.hpp"
};
enum class DamageType {
Physical = 0,
Piercing = 1,
Plasma = 5,
Heat = 2,
Freeze = 3,
Shock = 4,
#include "../Maps/DamageTypes.hpp"
};
enum class EffectColourMode {
Default = 0,
Custom = 1,
#include "../Maps/EffectColourModes.hpp"
};
#undef c
struct Weapon {
Weapon() = default;

View file

@ -185,22 +185,27 @@ void MassManager::refreshStagedMasses() {
auto file_list = Utility::Path::list(_stagingAreaDirectory, ListFlag::SkipSpecial|ListFlag::SkipDirectories|ListFlag::SkipDotAndDotDot);
if(!file_list) {
_lastError = _stagingAreaDirectory + " couldn't be opened"_s;
Utility::Error{} << _stagingAreaDirectory << "couldn't be opened";
return;
}
auto iter = std::remove_if(file_list->begin(), file_list->end(), [](Containers::StringView file){
return file.hasSuffix(".sav"_s);
return !file.hasSuffix(".sav"_s);
});
auto list_view = file_list->except(file_list->end() - iter);
Utility::Debug{} << "Scanning for staged M.A.S.S.es...";
for(Containers::StringView file : list_view) {
auto name = Mass::getNameFromFile(Utility::Path::join(_stagingAreaDirectory, file));
if(name) {
Utility::Debug{} << "Found staged M.A.S.S.:" << *name;
_stagedMasses[file] = *name;
}
else {
Utility::Warning{} << "Skipped:" << file;
}
}
}

View file

@ -375,6 +375,11 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
}
void SaveTool::fileUpdateEvent(SDL_Event& event) {
if(event.user.code == StagedUpdate) {
_massManager->refreshStagedMasses();
return;
}
Containers::String filename{static_cast<char*>(event.user.data1), std::strlen(static_cast<char*>(event.user.data1)), nullptr};
Containers::String old_filename;
@ -444,9 +449,6 @@ void SaveTool::fileUpdateEvent(SDL_Event& event) {
}
}
break;
case StagedUpdate:
_massManager->refreshStagedMasses();
break;
default:
_queue.addToast(Toast::Type::Warning, "Unknown file action type"_s);
}

View file

@ -161,15 +161,13 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
auto drawUnsafeWidget(Functor func, Args... args) -> bool {
GameState game_state = _gameState; // Copying the value to reduce the risk of a data race.
if(!_unsafeMode && game_state != GameState::NotRunning) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
ImGui::BeginDisabled();
}
bool result = func(std::forward<Args>(args)...);
if(!_unsafeMode && game_state != GameState::NotRunning) {
ImGui::PopItemFlag();
ImGui::PopStyleVar();
ImGui::EndDisabled();
}
return result;

View file

@ -150,8 +150,7 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool {
!(len >= 6 && len <= 32) ||
!(name_view[0] != ' ' && name_view[len - 1] != ' '))
{
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
ImGui::BeginDisabled();
}
if(ImGui::Button("Apply")) {
@ -163,8 +162,7 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool {
!(len >= 6 && len <= 32) ||
!(name_view[0] != ' ' && name_view[len - 1] != ' '))
{
ImGui::PopItemFlag();
ImGui::PopStyleVar();
ImGui::EndDisabled();
}
ImGui::EndPopup();

View file

@ -117,7 +117,7 @@ void SaveTool::drawMassViewer() {
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Armour parts")) {
if(ImGui::BeginTabItem("Armour")) {
drawArmour();
ImGui::EndTabItem();
}
@ -127,7 +127,7 @@ void SaveTool::drawMassViewer() {
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Weapons (WIP)")) {
if(ImGui::BeginTabItem("Weapons")) {
drawWeapons();
ImGui::EndTabItem();
}