From 819e144410baf5bacf7409259d622aee0c810e59 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquemin Date: Wed, 29 Nov 2023 12:33:26 +0100 Subject: [PATCH] Reorganise code. This is a big one. Namespacing, general formatting updates, and renaming, among others. --- .../Application.cpp} | 56 +- .../SaveTool.h => Application/Application.h} | 86 +- .../Application_FileWatcher.cpp} | 10 +- .../Application_Initialisation.cpp} | 23 +- .../Application_MainManager.cpp} | 108 +- .../Application_MassViewer.cpp} | 60 +- .../Application_MassViewer_Armour.cpp} | 44 +- .../Application_MassViewer_Frame.cpp} | 28 +- .../Application_MassViewer_Weapons.cpp} | 120 +- .../Application_ProfileManager.cpp} | 18 +- .../Application_UpdateChecker.cpp} | 10 +- .../Application_drawAbout.cpp} | 12 +- .../Application_drawMainMenu.cpp} | 8 +- src/CMakeLists.txt | 32 +- src/Configuration/Configuration.cpp | 4 + src/Configuration/Configuration.h | 20 +- src/{UESaveFile => Gvas}/BinaryReader.cpp | 4 + src/{UESaveFile => Gvas}/BinaryReader.h | 8 +- src/{UESaveFile => Gvas}/BinaryWriter.cpp | 4 + src/{UESaveFile => Gvas}/BinaryWriter.h | 16 +- src/Gvas/CMakeLists.txt | 102 ++ src/{UESaveFile => Gvas}/Debug.cpp | 18 +- src/Gvas/Debug.h | 29 + .../UESaveFile.cpp => Gvas/File.cpp} | 35 +- src/{UESaveFile/UESaveFile.h => Gvas/File.h} | 20 +- src/Gvas/Gvas.h | 26 + .../PropertySerialiser.cpp | 114 +- src/Gvas/PropertySerialiser.h | 64 + .../AbstractUnrealCollectionProperty.h} | 28 +- .../Serialisers/AbstractUnrealProperty.h} | 24 +- .../Serialisers/AbstractUnrealStruct.h} | 17 +- .../Serialisers/ArrayProperty.cpp} | 21 +- .../Serialisers/ArrayProperty.h} | 20 +- .../Serialisers/BoolProperty.cpp} | 22 +- .../Serialisers/BoolProperty.h} | 20 +- .../Serialisers/ByteProperty.cpp} | 20 +- .../Serialisers/ByteProperty.h} | 20 +- .../Serialisers/ColourProperty.cpp} | 21 +- .../Serialisers/ColourProperty.h} | 18 +- .../Serialisers/DateTimeProperty.cpp} | 21 +- .../Serialisers/DateTimeProperty.h} | 18 +- .../Serialisers/EnumProperty.cpp} | 22 +- .../Serialisers/EnumProperty.h} | 20 +- .../Serialisers/FloatProperty.cpp} | 22 +- .../Serialisers/FloatProperty.h} | 20 +- .../Serialisers/GuidProperty.cpp} | 23 +- .../Serialisers/GuidProperty.h} | 18 +- .../Serialisers/IntProperty.cpp} | 21 +- .../Serialisers/IntProperty.h} | 18 +- .../Serialisers/MapProperty.cpp} | 27 +- .../Serialisers/MapProperty.h} | 18 +- .../Serialisers/ResourceProperty.cpp} | 31 +- .../Serialisers/ResourceProperty.h} | 18 +- .../Serialisers/RotatorProperty.cpp} | 21 +- .../Serialisers/RotatorProperty.h} | 18 +- src/Gvas/Serialisers/Serialisers.h | 44 + .../Serialisers/SetProperty.cpp} | 21 +- .../Serialisers/SetProperty.h} | 18 +- .../Serialisers/StringProperty.cpp} | 22 +- .../Serialisers/StringProperty.h} | 20 +- .../Serialisers/Struct.cpp} | 66 +- src/Gvas/Serialisers/Struct.h | 55 + .../Serialisers/TextProperty.cpp} | 25 +- .../Serialisers/TextProperty.h} | 18 +- .../Serialisers/UnrealProperty.h} | 36 +- .../Serialisers/Vector2DProperty.cpp} | 21 +- .../Serialisers/Vector2DProperty.h} | 18 +- .../Serialisers/VectorProperty.cpp} | 26 +- .../Serialisers/VectorProperty.h} | 18 +- .../Types/ArrayProperty.h | 4 + src/{UESaveFile => Gvas}/Types/BoolProperty.h | 4 + src/{UESaveFile => Gvas}/Types/ByteProperty.h | 7 +- .../Types/ColourStructProperty.h | 4 + .../Types/DateTimeStructProperty.h | 4 + src/{UESaveFile => Gvas}/Types/EnumProperty.h | 4 + .../Types/FloatProperty.h | 4 + .../Types/GenericStructProperty.h | 4 + .../Types/GuidStructProperty.h | 4 + src/{UESaveFile => Gvas}/Types/IntProperty.h | 4 + src/{UESaveFile => Gvas}/Types/MapProperty.h | 5 + src/{UESaveFile => Gvas}/Types/NoneProperty.h | 4 + .../Types/ResourceItemValue.h | 4 + .../Types/RotatorStructProperty.h | 4 + src/{UESaveFile => Gvas}/Types/SetProperty.h | 4 + .../Types/StringProperty.h | 4 + .../Types/StructProperty.h | 4 + src/{UESaveFile => Gvas}/Types/TextProperty.h | 4 + .../Debug.h => Gvas/Types/Types.h} | 36 +- .../Types/UnrealProperty.h | 4 + .../Types/UnrealPropertyBase.h | 4 + .../Types/Vector2DStructProperty.h | 4 + .../Types/VectorStructProperty.h | 4 + src/Logger/Logger.h | 4 +- src/Logger/MagnumLogBuffer.h | 2 +- src/Maps/Accessories.h | 1191 +++++++++-------- src/Maps/ArmourSets.h | 4 + src/Maps/LastMissionId.h | 56 +- src/Maps/StoryProgress.h | 4 + src/Maps/StyleNames.h | 4 + src/Maps/WeaponParts.h | 4 + src/Mass/Accessory.h | 4 + src/Mass/ArmourPart.h | 15 +- src/Mass/BulletLauncherAttachment.h | 17 +- src/Mass/CustomStyle.h | 4 + src/Mass/Decal.h | 4 + src/Mass/Joints.h | 4 + src/Mass/Mass.cpp | 40 +- src/Mass/Mass.h | 77 +- src/Mass/Mass_Armour.cpp | 118 +- src/Mass/Mass_DecalsAccessories.cpp | 114 +- src/Mass/Mass_Frame.cpp | 92 +- src/Mass/Mass_Styles.cpp | 72 +- src/Mass/Mass_Weapons.cpp | 98 +- src/Mass/Weapon.cpp | 7 +- src/Mass/Weapon.h | 30 +- src/Mass/WeaponPart.h | 4 + src/MassManager/MassManager.cpp | 28 +- src/MassManager/MassManager.h | 12 +- src/Profile/Profile.cpp | 128 +- src/Profile/Profile.h | 36 +- src/Profile/ResourceIDs.h | 4 + src/ProfileManager/ProfileManager.cpp | 21 +- src/ProfileManager/ProfileManager.h | 16 +- src/ToastQueue/ToastQueue.cpp | 4 + src/ToastQueue/ToastQueue.h | 26 +- src/UESaveFile/CMakeLists.txt | 98 -- src/UESaveFile/PropertySerialiser.h | 61 - src/UESaveFile/Serialisers/StructSerialiser.h | 51 - src/UpdateChecker/UpdateChecker.cpp | 4 + src/UpdateChecker/UpdateChecker.h | 4 + src/Utilities/Crc32.cpp | 56 + src/Utilities/Crc32.h | 38 +- src/Version/Version.cpp | 41 + src/Version/Version.h | 36 +- src/main.cpp | 6 +- 135 files changed, 2727 insertions(+), 2094 deletions(-) rename src/{SaveTool/SaveTool.cpp => Application/Application.cpp} (91%) rename src/{SaveTool/SaveTool.h => Application/Application.h} (77%) rename src/{SaveTool/SaveTool_FileWatcher.cpp => Application/Application_FileWatcher.cpp} (97%) rename src/{SaveTool/SaveTool_Initialisation.cpp => Application/Application_Initialisation.cpp} (95%) rename src/{SaveTool/SaveTool_MainManager.cpp => Application/Application_MainManager.cpp} (85%) rename src/{SaveTool/SaveTool_MassViewer.cpp => Application/Application_MassViewer.cpp} (92%) rename src/{SaveTool/SaveTool_MassViewer_Armour.cpp => Application/Application_MassViewer_Armour.cpp} (88%) rename src/{SaveTool/SaveTool_MassViewer_Frame.cpp => Application/Application_MassViewer_Frame.cpp} (93%) rename src/{SaveTool/SaveTool_MassViewer_Weapons.cpp => Application/Application_MassViewer_Weapons.cpp} (79%) rename src/{SaveTool/SaveTool_ProfileManager.cpp => Application/Application_ProfileManager.cpp} (97%) rename src/{SaveTool/SaveTool_UpdateChecker.cpp => Application/Application_UpdateChecker.cpp} (96%) rename src/{SaveTool/SaveTool_drawAbout.cpp => Application/Application_drawAbout.cpp} (98%) rename src/{SaveTool/SaveTool_drawMainMenu.cpp => Application/Application_drawMainMenu.cpp} (99%) rename src/{UESaveFile => Gvas}/BinaryReader.cpp (99%) rename src/{UESaveFile => Gvas}/BinaryReader.h (95%) rename src/{UESaveFile => Gvas}/BinaryWriter.cpp (99%) rename src/{UESaveFile => Gvas}/BinaryWriter.h (89%) create mode 100644 src/Gvas/CMakeLists.txt rename src/{UESaveFile => Gvas}/Debug.cpp (77%) create mode 100644 src/Gvas/Debug.h rename src/{UESaveFile/UESaveFile.cpp => Gvas/File.cpp} (93%) rename src/{UESaveFile/UESaveFile.h => Gvas/File.h} (83%) create mode 100644 src/Gvas/Gvas.h rename src/{UESaveFile => Gvas}/PropertySerialiser.cpp (64%) create mode 100644 src/Gvas/PropertySerialiser.h rename src/{UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h => Gvas/Serialisers/AbstractUnrealCollectionProperty.h} (58%) rename src/{UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h => Gvas/Serialisers/AbstractUnrealProperty.h} (60%) rename src/{UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h => Gvas/Serialisers/AbstractUnrealStruct.h} (69%) rename src/{UESaveFile/Serialisers/ArrayPropertySerialiser.cpp => Gvas/Serialisers/ArrayProperty.cpp} (77%) rename src/{UESaveFile/Serialisers/ArrayPropertySerialiser.h => Gvas/Serialisers/ArrayProperty.h} (60%) rename src/{UESaveFile/Serialisers/BoolPropertySerialiser.cpp => Gvas/Serialisers/BoolProperty.cpp} (74%) rename src/{UESaveFile/Serialisers/BoolPropertySerialiser.h => Gvas/Serialisers/BoolProperty.h} (61%) rename src/{UESaveFile/Serialisers/BytePropertySerialiser.cpp => Gvas/Serialisers/ByteProperty.cpp} (82%) rename src/{UESaveFile/Serialisers/BytePropertySerialiser.h => Gvas/Serialisers/ByteProperty.h} (60%) rename src/{UESaveFile/Serialisers/ColourPropertySerialiser.cpp => Gvas/Serialisers/ColourProperty.cpp} (69%) rename src/{UESaveFile/Serialisers/ColourPropertySerialiser.h => Gvas/Serialisers/ColourProperty.h} (60%) rename src/{UESaveFile/Serialisers/DateTimePropertySerialiser.cpp => Gvas/Serialisers/DateTimeProperty.cpp} (64%) rename src/{UESaveFile/Serialisers/DateTimePropertySerialiser.h => Gvas/Serialisers/DateTimeProperty.h} (60%) rename src/{UESaveFile/Serialisers/EnumPropertySerialiser.cpp => Gvas/Serialisers/EnumProperty.cpp} (74%) rename src/{UESaveFile/Serialisers/EnumPropertySerialiser.h => Gvas/Serialisers/EnumProperty.h} (60%) rename src/{UESaveFile/Serialisers/FloatPropertySerialiser.cpp => Gvas/Serialisers/FloatProperty.cpp} (72%) rename src/{UESaveFile/Serialisers/FloatPropertySerialiser.h => Gvas/Serialisers/FloatProperty.h} (60%) rename src/{UESaveFile/Serialisers/GuidPropertySerialiser.cpp => Gvas/Serialisers/GuidProperty.cpp} (62%) rename src/{UESaveFile/Serialisers/GuidPropertySerialiser.h => Gvas/Serialisers/GuidProperty.h} (60%) rename src/{UESaveFile/Serialisers/IntPropertySerialiser.cpp => Gvas/Serialisers/IntProperty.cpp} (73%) rename src/{UESaveFile/Serialisers/IntPropertySerialiser.h => Gvas/Serialisers/IntProperty.h} (60%) rename src/{UESaveFile/Serialisers/MapPropertySerialiser.cpp => Gvas/Serialisers/MapProperty.cpp} (85%) rename src/{UESaveFile/Serialisers/MapPropertySerialiser.h => Gvas/Serialisers/MapProperty.h} (60%) rename src/{UESaveFile/Serialisers/ResourcePropertySerialiser.cpp => Gvas/Serialisers/ResourceProperty.cpp} (75%) rename src/{UESaveFile/Serialisers/ResourcePropertySerialiser.h => Gvas/Serialisers/ResourceProperty.h} (60%) rename src/{UESaveFile/Serialisers/RotatorPropertySerialiser.cpp => Gvas/Serialisers/RotatorProperty.cpp} (66%) rename src/{UESaveFile/Serialisers/RotatorPropertySerialiser.h => Gvas/Serialisers/RotatorProperty.h} (60%) create mode 100644 src/Gvas/Serialisers/Serialisers.h rename src/{UESaveFile/Serialisers/SetPropertySerialiser.cpp => Gvas/Serialisers/SetProperty.cpp} (79%) rename src/{UESaveFile/Serialisers/SetPropertySerialiser.h => Gvas/Serialisers/SetProperty.h} (60%) rename src/{UESaveFile/Serialisers/StringPropertySerialiser.cpp => Gvas/Serialisers/StringProperty.cpp} (74%) rename src/{UESaveFile/Serialisers/StringPropertySerialiser.h => Gvas/Serialisers/StringProperty.h} (60%) rename src/{UESaveFile/Serialisers/StructSerialiser.cpp => Gvas/Serialisers/Struct.cpp} (72%) create mode 100644 src/Gvas/Serialisers/Struct.h rename src/{UESaveFile/Serialisers/TextPropertySerialiser.cpp => Gvas/Serialisers/TextProperty.cpp} (72%) rename src/{UESaveFile/Serialisers/TextPropertySerialiser.h => Gvas/Serialisers/TextProperty.h} (60%) rename src/{UESaveFile/Serialisers/UnrealPropertySerialiser.h => Gvas/Serialisers/UnrealProperty.h} (56%) rename src/{UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp => Gvas/Serialisers/Vector2DProperty.cpp} (65%) rename src/{UESaveFile/Serialisers/Vector2DPropertySerialiser.h => Gvas/Serialisers/Vector2DProperty.h} (60%) rename src/{UESaveFile/Serialisers/VectorPropertySerialiser.cpp => Gvas/Serialisers/VectorProperty.cpp} (67%) rename src/{UESaveFile/Serialisers/VectorPropertySerialiser.h => Gvas/Serialisers/VectorProperty.h} (60%) rename src/{UESaveFile => Gvas}/Types/ArrayProperty.h (97%) rename src/{UESaveFile => Gvas}/Types/BoolProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/ByteProperty.h (87%) rename src/{UESaveFile => Gvas}/Types/ColourStructProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/DateTimeStructProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/EnumProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/FloatProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/GenericStructProperty.h (97%) rename src/{UESaveFile => Gvas}/Types/GuidStructProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/IntProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/MapProperty.h (94%) rename src/{UESaveFile => Gvas}/Types/NoneProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/ResourceItemValue.h (97%) rename src/{UESaveFile => Gvas}/Types/RotatorStructProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/SetProperty.h (97%) rename src/{UESaveFile => Gvas}/Types/StringProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/StructProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/TextProperty.h (96%) rename src/{UESaveFile/Debug.h => Gvas/Types/Types.h} (64%) rename src/{UESaveFile => Gvas}/Types/UnrealProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/UnrealPropertyBase.h (96%) rename src/{UESaveFile => Gvas}/Types/Vector2DStructProperty.h (96%) rename src/{UESaveFile => Gvas}/Types/VectorStructProperty.h (96%) delete mode 100644 src/UESaveFile/CMakeLists.txt delete mode 100644 src/UESaveFile/PropertySerialiser.h delete mode 100644 src/UESaveFile/Serialisers/StructSerialiser.h create mode 100644 src/Utilities/Crc32.cpp create mode 100644 src/Version/Version.cpp diff --git a/src/SaveTool/SaveTool.cpp b/src/Application/Application.cpp similarity index 91% rename from src/SaveTool/SaveTool.cpp rename to src/Application/Application.cpp index 2859392..ff5efea 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/Application/Application.cpp @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "SaveTool.h" - #include #include @@ -37,6 +35,8 @@ #include "../Configuration/Configuration.h" #include "../Logger/Logger.h" +#include "Application.h" + using namespace Containers::Literals; extern const ImVec2 center_pivot = {0.5f, 0.5f}; @@ -45,7 +45,9 @@ extern const ImVec2 center_pivot = {0.5f, 0.5f}; Utility::Tweakable tweak; #endif -SaveTool::SaveTool(const Arguments& arguments): +namespace mbst { + +Application::Application(const Arguments& arguments): Platform::Sdl2Application{arguments, Configuration{}.setTitle("M.A.S.S. Builder Save Tool " SAVETOOL_VERSION_STRING " (\"" SAVETOOL_CODENAME "\")") .setSize({960, 720})} @@ -82,7 +84,7 @@ SaveTool::SaveTool(const Arguments& arguments): LOG_INFO("Registering custom events."); if((_initEventId = SDL_RegisterEvents(3)) == std::uint32_t(-1)) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", - "SDL_RegisterEvents() failed in SaveTool::SaveTool(). Exiting...", window()); + "SDL_RegisterEvents() failed in Application::SaveTool(). Exiting...", window()); exit(EXIT_FAILURE); return; } @@ -118,7 +120,7 @@ SaveTool::SaveTool(const Arguments& arguments): checkGameState(); _gameCheckTimerId = SDL_AddTimer(2000, [](std::uint32_t interval, void* param)->std::uint32_t{ - static_cast(param)->checkGameState(); + static_cast(param)->checkGameState(); return interval; }, this); if(_gameCheckTimerId == 0) { @@ -149,7 +151,7 @@ SaveTool::SaveTool(const Arguments& arguments): _timeline.start(); } -SaveTool::~SaveTool() { +Application::~Application() { LOG_INFO("Cleaning up."); SDL_RemoveTimer(_gameCheckTimerId); @@ -162,7 +164,7 @@ SaveTool::~SaveTool() { } void -SaveTool::drawEvent() { +Application::drawEvent() { #ifdef SAVETOOL_DEBUG_BUILD tweak.update(); #endif @@ -183,7 +185,7 @@ SaveTool::drawEvent() { } void -SaveTool::viewportEvent(ViewportEvent& event) { +Application::viewportEvent(ViewportEvent& event) { GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()}); const Vector2 size = Vector2{windowSize()}/dpiScaling(); @@ -191,32 +193,32 @@ SaveTool::viewportEvent(ViewportEvent& event) { } void -SaveTool::keyPressEvent(KeyEvent& event) { +Application::keyPressEvent(KeyEvent& event) { if(_imgui.handleKeyPressEvent(event)) return; } void -SaveTool::keyReleaseEvent(KeyEvent& event) { +Application::keyReleaseEvent(KeyEvent& event) { if(_imgui.handleKeyReleaseEvent(event)) return; } void -SaveTool::mousePressEvent(MouseEvent& event) { +Application::mousePressEvent(MouseEvent& event) { if(_imgui.handleMousePressEvent(event)) return; } void -SaveTool::mouseReleaseEvent(MouseEvent& event) { +Application::mouseReleaseEvent(MouseEvent& event) { if(_imgui.handleMouseReleaseEvent(event)) return; } void -SaveTool::mouseMoveEvent(MouseMoveEvent& event) { +Application::mouseMoveEvent(MouseMoveEvent& event) { if(_imgui.handleMouseMoveEvent(event)) return; } void -SaveTool::mouseScrollEvent(MouseScrollEvent& event) { +Application::mouseScrollEvent(MouseScrollEvent& event) { if(_imgui.handleMouseScrollEvent(event)) { event.setAccepted(); return; @@ -224,12 +226,12 @@ SaveTool::mouseScrollEvent(MouseScrollEvent& event) { } void -SaveTool::textInputEvent(TextInputEvent& event) { +Application::textInputEvent(TextInputEvent& event) { if(_imgui.handleTextInputEvent(event)) return; } void -SaveTool::anyEvent(SDL_Event& event) { +Application::anyEvent(SDL_Event& event) { if(event.type == _initEventId) { initEvent(event); } @@ -242,7 +244,7 @@ SaveTool::anyEvent(SDL_Event& event) { } void -SaveTool::drawImGui() { +Application::drawImGui() { _imgui.newFrame(); if(ImGui::GetIO().WantTextInput && !isTextInputActive()) { @@ -260,7 +262,7 @@ SaveTool::drawImGui() { } void -SaveTool::drawGui() { +Application::drawGui() { drawMainMenu(); switch(_uiState) { @@ -303,7 +305,7 @@ SaveTool::drawGui() { } void -SaveTool::drawDisclaimer() { +Application::drawDisclaimer() { ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot); if(ImGui::Begin("Disclaimer##DisclaimerWindow", nullptr, @@ -371,7 +373,7 @@ SaveTool::drawDisclaimer() { } void -SaveTool::drawInitialisation() { +Application::drawInitialisation() { ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot); if(ImGui::BeginPopupModal("##InitPopup", nullptr, @@ -385,7 +387,7 @@ SaveTool::drawInitialisation() { } void -SaveTool::drawGameState() { +Application::drawGameState() { ImGui::TextUnformatted("Game state:"); ImGui::SameLine(); { @@ -407,13 +409,13 @@ SaveTool::drawGameState() { } void -SaveTool::drawHelpMarker(Containers::StringView text, float wrap_pos) { +Application::drawHelpMarker(Containers::StringView text, float wrap_pos) { ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE); drawTooltip(text, wrap_pos); } void -SaveTool::drawTooltip(Containers::StringView text, float wrap_pos) { +Application::drawTooltip(Containers::StringView text, float wrap_pos) { if(ImGui::IsItemHovered()){ ImGui::BeginTooltip(); if(wrap_pos > 0.0f) { @@ -428,12 +430,12 @@ SaveTool::drawTooltip(Containers::StringView text, float wrap_pos) { } bool -SaveTool::drawCheckbox(Containers::StringView label, bool value) { +Application::drawCheckbox(Containers::StringView label, bool value) { return ImGui::Checkbox(label.data(), &value); } void -SaveTool::openUri(Containers::StringView uri) { +Application::openUri(Containers::StringView uri) { if(!conf().isRunningInWine()) { ShellExecuteA(nullptr, nullptr, uri.data(), nullptr, nullptr, SW_SHOWDEFAULT); } @@ -443,7 +445,7 @@ SaveTool::openUri(Containers::StringView uri) { } void -SaveTool::checkGameState() { +Application::checkGameState() { WTS_PROCESS_INFOW* process_infos = nullptr; unsigned long process_count = 0; @@ -464,3 +466,5 @@ SaveTool::checkGameState() { _gameState = GameState::Unknown; } } + +} diff --git a/src/SaveTool/SaveTool.h b/src/Application/Application.h similarity index 77% rename from src/SaveTool/SaveTool.h rename to src/Application/Application.h index e1a3077..2f30b0e 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/Application/Application.h @@ -51,11 +51,13 @@ using namespace Corrade; using namespace Containers::Literals; using namespace Magnum; -class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener { - public: - explicit SaveTool(const Arguments& arguments); +namespace mbst { - ~SaveTool() override; +class Application: public Platform::Sdl2Application, public efsw::FileWatchListener { + public: + explicit Application(const Arguments& arguments); + + ~Application() override; void handleFileAction(efsw::WatchID watch_id, const std::string& dir, @@ -113,20 +115,20 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void drawInitialisation(); void drawProfileManager(); - ImGuiID drawBackupListPopup(); - ImGuiID drawBackupProfilePopup(std::size_t profile_index); - ImGuiID drawDeleteProfilePopup(std::size_t profile_index); + auto drawBackupListPopup() -> ImGuiID; + auto drawBackupProfilePopup(std::size_t profile_index) -> ImGuiID; + auto drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID; void drawManager(); bool drawIntEditPopup(int* value_to_edit, int max); bool drawRenamePopup(Containers::ArrayView name_view); void drawGeneralInfo(); void drawResearchInventory(); - void drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id); + void drawMaterialRow(Containers::StringView name, std::int32_t tier, GameData::MaterialID id); void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier); void drawMassManager(); - ImGuiID drawDeleteMassPopup(int mass_index); - ImGuiID drawDeleteStagedMassPopup(Containers::StringView filename); + auto drawDeleteMassPopup(int mass_index) -> ImGuiID; + auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID; void drawMassViewer(); void drawFrameInfo(); @@ -137,21 +139,24 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void drawArmour(); void drawCustomArmourStyles(); void drawWeapons(); - void drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view, bool& dirty, - Containers::StringView payload_type, Containers::StringView payload_tooltip); - void drawWeaponEditor(Weapon& weapon); + void drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view, + bool& dirty, Containers::StringView payload_type, + Containers::StringView payload_tooltip); + void drawWeaponEditor(GameObjects::Weapon& weapon); void drawGlobalStyles(); void drawTuning(); - void drawDecalEditor(Decal& decal); - void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView style_view); - Containers::StringView getStyleName(std::int32_t id, Containers::ArrayView view); + void drawDecalEditor(GameObjects::Decal& decal); + void drawAccessoryEditor(GameObjects::Accessory& accessory, + Containers::ArrayView style_view); + auto getStyleName(std::int32_t id, Containers::ArrayView view) + -> Containers::StringView; enum DCSResult { DCS_Fail, DCS_ResetStyle, DCS_Save }; - DCSResult drawCustomStyle(CustomStyle& style); + auto drawCustomStyle(GameObjects::CustomStyle& style) -> DCSResult; void drawAbout(); void drawGameState(); @@ -206,11 +211,11 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener MassViewer } _uiState{UiState::Disclaimer}; - bool _aboutPopup{false}; + bool _aboutPopup = false; #ifdef SAVETOOL_DEBUG_BUILD - bool _demoWindow{false}; - bool _styleEditor{false}; - bool _metricsWindow{false}; + bool _demoWindow = false; + bool _styleEditor = false; + bool _metricsWindow = false; #endif ToastQueue _queue; @@ -243,12 +248,12 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener SDL_TimerID _gameCheckTimerId = 0; Containers::Pointer _profileManager; - Profile* _currentProfile{nullptr}; + GameObjects::Profile* _currentProfile = nullptr; Containers::Pointer _massManager; - Mass* _currentMass{nullptr}; + GameObjects::Mass* _currentMass = nullptr; - Weapon* _currentWeapon = nullptr; + GameObjects::Weapon* _currentWeapon = nullptr; Containers::Pointer _fileWatcher; enum watchID { @@ -258,24 +263,27 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener Containers::StaticArray<2, efsw::WatchID> _watchIDs; Containers::Optional _checker{Containers::NullOpt}; - std::mutex _checkerMutex; + std::mutex _checkerMutex; + + bool _modifiedBySaveTool = false; + bool _jointsDirty = false; + bool _stylesDirty = false; + bool _eyeFlareDirty = false; + bool _meleeDirty = false; + bool _shieldsDirty = false; + bool _bShootersDirty = false; + bool _eShootersDirty = false; + bool _bLaunchersDirty = false; + bool _eLaunchersDirty = false; - bool _modifiedBySaveTool{false}; - bool _jointsDirty{false}; - bool _stylesDirty{false}; - bool _eyeFlareDirty{false}; Containers::StaticArray<38, std::int32_t> _selectedArmourDecals{ValueInit}; Containers::StaticArray<38, std::int32_t> _selectedArmourAccessories{ValueInit}; - std::int32_t _selectedBLPlacement{0}; - std::int32_t _selectedWeaponPart{0}; - std::int32_t _selectedWeaponDecal{0}; - std::int32_t _selectedWeaponAccessory{0}; - bool _meleeDirty{false}; - bool _shieldsDirty{false}; - bool _bShootersDirty{false}; - bool _eShootersDirty{false}; - bool _bLaunchersDirty{false}; - bool _eLaunchersDirty{false}; + std::int32_t _selectedBLPlacement = 0; + std::int32_t _selectedWeaponPart = 0; + std::int32_t _selectedWeaponDecal = 0; + std::int32_t _selectedWeaponAccessory = 0; Timeline _timeline; }; + +} diff --git a/src/SaveTool/SaveTool_FileWatcher.cpp b/src/Application/Application_FileWatcher.cpp similarity index 97% rename from src/SaveTool/SaveTool_FileWatcher.cpp rename to src/Application/Application_FileWatcher.cpp index c35b233..f99f40b 100644 --- a/src/SaveTool/SaveTool_FileWatcher.cpp +++ b/src/Application/Application_FileWatcher.cpp @@ -24,10 +24,12 @@ #include #include -#include "SaveTool.h" +#include "Application.h" + +namespace mbst { void -SaveTool::handleFileAction(efsw::WatchID watch_id, +Application::handleFileAction(efsw::WatchID watch_id, const std::string&, const std::string& filename, efsw::Action action, @@ -64,7 +66,7 @@ SaveTool::handleFileAction(efsw::WatchID watch_id, } void -SaveTool::fileUpdateEvent(SDL_Event& event) { +Application::fileUpdateEvent(SDL_Event& event) { Containers::String filename{static_cast(event.user.data1), std::strlen(static_cast(event.user.data1)), nullptr}; @@ -153,3 +155,5 @@ SaveTool::fileUpdateEvent(SDL_Event& event) { _queue.addToast(Toast::Type::Warning, "Unknown file action type"_s); } } + +} diff --git a/src/SaveTool/SaveTool_Initialisation.cpp b/src/Application/Application_Initialisation.cpp similarity index 95% rename from src/SaveTool/SaveTool_Initialisation.cpp rename to src/Application/Application_Initialisation.cpp index b6f6449..606f7cc 100644 --- a/src/SaveTool/SaveTool_Initialisation.cpp +++ b/src/Application/Application_Initialisation.cpp @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include #include #include #include @@ -29,10 +28,12 @@ #include "../FontAwesome/IconsFontAwesome5Brands.h" #include "../Logger/Logger.h" -#include "SaveTool.h" +#include "Application.h" + +namespace mbst { void -SaveTool::initEvent(SDL_Event& event) { +Application::initEvent(SDL_Event& event) { _initThread.join(); switch(event.user.code) { @@ -51,7 +52,7 @@ SaveTool::initEvent(SDL_Event& event) { } void -SaveTool::initialiseConfiguration() { +Application::initialiseConfiguration() { LOG_INFO("Reading configuration file."); setSwapInterval(conf().swapInterval()); @@ -59,7 +60,7 @@ SaveTool::initialiseConfiguration() { } void -SaveTool::initialiseGui() { +Application::initialiseGui() { LOG_INFO("Initialising Dear ImGui."); auto ctx = ImGui::CreateContext(); @@ -107,7 +108,7 @@ SaveTool::initialiseGui() { } void -SaveTool::initialiseManager() { +Application::initialiseManager() { LOG_INFO("Initialising the profile manager."); SDL_Event event; @@ -126,7 +127,7 @@ SaveTool::initialiseManager() { } auto -SaveTool::initialiseToolDirectories() -> bool { +Application::initialiseToolDirectories() -> bool { LOG_INFO("Initialising Save Tool directories."); _backupsDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "backups"); @@ -188,7 +189,7 @@ SaveTool::initialiseToolDirectories() -> bool { } auto -SaveTool::findGameDataDirectory() -> bool { +Application::findGameDataDirectory() -> bool { LOG_INFO("Searching for the game's save directory."); wchar_t* localappdata_path = nullptr; @@ -223,16 +224,18 @@ SaveTool::findGameDataDirectory() -> bool { } void -SaveTool::initialiseMassManager() { +Application::initialiseMassManager() { LOG_INFO("Initialising the M.A.S.S. manager."); _massManager.emplace(_saveDir, _currentProfile->account(), _currentProfile->isDemo(), _stagingDir); } void -SaveTool::initialiseFileWatcher() { +Application::initialiseFileWatcher() { LOG_INFO("Initialising the file watcher."); _fileWatcher.emplace(); _watchIDs[SaveDir] = _fileWatcher->addWatch(_saveDir, this, false); _watchIDs[StagingDir] = _fileWatcher->addWatch(_stagingDir, this, false); _fileWatcher->watch(); } + +} diff --git a/src/SaveTool/SaveTool_MainManager.cpp b/src/Application/Application_MainManager.cpp similarity index 85% rename from src/SaveTool/SaveTool_MainManager.cpp rename to src/Application/Application_MainManager.cpp index b95df8d..e9861c6 100644 --- a/src/SaveTool/SaveTool_MainManager.cpp +++ b/src/Application/Application_MainManager.cpp @@ -28,10 +28,12 @@ #include "../Maps/LastMissionId.h" #include "../Maps/StoryProgress.h" -#include "SaveTool.h" +#include "Application.h" + +namespace mbst { void -SaveTool::drawManager() { +Application::drawManager() { ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always); ImGui::SetNextWindowSize(ImVec2{Vector2{float(windowSize().x()), float(windowSize().y()) - ImGui::GetItemRectSize().y} / dpiScaling()}, ImGuiCond_Always); @@ -99,7 +101,7 @@ SaveTool::drawManager() { } bool -SaveTool::drawIntEditPopup(int* value_to_edit, int max) { +Application::drawIntEditPopup(int* value_to_edit, int max) { bool apply = false; if(ImGui::BeginPopup("int_edit")) { ImGui::Text("Please enter a value between 0 and %i:", max); @@ -123,7 +125,7 @@ SaveTool::drawIntEditPopup(int* value_to_edit, int max) { } bool -SaveTool::drawRenamePopup(Containers::ArrayView name_view) { +Application::drawRenamePopup(Containers::ArrayView name_view) { bool apply = false; if(ImGui::BeginPopup("name_edit")) { ImGui::TextUnformatted("Please enter a new name. Conditions:"); @@ -178,16 +180,16 @@ SaveTool::drawRenamePopup(Containers::ArrayView name_view) { } void -SaveTool::drawGeneralInfo() { +Application::drawGeneralInfo() { if(!_currentProfile) { return; } ImGui::Text("Credits: %i", _currentProfile->credits()); - auto it = std::find_if(story_progress.begin(), story_progress.end(), - [this](const StoryProgressPoint& p){ return p.id == _currentProfile->storyProgress(); }); - if(it != story_progress.end()) + auto it = std::find_if(GameData::story_progress.begin(), GameData::story_progress.end(), + [this](const GameData::StoryProgressPoint& p){ return p.id == _currentProfile->storyProgress(); }); + if(it != GameData::story_progress.end()) { ImGui::TextUnformatted("Story progress:"); ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.x / 4.0f); @@ -202,8 +204,8 @@ SaveTool::drawGeneralInfo() { ImGui::Text("Story progress: 0x%x", _currentProfile->storyProgress()); } - if(mission_id_map.find(_currentProfile->lastMissionId()) != mission_id_map.cend()) { - ImGui::Text("Last mission: %s", mission_id_map.at(_currentProfile->lastMissionId()).data()); + if(GameData::mission_id_map.find(_currentProfile->lastMissionId()) != GameData::mission_id_map.cend()) { + ImGui::Text("Last mission: %s", GameData::mission_id_map.at(_currentProfile->lastMissionId()).data()); } else if(_currentProfile->lastMissionId() == -1) { ImGui::TextUnformatted("Last mission: none"); @@ -260,7 +262,7 @@ SaveTool::drawGeneralInfo() { if(_gameState != GameState::NotRunning) { ImGui::CloseCurrentPopup(); } - for(const auto& sp : story_progress) { + for(const auto& sp : GameData::story_progress) { if(ImGui::BeginMenu(sp.chapter.data())) { if(!sp.after) { if(ImGui::MenuItem(sp.point.data())) { @@ -287,7 +289,7 @@ SaveTool::drawGeneralInfo() { } void -SaveTool::drawResearchInventory() { +Application::drawResearchInventory() { if(!_currentProfile) { return; } @@ -304,48 +306,48 @@ SaveTool::drawResearchInventory() { ImGui::TableSetColumnIndex(1); ImGui::TextUnformatted("Engine materials"); - drawMaterialRow("Verse steel", 1, VerseSteel); - drawMaterialRow("Undinium", 2, Undinium); - drawMaterialRow("Necrium alloy", 3, NecriumAlloy); - drawMaterialRow("Lunarite", 4, Lunarite); - drawMaterialRow("Asterite", 5, Asterite); - drawMaterialRow("Hallite fragma", 6, HalliteFragma); + drawMaterialRow("Verse steel", 1, GameData::MaterialID::VerseSteel); + drawMaterialRow("Undinium", 2, GameData::MaterialID::Undinium); + drawMaterialRow("Necrium alloy", 3, GameData::MaterialID::NecriumAlloy); + drawMaterialRow("Lunarite", 4, GameData::MaterialID::Lunarite); + drawMaterialRow("Asterite", 5, GameData::MaterialID::Asterite); + drawMaterialRow("Hallite fragma", 6, GameData::MaterialID::HalliteFragma); drawUnavailableMaterialRow("Unnoctinium", 7); ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableSetColumnIndex(1); ImGui::TextUnformatted("OS materials"); - drawMaterialRow("Ednil", 1, Ednil); - drawMaterialRow("Nuflalt", 2, Nuflalt); - drawMaterialRow("Aurelene", 3, Aurelene); - drawMaterialRow("Soldus", 4, Soldus); - drawMaterialRow("Synthesized N", 5, SynthesisedN); - drawMaterialRow("Nanoc", 6, Nanoc); + drawMaterialRow("Ednil", 1, GameData::MaterialID::Ednil); + drawMaterialRow("Nuflalt", 2, GameData::MaterialID::Nuflalt); + drawMaterialRow("Aurelene", 3, GameData::MaterialID::Aurelene); + drawMaterialRow("Soldus", 4, GameData::MaterialID::Soldus); + drawMaterialRow("Synthesized N", 5, GameData::MaterialID::SynthesisedN); + drawMaterialRow("Nanoc", 6, GameData::MaterialID::Nanoc); drawUnavailableMaterialRow("Abyssillite", 7); ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableSetColumnIndex(1); ImGui::TextUnformatted("Architect materials"); - drawMaterialRow("Alcarbonite", 1, Alcarbonite); - drawMaterialRow("Keriphene", 2, Keriphene); - drawMaterialRow("Nitinol-CM", 3, NitinolCM); - drawMaterialRow("Quarkium", 4, Quarkium); - drawMaterialRow("Alterene", 5, Alterene); - drawMaterialRow("Cosmium", 6, Cosmium); + drawMaterialRow("Alcarbonite", 1, GameData::MaterialID::Alcarbonite); + drawMaterialRow("Keriphene", 2, GameData::MaterialID::Keriphene); + drawMaterialRow("Nitinol-CM", 3, GameData::MaterialID::NitinolCM); + drawMaterialRow("Quarkium", 4, GameData::MaterialID::Quarkium); + drawMaterialRow("Alterene", 5, GameData::MaterialID::Alterene); + drawMaterialRow("Cosmium", 6, GameData::MaterialID::Cosmium); drawUnavailableMaterialRow("Purified quarkium", 7); ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableSetColumnIndex(1); ImGui::TextUnformatted("Quark data"); - drawMaterialRow("Mixed composition", 1, MixedComposition); - drawMaterialRow("Void residue", 2, VoidResidue); - drawMaterialRow("Muscular construction", 3, MuscularConstruction); - drawMaterialRow("Mineral exoskeletology", 4, MineralExoskeletology); - drawMaterialRow("Carbonized skin", 5, CarbonisedSkin); - drawMaterialRow("Isolated void particle", 6, IsolatedVoidParticle); + drawMaterialRow("Mixed composition", 1, GameData::MaterialID::MixedComposition); + drawMaterialRow("Void residue", 2, GameData::MaterialID::VoidResidue); + drawMaterialRow("Muscular construction", 3, GameData::MaterialID::MuscularConstruction); + drawMaterialRow("Mineral exoskeletology", 4, GameData::MaterialID::MineralExoskeletology); + drawMaterialRow("Carbonized skin", 5, GameData::MaterialID::CarbonisedSkin); + drawMaterialRow("Isolated void particle", 6, GameData::MaterialID::IsolatedVoidParticle); drawUnavailableMaterialRow("Weaponised physiology", 7); ImGui::EndTable(); @@ -353,7 +355,7 @@ SaveTool::drawResearchInventory() { } void -SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id) { +Application::drawMaterialRow(Containers::StringView name, std::int32_t tier, GameData::MaterialID id) { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); ImGui::Text("T%i", tier); @@ -380,7 +382,7 @@ SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, Materi } void -SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) { +Application::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); ImGui::Text("T%i", tier); @@ -391,7 +393,7 @@ SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t t } void -SaveTool::drawMassManager() { +Application::drawMassManager() { if(!_massManager) { return; } @@ -426,7 +428,7 @@ SaveTool::drawMassManager() { ImGui::TableSetColumnIndex(0); ImGui::Selectable(Utility::format("{:.2d}", i + 1).data(), false, ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap); - if(_massManager->hangar(i).state() == Mass::State::Valid && + if(_massManager->hangar(i).state() == GameObjects::Mass::State::Valid && ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceNoHoldToOpenOthers)) { drag_drop_index = i; @@ -440,7 +442,7 @@ SaveTool::drawMassManager() { if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("StagedMass")) { if(payload->DataSize != sizeof(Containers::String)) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal error", - "payload->DataSize != sizeof(Containers::String) in SaveTool::drawMassManager()", + "payload->DataSize != sizeof(Containers::String) in Application::drawMassManager()", window()); exit(EXIT_FAILURE); } @@ -454,7 +456,7 @@ SaveTool::drawMassManager() { else if((payload = ImGui::AcceptDragDropPayload("Mass"))) { if(payload->DataSize != sizeof(int)) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal error", - "payload->DataSize != sizeof(int) in SaveTool::drawMassManager()", + "payload->DataSize != sizeof(int) in Application::drawMassManager()", window()); exit(EXIT_FAILURE); } @@ -471,13 +473,13 @@ SaveTool::drawMassManager() { ImGui::TableSetColumnIndex(1); switch(_massManager->hangar(i).state()) { - case Mass::State::Empty: + case GameObjects::Mass::State::Empty: ImGui::TextDisabled(""); break; - case Mass::State::Invalid: + case GameObjects::Mass::State::Invalid: ImGui::TextDisabled(""); break; - case Mass::State::Valid: + case GameObjects::Mass::State::Valid: ImGui::TextUnformatted(_massManager->hangar(i).name().data()); break; } @@ -488,10 +490,10 @@ SaveTool::drawMassManager() { drawTooltip("This is the currently active frame slot."); } - if(_massManager->hangar(i).state() != Mass::State::Empty) { + if(_massManager->hangar(i).state() != GameObjects::Mass::State::Empty) { ImGui::TableSetColumnIndex(3); ImGui::PushID(i); - if(_massManager->hangar(i).state() == Mass::State::Valid) { + if(_massManager->hangar(i).state() == GameObjects::Mass::State::Valid) { if(ImGui::SmallButton(ICON_FA_SEARCH)) { _currentMass = &_massManager->hangar(i); _uiState = UiState::MassViewer; @@ -570,7 +572,7 @@ SaveTool::drawMassManager() { if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("Mass")) { if(payload->DataSize != sizeof(int)) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal error", - "payload->DataSize != sizeof(int) in SaveTool::drawMassManager()", + "payload->DataSize != sizeof(int) in Application::drawMassManager()", window()); exit(EXIT_FAILURE); } @@ -589,14 +591,14 @@ SaveTool::drawMassManager() { } ImGuiID -SaveTool::drawDeleteMassPopup(int mass_index) { +Application::drawDeleteMassPopup(int mass_index) { if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) { return ImGui::GetID("Confirmation##DeleteMassConfirmation"); } - if(_massManager->hangar(mass_index).state() == Mass::State::Empty) { + if(_massManager->hangar(mass_index).state() == GameObjects::Mass::State::Empty) { ImGui::CloseCurrentPopup(); ImGui::EndPopup(); return 0; @@ -609,7 +611,7 @@ SaveTool::drawDeleteMassPopup(int mass_index) { } ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f); - if(_massManager->hangar(mass_index).state() == Mass::State::Invalid) { + if(_massManager->hangar(mass_index).state() == GameObjects::Mass::State::Invalid) { ImGui::Text("Are you sure you want to delete the invalid M.A.S.S. data in hangar %.2i ? This operation is irreversible.", mass_index + 1); } @@ -646,7 +648,7 @@ SaveTool::drawDeleteMassPopup(int mass_index) { } ImGuiID -SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) { +Application::drawDeleteStagedMassPopup(Containers::StringView filename) { if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) { @@ -683,3 +685,5 @@ SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) { return 0; } + +} diff --git a/src/SaveTool/SaveTool_MassViewer.cpp b/src/Application/Application_MassViewer.cpp similarity index 92% rename from src/SaveTool/SaveTool_MassViewer.cpp rename to src/Application/Application_MassViewer.cpp index 4bb3da2..6af7887 100644 --- a/src/SaveTool/SaveTool_MassViewer.cpp +++ b/src/Application/Application_MassViewer.cpp @@ -25,11 +25,13 @@ #define STYLENAMES_DEFINITION #include "../Maps/StyleNames.h" -#include "SaveTool.h" +#include "Application.h" + +namespace mbst { void -SaveTool::drawMassViewer() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawMassViewer() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { _currentMass = nullptr; _currentWeapon = nullptr; _uiState = UiState::MainManager; @@ -156,8 +158,8 @@ SaveTool::drawMassViewer() { } void -SaveTool::drawGlobalStyles() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawGlobalStyles() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return; } @@ -193,8 +195,8 @@ SaveTool::drawGlobalStyles() { } void -SaveTool::drawTuning() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawTuning() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return; } @@ -289,9 +291,9 @@ SaveTool::drawTuning() { ImGui::EndTable(); } -SaveTool::DCSResult -SaveTool::drawCustomStyle(CustomStyle& style) { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::DCSResult +Application::drawCustomStyle(GameObjects::CustomStyle& style) { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return DCS_Fail; } @@ -396,7 +398,7 @@ SaveTool::drawCustomStyle(CustomStyle& style) { } void -SaveTool::drawDecalEditor(Decal& decal) { +Application::drawDecalEditor(GameObjects::Decal& decal) { ImGui::Text("ID: %i", decal.id); if(ImGui::BeginTable("##DecalTable", conf().advancedMode() ? 2 : 1, ImGuiTableFlags_BordersInnerV)) { @@ -501,12 +503,12 @@ SaveTool::drawDecalEditor(Decal& decal) { } void -SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView style_view) { +Application::drawAccessoryEditor(GameObjects::Accessory& accessory, Containers::ArrayView style_view) { if(accessory.id < 1) { ImGui::TextUnformatted("Accessory: "); } - else if(accessories.find(accessory.id) != accessories.cend()) { - ImGui::Text("Accessory #%.4i - %s", accessory.id, accessories.at(accessory.id).name.data()); + else if(GameData::accessories.find(accessory.id) != GameData::accessories.cend()) { + ImGui::Text("Accessory #%.4i - %s", accessory.id, GameData::accessories.at(accessory.id).name.data()); } else { ImGui::Text("Accessory #%i", accessory.id); @@ -516,7 +518,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView size = Containers::NullOpt; + static Containers::Optional size = Containers::NullOpt; if(ImGui::SmallButton("Change")) { ImGui::OpenPopup("##AccessoryPopup"); if(accessory.id >= 3000) { @@ -574,45 +576,45 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView= tab * 1000 && acc.first < ((tab + 1) * 1000) && (!size || *size == acc.second.size)) { if(ImGui::Selectable(Utility::format("#{:.4d} - {} ({})", acc.first, acc.second.name, size_labels[acc.second.size]).data(), acc.first == accessory.id)) @@ -658,7 +660,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView view) { +Application::getStyleName(std::int32_t id, Containers::ArrayView view) { if(id >= 0 && id <= 15) { return view[id].name; } @@ -748,6 +750,8 @@ SaveTool::getStyleName(std::int32_t id, Containers::ArrayView view) return _currentMass->globalStyles()[id - 50].name; } else { - return style_names.at(id); + return GameData::style_names.at(id); } } + +} diff --git a/src/SaveTool/SaveTool_MassViewer_Armour.cpp b/src/Application/Application_MassViewer_Armour.cpp similarity index 88% rename from src/SaveTool/SaveTool_MassViewer_Armour.cpp rename to src/Application/Application_MassViewer_Armour.cpp index 2733a78..769dcc3 100644 --- a/src/SaveTool/SaveTool_MassViewer_Armour.cpp +++ b/src/Application/Application_MassViewer_Armour.cpp @@ -19,11 +19,13 @@ #include "../Maps/ArmourSets.h" #include "../Maps/StyleNames.h" -#include "SaveTool.h" +#include "Application.h" + +namespace mbst { void -SaveTool::drawArmour() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawArmour() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return; } @@ -52,11 +54,17 @@ SaveTool::drawArmour() { std::memset(header, '\0', 129); - if(armour_sets.find(part.id) != armour_sets.cend()) { - std::snprintf(header, 128, "%s: %s###%u", slot_labels[std::uint32_t(part.slot)].data(), armour_sets.at(part.id).name.data(), std::uint32_t(part.slot)); + if(GameData::armour_sets.find(part.id) != GameData::armour_sets.cend()) { + std::snprintf(header, 128, "%s: %s###%u", + slot_labels[std::uint32_t(part.slot)].data(), + GameData::armour_sets.at(part.id).name.data(), + std::uint32_t(part.slot)); } else { - std::snprintf(header, 128, "%s: %i###%u", slot_labels[std::uint32_t(part.slot)].data(), part.id, std::uint32_t(part.slot)); + std::snprintf(header, 128, "%s: %i###%u", + slot_labels[std::uint32_t(part.slot)].data(), + part.id, + std::uint32_t(part.slot)); } if(ImGui::CollapsingHeader(header)) { @@ -65,14 +73,14 @@ SaveTool::drawArmour() { ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.491f); if(ImGui::BeginListBox("##ChangePart")) { if(std::strncmp("Neck", slot_labels[std::uint32_t(part.slot)].data(), 4) != 0) { - for(auto& set : armour_sets) { + for(auto& set : GameData::armour_sets) { if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) { part.id = set.first; } } } else { - for(auto& set : armour_sets) { + for(auto& set : GameData::armour_sets) { if(!set.second.neck_compatible) { continue; } @@ -106,7 +114,7 @@ SaveTool::drawArmour() { ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - 2.0f); if(ImGui::BeginCombo("##Style", getStyleName(part.styles[j], _currentMass->armourCustomStyles()).data())) { - for(const auto& style : style_names) { + for(const auto& style : GameData::style_names) { if(ImGui::Selectable(getStyleName(style.first, _currentMass->armourCustomStyles()).data(), part.styles[j] == style.first)) { part.styles[j] = style.first; } @@ -164,19 +172,19 @@ SaveTool::drawArmour() { ImGui::PopID(); } - if(_currentMass->bulletLauncherAttachmentStyle() != BulletLauncherAttachmentStyle::NotFound && + if(_currentMass->bulletLauncherAttachmentStyle() != GameObjects::BulletLauncherAttachmentStyle::NotFound && ImGui::CollapsingHeader("Bullet launcher placement")) { drawAlignedText("Attachment style:"_s); ImGui::SameLine(); ImGui::RadioButton("Active one", - _currentMass->bulletLauncherAttachmentStyle() == BulletLauncherAttachmentStyle::ActiveOne); + _currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::ActiveOne); ImGui::SameLine(); ImGui::RadioButton("Active one per slot", - _currentMass->bulletLauncherAttachmentStyle() == BulletLauncherAttachmentStyle::ActiveOnePerSlot); + _currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::ActiveOnePerSlot); ImGui::SameLine(); ImGui::RadioButton("All equipped", - _currentMass->bulletLauncherAttachmentStyle() == BulletLauncherAttachmentStyle::AllEquipped); + _currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::AllEquipped); ImGui::Separator(); @@ -203,13 +211,13 @@ SaveTool::drawArmour() { if(ImGui::BeginCombo("##Socket", socket_labels[std::uint32_t(placement.socket)].data())) { for(std::uint32_t i = 0; i < (sizeof(socket_labels) / sizeof(socket_labels[0])); i++) { if(ImGui::Selectable(socket_labels[i].data(), i == std::uint32_t(placement.socket), ImGuiSelectableFlags_SpanAvailWidth)) { - placement.socket = static_cast(i); + placement.socket = static_cast(i); } } ImGui::EndCombo(); } - if(placement.socket != BulletLauncherSocket::Auto) { + if(placement.socket != GameObjects::BulletLauncherAttachment::Socket::Auto) { ImGui::BeginGroup(); drawAlignedText("Relative position:"); drawAlignedText("Offset position:"); @@ -290,8 +298,8 @@ SaveTool::drawArmour() { } void -SaveTool::drawCustomArmourStyles() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawCustomArmourStyles() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return; } @@ -325,3 +333,5 @@ SaveTool::drawCustomArmourStyles() { ImGui::EndChild(); } + +} diff --git a/src/SaveTool/SaveTool_MassViewer_Frame.cpp b/src/Application/Application_MassViewer_Frame.cpp similarity index 93% rename from src/SaveTool/SaveTool_MassViewer_Frame.cpp rename to src/Application/Application_MassViewer_Frame.cpp index 7b93155..445b561 100644 --- a/src/SaveTool/SaveTool_MassViewer_Frame.cpp +++ b/src/Application/Application_MassViewer_Frame.cpp @@ -17,11 +17,13 @@ #include "../FontAwesome/IconsFontAwesome5.h" #include "../Maps/StyleNames.h" -#include "SaveTool.h" +#include "Application.h" + +namespace mbst { void -SaveTool::drawFrameInfo() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawFrameInfo() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return; } @@ -81,8 +83,8 @@ SaveTool::drawFrameInfo() { } void -SaveTool::drawJointSliders() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawJointSliders() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return; } @@ -204,8 +206,8 @@ SaveTool::drawJointSliders() { } void -SaveTool::drawFrameStyles() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawFrameStyles() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return; } @@ -217,7 +219,7 @@ SaveTool::drawFrameStyles() { ImGui::PushID(i); if(ImGui::BeginCombo("##Style", getStyleName(_currentMass->frameStyles()[i], _currentMass->frameCustomStyles()).data())) { - for(const auto& style : style_names) { + for(const auto& style : GameData::style_names) { if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()).data(), _currentMass->frameStyles()[i] == style.first)) { _currentMass->frameStyles()[i] = style.first; _stylesDirty = true; @@ -255,8 +257,8 @@ SaveTool::drawFrameStyles() { } void -SaveTool::drawEyeColourPicker() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawEyeColourPicker() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return; } @@ -289,8 +291,8 @@ SaveTool::drawEyeColourPicker() { } void -SaveTool::drawCustomFrameStyles() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawCustomFrameStyles() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { return; } @@ -324,3 +326,5 @@ SaveTool::drawCustomFrameStyles() { ImGui::EndChild(); } + +} diff --git a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp b/src/Application/Application_MassViewer_Weapons.cpp similarity index 79% rename from src/SaveTool/SaveTool_MassViewer_Weapons.cpp rename to src/Application/Application_MassViewer_Weapons.cpp index c60cdc9..6f56390 100644 --- a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp +++ b/src/Application/Application_MassViewer_Weapons.cpp @@ -19,11 +19,13 @@ #include "../Maps/StyleNames.h" #include "../Maps/WeaponParts.h" -#include "SaveTool.h" +#include "Application.h" + +namespace mbst { void -SaveTool::drawWeapons() { - if(!_currentMass || _currentMass->state() != Mass::State::Valid) { +Application::drawWeapons() { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) { _currentWeapon = nullptr; return; } @@ -179,37 +181,37 @@ SaveTool::drawWeapons() { if(drawUnsafeWidget([](){ return ImGui::Button(ICON_FA_SAVE " Save changes to weapon category"); })) { _modifiedBySaveTool = true; switch(_currentWeapon->type) { - case WeaponType::Melee: + case GameObjects::Weapon::Type::Melee: if(!_currentMass->writeMeleeWeapons()) { _modifiedBySaveTool = false; _queue.addToast(Toast::Type::Error, _currentMass->lastError()); } break; - case WeaponType::Shield: + case GameObjects::Weapon::Type::Shield: if(!_currentMass->writeShields()) { _modifiedBySaveTool = false; _queue.addToast(Toast::Type::Error, _currentMass->lastError()); } break; - case WeaponType::BulletShooter: + case GameObjects::Weapon::Type::BulletShooter: if(!_currentMass->writeBulletShooters()) { _modifiedBySaveTool = false; _queue.addToast(Toast::Type::Error, _currentMass->lastError()); } break; - case WeaponType::EnergyShooter: + case GameObjects::Weapon::Type::EnergyShooter: if(!_currentMass->writeEnergyShooters()) { _modifiedBySaveTool = false; _queue.addToast(Toast::Type::Error, _currentMass->lastError()); } break; - case WeaponType::BulletLauncher: + case GameObjects::Weapon::Type::BulletLauncher: if(!_currentMass->writeBulletLaunchers()) { _modifiedBySaveTool = false; _queue.addToast(Toast::Type::Error, _currentMass->lastError()); } break; - case WeaponType::EnergyLauncher: + case GameObjects::Weapon::Type::EnergyLauncher: if(!_currentMass->writeEnergyLaunchers()) { _modifiedBySaveTool = false; _queue.addToast(Toast::Type::Error, _currentMass->lastError()); @@ -225,22 +227,22 @@ SaveTool::drawWeapons() { if(ImGui::Button(ICON_FA_UNDO_ALT " Reset weapon category")) { switch(_currentWeapon->type) { - case WeaponType::Melee: + case GameObjects::Weapon::Type::Melee: _currentMass->getMeleeWeapons(); break; - case WeaponType::Shield: + case GameObjects::Weapon::Type::Shield: _currentMass->getShields(); break; - case WeaponType::BulletShooter: + case GameObjects::Weapon::Type::BulletShooter: _currentMass->getBulletShooters(); break; - case WeaponType::EnergyShooter: + case GameObjects::Weapon::Type::EnergyShooter: _currentMass->getEnergyShooters(); break; - case WeaponType::BulletLauncher: + case GameObjects::Weapon::Type::BulletLauncher: _currentMass->getBulletLaunchers(); break; - case WeaponType::EnergyLauncher: + case GameObjects::Weapon::Type::EnergyLauncher: _currentMass->getEnergyLaunchers(); break; default: @@ -252,7 +254,7 @@ SaveTool::drawWeapons() { } void -SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view, bool& dirty, +Application::drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view, bool& dirty, Containers::StringView payload_type, Containers::StringView payload_tooltip) { ImGui::TableNextRow(ImGuiTableRowFlags_Headers); @@ -316,8 +318,8 @@ SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView< } void -SaveTool::drawWeaponEditor(Weapon& weapon) { - if(!_currentMass || _currentMass->state() != Mass::State::Valid || !_currentWeapon) { +Application::drawWeaponEditor(GameObjects::Weapon& weapon) { + if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid || !_currentWeapon) { return; } @@ -346,11 +348,11 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { ImGui::BeginGroup(); drawAlignedText("Equipped:"); - if(weapon.type != WeaponType::Shield) { + if(weapon.type != GameObjects::Weapon::Type::Shield) { drawAlignedText("Damage type:"); } - if(weapon.type == WeaponType::Melee) { + if(weapon.type == GameObjects::Weapon::Type::Melee) { drawAlignedText("Dual-wield:"); drawAlignedText("Custom effect mode:"); @@ -364,48 +366,48 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { ImGui::BeginGroup(); ImGui::Checkbox("##EquippedCheckbox", &weapon.attached); - if(weapon.type != WeaponType::Shield) { - if(weapon.type == WeaponType::Melee && - ImGui::RadioButton("Physical##NoElement", weapon.damageType == DamageType::Physical)) + if(weapon.type != GameObjects::Weapon::Type::Shield) { + if(weapon.type == GameObjects::Weapon::Type::Melee && + ImGui::RadioButton("Physical##NoElement", weapon.damageType == GameObjects::Weapon::DamageType::Physical)) { - weapon.damageType = DamageType::Physical; + weapon.damageType = GameObjects::Weapon::DamageType::Physical; } - else if((weapon.type == WeaponType::BulletShooter || weapon.type == WeaponType::BulletLauncher) && - ImGui::RadioButton("Piercing##NoElement", weapon.damageType == DamageType::Piercing)) + else if((weapon.type == GameObjects::Weapon::Type::BulletShooter || weapon.type == GameObjects::Weapon::Type::BulletLauncher) && + ImGui::RadioButton("Piercing##NoElement", weapon.damageType == GameObjects::Weapon::DamageType::Piercing)) { - weapon.damageType = DamageType::Piercing; + weapon.damageType = GameObjects::Weapon::DamageType::Piercing; } - else if((weapon.type == WeaponType::EnergyShooter || weapon.type == WeaponType::EnergyLauncher) && - ImGui::RadioButton("Plasma##NoElement", weapon.damageType == DamageType::Plasma)) + else if((weapon.type == GameObjects::Weapon::Type::EnergyShooter || weapon.type == GameObjects::Weapon::Type::EnergyLauncher) && + ImGui::RadioButton("Plasma##NoElement", weapon.damageType == GameObjects::Weapon::DamageType::Plasma)) { - weapon.damageType = DamageType::Plasma; + weapon.damageType = GameObjects::Weapon::DamageType::Plasma; } ImGui::SameLine(); - if(ImGui::RadioButton("Heat##Heat", weapon.damageType == DamageType::Heat)) { - weapon.damageType = DamageType::Heat; + if(ImGui::RadioButton("Heat##Heat", weapon.damageType == GameObjects::Weapon::DamageType::Heat)) { + weapon.damageType = GameObjects::Weapon::DamageType::Heat; } ImGui::SameLine(); - if(ImGui::RadioButton("Freeze##Freeze", weapon.damageType == DamageType::Freeze)) { - weapon.damageType = DamageType::Freeze; + if(ImGui::RadioButton("Freeze##Freeze", weapon.damageType == GameObjects::Weapon::DamageType::Freeze)) { + weapon.damageType = GameObjects::Weapon::DamageType::Freeze; } ImGui::SameLine(); - if(ImGui::RadioButton("Shock##Shock", weapon.damageType == DamageType::Shock)) { - weapon.damageType = DamageType::Shock; + if(ImGui::RadioButton("Shock##Shock", weapon.damageType == GameObjects::Weapon::DamageType::Shock)) { + weapon.damageType = GameObjects::Weapon::DamageType::Shock; } } - if(weapon.type == WeaponType::Melee) { + if(weapon.type == GameObjects::Weapon::Type::Melee) { ImGui::Checkbox("##DualWield", &weapon.dualWield); - if(ImGui::RadioButton("Default##Default", weapon.effectColourMode == EffectColourMode::Default)) { - weapon.effectColourMode = EffectColourMode::Default; + if(ImGui::RadioButton("Default##Default", weapon.effectColourMode == GameObjects::Weapon::EffectColourMode::Default)) { + weapon.effectColourMode = GameObjects::Weapon::EffectColourMode::Default; } ImGui::SameLine(); - if(ImGui::RadioButton("Custom##Custom", weapon.effectColourMode == EffectColourMode::Custom)) { - weapon.effectColourMode = EffectColourMode::Custom; + if(ImGui::RadioButton("Custom##Custom", weapon.effectColourMode == GameObjects::Weapon::EffectColourMode::Custom)) { + weapon.effectColourMode = GameObjects::Weapon::EffectColourMode::Custom; } - bool custom_effect = (weapon.effectColourMode == EffectColourMode::Custom); + bool custom_effect = (weapon.effectColourMode == GameObjects::Weapon::EffectColourMode::Custom); if(!custom_effect) { ImGui::BeginDisabled(); } @@ -436,18 +438,18 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { const auto* map = [this, &weapon]()-> const std::map* { switch(weapon.type) { - case WeaponType::Melee: - return _selectedWeaponPart == 0 ? &melee_grips : &melee_assaulters; - case WeaponType::Shield: - return _selectedWeaponPart == 0 ? &shield_handles : &shield_shells; - case WeaponType::BulletShooter: - return _selectedWeaponPart == 0 ? &bshooter_triggers : &bshooter_barrels; - case WeaponType::EnergyShooter: - return _selectedWeaponPart == 0 ? &eshooter_triggers : &eshooter_busters; - case WeaponType::BulletLauncher: - return _selectedWeaponPart == 0 ? &blauncher_pods : &blauncher_projectiles; - case WeaponType::EnergyLauncher: - return _selectedWeaponPart == 0 ? &elauncher_generators : &elauncher_pods; + case GameObjects::Weapon::Type::Melee: + return _selectedWeaponPart == 0 ? &GameData::melee_grips : &GameData::melee_assaulters; + case GameObjects::Weapon::Type::Shield: + return _selectedWeaponPart == 0 ? &GameData::shield_handles : &GameData::shield_shells; + case GameObjects::Weapon::Type::BulletShooter: + return _selectedWeaponPart == 0 ? &GameData::bshooter_triggers : &GameData::bshooter_barrels; + case GameObjects::Weapon::Type::EnergyShooter: + return _selectedWeaponPart == 0 ? &GameData::eshooter_triggers : &GameData::eshooter_busters; + case GameObjects::Weapon::Type::BulletLauncher: + return _selectedWeaponPart == 0 ? &GameData::blauncher_pods : &GameData::blauncher_projectiles; + case GameObjects::Weapon::Type::EnergyLauncher: + return _selectedWeaponPart == 0 ? &GameData::elauncher_generators : &GameData::elauncher_pods; } return nullptr; @@ -489,14 +491,14 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { } } - if(weapon.type == WeaponType::Shield || - (weapon.type == WeaponType::BulletLauncher && _selectedWeaponPart != 0)) + if(weapon.type == GameObjects::Weapon::Type::Shield || + (weapon.type == GameObjects::Weapon::Type::BulletLauncher && _selectedWeaponPart != 0)) { ImGui::SameLine(); if(ImGui::SmallButton("Unequip")) { part.id = -1; } - if(weapon.type == WeaponType::Shield && _selectedWeaponPart == 0) { + if(weapon.type == GameObjects::Weapon::Type::Shield && _selectedWeaponPart == 0) { drawTooltip("This will make the whole shield and its accessories invisible."); } else { @@ -515,7 +517,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { ImGui::PushID(i); if(ImGui::BeginCombo("##Style", getStyleName(part.styles[i], weapon.customStyles).data())) { - for(const auto& style: style_names) { + for(const auto& style: GameData::style_names) { if(ImGui::Selectable(getStyleName(style.first, weapon.customStyles).data(), part.styles[i] == style.first)) { part.styles[i] = style.first; @@ -562,3 +564,5 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { ImGui::EndChild(); } } + +} diff --git a/src/SaveTool/SaveTool_ProfileManager.cpp b/src/Application/Application_ProfileManager.cpp similarity index 97% rename from src/SaveTool/SaveTool_ProfileManager.cpp rename to src/Application/Application_ProfileManager.cpp index cdeb37e..548a096 100644 --- a/src/SaveTool/SaveTool_ProfileManager.cpp +++ b/src/Application/Application_ProfileManager.cpp @@ -20,12 +20,14 @@ #include "../FontAwesome/IconsFontAwesome5.h" -#include "SaveTool.h" +#include "Application.h" extern const ImVec2 center_pivot; +namespace mbst { + void -SaveTool::drawProfileManager() { +Application::drawProfileManager() { static std::size_t profile_index = 0; ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot); @@ -81,7 +83,7 @@ SaveTool::drawProfileManager() { ImGui::TextUnformatted("Actions"); for(std::size_t i = 0; i < _profileManager->profiles().size(); ++i) { - Profile& profile = _profileManager->profiles()[i]; + GameObjects::Profile& profile = _profileManager->profiles()[i]; ImGui::TableNextRow(); @@ -127,7 +129,7 @@ SaveTool::drawProfileManager() { } ImGuiID -SaveTool::drawBackupListPopup() { +Application::drawBackupListPopup() { ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot); if(!ImGui::BeginPopupModal("Backups##BackupsModal", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) @@ -283,7 +285,7 @@ SaveTool::drawBackupListPopup() { backup.timestamp.second); ImGui::TableSetColumnIndex(2); - ImGui::TextUnformatted(backup.type == ProfileType::Demo ? "Demo" : "Full"); + ImGui::TextUnformatted(backup.demo ? "Demo" : "Full"); ImGui::TableSetColumnIndex(3); ImGui::PushID(int(i)); @@ -327,7 +329,7 @@ SaveTool::drawBackupListPopup() { } ImGuiID -SaveTool::drawBackupProfilePopup(std::size_t profile_index) { +Application::drawBackupProfilePopup(std::size_t profile_index) { if(!ImGui::BeginPopupModal("Include builds ?##IncludeBuildsDialog", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) { @@ -372,7 +374,7 @@ SaveTool::drawBackupProfilePopup(std::size_t profile_index) { } ImGuiID -SaveTool::drawDeleteProfilePopup(std::size_t profile_index) { +Application::drawDeleteProfilePopup(std::size_t profile_index) { if(!ImGui::BeginPopupModal("Confirmation##DeleteProfileConfirmation", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) { @@ -417,3 +419,5 @@ SaveTool::drawDeleteProfilePopup(std::size_t profile_index) { return 0; } + +} diff --git a/src/SaveTool/SaveTool_UpdateChecker.cpp b/src/Application/Application_UpdateChecker.cpp similarity index 96% rename from src/SaveTool/SaveTool_UpdateChecker.cpp rename to src/Application/Application_UpdateChecker.cpp index 4492f75..6fe63c1 100644 --- a/src/SaveTool/SaveTool_UpdateChecker.cpp +++ b/src/Application/Application_UpdateChecker.cpp @@ -20,10 +20,12 @@ #include "../Logger/Logger.h" -#include "SaveTool.h" +#include "Application.h" + +namespace mbst { void -SaveTool::updateCheckEvent(SDL_Event& event) { +Application::updateCheckEvent(SDL_Event& event) { _updateThread.join(); switch(static_cast(event.user.code)) { @@ -72,7 +74,7 @@ SaveTool::updateCheckEvent(SDL_Event& event) { } void -SaveTool::checkForUpdates() { +Application::checkForUpdates() { SDL_Event event; SDL_zero(event); event.type = _updateEventId; @@ -89,3 +91,5 @@ SaveTool::checkForUpdates() { SDL_PushEvent(&event); } + +} diff --git a/src/SaveTool/SaveTool_drawAbout.cpp b/src/Application/Application_drawAbout.cpp similarity index 98% rename from src/SaveTool/SaveTool_drawAbout.cpp rename to src/Application/Application_drawAbout.cpp index 1598e35..c68472d 100644 --- a/src/SaveTool/SaveTool_drawAbout.cpp +++ b/src/Application/Application_drawAbout.cpp @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "SaveTool.h" - #include #include @@ -29,10 +27,14 @@ #include "../FontAwesome/IconsFontAwesome5.h" #include "../FontAwesome/IconsFontAwesome5Brands.h" +#include "Application.h" + extern const ImVec2 center_pivot; +namespace mbst { + void -SaveTool::drawAbout() { +Application::drawAbout() { ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); ImGui::SetNextWindowSize({float(windowSize().x()) * 0.8f, float(windowSize().y()) * 0.75f}, ImGuiCond_Always); @@ -60,7 +62,7 @@ SaveTool::drawAbout() { ImGui::TextWrapped("This application, made for the M.A.S.S. Builder community by Guillaume Jacquemin (aka William JCM), " "is a rewrite of the wxWidgets-powered M.A.S.S. Builder Save Tool (formerly known as wxMASSManager)."); - auto website = "https://williamjcm.ovh/coding/mbst"; + auto website = "https://williamjcm.ovh/mbst"; drawAlignedText(ICON_FA_GLOBE " %s", website); ImGui::SameLine(); if(ImGui::Button("Copy to clipboard")) { @@ -267,3 +269,5 @@ SaveTool::drawAbout() { ImGui::EndPopup(); } + +} diff --git a/src/SaveTool/SaveTool_drawMainMenu.cpp b/src/Application/Application_drawMainMenu.cpp similarity index 99% rename from src/SaveTool/SaveTool_drawMainMenu.cpp rename to src/Application/Application_drawMainMenu.cpp index 46d930e..290e8cd 100644 --- a/src/SaveTool/SaveTool_drawMainMenu.cpp +++ b/src/Application/Application_drawMainMenu.cpp @@ -20,10 +20,12 @@ #include "../FontAwesome/IconsFontAwesome5.h" #include "../FontAwesome/IconsFontAwesome5Brands.h" -#include "SaveTool.h" +#include "Application.h" + +namespace mbst { void -SaveTool::drawMainMenu() { +Application::drawMainMenu() { if(!ImGui::BeginMainMenuBar()) { return; } @@ -239,3 +241,5 @@ SaveTool::drawMainMenu() { ImGui::EndMainMenuBar(); } + +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eebfbe4..f72df89 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,7 +37,7 @@ set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON) corrade_add_resource(Assets assets.conf) add_subdirectory(Logger EXCLUDE_FROM_ALL) -add_subdirectory(UESaveFile EXCLUDE_FROM_ALL) +add_subdirectory(Gvas EXCLUDE_FROM_ALL) if(CORRADE_TARGET_WINDOWS) set(SAVETOOL_RC_FILE resource.rc) @@ -45,19 +45,19 @@ endif() add_executable(MassBuilderSaveTool main.cpp - SaveTool/SaveTool.h - SaveTool/SaveTool.cpp - SaveTool/SaveTool_drawAbout.cpp - SaveTool/SaveTool_drawMainMenu.cpp - SaveTool/SaveTool_FileWatcher.cpp - SaveTool/SaveTool_Initialisation.cpp - SaveTool/SaveTool_MainManager.cpp - SaveTool/SaveTool_MassViewer.cpp - SaveTool/SaveTool_MassViewer_Frame.cpp - SaveTool/SaveTool_MassViewer_Armour.cpp - SaveTool/SaveTool_MassViewer_Weapons.cpp - SaveTool/SaveTool_ProfileManager.cpp - SaveTool/SaveTool_UpdateChecker.cpp + Application/Application.h + Application/Application.cpp + Application/Application_drawAbout.cpp + Application/Application_drawMainMenu.cpp + Application/Application_FileWatcher.cpp + Application/Application_Initialisation.cpp + Application/Application_MainManager.cpp + Application/Application_MassViewer.cpp + Application/Application_MassViewer_Frame.cpp + Application/Application_MassViewer_Armour.cpp + Application/Application_MassViewer_Weapons.cpp + Application/Application_ProfileManager.cpp + Application/Application_UpdateChecker.cpp Configuration/Configuration.h Configuration/Configuration.cpp ProfileManager/ProfileManager.h @@ -102,7 +102,9 @@ add_executable(MassBuilderSaveTool UpdateChecker/UpdateChecker.h UpdateChecker/UpdateChecker.cpp Utilities/Crc32.h + Utilities/Crc32.cpp Version/Version.h + Version/Version.cpp FontAwesome/IconsFontAwesome5.h FontAwesome/IconsFontAwesome5Brands.h ${SAVETOOL_RC_FILE} @@ -145,7 +147,7 @@ target_link_libraries(MassBuilderSaveTool PRIVATE Magnum::Sdl2Application MagnumIntegration::ImGui Logger - UESaveFile + Gvas CURL::libcurl_static ) diff --git a/src/Configuration/Configuration.cpp b/src/Configuration/Configuration.cpp index 12c5555..038b5c8 100644 --- a/src/Configuration/Configuration.cpp +++ b/src/Configuration/Configuration.cpp @@ -20,6 +20,8 @@ #include "Configuration.h" +namespace mbst { + Configuration::Configuration() { Containers::String exe_path = Utility::Path::split(*Utility::Path::executableLocation()).first(); _conf = Utility::Configuration{Utility::Path::join(exe_path, "MassBuilderSaveTool.ini")}; @@ -174,3 +176,5 @@ Configuration& conf() { return Configuration::instance(); } + +} diff --git a/src/Configuration/Configuration.h b/src/Configuration/Configuration.h index a685e30..c3be643 100644 --- a/src/Configuration/Configuration.h +++ b/src/Configuration/Configuration.h @@ -20,18 +20,20 @@ using namespace Corrade; +namespace mbst { + class Configuration { public: - static Configuration& instance(); + static auto instance() -> Configuration&; ~Configuration(); void save(); - int swapInterval() const; + auto swapInterval() const -> int; void setSwapInterval(int interval); - float fpsCap() const; + auto fpsCap() const -> float; void setFpsCap(float cap); bool cheatMode() const; @@ -54,14 +56,16 @@ class Configuration { Utility::Configuration _conf; - int _swapInterval = 1; + int _swapInterval = 1; float _fpsCap = 60.0f; - bool _cheatMode = false; - bool _advancedMode = false; - bool _checkUpdatesOnStartup = true; - bool _skipDisclaimer = false; + bool _cheatMode = false; + bool _advancedMode = false; + bool _checkUpdatesOnStartup = true; + bool _skipDisclaimer = false; bool _isRunningInWine = false; }; Configuration& conf(); + +} diff --git a/src/UESaveFile/BinaryReader.cpp b/src/Gvas/BinaryReader.cpp similarity index 99% rename from src/UESaveFile/BinaryReader.cpp rename to src/Gvas/BinaryReader.cpp index 131607d..91e69c8 100644 --- a/src/UESaveFile/BinaryReader.cpp +++ b/src/Gvas/BinaryReader.cpp @@ -23,6 +23,8 @@ #include "BinaryReader.h" +namespace Gvas { + BinaryReader::BinaryReader(Containers::StringView filename) { _file = std::fopen(filename.data(), "rb"); @@ -144,3 +146,5 @@ BinaryReader::peekChar() { std::ungetc(c, _file); return c; } + +} diff --git a/src/UESaveFile/BinaryReader.h b/src/Gvas/BinaryReader.h similarity index 95% rename from src/UESaveFile/BinaryReader.h rename to src/Gvas/BinaryReader.h index e04d711..d6c9d36 100644 --- a/src/UESaveFile/BinaryReader.h +++ b/src/Gvas/BinaryReader.h @@ -25,6 +25,8 @@ using namespace Corrade; +namespace Gvas { + class BinaryReader { public: explicit BinaryReader(Containers::StringView filename); @@ -32,7 +34,7 @@ class BinaryReader { bool open(); bool eof(); - std::int64_t position(); + auto position() -> std::int64_t; bool seek(std::int64_t position); @@ -63,8 +65,10 @@ class BinaryReader { bool readUEString(Containers::String& str); - std::int32_t peekChar(); + auto peekChar() -> std::int32_t; private: std::FILE* _file = nullptr; }; + +} diff --git a/src/UESaveFile/BinaryWriter.cpp b/src/Gvas/BinaryWriter.cpp similarity index 99% rename from src/UESaveFile/BinaryWriter.cpp rename to src/Gvas/BinaryWriter.cpp index ab0ebba..05a04e0 100644 --- a/src/UESaveFile/BinaryWriter.cpp +++ b/src/Gvas/BinaryWriter.cpp @@ -22,6 +22,8 @@ using namespace Containers::Literals; +namespace Gvas { + BinaryWriter::BinaryWriter(Containers::StringView filename) { _file = std::fopen(filename.data(), "wb"); if(!_file) { @@ -157,3 +159,5 @@ BinaryWriter::writeUEStringToArray(Containers::StringView value) { writeDataToArray(Containers::ArrayView{value}) + writeValueToArray('\0'); } + +} diff --git a/src/UESaveFile/BinaryWriter.h b/src/Gvas/BinaryWriter.h similarity index 89% rename from src/UESaveFile/BinaryWriter.h rename to src/Gvas/BinaryWriter.h index 3c11eed..7dfceba 100644 --- a/src/UESaveFile/BinaryWriter.h +++ b/src/Gvas/BinaryWriter.h @@ -26,6 +26,8 @@ using namespace Corrade; +namespace Gvas { + class BinaryWriter { public: explicit BinaryWriter(Containers::StringView filename); @@ -41,10 +43,10 @@ class BinaryWriter { void closeFile(); - std::int64_t position(); + auto position() -> std::int64_t; - Containers::ArrayView array() const; - std::size_t arrayPosition() const; + auto array() const -> Containers::ArrayView; + auto arrayPosition() const -> std::size_t; bool flushToFile(); bool writeChar(char value); @@ -72,12 +74,12 @@ class BinaryWriter { bool writeUEString(Containers::StringView str); template::value, T, T&>> - std::size_t writeValueToArray(U value) { + auto writeValueToArray(U value) -> std::size_t { Containers::ArrayView view{&value, 1}; return writeDataToArray(view); } - std::size_t writeUEStringToArray(Containers::StringView value); + auto writeUEStringToArray(Containers::StringView value) -> std::size_t; template void writeValueToArrayAt(T& value, std::size_t position) { @@ -86,7 +88,7 @@ class BinaryWriter { } template - std::size_t writeDataToArray(Containers::ArrayView view) { + auto writeDataToArray(Containers::ArrayView view) -> std::size_t { arrayAppend(_data, Containers::arrayCast(view)); _index += sizeof(T) * view.size(); return sizeof(T) * view.size(); @@ -106,3 +108,5 @@ class BinaryWriter { Containers::Array _data; std::size_t _index = 0; }; + +} diff --git a/src/Gvas/CMakeLists.txt b/src/Gvas/CMakeLists.txt new file mode 100644 index 0000000..c635c3c --- /dev/null +++ b/src/Gvas/CMakeLists.txt @@ -0,0 +1,102 @@ +# MassBuilderSaveTool +# Copyright (C) 2021-2023 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 . + +add_library(Gvas STATIC EXCLUDE_FROM_ALL + Serialisers/Serialisers.h + Serialisers/AbstractUnrealCollectionProperty.h + Serialisers/AbstractUnrealProperty.h + Serialisers/AbstractUnrealStruct.h + Serialisers/ArrayProperty.h + Serialisers/ArrayProperty.cpp + Serialisers/BoolProperty.h + Serialisers/BoolProperty.cpp + Serialisers/ByteProperty.h + Serialisers/ByteProperty.cpp + Serialisers/ColourProperty.h + Serialisers/ColourProperty.cpp + Serialisers/DateTimeProperty.h + Serialisers/DateTimeProperty.cpp + Serialisers/EnumProperty.h + Serialisers/EnumProperty.cpp + Serialisers/FloatProperty.h + Serialisers/FloatProperty.cpp + Serialisers/GuidProperty.h + Serialisers/GuidProperty.cpp + Serialisers/IntProperty.h + Serialisers/IntProperty.cpp + Serialisers/MapProperty.h + Serialisers/MapProperty.cpp + Serialisers/ResourceProperty.h + Serialisers/ResourceProperty.cpp + Serialisers/RotatorProperty.h + Serialisers/RotatorProperty.cpp + Serialisers/StringProperty.h + Serialisers/StringProperty.cpp + Serialisers/SetProperty.h + Serialisers/SetProperty.cpp + Serialisers/Struct.h + Serialisers/Struct.cpp + Serialisers/TextProperty.h + Serialisers/TextProperty.cpp + Serialisers/UnrealProperty.h + Serialisers/VectorProperty.h + Serialisers/VectorProperty.cpp + Serialisers/Vector2DProperty.h + Serialisers/Vector2DProperty.cpp + + Types/Types.h + Types/ArrayProperty.h + Types/BoolProperty.h + Types/ByteProperty.h + Types/ColourStructProperty.h + Types/DateTimeStructProperty.h + Types/EnumProperty.h + Types/FloatProperty.h + Types/GenericStructProperty.h + Types/GuidStructProperty.h + Types/IntProperty.h + Types/MapProperty.h + Types/NoneProperty.h + Types/RotatorStructProperty.h + Types/SetProperty.h + Types/StringProperty.h + Types/StructProperty.h + Types/ResourceItemValue.h + Types/TextProperty.h + Types/UnrealProperty.h + Types/UnrealPropertyBase.h + Types/Vector2DStructProperty.h + Types/VectorStructProperty.h + + Gvas.h + Debug.h + Debug.cpp + File.h + File.cpp + BinaryReader.h + BinaryReader.cpp + BinaryWriter.h + BinaryWriter.cpp + PropertySerialiser.h + PropertySerialiser.cpp +) + +target_link_libraries(Gvas PRIVATE + Corrade::Containers + Corrade::Utility + Magnum::Magnum + Logger +) diff --git a/src/UESaveFile/Debug.cpp b/src/Gvas/Debug.cpp similarity index 77% rename from src/UESaveFile/Debug.cpp rename to src/Gvas/Debug.cpp index 050fa4c..56f2141 100644 --- a/src/UESaveFile/Debug.cpp +++ b/src/Gvas/Debug.cpp @@ -23,19 +23,19 @@ #include "Debug.h" Utility::Debug& -operator<<(Utility::Debug& debug, const ArrayProperty* prop) { +operator<<(Utility::Debug& debug, const Gvas::Types::ArrayProperty* prop) { return debug << (*prop->name) << Utility::Debug::nospace << ":" << prop->propertyType << "of" << prop->items.size() << prop->itemType; } Utility::Debug& -operator<<(Utility::Debug& debug, const SetProperty* prop) { +operator<<(Utility::Debug& debug, const Gvas::Types::SetProperty* prop) { return debug << (*prop->name) << Utility::Debug::nospace << ":" << prop->propertyType << "of" << prop->items.size() << prop->itemType; } Utility::Debug& -operator<<(Utility::Debug& debug, const GenericStructProperty* prop) { +operator<<(Utility::Debug& debug, const Gvas::Types::GenericStructProperty* prop) { debug << (*prop->name) << Utility::Debug::nospace << ":" << prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace << ") Contents:"; @@ -46,8 +46,8 @@ operator<<(Utility::Debug& debug, const GenericStructProperty* prop) { } Utility::Debug& -operator<<(Utility::Debug& debug, const StructProperty* prop) { - auto cast = dynamic_cast(prop); +operator<<(Utility::Debug& debug, const Gvas::Types::StructProperty* prop) { + auto cast = dynamic_cast(prop); if(cast) { return debug << cast; } @@ -57,21 +57,21 @@ operator<<(Utility::Debug& debug, const StructProperty* prop) { } Utility::Debug& -operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop) { +operator<<(Utility::Debug& debug, const Gvas::Types::UnrealPropertyBase* prop) { if(prop->propertyType == "ArrayProperty") { - auto array_prop = dynamic_cast(prop); + auto array_prop = dynamic_cast(prop); if(array_prop) { return debug << array_prop; } } else if(prop->propertyType == "SetProperty") { - auto set_prop = dynamic_cast(prop); + auto set_prop = dynamic_cast(prop); if(set_prop) { return debug << set_prop; } } else if(prop->propertyType == "StructProperty") { - auto struct_prop = dynamic_cast(prop); + auto struct_prop = dynamic_cast(prop); if(struct_prop) { return debug << struct_prop; } diff --git a/src/Gvas/Debug.h b/src/Gvas/Debug.h new file mode 100644 index 0000000..55dacd2 --- /dev/null +++ b/src/Gvas/Debug.h @@ -0,0 +1,29 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2023 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 . + +#include + +#include "Types/Types.h" + +using namespace Corrade; + +Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::ArrayProperty* prop); +Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::SetProperty* prop); +Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::GenericStructProperty* prop); +Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::StructProperty* prop); +Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::UnrealPropertyBase* prop); diff --git a/src/UESaveFile/UESaveFile.cpp b/src/Gvas/File.cpp similarity index 93% rename from src/UESaveFile/UESaveFile.cpp rename to src/Gvas/File.cpp index af44e10..c9b9d24 100644 --- a/src/UESaveFile/UESaveFile.cpp +++ b/src/Gvas/File.cpp @@ -17,15 +17,18 @@ #include #include -#include "BinaryReader.h" -#include "BinaryWriter.h" #include "../Logger/Logger.h" -#include "UESaveFile.h" +#include "BinaryReader.h" +#include "BinaryWriter.h" + +#include "File.h" using namespace Containers::Literals; -UESaveFile::UESaveFile(Containers::String filepath): +namespace Gvas { + +File::File(Containers::String filepath): _propSerialiser{PropertySerialiser::instance()} { _filepath = std::move(filepath); @@ -34,46 +37,46 @@ UESaveFile::UESaveFile(Containers::String filepath): } bool -UESaveFile::valid() const { +File::valid() const { return _valid; } Containers::StringView -UESaveFile::lastError() const { +File::lastError() const { return _lastError; } bool -UESaveFile::reloadData() { +File::reloadData() { if(_noReloadAfterSave) { _noReloadAfterSave = false; return valid(); } - _properties = Containers::Array{}; + _properties = Containers::Array{}; loadData(); return valid(); } Containers::StringView -UESaveFile::saveType() { +File::saveType() { return _saveType; } void -UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) { +File::appendProperty(Types::UnrealPropertyBase::ptr prop) { auto none_prop = std::move(_properties.back()); _properties.back() = std::move(prop); arrayAppend(_properties, std::move(none_prop)); } -Containers::ArrayView -UESaveFile::props() { +Containers::ArrayView +File::props() { return _properties; } bool -UESaveFile::saveToFile() { +File::saveToFile() { LOG_INFO_FORMAT("Writing to {}.", _filepath); bool temp_file = _filepath.hasSuffix(".tmp"); @@ -161,7 +164,7 @@ UESaveFile::saveToFile() { } void -UESaveFile::loadData() { +File::loadData() { LOG_INFO_FORMAT("Reading data from {}.", _filepath); _valid = false; @@ -244,7 +247,7 @@ UESaveFile::loadData() { return; } - UnrealPropertyBase::ptr prop; + Types::UnrealPropertyBase::ptr prop; while((prop = _propSerialiser->read(reader)) != nullptr) { arrayAppend(_properties, std::move(prop)); } @@ -265,3 +268,5 @@ UESaveFile::loadData() { _valid = true; } + +} diff --git a/src/UESaveFile/UESaveFile.h b/src/Gvas/File.h similarity index 83% rename from src/UESaveFile/UESaveFile.h rename to src/Gvas/File.h index 7aa72f2..0af071c 100644 --- a/src/UESaveFile/UESaveFile.h +++ b/src/Gvas/File.h @@ -29,19 +29,21 @@ using namespace Corrade; -class UESaveFile { +namespace Gvas { + +class File { public: - explicit UESaveFile(Containers::String filepath); + explicit File(Containers::String filepath); bool valid() const; - Containers::StringView lastError() const; + auto lastError() const -> Containers::StringView; bool reloadData(); - Containers::StringView saveType(); + auto saveType() -> Containers::StringView; template - std::enable_if_t::value, T*> + std::enable_if_t::value, T*> at(Containers::StringView name) { for(auto& prop : _properties) { if(prop->name == name) { @@ -51,9 +53,9 @@ class UESaveFile { return nullptr; } - void appendProperty(UnrealPropertyBase::ptr prop); + void appendProperty(Types::UnrealPropertyBase::ptr prop); - Containers::ArrayView props(); + auto props() -> Containers::ArrayView; bool saveToFile(); @@ -88,7 +90,9 @@ class UESaveFile { Containers::String _saveType; - Containers::Array _properties; + Containers::Array _properties; Containers::Reference _propSerialiser; }; + +} diff --git a/src/Gvas/Gvas.h b/src/Gvas/Gvas.h new file mode 100644 index 0000000..fad929c --- /dev/null +++ b/src/Gvas/Gvas.h @@ -0,0 +1,26 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2023 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 . + +namespace Gvas { + +class BinaryReader; +class BinaryWriter; +class File; +class PropertySerialiser; + +} diff --git a/src/UESaveFile/PropertySerialiser.cpp b/src/Gvas/PropertySerialiser.cpp similarity index 64% rename from src/UESaveFile/PropertySerialiser.cpp rename to src/Gvas/PropertySerialiser.cpp index 1e89498..2aa5c10 100644 --- a/src/UESaveFile/PropertySerialiser.cpp +++ b/src/Gvas/PropertySerialiser.cpp @@ -16,55 +16,57 @@ #include -#include "Serialisers/ArrayPropertySerialiser.h" -#include "Serialisers/BoolPropertySerialiser.h" -#include "Serialisers/BytePropertySerialiser.h" -#include "Serialisers/ColourPropertySerialiser.h" -#include "Serialisers/DateTimePropertySerialiser.h" -#include "Serialisers/EnumPropertySerialiser.h" -#include "Serialisers/FloatPropertySerialiser.h" -#include "Serialisers/GuidPropertySerialiser.h" -#include "Serialisers/IntPropertySerialiser.h" -#include "Serialisers/MapPropertySerialiser.h" -#include "Serialisers/ResourcePropertySerialiser.h" -#include "Serialisers/RotatorPropertySerialiser.h" -#include "Serialisers/StringPropertySerialiser.h" -#include "Serialisers/SetPropertySerialiser.h" -#include "Serialisers/StructSerialiser.h" -#include "Serialisers/TextPropertySerialiser.h" -#include "Serialisers/VectorPropertySerialiser.h" -#include "Serialisers/Vector2DPropertySerialiser.h" +#include "../Logger/Logger.h" + +#include "Serialisers/ArrayProperty.h" +#include "Serialisers/BoolProperty.h" +#include "Serialisers/ByteProperty.h" +#include "Serialisers/ColourProperty.h" +#include "Serialisers/DateTimeProperty.h" +#include "Serialisers/EnumProperty.h" +#include "Serialisers/FloatProperty.h" +#include "Serialisers/GuidProperty.h" +#include "Serialisers/IntProperty.h" +#include "Serialisers/MapProperty.h" +#include "Serialisers/ResourceProperty.h" +#include "Serialisers/RotatorProperty.h" +#include "Serialisers/StringProperty.h" +#include "Serialisers/SetProperty.h" +#include "Serialisers/Struct.h" +#include "Serialisers/TextProperty.h" +#include "Serialisers/VectorProperty.h" +#include "Serialisers/Vector2DProperty.h" #include "Types/NoneProperty.h" #include "BinaryReader.h" #include "BinaryWriter.h" -#include "../Logger/Logger.h" - #include "PropertySerialiser.h" -PropertySerialiser::PropertySerialiser() { - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); - arrayAppend(_serialisers, Containers::pointer()); +namespace Gvas { - arrayAppend(_collectionSerialisers, Containers::pointer()); +PropertySerialiser::PropertySerialiser() { + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + arrayAppend(_serialisers, Containers::pointer()); + + arrayAppend(_collectionSerialisers, Containers::pointer()); } PropertySerialiser& @@ -73,7 +75,7 @@ PropertySerialiser::instance() { return serialiser; } -UnrealPropertyBase::ptr +Types::UnrealPropertyBase::ptr PropertySerialiser::read(BinaryReader& reader) { if(reader.peekChar() < 0 || reader.eof()) { return nullptr; @@ -85,7 +87,7 @@ PropertySerialiser::read(BinaryReader& reader) { } if(name == "None") { - return Containers::pointer(); + return Containers::pointer(); } Containers::String type; @@ -101,7 +103,7 @@ PropertySerialiser::read(BinaryReader& reader) { return deserialise(std::move(name), std::move(type), value_length, reader); } -UnrealPropertyBase::ptr +Types::UnrealPropertyBase::ptr PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, std::size_t value_length, Containers::String name) { @@ -112,7 +114,7 @@ PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, std: return deserialise(std::move(name), std::move(type), value_length, reader); } -Containers::Array +Containers::Array PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, std::uint32_t count) { if(reader.peekChar() < 0 || reader.eof()) { return nullptr; @@ -120,7 +122,7 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty auto serialiser = getCollectionSerialiser(item_type); - Containers::Array array; + Containers::Array array; if(serialiser) { Containers::String name; @@ -156,11 +158,11 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty return array; } -UnrealPropertyBase::ptr +Types::UnrealPropertyBase::ptr PropertySerialiser::deserialise(Containers::String name, Containers::String type, std::size_t value_length, BinaryReader& reader) { - UnrealPropertyBase::ptr prop; + Types::UnrealPropertyBase::ptr prop; auto serialiser = getSerialiser(type); if(serialiser == nullptr) { @@ -180,7 +182,7 @@ PropertySerialiser::deserialise(Containers::String name, Containers::String type return prop; } -bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, +bool PropertySerialiser::serialise(Types::UnrealPropertyBase::ptr& prop, Containers::StringView item_type, std::size_t& bytes_written, BinaryWriter& writer) { auto serialiser = getSerialiser(item_type); @@ -191,8 +193,8 @@ bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St } bool -PropertySerialiser::write(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer) { - if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) { +PropertySerialiser::write(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer) { + if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) { bytes_written += writer.writeUEStringToArray(*prop->name); return true; } @@ -215,10 +217,10 @@ PropertySerialiser::write(UnrealPropertyBase::ptr& prop, std::size_t& bytes_writ } bool -PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, +PropertySerialiser::writeItem(Types::UnrealPropertyBase::ptr& prop, Containers::StringView item_type, std::size_t& bytes_written, BinaryWriter& writer) { - if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) { + if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) { bytes_written += writer.writeUEStringToArray(*prop->name); return true; } @@ -226,7 +228,7 @@ PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringV return serialise(prop, item_type, bytes_written, writer); } -bool PropertySerialiser::writeSet(Containers::ArrayView props, +bool PropertySerialiser::writeSet(Containers::ArrayView props, Containers::StringView item_type, std::size_t& bytes_written, BinaryWriter& writer) { auto serialiser = getCollectionSerialiser(item_type); @@ -244,7 +246,7 @@ bool PropertySerialiser::writeSet(Containers::ArrayView } } -AbstractUnrealPropertySerialiser* +Serialisers::AbstractUnrealProperty* PropertySerialiser::getSerialiser(Containers::StringView item_type) { for(auto& item : _serialisers) { for(auto serialiser_type : item->types()) { @@ -257,7 +259,7 @@ PropertySerialiser::getSerialiser(Containers::StringView item_type) { return nullptr; } -AbstractUnrealCollectionPropertySerialiser* +Serialisers::AbstractUnrealCollectionProperty* PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) { for(auto& item : _collectionSerialisers) { for(Containers::StringView serialiser_type : item->types()) { @@ -269,3 +271,5 @@ PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) { return nullptr; } + +} diff --git a/src/Gvas/PropertySerialiser.h b/src/Gvas/PropertySerialiser.h new file mode 100644 index 0000000..79889d9 --- /dev/null +++ b/src/Gvas/PropertySerialiser.h @@ -0,0 +1,64 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2023 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 . + +#include +#include +#include + +#include "Serialisers/AbstractUnrealProperty.h" +#include "Serialisers/AbstractUnrealCollectionProperty.h" + +#include "Types/UnrealPropertyBase.h" + +#include "Gvas.h" + +using namespace Corrade; + +namespace Gvas { + +class PropertySerialiser { + public: + static auto instance() -> PropertySerialiser&; + + auto read(BinaryReader& reader) -> Types::UnrealPropertyBase::ptr; + auto readItem(BinaryReader& reader, Containers::String type, std::size_t value_length, Containers::String name) + -> Types::UnrealPropertyBase::ptr; + auto readSet(BinaryReader& reader, Containers::StringView item_type, std::uint32_t count) + -> Containers::Array; + auto deserialise(Containers::String name, Containers::String type, std::size_t value_length, + BinaryReader& reader) -> Types::UnrealPropertyBase::ptr; + + bool serialise(Types::UnrealPropertyBase::ptr& prop, Containers::StringView item_type, + std::size_t& bytes_written, BinaryWriter& writer); + bool write(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer); + bool writeItem(Types::UnrealPropertyBase::ptr& prop, Containers::StringView item_type, + std::size_t& bytes_written, BinaryWriter& writer); + bool writeSet(Containers::ArrayView props, Containers::StringView item_type, + std::size_t& bytes_written, BinaryWriter& writer); + + private: + PropertySerialiser(); + + auto getSerialiser(Containers::StringView item_type) -> Serialisers::AbstractUnrealProperty*; + auto getCollectionSerialiser(Containers::StringView item_type) -> Serialisers::AbstractUnrealCollectionProperty*; + + Containers::Array _serialisers; + Containers::Array _collectionSerialisers; +}; + +} diff --git a/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h b/src/Gvas/Serialisers/AbstractUnrealCollectionProperty.h similarity index 58% rename from src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h rename to src/Gvas/Serialisers/AbstractUnrealCollectionProperty.h index 4a974ab..8d7a390 100644 --- a/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h +++ b/src/Gvas/Serialisers/AbstractUnrealCollectionProperty.h @@ -21,29 +21,31 @@ #include #include +#include "../Gvas.h" #include "../Types/UnrealPropertyBase.h" using namespace Corrade; -class BinaryReader; -class BinaryWriter; -class PropertySerialiser; +namespace Gvas { namespace Serialisers { -using PropertyArray = Containers::Array; -using PropertyArrayView = Containers::ArrayView; +using PropertyArray = Containers::Array; +using PropertyArrayView = Containers::ArrayView; +using StringArrayView = Containers::ArrayView; -class AbstractUnrealCollectionPropertySerialiser { +class AbstractUnrealCollectionProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; - virtual ~AbstractUnrealCollectionPropertySerialiser() = default; + virtual ~AbstractUnrealCollectionProperty() = default; - virtual StringArrayView types() = 0; + virtual auto types() -> StringArrayView = 0; - virtual PropertyArray deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, std::uint32_t count, BinaryReader& reader, - PropertySerialiser& serialiser) = 0; + virtual auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser) + -> PropertyArray = 0; - virtual bool serialise(Containers::ArrayView props, Containers::StringView item_type, + virtual bool serialise(PropertyArrayView props, Containers::StringView item_type, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) = 0; }; + +}} diff --git a/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h b/src/Gvas/Serialisers/AbstractUnrealProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h rename to src/Gvas/Serialisers/AbstractUnrealProperty.h index 6b2e615..11c8359 100644 --- a/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h +++ b/src/Gvas/Serialisers/AbstractUnrealProperty.h @@ -20,28 +20,30 @@ #include #include +#include "../Gvas.h" #include "../Types/UnrealPropertyBase.h" using namespace Corrade; -class BinaryReader; -class BinaryWriter; -class PropertySerialiser; + +namespace Gvas { namespace Serialisers { using StringArrayView = Containers::ArrayView; -class AbstractUnrealPropertySerialiser { +class AbstractUnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; - virtual ~AbstractUnrealPropertySerialiser() = default; + virtual ~AbstractUnrealProperty() = default; - virtual StringArrayView types() = 0; + virtual auto types() -> StringArrayView = 0; - virtual UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) = 0; + virtual auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr = 0; - virtual bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + virtual bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) = 0; }; + +}} diff --git a/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h b/src/Gvas/Serialisers/AbstractUnrealStruct.h similarity index 69% rename from src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h rename to src/Gvas/Serialisers/AbstractUnrealStruct.h index 57e79d7..e08dfc9 100644 --- a/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h +++ b/src/Gvas/Serialisers/AbstractUnrealStruct.h @@ -21,22 +21,25 @@ #include #include +#include "../Gvas.h" #include "../Types/UnrealPropertyBase.h" using namespace Corrade; -class BinaryReader; -class BinaryWriter; +namespace Gvas { namespace Serialisers { -class AbstractUnrealStructSerialiser { +class AbstractUnrealStruct { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; - virtual ~AbstractUnrealStructSerialiser() = default; + virtual ~AbstractUnrealStruct() = default; virtual bool supportsType(Containers::StringView type) = 0; - virtual UnrealPropertyBase::ptr deserialise(BinaryReader& reader) = 0; + virtual auto deserialise(BinaryReader& reader) -> Types::UnrealPropertyBase::ptr = 0; - virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, std::size_t& bytes_written) = 0; + virtual bool serialise(Types::UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, + std::size_t& bytes_written) = 0; }; + +}} diff --git a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp b/src/Gvas/Serialisers/ArrayProperty.cpp similarity index 77% rename from src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp rename to src/Gvas/Serialisers/ArrayProperty.cpp index ed412af..83829ae 100644 --- a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/ArrayProperty.cpp @@ -21,12 +21,13 @@ #include "../PropertySerialiser.h" #include "../../Logger/Logger.h" -#include "ArrayPropertySerialiser.h" +#include "ArrayProperty.h" -UnrealPropertyBase::ptr -ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +ArrayProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { Containers::String item_type; if(!reader.readUEString(item_type)) { @@ -46,7 +47,7 @@ ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Contai return nullptr; } - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); prop->itemType = std::move(item_type); prop->items = serialiser.readSet(reader, prop->itemType, item_count); @@ -54,10 +55,10 @@ ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Contai } bool -ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +ArrayProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto array_prop = dynamic_cast(prop.get()); + auto array_prop = dynamic_cast(prop.get()); if(!array_prop) { LOG_ERROR("The property is not a valid array property."); return false; @@ -74,3 +75,5 @@ ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::s return ret; } + +}} diff --git a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h b/src/Gvas/Serialisers/ArrayProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/ArrayPropertySerialiser.h rename to src/Gvas/Serialisers/ArrayProperty.h index 6f6b741..6f50b95 100644 --- a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h +++ b/src/Gvas/Serialisers/ArrayProperty.h @@ -18,20 +18,24 @@ #include -#include "UnrealPropertySerialiser.h" - +#include "../Gvas.h" +#include "UnrealProperty.h" #include "../Types/ArrayProperty.h" using namespace Corrade; -class ArrayPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class ArrayProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp b/src/Gvas/Serialisers/BoolProperty.cpp similarity index 74% rename from src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp rename to src/Gvas/Serialisers/BoolProperty.cpp index 8e2c1ea..c67e6ec 100644 --- a/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/BoolProperty.cpp @@ -18,18 +18,20 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "BoolPropertySerialiser.h" +#include "BoolProperty.h" + +namespace Gvas { namespace Serialisers { StringArrayView -BoolPropertySerialiser::types() { +BoolProperty::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"BoolProperty"_s}}; return types; } -UnrealPropertyBase::ptr -BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, - BinaryReader& reader, PropertySerialiser& serialiser) +Types::UnrealPropertyBase::ptr +BoolProperty::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { if(value_length != 0) { LOG_ERROR_FORMAT("Invalid value length for bool property {}. Expected 0, got {} instead.", name, value_length); @@ -47,17 +49,17 @@ BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::Str return nullptr; } - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); prop->value = value; return prop; } bool -BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) +BoolProperty::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto bool_prop = dynamic_cast(prop.get()); + auto bool_prop = dynamic_cast(prop.get()); if(!bool_prop) { LOG_ERROR("The property is not a valid bool property."); return false; @@ -67,3 +69,5 @@ BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& by return true; } + +}} diff --git a/src/UESaveFile/Serialisers/BoolPropertySerialiser.h b/src/Gvas/Serialisers/BoolProperty.h similarity index 61% rename from src/UESaveFile/Serialisers/BoolPropertySerialiser.h rename to src/Gvas/Serialisers/BoolProperty.h index 6e41afc..58171e4 100644 --- a/src/UESaveFile/Serialisers/BoolPropertySerialiser.h +++ b/src/Gvas/Serialisers/BoolProperty.h @@ -19,22 +19,26 @@ #include #include -#include "AbstractUnrealPropertySerialiser.h" +#include "AbstractUnrealProperty.h" #include "../Types/BoolProperty.h" using namespace Corrade; -class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class BoolProperty : public AbstractUnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; - StringArrayView types() override; + auto types() -> StringArrayView override; - UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; + auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; - bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp b/src/Gvas/Serialisers/ByteProperty.cpp similarity index 82% rename from src/UESaveFile/Serialisers/BytePropertySerialiser.cpp rename to src/Gvas/Serialisers/ByteProperty.cpp index 45b7934..1463798 100644 --- a/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp +++ b/src/Gvas/Serialisers/ByteProperty.cpp @@ -18,20 +18,22 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "BytePropertySerialiser.h" +#include "ByteProperty.h" + +namespace Gvas { namespace Serialisers { StringArrayView -BytePropertySerialiser::types() { +ByteProperty::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"ByteProperty"_s}}; return types; } -UnrealPropertyBase::ptr -BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, +Types::UnrealPropertyBase::ptr +ByteProperty::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(value_length != std::size_t(-1)) { if(!reader.readUEString(prop->enumType)) { @@ -66,10 +68,10 @@ BytePropertySerialiser::deserialise(Containers::StringView name, Containers::Str } bool -BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) +ByteProperty::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto byte_prop = dynamic_cast(prop.get()); + auto byte_prop = dynamic_cast(prop.get()); if(!byte_prop) { LOG_ERROR("The property is not a valid byte property."); return false; @@ -88,3 +90,5 @@ BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& by return true; } + +}} diff --git a/src/UESaveFile/Serialisers/BytePropertySerialiser.h b/src/Gvas/Serialisers/ByteProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/BytePropertySerialiser.h rename to src/Gvas/Serialisers/ByteProperty.h index fb2b2d4..adb4201 100644 --- a/src/UESaveFile/Serialisers/BytePropertySerialiser.h +++ b/src/Gvas/Serialisers/ByteProperty.h @@ -19,20 +19,24 @@ #include #include -#include "AbstractUnrealPropertySerialiser.h" +#include "AbstractUnrealProperty.h" #include "../Types/ByteProperty.h" -class BytePropertySerialiser : public AbstractUnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class ByteProperty : public AbstractUnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; - StringArrayView types() override; + auto types() -> StringArrayView override; - UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; + auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; - bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp b/src/Gvas/Serialisers/ColourProperty.cpp similarity index 69% rename from src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp rename to src/Gvas/Serialisers/ColourProperty.cpp index 9e5cd9a..1af0ea1 100644 --- a/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/ColourProperty.cpp @@ -18,14 +18,15 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "ColourPropertySerialiser.h" +#include "ColourProperty.h" -UnrealPropertyBase::ptr -ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +ColourProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(!reader.readFloat(prop->r) || !reader.readFloat(prop->g) || !reader.readFloat(prop->b) || !reader.readFloat(prop->a)) @@ -38,10 +39,10 @@ ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Conta } bool -ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +ColourProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { - auto colour_prop = dynamic_cast(prop.get()); + auto colour_prop = dynamic_cast(prop.get()); if(!colour_prop) { LOG_ERROR("The property is not a valid colour property."); return false; @@ -54,3 +55,5 @@ ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std:: return true; } + +}} diff --git a/src/UESaveFile/Serialisers/ColourPropertySerialiser.h b/src/Gvas/Serialisers/ColourProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/ColourPropertySerialiser.h rename to src/Gvas/Serialisers/ColourProperty.h index 812f7a9..173c6f2 100644 --- a/src/UESaveFile/Serialisers/ColourPropertySerialiser.h +++ b/src/Gvas/Serialisers/ColourProperty.h @@ -18,20 +18,24 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/ColourStructProperty.h" using namespace Corrade; -class ColourPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class ColourProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp b/src/Gvas/Serialisers/DateTimeProperty.cpp similarity index 64% rename from src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp rename to src/Gvas/Serialisers/DateTimeProperty.cpp index 9724dfb..1be9685 100644 --- a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp +++ b/src/Gvas/Serialisers/DateTimeProperty.cpp @@ -18,14 +18,15 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "DateTimePropertySerialiser.h" +#include "DateTimeProperty.h" -UnrealPropertyBase::ptr -DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +DateTimeProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(!reader.readInt64(prop->timestamp)) { LOG_ERROR_FORMAT("Couldn't read date/time property {}'s value.", name); @@ -36,10 +37,10 @@ DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Con } bool -DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +DateTimeProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { - auto dt_prop = dynamic_cast(prop.get()); + auto dt_prop = dynamic_cast(prop.get()); if(!dt_prop) { LOG_ERROR("The property is not a valid date/time property."); return false; @@ -49,3 +50,5 @@ DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std return true; } + +}} diff --git a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h b/src/Gvas/Serialisers/DateTimeProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/DateTimePropertySerialiser.h rename to src/Gvas/Serialisers/DateTimeProperty.h index 68f2476..ca604a2 100644 --- a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h +++ b/src/Gvas/Serialisers/DateTimeProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/DateTimeStructProperty.h" -class DateTimePropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class DateTimeProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp b/src/Gvas/Serialisers/EnumProperty.cpp similarity index 74% rename from src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp rename to src/Gvas/Serialisers/EnumProperty.cpp index f7e1246..4e8125a 100644 --- a/src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/EnumProperty.cpp @@ -18,20 +18,22 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "EnumPropertySerialiser.h" +#include "EnumProperty.h" + +namespace Gvas { namespace Serialisers { StringArrayView -EnumPropertySerialiser::types() { +EnumProperty::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"EnumProperty"_s}}; return types; } -UnrealPropertyBase::ptr -EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, - BinaryReader& reader, PropertySerialiser& serialiser) +Types::UnrealPropertyBase::ptr +EnumProperty::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(!reader.readUEString(prop->enumType)) { LOG_ERROR_FORMAT("Couldn't read enum property {}'s enum type.", name); @@ -53,10 +55,10 @@ EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::Str } bool -EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) +EnumProperty::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto enum_prop = dynamic_cast(prop.get()); + auto enum_prop = dynamic_cast(prop.get()); if(!enum_prop) { LOG_ERROR("The property is not a valid enum property."); return false; @@ -68,3 +70,5 @@ EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& by return true; } + +}} diff --git a/src/UESaveFile/Serialisers/EnumPropertySerialiser.h b/src/Gvas/Serialisers/EnumProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/EnumPropertySerialiser.h rename to src/Gvas/Serialisers/EnumProperty.h index 077eeae..be1ade7 100644 --- a/src/UESaveFile/Serialisers/EnumPropertySerialiser.h +++ b/src/Gvas/Serialisers/EnumProperty.h @@ -19,20 +19,24 @@ #include #include -#include "AbstractUnrealPropertySerialiser.h" +#include "AbstractUnrealProperty.h" #include "../Types/EnumProperty.h" -class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class EnumProperty : public AbstractUnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; - StringArrayView types() override; + auto types() -> StringArrayView override; - UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; + auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; - bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp b/src/Gvas/Serialisers/FloatProperty.cpp similarity index 72% rename from src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp rename to src/Gvas/Serialisers/FloatProperty.cpp index d643ca0..e3cf14c 100644 --- a/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/FloatProperty.cpp @@ -18,20 +18,22 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "FloatPropertySerialiser.h" +#include "FloatProperty.h" + +namespace Gvas { namespace Serialisers { StringArrayView -FloatPropertySerialiser::types() { +FloatProperty::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"FloatProperty"_s}}; return types; } -UnrealPropertyBase::ptr -FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) +Types::UnrealPropertyBase::ptr +FloatProperty::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); char terminator; if(!reader.readChar(terminator) || terminator != '\0') { @@ -48,10 +50,10 @@ FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::St } bool -FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) +FloatProperty::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto float_prop = dynamic_cast(prop.get()); + auto float_prop = dynamic_cast(prop.get()); if(!float_prop) { LOG_ERROR("The property is not a valid float property."); return false; @@ -62,3 +64,5 @@ FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& b return true; } + +}} diff --git a/src/UESaveFile/Serialisers/FloatPropertySerialiser.h b/src/Gvas/Serialisers/FloatProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/FloatPropertySerialiser.h rename to src/Gvas/Serialisers/FloatProperty.h index 9aa8ee9..bde9188 100644 --- a/src/UESaveFile/Serialisers/FloatPropertySerialiser.h +++ b/src/Gvas/Serialisers/FloatProperty.h @@ -19,20 +19,24 @@ #include #include -#include "AbstractUnrealPropertySerialiser.h" +#include "AbstractUnrealProperty.h" #include "../Types/FloatProperty.h" -class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class FloatProperty : public AbstractUnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; - StringArrayView types() override; + auto types() -> StringArrayView override; - UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; + auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; - bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp b/src/Gvas/Serialisers/GuidProperty.cpp similarity index 62% rename from src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp rename to src/Gvas/Serialisers/GuidProperty.cpp index 46715b6..ff173b8 100644 --- a/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/GuidProperty.cpp @@ -18,16 +18,17 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "GuidPropertySerialiser.h" +#include "GuidProperty.h" using namespace Containers::Literals; -UnrealPropertyBase::ptr -GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +GuidProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(!reader.readStaticArray(prop->guid)) { LOG_ERROR_FORMAT("Couldn't read GUID property {}'s value.", name); @@ -38,12 +39,12 @@ GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain } bool -GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +GuidProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto guid_prop = dynamic_cast(prop.get()); + auto guid_prop = dynamic_cast(prop.get()); if(!guid_prop) { - LOG_ERROR("The property is not a valid byte property."); + LOG_ERROR("The property is not a valid GUID property."); return false; } @@ -51,3 +52,5 @@ GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::si return true; } + +}} diff --git a/src/UESaveFile/Serialisers/GuidPropertySerialiser.h b/src/Gvas/Serialisers/GuidProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/GuidPropertySerialiser.h rename to src/Gvas/Serialisers/GuidProperty.h index 1a2a7c4..8de587c 100644 --- a/src/UESaveFile/Serialisers/GuidPropertySerialiser.h +++ b/src/Gvas/Serialisers/GuidProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/GuidStructProperty.h" -class GuidPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class GuidProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/IntPropertySerialiser.cpp b/src/Gvas/Serialisers/IntProperty.cpp similarity index 73% rename from src/UESaveFile/Serialisers/IntPropertySerialiser.cpp rename to src/Gvas/Serialisers/IntProperty.cpp index 76a8443..94f51d7 100644 --- a/src/UESaveFile/Serialisers/IntPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/IntProperty.cpp @@ -18,14 +18,15 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "IntPropertySerialiser.h" +#include "IntProperty.h" -UnrealPropertyBase::ptr -IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +IntProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(value_length == std::size_t(-1)) { if(!reader.readInt32(prop->value)) { @@ -54,10 +55,10 @@ IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe } bool -IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +IntProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto int_prop = dynamic_cast(prop.get()); + auto int_prop = dynamic_cast(prop.get()); if(!int_prop) { LOG_ERROR("The property is not a valid int property."); return false; @@ -71,3 +72,5 @@ IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::siz return true; } + +}} diff --git a/src/UESaveFile/Serialisers/IntPropertySerialiser.h b/src/Gvas/Serialisers/IntProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/IntPropertySerialiser.h rename to src/Gvas/Serialisers/IntProperty.h index 4cf7c93..777d625 100644 --- a/src/UESaveFile/Serialisers/IntPropertySerialiser.h +++ b/src/Gvas/Serialisers/IntProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/IntProperty.h" -class IntPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class IntProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp b/src/Gvas/Serialisers/MapProperty.cpp similarity index 85% rename from src/UESaveFile/Serialisers/MapPropertySerialiser.cpp rename to src/Gvas/Serialisers/MapProperty.cpp index b2f9057..7893447 100644 --- a/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/MapProperty.cpp @@ -20,16 +20,17 @@ #include "../Types/NoneProperty.h" #include "../../Logger/Logger.h" -#include "MapPropertySerialiser.h" +#include "MapProperty.h" using namespace Containers::Literals; -UnrealPropertyBase::ptr -MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +MapProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(!reader.readUEString(prop->keyType)) { LOG_ERROR_FORMAT("Couldn't read map property {}'s key type.", name); @@ -65,7 +66,7 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe arrayReserve(prop->map, count); for(std::uint32_t i = 0; i < count; i++) { - MapProperty::KeyValuePair pair; + Types::MapProperty::KeyValuePair pair; if(prop->keyType == "IntProperty"_s || prop->keyType == "StrProperty"_s) { pair.key = serialiser.readItem(reader, prop->keyType, -1, name); @@ -79,14 +80,14 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe return nullptr; } - UnrealPropertyBase::ptr value_item; + Types::UnrealPropertyBase::ptr value_item; if(prop->valueType == "StructProperty"_s) { while((value_item = serialiser.read(reader)) != nullptr) { arrayAppend(pair.values, std::move(value_item)); if(pair.values.back()->name == "None"_s && pair.values.back()->propertyType == "NoneProperty"_s && - dynamic_cast(pair.values.back().get()) != nullptr) + dynamic_cast(pair.values.back().get()) != nullptr) { break; } @@ -109,10 +110,10 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe } bool -MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +MapProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto map_prop = dynamic_cast(prop.get()); + auto map_prop = dynamic_cast(prop.get()); if(!map_prop) { LOG_ERROR("The property is not a valid map property."); return false; @@ -154,3 +155,5 @@ MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::siz return true; } + +}} diff --git a/src/UESaveFile/Serialisers/MapPropertySerialiser.h b/src/Gvas/Serialisers/MapProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/MapPropertySerialiser.h rename to src/Gvas/Serialisers/MapProperty.h index 0b59b4d..f992653 100644 --- a/src/UESaveFile/Serialisers/MapPropertySerialiser.h +++ b/src/Gvas/Serialisers/MapProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/MapProperty.h" -class MapPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class MapProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp b/src/Gvas/Serialisers/ResourceProperty.cpp similarity index 75% rename from src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp rename to src/Gvas/Serialisers/ResourceProperty.cpp index 9182591..da63c1e 100644 --- a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp +++ b/src/Gvas/Serialisers/ResourceProperty.cpp @@ -21,16 +21,17 @@ #include "../Types/NoneProperty.h" #include "../../Logger/Logger.h" -#include "ResourcePropertySerialiser.h" +#include "ResourceProperty.h" using namespace Containers::Literals; -UnrealPropertyBase::ptr -ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +ResourceProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); auto id_prop = serialiser.read(reader); if(!id_prop) { @@ -40,13 +41,13 @@ ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Con if((*id_prop->name) != "ID_4_AAE08F17428E229EC7A2209F51081A21"_s || id_prop->propertyType != "IntProperty"_s || - dynamic_cast(id_prop.get()) == nullptr) + dynamic_cast(id_prop.get()) == nullptr) { LOG_ERROR("The ID property is invalid."_s); return nullptr; } - prop->id = dynamic_cast(id_prop.get())->value; + prop->id = dynamic_cast(id_prop.get())->value; auto value_prop = serialiser.read(reader); if(!value_prop) { @@ -56,20 +57,20 @@ ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Con if((*value_prop->name) != "Quantity_3_560F09B5485C365D3041888910019CE3"_s || value_prop->propertyType != "IntProperty"_s || - dynamic_cast(value_prop.get()) == nullptr) + dynamic_cast(value_prop.get()) == nullptr) { LOG_ERROR("The value property is invalid."_s); return nullptr; } - prop->quantity = dynamic_cast(value_prop.get())->value; + prop->quantity = dynamic_cast(value_prop.get())->value; auto none_prop = serialiser.read(reader); if(!none_prop || (*none_prop->name) != "None"_s || none_prop->propertyType != "NoneProperty"_s || - !dynamic_cast(none_prop.get())) + !dynamic_cast(none_prop.get())) { LOG_ERROR("Couldn't find a terminating NoneProperty."_s); return nullptr; @@ -79,10 +80,10 @@ ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Con } bool -ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +ResourceProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { - auto res_prop = dynamic_cast(prop.get()); + auto res_prop = dynamic_cast(prop.get()); if(!res_prop) { LOG_ERROR("The property is not a valid ResourceItemValue property."); return false; @@ -104,3 +105,5 @@ ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std return true; } + +}} diff --git a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h b/src/Gvas/Serialisers/ResourceProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/ResourcePropertySerialiser.h rename to src/Gvas/Serialisers/ResourceProperty.h index 4e5e360..db97155 100644 --- a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h +++ b/src/Gvas/Serialisers/ResourceProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/ResourceItemValue.h" -class ResourcePropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class ResourceProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.cpp b/src/Gvas/Serialisers/RotatorProperty.cpp similarity index 66% rename from src/UESaveFile/Serialisers/RotatorPropertySerialiser.cpp rename to src/Gvas/Serialisers/RotatorProperty.cpp index 5a0b9e2..66ce58e 100644 --- a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/RotatorProperty.cpp @@ -18,14 +18,15 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "RotatorPropertySerialiser.h" +#include "RotatorProperty.h" -UnrealPropertyBase::ptr -RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +RotatorProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(!reader.readFloat(prop->x) || !reader.readFloat(prop->y) || !reader.readFloat(prop->z)) { LOG_ERROR_FORMAT("Couldn't read rotator property {}'s value.", name); @@ -36,10 +37,10 @@ RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Cont } bool -RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +RotatorProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { - auto rotator = dynamic_cast(prop.get()); + auto rotator = dynamic_cast(prop.get()); if(!rotator) { LOG_ERROR("The property is not a valid rotator property."); return false; @@ -50,3 +51,5 @@ RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std: return true; } + +}} diff --git a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h b/src/Gvas/Serialisers/RotatorProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/RotatorPropertySerialiser.h rename to src/Gvas/Serialisers/RotatorProperty.h index ec56385..a2df613 100644 --- a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h +++ b/src/Gvas/Serialisers/RotatorProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/RotatorStructProperty.h" -class RotatorPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class RotatorProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/Gvas/Serialisers/Serialisers.h b/src/Gvas/Serialisers/Serialisers.h new file mode 100644 index 0000000..182a7d7 --- /dev/null +++ b/src/Gvas/Serialisers/Serialisers.h @@ -0,0 +1,44 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2023 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 . + +namespace Gvas { namespace Serialisers { + +class AbstractUnrealCollectionProperty; +class AbstractUnrealProperty; +class AbstractUnrealStruct; +class ArrayProperty; +class BoolProperty; +class ByteProperty; +class ColourProperty; +class DateTimeProperty; +class EnumProperty; +class FloatProperty; +class GuidProperty; +class IntProperty; +class MapProperty; +class ResourceProperty; +class RotatorProperty; +class SetProperty; +class StringProperty; +class Struct; +class TextProperty; +class UnrealProperty; +class Vector2DProperty; +class VectorProperty; + +}} diff --git a/src/UESaveFile/Serialisers/SetPropertySerialiser.cpp b/src/Gvas/Serialisers/SetProperty.cpp similarity index 79% rename from src/UESaveFile/Serialisers/SetPropertySerialiser.cpp rename to src/Gvas/Serialisers/SetProperty.cpp index 2bef358..5237483 100644 --- a/src/UESaveFile/Serialisers/SetPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/SetProperty.cpp @@ -19,12 +19,13 @@ #include "../PropertySerialiser.h" #include "../../Logger/Logger.h" -#include "SetPropertySerialiser.h" +#include "SetProperty.h" -UnrealPropertyBase::ptr -SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +SetProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { Containers::String item_type; if(!reader.readUEString(item_type)) { @@ -50,7 +51,7 @@ SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe return nullptr; } - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); prop->itemType = std::move(item_type); prop->items = serialiser.readSet(reader, prop->itemType, item_count); @@ -58,10 +59,10 @@ SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe } bool -SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +SetProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto set_prop = dynamic_cast(prop.get()); + auto set_prop = dynamic_cast(prop.get()); if(!set_prop) { LOG_ERROR("The property is not a valid set property."); return false; @@ -80,3 +81,5 @@ SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::siz return true; } + +}} diff --git a/src/UESaveFile/Serialisers/SetPropertySerialiser.h b/src/Gvas/Serialisers/SetProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/SetPropertySerialiser.h rename to src/Gvas/Serialisers/SetProperty.h index 083e2c8..ca2629e 100644 --- a/src/UESaveFile/Serialisers/SetPropertySerialiser.h +++ b/src/Gvas/Serialisers/SetProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/SetProperty.h" -class SetPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class SetProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp b/src/Gvas/Serialisers/StringProperty.cpp similarity index 74% rename from src/UESaveFile/Serialisers/StringPropertySerialiser.cpp rename to src/Gvas/Serialisers/StringProperty.cpp index 177dacc..e3fee8e 100644 --- a/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/StringProperty.cpp @@ -18,10 +18,12 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "StringPropertySerialiser.h" +#include "StringProperty.h" + +namespace Gvas { namespace Serialisers { StringArrayView -StringPropertySerialiser::types() { +StringProperty::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, { "NameProperty"_s, "StrProperty"_s, "SoftObjectProperty"_s, "ObjectProperty"_s @@ -29,11 +31,11 @@ StringPropertySerialiser::types() { return types; } -UnrealPropertyBase::ptr -StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) +Types::UnrealPropertyBase::ptr +StringProperty::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(type); + auto prop = Containers::pointer(type); if(value_length != std::size_t(-1)) { char terminator; @@ -54,10 +56,10 @@ StringPropertySerialiser::deserialise(Containers::StringView name, Containers::S } bool -StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) +StringProperty::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto str_prop = dynamic_cast(prop.get()); + auto str_prop = dynamic_cast(prop.get()); if(!str_prop) { LOG_ERROR("The property is not a valid string property."); return false; @@ -71,3 +73,5 @@ StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& return true; } + +}} diff --git a/src/UESaveFile/Serialisers/StringPropertySerialiser.h b/src/Gvas/Serialisers/StringProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/StringPropertySerialiser.h rename to src/Gvas/Serialisers/StringProperty.h index cfca6ce..f66fd98 100644 --- a/src/UESaveFile/Serialisers/StringPropertySerialiser.h +++ b/src/Gvas/Serialisers/StringProperty.h @@ -19,20 +19,24 @@ #include #include -#include "AbstractUnrealPropertySerialiser.h" +#include "AbstractUnrealProperty.h" #include "../Types/StringProperty.h" -class StringPropertySerialiser : public AbstractUnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class StringProperty : public AbstractUnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; - StringArrayView types() override; + auto types() -> StringArrayView override; - UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; + auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; - bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/StructSerialiser.cpp b/src/Gvas/Serialisers/Struct.cpp similarity index 72% rename from src/UESaveFile/Serialisers/StructSerialiser.cpp rename to src/Gvas/Serialisers/Struct.cpp index 1e8affc..3602d66 100644 --- a/src/UESaveFile/Serialisers/StructSerialiser.cpp +++ b/src/Gvas/Serialisers/Struct.cpp @@ -23,18 +23,20 @@ #include "../Types/NoneProperty.h" #include "../../Logger/Logger.h" -#include "StructSerialiser.h" +#include "Struct.h" + +namespace Gvas { namespace Serialisers { StringArrayView -StructSerialiser::types() { +Struct::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"StructProperty"_s}}; return types; } -Containers::Array -StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, - std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser) +PropertyArray +Struct::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser) { Containers::String item_type; if(!reader.readUEString(item_type)) { @@ -54,16 +56,16 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie return nullptr; } - Containers::Array array; + Containers::Array array; if(count == 0) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); prop->structType = std::move(item_type); prop->structGuid = std::move(guid); } else { for(std::uint32_t i = 0; i < count; i++) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); prop = serialiser.readItem(reader, item_type, std::size_t(-1), name); @@ -76,7 +78,7 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie return nullptr; } - dynamic_cast(prop.get())->structGuid = guid; + dynamic_cast(prop.get())->structGuid = guid; arrayAppend(array, std::move(prop)); } @@ -85,9 +87,9 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie return array; } -UnrealPropertyBase::ptr -StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, - BinaryReader& reader, PropertySerialiser& serialiser) +Types::UnrealPropertyBase::ptr +Struct::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { Containers::String item_type; if(!reader.readUEString(item_type)) { @@ -96,7 +98,7 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie } if(item_type == "None") { - return NoneProperty::ptr{}; + return Containers::pointer(); } Containers::StaticArray<16, char> guid{ValueInit}; @@ -111,12 +113,12 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie return nullptr; } - UnrealPropertyBase::ptr prop = serialiser.readItem(reader, item_type, value_length, name); + auto prop = serialiser.readItem(reader, item_type, value_length, name); if(!prop) { prop = readStructValue(name, item_type, value_length, reader, serialiser); if(prop) { - dynamic_cast(prop.get())->structGuid = std::move(guid); + dynamic_cast(prop.get())->structGuid = std::move(guid); } } @@ -124,15 +126,15 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie } bool -StructSerialiser::serialise(Containers::ArrayView props, Containers::StringView item_type, - std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) +Struct::serialise(PropertyArrayView props, Containers::StringView item_type, std::size_t& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { bytes_written += writer.writeUEStringToArray(*(props.front()->name)); bytes_written += writer.writeUEStringToArray(item_type); std::size_t vl_pos = writer.arrayPosition(); bytes_written += writer.writeValueToArray(0ull); - auto struct_prop = dynamic_cast(props.front().get()); + auto struct_prop = dynamic_cast(props.front().get()); if(!struct_prop) { LOG_ERROR("The property is not a valid struct property."); return false; @@ -146,7 +148,7 @@ StructSerialiser::serialise(Containers::ArrayView props std::size_t bytes_written_here = 0; for(auto& prop : props) { - struct_prop = dynamic_cast(prop.get()); + struct_prop = dynamic_cast(prop.get()); if(!struct_prop) { LOG_ERROR("The property is not a valid struct property."); return false; @@ -168,10 +170,10 @@ StructSerialiser::serialise(Containers::ArrayView props } bool -StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) +Struct::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto struct_prop = dynamic_cast(prop.get()); + auto struct_prop = dynamic_cast(prop.get()); if(!struct_prop) { LOG_ERROR("The property is not a valid struct property."); return false; @@ -194,22 +196,22 @@ StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_wr return true; } -StructProperty::ptr -StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, std::size_t value_length, - BinaryReader& reader, PropertySerialiser& serialiser) +Types::StructProperty::ptr +Struct::readStructValue(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { static_cast(value_length); - auto st_prop = Containers::pointer(); + auto st_prop = Containers::pointer(); st_prop->structType = type; - UnrealPropertyBase::ptr prop; + Types::UnrealPropertyBase::ptr prop; while((prop = serialiser.read(reader)) != nullptr) { arrayAppend(st_prop->properties, std::move(prop)); if(st_prop->properties.back()->name == "None" && st_prop->properties.back()->propertyType == "NoneProperty" && - dynamic_cast(st_prop->properties.back().get()) != nullptr) + dynamic_cast(st_prop->properties.back().get()) != nullptr) { break; } @@ -221,10 +223,10 @@ StructSerialiser::readStructValue(Containers::StringView name, Containers::Strin } bool -StructSerialiser::writeStructValue(StructProperty* prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) +Struct::writeStructValue(Types::StructProperty* prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto struct_prop = dynamic_cast(prop); + auto struct_prop = dynamic_cast(prop); if(!struct_prop) { LOG_ERROR("The property is not a valid struct property."); return false; @@ -239,3 +241,5 @@ StructSerialiser::writeStructValue(StructProperty* prop, std::size_t& bytes_writ return true; } + +}} diff --git a/src/Gvas/Serialisers/Struct.h b/src/Gvas/Serialisers/Struct.h new file mode 100644 index 0000000..c26740c --- /dev/null +++ b/src/Gvas/Serialisers/Struct.h @@ -0,0 +1,55 @@ +#pragma once + +// MassBuilderSaveTool +// Copyright (C) 2021-2023 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 . + +#include +#include + +#include "AbstractUnrealCollectionProperty.h" +#include "AbstractUnrealProperty.h" +#include "AbstractUnrealStruct.h" + +#include "../Types/StructProperty.h" + +namespace Gvas { namespace Serialisers { + +class Struct : public AbstractUnrealProperty, public AbstractUnrealCollectionProperty { + public: + using ptr = Containers::Pointer; + + auto types() -> StringArrayView override; + + auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser) + -> PropertyArray override; + auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + + bool serialise(PropertyArrayView props, Containers::StringView item_type, std::size_t& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) override; + bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; + + private: + auto readStructValue(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) -> Types::StructProperty::ptr; + bool writeStructValue(Types::StructProperty* prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser); +}; + +}} diff --git a/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp b/src/Gvas/Serialisers/TextProperty.cpp similarity index 72% rename from src/UESaveFile/Serialisers/TextPropertySerialiser.cpp rename to src/Gvas/Serialisers/TextProperty.cpp index cba065f..4850cd0 100644 --- a/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/TextProperty.cpp @@ -16,17 +16,20 @@ #include +#include "../../Logger/Logger.h" + #include "../BinaryReader.h" #include "../BinaryWriter.h" -#include "TextPropertySerialiser.h" +#include "TextProperty.h" -UnrealPropertyBase::ptr -TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +TextProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); auto start_position = reader.position(); @@ -70,12 +73,12 @@ TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain } bool -TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +TextProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { - auto text_prop = dynamic_cast(prop.get()); - + auto text_prop = dynamic_cast(prop.get()); if(!text_prop) { + LOG_ERROR("The property is not a valid text property."); return false; } @@ -87,3 +90,5 @@ TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::si return true; } + +}} diff --git a/src/UESaveFile/Serialisers/TextPropertySerialiser.h b/src/Gvas/Serialisers/TextProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/TextPropertySerialiser.h rename to src/Gvas/Serialisers/TextProperty.h index 865b63e..496c955 100644 --- a/src/UESaveFile/Serialisers/TextPropertySerialiser.h +++ b/src/Gvas/Serialisers/TextProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/TextProperty.h" -class TextPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class TextProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h b/src/Gvas/Serialisers/UnrealProperty.h similarity index 56% rename from src/UESaveFile/Serialisers/UnrealPropertySerialiser.h rename to src/Gvas/Serialisers/UnrealProperty.h index d351030..4ba6b24 100644 --- a/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h +++ b/src/Gvas/Serialisers/UnrealProperty.h @@ -22,23 +22,25 @@ #include #include -#include "AbstractUnrealPropertySerialiser.h" +#include "AbstractUnrealProperty.h" #include "../Types/StructProperty.h" +namespace Gvas { namespace Serialisers { + template -class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser { - static_assert(std::is_base_of::value, "T must be derived from UnrealPropertyBase."); +class UnrealProperty : public AbstractUnrealProperty { + static_assert(std::is_base_of::value, "T must be derived from UnrealPropertyBase."); public: - using ptr = Containers::Pointer>; + using ptr = Containers::Pointer>; - StringArrayView types() override { + auto types() -> StringArrayView override { static const Containers::Array types = []{ Containers::Array array; Containers::Pointer p(new T); - if(std::is_base_of::value) { + if(std::is_base_of::value) { array = Containers::Array{InPlaceInit, { - dynamic_cast(p.get())->structType + dynamic_cast(p.get())->structType }}; } else { @@ -49,24 +51,26 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser { return types; } - UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override + auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override { return deserialiseProperty(name, type, value_length, reader, serialiser); } - bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override { return serialiseProperty(prop, bytes_written, writer, serialiser); } private: - virtual UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) = 0; + virtual auto deserialiseProperty(Containers::StringView name, Containers::StringView type, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr = 0; - virtual bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) = 0; + virtual bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) = 0; }; + +}} diff --git a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp b/src/Gvas/Serialisers/Vector2DProperty.cpp similarity index 65% rename from src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp rename to src/Gvas/Serialisers/Vector2DProperty.cpp index 6cb611a..40f69eb 100644 --- a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/Vector2DProperty.cpp @@ -18,14 +18,15 @@ #include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "Vector2DPropertySerialiser.h" +#include "Vector2DProperty.h" -UnrealPropertyBase::ptr -Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +Vector2DProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(!reader.readFloat(prop->x) || !reader.readFloat(prop->y)) { LOG_ERROR_FORMAT("Couldn't read 2D vector property {}'s value.", name); @@ -36,10 +37,10 @@ Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Con } bool -Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +Vector2DProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { - auto vector = dynamic_cast(prop.get()); + auto vector = dynamic_cast(prop.get()); if(!vector) { LOG_ERROR("The property is not a valid 2D vector property."); return false; @@ -49,3 +50,5 @@ Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std return true; } + +}} diff --git a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h b/src/Gvas/Serialisers/Vector2DProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h rename to src/Gvas/Serialisers/Vector2DProperty.h index cc40bb1..daee73d 100644 --- a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h +++ b/src/Gvas/Serialisers/Vector2DProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/Vector2DStructProperty.h" -class Vector2DPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class Vector2DProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Serialisers/VectorPropertySerialiser.cpp b/src/Gvas/Serialisers/VectorProperty.cpp similarity index 67% rename from src/UESaveFile/Serialisers/VectorPropertySerialiser.cpp rename to src/Gvas/Serialisers/VectorProperty.cpp index 7e07989..2dc84db 100644 --- a/src/UESaveFile/Serialisers/VectorPropertySerialiser.cpp +++ b/src/Gvas/Serialisers/VectorProperty.cpp @@ -14,18 +14,20 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "../BinaryReader.h" -#include "../BinaryWriter.h" #include "../../Logger/Logger.h" -#include "VectorPropertySerialiser.h" +#include "../BinaryReader.h" +#include "../BinaryWriter.h" -UnrealPropertyBase::ptr -VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) +#include "VectorProperty.h" + +namespace Gvas { namespace Serialisers { + +Types::UnrealPropertyBase::ptr +VectorProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { - auto prop = Containers::pointer(); + auto prop = Containers::pointer(); if(!reader.readFloat(prop->x) || !reader.readFloat(prop->y) || !reader.readFloat(prop->z)) { LOG_ERROR_FORMAT("Couldn't read vector property {}'s value.", name); @@ -36,10 +38,10 @@ VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Conta } bool -VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) +VectorProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { - auto vector = dynamic_cast(prop.get()); + auto vector = dynamic_cast(prop.get()); if(!vector) { LOG_ERROR("The property is not a valid vector property."); return false; @@ -50,3 +52,5 @@ VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std:: return true; } + +}} diff --git a/src/UESaveFile/Serialisers/VectorPropertySerialiser.h b/src/Gvas/Serialisers/VectorProperty.h similarity index 60% rename from src/UESaveFile/Serialisers/VectorPropertySerialiser.h rename to src/Gvas/Serialisers/VectorProperty.h index 212adef..d0af522 100644 --- a/src/UESaveFile/Serialisers/VectorPropertySerialiser.h +++ b/src/Gvas/Serialisers/VectorProperty.h @@ -18,18 +18,22 @@ #include -#include "UnrealPropertySerialiser.h" +#include "UnrealProperty.h" #include "../Types/VectorStructProperty.h" -class VectorPropertySerialiser : public UnrealPropertySerialiser { +namespace Gvas { namespace Serialisers { + +class VectorProperty : public UnrealProperty { public: - using ptr = Containers::Pointer; + using ptr = Containers::Pointer; private: - UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, + auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length, + BinaryReader& reader, PropertySerialiser& serialiser) + -> Types::UnrealPropertyBase::ptr override; + bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; + +}} diff --git a/src/UESaveFile/Types/ArrayProperty.h b/src/Gvas/Types/ArrayProperty.h similarity index 97% rename from src/UESaveFile/Types/ArrayProperty.h rename to src/Gvas/Types/ArrayProperty.h index 4c4f476..65d73d6 100644 --- a/src/UESaveFile/Types/ArrayProperty.h +++ b/src/Gvas/Types/ArrayProperty.h @@ -23,6 +23,8 @@ #include "UnrealPropertyBase.h" +namespace Gvas { namespace Types { + struct ArrayProperty : public UnrealPropertyBase { using ptr = Containers::Pointer; @@ -44,3 +46,5 @@ struct ArrayProperty : public UnrealPropertyBase { Containers::String itemType; Containers::Array items; }; + +}} diff --git a/src/UESaveFile/Types/BoolProperty.h b/src/Gvas/Types/BoolProperty.h similarity index 96% rename from src/UESaveFile/Types/BoolProperty.h rename to src/Gvas/Types/BoolProperty.h index cc70178..eda8b72 100644 --- a/src/UESaveFile/Types/BoolProperty.h +++ b/src/Gvas/Types/BoolProperty.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct BoolProperty : public UnrealProperty { using ptr = Containers::Pointer; @@ -31,3 +33,5 @@ struct BoolProperty : public UnrealProperty { propertyType = "BoolProperty"_s; } }; + +}} diff --git a/src/UESaveFile/Types/ByteProperty.h b/src/Gvas/Types/ByteProperty.h similarity index 87% rename from src/UESaveFile/Types/ByteProperty.h rename to src/Gvas/Types/ByteProperty.h index 7c55d9d..cc9065a 100644 --- a/src/UESaveFile/Types/ByteProperty.h +++ b/src/Gvas/Types/ByteProperty.h @@ -25,6 +25,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct ByteProperty : public UnrealProperty> { using ptr = Containers::Pointer; @@ -33,7 +35,10 @@ struct ByteProperty : public UnrealProperty> { propertyType = "ByteProperty"_s; } - // For some reason, M.A.S.S. Builder stores EnumProperties as ByteProperties. Ugh... + // M.A.S.S. Builder stores EnumProperties as ByteProperties. + // I wonder if it's a general UE thing and agc93/unsave was just wrong. Containers::String enumType; Containers::String enumValue; }; + +}} diff --git a/src/UESaveFile/Types/ColourStructProperty.h b/src/Gvas/Types/ColourStructProperty.h similarity index 96% rename from src/UESaveFile/Types/ColourStructProperty.h rename to src/Gvas/Types/ColourStructProperty.h index 38878f3..cc69b1d 100644 --- a/src/UESaveFile/Types/ColourStructProperty.h +++ b/src/Gvas/Types/ColourStructProperty.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct ColourStructProperty : public StructProperty { using ptr = Containers::Pointer; ColourStructProperty() { @@ -31,3 +33,5 @@ struct ColourStructProperty : public StructProperty { } float r = 0.0f, g = 0.0f, b = 0.0f, a = 0.0f; }; + +}} diff --git a/src/UESaveFile/Types/DateTimeStructProperty.h b/src/Gvas/Types/DateTimeStructProperty.h similarity index 96% rename from src/UESaveFile/Types/DateTimeStructProperty.h rename to src/Gvas/Types/DateTimeStructProperty.h index 4f3f37c..a917055 100644 --- a/src/UESaveFile/Types/DateTimeStructProperty.h +++ b/src/Gvas/Types/DateTimeStructProperty.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct DateTimeStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -33,3 +35,5 @@ struct DateTimeStructProperty : public StructProperty { std::int64_t timestamp = 0; }; + +}} diff --git a/src/UESaveFile/Types/EnumProperty.h b/src/Gvas/Types/EnumProperty.h similarity index 96% rename from src/UESaveFile/Types/EnumProperty.h rename to src/Gvas/Types/EnumProperty.h index c3941a5..834cf8f 100644 --- a/src/UESaveFile/Types/EnumProperty.h +++ b/src/Gvas/Types/EnumProperty.h @@ -24,6 +24,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct EnumProperty : public UnrealProperty { using ptr = Containers::Pointer; @@ -34,3 +36,5 @@ struct EnumProperty : public UnrealProperty { Containers::String enumType; }; + +}} diff --git a/src/UESaveFile/Types/FloatProperty.h b/src/Gvas/Types/FloatProperty.h similarity index 96% rename from src/UESaveFile/Types/FloatProperty.h rename to src/Gvas/Types/FloatProperty.h index c5ec882..7d9ea3f 100644 --- a/src/UESaveFile/Types/FloatProperty.h +++ b/src/Gvas/Types/FloatProperty.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct FloatProperty : public UnrealProperty { using ptr = Containers::Pointer; @@ -31,3 +33,5 @@ struct FloatProperty : public UnrealProperty { propertyType = "FloatProperty"_s; } }; + +}} diff --git a/src/UESaveFile/Types/GenericStructProperty.h b/src/Gvas/Types/GenericStructProperty.h similarity index 97% rename from src/UESaveFile/Types/GenericStructProperty.h rename to src/Gvas/Types/GenericStructProperty.h index 5c72bb6..409d601 100644 --- a/src/UESaveFile/Types/GenericStructProperty.h +++ b/src/Gvas/Types/GenericStructProperty.h @@ -26,6 +26,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct GenericStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -53,3 +55,5 @@ struct GenericStructProperty : public StructProperty { Containers::Array properties; }; + +}} diff --git a/src/UESaveFile/Types/GuidStructProperty.h b/src/Gvas/Types/GuidStructProperty.h similarity index 96% rename from src/UESaveFile/Types/GuidStructProperty.h rename to src/Gvas/Types/GuidStructProperty.h index 8a8e490..1b53b56 100644 --- a/src/UESaveFile/Types/GuidStructProperty.h +++ b/src/Gvas/Types/GuidStructProperty.h @@ -24,6 +24,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct GuidStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -34,3 +36,5 @@ struct GuidStructProperty : public StructProperty { Containers::StaticArray<16, char> guid{ValueInit}; }; + +}} diff --git a/src/UESaveFile/Types/IntProperty.h b/src/Gvas/Types/IntProperty.h similarity index 96% rename from src/UESaveFile/Types/IntProperty.h rename to src/Gvas/Types/IntProperty.h index a92e807..c966397 100644 --- a/src/UESaveFile/Types/IntProperty.h +++ b/src/Gvas/Types/IntProperty.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct IntProperty : public UnrealProperty { using ptr = Containers::Pointer; @@ -31,3 +33,5 @@ struct IntProperty : public UnrealProperty { propertyType = "IntProperty"_s; } }; + +}} diff --git a/src/UESaveFile/Types/MapProperty.h b/src/Gvas/Types/MapProperty.h similarity index 94% rename from src/UESaveFile/Types/MapProperty.h rename to src/Gvas/Types/MapProperty.h index 306552c..44f8ec8 100644 --- a/src/UESaveFile/Types/MapProperty.h +++ b/src/Gvas/Types/MapProperty.h @@ -16,6 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include #include #include #include @@ -24,6 +25,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct MapProperty : public UnrealPropertyBase { using ptr = Containers::Pointer; @@ -42,3 +45,5 @@ struct MapProperty : public UnrealPropertyBase { Containers::Array map; }; + +}} diff --git a/src/UESaveFile/Types/NoneProperty.h b/src/Gvas/Types/NoneProperty.h similarity index 96% rename from src/UESaveFile/Types/NoneProperty.h rename to src/Gvas/Types/NoneProperty.h index 68cc44a..4d8dfdd 100644 --- a/src/UESaveFile/Types/NoneProperty.h +++ b/src/Gvas/Types/NoneProperty.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct NoneProperty : UnrealPropertyBase { using ptr = Containers::Pointer; @@ -32,3 +34,5 @@ struct NoneProperty : UnrealPropertyBase { propertyType = "NoneProperty"_s; } }; + +}} diff --git a/src/UESaveFile/Types/ResourceItemValue.h b/src/Gvas/Types/ResourceItemValue.h similarity index 97% rename from src/UESaveFile/Types/ResourceItemValue.h rename to src/Gvas/Types/ResourceItemValue.h index c5d9e7c..a6f0e63 100644 --- a/src/UESaveFile/Types/ResourceItemValue.h +++ b/src/Gvas/Types/ResourceItemValue.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct ResourceItemValue : public StructProperty { using ptr = Containers::Pointer; @@ -38,3 +40,5 @@ struct ResourceItemValue : public StructProperty { std::int32_t id = 0; std::int32_t quantity = 0; }; + +}} diff --git a/src/UESaveFile/Types/RotatorStructProperty.h b/src/Gvas/Types/RotatorStructProperty.h similarity index 96% rename from src/UESaveFile/Types/RotatorStructProperty.h rename to src/Gvas/Types/RotatorStructProperty.h index c8e5a7c..5579a33 100644 --- a/src/UESaveFile/Types/RotatorStructProperty.h +++ b/src/Gvas/Types/RotatorStructProperty.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct RotatorStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -33,3 +35,5 @@ struct RotatorStructProperty : public StructProperty { float x = 0.0f, y = 0.0f, z = 0.0f; }; + +}} diff --git a/src/UESaveFile/Types/SetProperty.h b/src/Gvas/Types/SetProperty.h similarity index 97% rename from src/UESaveFile/Types/SetProperty.h rename to src/Gvas/Types/SetProperty.h index 6e51a18..deffd22 100644 --- a/src/UESaveFile/Types/SetProperty.h +++ b/src/Gvas/Types/SetProperty.h @@ -25,6 +25,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct SetProperty : public UnrealPropertyBase { using ptr = Containers::Pointer; @@ -44,3 +46,5 @@ struct SetProperty : public UnrealPropertyBase { Containers::String itemType; Containers::Array items; }; + +}} diff --git a/src/UESaveFile/Types/StringProperty.h b/src/Gvas/Types/StringProperty.h similarity index 96% rename from src/UESaveFile/Types/StringProperty.h rename to src/Gvas/Types/StringProperty.h index 0a0526e..cfc4ebe 100644 --- a/src/UESaveFile/Types/StringProperty.h +++ b/src/Gvas/Types/StringProperty.h @@ -25,6 +25,8 @@ using namespace Corrade; using namespace Containers::Literals; +namespace Gvas { namespace Types { + struct StringProperty : public UnrealProperty { using ptr = Containers::Pointer; @@ -32,3 +34,5 @@ struct StringProperty : public UnrealProperty { propertyType = type; } }; + +}} diff --git a/src/UESaveFile/Types/StructProperty.h b/src/Gvas/Types/StructProperty.h similarity index 96% rename from src/UESaveFile/Types/StructProperty.h rename to src/Gvas/Types/StructProperty.h index 3bb8d14..541f0db 100644 --- a/src/UESaveFile/Types/StructProperty.h +++ b/src/Gvas/Types/StructProperty.h @@ -25,6 +25,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct StructProperty : public UnrealPropertyBase { using ptr = Containers::Pointer; @@ -36,3 +38,5 @@ struct StructProperty : public UnrealPropertyBase { Containers::StaticArray<16, char> structGuid{ValueInit}; Containers::String structType; }; + +}} diff --git a/src/UESaveFile/Types/TextProperty.h b/src/Gvas/Types/TextProperty.h similarity index 96% rename from src/UESaveFile/Types/TextProperty.h rename to src/Gvas/Types/TextProperty.h index 8f4e8ad..7392dfe 100644 --- a/src/UESaveFile/Types/TextProperty.h +++ b/src/Gvas/Types/TextProperty.h @@ -25,6 +25,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct TextProperty : public UnrealProperty { using ptr = Containers::Pointer; @@ -37,3 +39,5 @@ struct TextProperty : public UnrealProperty { char id = 0; Containers::Array data; }; + +}} diff --git a/src/UESaveFile/Debug.h b/src/Gvas/Types/Types.h similarity index 64% rename from src/UESaveFile/Debug.h rename to src/Gvas/Types/Types.h index 1f6f879..8ebe58a 100644 --- a/src/UESaveFile/Debug.h +++ b/src/Gvas/Types/Types.h @@ -16,18 +16,30 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include +namespace Gvas { namespace Types { -struct ArrayProperty; -struct SetProperty; -struct GenericStructProperty; -struct StructProperty; struct UnrealPropertyBase; +template +struct UnrealProperty; +struct ArrayProperty; +struct BoolProperty; +struct ByteProperty; +struct ColourStructProperty; +struct DateTimeStructProperty; +struct EnumProperty; +struct FloatProperty; +struct GenericStructProperty; +struct GuidStructProperty; +struct IntProperty; +struct MapProperty; +struct NoneProperty; +struct ResourceItemValue; +struct RotatorStructProperty; +struct SetProperty; +struct StringProperty; +struct StructProperty; +struct TextProperty; +struct Vector2DStructProperty; +struct VectorStructProperty; -using namespace Corrade; - -Utility::Debug& operator<<(Utility::Debug& debug, const ArrayProperty* prop); -Utility::Debug& operator<<(Utility::Debug& debug, const SetProperty* prop); -Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* prop); -Utility::Debug& operator<<(Utility::Debug& debug, const StructProperty* prop); -Utility::Debug& operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop); +}} diff --git a/src/UESaveFile/Types/UnrealProperty.h b/src/Gvas/Types/UnrealProperty.h similarity index 96% rename from src/UESaveFile/Types/UnrealProperty.h rename to src/Gvas/Types/UnrealProperty.h index 33b63b7..6f9fe39 100644 --- a/src/UESaveFile/Types/UnrealProperty.h +++ b/src/Gvas/Types/UnrealProperty.h @@ -22,9 +22,13 @@ using namespace Corrade; +namespace Gvas { namespace Types { + template struct UnrealProperty : public UnrealPropertyBase { using ptr = Containers::Pointer>; T value; }; + +}} diff --git a/src/UESaveFile/Types/UnrealPropertyBase.h b/src/Gvas/Types/UnrealPropertyBase.h similarity index 96% rename from src/UESaveFile/Types/UnrealPropertyBase.h rename to src/Gvas/Types/UnrealPropertyBase.h index d27714f..01ca885 100644 --- a/src/UESaveFile/Types/UnrealPropertyBase.h +++ b/src/Gvas/Types/UnrealPropertyBase.h @@ -24,6 +24,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct UnrealPropertyBase { using ptr = Containers::Pointer; @@ -33,3 +35,5 @@ struct UnrealPropertyBase { Containers::String propertyType; std::size_t valueLength = 0; }; + +}} diff --git a/src/UESaveFile/Types/Vector2DStructProperty.h b/src/Gvas/Types/Vector2DStructProperty.h similarity index 96% rename from src/UESaveFile/Types/Vector2DStructProperty.h rename to src/Gvas/Types/Vector2DStructProperty.h index 64682d3..67f1127 100644 --- a/src/UESaveFile/Types/Vector2DStructProperty.h +++ b/src/Gvas/Types/Vector2DStructProperty.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct Vector2DStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -33,3 +35,5 @@ struct Vector2DStructProperty : public StructProperty { float x = 0.0f, y = 0.0f; }; + +}} diff --git a/src/UESaveFile/Types/VectorStructProperty.h b/src/Gvas/Types/VectorStructProperty.h similarity index 96% rename from src/UESaveFile/Types/VectorStructProperty.h rename to src/Gvas/Types/VectorStructProperty.h index ecf2328..c7e277d 100644 --- a/src/UESaveFile/Types/VectorStructProperty.h +++ b/src/Gvas/Types/VectorStructProperty.h @@ -23,6 +23,8 @@ using namespace Corrade; +namespace Gvas { namespace Types { + struct VectorStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -33,3 +35,5 @@ struct VectorStructProperty : public StructProperty { float x = 0.0f, y = 0.0f, z = 0.0f; }; + +}} diff --git a/src/Logger/Logger.h b/src/Logger/Logger.h index 409f94f..cbe309d 100644 --- a/src/Logger/Logger.h +++ b/src/Logger/Logger.h @@ -45,7 +45,7 @@ class Logger { Logger(Logger&&) = delete; Logger& operator=(Logger&&) = delete; - static Logger& instance(); + static auto instance() -> Logger&; void initialise(); @@ -69,7 +69,7 @@ class Logger { std::mutex _logMutex{}; }; -Logger& logger(); +auto logger() -> Logger&; #define LOG(entry_type, message) logger().lockMutex(); \ logger().log(EntryType::entry_type, \ diff --git a/src/Logger/MagnumLogBuffer.h b/src/Logger/MagnumLogBuffer.h index 010c788..da45b04 100644 --- a/src/Logger/MagnumLogBuffer.h +++ b/src/Logger/MagnumLogBuffer.h @@ -28,7 +28,7 @@ class MagnumLogBuffer : public std::stringbuf { ~MagnumLogBuffer() override; private: - int sync() override; + auto sync() -> int override; EntryType _type; }; diff --git a/src/Maps/Accessories.h b/src/Maps/Accessories.h index ab3e6e1..8f8b7b4 100644 --- a/src/Maps/Accessories.h +++ b/src/Maps/Accessories.h @@ -25,659 +25,662 @@ using namespace Corrade; using namespace Containers::Literals; -enum AccessorySize { - S, - M, - L, - XL -}; +namespace mbst { namespace GameData { -struct AccessoryData{ +struct Accessory { Containers::StringView name; - AccessorySize size = AccessorySize::S; + enum Size { + S, + M, + L, + XL + }; + Size size{}; }; -static const std::map accessories { +static const std::map accessories{ // region Primitives - {1, {"Cube"_s, AccessorySize::S}}, - {2, {"Pentagon"_s, AccessorySize::S}}, - {3, {"Hexagon"_s, AccessorySize::S}}, - {4, {"Cylinder"_s, AccessorySize::S}}, - {5, {"Sphere"_s, AccessorySize::S}}, - {6, {"TriPyramid"_s, AccessorySize::S}}, - {7, {"SquPyramid"_s, AccessorySize::S}}, - {8, {"PenPyramid"_s, AccessorySize::S}}, - {9, {"HexPyramid"_s, AccessorySize::S}}, - {10, {"Cone"_s, AccessorySize::S}}, - {11, {"SquStick"_s, AccessorySize::S}}, - {12, {"PenStick"_s, AccessorySize::S}}, - {13, {"HexStick"_s, AccessorySize::S}}, - {14, {"CycStick"_s, AccessorySize::S}}, - {15, {"Capsule"_s, AccessorySize::S}}, - {16, {"Decal Pad 01"_s, AccessorySize::S}}, - {17, {"Decal Pad 02"_s, AccessorySize::S}}, - {18, {"Decal Pad 03"_s, AccessorySize::S}}, - {19, {"Decal Pad 04"_s, AccessorySize::S}}, - {20, {"Decal Pad 05"_s, AccessorySize::S}}, - {21, {"Triangle"_s, AccessorySize::S}}, - {22, {"ThinStar"_s, AccessorySize::S}}, - {23, {"Star"_s, AccessorySize::S}}, - {24, {"SixSideStar"_s, AccessorySize::S}}, - {25, {"Asterisk"_s, AccessorySize::S}}, - {26, {"Ring"_s, AccessorySize::S}}, - {27, {"SawedRing"_s, AccessorySize::S}}, - {28, {"HalfRing"_s, AccessorySize::S}}, - {29, {"Cresent"_s, AccessorySize::S}}, - {30, {"Donut"_s, AccessorySize::S}}, - {31, {"FiveCogWheel"_s, AccessorySize::S}}, - {32, {"SixCogWheel"_s, AccessorySize::S}}, - {33, {"SevenCogWheel"_s, AccessorySize::S}}, - {34, {"EightCogWheel"_s, AccessorySize::S}}, - {35, {"TwelveCogWheel"_s, AccessorySize::S}}, + {1, {"Cube"_s, Accessory::Size::S}}, + {2, {"Pentagon"_s, Accessory::Size::S}}, + {3, {"Hexagon"_s, Accessory::Size::S}}, + {4, {"Cylinder"_s, Accessory::Size::S}}, + {5, {"Sphere"_s, Accessory::Size::S}}, + {6, {"TriPyramid"_s, Accessory::Size::S}}, + {7, {"SquPyramid"_s, Accessory::Size::S}}, + {8, {"PenPyramid"_s, Accessory::Size::S}}, + {9, {"HexPyramid"_s, Accessory::Size::S}}, + {10, {"Cone"_s, Accessory::Size::S}}, + {11, {"SquStick"_s, Accessory::Size::S}}, + {12, {"PenStick"_s, Accessory::Size::S}}, + {13, {"HexStick"_s, Accessory::Size::S}}, + {14, {"CycStick"_s, Accessory::Size::S}}, + {15, {"Capsule"_s, Accessory::Size::S}}, + {16, {"Decal Pad 01"_s, Accessory::Size::S}}, + {17, {"Decal Pad 02"_s, Accessory::Size::S}}, + {18, {"Decal Pad 03"_s, Accessory::Size::S}}, + {19, {"Decal Pad 04"_s, Accessory::Size::S}}, + {20, {"Decal Pad 05"_s, Accessory::Size::S}}, + {21, {"Triangle"_s, Accessory::Size::S}}, + {22, {"ThinStar"_s, Accessory::Size::S}}, + {23, {"Star"_s, Accessory::Size::S}}, + {24, {"SixSideStar"_s, Accessory::Size::S}}, + {25, {"Asterisk"_s, Accessory::Size::S}}, + {26, {"Ring"_s, Accessory::Size::S}}, + {27, {"SawedRing"_s, Accessory::Size::S}}, + {28, {"HalfRing"_s, Accessory::Size::S}}, + {29, {"Cresent"_s, Accessory::Size::S}}, + {30, {"Donut"_s, Accessory::Size::S}}, + {31, {"FiveCogWheel"_s, Accessory::Size::S}}, + {32, {"SixCogWheel"_s, Accessory::Size::S}}, + {33, {"SevenCogWheel"_s, Accessory::Size::S}}, + {34, {"EightCogWheel"_s, Accessory::Size::S}}, + {35, {"TwelveCogWheel"_s, Accessory::Size::S}}, - {51, {"SquBevel"_s, AccessorySize::S}}, - {52, {"TriBevel"_s, AccessorySize::S}}, - {53, {"PenBevel"_s, AccessorySize::S}}, - {54, {"HexBevel"_s, AccessorySize::S}}, - {55, {"CycBevel"_s, AccessorySize::S}}, - {56, {"RecBevel"_s, AccessorySize::S}}, - {57, {"DaiBevel"_s, AccessorySize::S}}, - {58, {"MonBevel"_s, AccessorySize::S}}, - {59, {"CofBevel"_s, AccessorySize::S}}, - {60, {"JevBevel"_s, AccessorySize::S}}, - {61, {"SquEmboss"_s, AccessorySize::S}}, - {62, {"TriEmboss"_s, AccessorySize::S}}, - {63, {"PenEmboss"_s, AccessorySize::S}}, - {64, {"HexEmboss"_s, AccessorySize::S}}, - {65, {"CycEmboss"_s, AccessorySize::S}}, - {66, {"RecEmboss"_s, AccessorySize::S}}, - {67, {"DaiEmboss"_s, AccessorySize::S}}, - {68, {"MonEmboss"_s, AccessorySize::S}}, - {69, {"CofEmboss"_s, AccessorySize::S}}, - {70, {"JevEmboss"_s, AccessorySize::S}}, + {51, {"SquBevel"_s, Accessory::Size::S}}, + {52, {"TriBevel"_s, Accessory::Size::S}}, + {53, {"PenBevel"_s, Accessory::Size::S}}, + {54, {"HexBevel"_s, Accessory::Size::S}}, + {55, {"CycBevel"_s, Accessory::Size::S}}, + {56, {"RecBevel"_s, Accessory::Size::S}}, + {57, {"DaiBevel"_s, Accessory::Size::S}}, + {58, {"MonBevel"_s, Accessory::Size::S}}, + {59, {"CofBevel"_s, Accessory::Size::S}}, + {60, {"JevBevel"_s, Accessory::Size::S}}, + {61, {"SquEmboss"_s, Accessory::Size::S}}, + {62, {"TriEmboss"_s, Accessory::Size::S}}, + {63, {"PenEmboss"_s, Accessory::Size::S}}, + {64, {"HexEmboss"_s, Accessory::Size::S}}, + {65, {"CycEmboss"_s, Accessory::Size::S}}, + {66, {"RecEmboss"_s, Accessory::Size::S}}, + {67, {"DaiEmboss"_s, Accessory::Size::S}}, + {68, {"MonEmboss"_s, Accessory::Size::S}}, + {69, {"CofEmboss"_s, Accessory::Size::S}}, + {70, {"JevEmboss"_s, Accessory::Size::S}}, - {101, {"Flat Hex Pin"_s, AccessorySize::S}}, - {102, {"Cross Circle Pin"_s, AccessorySize::S}}, - {103, {"Flat Circle Pin"_s, AccessorySize::S}}, - {104, {"Hex Circle Pin"_s, AccessorySize::S}}, - {105, {"Circle Button Pin"_s, AccessorySize::S}}, - {106, {"Hexagon Pin"_s, AccessorySize::S}}, - {107, {"Cross Square Pin"_s, AccessorySize::S}}, - {108, {"Flat Square Pin"_s, AccessorySize::S}}, - {109, {"Quad Corner Pin"_s, AccessorySize::S}}, - {110, {"Bi Corner Pin"_s, AccessorySize::S}}, - {111, {"Circle Pin"_s, AccessorySize::S}}, - {112, {"Flat End Pin"_s, AccessorySize::S}}, - {113, {"Flat Cut Pin"_s, AccessorySize::S}}, - {114, {"Radial Pin"_s, AccessorySize::S}}, - {115, {"Diamiter Pin"_s, AccessorySize::S}}, + {101, {"Flat Hex Pin"_s, Accessory::Size::S}}, + {102, {"Cross Circle Pin"_s, Accessory::Size::S}}, + {103, {"Flat Circle Pin"_s, Accessory::Size::S}}, + {104, {"Hex Circle Pin"_s, Accessory::Size::S}}, + {105, {"Circle Button Pin"_s, Accessory::Size::S}}, + {106, {"Hexagon Pin"_s, Accessory::Size::S}}, + {107, {"Cross Square Pin"_s, Accessory::Size::S}}, + {108, {"Flat Square Pin"_s, Accessory::Size::S}}, + {109, {"Quad Corner Pin"_s, Accessory::Size::S}}, + {110, {"Bi Corner Pin"_s, Accessory::Size::S}}, + {111, {"Circle Pin"_s, Accessory::Size::S}}, + {112, {"Flat End Pin"_s, Accessory::Size::S}}, + {113, {"Flat Cut Pin"_s, Accessory::Size::S}}, + {114, {"Radial Pin"_s, Accessory::Size::S}}, + {115, {"Diamiter Pin"_s, Accessory::Size::S}}, - {151, {"TriPoint"_s, AccessorySize::S}}, - {152, {"SquPoint"_s, AccessorySize::S}}, - {153, {"PenPoint"_s, AccessorySize::S}}, - {154, {"HexPoint"_s, AccessorySize::S}}, - {155, {"CycPoint"_s, AccessorySize::S}}, - {156, {"Bevel SquCutPoint"_s, AccessorySize::S}}, - {157, {"Bevel HexCutPoint"_s, AccessorySize::S}}, - {158, {"Bevel HexPoint"_s, AccessorySize::S}}, - {159, {"Bevel CycCutPoint"_s, AccessorySize::S}}, - {160, {"Bevel CycPoint"_s, AccessorySize::S}}, + {151, {"TriPoint"_s, Accessory::Size::S}}, + {152, {"SquPoint"_s, Accessory::Size::S}}, + {153, {"PenPoint"_s, Accessory::Size::S}}, + {154, {"HexPoint"_s, Accessory::Size::S}}, + {155, {"CycPoint"_s, Accessory::Size::S}}, + {156, {"Bevel SquCutPoint"_s, Accessory::Size::S}}, + {157, {"Bevel HexCutPoint"_s, Accessory::Size::S}}, + {158, {"Bevel HexPoint"_s, Accessory::Size::S}}, + {159, {"Bevel CycCutPoint"_s, Accessory::Size::S}}, + {160, {"Bevel CycPoint"_s, Accessory::Size::S}}, - {201, {"Shaped Edge 01"_s, AccessorySize::M}}, - {202, {"Shaped Edge 02"_s, AccessorySize::M}}, - {203, {"Shaped Edge 03"_s, AccessorySize::M}}, - {204, {"Shaped Edge 04"_s, AccessorySize::M}}, - {205, {"Shaped Edge 05"_s, AccessorySize::M}}, - {206, {"Shaped Edge 06"_s, AccessorySize::M}}, - {207, {"Shaped Edge 07"_s, AccessorySize::M}}, - {208, {"Shaped Edge 08"_s, AccessorySize::M}}, - {209, {"Shaped Edge 09"_s, AccessorySize::M}}, - {210, {"Shaped Edge 10"_s, AccessorySize::M}}, - {211, {"Shaped Edge 11"_s, AccessorySize::M}}, - {212, {"Shaped Edge 12"_s, AccessorySize::M}}, - {213, {"Shaped Edge 13"_s, AccessorySize::M}}, - {214, {"Shaped Edge 14"_s, AccessorySize::M}}, - {215, {"Shaped Edge 15"_s, AccessorySize::M}}, - {216, {"Shaped Edge 16"_s, AccessorySize::M}}, - {217, {"Shaped Edge 17"_s, AccessorySize::M}}, - {218, {"Shaped Edge 18"_s, AccessorySize::M}}, - {219, {"Shaped Edge 19"_s, AccessorySize::M}}, - {220, {"Shaped Edge 20"_s, AccessorySize::M}}, + {201, {"Shaped Edge 01"_s, Accessory::Size::M}}, + {202, {"Shaped Edge 02"_s, Accessory::Size::M}}, + {203, {"Shaped Edge 03"_s, Accessory::Size::M}}, + {204, {"Shaped Edge 04"_s, Accessory::Size::M}}, + {205, {"Shaped Edge 05"_s, Accessory::Size::M}}, + {206, {"Shaped Edge 06"_s, Accessory::Size::M}}, + {207, {"Shaped Edge 07"_s, Accessory::Size::M}}, + {208, {"Shaped Edge 08"_s, Accessory::Size::M}}, + {209, {"Shaped Edge 09"_s, Accessory::Size::M}}, + {210, {"Shaped Edge 10"_s, Accessory::Size::M}}, + {211, {"Shaped Edge 11"_s, Accessory::Size::M}}, + {212, {"Shaped Edge 12"_s, Accessory::Size::M}}, + {213, {"Shaped Edge 13"_s, Accessory::Size::M}}, + {214, {"Shaped Edge 14"_s, Accessory::Size::M}}, + {215, {"Shaped Edge 15"_s, Accessory::Size::M}}, + {216, {"Shaped Edge 16"_s, Accessory::Size::M}}, + {217, {"Shaped Edge 17"_s, Accessory::Size::M}}, + {218, {"Shaped Edge 18"_s, Accessory::Size::M}}, + {219, {"Shaped Edge 19"_s, Accessory::Size::M}}, + {220, {"Shaped Edge 20"_s, Accessory::Size::M}}, - {251, {"Fish Tail 01"_s, AccessorySize::M}}, - {252, {"Fish Tail 02"_s, AccessorySize::M}}, - {253, {"Fish Tail 03"_s, AccessorySize::M}}, - {254, {"Fish Tail 04"_s, AccessorySize::M}}, - {255, {"Fish Tail 05"_s, AccessorySize::M}}, - {256, {"Based Separator 01"_s, AccessorySize::M}}, - {257, {"Based Separator 02"_s, AccessorySize::M}}, - {258, {"Based Separator 03"_s, AccessorySize::M}}, - {259, {"Based Separator 04"_s, AccessorySize::M}}, - {260, {"Based Separator 05"_s, AccessorySize::M}}, - {261, {"Based Separator 06"_s, AccessorySize::M}}, - {262, {"Based Separator 07"_s, AccessorySize::M}}, - {263, {"Based Separator 08"_s, AccessorySize::M}}, - {264, {"Based Separator 09"_s, AccessorySize::M}}, - {265, {"Based Separator 10"_s, AccessorySize::M}}, + {251, {"Fish Tail 01"_s, Accessory::Size::M}}, + {252, {"Fish Tail 02"_s, Accessory::Size::M}}, + {253, {"Fish Tail 03"_s, Accessory::Size::M}}, + {254, {"Fish Tail 04"_s, Accessory::Size::M}}, + {255, {"Fish Tail 05"_s, Accessory::Size::M}}, + {256, {"Based Separator 01"_s, Accessory::Size::M}}, + {257, {"Based Separator 02"_s, Accessory::Size::M}}, + {258, {"Based Separator 03"_s, Accessory::Size::M}}, + {259, {"Based Separator 04"_s, Accessory::Size::M}}, + {260, {"Based Separator 05"_s, Accessory::Size::M}}, + {261, {"Based Separator 06"_s, Accessory::Size::M}}, + {262, {"Based Separator 07"_s, Accessory::Size::M}}, + {263, {"Based Separator 08"_s, Accessory::Size::M}}, + {264, {"Based Separator 09"_s, Accessory::Size::M}}, + {265, {"Based Separator 10"_s, Accessory::Size::M}}, - {301, {"Rectangular Box 01"_s, AccessorySize::M}}, - {302, {"Rectangular Box 02"_s, AccessorySize::M}}, - {303, {"Rectangular Box 03"_s, AccessorySize::M}}, - {304, {"Rectangular Box 04"_s, AccessorySize::M}}, - {305, {"Rectangular Box 05"_s, AccessorySize::M}}, - {306, {"CofBox 01"_s, AccessorySize::M}}, - {307, {"CofBox 02"_s, AccessorySize::M}}, - {308, {"CofBox 03"_s, AccessorySize::M}}, - {309, {"CofBox 04"_s, AccessorySize::M}}, - {310, {"CofBox 05"_s, AccessorySize::M}}, - {311, {"Triangular Box 01"_s, AccessorySize::M}}, - {312, {"Triangular Box 02"_s, AccessorySize::M}}, - {313, {"Triangular Box 03"_s, AccessorySize::M}}, - {314, {"Triangular Box 04"_s, AccessorySize::M}}, - {315, {"Triangular Box 05"_s, AccessorySize::M}}, - {316, {"Diagonal Box A01"_s, AccessorySize::M}}, - {317, {"Diagonal Box A02"_s, AccessorySize::M}}, - {318, {"Diagonal Box A03"_s, AccessorySize::M}}, - {319, {"Diagonal Box A04"_s, AccessorySize::M}}, - {320, {"Diagonal Box A05"_s, AccessorySize::M}}, - {321, {"Diagonal Box B01"_s, AccessorySize::M}}, - {322, {"Diagonal Box B02"_s, AccessorySize::M}}, - {323, {"Diagonal Box B03"_s, AccessorySize::M}}, - {324, {"Diagonal Box B04"_s, AccessorySize::M}}, - {325, {"Diagonal Box B05"_s, AccessorySize::M}}, + {301, {"Rectangular Box 01"_s, Accessory::Size::M}}, + {302, {"Rectangular Box 02"_s, Accessory::Size::M}}, + {303, {"Rectangular Box 03"_s, Accessory::Size::M}}, + {304, {"Rectangular Box 04"_s, Accessory::Size::M}}, + {305, {"Rectangular Box 05"_s, Accessory::Size::M}}, + {306, {"CofBox 01"_s, Accessory::Size::M}}, + {307, {"CofBox 02"_s, Accessory::Size::M}}, + {308, {"CofBox 03"_s, Accessory::Size::M}}, + {309, {"CofBox 04"_s, Accessory::Size::M}}, + {310, {"CofBox 05"_s, Accessory::Size::M}}, + {311, {"Triangular Box 01"_s, Accessory::Size::M}}, + {312, {"Triangular Box 02"_s, Accessory::Size::M}}, + {313, {"Triangular Box 03"_s, Accessory::Size::M}}, + {314, {"Triangular Box 04"_s, Accessory::Size::M}}, + {315, {"Triangular Box 05"_s, Accessory::Size::M}}, + {316, {"Diagonal Box A01"_s, Accessory::Size::M}}, + {317, {"Diagonal Box A02"_s, Accessory::Size::M}}, + {318, {"Diagonal Box A03"_s, Accessory::Size::M}}, + {319, {"Diagonal Box A04"_s, Accessory::Size::M}}, + {320, {"Diagonal Box A05"_s, Accessory::Size::M}}, + {321, {"Diagonal Box B01"_s, Accessory::Size::M}}, + {322, {"Diagonal Box B02"_s, Accessory::Size::M}}, + {323, {"Diagonal Box B03"_s, Accessory::Size::M}}, + {324, {"Diagonal Box B04"_s, Accessory::Size::M}}, + {325, {"Diagonal Box B05"_s, Accessory::Size::M}}, // endregion // region Armours - {1001, {"Short Layer 01"_s, AccessorySize::M}}, - {1002, {"Short Layer 02"_s, AccessorySize::M}}, - {1003, {"Short Layer 03"_s, AccessorySize::M}}, - {1004, {"Short Layer 04"_s, AccessorySize::M}}, - {1005, {"Short Layer 05"_s, AccessorySize::M}}, - {1006, {"Long Layer 01"_s, AccessorySize::M}}, - {1007, {"Long Layer 02"_s, AccessorySize::M}}, - {1008, {"Long Layer 03"_s, AccessorySize::M}}, - {1009, {"Long Layer 04"_s, AccessorySize::M}}, - {1010, {"Long Layer 05"_s, AccessorySize::M}}, - {1011, {"Diagonal Long Layer 01"_s, AccessorySize::M}}, - {1012, {"Diagonal Long Layer 02"_s, AccessorySize::M}}, - {1013, {"Diagonal Long Layer 03"_s, AccessorySize::M}}, - {1014, {"Diagonal Long Layer 04"_s, AccessorySize::M}}, - {1015, {"Diagonal Long Layer 05"_s, AccessorySize::M}}, + {1001, {"Short Layer 01"_s, Accessory::Size::M}}, + {1002, {"Short Layer 02"_s, Accessory::Size::M}}, + {1003, {"Short Layer 03"_s, Accessory::Size::M}}, + {1004, {"Short Layer 04"_s, Accessory::Size::M}}, + {1005, {"Short Layer 05"_s, Accessory::Size::M}}, + {1006, {"Long Layer 01"_s, Accessory::Size::M}}, + {1007, {"Long Layer 02"_s, Accessory::Size::M}}, + {1008, {"Long Layer 03"_s, Accessory::Size::M}}, + {1009, {"Long Layer 04"_s, Accessory::Size::M}}, + {1010, {"Long Layer 05"_s, Accessory::Size::M}}, + {1011, {"Diagonal Long Layer 01"_s, Accessory::Size::M}}, + {1012, {"Diagonal Long Layer 02"_s, Accessory::Size::M}}, + {1013, {"Diagonal Long Layer 03"_s, Accessory::Size::M}}, + {1014, {"Diagonal Long Layer 04"_s, Accessory::Size::M}}, + {1015, {"Diagonal Long Layer 05"_s, Accessory::Size::M}}, - {1051, {"Sloped Layer 01"_s, AccessorySize::M}}, - {1052, {"Sloped Layer 02"_s, AccessorySize::M}}, - {1053, {"Sloped Layer 03"_s, AccessorySize::M}}, - {1054, {"Sloped Layer 04"_s, AccessorySize::M}}, - {1055, {"Sloped Layer 05"_s, AccessorySize::M}}, - {1056, {"Sloped Layer 06"_s, AccessorySize::M}}, - {1057, {"Sloped Layer 07"_s, AccessorySize::M}}, - {1058, {"Sloped Layer 08"_s, AccessorySize::M}}, - {1059, {"Sloped Layer 09"_s, AccessorySize::M}}, - {1060, {"Sloped Layer 10"_s, AccessorySize::M}}, - {1061, {"Sloped Layer 11"_s, AccessorySize::M}}, - {1062, {"Sloped Layer 12"_s, AccessorySize::M}}, - {1063, {"Sloped Layer 13"_s, AccessorySize::M}}, - {1064, {"Sloped Layer 14"_s, AccessorySize::M}}, - {1065, {"Sloped Layer 15"_s, AccessorySize::M}}, + {1051, {"Sloped Layer 01"_s, Accessory::Size::M}}, + {1052, {"Sloped Layer 02"_s, Accessory::Size::M}}, + {1053, {"Sloped Layer 03"_s, Accessory::Size::M}}, + {1054, {"Sloped Layer 04"_s, Accessory::Size::M}}, + {1055, {"Sloped Layer 05"_s, Accessory::Size::M}}, + {1056, {"Sloped Layer 06"_s, Accessory::Size::M}}, + {1057, {"Sloped Layer 07"_s, Accessory::Size::M}}, + {1058, {"Sloped Layer 08"_s, Accessory::Size::M}}, + {1059, {"Sloped Layer 09"_s, Accessory::Size::M}}, + {1060, {"Sloped Layer 10"_s, Accessory::Size::M}}, + {1061, {"Sloped Layer 11"_s, Accessory::Size::M}}, + {1062, {"Sloped Layer 12"_s, Accessory::Size::M}}, + {1063, {"Sloped Layer 13"_s, Accessory::Size::M}}, + {1064, {"Sloped Layer 14"_s, Accessory::Size::M}}, + {1065, {"Sloped Layer 15"_s, Accessory::Size::M}}, - {1101, {"Raised Center 01"_s, AccessorySize::M}}, - {1102, {"Raised Center 02"_s, AccessorySize::M}}, - {1103, {"Raised Center 03"_s, AccessorySize::M}}, - {1104, {"Raised Center 04"_s, AccessorySize::M}}, - {1105, {"Raised Center 05"_s, AccessorySize::M}}, - {1106, {"Raised Block 01"_s, AccessorySize::M}}, - {1107, {"Raised Block 02"_s, AccessorySize::M}}, - {1108, {"Raised Block 03"_s, AccessorySize::M}}, - {1109, {"Raised Pointed"_s, AccessorySize::M}}, - {1110, {"Raised Cover"_s, AccessorySize::M}}, - {1111, {"Raised Slant 01"_s, AccessorySize::M}}, - {1112, {"Raised Slant 02"_s, AccessorySize::M}}, - {1113, {"Raised Slant 03"_s, AccessorySize::M}}, - {1114, {"Raised Slant 04"_s, AccessorySize::M}}, - {1115, {"Raised Slant 05"_s, AccessorySize::M}}, + {1101, {"Raised Center 01"_s, Accessory::Size::M}}, + {1102, {"Raised Center 02"_s, Accessory::Size::M}}, + {1103, {"Raised Center 03"_s, Accessory::Size::M}}, + {1104, {"Raised Center 04"_s, Accessory::Size::M}}, + {1105, {"Raised Center 05"_s, Accessory::Size::M}}, + {1106, {"Raised Block 01"_s, Accessory::Size::M}}, + {1107, {"Raised Block 02"_s, Accessory::Size::M}}, + {1108, {"Raised Block 03"_s, Accessory::Size::M}}, + {1109, {"Raised Pointed"_s, Accessory::Size::M}}, + {1110, {"Raised Cover"_s, Accessory::Size::M}}, + {1111, {"Raised Slant 01"_s, Accessory::Size::M}}, + {1112, {"Raised Slant 02"_s, Accessory::Size::M}}, + {1113, {"Raised Slant 03"_s, Accessory::Size::M}}, + {1114, {"Raised Slant 04"_s, Accessory::Size::M}}, + {1115, {"Raised Slant 05"_s, Accessory::Size::M}}, - {1151, {"Wide Patch 01"_s, AccessorySize::L}}, - {1152, {"Wide Patch 02"_s, AccessorySize::L}}, - {1153, {"Wide Patch 03"_s, AccessorySize::L}}, - {1154, {"Wide Patch 04"_s, AccessorySize::L}}, - {1155, {"Wide Patch 05"_s, AccessorySize::L}}, + {1151, {"Wide Patch 01"_s, Accessory::Size::L}}, + {1152, {"Wide Patch 02"_s, Accessory::Size::L}}, + {1153, {"Wide Patch 03"_s, Accessory::Size::L}}, + {1154, {"Wide Patch 04"_s, Accessory::Size::L}}, + {1155, {"Wide Patch 05"_s, Accessory::Size::L}}, - {1201, {"Pointed Armour 01"_s, AccessorySize::L}}, - {1202, {"Pointed Armour 02"_s, AccessorySize::L}}, - {1203, {"Pointed Armour 03"_s, AccessorySize::L}}, - {1204, {"Pointed Armour 04"_s, AccessorySize::L}}, - {1205, {"Pointed Armour 05"_s, AccessorySize::L}}, - {1206, {"Pointed Armour 06"_s, AccessorySize::L}}, - {1207, {"Pointed Armour 07"_s, AccessorySize::L}}, - {1208, {"Pointed Armour 08"_s, AccessorySize::L}}, - {1209, {"Pointed Armour 09"_s, AccessorySize::L}}, - {1210, {"Pointed Armour 10"_s, AccessorySize::L}}, - {1211, {"Pointed Armour 11"_s, AccessorySize::L}}, - {1212, {"Pointed Armour 12"_s, AccessorySize::L}}, - {1213, {"Pointed Armour 13"_s, AccessorySize::L}}, - {1214, {"Pointed Armour 14"_s, AccessorySize::L}}, - {1215, {"Pointed Armour 15"_s, AccessorySize::L}}, + {1201, {"Pointed Armour 01"_s, Accessory::Size::L}}, + {1202, {"Pointed Armour 02"_s, Accessory::Size::L}}, + {1203, {"Pointed Armour 03"_s, Accessory::Size::L}}, + {1204, {"Pointed Armour 04"_s, Accessory::Size::L}}, + {1205, {"Pointed Armour 05"_s, Accessory::Size::L}}, + {1206, {"Pointed Armour 06"_s, Accessory::Size::L}}, + {1207, {"Pointed Armour 07"_s, Accessory::Size::L}}, + {1208, {"Pointed Armour 08"_s, Accessory::Size::L}}, + {1209, {"Pointed Armour 09"_s, Accessory::Size::L}}, + {1210, {"Pointed Armour 10"_s, Accessory::Size::L}}, + {1211, {"Pointed Armour 11"_s, Accessory::Size::L}}, + {1212, {"Pointed Armour 12"_s, Accessory::Size::L}}, + {1213, {"Pointed Armour 13"_s, Accessory::Size::L}}, + {1214, {"Pointed Armour 14"_s, Accessory::Size::L}}, + {1215, {"Pointed Armour 15"_s, Accessory::Size::L}}, - {1251, {"E Limb Cover 01"_s, AccessorySize::L}}, - {1252, {"E Limb Cover 02"_s, AccessorySize::L}}, - {1253, {"E Limb Cover 03"_s, AccessorySize::L}}, - {1254, {"E Limb Cover 04"_s, AccessorySize::L}}, - {1255, {"E Limb Cover 05"_s, AccessorySize::L}}, - {1256, {"E Limb Cover 06"_s, AccessorySize::L}}, - {1257, {"E Limb Cover 07"_s, AccessorySize::L}}, - {1258, {"E Limb Cover 08"_s, AccessorySize::L}}, - {1259, {"E Limb Cover 09"_s, AccessorySize::L}}, - {1260, {"E Limb Cover 10"_s, AccessorySize::L}}, + {1251, {"E Limb Cover 01"_s, Accessory::Size::L}}, + {1252, {"E Limb Cover 02"_s, Accessory::Size::L}}, + {1253, {"E Limb Cover 03"_s, Accessory::Size::L}}, + {1254, {"E Limb Cover 04"_s, Accessory::Size::L}}, + {1255, {"E Limb Cover 05"_s, Accessory::Size::L}}, + {1256, {"E Limb Cover 06"_s, Accessory::Size::L}}, + {1257, {"E Limb Cover 07"_s, Accessory::Size::L}}, + {1258, {"E Limb Cover 08"_s, Accessory::Size::L}}, + {1259, {"E Limb Cover 09"_s, Accessory::Size::L}}, + {1260, {"E Limb Cover 10"_s, Accessory::Size::L}}, - {1301, {"C Limb Cover 01"_s, AccessorySize::L}}, - {1302, {"C Limb Cover 02"_s, AccessorySize::L}}, - {1303, {"C Limb Cover 03"_s, AccessorySize::L}}, - {1304, {"C Limb Cover 04"_s, AccessorySize::L}}, - {1305, {"C Limb Cover 05"_s, AccessorySize::L}}, - {1306, {"C Limb Cover 06"_s, AccessorySize::L}}, - {1307, {"C Limb Cover 07"_s, AccessorySize::L}}, - {1308, {"C Limb Cover 08"_s, AccessorySize::L}}, - {1309, {"C Limb Cover 09"_s, AccessorySize::L}}, - {1310, {"C Limb Cover 10"_s, AccessorySize::L}}, - {1311, {"C Limb Cover 11"_s, AccessorySize::L}}, - {1312, {"C Limb Cover 12"_s, AccessorySize::L}}, - {1313, {"C Limb Cover 13"_s, AccessorySize::L}}, - {1314, {"C Limb Cover 14"_s, AccessorySize::L}}, - {1315, {"C Limb Cover 15"_s, AccessorySize::L}}, - {1316, {"C Limb Cover 16"_s, AccessorySize::L}}, - {1317, {"C Limb Cover 17"_s, AccessorySize::L}}, - {1318, {"C Limb Cover 18"_s, AccessorySize::L}}, - {1319, {"C Limb Cover 19"_s, AccessorySize::L}}, - {1320, {"C Limb Cover 20"_s, AccessorySize::L}}, + {1301, {"C Limb Cover 01"_s, Accessory::Size::L}}, + {1302, {"C Limb Cover 02"_s, Accessory::Size::L}}, + {1303, {"C Limb Cover 03"_s, Accessory::Size::L}}, + {1304, {"C Limb Cover 04"_s, Accessory::Size::L}}, + {1305, {"C Limb Cover 05"_s, Accessory::Size::L}}, + {1306, {"C Limb Cover 06"_s, Accessory::Size::L}}, + {1307, {"C Limb Cover 07"_s, Accessory::Size::L}}, + {1308, {"C Limb Cover 08"_s, Accessory::Size::L}}, + {1309, {"C Limb Cover 09"_s, Accessory::Size::L}}, + {1310, {"C Limb Cover 10"_s, Accessory::Size::L}}, + {1311, {"C Limb Cover 11"_s, Accessory::Size::L}}, + {1312, {"C Limb Cover 12"_s, Accessory::Size::L}}, + {1313, {"C Limb Cover 13"_s, Accessory::Size::L}}, + {1314, {"C Limb Cover 14"_s, Accessory::Size::L}}, + {1315, {"C Limb Cover 15"_s, Accessory::Size::L}}, + {1316, {"C Limb Cover 16"_s, Accessory::Size::L}}, + {1317, {"C Limb Cover 17"_s, Accessory::Size::L}}, + {1318, {"C Limb Cover 18"_s, Accessory::Size::L}}, + {1319, {"C Limb Cover 19"_s, Accessory::Size::L}}, + {1320, {"C Limb Cover 20"_s, Accessory::Size::L}}, - {1351, {"P Limb Cover 01"_s, AccessorySize::XL}}, - {1352, {"P Limb Cover 02"_s, AccessorySize::XL}}, - {1353, {"P Limb Cover 03"_s, AccessorySize::XL}}, - {1354, {"P Limb Cover 04"_s, AccessorySize::XL}}, - {1355, {"P Limb Cover 05"_s, AccessorySize::XL}}, + {1351, {"P Limb Cover 01"_s, Accessory::Size::XL}}, + {1352, {"P Limb Cover 02"_s, Accessory::Size::XL}}, + {1353, {"P Limb Cover 03"_s, Accessory::Size::XL}}, + {1354, {"P Limb Cover 04"_s, Accessory::Size::XL}}, + {1355, {"P Limb Cover 05"_s, Accessory::Size::XL}}, - {1401, {"Flat Cover 01"_s, AccessorySize::XL}}, - {1402, {"Flat Cover 02"_s, AccessorySize::XL}}, - {1403, {"Flat Cover 03"_s, AccessorySize::XL}}, - {1404, {"Flat Cover 04"_s, AccessorySize::XL}}, - {1405, {"Flat Cover 05"_s, AccessorySize::XL}}, - {1406, {"Flat Cover 06"_s, AccessorySize::XL}}, - {1407, {"Flat Cover 07"_s, AccessorySize::XL}}, - {1408, {"Flat Cover 08"_s, AccessorySize::XL}}, - {1409, {"Flat Cover 09"_s, AccessorySize::XL}}, - {1410, {"Flat Cover 10"_s, AccessorySize::XL}}, + {1401, {"Flat Cover 01"_s, Accessory::Size::XL}}, + {1402, {"Flat Cover 02"_s, Accessory::Size::XL}}, + {1403, {"Flat Cover 03"_s, Accessory::Size::XL}}, + {1404, {"Flat Cover 04"_s, Accessory::Size::XL}}, + {1405, {"Flat Cover 05"_s, Accessory::Size::XL}}, + {1406, {"Flat Cover 06"_s, Accessory::Size::XL}}, + {1407, {"Flat Cover 07"_s, Accessory::Size::XL}}, + {1408, {"Flat Cover 08"_s, Accessory::Size::XL}}, + {1409, {"Flat Cover 09"_s, Accessory::Size::XL}}, + {1410, {"Flat Cover 10"_s, Accessory::Size::XL}}, - {1451, {"L Side Opening 01"_s, AccessorySize::XL}}, - {1452, {"L Side Opening 02"_s, AccessorySize::XL}}, - {1453, {"L Side Opening 03"_s, AccessorySize::XL}}, - {1454, {"L Side Opening 04"_s, AccessorySize::XL}}, - {1455, {"L Side Opening 05"_s, AccessorySize::XL}}, - {1456, {"L Side Opening 06"_s, AccessorySize::XL}}, - {1457, {"L Side Opening 07"_s, AccessorySize::XL}}, - {1458, {"L Side Opening 08"_s, AccessorySize::XL}}, - {1459, {"L Side Opening 09"_s, AccessorySize::XL}}, - {1460, {"L Side Opening 10"_s, AccessorySize::XL}}, + {1451, {"L Side Opening 01"_s, Accessory::Size::XL}}, + {1452, {"L Side Opening 02"_s, Accessory::Size::XL}}, + {1453, {"L Side Opening 03"_s, Accessory::Size::XL}}, + {1454, {"L Side Opening 04"_s, Accessory::Size::XL}}, + {1455, {"L Side Opening 05"_s, Accessory::Size::XL}}, + {1456, {"L Side Opening 06"_s, Accessory::Size::XL}}, + {1457, {"L Side Opening 07"_s, Accessory::Size::XL}}, + {1458, {"L Side Opening 08"_s, Accessory::Size::XL}}, + {1459, {"L Side Opening 09"_s, Accessory::Size::XL}}, + {1460, {"L Side Opening 10"_s, Accessory::Size::XL}}, // endregion // region Components - {2001, {"Disc Padding 01"_s, AccessorySize::M}}, - {2002, {"Disc Padding 02"_s, AccessorySize::M}}, - {2003, {"Disc Padding 03"_s, AccessorySize::M}}, - {2004, {"Disc Padding 04"_s, AccessorySize::M}}, - {2005, {"Disc Padding 05"_s, AccessorySize::M}}, - {2006, {"Thin Padding 01"_s, AccessorySize::M}}, - {2007, {"Thin Padding 02"_s, AccessorySize::M}}, - {2008, {"Thin Padding 03"_s, AccessorySize::M}}, - {2009, {"Thin Padding 04"_s, AccessorySize::M}}, - {2010, {"Thin Padding 05"_s, AccessorySize::M}}, - {2011, {"Thick Padding 01"_s, AccessorySize::M}}, - {2012, {"Thick Padding 02"_s, AccessorySize::M}}, - {2013, {"Thick Padding 03"_s, AccessorySize::M}}, - {2014, {"Thick Padding 04"_s, AccessorySize::M}}, - {2015, {"Thick Padding 05"_s, AccessorySize::M}}, - {2016, {"Thick Padding 06"_s, AccessorySize::M}}, - {2017, {"Thick Padding 07"_s, AccessorySize::M}}, - {2018, {"Thick Padding 08"_s, AccessorySize::M}}, - {2019, {"Thick Padding 09"_s, AccessorySize::M}}, - {2020, {"Thick Padding 10"_s, AccessorySize::M}}, - {2021, {"CSide Padding 01"_s, AccessorySize::M}}, - {2022, {"CSide Padding 02"_s, AccessorySize::M}}, - {2023, {"CSide Padding 03"_s, AccessorySize::M}}, - {2024, {"CSide Padding 04"_s, AccessorySize::M}}, - {2025, {"CSide Padding 05"_s, AccessorySize::M}}, + {2001, {"Disc Padding 01"_s, Accessory::Size::M}}, + {2002, {"Disc Padding 02"_s, Accessory::Size::M}}, + {2003, {"Disc Padding 03"_s, Accessory::Size::M}}, + {2004, {"Disc Padding 04"_s, Accessory::Size::M}}, + {2005, {"Disc Padding 05"_s, Accessory::Size::M}}, + {2006, {"Thin Padding 01"_s, Accessory::Size::M}}, + {2007, {"Thin Padding 02"_s, Accessory::Size::M}}, + {2008, {"Thin Padding 03"_s, Accessory::Size::M}}, + {2009, {"Thin Padding 04"_s, Accessory::Size::M}}, + {2010, {"Thin Padding 05"_s, Accessory::Size::M}}, + {2011, {"Thick Padding 01"_s, Accessory::Size::M}}, + {2012, {"Thick Padding 02"_s, Accessory::Size::M}}, + {2013, {"Thick Padding 03"_s, Accessory::Size::M}}, + {2014, {"Thick Padding 04"_s, Accessory::Size::M}}, + {2015, {"Thick Padding 05"_s, Accessory::Size::M}}, + {2016, {"Thick Padding 06"_s, Accessory::Size::M}}, + {2017, {"Thick Padding 07"_s, Accessory::Size::M}}, + {2018, {"Thick Padding 08"_s, Accessory::Size::M}}, + {2019, {"Thick Padding 09"_s, Accessory::Size::M}}, + {2020, {"Thick Padding 10"_s, Accessory::Size::M}}, + {2021, {"CSide Padding 01"_s, Accessory::Size::M}}, + {2022, {"CSide Padding 02"_s, Accessory::Size::M}}, + {2023, {"CSide Padding 03"_s, Accessory::Size::M}}, + {2024, {"CSide Padding 04"_s, Accessory::Size::M}}, + {2025, {"CSide Padding 05"_s, Accessory::Size::M}}, - {2051, {"Container 01"_s, AccessorySize::L}}, - {2052, {"Container 02"_s, AccessorySize::L}}, - {2053, {"Container 03"_s, AccessorySize::L}}, - {2054, {"Container 04"_s, AccessorySize::L}}, - {2055, {"Container 05"_s, AccessorySize::L}}, + {2051, {"Container 01"_s, Accessory::Size::L}}, + {2052, {"Container 02"_s, Accessory::Size::L}}, + {2053, {"Container 03"_s, Accessory::Size::L}}, + {2054, {"Container 04"_s, Accessory::Size::L}}, + {2055, {"Container 05"_s, Accessory::Size::L}}, - {2101, {"Plating 01"_s, AccessorySize::L}}, - {2102, {"Plating 02"_s, AccessorySize::L}}, - {2103, {"Plating 03"_s, AccessorySize::L}}, - {2104, {"Plating 04"_s, AccessorySize::L}}, - {2105, {"Plating 05"_s, AccessorySize::L}}, + {2101, {"Plating 01"_s, Accessory::Size::L}}, + {2102, {"Plating 02"_s, Accessory::Size::L}}, + {2103, {"Plating 03"_s, Accessory::Size::L}}, + {2104, {"Plating 04"_s, Accessory::Size::L}}, + {2105, {"Plating 05"_s, Accessory::Size::L}}, - {2151, {"Complex Base 01"_s, AccessorySize::L}}, - {2152, {"Complex Base 02"_s, AccessorySize::L}}, - {2153, {"Complex Base 03"_s, AccessorySize::L}}, - {2154, {"Complex Base 04"_s, AccessorySize::L}}, - {2155, {"Complex Base 05"_s, AccessorySize::L}}, - {2156, {"Complex Base 06"_s, AccessorySize::L}}, - {2157, {"Complex Base 07"_s, AccessorySize::L}}, - {2158, {"Complex Base 08"_s, AccessorySize::L}}, - {2159, {"Complex Base 09"_s, AccessorySize::L}}, - {2160, {"Complex Base 10"_s, AccessorySize::L}}, + {2151, {"Complex Base 01"_s, Accessory::Size::L}}, + {2152, {"Complex Base 02"_s, Accessory::Size::L}}, + {2153, {"Complex Base 03"_s, Accessory::Size::L}}, + {2154, {"Complex Base 04"_s, Accessory::Size::L}}, + {2155, {"Complex Base 05"_s, Accessory::Size::L}}, + {2156, {"Complex Base 06"_s, Accessory::Size::L}}, + {2157, {"Complex Base 07"_s, Accessory::Size::L}}, + {2158, {"Complex Base 08"_s, Accessory::Size::L}}, + {2159, {"Complex Base 09"_s, Accessory::Size::L}}, + {2160, {"Complex Base 10"_s, Accessory::Size::L}}, - {2201, {"Long Base 01"_s, AccessorySize::XL}}, - {2202, {"Long Base 02"_s, AccessorySize::XL}}, - {2203, {"Long Base 03"_s, AccessorySize::XL}}, - {2204, {"Long Base 04"_s, AccessorySize::XL}}, - {2205, {"Long Base 05"_s, AccessorySize::XL}}, + {2201, {"Long Base 01"_s, Accessory::Size::XL}}, + {2202, {"Long Base 02"_s, Accessory::Size::XL}}, + {2203, {"Long Base 03"_s, Accessory::Size::XL}}, + {2204, {"Long Base 04"_s, Accessory::Size::XL}}, + {2205, {"Long Base 05"_s, Accessory::Size::XL}}, - {2251, {"Straight Wing 01"_s, AccessorySize::XL}}, - {2252, {"Straight Wing 02"_s, AccessorySize::XL}}, - {2253, {"Straight Wing 03"_s, AccessorySize::XL}}, - {2254, {"Straight Wing 04"_s, AccessorySize::XL}}, - {2255, {"Straight Wing 05"_s, AccessorySize::XL}}, - {2256, {"Straight Wing 06"_s, AccessorySize::XL}}, - {2257, {"Straight Wing 07"_s, AccessorySize::XL}}, - {2258, {"Straight Wing 08"_s, AccessorySize::XL}}, - {2259, {"Straight Wing 09"_s, AccessorySize::XL}}, - {2260, {"Straight Wing 10"_s, AccessorySize::XL}}, + {2251, {"Straight Wing 01"_s, Accessory::Size::XL}}, + {2252, {"Straight Wing 02"_s, Accessory::Size::XL}}, + {2253, {"Straight Wing 03"_s, Accessory::Size::XL}}, + {2254, {"Straight Wing 04"_s, Accessory::Size::XL}}, + {2255, {"Straight Wing 05"_s, Accessory::Size::XL}}, + {2256, {"Straight Wing 06"_s, Accessory::Size::XL}}, + {2257, {"Straight Wing 07"_s, Accessory::Size::XL}}, + {2258, {"Straight Wing 08"_s, Accessory::Size::XL}}, + {2259, {"Straight Wing 09"_s, Accessory::Size::XL}}, + {2260, {"Straight Wing 10"_s, Accessory::Size::XL}}, - {2301, {"Triangular Wing 01"_s, AccessorySize::XL}}, - {2302, {"Triangular Wing 02"_s, AccessorySize::XL}}, - {2303, {"Triangular Wing 03"_s, AccessorySize::XL}}, - {2304, {"Triangular Wing 04"_s, AccessorySize::XL}}, - {2305, {"Triangular Wing 05"_s, AccessorySize::XL}}, - {2306, {"Triangular Wing 06"_s, AccessorySize::XL}}, - {2307, {"Triangular Wing 07"_s, AccessorySize::XL}}, - {2308, {"Triangular Wing 08"_s, AccessorySize::XL}}, - {2309, {"Triangular Wing 09"_s, AccessorySize::XL}}, - {2310, {"Triangular Wing 10"_s, AccessorySize::XL}}, - {2311, {"Triangular Wing 11"_s, AccessorySize::L}}, - {2312, {"Triangular Wing 12"_s, AccessorySize::L}}, - {2313, {"Triangular Wing 13"_s, AccessorySize::L}}, - {2314, {"Triangular Wing 14"_s, AccessorySize::L}}, - {2315, {"Triangular Wing 15"_s, AccessorySize::L}}, + {2301, {"Triangular Wing 01"_s, Accessory::Size::XL}}, + {2302, {"Triangular Wing 02"_s, Accessory::Size::XL}}, + {2303, {"Triangular Wing 03"_s, Accessory::Size::XL}}, + {2304, {"Triangular Wing 04"_s, Accessory::Size::XL}}, + {2305, {"Triangular Wing 05"_s, Accessory::Size::XL}}, + {2306, {"Triangular Wing 06"_s, Accessory::Size::XL}}, + {2307, {"Triangular Wing 07"_s, Accessory::Size::XL}}, + {2308, {"Triangular Wing 08"_s, Accessory::Size::XL}}, + {2309, {"Triangular Wing 09"_s, Accessory::Size::XL}}, + {2310, {"Triangular Wing 10"_s, Accessory::Size::XL}}, + {2311, {"Triangular Wing 11"_s, Accessory::Size::L}}, + {2312, {"Triangular Wing 12"_s, Accessory::Size::L}}, + {2313, {"Triangular Wing 13"_s, Accessory::Size::L}}, + {2314, {"Triangular Wing 14"_s, Accessory::Size::L}}, + {2315, {"Triangular Wing 15"_s, Accessory::Size::L}}, - {2351, {"Complex Wing 01"_s, AccessorySize::XL}}, - {2352, {"Complex Wing 02"_s, AccessorySize::XL}}, - {2353, {"Complex Wing 03"_s, AccessorySize::XL}}, - {2354, {"Complex Wing 04"_s, AccessorySize::XL}}, - {2355, {"Complex Wing 05"_s, AccessorySize::XL}}, - {2356, {"Complex Wing 06"_s, AccessorySize::L}}, - {2357, {"Complex Wing 07"_s, AccessorySize::L}}, - {2358, {"Complex Wing 08"_s, AccessorySize::L}}, - {2359, {"Complex Wing 09"_s, AccessorySize::L}}, - {2360, {"Complex Wing 10"_s, AccessorySize::L}}, + {2351, {"Complex Wing 01"_s, Accessory::Size::XL}}, + {2352, {"Complex Wing 02"_s, Accessory::Size::XL}}, + {2353, {"Complex Wing 03"_s, Accessory::Size::XL}}, + {2354, {"Complex Wing 04"_s, Accessory::Size::XL}}, + {2355, {"Complex Wing 05"_s, Accessory::Size::XL}}, + {2356, {"Complex Wing 06"_s, Accessory::Size::L}}, + {2357, {"Complex Wing 07"_s, Accessory::Size::L}}, + {2358, {"Complex Wing 08"_s, Accessory::Size::L}}, + {2359, {"Complex Wing 09"_s, Accessory::Size::L}}, + {2360, {"Complex Wing 10"_s, Accessory::Size::L}}, - {2401, {"Blade 01"_s, AccessorySize::XL}}, - {2402, {"Blade 02"_s, AccessorySize::XL}}, - {2403, {"Blade 03"_s, AccessorySize::XL}}, - {2404, {"Blade 04"_s, AccessorySize::XL}}, - {2405, {"Blade 05"_s, AccessorySize::XL}}, - {2406, {"Blade 06"_s, AccessorySize::XL}}, - {2407, {"Blade 07"_s, AccessorySize::XL}}, - {2408, {"Blade 08"_s, AccessorySize::XL}}, - {2409, {"Blade 09"_s, AccessorySize::XL}}, - {2410, {"Blade 10"_s, AccessorySize::XL}}, - {2411, {"Blade 11"_s, AccessorySize::XL}}, - {2412, {"Blade 12"_s, AccessorySize::XL}}, - {2413, {"Blade 13"_s, AccessorySize::XL}}, - {2414, {"Blade 14"_s, AccessorySize::XL}}, - {2415, {"Blade 15"_s, AccessorySize::XL}}, + {2401, {"Blade 01"_s, Accessory::Size::XL}}, + {2402, {"Blade 02"_s, Accessory::Size::XL}}, + {2403, {"Blade 03"_s, Accessory::Size::XL}}, + {2404, {"Blade 04"_s, Accessory::Size::XL}}, + {2405, {"Blade 05"_s, Accessory::Size::XL}}, + {2406, {"Blade 06"_s, Accessory::Size::XL}}, + {2407, {"Blade 07"_s, Accessory::Size::XL}}, + {2408, {"Blade 08"_s, Accessory::Size::XL}}, + {2409, {"Blade 09"_s, Accessory::Size::XL}}, + {2410, {"Blade 10"_s, Accessory::Size::XL}}, + {2411, {"Blade 11"_s, Accessory::Size::XL}}, + {2412, {"Blade 12"_s, Accessory::Size::XL}}, + {2413, {"Blade 13"_s, Accessory::Size::XL}}, + {2414, {"Blade 14"_s, Accessory::Size::XL}}, + {2415, {"Blade 15"_s, Accessory::Size::XL}}, - {2426, {"Curved Blade 01"_s, AccessorySize::XL}}, - {2427, {"Curved Blade 02"_s, AccessorySize::XL}}, - {2428, {"Curved Blade 03"_s, AccessorySize::XL}}, - {2429, {"Curved Blade 04"_s, AccessorySize::XL}}, - {2430, {"Curved Blade 05"_s, AccessorySize::XL}}, - {2431, {"Axe Head 01"_s, AccessorySize::XL}}, - {2432, {"Axe Head 02"_s, AccessorySize::XL}}, - {2433, {"Axe Head 03"_s, AccessorySize::XL}}, - {2434, {"Axe Head 04"_s, AccessorySize::XL}}, - {2435, {"Axe Head 05"_s, AccessorySize::XL}}, + {2426, {"Curved Blade 01"_s, Accessory::Size::XL}}, + {2427, {"Curved Blade 02"_s, Accessory::Size::XL}}, + {2428, {"Curved Blade 03"_s, Accessory::Size::XL}}, + {2429, {"Curved Blade 04"_s, Accessory::Size::XL}}, + {2430, {"Curved Blade 05"_s, Accessory::Size::XL}}, + {2431, {"Axe Head 01"_s, Accessory::Size::XL}}, + {2432, {"Axe Head 02"_s, Accessory::Size::XL}}, + {2433, {"Axe Head 03"_s, Accessory::Size::XL}}, + {2434, {"Axe Head 04"_s, Accessory::Size::XL}}, + {2435, {"Axe Head 05"_s, Accessory::Size::XL}}, - {2451, {"Horn 01"_s, AccessorySize::M}}, - {2452, {"Horn 02"_s, AccessorySize::M}}, - {2453, {"Horn 03"_s, AccessorySize::M}}, - {2454, {"Horn 04"_s, AccessorySize::M}}, - {2455, {"Horn 05"_s, AccessorySize::M}}, - {2456, {"Horn 06"_s, AccessorySize::M}}, - {2457, {"Horn 07"_s, AccessorySize::M}}, - {2458, {"Horn 08"_s, AccessorySize::M}}, - {2459, {"Horn 09"_s, AccessorySize::M}}, - {2460, {"Horn 10"_s, AccessorySize::M}}, - {2461, {"Horn 11"_s, AccessorySize::M}}, - {2462, {"Horn 12"_s, AccessorySize::M}}, - {2463, {"Horn 13"_s, AccessorySize::M}}, - {2464, {"Horn 14"_s, AccessorySize::M}}, - {2465, {"Horn 15"_s, AccessorySize::M}}, + {2451, {"Horn 01"_s, Accessory::Size::M}}, + {2452, {"Horn 02"_s, Accessory::Size::M}}, + {2453, {"Horn 03"_s, Accessory::Size::M}}, + {2454, {"Horn 04"_s, Accessory::Size::M}}, + {2455, {"Horn 05"_s, Accessory::Size::M}}, + {2456, {"Horn 06"_s, Accessory::Size::M}}, + {2457, {"Horn 07"_s, Accessory::Size::M}}, + {2458, {"Horn 08"_s, Accessory::Size::M}}, + {2459, {"Horn 09"_s, Accessory::Size::M}}, + {2460, {"Horn 10"_s, Accessory::Size::M}}, + {2461, {"Horn 11"_s, Accessory::Size::M}}, + {2462, {"Horn 12"_s, Accessory::Size::M}}, + {2463, {"Horn 13"_s, Accessory::Size::M}}, + {2464, {"Horn 14"_s, Accessory::Size::M}}, + {2465, {"Horn 15"_s, Accessory::Size::M}}, - {2471, {"Mask"_s, AccessorySize::M}}, - {2472, {"Droplet"_s, AccessorySize::M}}, - {2473, {"Thigh"_s, AccessorySize::M}}, - {2474, {"LegS"_s, AccessorySize::M}}, - {2475, {"LegTH"_s, AccessorySize::M}}, - {2476, {"Plume 01"_s, AccessorySize::M}}, - {2477, {"Plume 02"_s, AccessorySize::M}}, - {2478, {"Plume 03"_s, AccessorySize::M}}, - {2479, {"Plume 04"_s, AccessorySize::M}}, - {2480, {"Plume 05"_s, AccessorySize::M}}, + {2471, {"Mask"_s, Accessory::Size::M}}, + {2472, {"Droplet"_s, Accessory::Size::M}}, + {2473, {"Thigh"_s, Accessory::Size::M}}, + {2474, {"LegS"_s, Accessory::Size::M}}, + {2475, {"LegTH"_s, Accessory::Size::M}}, + {2476, {"Plume 01"_s, Accessory::Size::M}}, + {2477, {"Plume 02"_s, Accessory::Size::M}}, + {2478, {"Plume 03"_s, Accessory::Size::M}}, + {2479, {"Plume 04"_s, Accessory::Size::M}}, + {2480, {"Plume 05"_s, Accessory::Size::M}}, - {2491, {"Tail 01"_s, AccessorySize::XL}}, - {2492, {"Tail 02"_s, AccessorySize::XL}}, - {2493, {"Tail 03"_s, AccessorySize::XL}}, - {2494, {"Tail 04"_s, AccessorySize::XL}}, - {2495, {"Tail 05"_s, AccessorySize::XL}}, + {2491, {"Tail 01"_s, Accessory::Size::XL}}, + {2492, {"Tail 02"_s, Accessory::Size::XL}}, + {2493, {"Tail 03"_s, Accessory::Size::XL}}, + {2494, {"Tail 04"_s, Accessory::Size::XL}}, + {2495, {"Tail 05"_s, Accessory::Size::XL}}, - {2501, {"Finger 01"_s, AccessorySize::M}}, - {2502, {"Finger 02"_s, AccessorySize::M}}, - {2503, {"Finger 03"_s, AccessorySize::M}}, - {2504, {"Finger 04"_s, AccessorySize::M}}, - {2505, {"Finger 05"_s, AccessorySize::M}}, + {2501, {"Finger 01"_s, Accessory::Size::M}}, + {2502, {"Finger 02"_s, Accessory::Size::M}}, + {2503, {"Finger 03"_s, Accessory::Size::M}}, + {2504, {"Finger 04"_s, Accessory::Size::M}}, + {2505, {"Finger 05"_s, Accessory::Size::M}}, - {2510, {"Clamp 01"_s, AccessorySize::M}}, - {2511, {"Clamp 02"_s, AccessorySize::M}}, - {2512, {"Clamp 03"_s, AccessorySize::M}}, - {2513, {"Clamp 04"_s, AccessorySize::M}}, - {2514, {"Clamp 05"_s, AccessorySize::M}}, + {2510, {"Clamp 01"_s, Accessory::Size::M}}, + {2511, {"Clamp 02"_s, Accessory::Size::M}}, + {2512, {"Clamp 03"_s, Accessory::Size::M}}, + {2513, {"Clamp 04"_s, Accessory::Size::M}}, + {2514, {"Clamp 05"_s, Accessory::Size::M}}, - {2521, {"Fabric 01"_s, AccessorySize::XL}}, - {2522, {"Fabric 02"_s, AccessorySize::XL}}, - {2523, {"Fabric 03"_s, AccessorySize::XL}}, - {2524, {"Fabric 04"_s, AccessorySize::XL}}, - {2525, {"Fabric 05"_s, AccessorySize::XL}}, + {2521, {"Fabric 01"_s, Accessory::Size::XL}}, + {2522, {"Fabric 02"_s, Accessory::Size::XL}}, + {2523, {"Fabric 03"_s, Accessory::Size::XL}}, + {2524, {"Fabric 04"_s, Accessory::Size::XL}}, + {2525, {"Fabric 05"_s, Accessory::Size::XL}}, - {2551, {"Energy Barrel 01"_s, AccessorySize::XL}}, - {2552, {"Energy Barrel 02"_s, AccessorySize::XL}}, - {2553, {"Energy Barrel 03"_s, AccessorySize::XL}}, - {2554, {"Energy Barrel 04"_s, AccessorySize::XL}}, - {2555, {"Energy Barrel 05"_s, AccessorySize::XL}}, + {2551, {"Energy Barrel 01"_s, Accessory::Size::XL}}, + {2552, {"Energy Barrel 02"_s, Accessory::Size::XL}}, + {2553, {"Energy Barrel 03"_s, Accessory::Size::XL}}, + {2554, {"Energy Barrel 04"_s, Accessory::Size::XL}}, + {2555, {"Energy Barrel 05"_s, Accessory::Size::XL}}, - {2601, {"L Bullet Barrel 01"_s, AccessorySize::XL}}, - {2602, {"L Bullet Barrel 02"_s, AccessorySize::XL}}, - {2603, {"L Bullet Barrel 03"_s, AccessorySize::XL}}, - {2604, {"L Bullet Barrel 04"_s, AccessorySize::XL}}, - {2605, {"L Bullet Barrel 05"_s, AccessorySize::XL}}, - {2606, {"S Bullet Barrel 01"_s, AccessorySize::XL}}, - {2607, {"S Bullet Barrel 02"_s, AccessorySize::XL}}, - {2608, {"S Bullet Barrel 03"_s, AccessorySize::XL}}, - {2609, {"S Bullet Barrel 04"_s, AccessorySize::XL}}, - {2610, {"S Bullet Barrel 05"_s, AccessorySize::XL}}, - {2611, {"B Bullet Barrel 01"_s, AccessorySize::XL}}, - {2612, {"B Bullet Barrel 02"_s, AccessorySize::XL}}, - {2613, {"B Bullet Barrel 03"_s, AccessorySize::XL}}, - {2614, {"B Bullet Barrel 04"_s, AccessorySize::XL}}, - {2615, {"B Bullet Barrel 05"_s, AccessorySize::XL}}, - {2616, {"B Bullet Barrel 06"_s, AccessorySize::XL}}, - {2617, {"B Bullet Barrel 07"_s, AccessorySize::XL}}, - {2618, {"B Bullet Barrel 08"_s, AccessorySize::XL}}, - {2619, {"B Bullet Barrel 09"_s, AccessorySize::XL}}, - {2620, {"B Bullet Barrel 10"_s, AccessorySize::XL}}, + {2601, {"L Bullet Barrel 01"_s, Accessory::Size::XL}}, + {2602, {"L Bullet Barrel 02"_s, Accessory::Size::XL}}, + {2603, {"L Bullet Barrel 03"_s, Accessory::Size::XL}}, + {2604, {"L Bullet Barrel 04"_s, Accessory::Size::XL}}, + {2605, {"L Bullet Barrel 05"_s, Accessory::Size::XL}}, + {2606, {"S Bullet Barrel 01"_s, Accessory::Size::XL}}, + {2607, {"S Bullet Barrel 02"_s, Accessory::Size::XL}}, + {2608, {"S Bullet Barrel 03"_s, Accessory::Size::XL}}, + {2609, {"S Bullet Barrel 04"_s, Accessory::Size::XL}}, + {2610, {"S Bullet Barrel 05"_s, Accessory::Size::XL}}, + {2611, {"B Bullet Barrel 01"_s, Accessory::Size::XL}}, + {2612, {"B Bullet Barrel 02"_s, Accessory::Size::XL}}, + {2613, {"B Bullet Barrel 03"_s, Accessory::Size::XL}}, + {2614, {"B Bullet Barrel 04"_s, Accessory::Size::XL}}, + {2615, {"B Bullet Barrel 05"_s, Accessory::Size::XL}}, + {2616, {"B Bullet Barrel 06"_s, Accessory::Size::XL}}, + {2617, {"B Bullet Barrel 07"_s, Accessory::Size::XL}}, + {2618, {"B Bullet Barrel 08"_s, Accessory::Size::XL}}, + {2619, {"B Bullet Barrel 09"_s, Accessory::Size::XL}}, + {2620, {"B Bullet Barrel 10"_s, Accessory::Size::XL}}, - {2651, {"Cylinder Scope 01"_s, AccessorySize::M}}, - {2652, {"Cylinder Scope 02"_s, AccessorySize::M}}, - {2653, {"Cylinder Scope 03"_s, AccessorySize::M}}, - {2654, {"Cylinder Scope 04"_s, AccessorySize::M}}, - {2655, {"Cylinder Scope 05"_s, AccessorySize::M}}, - {2656, {"Elec Scope 01"_s, AccessorySize::M}}, - {2657, {"Elec Scope 02"_s, AccessorySize::M}}, - {2658, {"Elec Scope 03"_s, AccessorySize::M}}, - {2659, {"Elec Scope 04"_s, AccessorySize::M}}, - {2660, {"Elec Scope 05"_s, AccessorySize::M}}, - {2661, {"Mark Scope 01"_s, AccessorySize::S}}, - {2662, {"Mark Scope 02"_s, AccessorySize::S}}, - {2663, {"Mark Scope 03"_s, AccessorySize::S}}, - {2664, {"Mark Scope 04"_s, AccessorySize::S}}, - {2665, {"Mark Scope 05"_s, AccessorySize::S}}, + {2651, {"Cylinder Scope 01"_s, Accessory::Size::M}}, + {2652, {"Cylinder Scope 02"_s, Accessory::Size::M}}, + {2653, {"Cylinder Scope 03"_s, Accessory::Size::M}}, + {2654, {"Cylinder Scope 04"_s, Accessory::Size::M}}, + {2655, {"Cylinder Scope 05"_s, Accessory::Size::M}}, + {2656, {"Elec Scope 01"_s, Accessory::Size::M}}, + {2657, {"Elec Scope 02"_s, Accessory::Size::M}}, + {2658, {"Elec Scope 03"_s, Accessory::Size::M}}, + {2659, {"Elec Scope 04"_s, Accessory::Size::M}}, + {2660, {"Elec Scope 05"_s, Accessory::Size::M}}, + {2661, {"Mark Scope 01"_s, Accessory::Size::S}}, + {2662, {"Mark Scope 02"_s, Accessory::Size::S}}, + {2663, {"Mark Scope 03"_s, Accessory::Size::S}}, + {2664, {"Mark Scope 04"_s, Accessory::Size::S}}, + {2665, {"Mark Scope 05"_s, Accessory::Size::S}}, - {2701, {"S Single Weaponry"_s, AccessorySize::M}}, - {2702, {"S Packed Weaponry 01"_s, AccessorySize::M}}, - {2703, {"S Packed Weaponry 02"_s, AccessorySize::M}}, - {2704, {"S Packed Weaponry 03"_s, AccessorySize::M}}, - {2705, {"S Packed Weaponry 04"_s, AccessorySize::M}}, - {2706, {"L Single Weaponry"_s, AccessorySize::XL}}, - {2707, {"L Packed Weaponry 01"_s, AccessorySize::XL}}, - {2708, {"L Packed Weaponry 02"_s, AccessorySize::XL}}, - {2709, {"L Packed Weaponry 03"_s, AccessorySize::XL}}, - {2710, {"L Packed Weaponry 04"_s, AccessorySize::XL}}, - {2711, {"Atk Single Weaponry"_s, AccessorySize::XL}}, - {2712, {"Atk Packed Weaponry 01"_s, AccessorySize::XL}}, - {2713, {"Atk Packed Weaponry 02"_s, AccessorySize::XL}}, - {2714, {"Atk Packed Weaponry 03"_s, AccessorySize::XL}}, - {2715, {"Atk Packed Weaponry 04"_s, AccessorySize::XL}}, + {2701, {"S Single Weaponry"_s, Accessory::Size::M}}, + {2702, {"S Packed Weaponry 01"_s, Accessory::Size::M}}, + {2703, {"S Packed Weaponry 02"_s, Accessory::Size::M}}, + {2704, {"S Packed Weaponry 03"_s, Accessory::Size::M}}, + {2705, {"S Packed Weaponry 04"_s, Accessory::Size::M}}, + {2706, {"L Single Weaponry"_s, Accessory::Size::XL}}, + {2707, {"L Packed Weaponry 01"_s, Accessory::Size::XL}}, + {2708, {"L Packed Weaponry 02"_s, Accessory::Size::XL}}, + {2709, {"L Packed Weaponry 03"_s, Accessory::Size::XL}}, + {2710, {"L Packed Weaponry 04"_s, Accessory::Size::XL}}, + {2711, {"Atk Single Weaponry"_s, Accessory::Size::XL}}, + {2712, {"Atk Packed Weaponry 01"_s, Accessory::Size::XL}}, + {2713, {"Atk Packed Weaponry 02"_s, Accessory::Size::XL}}, + {2714, {"Atk Packed Weaponry 03"_s, Accessory::Size::XL}}, + {2715, {"Atk Packed Weaponry 04"_s, Accessory::Size::XL}}, - {2751, {"Vent 01"_s, AccessorySize::M}}, - {2752, {"Vent 02"_s, AccessorySize::M}}, - {2753, {"Vent 03"_s, AccessorySize::M}}, - {2754, {"Vent 04"_s, AccessorySize::M}}, - {2755, {"Vent 05"_s, AccessorySize::M}}, - {2756, {"Vent 06"_s, AccessorySize::M}}, - {2757, {"Vent 07"_s, AccessorySize::M}}, - {2758, {"Vent 08"_s, AccessorySize::M}}, - {2759, {"Vent 09"_s, AccessorySize::M}}, - {2760, {"Vent 10"_s, AccessorySize::M}}, + {2751, {"Vent 01"_s, Accessory::Size::M}}, + {2752, {"Vent 02"_s, Accessory::Size::M}}, + {2753, {"Vent 03"_s, Accessory::Size::M}}, + {2754, {"Vent 04"_s, Accessory::Size::M}}, + {2755, {"Vent 05"_s, Accessory::Size::M}}, + {2756, {"Vent 06"_s, Accessory::Size::M}}, + {2757, {"Vent 07"_s, Accessory::Size::M}}, + {2758, {"Vent 08"_s, Accessory::Size::M}}, + {2759, {"Vent 09"_s, Accessory::Size::M}}, + {2760, {"Vent 10"_s, Accessory::Size::M}}, - {2901, {"Complex Construct 01"_s, AccessorySize::L}}, - {2902, {"Complex Construct 02"_s, AccessorySize::L}}, - {2903, {"Complex Construct 03"_s, AccessorySize::L}}, - {2904, {"Complex Construct 04"_s, AccessorySize::L}}, - {2905, {"Complex Construct 05"_s, AccessorySize::L}}, + {2901, {"Complex Construct 01"_s, Accessory::Size::L}}, + {2902, {"Complex Construct 02"_s, Accessory::Size::L}}, + {2903, {"Complex Construct 03"_s, Accessory::Size::L}}, + {2904, {"Complex Construct 04"_s, Accessory::Size::L}}, + {2905, {"Complex Construct 05"_s, Accessory::Size::L}}, - {2950, {"Q Mask 01"_s, AccessorySize::M}}, - {2951, {"Q Mask 02"_s, AccessorySize::M}}, - {2952, {"Q Mask 03"_s, AccessorySize::M}}, - {2953, {"Q Mask 04"_s, AccessorySize::M}}, - {2954, {"Q Mask 05"_s, AccessorySize::M}}, + {2950, {"Q Mask 01"_s, Accessory::Size::M}}, + {2951, {"Q Mask 02"_s, Accessory::Size::M}}, + {2952, {"Q Mask 03"_s, Accessory::Size::M}}, + {2953, {"Q Mask 04"_s, Accessory::Size::M}}, + {2954, {"Q Mask 05"_s, Accessory::Size::M}}, // endregion // region Connectors - {3001, {"Circular Vent 01"_s, AccessorySize::M}}, - {3002, {"Circular Vent 02"_s, AccessorySize::M}}, - {3003, {"Circular Vent 03"_s, AccessorySize::M}}, - {3004, {"Circular Vent 04"_s, AccessorySize::M}}, - {3005, {"Circular Vent 05"_s, AccessorySize::M}}, - {3006, {"Circular Vent 06"_s, AccessorySize::M}}, - {3007, {"Circular Vent 07"_s, AccessorySize::M}}, - {3008, {"Circular Vent 08"_s, AccessorySize::M}}, - {3009, {"Circular Vent 09"_s, AccessorySize::M}}, - {3010, {"Circular Vent 10"_s, AccessorySize::M}}, - {3011, {"Circular Vent 11"_s, AccessorySize::M}}, - {3012, {"Circular Vent 12"_s, AccessorySize::M}}, - {3013, {"Circular Vent 13"_s, AccessorySize::M}}, - {3014, {"Circular Vent 14"_s, AccessorySize::M}}, - {3015, {"Circular Vent 15"_s, AccessorySize::M}}, + {3001, {"Circular Vent 01"_s, Accessory::Size::M}}, + {3002, {"Circular Vent 02"_s, Accessory::Size::M}}, + {3003, {"Circular Vent 03"_s, Accessory::Size::M}}, + {3004, {"Circular Vent 04"_s, Accessory::Size::M}}, + {3005, {"Circular Vent 05"_s, Accessory::Size::M}}, + {3006, {"Circular Vent 06"_s, Accessory::Size::M}}, + {3007, {"Circular Vent 07"_s, Accessory::Size::M}}, + {3008, {"Circular Vent 08"_s, Accessory::Size::M}}, + {3009, {"Circular Vent 09"_s, Accessory::Size::M}}, + {3010, {"Circular Vent 10"_s, Accessory::Size::M}}, + {3011, {"Circular Vent 11"_s, Accessory::Size::M}}, + {3012, {"Circular Vent 12"_s, Accessory::Size::M}}, + {3013, {"Circular Vent 13"_s, Accessory::Size::M}}, + {3014, {"Circular Vent 14"_s, Accessory::Size::M}}, + {3015, {"Circular Vent 15"_s, Accessory::Size::M}}, - {3051, {"Reactor 01"_s, AccessorySize::L}}, - {3052, {"Reactor 02"_s, AccessorySize::L}}, - {3053, {"Reactor 03"_s, AccessorySize::L}}, - {3054, {"Reactor 04"_s, AccessorySize::L}}, - {3055, {"Reactor 05"_s, AccessorySize::L}}, + {3051, {"Reactor 01"_s, Accessory::Size::L}}, + {3052, {"Reactor 02"_s, Accessory::Size::L}}, + {3053, {"Reactor 03"_s, Accessory::Size::L}}, + {3054, {"Reactor 04"_s, Accessory::Size::L}}, + {3055, {"Reactor 05"_s, Accessory::Size::L}}, - {3101, {"Connecting Tube 01"_s, AccessorySize::XL}}, - {3102, {"Connecting Tube 02"_s, AccessorySize::XL}}, - {3103, {"Connecting Tube 03"_s, AccessorySize::XL}}, - {3104, {"Connecting Tube 04"_s, AccessorySize::XL}}, - {3105, {"Connecting Tube 05"_s, AccessorySize::XL}}, + {3101, {"Connecting Tube 01"_s, Accessory::Size::XL}}, + {3102, {"Connecting Tube 02"_s, Accessory::Size::XL}}, + {3103, {"Connecting Tube 03"_s, Accessory::Size::XL}}, + {3104, {"Connecting Tube 04"_s, Accessory::Size::XL}}, + {3105, {"Connecting Tube 05"_s, Accessory::Size::XL}}, - {3151, {"Latch 01"_s, AccessorySize::M}}, - {3152, {"Latch 02"_s, AccessorySize::M}}, - {3153, {"Latch 03"_s, AccessorySize::M}}, - {3154, {"Latch 04"_s, AccessorySize::M}}, - {3155, {"Latch 05"_s, AccessorySize::M}}, - {3156, {"Latch 06"_s, AccessorySize::M}}, - {3157, {"Latch 07"_s, AccessorySize::M}}, - {3158, {"Latch 08"_s, AccessorySize::M}}, - {3159, {"Latch 09"_s, AccessorySize::M}}, - {3160, {"Latch 10"_s, AccessorySize::M}}, - {3161, {"Latch 11"_s, AccessorySize::M}}, - {3162, {"Latch 12"_s, AccessorySize::M}}, - {3163, {"Latch 13"_s, AccessorySize::M}}, - {3164, {"Latch 14"_s, AccessorySize::M}}, - {3165, {"Latch 15"_s, AccessorySize::M}}, + {3151, {"Latch 01"_s, Accessory::Size::M}}, + {3152, {"Latch 02"_s, Accessory::Size::M}}, + {3153, {"Latch 03"_s, Accessory::Size::M}}, + {3154, {"Latch 04"_s, Accessory::Size::M}}, + {3155, {"Latch 05"_s, Accessory::Size::M}}, + {3156, {"Latch 06"_s, Accessory::Size::M}}, + {3157, {"Latch 07"_s, Accessory::Size::M}}, + {3158, {"Latch 08"_s, Accessory::Size::M}}, + {3159, {"Latch 09"_s, Accessory::Size::M}}, + {3160, {"Latch 10"_s, Accessory::Size::M}}, + {3161, {"Latch 11"_s, Accessory::Size::M}}, + {3162, {"Latch 12"_s, Accessory::Size::M}}, + {3163, {"Latch 13"_s, Accessory::Size::M}}, + {3164, {"Latch 14"_s, Accessory::Size::M}}, + {3165, {"Latch 15"_s, Accessory::Size::M}}, - {3201, {"Short Connector 01"_s, AccessorySize::M}}, - {3202, {"Short Connector 02"_s, AccessorySize::M}}, - {3203, {"Short Connector 03"_s, AccessorySize::M}}, - {3204, {"Short Connector 04"_s, AccessorySize::M}}, - {3205, {"Short Connector 05"_s, AccessorySize::M}}, - {3206, {"Antenna 01"_s, AccessorySize::S}}, - {3207, {"Antenna 02"_s, AccessorySize::S}}, - {3208, {"Antenna 03"_s, AccessorySize::S}}, - {3209, {"Antenna 04"_s, AccessorySize::S}}, - {3210, {"Antenna 05"_s, AccessorySize::S}}, + {3201, {"Short Connector 01"_s, Accessory::Size::M}}, + {3202, {"Short Connector 02"_s, Accessory::Size::M}}, + {3203, {"Short Connector 03"_s, Accessory::Size::M}}, + {3204, {"Short Connector 04"_s, Accessory::Size::M}}, + {3205, {"Short Connector 05"_s, Accessory::Size::M}}, + {3206, {"Antenna 01"_s, Accessory::Size::S}}, + {3207, {"Antenna 02"_s, Accessory::Size::S}}, + {3208, {"Antenna 03"_s, Accessory::Size::S}}, + {3209, {"Antenna 04"_s, Accessory::Size::S}}, + {3210, {"Antenna 05"_s, Accessory::Size::S}}, - {3226, {"Long Connector 01"_s, AccessorySize::XL}}, - {3227, {"Long Connector 02"_s, AccessorySize::XL}}, - {3228, {"Long Connector 03"_s, AccessorySize::XL}}, - {3229, {"Long Connector 04"_s, AccessorySize::XL}}, - {3230, {"Long Connector 05"_s, AccessorySize::XL}}, - {3231, {"Long Connector 06"_s, AccessorySize::XL}}, - {3232, {"Long Connector 07"_s, AccessorySize::XL}}, - {3233, {"Long Connector 08"_s, AccessorySize::XL}}, - {3234, {"Long Connector 09"_s, AccessorySize::XL}}, - {3235, {"Long Connector 10"_s, AccessorySize::XL}}, + {3226, {"Long Connector 01"_s, Accessory::Size::XL}}, + {3227, {"Long Connector 02"_s, Accessory::Size::XL}}, + {3228, {"Long Connector 03"_s, Accessory::Size::XL}}, + {3229, {"Long Connector 04"_s, Accessory::Size::XL}}, + {3230, {"Long Connector 05"_s, Accessory::Size::XL}}, + {3231, {"Long Connector 06"_s, Accessory::Size::XL}}, + {3232, {"Long Connector 07"_s, Accessory::Size::XL}}, + {3233, {"Long Connector 08"_s, Accessory::Size::XL}}, + {3234, {"Long Connector 09"_s, Accessory::Size::XL}}, + {3235, {"Long Connector 10"_s, Accessory::Size::XL}}, - {3251, {"Complex Connector 01"_s, AccessorySize::XL}}, - {3252, {"Complex Connector 02"_s, AccessorySize::XL}}, - {3253, {"Complex Connector 03"_s, AccessorySize::XL}}, - {3254, {"Complex Connector 04"_s, AccessorySize::XL}}, - {3255, {"Complex Connector 05"_s, AccessorySize::XL}}, + {3251, {"Complex Connector 01"_s, Accessory::Size::XL}}, + {3252, {"Complex Connector 02"_s, Accessory::Size::XL}}, + {3253, {"Complex Connector 03"_s, Accessory::Size::XL}}, + {3254, {"Complex Connector 04"_s, Accessory::Size::XL}}, + {3255, {"Complex Connector 05"_s, Accessory::Size::XL}}, - {3301, {"Tube Line 01"_s, AccessorySize::L}}, - {3302, {"Tube Line 02"_s, AccessorySize::L}}, - {3303, {"Tube Line 03"_s, AccessorySize::L}}, - {3304, {"Tube Line 04"_s, AccessorySize::XL}}, - {3305, {"Tube Line 05"_s, AccessorySize::XL}}, - {3306, {"Tube Line 06"_s, AccessorySize::M}}, - {3307, {"Tube Line 07"_s, AccessorySize::M}}, - {3308, {"Tube Line 08"_s, AccessorySize::M}}, - {3309, {"Tube Line 09"_s, AccessorySize::L}}, - {3310, {"Tube Line 10"_s, AccessorySize::L}}, + {3301, {"Tube Line 01"_s, Accessory::Size::L}}, + {3302, {"Tube Line 02"_s, Accessory::Size::L}}, + {3303, {"Tube Line 03"_s, Accessory::Size::L}}, + {3304, {"Tube Line 04"_s, Accessory::Size::XL}}, + {3305, {"Tube Line 05"_s, Accessory::Size::XL}}, + {3306, {"Tube Line 06"_s, Accessory::Size::M}}, + {3307, {"Tube Line 07"_s, Accessory::Size::M}}, + {3308, {"Tube Line 08"_s, Accessory::Size::M}}, + {3309, {"Tube Line 09"_s, Accessory::Size::L}}, + {3310, {"Tube Line 10"_s, Accessory::Size::L}}, - {3351, {"Radar Plate 01"_s, AccessorySize::M}}, - {3352, {"Radar Plate 02"_s, AccessorySize::M}}, - {3353, {"Radar Plate 03"_s, AccessorySize::M}}, - {3354, {"Radar Plate 04"_s, AccessorySize::M}}, - {3355, {"Radar Plate 05"_s, AccessorySize::M}}, - {3356, {"Radar Pod 01"_s, AccessorySize::M}}, - {3357, {"Radar Pod 02"_s, AccessorySize::M}}, - {3358, {"Radar Pod 03"_s, AccessorySize::M}}, - {3359, {"Radar Pod 04"_s, AccessorySize::M}}, - {3360, {"Radar Pod 05"_s, AccessorySize::M}}, + {3351, {"Radar Plate 01"_s, Accessory::Size::M}}, + {3352, {"Radar Plate 02"_s, Accessory::Size::M}}, + {3353, {"Radar Plate 03"_s, Accessory::Size::M}}, + {3354, {"Radar Plate 04"_s, Accessory::Size::M}}, + {3355, {"Radar Plate 05"_s, Accessory::Size::M}}, + {3356, {"Radar Pod 01"_s, Accessory::Size::M}}, + {3357, {"Radar Pod 02"_s, Accessory::Size::M}}, + {3358, {"Radar Pod 03"_s, Accessory::Size::M}}, + {3359, {"Radar Pod 04"_s, Accessory::Size::M}}, + {3360, {"Radar Pod 05"_s, Accessory::Size::M}}, - {3401, {"Tri Pod 01"_s, AccessorySize::M}}, - {3402, {"Tri Pod 02"_s, AccessorySize::M}}, - {3403, {"Tri Pod 03"_s, AccessorySize::M}}, - {3404, {"Tri Pod 04"_s, AccessorySize::M}}, - {3405, {"Tri Pod 05"_s, AccessorySize::M}}, - {3406, {"Signal Pod 01"_s, AccessorySize::M}}, - {3407, {"Signal Pod 02"_s, AccessorySize::M}}, - {3408, {"Signal Pod 03"_s, AccessorySize::M}}, - {3409, {"Signal Pod 04"_s, AccessorySize::M}}, - {3410, {"Signal Pod 05"_s, AccessorySize::M}}, + {3401, {"Tri Pod 01"_s, Accessory::Size::M}}, + {3402, {"Tri Pod 02"_s, Accessory::Size::M}}, + {3403, {"Tri Pod 03"_s, Accessory::Size::M}}, + {3404, {"Tri Pod 04"_s, Accessory::Size::M}}, + {3405, {"Tri Pod 05"_s, Accessory::Size::M}}, + {3406, {"Signal Pod 01"_s, Accessory::Size::M}}, + {3407, {"Signal Pod 02"_s, Accessory::Size::M}}, + {3408, {"Signal Pod 03"_s, Accessory::Size::M}}, + {3409, {"Signal Pod 04"_s, Accessory::Size::M}}, + {3410, {"Signal Pod 05"_s, Accessory::Size::M}}, // endregion }; + +}} diff --git a/src/Maps/ArmourSets.h b/src/Maps/ArmourSets.h index a59fe8b..6aeb01b 100644 --- a/src/Maps/ArmourSets.h +++ b/src/Maps/ArmourSets.h @@ -25,6 +25,8 @@ using namespace Corrade; using namespace Containers::Literals; +namespace mbst { namespace GameData { + struct ArmourSet { Containers::StringView name; bool neck_compatible; @@ -55,3 +57,5 @@ static const std::map armour_sets { {26, {"Axial Core S-Type"_s, false}}, {27, {"Axial Core X-Type"_s, false}}, }; + +}} diff --git a/src/Maps/LastMissionId.h b/src/Maps/LastMissionId.h index 4d8a4f0..f535ca1 100644 --- a/src/Maps/LastMissionId.h +++ b/src/Maps/LastMissionId.h @@ -23,36 +23,40 @@ using namespace Corrade; using namespace Containers::Literals; +namespace mbst { namespace GameData { + static const std::map mission_id_map {{ // Story missions - {0x0064, "Mission 1 - Training"_s}, - {0x0065, "Mission 2 - Patrol Operation"_s}, - {0x0066, "Mission 3 - Fusion Cells in the Snow"_s}, - {0x0067, "Mission 4 - Earning Changes"_s}, - {0x0068, "Mission 5 - Unexpected Coordination"_s}, - {0x0069, "Mission 6 - Empowering Void"_s}, - {0x006A, "Mission 7 - Logisitics Obstacles"_s}, - {0x006B, "Mission 8 - Wrath of the Wastelands"_s}, - {0x006C, "Mission 9 - Suspicious Originator"_s}, - {0x006D, "Mission 10 - Researchers Data Recovery"_s}, - {0x006E, "Mission 11 - Tempestuous Sector"_s}, - {0x006F, "Mission 12 - Clashes of Metal"_s}, - {0x0070, "Mission 13 - The Sandstorm Glutton"_s}, - {0x0071, "Mission 14 - An Icy Investigation"_s}, - {0x0072, "Mission 15 - Outposts Line of Defense"_s}, - {0x0073, "Mission 16 - Hidden in the Pass"_s}, - {0x0074, "Mission 17 - Homebase Security"_s}, + {100, "Mission 1 - Training"_s}, + {101, "Mission 2 - Patrol Operation"_s}, + {102, "Mission 3 - Fusion Cells in the Snow"_s}, + {103, "Mission 4 - Earning Changes"_s}, + {104, "Mission 5 - Unexpected Coordination"_s}, + {105, "Mission 6 - Empowering Void"_s}, + {106, "Mission 7 - Logisitics Obstacles"_s}, + {107, "Mission 8 - Wrath of the Wastelands"_s}, + {108, "Mission 9 - Suspicious Originator"_s}, + {109, "Mission 10 - Researchers Data Recovery"_s}, + {110, "Mission 11 - Tempestuous Sector"_s}, + {111, "Mission 12 - Clashes of Metal"_s}, + {112, "Mission 13 - The Sandstorm Glutton"_s}, + {113, "Mission 14 - An Icy Investigation"_s}, + {114, "Mission 15 - Outposts Line of Defense"_s}, + {115, "Mission 16 - Hidden in the Pass"_s}, + {116, "Mission 17 - Homebase Security"_s}, // Hunting grounds - {0x00C8, "Hunt 1 - Desert Pathway Safety"_s}, - {0x00C9, "Hunt 2 - Snowfield Custodian"_s}, - {0x00CA, "Hunt 3 - Abandoned Valley Raid"_s}, - {0x00CB, "Hunt 4 - Depths of the Machineries"_s}, - {0x00CC, "Hunt 5 - Crater Crashers"_s}, - {0x00CD, "Hunt 6 - Prototype Performance Tests"_s}, + {200, "Hunt 1 - Desert Pathway Safety"_s}, + {201, "Hunt 2 - Snowfield Custodian"_s}, + {202, "Hunt 3 - Abandoned Valley Raid"_s}, + {203, "Hunt 4 - Depths of the Machineries"_s}, + {204, "Hunt 5 - Crater Crashers"_s}, + {205, "Hunt 6 - Prototype Performance Tests"_s}, // Challenges - {0x012C, "Challenge 1 - Redline Battlefront"_s}, - {0x0140, "Challenge 2 - Void Convergence"_s}, - {0x0190, "Challenge 3 - Gates of Ascension"_s} + {300, "Challenge 1 - Redline Battlefront"_s}, + {320, "Challenge 2 - Void Convergence"_s}, + {400, "Challenge 3 - Gates of Ascension"_s} }}; + +}} diff --git a/src/Maps/StoryProgress.h b/src/Maps/StoryProgress.h index 61d857e..e5f4938 100644 --- a/src/Maps/StoryProgress.h +++ b/src/Maps/StoryProgress.h @@ -22,6 +22,8 @@ using namespace Corrade; using namespace Containers::Literals; +namespace mbst { namespace GameData { + struct StoryProgressPoint { std::int32_t id{}; Containers::StringView chapter = nullptr; @@ -109,3 +111,5 @@ static const Corrade::Containers::Array story_progress {0x070A, "Chapter 3"_s, "Got hunt 6 briefing"_s, "After mission 17"_s}, } }; + +}} diff --git a/src/Maps/StyleNames.h b/src/Maps/StyleNames.h index b54a7ef..e977b3b 100644 --- a/src/Maps/StyleNames.h +++ b/src/Maps/StyleNames.h @@ -25,6 +25,8 @@ using namespace Corrade; using namespace Containers::Literals; +namespace mbst { namespace GameData { + extern const std::map style_names #ifdef STYLENAMES_DEFINITION { @@ -193,3 +195,5 @@ extern const std::map style_names } #endif ; + +}} diff --git a/src/Maps/WeaponParts.h b/src/Maps/WeaponParts.h index 878fa96..f8f49ae 100644 --- a/src/Maps/WeaponParts.h +++ b/src/Maps/WeaponParts.h @@ -25,6 +25,8 @@ using namespace Corrade; using namespace Containers::Literals; +namespace mbst { namespace GameData { + // region Melee static const std::map melee_grips { {0, "Combat Grip (1H)"_s}, @@ -430,3 +432,5 @@ static const std::map elauncher_pods { {399, "P Base EPod (Photon)"_s}, }; // endregion + +}} diff --git a/src/Mass/Accessory.h b/src/Mass/Accessory.h index c82b24b..c72600a 100644 --- a/src/Mass/Accessory.h +++ b/src/Mass/Accessory.h @@ -24,6 +24,8 @@ using namespace Corrade; using namespace Magnum; +namespace mbst { namespace GameObjects { + struct Accessory { std::int32_t attachIndex = -1; std::int32_t id = -1; @@ -34,3 +36,5 @@ struct Accessory { Vector3 relativeRotationOffset{0.0f}; Vector3 localScale{1.0f}; }; + +}} diff --git a/src/Mass/ArmourPart.h b/src/Mass/ArmourPart.h index 300948e..e4314a4 100644 --- a/src/Mass/ArmourPart.h +++ b/src/Mass/ArmourPart.h @@ -24,16 +24,19 @@ using namespace Corrade; -enum class ArmourSlot { - #define c(enumerator, enumstr, name) enumerator, - #include "../Maps/ArmourSlots.hpp" - #undef c -}; +namespace mbst { namespace GameObjects { struct ArmourPart { - ArmourSlot slot = ArmourSlot::Face; + enum class Slot { + #define c(enumerator, enumstr, name) enumerator, + #include "../Maps/ArmourSlots.hpp" + #undef c + }; + Slot slot = Slot::Face; std::int32_t id = 0; Containers::StaticArray<4, std::int32_t> styles{ValueInit}; Containers::Array decals; Containers::Array accessories; }; + +}} diff --git a/src/Mass/BulletLauncherAttachment.h b/src/Mass/BulletLauncherAttachment.h index 5be79e0..b111064 100644 --- a/src/Mass/BulletLauncherAttachment.h +++ b/src/Mass/BulletLauncherAttachment.h @@ -24,23 +24,26 @@ using namespace Corrade; using namespace Magnum; +namespace mbst { namespace GameObjects { + enum class BulletLauncherAttachmentStyle { #define c(enumerator, enumstr) enumerator, #include "../Maps/BulletLauncherAttachmentStyles.hpp" #undef c }; -enum class BulletLauncherSocket { - #define c(enumerator, enumstr, name) enumerator, - #include "../Maps/BulletLauncherSockets.hpp" - #undef c -}; - struct BulletLauncherAttachment { - BulletLauncherSocket socket = BulletLauncherSocket::Auto; + enum class Socket { + #define c(enumerator, enumstr, name) enumerator, + #include "../Maps/BulletLauncherSockets.hpp" + #undef c + }; + Socket socket = Socket::Auto; Vector3 relativeLocation; Vector3 offsetLocation; Vector3 relativeRotation; Vector3 offsetRotation; Vector3 relativeScale; }; + +}} diff --git a/src/Mass/CustomStyle.h b/src/Mass/CustomStyle.h index 73d7cb3..bfdcdd4 100644 --- a/src/Mass/CustomStyle.h +++ b/src/Mass/CustomStyle.h @@ -25,6 +25,8 @@ using namespace Corrade; using namespace Magnum; +namespace mbst { namespace GameObjects { + struct CustomStyle { Containers::String name; Color4 colour{0.0f}; @@ -38,3 +40,5 @@ struct CustomStyle { float rotation = 0.0f; float scale = 0.5f; }; + +}} diff --git a/src/Mass/Decal.h b/src/Mass/Decal.h index 3bf7f14..4c057b5 100644 --- a/src/Mass/Decal.h +++ b/src/Mass/Decal.h @@ -23,6 +23,8 @@ using namespace Magnum; +namespace mbst { namespace GameObjects { + struct Decal { std::int32_t id = -1; Color4 colour{0.0f}; @@ -35,3 +37,5 @@ struct Decal { bool flip = false; bool wrap = false; }; + +}} diff --git a/src/Mass/Joints.h b/src/Mass/Joints.h index d2bb3fa..ce30800 100644 --- a/src/Mass/Joints.h +++ b/src/Mass/Joints.h @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +namespace mbst { namespace GameObjects { + struct Joints { float neck = 0.0f; float body = 0.0f; @@ -26,3 +28,5 @@ struct Joints { float upperLegs = 0.0f; float lowerLegs = 0.0f; }; + +}} diff --git a/src/Mass/Mass.cpp b/src/Mass/Mass.cpp index f34475e..901f820 100644 --- a/src/Mass/Mass.cpp +++ b/src/Mass/Mass.cpp @@ -23,17 +23,19 @@ #include "PropertyNames.h" #include "../Logger/Logger.h" -#include "../UESaveFile/Types/ArrayProperty.h" -#include "../UESaveFile/Types/BoolProperty.h" -#include "../UESaveFile/Types/ColourStructProperty.h" -#include "../UESaveFile/Types/GenericStructProperty.h" -#include "../UESaveFile/Types/IntProperty.h" -#include "../UESaveFile/Types/StringProperty.h" +#include "../Gvas/Types/ArrayProperty.h" +#include "../Gvas/Types/BoolProperty.h" +#include "../Gvas/Types/ColourStructProperty.h" +#include "../Gvas/Types/GenericStructProperty.h" +#include "../Gvas/Types/IntProperty.h" +#include "../Gvas/Types/StringProperty.h" #include "Mass.h" using namespace Containers::Literals; +namespace mbst { namespace GameObjects { + Mass::Mass(Containers::StringView path) { auto split = Utility::Path::split(path); _folder = split.first(); @@ -54,21 +56,21 @@ Mass::getNameFromFile(Containers::StringView path) { return Containers::NullOpt; } - UESaveFile mass{path}; + Gvas::File mass{path}; if(!mass.valid()) { LOG_ERROR_FORMAT("{} is invalid: {}", path, mass.lastError()); return Containers::NullOpt; } - auto unit_data = mass.at(MASS_UNIT_DATA); + auto unit_data = mass.at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, path); return Containers::NullOpt; } - auto name_prop = unit_data->at(MASS_NAME); + auto name_prop = unit_data->at(MASS_NAME); if(!name_prop) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_NAME, path); @@ -125,7 +127,7 @@ Mass::refreshValues() { } LOG_INFO("Getting the unit data."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; @@ -133,7 +135,7 @@ Mass::refreshValues() { } LOG_INFO("Reading the M.A.S.S. name."); - auto name_prop = unit_data->at(MASS_NAME); + auto name_prop = unit_data->at(MASS_NAME); if(!name_prop) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_NAME, _filename); @@ -220,7 +222,7 @@ Mass::refreshValues() { } LOG_INFO("Getting the associated account."); - auto account_prop = _mass->at("Account"_s); + auto account_prop = _mass->at("Account"_s); if(!account_prop) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_ACCOUNT, _filename); _state = State::Invalid; @@ -247,7 +249,7 @@ bool Mass::setName(Containers::StringView new_name) { _name = {new_name}; - auto unit_data = _mass->at("UnitData"_s); + auto unit_data = _mass->at("UnitData"_s); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); @@ -255,7 +257,7 @@ Mass::setName(Containers::StringView new_name) { return false; } - auto name_prop = unit_data->at("Name_45_A037C5D54E53456407BDF091344529BB"_s); + auto name_prop = unit_data->at("Name_45_A037C5D54E53456407BDF091344529BB"_s); if(!name_prop) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_NAME, _filename); @@ -347,7 +349,7 @@ bool Mass::updateAccount(Containers::StringView new_account) { _account = new_account; - auto account = _mass->at(MASS_ACCOUNT); + auto account = _mass->at(MASS_ACCOUNT); if(!account) { _lastError = "Couldn't find the " MASS_ACCOUNT " property."_s; _state = State::Invalid; @@ -371,7 +373,7 @@ Mass::getTuningCategory(Containers::StringView big_node_prop_name, std::int32_t& { LOG_INFO_FORMAT("Getting tuning data ({}, {}).", big_node_prop_name, small_nodes_prop_name); - auto node_id = _mass->at(big_node_prop_name); + auto node_id = _mass->at(big_node_prop_name); if(!node_id) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", big_node_prop_name, _filename); _state = State::Invalid; @@ -379,7 +381,7 @@ Mass::getTuningCategory(Containers::StringView big_node_prop_name, std::int32_t& } big_node_id = node_id->value; - auto node_ids = _mass->at(small_nodes_prop_name); + auto node_ids = _mass->at(small_nodes_prop_name); if(!node_ids) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", small_nodes_prop_name, _filename); _state = State::Invalid; @@ -394,8 +396,10 @@ Mass::getTuningCategory(Containers::StringView big_node_prop_name, std::int32_t& } for(std::uint32_t i = 0; i < small_nodes_ids.size(); i++) { - auto small_node_id = node_ids->at(i); + auto small_node_id = node_ids->at(i); CORRADE_INTERNAL_ASSERT(small_node_id); small_nodes_ids[i] = small_node_id->value; } } + +}} diff --git a/src/Mass/Mass.h b/src/Mass/Mass.h index eb1398b..ec1b419 100644 --- a/src/Mass/Mass.h +++ b/src/Mass/Mass.h @@ -36,12 +36,13 @@ #include "WeaponPart.h" #include "Weapon.h" -#include "../UESaveFile/UESaveFile.h" +#include "../Gvas/File.h" +#include "../Gvas/Types/Types.h" using namespace Corrade; using namespace Magnum; -struct ArrayProperty; +namespace mbst { namespace GameObjects { class Mass { public: @@ -53,106 +54,106 @@ class Mass { Mass(Mass&&) = default; Mass& operator=(Mass&&) = default; - Containers::StringView lastError(); + auto lastError() -> Containers::StringView ; - static Containers::Optional getNameFromFile(Containers::StringView path); + static auto getNameFromFile(Containers::StringView path) -> Containers::Optional; void refreshValues(); - Containers::StringView filename(); + auto filename() -> Containers::StringView; - Containers::StringView name(); + auto name() -> Containers::StringView; bool setName(Containers::StringView new_name); enum class State: std::uint8_t { Empty, Invalid, Valid }; - State state(); + auto state() -> State; bool dirty() const; void setDirty(bool dirty = true); - Joints& jointSliders(); + auto jointSliders() -> Joints&; void getJointSliders(); bool writeJointSliders(); - Containers::ArrayView frameStyles(); + auto frameStyles() -> Containers::ArrayView; void getFrameStyles(); bool writeFrameStyles(); - Color4& eyeFlareColour(); + auto eyeFlareColour() -> Color4&; void getEyeFlareColour(); bool writeEyeFlareColour(); - Containers::ArrayView frameCustomStyles(); + auto frameCustomStyles() -> Containers::ArrayView; void getFrameCustomStyles(); bool writeFrameCustomStyle(std::size_t index); - Containers::ArrayView armourParts(); + auto armourParts() -> Containers::ArrayView; void getArmourParts(); - bool writeArmourPart(ArmourSlot slot); + bool writeArmourPart(ArmourPart::Slot slot); - BulletLauncherAttachmentStyle& bulletLauncherAttachmentStyle(); - Containers::ArrayView bulletLauncherAttachments(); + auto bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle&; + auto bulletLauncherAttachments() -> Containers::ArrayView; void getBulletLauncherAttachments(); bool writeBulletLauncherAttachments(); - Containers::ArrayView armourCustomStyles(); + auto armourCustomStyles() -> Containers::ArrayView; void getArmourCustomStyles(); bool writeArmourCustomStyle(std::size_t index); - Containers::ArrayView meleeWeapons(); + auto meleeWeapons() -> Containers::ArrayView; void getMeleeWeapons(); bool writeMeleeWeapons(); - Containers::ArrayView shields(); + auto shields() -> Containers::ArrayView; void getShields(); bool writeShields(); - Containers::ArrayView bulletShooters(); + auto bulletShooters() -> Containers::ArrayView; void getBulletShooters(); bool writeBulletShooters(); - Containers::ArrayView energyShooters(); + auto energyShooters() -> Containers::ArrayView; void getEnergyShooters(); bool writeEnergyShooters(); - Containers::ArrayView bulletLaunchers(); + auto bulletLaunchers() -> Containers::ArrayView; void getBulletLaunchers(); bool writeBulletLaunchers(); - Containers::ArrayView energyLaunchers(); + auto energyLaunchers() -> Containers::ArrayView; void getEnergyLaunchers(); bool writeEnergyLaunchers(); - Containers::ArrayView globalStyles(); + auto globalStyles() -> Containers::ArrayView; void getGlobalStyles(); bool writeGlobalStyle(std::size_t index); void getTuning(); - std::int32_t& engine(); - Containers::ArrayView gears(); + auto engine() -> std::int32_t&; + auto gears() -> Containers::ArrayView; - std::int32_t& os(); - Containers::ArrayView modules(); + auto os() -> std::int32_t&; + auto modules() -> Containers::ArrayView; - std::int32_t& architecture(); - Containers::ArrayView techs(); + auto architecture() -> std::int32_t&; + auto techs() -> Containers::ArrayView; - Containers::StringView account(); + auto account() -> Containers::StringView; bool updateAccount(Containers::StringView new_account); private: - void getCustomStyles(Containers::ArrayView styles, ArrayProperty* style_array); - bool writeCustomStyle(const CustomStyle& style, std::size_t index, ArrayProperty* style_array); + void getCustomStyles(Containers::ArrayView styles, Gvas::Types::ArrayProperty* style_array); + bool writeCustomStyle(const CustomStyle& style, std::size_t index, Gvas::Types::ArrayProperty* style_array); - void getDecals(Containers::ArrayView decals, ArrayProperty* decal_array); - void writeDecals(Containers::ArrayView decals, ArrayProperty* decal_array); + void getDecals(Containers::ArrayView decals, Gvas::Types::ArrayProperty* decal_array); + void writeDecals(Containers::ArrayView decals, Gvas::Types::ArrayProperty* decal_array); - void getAccessories(Containers::ArrayView accessories, ArrayProperty* accessory_array); - void writeAccessories(Containers::ArrayView accessories, ArrayProperty* accs_array); + void getAccessories(Containers::ArrayView accessories, Gvas::Types::ArrayProperty* accessory_array); + void writeAccessories(Containers::ArrayView accessories, Gvas::Types::ArrayProperty* accs_array); void getWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array); bool writeWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array); @@ -161,7 +162,7 @@ class Mass { Containers::StringView small_nodes_prop_name, Containers::ArrayView small_nodes_ids); - Containers::Optional _mass; + Containers::Optional _mass; Containers::String _lastError; @@ -211,3 +212,5 @@ class Mass { Containers::String _account; }; + +}} diff --git a/src/Mass/Mass_Armour.cpp b/src/Mass/Mass_Armour.cpp index 990d637..796a1e9 100644 --- a/src/Mass/Mass_Armour.cpp +++ b/src/Mass/Mass_Armour.cpp @@ -18,17 +18,19 @@ #include "PropertyNames.h" #include "../Logger/Logger.h" -#include "../UESaveFile/Types/ArrayProperty.h" -#include "../UESaveFile/Types/ByteProperty.h" -#include "../UESaveFile/Types/GenericStructProperty.h" -#include "../UESaveFile/Types/IntProperty.h" -#include "../UESaveFile/Types/StringProperty.h" -#include "../UESaveFile/Types/VectorStructProperty.h" +#include "../Gvas/Types/ArrayProperty.h" +#include "../Gvas/Types/ByteProperty.h" +#include "../Gvas/Types/GenericStructProperty.h" +#include "../Gvas/Types/IntProperty.h" +#include "../Gvas/Types/StringProperty.h" +#include "../Gvas/Types/VectorStructProperty.h" #include "Mass.h" using namespace Containers::Literals; +namespace mbst { namespace GameObjects { + Containers::ArrayView Mass::armourParts() { return _armour.parts; @@ -38,14 +40,14 @@ void Mass::getArmourParts() { LOG_INFO("Getting armour parts."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; return; } - auto armour_array = unit_data->at(MASS_ARMOUR_PARTS); + auto armour_array = unit_data->at(MASS_ARMOUR_PARTS); if(!armour_array) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_ARMOUR_PARTS, _filename); _state = State::Invalid; @@ -60,11 +62,11 @@ Mass::getArmourParts() { } for(std::uint32_t i = 0; i < armour_array->items.size(); i++) { - auto part_prop = armour_array->at(i); + auto part_prop = armour_array->at(i); auto& part = _armour.parts[i]; - auto& armour_slot = part_prop->at(MASS_ARMOUR_SLOT)->enumValue; - #define c(enumerator, strenum, name) if(armour_slot == (strenum)) { part.slot = ArmourSlot::enumerator; } else + auto& armour_slot = part_prop->at(MASS_ARMOUR_SLOT)->enumValue; + #define c(enumerator, strenum, name) if(armour_slot == (strenum)) { part.slot = ArmourPart::Slot::enumerator; } else #include "../Maps/ArmourSlots.hpp" #undef c { @@ -73,9 +75,9 @@ Mass::getArmourParts() { return; } - part.id = part_prop->at(MASS_ARMOUR_ID)->value; + part.id = part_prop->at(MASS_ARMOUR_ID)->value; - auto part_styles = part_prop->at(MASS_ARMOUR_STYLES); + auto part_styles = part_prop->at(MASS_ARMOUR_STYLES); if(!part_styles) { LOG_ERROR_FORMAT("Part styles not found for part number {}.", i); _state = State::Invalid; @@ -90,10 +92,10 @@ Mass::getArmourParts() { } for(std::uint32_t j = 0; j < part_styles->items.size(); j++) { - part.styles[j] = part_styles->at(j)->value; + part.styles[j] = part_styles->at(j)->value; } - auto decals_array = part_prop->at(MASS_ARMOUR_DECALS); + auto decals_array = part_prop->at(MASS_ARMOUR_DECALS); if(!decals_array) { LOG_ERROR_FORMAT("Part decals not found for part number {}.", i); _state = State::Invalid; @@ -104,7 +106,7 @@ Mass::getArmourParts() { getDecals(part.decals, decals_array); - auto accs_array = part_prop->at(MASS_ARMOUR_ACCESSORIES); + auto accs_array = part_prop->at(MASS_ARMOUR_ACCESSORIES); if(!accs_array) { LOG_WARNING_FORMAT("Part accessories not found for part number {}.", i); part.accessories = Containers::Array{}; @@ -120,12 +122,12 @@ Mass::getArmourParts() { } bool -Mass::writeArmourPart(ArmourSlot slot) { +Mass::writeArmourPart(ArmourPart::Slot slot) { LOG_INFO_FORMAT("Writing armour part in slot {}.", static_cast(slot)); auto& part = *std::find_if(_armour.parts.begin(), _armour.parts.end(), [&slot](const ArmourPart& part){ return slot == part.slot; }); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "Couldn't find the unit data in " + _filename + "."; LOG_ERROR(_lastError); @@ -133,7 +135,7 @@ Mass::writeArmourPart(ArmourSlot slot) { return false; } - auto armour_array = unit_data->at(MASS_ARMOUR_PARTS); + auto armour_array = unit_data->at(MASS_ARMOUR_PARTS); if(!armour_array) { _lastError = "Couldn't find the armour part array in " + _filename + "."; LOG_ERROR(_lastError); @@ -143,18 +145,18 @@ Mass::writeArmourPart(ArmourSlot slot) { Containers::StringView slot_str = nullptr; switch(slot) { - #define c(enumerator, strenum, name) case ArmourSlot::enumerator: \ + #define c(enumerator, strenum, name) case ArmourPart::Slot::enumerator: \ slot_str = strenum; \ break; #include "../Maps/ArmourSlots.hpp" #undef c } - GenericStructProperty* part_prop = nullptr; + Gvas::Types::GenericStructProperty* part_prop = nullptr; for(std::uint32_t i = 0; i < armour_array->items.size(); i++) { - part_prop = armour_array->at(i); - if(slot_str == part_prop->at(MASS_ARMOUR_SLOT)->enumValue) { + part_prop = armour_array->at(i); + if(slot_str == part_prop->at(MASS_ARMOUR_SLOT)->enumValue) { break; } else { @@ -165,7 +167,7 @@ Mass::writeArmourPart(ArmourSlot slot) { if(!part_prop) { auto prefix = "Couldn't find the armour part for slot "_s; switch(slot) { - #define c(enumerator, strenum, name) case ArmourSlot::enumerator: \ + #define c(enumerator, strenum, name) case ArmourPart::Slot::enumerator: \ _lastError = prefix + "ArmourSlot::" #enumerator "."_s; \ break; #include "../Maps/ArmourSlots.hpp" @@ -175,18 +177,18 @@ Mass::writeArmourPart(ArmourSlot slot) { return false; } - part_prop->at(MASS_ARMOUR_ID)->value = part.id; + part_prop->at(MASS_ARMOUR_ID)->value = part.id; - auto part_styles = part_prop->at(MASS_ARMOUR_STYLES); + auto part_styles = part_prop->at(MASS_ARMOUR_STYLES); for(std::uint32_t i = 0; i < part.styles.size(); i++) { - part_styles->at(i)->value = part.styles[i]; + part_styles->at(i)->value = part.styles[i]; } - auto decals_array = part_prop->at(MASS_ARMOUR_DECALS); + auto decals_array = part_prop->at(MASS_ARMOUR_DECALS); writeDecals(part.decals, decals_array); if(!part.accessories.isEmpty()) { - auto accs_array = part_prop->at(MASS_ARMOUR_ACCESSORIES); + auto accs_array = part_prop->at(MASS_ARMOUR_ACCESSORIES); writeAccessories(part.accessories, accs_array); } @@ -212,15 +214,15 @@ void Mass::getBulletLauncherAttachments() { LOG_INFO("Getting the bullet launcher attachment data."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; return; } - auto attach_style_prop = unit_data->at(MASS_BL_ATTACHMENT_STYLE); - auto attach_array = unit_data->at(MASS_BL_ATTACHMENTS); + auto attach_style_prop = unit_data->at(MASS_BL_ATTACHMENT_STYLE); + auto attach_array = unit_data->at(MASS_BL_ATTACHMENTS); if(!attach_style_prop && !attach_array) { LOG_WARNING_FORMAT("No bullet launcher attachment data found in {}.", _filename); @@ -239,11 +241,11 @@ Mass::getBulletLauncherAttachments() { attach_array->items.size() == _armour.blAttachment.size()) { for(std::uint32_t i = 0; i < attach_array->items.size(); i++) { - auto attachment_prop = attach_array->at(i); + auto attachment_prop = attach_array->at(i); auto& attachment = _armour.blAttachment[i]; - Containers::StringView socket = attachment_prop->at(MASS_BL_ATTACHMENT_SOCKET)->value; - #define c(enumerator, strenum, name) if(socket == (strenum)) { attachment.socket = BulletLauncherSocket::enumerator; } else + Containers::StringView socket = attachment_prop->at(MASS_BL_ATTACHMENT_SOCKET)->value; + #define c(enumerator, strenum, name) if(socket == (strenum)) { attachment.socket = BulletLauncherAttachment::Socket::enumerator; } else #include "../Maps/BulletLauncherSockets.hpp" #undef c { @@ -252,15 +254,15 @@ Mass::getBulletLauncherAttachments() { return; } - auto rel_loc_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELLOC); + auto rel_loc_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELLOC); attachment.relativeLocation = Vector3{rel_loc_prop->x, rel_loc_prop->y, rel_loc_prop->z}; - auto off_loc_prop = attachment_prop->at(MASS_BL_ATTACHMENT_OFFLOC); + auto off_loc_prop = attachment_prop->at(MASS_BL_ATTACHMENT_OFFLOC); attachment.offsetLocation = Vector3{off_loc_prop->x, off_loc_prop->y, off_loc_prop->z}; - auto rel_rot_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELROT); + auto rel_rot_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELROT); attachment.relativeRotation = Vector3{rel_rot_prop->x, rel_rot_prop->y, rel_rot_prop->z}; - auto off_rot_prop = attachment_prop->at(MASS_BL_ATTACHMENT_OFFROT); + auto off_rot_prop = attachment_prop->at(MASS_BL_ATTACHMENT_OFFROT); attachment.offsetRotation = Vector3{off_rot_prop->x, off_rot_prop->y, off_rot_prop->z}; - auto rel_scale_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELSCALE); + auto rel_scale_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELSCALE); attachment.relativeScale = Vector3{rel_scale_prop->x, rel_scale_prop->y, rel_scale_prop->z}; } } @@ -284,7 +286,7 @@ bool Mass::writeBulletLauncherAttachments() { LOG_INFO("Writing bullet launcher attachments."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "No unit data in " + _filename; LOG_ERROR(_lastError); @@ -292,8 +294,8 @@ Mass::writeBulletLauncherAttachments() { return false; } - auto attach_style_prop = unit_data->at(MASS_BL_ATTACHMENT_STYLE); - auto attach_array = unit_data->at(MASS_BL_ATTACHMENTS); + auto attach_style_prop = unit_data->at(MASS_BL_ATTACHMENT_STYLE); + auto attach_array = unit_data->at(MASS_BL_ATTACHMENTS); if(!attach_style_prop && !attach_array) { _lastError = "No attachment properties to write to in " + _filename; @@ -314,12 +316,12 @@ Mass::writeBulletLauncherAttachments() { attach_array->items.size() == _armour.blAttachment.size()) { for(std::uint32_t i = 0; i < attach_array->items.size(); i++) { - auto attachment_prop = attach_array->at(i); + auto attachment_prop = attach_array->at(i); auto& attachment = _armour.blAttachment[i]; - auto& socket = attachment_prop->at(MASS_BL_ATTACHMENT_SOCKET)->value; + auto& socket = attachment_prop->at(MASS_BL_ATTACHMENT_SOCKET)->value; switch(attachment.socket) { - #define c(enumerator, strenum, name) case BulletLauncherSocket::enumerator: socket = strenum; break; + #define c(enumerator, strenum, name) case BulletLauncherAttachment::Socket::enumerator: socket = strenum; break; #include "../Maps/BulletLauncherSockets.hpp" #undef c default: @@ -328,23 +330,23 @@ Mass::writeBulletLauncherAttachments() { return false; } - auto rel_loc_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELLOC); + auto rel_loc_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELLOC); rel_loc_prop->x = attachment.relativeLocation.x(); rel_loc_prop->y = attachment.relativeLocation.y(); rel_loc_prop->z = attachment.relativeLocation.z(); - auto off_loc_prop = attachment_prop->at(MASS_BL_ATTACHMENT_OFFLOC); + auto off_loc_prop = attachment_prop->at(MASS_BL_ATTACHMENT_OFFLOC); off_loc_prop->x = attachment.offsetLocation.x(); off_loc_prop->y = attachment.offsetLocation.y(); off_loc_prop->z = attachment.offsetLocation.z(); - auto rel_rot_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELROT); + auto rel_rot_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELROT); rel_rot_prop->x = attachment.relativeRotation.x(); rel_rot_prop->y = attachment.relativeRotation.y(); rel_rot_prop->z = attachment.relativeRotation.z(); - auto off_rot_prop = attachment_prop->at(MASS_BL_ATTACHMENT_OFFROT); + auto off_rot_prop = attachment_prop->at(MASS_BL_ATTACHMENT_OFFROT); off_rot_prop->x = attachment.offsetRotation.x(); off_rot_prop->y = attachment.offsetRotation.y(); off_rot_prop->z = attachment.offsetRotation.z(); - auto rel_scale_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELSCALE); + auto rel_scale_prop = attachment_prop->at(MASS_BL_ATTACHMENT_RELSCALE); rel_scale_prop->x = attachment.relativeScale.x(); rel_scale_prop->y = attachment.relativeScale.y(); rel_scale_prop->z = attachment.relativeScale.z(); @@ -352,10 +354,10 @@ Mass::writeBulletLauncherAttachments() { } if(!attach_style_prop) { - attach_style_prop = new ByteProperty; + attach_style_prop = new Gvas::Types::ByteProperty; attach_style_prop->name.emplace(MASS_BL_ATTACHMENT_STYLE); attach_style_prop->enumType = "enuBLAttachmentStyle"_s; - ByteProperty::ptr prop{attach_style_prop}; + Gvas::Types::ByteProperty::ptr prop{attach_style_prop}; arrayAppend(unit_data->properties, std::move(prop)); } @@ -389,14 +391,14 @@ void Mass::getArmourCustomStyles() { LOG_INFO("Getting the custom armour styles."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; return; } - auto armour_styles = unit_data->at(MASS_CUSTOM_ARMOUR_STYLES); + auto armour_styles = unit_data->at(MASS_CUSTOM_ARMOUR_STYLES); if(!armour_styles) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_CUSTOM_ARMOUR_STYLES, _filename); _state = State::Invalid; @@ -423,7 +425,7 @@ Mass::writeArmourCustomStyle(std::size_t index) { return false; } - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "Couldn't find unit data in "_s + _filename; LOG_ERROR(_lastError); @@ -431,7 +433,7 @@ Mass::writeArmourCustomStyle(std::size_t index) { return false; } - auto armour_styles = unit_data->at(MASS_CUSTOM_ARMOUR_STYLES); + auto armour_styles = unit_data->at(MASS_CUSTOM_ARMOUR_STYLES); if(!armour_styles) { _lastError = "Couldn't find armour custom styles in "_s + _filename; LOG_ERROR(_lastError); @@ -441,3 +443,5 @@ Mass::writeArmourCustomStyle(std::size_t index) { return writeCustomStyle(_armour.customStyles[index], index, armour_styles); } + +}} diff --git a/src/Mass/Mass_DecalsAccessories.cpp b/src/Mass/Mass_DecalsAccessories.cpp index 002a95b..91fcc71 100644 --- a/src/Mass/Mass_DecalsAccessories.cpp +++ b/src/Mass/Mass_DecalsAccessories.cpp @@ -15,138 +15,142 @@ // along with this program. If not, see . #include "PropertyNames.h" -#include "../UESaveFile/Types/ArrayProperty.h" -#include "../UESaveFile/Types/BoolProperty.h" -#include "../UESaveFile/Types/ColourStructProperty.h" -#include "../UESaveFile/Types/FloatProperty.h" -#include "../UESaveFile/Types/GenericStructProperty.h" -#include "../UESaveFile/Types/RotatorStructProperty.h" -#include "../UESaveFile/Types/VectorStructProperty.h" -#include "../UESaveFile/Types/Vector2DStructProperty.h" -#include "../UESaveFile/Types/IntProperty.h" +#include "../Gvas/Types/ArrayProperty.h" +#include "../Gvas/Types/BoolProperty.h" +#include "../Gvas/Types/ColourStructProperty.h" +#include "../Gvas/Types/FloatProperty.h" +#include "../Gvas/Types/GenericStructProperty.h" +#include "../Gvas/Types/RotatorStructProperty.h" +#include "../Gvas/Types/VectorStructProperty.h" +#include "../Gvas/Types/Vector2DStructProperty.h" +#include "../Gvas/Types/IntProperty.h" #include "Mass.h" using namespace Containers::Literals; +namespace mbst { namespace GameObjects { + void -Mass::getDecals(Containers::ArrayView decals, ArrayProperty* decal_array) { +Mass::getDecals(Containers::ArrayView decals, Gvas::Types::ArrayProperty* decal_array) { for(std::uint32_t i = 0; i < decal_array->items.size(); i++) { - auto decal_prop = decal_array->at(i); + auto decal_prop = decal_array->at(i); CORRADE_INTERNAL_ASSERT(decal_prop); auto& decal = decals[i]; - decal.id = decal_prop->at(MASS_DECAL_ID)->value; - auto colour_prop = decal_prop->at(MASS_DECAL_COLOUR); + decal.id = decal_prop->at(MASS_DECAL_ID)->value; + auto colour_prop = decal_prop->at(MASS_DECAL_COLOUR); decal.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a}; - auto pos_prop = decal_prop->at(MASS_DECAL_POSITION); + auto pos_prop = decal_prop->at(MASS_DECAL_POSITION); decal.position = Vector3{pos_prop->x, pos_prop->y, pos_prop->z}; - auto u_prop = decal_prop->at(MASS_DECAL_UAXIS); + auto u_prop = decal_prop->at(MASS_DECAL_UAXIS); decal.uAxis = Vector3{u_prop->x, u_prop->y, u_prop->z}; - auto v_prop = decal_prop->at(MASS_DECAL_VAXIS); + auto v_prop = decal_prop->at(MASS_DECAL_VAXIS); decal.vAxis = Vector3{v_prop->x, v_prop->y, v_prop->z}; - auto offset_prop = decal_prop->at(MASS_DECAL_OFFSET); + auto offset_prop = decal_prop->at(MASS_DECAL_OFFSET); decal.offset = Vector2{offset_prop->x, offset_prop->y}; - decal.scale = decal_prop->at(MASS_DECAL_SCALE)->value; - decal.rotation = decal_prop->at(MASS_DECAL_ROTATION)->value; - decal.flip = decal_prop->at(MASS_DECAL_FLIP)->value; - decal.wrap = decal_prop->at(MASS_DECAL_WRAP)->value; + decal.scale = decal_prop->at(MASS_DECAL_SCALE)->value; + decal.rotation = decal_prop->at(MASS_DECAL_ROTATION)->value; + decal.flip = decal_prop->at(MASS_DECAL_FLIP)->value; + decal.wrap = decal_prop->at(MASS_DECAL_WRAP)->value; } } void -Mass::writeDecals(Containers::ArrayView decals, ArrayProperty* decal_array) { +Mass::writeDecals(Containers::ArrayView decals, Gvas::Types::ArrayProperty* decal_array) { for(std::uint32_t i = 0; i < decal_array->items.size(); i++) { - auto decal_prop = decal_array->at(i); + auto decal_prop = decal_array->at(i); CORRADE_INTERNAL_ASSERT(decal_prop); auto& decal = decals[i]; - decal_prop->at(MASS_DECAL_ID)->value = decal.id; - auto colour_prop = decal_prop->at(MASS_DECAL_COLOUR); + decal_prop->at(MASS_DECAL_ID)->value = decal.id; + auto colour_prop = decal_prop->at(MASS_DECAL_COLOUR); colour_prop->r = decal.colour.r(); colour_prop->g = decal.colour.g(); colour_prop->b = decal.colour.b(); colour_prop->a = decal.colour.a(); - auto pos_prop = decal_prop->at(MASS_DECAL_POSITION); + auto pos_prop = decal_prop->at(MASS_DECAL_POSITION); pos_prop->x = decal.position.x(); pos_prop->y = decal.position.y(); pos_prop->z = decal.position.z(); - auto u_prop = decal_prop->at(MASS_DECAL_UAXIS); + auto u_prop = decal_prop->at(MASS_DECAL_UAXIS); u_prop->x = decal.uAxis.x(); u_prop->y = decal.uAxis.y(); u_prop->z = decal.uAxis.z(); - auto v_prop = decal_prop->at(MASS_DECAL_VAXIS); + auto v_prop = decal_prop->at(MASS_DECAL_VAXIS); v_prop->x = decal.vAxis.x(); v_prop->y = decal.vAxis.y(); v_prop->z = decal.vAxis.z(); - auto offset_prop = decal_prop->at(MASS_DECAL_OFFSET); + auto offset_prop = decal_prop->at(MASS_DECAL_OFFSET); offset_prop->x = decal.offset.x(); offset_prop->y = decal.offset.y(); - decal_prop->at(MASS_DECAL_SCALE)->value = decal.scale; - decal_prop->at(MASS_DECAL_ROTATION)->value = decal.rotation; - decal_prop->at(MASS_DECAL_FLIP)->value = decal.flip; - decal_prop->at(MASS_DECAL_WRAP)->value = decal.wrap; + decal_prop->at(MASS_DECAL_SCALE)->value = decal.scale; + decal_prop->at(MASS_DECAL_ROTATION)->value = decal.rotation; + decal_prop->at(MASS_DECAL_FLIP)->value = decal.flip; + decal_prop->at(MASS_DECAL_WRAP)->value = decal.wrap; } } void -Mass::getAccessories(Containers::ArrayView accessories, ArrayProperty* accessory_array) { +Mass::getAccessories(Containers::ArrayView accessories, Gvas::Types::ArrayProperty* accessory_array) { for(std::uint32_t i = 0; i < accessory_array->items.size(); i++) { - auto acc_prop = accessory_array->at(i); + auto acc_prop = accessory_array->at(i); CORRADE_INTERNAL_ASSERT(acc_prop); auto& accessory = accessories[i]; - accessory.attachIndex = acc_prop->at(MASS_ACCESSORY_ATTACH_INDEX)->value; - accessory.id = acc_prop->at(MASS_ACCESSORY_ID)->value; - auto acc_styles = acc_prop->at(MASS_ACCESSORY_STYLES); + accessory.attachIndex = acc_prop->at(MASS_ACCESSORY_ATTACH_INDEX)->value; + accessory.id = acc_prop->at(MASS_ACCESSORY_ID)->value; + auto acc_styles = acc_prop->at(MASS_ACCESSORY_STYLES); for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) { - accessory.styles[j] = acc_styles->at(j)->value; + accessory.styles[j] = acc_styles->at(j)->value; } - auto rel_pos_prop = acc_prop->at(MASS_ACCESSORY_RELPOS); + auto rel_pos_prop = acc_prop->at(MASS_ACCESSORY_RELPOS); accessory.relativePosition = Vector3{rel_pos_prop->x, rel_pos_prop->y, rel_pos_prop->z}; - auto rel_pos_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFPOS); + auto rel_pos_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFPOS); accessory.relativePositionOffset = Vector3{rel_pos_offset_prop->x, rel_pos_offset_prop->y, rel_pos_offset_prop->z}; - auto rel_rot_prop = acc_prop->at(MASS_ACCESSORY_RELROT); + auto rel_rot_prop = acc_prop->at(MASS_ACCESSORY_RELROT); accessory.relativeRotation = Vector3{rel_rot_prop->x, rel_rot_prop->y, rel_rot_prop->z}; - auto rel_rot_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFROT); + auto rel_rot_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFROT); accessory.relativeRotationOffset = Vector3{rel_rot_offset_prop->x, rel_rot_offset_prop->y, rel_rot_offset_prop->z}; - auto local_scale_prop = acc_prop->at(MASS_ACCESSORY_SCALE); + auto local_scale_prop = acc_prop->at(MASS_ACCESSORY_SCALE); accessory.localScale = Vector3{local_scale_prop->x, local_scale_prop->y, local_scale_prop->z}; } } void -Mass::writeAccessories(Containers::ArrayView accessories, ArrayProperty* accs_array) { +Mass::writeAccessories(Containers::ArrayView accessories, Gvas::Types::ArrayProperty* accs_array) { for(std::uint32_t i = 0; i < accs_array->items.size(); i++) { - auto acc_prop = accs_array->at(i); + auto acc_prop = accs_array->at(i); CORRADE_INTERNAL_ASSERT(acc_prop); auto& accessory = accessories[i]; - acc_prop->at(MASS_ACCESSORY_ATTACH_INDEX)->value = accessory.attachIndex; - acc_prop->at(MASS_ACCESSORY_ID)->value = accessory.id; - auto acc_styles = acc_prop->at(MASS_ACCESSORY_STYLES); + acc_prop->at(MASS_ACCESSORY_ATTACH_INDEX)->value = accessory.attachIndex; + acc_prop->at(MASS_ACCESSORY_ID)->value = accessory.id; + auto acc_styles = acc_prop->at(MASS_ACCESSORY_STYLES); for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) { - acc_styles->at(j)->value = accessory.styles[j]; + acc_styles->at(j)->value = accessory.styles[j]; } - auto rel_pos_prop = acc_prop->at(MASS_ACCESSORY_RELPOS); + auto rel_pos_prop = acc_prop->at(MASS_ACCESSORY_RELPOS); rel_pos_prop->x = accessory.relativePosition.x(); rel_pos_prop->y = accessory.relativePosition.y(); rel_pos_prop->z = accessory.relativePosition.z(); - auto rel_pos_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFPOS); + auto rel_pos_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFPOS); rel_pos_offset_prop->x = accessory.relativePositionOffset.x(); rel_pos_offset_prop->y = accessory.relativePositionOffset.y(); rel_pos_offset_prop->z = accessory.relativePositionOffset.z(); - auto rel_rot_prop = acc_prop->at(MASS_ACCESSORY_RELROT); + auto rel_rot_prop = acc_prop->at(MASS_ACCESSORY_RELROT); rel_rot_prop->x = accessory.relativeRotation.x(); rel_rot_prop->y = accessory.relativeRotation.y(); rel_rot_prop->z = accessory.relativeRotation.z(); - auto rel_rot_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFROT); + auto rel_rot_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFROT); rel_rot_offset_prop->x = accessory.relativeRotationOffset.x(); rel_rot_offset_prop->y = accessory.relativeRotationOffset.y(); rel_rot_offset_prop->z = accessory.relativeRotationOffset.z(); - auto local_scale_prop = acc_prop->at(MASS_ACCESSORY_SCALE); + auto local_scale_prop = acc_prop->at(MASS_ACCESSORY_SCALE); local_scale_prop->x = accessory.localScale.x(); local_scale_prop->y = accessory.localScale.y(); local_scale_prop->z = accessory.localScale.z(); } } + +}} diff --git a/src/Mass/Mass_Frame.cpp b/src/Mass/Mass_Frame.cpp index 510bcdb..1c44096 100644 --- a/src/Mass/Mass_Frame.cpp +++ b/src/Mass/Mass_Frame.cpp @@ -16,16 +16,18 @@ #include "PropertyNames.h" #include "../Logger/Logger.h" -#include "../UESaveFile/Types/ArrayProperty.h" -#include "../UESaveFile/Types/ColourStructProperty.h" -#include "../UESaveFile/Types/FloatProperty.h" -#include "../UESaveFile/Types/GenericStructProperty.h" -#include "../UESaveFile/Types/IntProperty.h" +#include "../Gvas/Types/ArrayProperty.h" +#include "../Gvas/Types/ColourStructProperty.h" +#include "../Gvas/Types/FloatProperty.h" +#include "../Gvas/Types/GenericStructProperty.h" +#include "../Gvas/Types/IntProperty.h" #include "Mass.h" using namespace Containers::Literals; +namespace mbst { namespace GameObjects { + Joints& Mass::jointSliders() { return _frame.joints; @@ -35,35 +37,35 @@ void Mass::getJointSliders() { LOG_INFO("Getting joint sliders."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; return; } - auto frame_prop = unit_data->at(MASS_FRAME); + auto frame_prop = unit_data->at(MASS_FRAME); if(!frame_prop) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_FRAME, _filename); _state = State::Invalid; return; } - auto length = frame_prop->at(MASS_JOINT_NECK); + auto length = frame_prop->at(MASS_JOINT_NECK); _frame.joints.neck = (length ? length->value : 0.0f); - length = frame_prop->at(MASS_JOINT_BODY); + length = frame_prop->at(MASS_JOINT_BODY); _frame.joints.body = (length ? length->value : 0.0f); - length = frame_prop->at(MASS_JOINT_SHOULDER); + length = frame_prop->at(MASS_JOINT_SHOULDER); _frame.joints.shoulders = (length ? length->value : 0.0f); - length = frame_prop->at(MASS_JOINT_HIP); + length = frame_prop->at(MASS_JOINT_HIP); _frame.joints.hips = (length ? length->value : 0.0f); - length = frame_prop->at(MASS_JOINT_ARM_UPPER); + length = frame_prop->at(MASS_JOINT_ARM_UPPER); _frame.joints.upperArms = (length ? length->value : 0.0f); - length = frame_prop->at(MASS_JOINT_ARM_LOWER); + length = frame_prop->at(MASS_JOINT_ARM_LOWER); _frame.joints.lowerArms = (length ? length->value : 0.0f); - length = frame_prop->at(MASS_JOINT_LEG_UPPER); + length = frame_prop->at(MASS_JOINT_LEG_UPPER); _frame.joints.upperLegs = (length ? length->value : 0.0f); - length = frame_prop->at(MASS_JOINT_LEG_LOWER); + length = frame_prop->at(MASS_JOINT_LEG_LOWER); _frame.joints.lowerLegs = (length ? length->value : 0.0f); } @@ -71,7 +73,7 @@ bool Mass::writeJointSliders() { LOG_INFO("Writing joint sliders"); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "No unit data in "_s + _filename; LOG_ERROR(_lastError); @@ -79,7 +81,7 @@ Mass::writeJointSliders() { return false; } - auto frame_prop = unit_data->at(MASS_FRAME); + auto frame_prop = unit_data->at(MASS_FRAME); if(!frame_prop) { _lastError = "No frame data in "_s + _filename; @@ -88,9 +90,9 @@ Mass::writeJointSliders() { return false; } - Containers::Array temp; + Containers::Array temp; - auto length = frame_prop->atMove(MASS_JOINT_NECK); + auto length = frame_prop->atMove(MASS_JOINT_NECK); if(_frame.joints.neck != 0.0f) { if(!length) { length.emplace(); @@ -100,7 +102,7 @@ Mass::writeJointSliders() { arrayAppend(temp, std::move(length)); } - length = frame_prop->atMove(MASS_JOINT_BODY); + length = frame_prop->atMove(MASS_JOINT_BODY); if(_frame.joints.body != 0.0f) { if(!length) { length.emplace(); @@ -110,7 +112,7 @@ Mass::writeJointSliders() { arrayAppend(temp, std::move(length)); } - length = frame_prop->atMove(MASS_JOINT_SHOULDER); + length = frame_prop->atMove(MASS_JOINT_SHOULDER); if(_frame.joints.shoulders != 0.0f) { if(!length) { length.emplace(); @@ -120,7 +122,7 @@ Mass::writeJointSliders() { arrayAppend(temp, std::move(length)); } - length = frame_prop->atMove(MASS_JOINT_ARM_UPPER); + length = frame_prop->atMove(MASS_JOINT_ARM_UPPER); if(_frame.joints.upperArms != 0.0f) { if(!length) { length.emplace(); @@ -130,7 +132,7 @@ Mass::writeJointSliders() { arrayAppend(temp, std::move(length)); } - length = frame_prop->atMove(MASS_JOINT_ARM_LOWER); + length = frame_prop->atMove(MASS_JOINT_ARM_LOWER); if(_frame.joints.lowerArms != 0.0f) { if(!length) { length.emplace(); @@ -140,7 +142,7 @@ Mass::writeJointSliders() { arrayAppend(temp, std::move(length)); } - length = frame_prop->atMove(MASS_JOINT_HIP); + length = frame_prop->atMove(MASS_JOINT_HIP); if(_frame.joints.hips != 0.0f) { if(!length) { length.emplace(); @@ -150,7 +152,7 @@ Mass::writeJointSliders() { arrayAppend(temp, std::move(length)); } - length = frame_prop->atMove(MASS_JOINT_LEG_UPPER); + length = frame_prop->atMove(MASS_JOINT_LEG_UPPER); if(_frame.joints.upperLegs != 0.0f) { if(!length) { length.emplace(); @@ -160,7 +162,7 @@ Mass::writeJointSliders() { arrayAppend(temp, std::move(length)); } - length = frame_prop->atMove(MASS_JOINT_LEG_LOWER); + length = frame_prop->atMove(MASS_JOINT_LEG_LOWER); if(_frame.joints.lowerLegs != 0.0f) { if(!length) { length.emplace(); @@ -193,21 +195,21 @@ void Mass::getFrameStyles() { LOG_INFO("Getting frame styles."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; return; } - auto frame_prop = unit_data->at(MASS_FRAME); + auto frame_prop = unit_data->at(MASS_FRAME); if(!frame_prop) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_FRAME, _filename); _state = State::Invalid; return; } - auto frame_styles = frame_prop->at(MASS_FRAME_STYLES); + auto frame_styles = frame_prop->at(MASS_FRAME_STYLES); if(!frame_styles) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_FRAME_STYLES, _filename); _state = State::Invalid; @@ -222,7 +224,7 @@ Mass::getFrameStyles() { } for(std::uint32_t i = 0; i < frame_styles->items.size(); i++) { - _frame.styles[i] = frame_styles->at(i)->value; + _frame.styles[i] = frame_styles->at(i)->value; } } @@ -230,7 +232,7 @@ bool Mass::writeFrameStyles() { LOG_INFO("Writing frame styles."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "No unit data in "_s + _filename; LOG_ERROR(_lastError); @@ -238,7 +240,7 @@ Mass::writeFrameStyles() { return false; } - auto frame = unit_data->at(MASS_FRAME); + auto frame = unit_data->at(MASS_FRAME); if(!frame) { _lastError = "No frame data in "_s + _filename; LOG_ERROR(_lastError); @@ -246,7 +248,7 @@ Mass::writeFrameStyles() { return false; } - auto frame_styles = frame->at(MASS_FRAME_STYLES); + auto frame_styles = frame->at(MASS_FRAME_STYLES); if(!frame_styles) { _lastError = "No frame styles in "_s + _filename; LOG_ERROR(_lastError); @@ -255,7 +257,7 @@ Mass::writeFrameStyles() { } for(std::uint32_t i = 0; i < frame_styles->items.size(); i++) { - frame_styles->at(i)->value = _frame.styles[i]; + frame_styles->at(i)->value = _frame.styles[i]; } if(!_mass->saveToFile()) { @@ -275,21 +277,21 @@ void Mass::getEyeFlareColour() { LOG_INFO("Getting the eye flare colour."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; return; } - auto frame_prop = unit_data->at(MASS_FRAME); + auto frame_prop = unit_data->at(MASS_FRAME); if(!frame_prop) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_FRAME, _filename); _state = State::Invalid; return; } - auto eye_flare_prop = frame_prop->at(MASS_EYE_FLARE); + auto eye_flare_prop = frame_prop->at(MASS_EYE_FLARE); if(!eye_flare_prop) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_EYE_FLARE, _filename); _state = State::Invalid; @@ -303,7 +305,7 @@ bool Mass::writeEyeFlareColour() { LOG_INFO("Writing the eye flare colour."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "No unit data in "_s + _filename; LOG_ERROR(_lastError); @@ -311,7 +313,7 @@ Mass::writeEyeFlareColour() { return false; } - auto frame = unit_data->at(MASS_FRAME); + auto frame = unit_data->at(MASS_FRAME); if(!frame) { _lastError = "No frame data in "_s + _filename; LOG_ERROR(_lastError); @@ -319,7 +321,7 @@ Mass::writeEyeFlareColour() { return false; } - auto eye_flare_prop = frame->at(MASS_EYE_FLARE); + auto eye_flare_prop = frame->at(MASS_EYE_FLARE); if(!eye_flare_prop) { _lastError = "No eye flare property in "_s + _filename; LOG_ERROR(_lastError); @@ -349,14 +351,14 @@ void Mass::getFrameCustomStyles() { LOG_INFO("Getting the frame's custom styles."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; return; } - auto frame_styles = unit_data->at(MASS_CUSTOM_FRAME_STYLES); + auto frame_styles = unit_data->at(MASS_CUSTOM_FRAME_STYLES); if(!frame_styles) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_CUSTOM_FRAME_STYLES, _filename); _state = State::Invalid; @@ -383,7 +385,7 @@ Mass::writeFrameCustomStyle(std::size_t index) { return false; } - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "No unit data in "_s + _filename; LOG_ERROR(_lastError); @@ -391,7 +393,7 @@ Mass::writeFrameCustomStyle(std::size_t index) { return false; } - auto frame_styles = unit_data->at(MASS_CUSTOM_FRAME_STYLES); + auto frame_styles = unit_data->at(MASS_CUSTOM_FRAME_STYLES); if(!frame_styles) { _lastError = "No frame styles in "_s + _filename; LOG_ERROR(_lastError); @@ -401,3 +403,5 @@ Mass::writeFrameCustomStyle(std::size_t index) { return writeCustomStyle(_frame.customStyles[index], index, frame_styles); } + +}} diff --git a/src/Mass/Mass_Styles.cpp b/src/Mass/Mass_Styles.cpp index ea22921..48a3f94 100644 --- a/src/Mass/Mass_Styles.cpp +++ b/src/Mass/Mass_Styles.cpp @@ -16,17 +16,19 @@ #include "PropertyNames.h" #include "../Logger/Logger.h" -#include "../UESaveFile/Types/ArrayProperty.h" -#include "../UESaveFile/Types/ColourStructProperty.h" -#include "../UESaveFile/Types/FloatProperty.h" -#include "../UESaveFile/Types/GenericStructProperty.h" -#include "../UESaveFile/Types/IntProperty.h" -#include "../UESaveFile/Types/StringProperty.h" +#include "../Gvas/Types/ArrayProperty.h" +#include "../Gvas/Types/ColourStructProperty.h" +#include "../Gvas/Types/FloatProperty.h" +#include "../Gvas/Types/GenericStructProperty.h" +#include "../Gvas/Types/IntProperty.h" +#include "../Gvas/Types/StringProperty.h" #include "Mass.h" using namespace Containers::Literals; +namespace mbst { namespace GameObjects { + Containers::ArrayView Mass::globalStyles() { return _globalStyles; @@ -36,14 +38,14 @@ void Mass::getGlobalStyles() { LOG_INFO("Getting global styles."); - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; return; } - auto global_styles = unit_data->at(MASS_GLOBAL_STYLES); + auto global_styles = unit_data->at(MASS_GLOBAL_STYLES); if(!global_styles) { LOG_WARNING_FORMAT("Couldn't find global styles in {}.", _filename); _globalStyles = Containers::Array{0}; @@ -67,7 +69,7 @@ Mass::writeGlobalStyle(std::size_t index) { return false; } - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "No unit data found in "_s + _filename; LOG_ERROR(_lastError); @@ -75,7 +77,7 @@ Mass::writeGlobalStyle(std::size_t index) { return false; } - auto global_styles = unit_data->at(MASS_GLOBAL_STYLES); + auto global_styles = unit_data->at(MASS_GLOBAL_STYLES); if(!global_styles) { _lastError = "No global styles found in "_s + _filename; LOG_ERROR(_lastError); @@ -87,59 +89,59 @@ Mass::writeGlobalStyle(std::size_t index) { } void -Mass::getCustomStyles(Containers::ArrayView styles, ArrayProperty* style_array) { +Mass::getCustomStyles(Containers::ArrayView styles, Gvas::Types::ArrayProperty* style_array) { for(std::uint32_t i = 0; i < style_array->items.size(); i++) { - auto style_prop = style_array->at(i); + auto style_prop = style_array->at(i); auto& style = styles[i]; - style.name = style_prop->at(MASS_STYLE_NAME)->value; - auto colour_prop = style_prop->at(MASS_STYLE_COLOUR); + style.name = style_prop->at(MASS_STYLE_NAME)->value; + auto colour_prop = style_prop->at(MASS_STYLE_COLOUR); style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a}; - style.metallic = style_prop->at(MASS_STYLE_METALLIC)->value; - style.gloss = style_prop->at(MASS_STYLE_GLOSS)->value; + style.metallic = style_prop->at(MASS_STYLE_METALLIC)->value; + style.gloss = style_prop->at(MASS_STYLE_GLOSS)->value; style.glow = colour_prop->a != 0.0f; - style.patternId = style_prop->at(MASS_STYLE_PATTERN_ID)->value; - style.opacity = style_prop->at(MASS_STYLE_PATTERN_OPACITY)->value; + style.patternId = style_prop->at(MASS_STYLE_PATTERN_ID)->value; + style.opacity = style_prop->at(MASS_STYLE_PATTERN_OPACITY)->value; style.offset = Vector2{ - style_prop->at(MASS_STYLE_PATTERN_OFFSETX)->value, - style_prop->at(MASS_STYLE_PATTERN_OFFSETY)->value + style_prop->at(MASS_STYLE_PATTERN_OFFSETX)->value, + style_prop->at(MASS_STYLE_PATTERN_OFFSETY)->value }; - style.rotation = style_prop->at(MASS_STYLE_PATTERN_ROTATION)->value; - style.scale = style_prop->at(MASS_STYLE_PATTERN_SCALE)->value; + style.rotation = style_prop->at(MASS_STYLE_PATTERN_ROTATION)->value; + style.scale = style_prop->at(MASS_STYLE_PATTERN_SCALE)->value; } } bool -Mass::writeCustomStyle(const CustomStyle& style, std::size_t index, ArrayProperty* style_array) { +Mass::writeCustomStyle(const CustomStyle& style, std::size_t index, Gvas::Types::ArrayProperty* style_array) { if(!style_array) { _lastError = "style_array is null."_s; LOG_ERROR(_lastError); return false; } - auto style_prop = style_array->at(index); + auto style_prop = style_array->at(index); if(!style_prop) { _lastError = "Style index is out of range in "_s + _filename; LOG_ERROR(_lastError); return false; } - style_prop->at(MASS_STYLE_NAME)->value = style.name; - auto colour_prop = style_prop->at(MASS_STYLE_COLOUR); + style_prop->at(MASS_STYLE_NAME)->value = style.name; + auto colour_prop = style_prop->at(MASS_STYLE_COLOUR); colour_prop->r = style.colour.r(); colour_prop->g = style.colour.g(); colour_prop->b = style.colour.b(); colour_prop->a = style.glow ? 1.0f : 0.0f; - style_prop->at(MASS_STYLE_METALLIC)->value = style.metallic; - style_prop->at(MASS_STYLE_GLOSS)->value = style.gloss; + style_prop->at(MASS_STYLE_METALLIC)->value = style.metallic; + style_prop->at(MASS_STYLE_GLOSS)->value = style.gloss; - style_prop->at(MASS_STYLE_PATTERN_ID)->value = style.patternId; - style_prop->at(MASS_STYLE_PATTERN_OPACITY)->value = style.opacity; - style_prop->at(MASS_STYLE_PATTERN_OFFSETX)->value = style.offset.x(); - style_prop->at(MASS_STYLE_PATTERN_OFFSETY)->value = style.offset.y(); - style_prop->at(MASS_STYLE_PATTERN_ROTATION)->value = style.rotation; - style_prop->at(MASS_STYLE_PATTERN_SCALE)->value = style.scale; + style_prop->at(MASS_STYLE_PATTERN_ID)->value = style.patternId; + style_prop->at(MASS_STYLE_PATTERN_OPACITY)->value = style.opacity; + style_prop->at(MASS_STYLE_PATTERN_OFFSETX)->value = style.offset.x(); + style_prop->at(MASS_STYLE_PATTERN_OFFSETY)->value = style.offset.y(); + style_prop->at(MASS_STYLE_PATTERN_ROTATION)->value = style.rotation; + style_prop->at(MASS_STYLE_PATTERN_SCALE)->value = style.scale; if(!_mass->saveToFile()) { _lastError = _mass->lastError(); @@ -148,3 +150,5 @@ Mass::writeCustomStyle(const CustomStyle& style, std::size_t index, ArrayPropert return true; } + +}} diff --git a/src/Mass/Mass_Weapons.cpp b/src/Mass/Mass_Weapons.cpp index ba21459..11a5ca6 100644 --- a/src/Mass/Mass_Weapons.cpp +++ b/src/Mass/Mass_Weapons.cpp @@ -16,18 +16,20 @@ #include "PropertyNames.h" #include "../Logger/Logger.h" -#include "../UESaveFile/Types/ArrayProperty.h" -#include "../UESaveFile/Types/BoolProperty.h" -#include "../UESaveFile/Types/ByteProperty.h" -#include "../UESaveFile/Types/ColourStructProperty.h" -#include "../UESaveFile/Types/GenericStructProperty.h" -#include "../UESaveFile/Types/IntProperty.h" -#include "../UESaveFile/Types/StringProperty.h" +#include "../Gvas/Types/ArrayProperty.h" +#include "../Gvas/Types/BoolProperty.h" +#include "../Gvas/Types/ByteProperty.h" +#include "../Gvas/Types/ColourStructProperty.h" +#include "../Gvas/Types/GenericStructProperty.h" +#include "../Gvas/Types/IntProperty.h" +#include "../Gvas/Types/StringProperty.h" #include "Mass.h" using namespace Containers::Literals; +namespace mbst { namespace GameObjects { + Containers::ArrayView Mass::meleeWeapons() { return _weapons.melee; @@ -132,14 +134,14 @@ Mass::writeEnergyLaunchers() { void Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array) { - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); _state = State::Invalid; return; } - auto prop = unit_data->at(prop_name); + auto prop = unit_data->at(prop_name); if(!prop) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", prop_name, _filename); _state = State::Invalid; @@ -154,12 +156,12 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(i); + auto weapon_prop = prop->at(i); auto& weapon = weapon_array[i]; - weapon.name = weapon_prop->at(MASS_WEAPON_NAME)->value; - auto& weapon_type = weapon_prop->at(MASS_WEAPON_TYPE)->enumValue; - #define c(enumerator, strenum, name) if(weapon_type == (strenum)) { weapon.type = WeaponType::enumerator; } else + weapon.name = weapon_prop->at(MASS_WEAPON_NAME)->value; + auto& weapon_type = weapon_prop->at(MASS_WEAPON_TYPE)->enumValue; + #define c(enumerator, strenum, name) if(weapon_type == (strenum)) { weapon.type = Weapon::Type::enumerator; } else #include "../Maps/WeaponTypes.hpp" #undef c { @@ -168,28 +170,28 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_ELEMENT); + auto parts_prop = weapon_prop->at(MASS_WEAPON_ELEMENT); weapon.parts = Containers::Array{ValueInit, parts_prop->items.size()}; for(std::uint32_t j = 0; j < parts_prop->items.size(); j++) { - auto part_prop = parts_prop->at(j); + auto part_prop = parts_prop->at(j); auto& part = weapon.parts[j]; - part.id = part_prop->at(MASS_WEAPON_PART_ID)->value; + part.id = part_prop->at(MASS_WEAPON_PART_ID)->value; - auto part_styles = part_prop->at(MASS_WEAPON_PART_STYLES); + auto part_styles = part_prop->at(MASS_WEAPON_PART_STYLES); for(std::uint32_t k = 0; k < part_styles->items.size(); k++) { - part.styles[k] = part_styles->at(k)->value; + part.styles[k] = part_styles->at(k)->value; } - auto part_decals = part_prop->at(MASS_WEAPON_PART_DECALS); + auto part_decals = part_prop->at(MASS_WEAPON_PART_DECALS); if(part_decals->items.size() != part.decals.size()) { part.decals = Containers::Array{part_decals->items.size()}; } getDecals(part.decals, part_decals); - auto part_accs = part_prop->at(MASS_WEAPON_PART_ACCESSORIES); + auto part_accs = part_prop->at(MASS_WEAPON_PART_ACCESSORIES); if(!part_accs) { part.accessories = Containers::Array{0}; continue; @@ -201,7 +203,7 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_CUSTOM_WEAPON_STYLES); + auto custom_styles = weapon_prop->at(MASS_CUSTOM_WEAPON_STYLES); if(!custom_styles) { LOG_ERROR_FORMAT("Can't find weapon custom styles in {}", _filename); _state = State::Invalid; @@ -217,9 +219,9 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_ATTACH)->value; - auto& damage_type = weapon_prop->at(MASS_WEAPON_DAMAGE_TYPE)->enumValue; - #define c(enumerator, strenum) if(damage_type == (strenum)) { weapon.damageType = DamageType::enumerator; } else + weapon.attached = weapon_prop->at(MASS_WEAPON_ATTACH)->value; + auto& damage_type = weapon_prop->at(MASS_WEAPON_DAMAGE_TYPE)->enumValue; + #define c(enumerator, strenum) if(damage_type == (strenum)) { weapon.damageType = Weapon::DamageType::enumerator; } else #include "../Maps/DamageTypes.hpp" #undef c { @@ -227,9 +229,9 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_DUAL_WIELD)->value; - auto& effect_colour_mode = weapon_prop->at(MASS_WEAPON_COLOUR_EFX_MODE)->enumValue; - #define c(enumerator, strenum) if(effect_colour_mode == (strenum)) { weapon.effectColourMode = EffectColourMode::enumerator; } else + weapon.dualWield = weapon_prop->at(MASS_WEAPON_DUAL_WIELD)->value; + auto& effect_colour_mode = weapon_prop->at(MASS_WEAPON_COLOUR_EFX_MODE)->enumValue; + #define c(enumerator, strenum) if(effect_colour_mode == (strenum)) { weapon.effectColourMode = Weapon::EffectColourMode::enumerator; } else #include "../Maps/EffectColourModes.hpp" #undef c { @@ -237,14 +239,14 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_COLOUR_EFX); + auto effect_colour = weapon_prop->at(MASS_WEAPON_COLOUR_EFX); weapon.effectColour = Color4{effect_colour->r, effect_colour->g, effect_colour->b, effect_colour->a}; } } bool Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array) { - auto unit_data = _mass->at(MASS_UNIT_DATA); + auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "No unit data in "_s + _filename; LOG_ERROR(_lastError); @@ -252,7 +254,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(prop_name); + auto prop = unit_data->at(prop_name); if(!prop) { _lastError = prop_name + " not found in "_s + _filename; LOG_ERROR(_lastError); @@ -269,12 +271,12 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(i); + auto weapon_prop = prop->at(i); auto& weapon = weapon_array[i]; - weapon_prop->at(MASS_WEAPON_NAME)->value = weapon.name; + weapon_prop->at(MASS_WEAPON_NAME)->value = weapon.name; switch(weapon.type) { - #define c(enumerator, strenum, name) case WeaponType::enumerator: weapon_prop->at(MASS_WEAPON_TYPE)->enumValue = strenum; break; + #define c(enumerator, strenum, name) case Weapon::Type::enumerator: weapon_prop->at(MASS_WEAPON_TYPE)->enumValue = strenum; break; #include "../Maps/WeaponTypes.hpp" #undef c default: @@ -283,7 +285,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_ELEMENT); + auto parts_prop = weapon_prop->at(MASS_WEAPON_ELEMENT); if(parts_prop->items.size() != weapon.parts.size()) { _lastError = Utility::format("Weapon part arrays are not of the same size. Expected {}, got {} instead.", weapon.parts.size(), parts_prop->items.size()); @@ -293,20 +295,20 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewitems.size(); j++) { - auto part_prop = parts_prop->at(j); + auto part_prop = parts_prop->at(j); auto& part = weapon.parts[j]; - part_prop->at(MASS_WEAPON_PART_ID)->value = part.id; + part_prop->at(MASS_WEAPON_PART_ID)->value = part.id; - auto part_styles = part_prop->at(MASS_WEAPON_PART_STYLES); + auto part_styles = part_prop->at(MASS_WEAPON_PART_STYLES); for(std::uint32_t k = 0; k < part_styles->items.size(); k++) { - part_styles->at(k)->value = part.styles[k]; + part_styles->at(k)->value = part.styles[k]; } - auto part_decals = part_prop->at(MASS_WEAPON_PART_DECALS); + auto part_decals = part_prop->at(MASS_WEAPON_PART_DECALS); writeDecals(part.decals, part_decals); - auto part_accs = part_prop->at(MASS_WEAPON_PART_ACCESSORIES); + auto part_accs = part_prop->at(MASS_WEAPON_PART_ACCESSORIES); if(!part_accs) { continue; } @@ -322,7 +324,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_CUSTOM_WEAPON_STYLES); + auto custom_styles = weapon_prop->at(MASS_CUSTOM_WEAPON_STYLES); if(!custom_styles) { _lastError = "No custom styles found for weapon."_s; LOG_ERROR(_lastError); @@ -342,9 +344,9 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_ATTACH)->value = weapon.attached; + weapon_prop->at(MASS_WEAPON_ATTACH)->value = weapon.attached; switch(weapon.damageType) { - #define c(enumerator, strenum) case DamageType::enumerator: weapon_prop->at(MASS_WEAPON_DAMAGE_TYPE)->enumValue = strenum; break; + #define c(enumerator, strenum) case Weapon::DamageType::enumerator: weapon_prop->at(MASS_WEAPON_DAMAGE_TYPE)->enumValue = strenum; break; #include "../Maps/DamageTypes.hpp" #undef c default: @@ -352,10 +354,10 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_DUAL_WIELD)->value = weapon.dualWield; + weapon_prop->at(MASS_WEAPON_DUAL_WIELD)->value = weapon.dualWield; switch(weapon.effectColourMode) { - #define c(enumerator, enumstr) case EffectColourMode::enumerator: \ - weapon_prop->at(MASS_WEAPON_COLOUR_EFX_MODE)->enumValue = enumstr; \ + #define c(enumerator, enumstr) case Weapon::EffectColourMode::enumerator: \ + weapon_prop->at(MASS_WEAPON_COLOUR_EFX_MODE)->enumValue = enumstr; \ break; #include "../Maps/EffectColourModes.hpp" #undef c @@ -364,7 +366,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_COLOUR_EFX); + auto effect_colour = weapon_prop->at(MASS_WEAPON_COLOUR_EFX); effect_colour->r = weapon.effectColour.r(); effect_colour->g = weapon.effectColour.g(); effect_colour->b = weapon.effectColour.b(); @@ -378,3 +380,5 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView{other.parts.size()}; @@ -47,3 +50,5 @@ Weapon& Weapon::operator=(const Weapon& other) { return *this; } + +}} diff --git a/src/Mass/Weapon.h b/src/Mass/Weapon.h index 63fc5b1..c8a44a8 100644 --- a/src/Mass/Weapon.h +++ b/src/Mass/Weapon.h @@ -29,19 +29,7 @@ using namespace Corrade; using namespace Magnum; -#define c(enumerator, ...) enumerator, -enum class WeaponType { - #include "../Maps/WeaponTypes.hpp" -}; - -enum class DamageType { - #include "../Maps/DamageTypes.hpp" -}; - -enum class EffectColourMode { - #include "../Maps/EffectColourModes.hpp" -}; -#undef c +namespace mbst { namespace GameObjects { struct Weapon { Weapon() = default; @@ -52,8 +40,20 @@ struct Weapon { Weapon(Weapon&& other) = default; Weapon& operator=(Weapon&& other) = default; + #define c(enumerator, ...) enumerator, + enum class Type { + #include "../Maps/WeaponTypes.hpp" + }; + enum class DamageType { + #include "../Maps/DamageTypes.hpp" + }; + enum class EffectColourMode { + #include "../Maps/EffectColourModes.hpp" + }; + #undef c + Containers::String name; - WeaponType type = WeaponType::Melee; + Type type = Type::Melee; Containers::Array parts; Containers::StaticArray<16, CustomStyle> customStyles{ValueInit}; bool attached = false; @@ -62,3 +62,5 @@ struct Weapon { EffectColourMode effectColourMode = EffectColourMode::Default; Color4 effectColour{0.0f}; }; + +}} diff --git a/src/Mass/WeaponPart.h b/src/Mass/WeaponPart.h index 2afdd0f..2340baf 100644 --- a/src/Mass/WeaponPart.h +++ b/src/Mass/WeaponPart.h @@ -24,6 +24,8 @@ using namespace Corrade; +namespace mbst { namespace GameObjects { + struct WeaponPart { WeaponPart() = default; @@ -61,3 +63,5 @@ struct WeaponPart { Containers::Array decals{}; Containers::Array accessories{}; }; + +}} diff --git a/src/MassManager/MassManager.cpp b/src/MassManager/MassManager.cpp index 9b21197..7753e00 100644 --- a/src/MassManager/MassManager.cpp +++ b/src/MassManager/MassManager.cpp @@ -25,6 +25,8 @@ using namespace Containers::Literals; +namespace mbst { + MassManager::MassManager(Containers::StringView save_path, Containers::StringView account, bool demo, Containers::StringView staging_dir): _saveDirectory{save_path}, _account{account}, _demo{demo}, _stagingAreaDirectory{staging_dir} @@ -33,7 +35,7 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie for(std::uint32_t i = 0; i < _hangars.size(); i++) { mass_filename = Utility::Path::join(_saveDirectory, Utility::format("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account)); - new(&_hangars[i]) Mass{mass_filename}; + new(&_hangars[i]) GameObjects::Mass{mass_filename}; } refreshStagedMasses(); @@ -44,7 +46,7 @@ MassManager::lastError() { return _lastError; } -Mass& +GameObjects::Mass& MassManager::hangar(std::int32_t hangar) { return _hangars[hangar]; } @@ -60,7 +62,7 @@ MassManager::refreshHangar(std::int32_t hangar) { Containers::String mass_filename = Utility::Path::join(_saveDirectory, Utility::format("{}Unit{:.2d}{}.sav", _demo ? "Demo" : "", hangar, _account)); - _hangars[hangar] = Mass{mass_filename}; + _hangars[hangar] = GameObjects::Mass{mass_filename}; } bool @@ -83,7 +85,7 @@ MassManager::importMass(Containers::StringView staged_fn, std::int32_t hangar) { Utility::Path::copy(source, source + ".tmp"_s); { - Mass mass{source + ".tmp"_s}; + GameObjects::Mass mass{source + ".tmp"_s}; if(!mass.updateAccount(_account)) { _lastError = mass.lastError(); Utility::Path::remove(source + ".tmp"_s); @@ -114,7 +116,7 @@ MassManager::exportMass(std::int32_t hangar) { return false; } - if(_hangars[hangar].state() != Mass::State::Valid) { + if(_hangars[hangar].state() != GameObjects::Mass::State::Valid) { _lastError = Utility::format("There is no valid data to export in hangar {:.2d}", hangar + 1); LOG_ERROR(_lastError); return false; @@ -149,22 +151,22 @@ MassManager::moveMass(std::int32_t source, std::int32_t destination) { Containers::String source_file = Utility::Path::join(_saveDirectory, _hangars[source].filename()); Containers::String dest_file = Utility::Path::join(_saveDirectory, _hangars[destination].filename()); - Mass::State dest_state = _hangars[destination].state(); + GameObjects::Mass::State dest_state = _hangars[destination].state(); switch(dest_state) { - case Mass::State::Empty: + case GameObjects::Mass::State::Empty: break; - case Mass::State::Invalid: + case GameObjects::Mass::State::Invalid: Utility::Path::remove(dest_file); break; - case Mass::State::Valid: + case GameObjects::Mass::State::Valid: Utility::Path::move(dest_file, dest_file + ".tmp"_s); break; } Utility::Path::move(source_file, dest_file); - if(dest_state == Mass::State::Valid) { + if(dest_state == GameObjects::Mass::State::Valid) { Utility::Path::move(dest_file + ".tmp"_s, source_file); } @@ -214,7 +216,7 @@ MassManager::refreshStagedMasses() { LOG_INFO("Scanning for staged M.A.S.S.es..."); for(Containers::StringView file : list_view) { - auto name = Mass::getNameFromFile(Utility::Path::join(_stagingAreaDirectory, file)); + auto name = GameObjects::Mass::getNameFromFile(Utility::Path::join(_stagingAreaDirectory, file)); if(name) { LOG_INFO_FORMAT("Found staged M.A.S.S.: {}", *name); @@ -234,7 +236,7 @@ MassManager::refreshStagedMass(Containers::StringView filename) { auto it = _stagedMasses.find(filename); if(file_exists) { - auto name = Mass::getNameFromFile(Utility::Path::join(_stagingAreaDirectory, filename)); + auto name = GameObjects::Mass::getNameFromFile(Utility::Path::join(_stagingAreaDirectory, filename)); if(name) { _stagedMasses[filename] = *name; } @@ -263,3 +265,5 @@ MassManager::deleteStagedMass(Containers::StringView filename) { return true; } + +} diff --git a/src/MassManager/MassManager.h b/src/MassManager/MassManager.h index 8ede9aa..708e42e 100644 --- a/src/MassManager/MassManager.h +++ b/src/MassManager/MassManager.h @@ -26,13 +26,15 @@ using namespace Corrade; +namespace mbst { + class MassManager { public: MassManager(Containers::StringView save_path, Containers::StringView account, bool demo, Containers::StringView staging_dir); - Containers::StringView lastError(); + auto lastError() -> Containers::StringView; - Mass& hangar(int hangar); + auto hangar(int hangar) -> GameObjects::Mass&; void refreshHangar(int hangar); @@ -42,7 +44,7 @@ class MassManager { bool moveMass(int source, int destination); bool deleteMass(int hangar); - std::map const& stagedMasses(); + auto stagedMasses() -> std::map const&; void refreshStagedMasses(); void refreshStagedMass(Containers::StringView filename); bool deleteStagedMass(Containers::StringView filename); @@ -54,9 +56,11 @@ class MassManager { Containers::String _lastError; - Containers::StaticArray<32, Mass> _hangars{NoInit}; + Containers::StaticArray<32, GameObjects::Mass> _hangars{NoInit}; Containers::StringView _stagingAreaDirectory; std::map _stagedMasses; }; + +} diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index a6a9bd2..bc2fb3a 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -21,16 +21,18 @@ #include "PropertyNames.h" #include "../Logger/Logger.h" -#include "../UESaveFile/Types/ArrayProperty.h" -#include "../UESaveFile/Types/ResourceItemValue.h" -#include "../UESaveFile/Types/IntProperty.h" -#include "../UESaveFile/Types/StringProperty.h" +#include "../Gvas/Types/ArrayProperty.h" +#include "../Gvas/Types/ResourceItemValue.h" +#include "../Gvas/Types/IntProperty.h" +#include "../Gvas/Types/StringProperty.h" #include "Profile.h" using namespace Corrade; using namespace Containers::Literals; +namespace mbst { namespace GameObjects { + Profile::Profile(Containers::StringView path): _profile(path) { @@ -45,13 +47,13 @@ Profile::Profile(Containers::StringView path): _filename = Utility::Path::split(path).second(); if(_filename.hasPrefix("Demo"_s)) { - _type = ProfileType::Demo; + _type = Type::Demo; } else { - _type = ProfileType::FullGame; + _type = Type::FullGame; } - auto account_prop = _profile.at(PROFILE_ACCOUNT); + auto account_prop = _profile.at(PROFILE_ACCOUNT); if(!account_prop) { _lastError = "Couldn't find an account ID in "_s + _filename; _valid = false; @@ -77,14 +79,14 @@ Profile::filename() const { return _filename; } -ProfileType +Profile::Type Profile::type() const { return _type; } bool Profile::isDemo() const { - return _type == ProfileType::Demo; + return _type == Type::Demo; } Containers::StringView @@ -107,7 +109,7 @@ Profile::refreshValues() { } LOG_INFO("Getting the company name."); - auto name_prop = _profile.at(PROFILE_NAME); + auto name_prop = _profile.at(PROFILE_NAME); if(!name_prop) { _lastError = "No company name in "_s + _filename; LOG_ERROR(_lastError); @@ -117,49 +119,49 @@ Profile::refreshValues() { _name = name_prop->value; LOG_INFO("Getting the active frame slot."); - auto prop = _profile.at(PROFILE_ACTIVE_FRAME_SLOT); + auto prop = _profile.at(PROFILE_ACTIVE_FRAME_SLOT); _activeFrameSlot = prop ? prop->value : 0; LOG_INFO("Getting the credits."); - prop = _profile.at(PROFILE_CREDITS); + prop = _profile.at(PROFILE_CREDITS); _credits = prop ? prop->value : 0; LOG_INFO("Getting the story progress."); - prop = _profile.at(PROFILE_STORY_PROGRESS); + prop = _profile.at(PROFILE_STORY_PROGRESS); _storyProgress = prop ? prop->value : 0; LOG_INFO("Getting the last mission ID."); - prop = _profile.at(PROFILE_LAST_MISSION_ID); + prop = _profile.at(PROFILE_LAST_MISSION_ID); _lastMissionId = prop ? prop->value : 0; LOG_INFO("Getting the materials."); - _materials[VerseSteel] = getResource(PROFILE_MATERIAL, VerseSteel); - _materials[Undinium] = getResource(PROFILE_MATERIAL, Undinium); - _materials[NecriumAlloy] = getResource(PROFILE_MATERIAL, NecriumAlloy); - _materials[Lunarite] = getResource(PROFILE_MATERIAL, Lunarite); - _materials[Asterite] = getResource(PROFILE_MATERIAL, Asterite); - _materials[HalliteFragma] = getResource(PROFILE_MATERIAL, HalliteFragma); + _materials[GameData::MaterialID::VerseSteel] = getResource(PROFILE_MATERIAL, GameData::MaterialID::VerseSteel); + _materials[GameData::MaterialID::Undinium] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Undinium); + _materials[GameData::MaterialID::NecriumAlloy] = getResource(PROFILE_MATERIAL, GameData::MaterialID::NecriumAlloy); + _materials[GameData::MaterialID::Lunarite] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Lunarite); + _materials[GameData::MaterialID::Asterite] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Asterite); + _materials[GameData::MaterialID::HalliteFragma] = getResource(PROFILE_MATERIAL, GameData::MaterialID::HalliteFragma); - _materials[Ednil] = getResource(PROFILE_MATERIAL, Ednil); - _materials[Nuflalt] = getResource(PROFILE_MATERIAL, Nuflalt); - _materials[Aurelene] = getResource(PROFILE_MATERIAL, Aurelene); - _materials[Soldus] = getResource(PROFILE_MATERIAL, Soldus); - _materials[SynthesisedN] = getResource(PROFILE_MATERIAL, SynthesisedN); - _materials[Nanoc] = getResource(PROFILE_MATERIAL, Nanoc); + _materials[GameData::MaterialID::Ednil] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Ednil); + _materials[GameData::MaterialID::Nuflalt] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Nuflalt); + _materials[GameData::MaterialID::Aurelene] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Aurelene); + _materials[GameData::MaterialID::Soldus] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Soldus); + _materials[GameData::MaterialID::SynthesisedN] = getResource(PROFILE_MATERIAL, GameData::MaterialID::SynthesisedN); + _materials[GameData::MaterialID::Nanoc] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Nanoc); - _materials[Alcarbonite] = getResource(PROFILE_MATERIAL, Alcarbonite); - _materials[Keriphene] = getResource(PROFILE_MATERIAL, Keriphene); - _materials[NitinolCM] = getResource(PROFILE_MATERIAL, NitinolCM); - _materials[Quarkium] = getResource(PROFILE_MATERIAL, Quarkium); - _materials[Alterene] = getResource(PROFILE_MATERIAL, Alterene); - _materials[Cosmium] = getResource(PROFILE_MATERIAL, Cosmium); + _materials[GameData::MaterialID::Alcarbonite] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Alcarbonite); + _materials[GameData::MaterialID::Keriphene] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Keriphene); + _materials[GameData::MaterialID::NitinolCM] = getResource(PROFILE_MATERIAL, GameData::MaterialID::NitinolCM); + _materials[GameData::MaterialID::Quarkium] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Quarkium); + _materials[GameData::MaterialID::Alterene] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Alterene); + _materials[GameData::MaterialID::Cosmium] = getResource(PROFILE_MATERIAL, GameData::MaterialID::Cosmium); - _materials[MixedComposition] = getResource(PROFILE_QUARK_DATA, MixedComposition); - _materials[VoidResidue] = getResource(PROFILE_QUARK_DATA, VoidResidue); - _materials[MuscularConstruction] = getResource(PROFILE_QUARK_DATA, MuscularConstruction); - _materials[MineralExoskeletology] = getResource(PROFILE_QUARK_DATA, MineralExoskeletology); - _materials[CarbonisedSkin] = getResource(PROFILE_QUARK_DATA, CarbonisedSkin); - _materials[IsolatedVoidParticle] = getResource(PROFILE_QUARK_DATA, IsolatedVoidParticle); + _materials[GameData::MaterialID::MixedComposition] = getResource(PROFILE_QUARK_DATA, GameData::MaterialID::MixedComposition); + _materials[GameData::MaterialID::VoidResidue] = getResource(PROFILE_QUARK_DATA, GameData::MaterialID::VoidResidue); + _materials[GameData::MaterialID::MuscularConstruction] = getResource(PROFILE_QUARK_DATA, GameData::MaterialID::MuscularConstruction); + _materials[GameData::MaterialID::MineralExoskeletology] = getResource(PROFILE_QUARK_DATA, GameData::MaterialID::MineralExoskeletology); + _materials[GameData::MaterialID::CarbonisedSkin] = getResource(PROFILE_QUARK_DATA, GameData::MaterialID::CarbonisedSkin); + _materials[GameData::MaterialID::IsolatedVoidParticle] = getResource(PROFILE_QUARK_DATA, GameData::MaterialID::IsolatedVoidParticle); _valid = true; } @@ -171,7 +173,7 @@ Profile::companyName() const { bool Profile::renameCompany(Containers::StringView new_name) { - auto name_prop = _profile.at(PROFILE_NAME); + auto name_prop = _profile.at(PROFILE_NAME); if(!name_prop) { _lastError = "No company name in "_s + _filename; LOG_ERROR(_lastError); @@ -201,13 +203,13 @@ Profile::credits() const { bool Profile::setCredits(std::int32_t amount) { - auto credits_prop = _profile.at(PROFILE_CREDITS); + auto credits_prop = _profile.at(PROFILE_CREDITS); if(!credits_prop) { - credits_prop = new IntProperty; + credits_prop = new Gvas::Types::IntProperty; credits_prop->name.emplace("Credit"_s); credits_prop->valueLength = sizeof(std::int32_t); - _profile.appendProperty(IntProperty::ptr{credits_prop}); + _profile.appendProperty(Gvas::Types::IntProperty::ptr{credits_prop}); } credits_prop->value = amount; @@ -227,13 +229,13 @@ Profile::storyProgress() const { bool Profile::setStoryProgress(std::int32_t progress) { - auto story_progress_prop = _profile.at("StoryProgress"_s); + auto story_progress_prop = _profile.at("StoryProgress"_s); if(!story_progress_prop) { - story_progress_prop = new IntProperty; + story_progress_prop = new Gvas::Types::IntProperty; story_progress_prop->name.emplace("StoryProgress"_s); story_progress_prop->valueLength = sizeof(std::int32_t); - _profile.appendProperty(IntProperty::ptr{story_progress_prop}); + _profile.appendProperty(Gvas::Types::IntProperty::ptr{story_progress_prop}); } story_progress_prop->value = progress; @@ -252,41 +254,41 @@ Profile::lastMissionId() const { } std::int32_t -Profile::material(MaterialID id) const { +Profile::material(GameData::MaterialID id) const { return _materials.at(id); } bool -Profile::setMaterial(MaterialID id, std::int32_t amount) { - Containers::StringView container = id > MixedComposition ? PROFILE_QUARK_DATA : PROFILE_MATERIAL; - auto mats_prop = _profile.at(container); +Profile::setMaterial(GameData::MaterialID id, std::int32_t amount) { + Containers::StringView container = id > GameData::MaterialID::MixedComposition ? PROFILE_QUARK_DATA : PROFILE_MATERIAL; + auto mats_prop = _profile.at(container); if(!mats_prop) { - mats_prop = new ArrayProperty; + mats_prop = new Gvas::Types::ArrayProperty; mats_prop->name.emplace(container); mats_prop->itemType = "StructProperty"; - _profile.appendProperty(ArrayProperty::ptr{mats_prop}); + _profile.appendProperty(Gvas::Types::ArrayProperty::ptr{mats_prop}); } - auto predicate = [&id](UnrealPropertyBase::ptr& prop){ - auto res_prop = dynamic_cast(prop.get()); + auto predicate = [&id](Gvas::Types::UnrealPropertyBase::ptr& prop){ + auto res_prop = dynamic_cast(prop.get()); return res_prop->id == id; }; auto it = std::find_if(mats_prop->items.begin(), mats_prop->items.end(), predicate); - ResourceItemValue* res_prop; + Gvas::Types::ResourceItemValue* res_prop; if(it == mats_prop->items.end()) { - res_prop = new ResourceItemValue; + res_prop = new Gvas::Types::ResourceItemValue; if(mats_prop->items.isEmpty()) { res_prop->name.emplace(container); } res_prop->id = id; - ResourceItemValue::ptr prop{res_prop}; + Gvas::Types::ResourceItemValue::ptr prop{res_prop}; arrayAppend(mats_prop->items, std::move(prop)); } else { - res_prop = dynamic_cast(it->get()); + res_prop = dynamic_cast(it->get()); } res_prop->quantity = amount; @@ -300,18 +302,20 @@ Profile::setMaterial(MaterialID id, std::int32_t amount) { } std::int32_t -Profile::getResource(Containers::StringView container, MaterialID id) { - auto mats_prop = _profile.at(container); +Profile::getResource(Containers::StringView container, GameData::MaterialID id) { + auto mats_prop = _profile.at(container); if(!mats_prop) { return 0; } - auto predicate = [&id](UnrealPropertyBase::ptr& prop){ - auto res_prop = dynamic_cast(prop.get()); + auto predicate = [&id](Gvas::Types::UnrealPropertyBase::ptr& prop){ + auto res_prop = dynamic_cast(prop.get()); return res_prop->id == id; }; auto it = std::find_if(mats_prop->items.begin(), mats_prop->items.end(), predicate); - return it != mats_prop->items.end() ? dynamic_cast(it->get())->quantity : 0; + return it != mats_prop->items.end() ? dynamic_cast(it->get())->quantity : 0; } + +}} diff --git a/src/Profile/Profile.h b/src/Profile/Profile.h index 64b036a..ef299e6 100644 --- a/src/Profile/Profile.h +++ b/src/Profile/Profile.h @@ -21,16 +21,13 @@ #include #include -#include "../UESaveFile/UESaveFile.h" +#include "../Gvas/File.h" #include "ResourceIDs.h" using namespace Corrade; -enum class ProfileType: std::uint8_t { - Demo, - FullGame -}; +namespace mbst { namespace GameObjects { class Profile { public: @@ -42,7 +39,12 @@ class Profile { auto filename() const -> Containers::StringView; - ProfileType type() const; + enum class Type: std::uint8_t { + Demo, + FullGame + }; + + auto type() const -> Type; bool isDemo() const; auto account() const -> Containers::StringView; @@ -52,27 +54,27 @@ class Profile { auto companyName() const -> Containers::StringView; bool renameCompany(Containers::StringView new_name); - std::int32_t activeFrameSlot() const; + auto activeFrameSlot() const -> std::int32_t; - std::int32_t credits() const; + auto credits() const -> std::int32_t; bool setCredits(std::int32_t credits); - std::int32_t storyProgress() const; + auto storyProgress() const -> std::int32_t; bool setStoryProgress(std::int32_t progress); - std::int32_t lastMissionId() const; + auto lastMissionId() const -> std::int32_t; - std::int32_t material(MaterialID id) const; - bool setMaterial(MaterialID id, std::int32_t amount); + auto material(GameData::MaterialID id) const -> std::int32_t; + bool setMaterial(GameData::MaterialID id, std::int32_t amount); private: - std::int32_t getResource(Containers::StringView container, MaterialID id); + auto getResource(Containers::StringView container, GameData::MaterialID id) -> std::int32_t; Containers::String _filename; - ProfileType _type; + Type _type; - UESaveFile _profile; + Gvas::File _profile; Containers::String _name; std::int32_t _activeFrameSlot = 0; @@ -80,10 +82,12 @@ class Profile { std::int32_t _storyProgress = 0; std::int32_t _lastMissionId = 0; - std::map _materials; + std::map _materials; Containers::String _account; bool _valid = false; Containers::String _lastError; }; + +}} diff --git a/src/Profile/ResourceIDs.h b/src/Profile/ResourceIDs.h index b1b2735..37f4b7f 100644 --- a/src/Profile/ResourceIDs.h +++ b/src/Profile/ResourceIDs.h @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +namespace mbst { namespace GameData { + enum MaterialID : std::int32_t { VerseSteel = 0xC3500, Undinium = 0xC3501, @@ -45,3 +47,5 @@ enum MaterialID : std::int32_t { CarbonisedSkin = 0xDBBA4, IsolatedVoidParticle = 0xDBBA5, }; + +}} diff --git a/src/ProfileManager/ProfileManager.cpp b/src/ProfileManager/ProfileManager.cpp index 7919fd8..a42d893 100644 --- a/src/ProfileManager/ProfileManager.cpp +++ b/src/ProfileManager/ProfileManager.cpp @@ -33,6 +33,8 @@ using namespace Containers::Literals; +namespace mbst { + ProfileManager::ProfileManager(Containers::StringView save_dir, Containers::StringView backup_dir): _saveDirectory{save_dir}, _backupsDirectory{backup_dir} @@ -50,7 +52,7 @@ ProfileManager::lastError() { return _lastError; } -Containers::ArrayView +Containers::ArrayView ProfileManager::profiles() { return _profiles; } @@ -59,7 +61,7 @@ bool ProfileManager::refreshProfiles() { LOG_INFO("Refreshing profiles."); - _profiles = Containers::Array{}; + _profiles = Containers::Array{}; using Utility::Path::ListFlag; auto files = Utility::Path::list(_saveDirectory, @@ -78,7 +80,7 @@ ProfileManager::refreshProfiles() { auto files_view = files->exceptSuffix(files->end() - std::remove_if(files->begin(), files->end(), predicate)); for(const auto& file : files_view) { - Profile profile{Utility::Path::join(_saveDirectory, file)}; + GameObjects::Profile profile{Utility::Path::join(_saveDirectory, file)}; if(!profile.valid()) { LOG_WARNING_FORMAT("Profile {} is invalid: {}", file, profile.lastError()); @@ -97,7 +99,7 @@ ProfileManager::refreshProfiles() { return true; } -Profile* +GameObjects::Profile* ProfileManager::getProfile(std::size_t index) { return index <= _profiles.size() ? &(_profiles[index]) : nullptr; } @@ -116,14 +118,15 @@ ProfileManager::deleteProfile(std::size_t index, bool delete_builds) { if(delete_builds) { for(std::uint8_t i = 0; i < 32; ++i) { auto filename = Utility::format("{}Unit{:.2d}{}.sav", - _profiles[index].type() == ProfileType::Demo ? "Demo": "", + _profiles[index].type() == GameObjects::Profile::Type::Demo ? "Demo": "", i, _profiles[index].account()); Utility::Path::remove(Utility::Path::join(_saveDirectory, filename)); } } auto file = _profiles[index].filename(); - auto it = std::remove_if(_profiles.begin(), _profiles.end(), [&file](Profile& profile){ return profile.filename() == file; }); + auto it = std::remove_if(_profiles.begin(), _profiles.end(), + [&file](GameObjects::Profile& profile){ return profile.filename() == file; }); if(it != _profiles.end()) { arrayRemoveSuffix(_profiles, 1); @@ -268,10 +271,10 @@ ProfileManager::refreshBackups() { backup.company = info[0]; if(info[1].hasPrefix("full")) { - backup.type = ProfileType::FullGame; + backup.demo = false; } else if(info[1].hasPrefix("demo")) { - backup.type = ProfileType::Demo; + backup.demo = true; } else { continue; @@ -376,3 +379,5 @@ ProfileManager::restoreBackup(std::size_t index) { return true; } + +} diff --git a/src/ProfileManager/ProfileManager.h b/src/ProfileManager/ProfileManager.h index 5b9db95..c6dff6b 100644 --- a/src/ProfileManager/ProfileManager.h +++ b/src/ProfileManager/ProfileManager.h @@ -27,10 +27,12 @@ using namespace Corrade; +namespace mbst { + struct Backup { Containers::String filename; Containers::String company; - ProfileType type; + bool demo; struct { std::int32_t year; std::int32_t month; @@ -47,16 +49,16 @@ class ProfileManager { explicit ProfileManager(Containers::StringView save_dir, Containers::StringView backup_dir); auto ready() const -> bool; - Containers::StringView lastError(); + auto lastError() -> Containers::StringView; - Containers::ArrayView profiles(); + auto profiles() -> Containers::ArrayView; bool refreshProfiles(); - Profile* getProfile(std::size_t index); + auto getProfile(std::size_t index) -> GameObjects::Profile*; bool deleteProfile(std::size_t index, bool delete_builds); bool backupProfile(std::size_t index, bool backup_builds); - Containers::ArrayView backups(); + auto backups() -> Containers::ArrayView; void refreshBackups(); bool deleteBackup(std::size_t index); @@ -69,6 +71,8 @@ class ProfileManager { Containers::StringView _saveDirectory; Containers::StringView _backupsDirectory; - Containers::Array _profiles; + Containers::Array _profiles; Containers::Array _backups; }; + +} diff --git a/src/ToastQueue/ToastQueue.cpp b/src/ToastQueue/ToastQueue.cpp index 637f87b..19f1ad9 100644 --- a/src/ToastQueue/ToastQueue.cpp +++ b/src/ToastQueue/ToastQueue.cpp @@ -26,6 +26,8 @@ using namespace Containers::Literals; +namespace mbst { + constexpr std::uint32_t success_colour = 0xff67d23bu; constexpr std::uint32_t info_colour = 0xffcc832fu; constexpr std::uint32_t warning_colour = 0xff2fcfc7u; @@ -172,3 +174,5 @@ void ToastQueue::removeToast(std::int64_t index) { _toasts.erase(_toasts.begin() + index); } + +} diff --git a/src/ToastQueue/ToastQueue.h b/src/ToastQueue/ToastQueue.h index 8d2ce40..1d175e7 100644 --- a/src/ToastQueue/ToastQueue.h +++ b/src/ToastQueue/ToastQueue.h @@ -27,6 +27,8 @@ using namespace Corrade; using namespace Magnum; +namespace mbst { + class Toast { public: enum class Type: std::uint8_t { @@ -46,25 +48,25 @@ class Toast { Toast(Toast&& other) = default; Toast& operator=(Toast&& other) = default; - Type type(); + auto type() -> Type; - Containers::StringView message(); + auto message() -> Containers::StringView; - std::chrono::milliseconds timeout(); + auto timeout() -> std::chrono::milliseconds; - std::chrono::steady_clock::time_point creationTime(); + auto creationTime() -> std::chrono::steady_clock::time_point; - std::chrono::milliseconds elapsedTime(); + auto elapsedTime() -> std::chrono::milliseconds; - Phase phase(); + auto phase() -> Phase; - float opacity(); + auto opacity() -> float; private: - Type _type{Type::Default}; - Containers::String _message; - std::chrono::milliseconds _timeout; - std::chrono::steady_clock::time_point _creationTime; + Type _type{Type::Default}; + Containers::String _message; + std::chrono::milliseconds _timeout; + std::chrono::steady_clock::time_point _creationTime; Animation::Track _phaseTrack; }; @@ -82,3 +84,5 @@ class ToastQueue { std::vector _toasts; }; + +} diff --git a/src/UESaveFile/CMakeLists.txt b/src/UESaveFile/CMakeLists.txt deleted file mode 100644 index 7a9c7fa..0000000 --- a/src/UESaveFile/CMakeLists.txt +++ /dev/null @@ -1,98 +0,0 @@ -# MassBuilderSaveTool -# Copyright (C) 2021-2023 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 . - -add_library(UESaveFile STATIC EXCLUDE_FROM_ALL - Serialisers/AbstractUnrealCollectionPropertySerialiser.h - Serialisers/AbstractUnrealPropertySerialiser.h - Serialisers/AbstractUnrealStructSerialiser.h - Serialisers/ArrayPropertySerialiser.h - Serialisers/ArrayPropertySerialiser.cpp - Serialisers/BoolPropertySerialiser.h - Serialisers/BoolPropertySerialiser.cpp - Serialisers/BytePropertySerialiser.h - Serialisers/BytePropertySerialiser.cpp - Serialisers/ColourPropertySerialiser.h - Serialisers/ColourPropertySerialiser.cpp - Serialisers/DateTimePropertySerialiser.h - Serialisers/DateTimePropertySerialiser.cpp - Serialisers/EnumPropertySerialiser.h - Serialisers/EnumPropertySerialiser.cpp - Serialisers/FloatPropertySerialiser.h - Serialisers/FloatPropertySerialiser.cpp - Serialisers/GuidPropertySerialiser.h - Serialisers/GuidPropertySerialiser.cpp - Serialisers/IntPropertySerialiser.h - Serialisers/IntPropertySerialiser.cpp - Serialisers/MapPropertySerialiser.h - Serialisers/MapPropertySerialiser.cpp - Serialisers/ResourcePropertySerialiser.h - Serialisers/ResourcePropertySerialiser.cpp - Serialisers/RotatorPropertySerialiser.h - Serialisers/RotatorPropertySerialiser.cpp - Serialisers/StringPropertySerialiser.h - Serialisers/StringPropertySerialiser.cpp - Serialisers/SetPropertySerialiser.h - Serialisers/SetPropertySerialiser.cpp - Serialisers/StructSerialiser.h - Serialisers/StructSerialiser.cpp - Serialisers/TextPropertySerialiser.h - Serialisers/TextPropertySerialiser.cpp - Serialisers/UnrealPropertySerialiser.h - Serialisers/VectorPropertySerialiser.h - Serialisers/VectorPropertySerialiser.cpp - Serialisers/Vector2DPropertySerialiser.h - Serialisers/Vector2DPropertySerialiser.cpp - - Types/ArrayProperty.h - Types/BoolProperty.h - Types/ByteProperty.h - Types/ColourStructProperty.h - Types/DateTimeStructProperty.h - Types/EnumProperty.h - Types/FloatProperty.h - Types/GenericStructProperty.h - Types/GuidStructProperty.h - Types/IntProperty.h - Types/MapProperty.h - Types/NoneProperty.h - Types/RotatorStructProperty.h - Types/SetProperty.h - Types/StringProperty.h - Types/StructProperty.h - Types/ResourceItemValue.h - Types/TextProperty.h - Types/UnrealProperty.h - Types/UnrealPropertyBase.h - Types/VectorStructProperty.h - - Debug.h - Debug.cpp - UESaveFile.h - UESaveFile.cpp - BinaryReader.h - BinaryReader.cpp - BinaryWriter.h - BinaryWriter.cpp - PropertySerialiser.h - PropertySerialiser.cpp -) - -target_link_libraries(UESaveFile PRIVATE - Corrade::Containers - Corrade::Utility - Magnum::Magnum - Logger -) diff --git a/src/UESaveFile/PropertySerialiser.h b/src/UESaveFile/PropertySerialiser.h deleted file mode 100644 index db89fa9..0000000 --- a/src/UESaveFile/PropertySerialiser.h +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -// MassBuilderSaveTool -// Copyright (C) 2021-2023 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 . - -#include -#include -#include - -#include "Serialisers/AbstractUnrealPropertySerialiser.h" -#include "Serialisers/AbstractUnrealCollectionPropertySerialiser.h" - -#include "Types/UnrealPropertyBase.h" - -using namespace Corrade; - -class BinaryReader; -class BinaryWriter; - -class PropertySerialiser { - public: - static PropertySerialiser& instance(); - - UnrealPropertyBase::ptr read(BinaryReader& reader); - UnrealPropertyBase::ptr readItem(BinaryReader& reader, Containers::String type, std::size_t value_length, - Containers::String name); - Containers::Array readSet(BinaryReader& reader, Containers::StringView item_type, - std::uint32_t count); - UnrealPropertyBase::ptr deserialise(Containers::String name, Containers::String type, std::size_t value_length, - BinaryReader& reader); - - bool serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, std::size_t& bytes_written, - BinaryWriter& writer); - bool write(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer); - bool writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, std::size_t& bytes_written, - BinaryWriter& writer); - bool writeSet(Containers::ArrayView props, Containers::StringView item_type, - std::size_t& bytes_written, BinaryWriter& writer); - - private: - PropertySerialiser(); - - AbstractUnrealPropertySerialiser* getSerialiser(Containers::StringView item_type); - AbstractUnrealCollectionPropertySerialiser* getCollectionSerialiser(Containers::StringView item_type); - - Containers::Array _serialisers; - Containers::Array _collectionSerialisers; -}; diff --git a/src/UESaveFile/Serialisers/StructSerialiser.h b/src/UESaveFile/Serialisers/StructSerialiser.h deleted file mode 100644 index 2644e6c..0000000 --- a/src/UESaveFile/Serialisers/StructSerialiser.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -// MassBuilderSaveTool -// Copyright (C) 2021-2023 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 . - -#include -#include - -#include "AbstractUnrealCollectionPropertySerialiser.h" -#include "AbstractUnrealPropertySerialiser.h" -#include "AbstractUnrealStructSerialiser.h" - -#include "../Types/StructProperty.h" - -class StructSerialiser : public AbstractUnrealPropertySerialiser, public AbstractUnrealCollectionPropertySerialiser { - public: - using ptr = Containers::Pointer; - - StringArrayView types() override; - - PropertyArray deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, - std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser) override; - UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser) override; - - bool serialise(PropertyArrayView props, Containers::StringView item_type, std::size_t& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) override; - bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) override; - - private: - StructProperty::ptr readStructValue(Containers::StringView name, Containers::StringView type, - std::size_t value_length, BinaryReader& reader, - PropertySerialiser& serialiser); - bool writeStructValue(StructProperty* prop, std::size_t& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser); -} ; diff --git a/src/UpdateChecker/UpdateChecker.cpp b/src/UpdateChecker/UpdateChecker.cpp index dd44d5b..e4b3225 100644 --- a/src/UpdateChecker/UpdateChecker.cpp +++ b/src/UpdateChecker/UpdateChecker.cpp @@ -27,6 +27,8 @@ using namespace Corrade; +namespace mbst { + UpdateChecker::UpdateChecker() { LOG_INFO("Initialising update checker."); curl_global_init(CURL_GLOBAL_DEFAULT); @@ -116,3 +118,5 @@ Containers::StringView UpdateChecker::downloadLink() const { return _downloadLink; } + +} diff --git a/src/UpdateChecker/UpdateChecker.h b/src/UpdateChecker/UpdateChecker.h index f460010..2e567d0 100644 --- a/src/UpdateChecker/UpdateChecker.h +++ b/src/UpdateChecker/UpdateChecker.h @@ -18,6 +18,8 @@ #include "../Version/Version.h" +namespace mbst { + class UpdateChecker { public: explicit UpdateChecker(); @@ -47,3 +49,5 @@ class UpdateChecker { Version _foundVersion{}; Containers::String _downloadLink; }; + +} diff --git a/src/Utilities/Crc32.cpp b/src/Utilities/Crc32.cpp new file mode 100644 index 0000000..66b6d8b --- /dev/null +++ b/src/Utilities/Crc32.cpp @@ -0,0 +1,56 @@ +// MassBuilderSaveTool +// Copyright (C) 2021-2023 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 . + +#include "Crc32.h" + +namespace mbst { namespace Crc32 { + +std::uint32_t +update(std::uint32_t initial, Containers::ArrayView data) { + static const auto table = []{ + std::uint32_t polynomial = 0xEDB88320u; + Containers::StaticArray<256, std::uint32_t> temp{ValueInit}; + + for(std::uint32_t i = 0; i < 256; i++) { + std::uint32_t c = i; + + for(std::size_t j = 0; j < 8; j++) { + if(c & 1) { + c = polynomial ^ (c >> 1); + } + else { + c >>= 1; + } + } + + temp[i] = c; + } + + return temp; + }(); + + std::uint32_t c = initial ^ 0xFFFFFFFF; + + auto u = Containers::arrayCast(data); + + for(std::size_t i = 0; i < data.size(); ++i) { + c = table[(c ^ u[i]) & 0xFF] ^ (c >> 8); + } + + return c ^ 0xFFFFFFFF; +} + +}} diff --git a/src/Utilities/Crc32.h b/src/Utilities/Crc32.h index 08e819a..a2f7af9 100644 --- a/src/Utilities/Crc32.h +++ b/src/Utilities/Crc32.h @@ -23,40 +23,8 @@ using namespace Corrade; -namespace Crc32 { +namespace mbst { namespace Utilities { -std::uint32_t update(std::uint32_t initial, Containers::ArrayView data) { - static const auto table = []{ - std::uint32_t polynomial = 0xEDB88320u; - Containers::StaticArray<256, std::uint32_t> temp{ValueInit}; +auto crc32(std::uint32_t initial, Containers::ArrayView data) -> std::uint32_t; - for(std::uint32_t i = 0; i < 256; i++) { - std::uint32_t c = i; - - for(std::size_t j = 0; j < 8; j++) { - if(c & 1) { - c = polynomial ^ (c >> 1); - } - else { - c >>= 1; - } - } - - temp[i] = c; - } - - return temp; - }(); - - std::uint32_t c = initial ^ 0xFFFFFFFF; - - auto u = Containers::arrayCast(data); - - for(std::size_t i = 0; i < data.size(); ++i) { - c = table[(c ^ u[i]) & 0xFF] ^ (c >> 8); - } - - return c ^ 0xFFFFFFFF; -} - -} // Crc32 +}} diff --git a/src/Version/Version.cpp b/src/Version/Version.cpp new file mode 100644 index 0000000..88016f7 --- /dev/null +++ b/src/Version/Version.cpp @@ -0,0 +1,41 @@ +// MassBuilderSaveTool +// Copyright (C) 2021-2023 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 . + +#include "Version.h" + +namespace mbst { + +Version::Version(Containers::StringView str) { + std::size_t start_point = 0; + + if(str[0] == 'v') { + start_point++; + } + + auto components = Containers::StringView{str.data() + start_point}.split('.'); + + major = std::strtol(components[0].data(), nullptr, 10); + minor = std::strtol(components[1].data(), nullptr, 10); + patch = std::strtol(components[2].data(), nullptr, 10); + + fullVersion = major * 10000 + minor * 100 + patch; + + if(str.hasSuffix("-pre")) { + prerelease = true; + } +} + +} diff --git a/src/Version/Version.h b/src/Version/Version.h index fb1ad23..71e2acb 100644 --- a/src/Version/Version.h +++ b/src/Version/Version.h @@ -25,28 +25,12 @@ using namespace Corrade; +namespace mbst { + struct Version { explicit Version() = default; - explicit Version(Containers::StringView str) { - std::size_t start_point = 0; - - if(str[0] == 'v') { - start_point++; - } - - auto components = Containers::StringView{str.data() + start_point}.split('.'); - - major = std::strtol(components[0].data(), nullptr, 10); - minor = std::strtol(components[1].data(), nullptr, 10); - patch = std::strtol(components[2].data(), nullptr, 10); - - fullVersion = major * 10000 + minor * 100 + patch; - - if(str.hasSuffix("-pre")) { - prerelease = true; - } - } + explicit Version(Containers::StringView str); constexpr explicit Version(long major_, long minor_, long patch_, bool prerelease_): major{major_}, minor{minor_}, patch{patch_}, prerelease{prerelease_}, @@ -55,17 +39,17 @@ struct Version { //ctor } - long major = 0; - long minor = 0; - long patch = 0; - bool prerelease = false; + long major = 0; + long minor = 0; + long patch = 0; + bool prerelease = false; long fullVersion = 0; - bool operator==(const Version& other) const { + inline bool operator==(const Version& other) const { return fullVersion == other.fullVersion && prerelease == other.prerelease; } - bool operator>(const Version& other) const { + inline bool operator>(const Version& other) const { if((fullVersion > other.fullVersion) || (fullVersion == other.fullVersion && !prerelease && other.prerelease)) { @@ -87,3 +71,5 @@ constexpr Version current_version{ SAVETOOL_VERSION_PATCH, SAVETOOL_VERSION_PRERELEASE }; + +} diff --git a/src/main.cpp b/src/main.cpp index dc6dc87..85eb88e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,7 +24,7 @@ #include "Configuration/Configuration.h" #include "Logger/MagnumLogBuffer.h" -#include "SaveTool/SaveTool.h" +#include "Application/Application.h" int main(int argc, char** argv) { MagnumLogBuffer debug_intercept_buffer{EntryType::Info}; @@ -54,7 +54,7 @@ int main(int argc, char** argv) { if(locale.hasSuffix(".65001")) { LOG_INFO("Wine detected."); - conf().setRunningInWine(true); + mbst::conf().setRunningInWine(true); } } @@ -86,7 +86,7 @@ int main(int argc, char** argv) { LOG_INFO_FORMAT("Processor: {}", Containers::arrayCast(brand).data()); } - SaveTool app({argc, argv}); + mbst::Application app({argc, argv}); int result = app.exec(); ReleaseMutex(mutex_handle);