#pragma once // MassBuilderSaveTool // Copyright (C) 2021-2022 Guillaume Jacquemin // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #include #include #include #include #include #include #include #include "Types/UnrealPropertyBase.h" #include "PropertySerialiser.h" using namespace Corrade; using namespace Magnum; class UESaveFile { public: explicit UESaveFile(Containers::String filepath); auto valid() const -> bool; auto lastError() const -> Containers::StringView; auto reloadData() -> bool; auto saveType() -> Containers::StringView; template std::enable_if_t::value, T*> at(Containers::StringView name) { for(auto& prop : _properties) { if(prop->name == name) { return static_cast(prop.get()); } } return nullptr; } void appendProperty(UnrealPropertyBase::ptr prop); auto props() -> Containers::ArrayView; auto saveToFile() -> bool; private: void loadData(); bool _valid{false}; Containers::String _lastError; Containers::String _filepath; bool _noReloadAfterSave = false; Containers::StaticArray<4, char> _magicBytes{'G', 'V', 'A', 'S'}; UnsignedInt _saveVersion = 0; UnsignedInt _packageVersion = 0; struct { UnsignedShort major = 0; UnsignedShort minor = 0; UnsignedShort patch = 0; UnsignedInt build = 0; Containers::String buildId; } _engineVersion; UnsignedInt _customFormatVersion = 0; struct CustomFormatDataEntry { Containers::StaticArray<16, char> id; Int value = 0; }; Containers::Array _customFormatData; Containers::String _saveType; Containers::Array _properties; Containers::Reference _propSerialiser; };