82 lines
2.3 KiB
C
82 lines
2.3 KiB
C
|
#pragma once
|
||
|
|
||
|
// MassBuilderSaveTool
|
||
|
// Copyright (C) 2021 Guillaume Jacquemin
|
||
|
//
|
||
|
// This program is free software: you can redistribute it and/or modify
|
||
|
// it under the terms of the GNU General Public License as published by
|
||
|
// the Free Software Foundation, either version 3 of the License, or
|
||
|
// (at your option) any later version.
|
||
|
//
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
|
||
|
#include <string>
|
||
|
|
||
|
#include <Corrade/Containers/Array.h>
|
||
|
#include <Corrade/Containers/GrowableArray.h>
|
||
|
#include <Corrade/Containers/StaticArray.h>
|
||
|
|
||
|
#include <Magnum/Magnum.h>
|
||
|
|
||
|
#include "Types/UnrealPropertyBase.h"
|
||
|
|
||
|
#include "PropertySerialiser.h"
|
||
|
|
||
|
using namespace Corrade;
|
||
|
using namespace Magnum;
|
||
|
|
||
|
class UESaveFile {
|
||
|
public:
|
||
|
explicit UESaveFile(std::string filepath);
|
||
|
|
||
|
auto valid() const -> bool;
|
||
|
auto lastError() const -> std::string const&;
|
||
|
|
||
|
auto reloadData() -> bool;
|
||
|
|
||
|
auto at(const std::string& name) -> UnrealPropertyBase*;
|
||
|
|
||
|
auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr>;
|
||
|
|
||
|
auto saveToFile() -> bool;
|
||
|
|
||
|
private:
|
||
|
void loadData();
|
||
|
|
||
|
bool _valid{false};
|
||
|
std::string _lastError;
|
||
|
|
||
|
std::string _filepath;
|
||
|
|
||
|
const 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;
|
||
|
std::string buildId;
|
||
|
} _engineVersion;
|
||
|
|
||
|
UnsignedInt _customFormatVersion = 0;
|
||
|
struct CustomFormatDataEntry {
|
||
|
Containers::StaticArray<16, char> id;
|
||
|
Int value = 0;
|
||
|
};
|
||
|
Containers::Array<CustomFormatDataEntry> _customFormatData;
|
||
|
|
||
|
std::string _saveType;
|
||
|
|
||
|
Containers::Array<UnrealPropertyBase::ptr> _properties;
|
||
|
|
||
|
PropertySerialiser _propSerialiser;
|
||
|
};
|