Compare commits
No commits in common. "953a2a9c8bef3ad4d8d753c68b7a33f228a557cf" and "8668c59858c75fc85806babc6b7f33c816d50bfe" have entirely different histories.
953a2a9c8b
...
8668c59858
82 changed files with 715 additions and 1111 deletions
|
@ -1,19 +1,3 @@
|
|||
// MassBuilderSaveTool
|
||||
// Copyright (C) 2021-2022 Guillaume Jacquemin
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <Corrade/Containers/Optional.h>
|
||||
#include <Corrade/Containers/Pair.h>
|
||||
#include <Corrade/Utility/Path.h>
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
// MassBuilderSaveTool
|
||||
// Copyright (C) 2021-2022 Guillaume Jacquemin
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <Corrade/Utility/Configuration.h>
|
||||
|
||||
using namespace Corrade;
|
||||
|
|
|
@ -49,7 +49,7 @@ class Logger {
|
|||
Logger(Logger&&) = delete;
|
||||
Logger& operator=(Logger&&) = delete;
|
||||
|
||||
static Logger& instance();
|
||||
static auto instance() -> Logger&;
|
||||
|
||||
void initialise();
|
||||
|
||||
|
@ -73,7 +73,7 @@ class Logger {
|
|||
std::mutex _logMutex{};
|
||||
};
|
||||
|
||||
Logger& logger();
|
||||
auto logger() -> Logger&;
|
||||
|
||||
#define LOG(entry_type, message) logger().lockMutex(); \
|
||||
logger().log(EntryType::entry_type, \
|
||||
|
|
|
@ -16,12 +16,7 @@
|
|||
|
||||
#include "MagnumLogBuffer.h"
|
||||
|
||||
MagnumLogBuffer::MagnumLogBuffer(EntryType type):
|
||||
std::stringbuf(std::ios_base::out),
|
||||
_type{type}
|
||||
{
|
||||
//ctor
|
||||
}
|
||||
MagnumLogBuffer::MagnumLogBuffer(EntryType type): std::stringbuf(std::ios_base::out), _type{type} {}
|
||||
|
||||
MagnumLogBuffer::~MagnumLogBuffer() = default;
|
||||
|
||||
|
|
|
@ -42,13 +42,11 @@ Mass::Mass(Containers::StringView path) {
|
|||
refreshValues();
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
Mass::lastError() {
|
||||
auto Mass::lastError() -> Containers::StringView {
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
Containers::Optional<Containers::String>
|
||||
Mass::getNameFromFile(Containers::StringView path) {
|
||||
auto Mass::getNameFromFile(Containers::StringView path) -> Containers::Optional<Containers::String> {
|
||||
if(!Utility::Path::exists(path)) {
|
||||
LOG_ERROR_FORMAT("{} couldn't be found.", path);
|
||||
return Containers::NullOpt;
|
||||
|
@ -78,8 +76,7 @@ Mass::getNameFromFile(Containers::StringView path) {
|
|||
return {name_prop->value};
|
||||
}
|
||||
|
||||
void
|
||||
Mass::refreshValues() {
|
||||
void Mass::refreshValues() {
|
||||
LOG_INFO_FORMAT("Refreshing values for {}.", _filename);
|
||||
|
||||
logger().lockMutex();
|
||||
|
@ -232,19 +229,16 @@ Mass::refreshValues() {
|
|||
_state = State::Valid;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
Mass::filename() {
|
||||
auto Mass::filename() -> Containers::StringView {
|
||||
return _filename;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
Mass::name() {
|
||||
auto Mass::name() -> Containers::StringView {
|
||||
CORRADE_INTERNAL_ASSERT(_name);
|
||||
return *_name;
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::setName(Containers::StringView new_name) {
|
||||
auto Mass::setName(Containers::StringView new_name) -> bool {
|
||||
_name = {new_name};
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>("UnitData"_s);
|
||||
|
@ -273,22 +267,19 @@ Mass::setName(Containers::StringView new_name) {
|
|||
return true;
|
||||
}
|
||||
|
||||
Mass::State
|
||||
Mass::state() {
|
||||
auto Mass::state() -> State {
|
||||
return _state;
|
||||
}
|
||||
|
||||
bool Mass::dirty() const {
|
||||
auto Mass::dirty() const -> bool {
|
||||
return _dirty;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::setDirty(bool dirty) {
|
||||
void Mass::setDirty(bool dirty) {
|
||||
_dirty = dirty;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getTuning() {
|
||||
void Mass::getTuning() {
|
||||
getTuningCategory(MASS_ENGINE, _tuning.engineId,
|
||||
MASS_GEARS, _tuning.gearIds);
|
||||
if(_state == State::Invalid) {
|
||||
|
@ -308,43 +299,35 @@ Mass::getTuning() {
|
|||
}
|
||||
}
|
||||
|
||||
Int&
|
||||
Mass::engine() {
|
||||
auto Mass::engine() -> Int& {
|
||||
return _tuning.engineId;
|
||||
}
|
||||
|
||||
Containers::ArrayView<Int>
|
||||
Mass::gears() {
|
||||
auto Mass::gears() -> Containers::ArrayView<Int> {
|
||||
return _tuning.gearIds;
|
||||
}
|
||||
|
||||
Int&
|
||||
Mass::os() {
|
||||
auto Mass::os() -> Int& {
|
||||
return _tuning.osId;
|
||||
}
|
||||
|
||||
Containers::ArrayView<Int>
|
||||
Mass::modules() {
|
||||
auto Mass::modules() -> Containers::ArrayView<Int> {
|
||||
return _tuning.moduleIds;
|
||||
}
|
||||
|
||||
Int&
|
||||
Mass::architecture() {
|
||||
auto Mass::architecture() -> Int& {
|
||||
return _tuning.archId;
|
||||
}
|
||||
|
||||
Containers::ArrayView<Int>
|
||||
Mass::techs() {
|
||||
auto Mass::techs() -> Containers::ArrayView<Int> {
|
||||
return _tuning.techIds;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
Mass::account() {
|
||||
auto Mass::account() -> Containers::StringView {
|
||||
return _account;
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::updateAccount(Containers::StringView new_account) {
|
||||
auto Mass::updateAccount(Containers::StringView new_account) -> bool {
|
||||
_account = new_account;
|
||||
|
||||
auto account = _mass->at<StringProperty>(MASS_ACCOUNT);
|
||||
|
@ -364,8 +347,7 @@ Mass::updateAccount(Containers::StringView new_account) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id,
|
||||
void Mass::getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id,
|
||||
Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids)
|
||||
{
|
||||
LOG_INFO_FORMAT("Getting tuning data ({}, {}).", big_node_prop_name, small_nodes_prop_name);
|
||||
|
|
100
src/Mass/Mass.h
100
src/Mass/Mass.h
|
@ -45,6 +45,10 @@ struct ArrayProperty;
|
|||
|
||||
class Mass {
|
||||
public:
|
||||
enum class State : UnsignedByte {
|
||||
Empty, Invalid, Valid
|
||||
};
|
||||
|
||||
explicit Mass(Containers::StringView path);
|
||||
|
||||
Mass(const Mass&) = delete;
|
||||
|
@ -53,100 +57,96 @@ class Mass {
|
|||
Mass(Mass&&) = default;
|
||||
Mass& operator=(Mass&&) = default;
|
||||
|
||||
Containers::StringView lastError();
|
||||
auto lastError() -> Containers::StringView;
|
||||
|
||||
static Containers::Optional<Containers::String> getNameFromFile(Containers::StringView path);
|
||||
static auto getNameFromFile(Containers::StringView path) -> Containers::Optional<Containers::String>;
|
||||
|
||||
void refreshValues();
|
||||
|
||||
Containers::StringView filename();
|
||||
auto filename() -> Containers::StringView;
|
||||
|
||||
Containers::StringView name();
|
||||
bool setName(Containers::StringView new_name);
|
||||
auto name() -> Containers::StringView;
|
||||
auto setName(Containers::StringView new_name) -> bool;
|
||||
|
||||
enum class State : UnsignedByte {
|
||||
Empty, Invalid, Valid
|
||||
};
|
||||
auto state() -> State;
|
||||
|
||||
State state();
|
||||
|
||||
bool dirty() const;
|
||||
auto dirty() const -> bool;
|
||||
void setDirty(bool dirty = true);
|
||||
|
||||
Joints& jointSliders();
|
||||
auto jointSliders() -> Joints&;
|
||||
void getJointSliders();
|
||||
bool writeJointSliders();
|
||||
auto writeJointSliders() -> bool;
|
||||
|
||||
Containers::ArrayView<Int> frameStyles();
|
||||
auto frameStyles() -> Containers::ArrayView<Int>;
|
||||
void getFrameStyles();
|
||||
bool writeFrameStyles();
|
||||
auto writeFrameStyles() -> bool;
|
||||
|
||||
Color4& eyeFlareColour();
|
||||
auto eyeFlareColour() -> Color4&;
|
||||
void getEyeFlareColour();
|
||||
bool writeEyeFlareColour();
|
||||
auto writeEyeFlareColour() -> bool;
|
||||
|
||||
Containers::ArrayView<CustomStyle> frameCustomStyles();
|
||||
auto frameCustomStyles() -> Containers::ArrayView<CustomStyle>;
|
||||
void getFrameCustomStyles();
|
||||
bool writeFrameCustomStyle(UnsignedLong index);
|
||||
auto writeFrameCustomStyle(UnsignedLong index) -> bool;
|
||||
|
||||
Containers::ArrayView<ArmourPart> armourParts();
|
||||
auto armourParts() -> Containers::ArrayView<ArmourPart>;
|
||||
void getArmourParts();
|
||||
bool writeArmourPart(ArmourSlot slot);
|
||||
auto writeArmourPart(ArmourSlot slot) -> bool;
|
||||
|
||||
BulletLauncherAttachmentStyle& bulletLauncherAttachmentStyle();
|
||||
Containers::ArrayView<BulletLauncherAttachment> bulletLauncherAttachments();
|
||||
auto bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle&;
|
||||
auto bulletLauncherAttachments() -> Containers::ArrayView<BulletLauncherAttachment>;
|
||||
void getBulletLauncherAttachments();
|
||||
bool writeBulletLauncherAttachments();
|
||||
auto writeBulletLauncherAttachments() -> bool;
|
||||
|
||||
Containers::ArrayView<CustomStyle> armourCustomStyles();
|
||||
auto armourCustomStyles() -> Containers::ArrayView<CustomStyle>;
|
||||
void getArmourCustomStyles();
|
||||
bool writeArmourCustomStyle(UnsignedLong index);
|
||||
auto writeArmourCustomStyle(UnsignedLong index) -> bool;
|
||||
|
||||
Containers::ArrayView<Weapon> meleeWeapons();
|
||||
auto meleeWeapons() -> Containers::ArrayView<Weapon>;
|
||||
void getMeleeWeapons();
|
||||
bool writeMeleeWeapons();
|
||||
auto writeMeleeWeapons() -> bool;
|
||||
|
||||
Containers::ArrayView<Weapon> shields();
|
||||
auto shields() -> Containers::ArrayView<Weapon>;
|
||||
void getShields();
|
||||
bool writeShields();
|
||||
auto writeShields() -> bool;
|
||||
|
||||
Containers::ArrayView<Weapon> bulletShooters();
|
||||
auto bulletShooters() -> Containers::ArrayView<Weapon>;
|
||||
void getBulletShooters();
|
||||
bool writeBulletShooters();
|
||||
auto writeBulletShooters() -> bool;
|
||||
|
||||
Containers::ArrayView<Weapon> energyShooters();
|
||||
auto energyShooters() -> Containers::ArrayView<Weapon>;
|
||||
void getEnergyShooters();
|
||||
bool writeEnergyShooters();
|
||||
auto writeEnergyShooters() -> bool;
|
||||
|
||||
Containers::ArrayView<Weapon> bulletLaunchers();
|
||||
auto bulletLaunchers() -> Containers::ArrayView<Weapon>;
|
||||
void getBulletLaunchers();
|
||||
bool writeBulletLaunchers();
|
||||
auto writeBulletLaunchers() -> bool;
|
||||
|
||||
Containers::ArrayView<Weapon> energyLaunchers();
|
||||
auto energyLaunchers() -> Containers::ArrayView<Weapon>;
|
||||
void getEnergyLaunchers();
|
||||
bool writeEnergyLaunchers();
|
||||
auto writeEnergyLaunchers() -> bool;
|
||||
|
||||
Containers::ArrayView<CustomStyle> globalStyles();
|
||||
auto globalStyles() -> Containers::ArrayView<CustomStyle>;
|
||||
void getGlobalStyles();
|
||||
bool writeGlobalStyle(UnsignedLong index);
|
||||
auto writeGlobalStyle(UnsignedLong index) -> bool;
|
||||
|
||||
void getTuning();
|
||||
|
||||
Int& engine();
|
||||
Containers::ArrayView<Int> gears();
|
||||
auto engine() -> Int&;
|
||||
auto gears() -> Containers::ArrayView<Int>;
|
||||
|
||||
Int& os();
|
||||
Containers::ArrayView<Int> modules();
|
||||
auto os() -> Int&;
|
||||
auto modules() -> Containers::ArrayView<Int>;
|
||||
|
||||
Int& architecture();
|
||||
Containers::ArrayView<Int> techs();
|
||||
auto architecture() -> Int&;
|
||||
auto techs() -> Containers::ArrayView<Int>;
|
||||
|
||||
Containers::StringView account();
|
||||
bool updateAccount(Containers::StringView new_account);
|
||||
auto account() -> Containers::StringView;
|
||||
auto updateAccount(Containers::StringView new_account) -> bool;
|
||||
|
||||
private:
|
||||
void getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array);
|
||||
bool writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array);
|
||||
auto writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool;
|
||||
|
||||
void getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
|
||||
void writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
|
||||
|
@ -155,7 +155,7 @@ class Mass {
|
|||
void writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array);
|
||||
|
||||
void getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array);
|
||||
bool writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array);
|
||||
auto writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) -> bool;
|
||||
|
||||
void getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id,
|
||||
Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids);
|
||||
|
|
|
@ -29,13 +29,11 @@
|
|||
|
||||
using namespace Containers::Literals;
|
||||
|
||||
Containers::ArrayView<ArmourPart>
|
||||
Mass::armourParts() {
|
||||
auto Mass::armourParts() -> Containers::ArrayView<ArmourPart> {
|
||||
return _armour.parts;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getArmourParts() {
|
||||
void Mass::getArmourParts() {
|
||||
LOG_INFO("Getting armour parts.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -119,8 +117,7 @@ Mass::getArmourParts() {
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeArmourPart(ArmourSlot slot) {
|
||||
auto Mass::writeArmourPart(ArmourSlot slot) -> bool {
|
||||
LOG_INFO_FORMAT("Writing armour part in slot {}.", static_cast<int>(slot));
|
||||
|
||||
auto& part = *std::find_if(_armour.parts.begin(), _armour.parts.end(), [&slot](const ArmourPart& part){ return slot == part.slot; });
|
||||
|
@ -198,18 +195,15 @@ Mass::writeArmourPart(ArmourSlot slot) {
|
|||
return true;
|
||||
}
|
||||
|
||||
BulletLauncherAttachmentStyle&
|
||||
Mass::bulletLauncherAttachmentStyle() {
|
||||
auto Mass::bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle& {
|
||||
return _armour.blAttachmentStyle;
|
||||
}
|
||||
|
||||
Containers::ArrayView<BulletLauncherAttachment>
|
||||
Mass::bulletLauncherAttachments() {
|
||||
auto Mass::bulletLauncherAttachments() -> Containers::ArrayView<BulletLauncherAttachment> {
|
||||
return _armour.blAttachment;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getBulletLauncherAttachments() {
|
||||
void Mass::getBulletLauncherAttachments() {
|
||||
LOG_INFO("Getting the bullet launcher attachment data.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -280,8 +274,7 @@ Mass::getBulletLauncherAttachments() {
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeBulletLauncherAttachments() {
|
||||
auto Mass::writeBulletLauncherAttachments() -> bool {
|
||||
LOG_INFO("Writing bullet launcher attachments.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -380,13 +373,11 @@ Mass::writeBulletLauncherAttachments() {
|
|||
return true;
|
||||
}
|
||||
|
||||
Containers::ArrayView<CustomStyle>
|
||||
Mass::armourCustomStyles() {
|
||||
auto Mass::armourCustomStyles() -> Containers::ArrayView<CustomStyle> {
|
||||
return _armour.customStyles;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getArmourCustomStyles() {
|
||||
void Mass::getArmourCustomStyles() {
|
||||
LOG_INFO("Getting the custom armour styles.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -413,8 +404,7 @@ Mass::getArmourCustomStyles() {
|
|||
getCustomStyles(_armour.customStyles, armour_styles);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeArmourCustomStyle(UnsignedLong index) {
|
||||
auto Mass::writeArmourCustomStyle(UnsignedLong index) -> bool {
|
||||
LOG_INFO_FORMAT("Writing custom armour style {}.", index);
|
||||
|
||||
if(index > _armour.customStyles.size()) {
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
|
||||
using namespace Containers::Literals;
|
||||
|
||||
void
|
||||
Mass::getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) {
|
||||
void Mass::getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) {
|
||||
for(UnsignedInt i = 0; i < decal_array->items.size(); i++) {
|
||||
auto decal_prop = decal_array->at<GenericStructProperty>(i);
|
||||
CORRADE_INTERNAL_ASSERT(decal_prop);
|
||||
|
@ -54,8 +53,7 @@ Mass::getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Mass::writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) {
|
||||
void Mass::writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) {
|
||||
for(UnsignedInt i = 0; i < decal_array->items.size(); i++) {
|
||||
auto decal_prop = decal_array->at<GenericStructProperty>(i);
|
||||
CORRADE_INTERNAL_ASSERT(decal_prop);
|
||||
|
@ -89,8 +87,7 @@ Mass::writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_arra
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accessory_array) {
|
||||
void Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accessory_array) {
|
||||
for(UnsignedInt i = 0; i < accessory_array->items.size(); i++) {
|
||||
auto acc_prop = accessory_array->at<GenericStructProperty>(i);
|
||||
CORRADE_INTERNAL_ASSERT(acc_prop);
|
||||
|
@ -115,8 +112,7 @@ Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Mass::writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array) {
|
||||
void Mass::writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array) {
|
||||
for(UnsignedInt i = 0; i < accs_array->items.size(); i++) {
|
||||
auto acc_prop = accs_array->at<GenericStructProperty>(i);
|
||||
CORRADE_INTERNAL_ASSERT(acc_prop);
|
||||
|
|
|
@ -26,13 +26,11 @@
|
|||
|
||||
using namespace Containers::Literals;
|
||||
|
||||
Joints&
|
||||
Mass::jointSliders() {
|
||||
auto Mass::jointSliders() -> Joints& {
|
||||
return _frame.joints;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getJointSliders() {
|
||||
void Mass::getJointSliders() {
|
||||
LOG_INFO("Getting joint sliders.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -67,8 +65,7 @@ Mass::getJointSliders() {
|
|||
_frame.joints.lowerLegs = (length ? length->value : 0.0f);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeJointSliders() {
|
||||
auto Mass::writeJointSliders() -> bool {
|
||||
LOG_INFO("Writing joint sliders");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -184,13 +181,11 @@ Mass::writeJointSliders() {
|
|||
return true;
|
||||
}
|
||||
|
||||
Containers::ArrayView<Int>
|
||||
Mass::frameStyles() {
|
||||
auto Mass::frameStyles() -> Containers::ArrayView<Int> {
|
||||
return _frame.styles;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getFrameStyles() {
|
||||
void Mass::getFrameStyles() {
|
||||
LOG_INFO("Getting frame styles.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -226,8 +221,7 @@ Mass::getFrameStyles() {
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeFrameStyles() {
|
||||
auto Mass::writeFrameStyles() -> bool {
|
||||
LOG_INFO("Writing frame styles.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -266,13 +260,11 @@ Mass::writeFrameStyles() {
|
|||
return true;
|
||||
}
|
||||
|
||||
Color4&
|
||||
Mass::eyeFlareColour() {
|
||||
auto Mass::eyeFlareColour() -> Color4& {
|
||||
return _frame.eyeFlare;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getEyeFlareColour() {
|
||||
void Mass::getEyeFlareColour() {
|
||||
LOG_INFO("Getting the eye flare colour.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -299,8 +291,7 @@ Mass::getEyeFlareColour() {
|
|||
_frame.eyeFlare = Color4{eye_flare_prop->r, eye_flare_prop->g, eye_flare_prop->b, eye_flare_prop->a};
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeEyeFlareColour() {
|
||||
auto Mass::writeEyeFlareColour() -> bool {
|
||||
LOG_INFO("Writing the eye flare colour.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -340,13 +331,11 @@ Mass::writeEyeFlareColour() {
|
|||
return true;
|
||||
}
|
||||
|
||||
Containers::ArrayView<CustomStyle>
|
||||
Mass::frameCustomStyles() {
|
||||
auto Mass::frameCustomStyles() -> Containers::ArrayView<CustomStyle> {
|
||||
return _frame.customStyles;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getFrameCustomStyles() {
|
||||
void Mass::getFrameCustomStyles() {
|
||||
LOG_INFO("Getting the frame's custom styles.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -373,8 +362,7 @@ Mass::getFrameCustomStyles() {
|
|||
getCustomStyles(_frame.customStyles, frame_styles);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeFrameCustomStyle(UnsignedLong index) {
|
||||
auto Mass::writeFrameCustomStyle(UnsignedLong index) -> bool {
|
||||
LOG_INFO_FORMAT("Writing frame custom style number {}.", index);
|
||||
|
||||
if(index > _frame.customStyles.size()) {
|
||||
|
|
|
@ -27,13 +27,11 @@
|
|||
|
||||
using namespace Containers::Literals;
|
||||
|
||||
Containers::ArrayView<CustomStyle>
|
||||
Mass::globalStyles() {
|
||||
auto Mass::globalStyles() -> Containers::ArrayView<CustomStyle> {
|
||||
return _globalStyles;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getGlobalStyles() {
|
||||
void Mass::getGlobalStyles() {
|
||||
LOG_INFO("Getting global styles.");
|
||||
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
|
@ -57,8 +55,7 @@ Mass::getGlobalStyles() {
|
|||
getCustomStyles(_globalStyles, global_styles);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeGlobalStyle(UnsignedLong index) {
|
||||
auto Mass::writeGlobalStyle(UnsignedLong index) -> bool {
|
||||
LOG_INFO_FORMAT("Writing global style number {}.", index);
|
||||
|
||||
if(index > _globalStyles.size()) {
|
||||
|
@ -86,8 +83,7 @@ Mass::writeGlobalStyle(UnsignedLong index) {
|
|||
return writeCustomStyle(_globalStyles[index], index, global_styles);
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array) {
|
||||
void Mass::getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array) {
|
||||
for(UnsignedInt i = 0; i < style_array->items.size(); i++) {
|
||||
auto style_prop = style_array->at<GenericStructProperty>(i);
|
||||
auto& style = styles[i];
|
||||
|
@ -110,8 +106,7 @@ Mass::getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty*
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) {
|
||||
auto Mass::writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool {
|
||||
if(!style_array) {
|
||||
_lastError = "style_array is null."_s;
|
||||
LOG_ERROR(_lastError);
|
||||
|
|
|
@ -28,110 +28,91 @@
|
|||
|
||||
using namespace Containers::Literals;
|
||||
|
||||
Containers::ArrayView<Weapon>
|
||||
Mass::meleeWeapons() {
|
||||
auto Mass::meleeWeapons() -> Containers::ArrayView<Weapon> {
|
||||
return _weapons.melee;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getMeleeWeapons() {
|
||||
void Mass::getMeleeWeapons() {
|
||||
LOG_INFO("Getting melee weapons.");
|
||||
getWeaponType(MASS_WEAPONS_MELEE, _weapons.melee);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeMeleeWeapons() {
|
||||
auto Mass::writeMeleeWeapons() -> bool {
|
||||
LOG_INFO("Writing melee weapons.");
|
||||
return writeWeaponType(MASS_WEAPONS_MELEE, _weapons.melee);
|
||||
}
|
||||
|
||||
Containers::ArrayView<Weapon>
|
||||
Mass::shields() {
|
||||
auto Mass::shields() -> Containers::ArrayView<Weapon> {
|
||||
return _weapons.shields;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getShields() {
|
||||
void Mass::getShields() {
|
||||
LOG_INFO("Getting shields.");
|
||||
getWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeShields() {
|
||||
auto Mass::writeShields() -> bool {
|
||||
LOG_INFO("Writing shields.");
|
||||
return writeWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields);
|
||||
}
|
||||
|
||||
Containers::ArrayView<Weapon>
|
||||
Mass::bulletShooters() {
|
||||
auto Mass::bulletShooters() -> Containers::ArrayView<Weapon> {
|
||||
return _weapons.bulletShooters;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getBulletShooters() {
|
||||
void Mass::getBulletShooters() {
|
||||
LOG_INFO("Getting bullet shooters.");
|
||||
getWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeBulletShooters() {
|
||||
auto Mass::writeBulletShooters() -> bool {
|
||||
LOG_INFO("Writing bullet shooters.");
|
||||
return writeWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters);
|
||||
}
|
||||
|
||||
Containers::ArrayView<Weapon>
|
||||
Mass::energyShooters() {
|
||||
auto Mass::energyShooters() -> Containers::ArrayView<Weapon> {
|
||||
return _weapons.energyShooters;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getEnergyShooters() {
|
||||
void Mass::getEnergyShooters() {
|
||||
LOG_INFO("Getting energy shooters.");
|
||||
getWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeEnergyShooters() {
|
||||
auto Mass::writeEnergyShooters() -> bool {
|
||||
LOG_INFO("Writing energy shooters.");
|
||||
return writeWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters);
|
||||
}
|
||||
|
||||
Containers::ArrayView<Weapon>
|
||||
Mass::bulletLaunchers() {
|
||||
auto Mass::bulletLaunchers() -> Containers::ArrayView<Weapon> {
|
||||
return _weapons.bulletLaunchers;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getBulletLaunchers() {
|
||||
void Mass::getBulletLaunchers() {
|
||||
LOG_INFO("Getting bullet launchers.");
|
||||
getWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeBulletLaunchers() {
|
||||
auto Mass::writeBulletLaunchers() -> bool {
|
||||
LOG_INFO("Writing bullet launchers.");
|
||||
return writeWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers);
|
||||
}
|
||||
|
||||
Containers::ArrayView<Weapon>
|
||||
Mass::energyLaunchers() {
|
||||
auto Mass::energyLaunchers() -> Containers::ArrayView<Weapon> {
|
||||
return _weapons.energyLaunchers;
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getEnergyLaunchers() {
|
||||
void Mass::getEnergyLaunchers() {
|
||||
LOG_INFO("Getting energy launchers.");
|
||||
getWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers);
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeEnergyLaunchers() {
|
||||
auto Mass::writeEnergyLaunchers() -> bool {
|
||||
LOG_INFO("Writing energy launchers.");
|
||||
return writeWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers);
|
||||
}
|
||||
|
||||
void
|
||||
Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) {
|
||||
void Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) {
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
if(!unit_data) {
|
||||
LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename);
|
||||
|
@ -242,8 +223,7 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weap
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) {
|
||||
auto Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) -> bool {
|
||||
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
|
||||
if(!unit_data) {
|
||||
_lastError = "No unit data in "_s + _filename;
|
||||
|
|
|
@ -39,18 +39,15 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie
|
|||
refreshStagedMasses();
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
MassManager::lastError() {
|
||||
auto MassManager::lastError() -> Containers::StringView {
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
Mass&
|
||||
MassManager::hangar(Int hangar) {
|
||||
auto MassManager::hangar(Int hangar) -> Mass& {
|
||||
return _hangars[hangar];
|
||||
}
|
||||
|
||||
void
|
||||
MassManager::refreshHangar(Int hangar) {
|
||||
void MassManager::refreshHangar(Int hangar) {
|
||||
if(hangar < 0 || hangar >= 32) {
|
||||
_lastError = "Hangar index out of range.";
|
||||
LOG_ERROR(_lastError);
|
||||
|
@ -63,8 +60,7 @@ MassManager::refreshHangar(Int hangar) {
|
|||
_hangars[hangar] = Mass{mass_filename};
|
||||
}
|
||||
|
||||
bool
|
||||
MassManager::importMass(Containers::StringView staged_fn, Int hangar) {
|
||||
auto MassManager::importMass(Containers::StringView staged_fn, Int hangar) -> bool {
|
||||
if(hangar < 0 || hangar >= 32) {
|
||||
_lastError = "Hangar index out of range.";
|
||||
LOG_ERROR(_lastError);
|
||||
|
@ -106,8 +102,7 @@ MassManager::importMass(Containers::StringView staged_fn, Int hangar) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
MassManager::exportMass(Int hangar) {
|
||||
auto MassManager::exportMass(Int hangar) -> bool {
|
||||
if(hangar < 0 || hangar >= 32) {
|
||||
_lastError = "Hangar index out of range."_s;
|
||||
LOG_ERROR(_lastError);
|
||||
|
@ -133,8 +128,7 @@ MassManager::exportMass(Int hangar) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
MassManager::moveMass(Int source, Int destination) {
|
||||
auto MassManager::moveMass(Int source, Int destination) -> bool {
|
||||
if(source < 0 || source >= 32) {
|
||||
_lastError = "Source hangar index out of range."_s;
|
||||
LOG_ERROR(_lastError);
|
||||
|
@ -171,8 +165,7 @@ MassManager::moveMass(Int source, Int destination) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
MassManager::deleteMass(Int hangar) {
|
||||
auto MassManager::deleteMass(Int hangar) -> bool {
|
||||
if(hangar < 0 || hangar >= 32) {
|
||||
_lastError = "Hangar index out of range."_s;
|
||||
LOG_ERROR(_lastError);
|
||||
|
@ -188,13 +181,11 @@ MassManager::deleteMass(Int hangar) {
|
|||
return true;
|
||||
}
|
||||
|
||||
const std::map<Containers::String, Containers::String>&
|
||||
MassManager::stagedMasses() {
|
||||
auto MassManager::stagedMasses() -> std::map<Containers::String, Containers::String> const& {
|
||||
return _stagedMasses;
|
||||
}
|
||||
|
||||
void
|
||||
MassManager::refreshStagedMasses() {
|
||||
void MassManager::refreshStagedMasses() {
|
||||
_stagedMasses.clear();
|
||||
|
||||
using Utility::Path::ListFlag;
|
||||
|
@ -226,8 +217,7 @@ MassManager::refreshStagedMasses() {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
MassManager::refreshStagedMass(Containers::StringView filename) {
|
||||
void MassManager::refreshStagedMass(Containers::StringView filename) {
|
||||
LOG_INFO_FORMAT("Refreshing staged unit with filename {}.", filename);
|
||||
|
||||
bool file_exists = Utility::Path::exists(Utility::Path::join(_stagingAreaDirectory, filename));
|
||||
|
@ -247,8 +237,7 @@ MassManager::refreshStagedMass(Containers::StringView filename) {
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
MassManager::deleteStagedMass(Containers::StringView filename) {
|
||||
auto MassManager::deleteStagedMass(Containers::StringView filename) -> bool {
|
||||
if(_stagedMasses.find(filename) == _stagedMasses.cend()) {
|
||||
_lastError = "The file "_s + filename + " couldn't be found in the list of staged M.A.S.S.es."_s;
|
||||
LOG_ERROR(_lastError);
|
||||
|
|
|
@ -30,22 +30,22 @@ 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) -> Mass&;
|
||||
|
||||
void refreshHangar(int hangar);
|
||||
|
||||
bool importMass(Containers::StringView staged_fn, int hangar);
|
||||
bool exportMass(int hangar);
|
||||
auto importMass(Containers::StringView staged_fn, int hangar) -> bool;
|
||||
auto exportMass(int hangar) -> bool;
|
||||
|
||||
bool moveMass(int source, int destination);
|
||||
bool deleteMass(int hangar);
|
||||
auto moveMass(int source, int destination) -> bool;
|
||||
auto deleteMass(int hangar) -> bool;
|
||||
|
||||
std::map<Containers::String, Containers::String> const& stagedMasses();
|
||||
auto stagedMasses() -> std::map<Containers::String, Containers::String> const&;
|
||||
void refreshStagedMasses();
|
||||
void refreshStagedMass(Containers::StringView filename);
|
||||
bool deleteStagedMass(Containers::StringView filename);
|
||||
auto deleteStagedMass(Containers::StringView filename) -> bool;
|
||||
|
||||
private:
|
||||
Containers::StringView _saveDirectory;
|
||||
|
|
|
@ -62,38 +62,31 @@ Profile::Profile(Containers::StringView path):
|
|||
refreshValues();
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::valid() const {
|
||||
auto Profile::valid() const -> bool {
|
||||
return _valid;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
Profile::lastError() const {
|
||||
auto Profile::lastError() const -> Containers::StringView {
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
Profile::filename() const {
|
||||
auto Profile::filename() const -> Containers::StringView {
|
||||
return _filename;
|
||||
}
|
||||
|
||||
ProfileType
|
||||
Profile::type() const {
|
||||
auto Profile::type() const -> ProfileType {
|
||||
return _type;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::isDemo() const {
|
||||
auto Profile::isDemo() const -> bool {
|
||||
return _type == ProfileType::Demo;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
Profile::account() const {
|
||||
auto Profile::account() const -> Containers::StringView {
|
||||
return _account;
|
||||
}
|
||||
|
||||
void
|
||||
Profile::refreshValues() {
|
||||
void Profile::refreshValues() {
|
||||
if(!_profile.reloadData()) {
|
||||
LOG_ERROR(_profile.lastError());
|
||||
_valid = false;
|
||||
|
@ -164,13 +157,11 @@ Profile::refreshValues() {
|
|||
_valid = true;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
Profile::companyName() const {
|
||||
auto Profile::companyName() const -> Containers::StringView {
|
||||
return _name;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::renameCompany(Containers::StringView new_name) {
|
||||
auto Profile::renameCompany(Containers::StringView new_name) -> bool {
|
||||
auto name_prop = _profile.at<StringProperty>(PROFILE_NAME);
|
||||
if(!name_prop) {
|
||||
_lastError = "No company name in "_s + _filename;
|
||||
|
@ -189,18 +180,15 @@ Profile::renameCompany(Containers::StringView new_name) {
|
|||
return true;
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::activeFrameSlot() const {
|
||||
auto Profile::activeFrameSlot() const -> Int {
|
||||
return _activeFrameSlot;
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::credits() const {
|
||||
auto Profile::credits() const -> Int {
|
||||
return _credits;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setCredits(Int amount) {
|
||||
auto Profile::setCredits(Int amount) -> bool {
|
||||
auto credits_prop = _profile.at<IntProperty>(PROFILE_CREDITS);
|
||||
|
||||
if(!credits_prop) {
|
||||
|
@ -220,13 +208,11 @@ Profile::setCredits(Int amount) {
|
|||
return true;
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::storyProgress() const {
|
||||
auto Profile::storyProgress() const -> Int {
|
||||
return _storyProgress;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setStoryProgress(Int progress) {
|
||||
auto Profile::setStoryProgress(Int progress) -> bool {
|
||||
auto story_progress_prop = _profile.at<IntProperty>("StoryProgress"_s);
|
||||
|
||||
if(!story_progress_prop) {
|
||||
|
@ -246,58 +232,47 @@ Profile::setStoryProgress(Int progress) {
|
|||
return true;
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::lastMissionId() const {
|
||||
auto Profile::lastMissionId() const -> Int {
|
||||
return _lastMissionId;
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::verseSteel() const {
|
||||
auto Profile::verseSteel() const -> Int {
|
||||
return _verseSteel;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setVerseSteel(Int amount) {
|
||||
auto Profile::setVerseSteel(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, VerseSteel, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::undinium() const {
|
||||
auto Profile::undinium() const -> Int {
|
||||
return _undinium;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setUndinium(Int amount) {
|
||||
auto Profile::setUndinium(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Undinium, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::necriumAlloy() const {
|
||||
auto Profile::necriumAlloy() const -> Int {
|
||||
return _necriumAlloy;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setNecriumAlloy(Int amount) {
|
||||
auto Profile::setNecriumAlloy(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, NecriumAlloy, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::lunarite() const {
|
||||
auto Profile::lunarite() const -> Int {
|
||||
return _lunarite;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setLunarite(Int amount) {
|
||||
auto Profile::setLunarite(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Lunarite, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::asterite() const {
|
||||
auto Profile::asterite() const -> Int {
|
||||
return _asterite;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setAsterite(Int amount) {
|
||||
auto Profile::setAsterite(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Asterite, amount);
|
||||
}
|
||||
|
||||
|
@ -311,53 +286,43 @@ Profile::setHalliteFragma(Int amount) {
|
|||
return setResource(PROFILE_MATERIAL, HalliteFragma, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::ednil() const {
|
||||
auto Profile::ednil() const -> Int {
|
||||
return _ednil;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setEdnil(Int amount) {
|
||||
auto Profile::setEdnil(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Ednil, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::nuflalt() const {
|
||||
auto Profile::nuflalt() const -> Int {
|
||||
return _nuflalt;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setNuflalt(Int amount) {
|
||||
auto Profile::setNuflalt(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Nuflalt, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::aurelene() const {
|
||||
auto Profile::aurelene() const -> Int {
|
||||
return _aurelene;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setAurelene(Int amount) {
|
||||
auto Profile::setAurelene(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Aurelene, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::soldus() const {
|
||||
auto Profile::soldus() const -> Int {
|
||||
return _soldus;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setSoldus(Int amount) {
|
||||
auto Profile::setSoldus(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Soldus, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::synthesisedN() const {
|
||||
auto Profile::synthesisedN() const -> Int {
|
||||
return _synthesisedN;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setSynthesisedN(Int amount) {
|
||||
auto Profile::setSynthesisedN(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, SynthesisedN, amount);
|
||||
}
|
||||
|
||||
|
@ -371,53 +336,43 @@ Profile::setNanoc(Int amount) {
|
|||
return setResource(PROFILE_MATERIAL, Nanoc, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::alcarbonite() const {
|
||||
auto Profile::alcarbonite() const -> Int {
|
||||
return _alcarbonite;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setAlcarbonite(Int amount) {
|
||||
auto Profile::setAlcarbonite(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Alcarbonite, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::keriphene() const {
|
||||
auto Profile::keriphene() const -> Int {
|
||||
return _keriphene;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setKeriphene(Int amount) {
|
||||
auto Profile::setKeriphene(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Keriphene, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::nitinolCM() const {
|
||||
auto Profile::nitinolCM() const -> Int {
|
||||
return _nitinolCM;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setNitinolCM(Int amount) {
|
||||
auto Profile::setNitinolCM(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, NitinolCM, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::quarkium() const {
|
||||
auto Profile::quarkium() const -> Int {
|
||||
return _quarkium;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setQuarkium(Int amount) {
|
||||
auto Profile::setQuarkium(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Quarkium, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::alterene() const {
|
||||
auto Profile::alterene() const -> Int {
|
||||
return _alterene;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setAlterene(Int amount) {
|
||||
auto Profile::setAlterene(Int amount) -> bool {
|
||||
return setResource(PROFILE_MATERIAL, Alterene, amount);
|
||||
}
|
||||
|
||||
|
@ -431,53 +386,43 @@ Profile::setCosmium(Int amount) {
|
|||
return setResource(PROFILE_MATERIAL, Cosmium, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::mixedComposition() const {
|
||||
auto Profile::mixedComposition() const -> Int {
|
||||
return _mixedComposition;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setMixedComposition(Int amount) {
|
||||
auto Profile::setMixedComposition(Int amount) -> bool {
|
||||
return setResource(PROFILE_QUARK_DATA, MixedComposition, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::voidResidue() const {
|
||||
auto Profile::voidResidue() const -> Int {
|
||||
return _voidResidue;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setVoidResidue(Int amount) {
|
||||
auto Profile::setVoidResidue(Int amount) -> bool {
|
||||
return setResource(PROFILE_QUARK_DATA, VoidResidue, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::muscularConstruction() const {
|
||||
auto Profile::muscularConstruction() const -> Int {
|
||||
return _muscularConstruction;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setMuscularConstruction(Int amount) {
|
||||
auto Profile::setMuscularConstruction(Int amount) -> bool {
|
||||
return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::mineralExoskeletology() const {
|
||||
auto Profile::mineralExoskeletology() const -> Int {
|
||||
return _mineralExoskeletology;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setMineralExoskeletology(Int amount) {
|
||||
auto Profile::setMineralExoskeletology(Int amount) -> bool {
|
||||
return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::carbonisedSkin() const {
|
||||
auto Profile::carbonisedSkin() const -> Int {
|
||||
return _carbonisedSkin;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setCarbonisedSkin(Int amount) {
|
||||
auto Profile::setCarbonisedSkin(Int amount) -> bool {
|
||||
return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount);
|
||||
}
|
||||
|
||||
|
@ -491,8 +436,7 @@ Profile::setIsolatedVoidParticle(Int amount) {
|
|||
return setResource(PROFILE_QUARK_DATA, IsolatedVoidParticle, amount);
|
||||
}
|
||||
|
||||
Int
|
||||
Profile::getResource(Containers::StringView container, MaterialID id) {
|
||||
auto Profile::getResource(Containers::StringView container, MaterialID id) -> Int {
|
||||
auto mats_prop = _profile.at<ArrayProperty>(container);
|
||||
|
||||
if(!mats_prop) {
|
||||
|
@ -508,8 +452,7 @@ Profile::getResource(Containers::StringView container, MaterialID id) {
|
|||
return it != mats_prop->items.end() ? static_cast<ResourceItemValue*>(it->get())->quantity : 0;
|
||||
}
|
||||
|
||||
bool
|
||||
Profile::setResource(Containers::StringView container, MaterialID id, Int amount) {
|
||||
auto Profile::setResource(Containers::StringView container, MaterialID id, Int amount) -> bool {
|
||||
auto mats_prop = _profile.at<ArrayProperty>(container);
|
||||
|
||||
if(!mats_prop) {
|
||||
|
|
|
@ -51,93 +51,93 @@ class Profile {
|
|||
void refreshValues();
|
||||
|
||||
auto companyName() const -> Containers::StringView;
|
||||
bool renameCompany(Containers::StringView new_name);
|
||||
auto renameCompany(Containers::StringView new_name) -> bool;
|
||||
|
||||
auto activeFrameSlot() const -> Int;
|
||||
|
||||
auto credits() const -> Int;
|
||||
bool setCredits(Int credits);
|
||||
auto setCredits(Int credits) -> bool;
|
||||
|
||||
auto storyProgress() const -> Int;
|
||||
bool setStoryProgress(Int progress);
|
||||
auto setStoryProgress(Int progress) -> bool;
|
||||
|
||||
auto lastMissionId() const -> Int;
|
||||
|
||||
auto verseSteel() const -> Int;
|
||||
bool setVerseSteel(Int amount);
|
||||
auto setVerseSteel(Int amount) -> bool;
|
||||
|
||||
auto undinium() const -> Int;
|
||||
bool setUndinium(Int amount);
|
||||
auto setUndinium(Int amount) -> bool;
|
||||
|
||||
auto necriumAlloy() const -> Int;
|
||||
bool setNecriumAlloy(Int amount);
|
||||
auto setNecriumAlloy(Int amount) -> bool;
|
||||
|
||||
auto lunarite() const -> Int;
|
||||
bool setLunarite(Int amount);
|
||||
auto setLunarite(Int amount) -> bool;
|
||||
|
||||
auto asterite() const -> Int;
|
||||
bool setAsterite(Int amount);
|
||||
auto setAsterite(Int amount) -> bool;
|
||||
|
||||
Int halliteFragma() const;
|
||||
bool setHalliteFragma(Int amount);
|
||||
|
||||
auto ednil() const -> Int;
|
||||
bool setEdnil(Int amount);
|
||||
auto setEdnil(Int amount) -> bool;
|
||||
|
||||
auto nuflalt() const -> Int;
|
||||
bool setNuflalt(Int amount);
|
||||
auto setNuflalt(Int amount) -> bool;
|
||||
|
||||
auto aurelene() const -> Int;
|
||||
bool setAurelene(Int amount);
|
||||
auto setAurelene(Int amount) -> bool;
|
||||
|
||||
auto soldus() const -> Int;
|
||||
bool setSoldus(Int amount);
|
||||
auto setSoldus(Int amount) -> bool;
|
||||
|
||||
auto synthesisedN() const -> Int;
|
||||
bool setSynthesisedN(Int amount);
|
||||
auto setSynthesisedN(Int amount) -> bool;
|
||||
|
||||
Int nanoc() const;
|
||||
bool setNanoc(Int amount);
|
||||
|
||||
auto alcarbonite() const -> Int;
|
||||
bool setAlcarbonite(Int amount);
|
||||
auto setAlcarbonite(Int amount) -> bool;
|
||||
|
||||
auto keriphene() const -> Int;
|
||||
bool setKeriphene(Int amount);
|
||||
auto setKeriphene(Int amount) -> bool;
|
||||
|
||||
auto nitinolCM() const -> Int;
|
||||
bool setNitinolCM(Int amount);
|
||||
auto setNitinolCM(Int amount) -> bool;
|
||||
|
||||
auto quarkium() const -> Int;
|
||||
bool setQuarkium(Int amount);
|
||||
auto setQuarkium(Int amount) -> bool;
|
||||
|
||||
auto alterene() const -> Int;
|
||||
bool setAlterene(Int amount);
|
||||
auto setAlterene(Int amount) -> bool;
|
||||
|
||||
Int cosmium() const;
|
||||
bool setCosmium(Int amount);
|
||||
|
||||
auto mixedComposition() const -> Int;
|
||||
bool setMixedComposition(Int amount);
|
||||
auto setMixedComposition(Int amount) -> bool;
|
||||
|
||||
auto voidResidue() const -> Int;
|
||||
bool setVoidResidue(Int amount);
|
||||
auto setVoidResidue(Int amount) -> bool;
|
||||
|
||||
auto muscularConstruction() const -> Int;
|
||||
bool setMuscularConstruction(Int amount);
|
||||
auto setMuscularConstruction(Int amount) -> bool;
|
||||
|
||||
auto mineralExoskeletology() const -> Int;
|
||||
bool setMineralExoskeletology(Int amount);
|
||||
auto setMineralExoskeletology(Int amount) -> bool;
|
||||
|
||||
auto carbonisedSkin() const -> Int;
|
||||
bool setCarbonisedSkin(Int amount);
|
||||
auto setCarbonisedSkin(Int amount) -> bool;
|
||||
|
||||
Int isolatedVoidParticle() const;
|
||||
bool setIsolatedVoidParticle(Int amount);
|
||||
|
||||
private:
|
||||
Int getResource(Containers::StringView container, MaterialID id);
|
||||
bool setResource(Containers::StringView container, MaterialID id, Int amount);
|
||||
auto getResource(Containers::StringView container, MaterialID id) -> Int;
|
||||
auto setResource(Containers::StringView container, MaterialID id, Int amount) -> bool;
|
||||
|
||||
Containers::String _filename;
|
||||
|
||||
|
|
|
@ -40,23 +40,19 @@ ProfileManager::ProfileManager(Containers::StringView save_dir, Containers::Stri
|
|||
_ready = refreshProfiles();
|
||||
}
|
||||
|
||||
bool
|
||||
ProfileManager::ready() const {
|
||||
auto ProfileManager::ready() const -> bool {
|
||||
return _ready;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
ProfileManager::lastError() {
|
||||
auto ProfileManager::lastError() -> Containers::StringView {
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
Containers::ArrayView<Profile>
|
||||
ProfileManager::profiles() {
|
||||
auto ProfileManager::profiles() -> Containers::ArrayView<Profile> {
|
||||
return _profiles;
|
||||
}
|
||||
|
||||
bool
|
||||
ProfileManager::refreshProfiles() {
|
||||
auto ProfileManager::refreshProfiles() -> bool {
|
||||
LOG_INFO("Refreshing profiles.");
|
||||
|
||||
_profiles = Containers::Array<Profile>{};
|
||||
|
@ -97,13 +93,11 @@ ProfileManager::refreshProfiles() {
|
|||
return true;
|
||||
}
|
||||
|
||||
Profile*
|
||||
ProfileManager::getProfile(std::size_t index) {
|
||||
auto ProfileManager::getProfile(std::size_t index) -> Profile* {
|
||||
return index <= _profiles.size() ? &(_profiles[index]) : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
ProfileManager::deleteProfile(std::size_t index, bool delete_builds) {
|
||||
auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> bool {
|
||||
if(!Utility::Path::remove(Utility::Path::join(_saveDirectory, _profiles[index].filename()))) {
|
||||
_lastError = Utility::format("Couldn't delete {} (filename: {}).",
|
||||
_profiles[index].companyName(),
|
||||
|
@ -132,8 +126,7 @@ ProfileManager::deleteProfile(std::size_t index, bool delete_builds) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ProfileManager::backupProfile(std::size_t index, bool backup_builds) {
|
||||
auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> bool {
|
||||
std::time_t timestamp = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||
std::tm* time = std::localtime(×tamp);
|
||||
auto& profile = _profiles[index];
|
||||
|
@ -209,13 +202,11 @@ ProfileManager::backupProfile(std::size_t index, bool backup_builds) {
|
|||
return true;
|
||||
}
|
||||
|
||||
Containers::ArrayView<Backup>
|
||||
ProfileManager::backups() {
|
||||
auto ProfileManager::backups() -> Containers::ArrayView<Backup> {
|
||||
return _backups;
|
||||
}
|
||||
|
||||
void
|
||||
ProfileManager::refreshBackups() {
|
||||
void ProfileManager::refreshBackups() {
|
||||
_backups = Containers::Array<Backup>{};
|
||||
|
||||
using Utility::Path::ListFlag;
|
||||
|
@ -299,8 +290,7 @@ ProfileManager::refreshBackups() {
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ProfileManager::deleteBackup(std::size_t index) {
|
||||
auto ProfileManager::deleteBackup(std::size_t index) -> bool {
|
||||
if(!Utility::Path::remove(Utility::Path::join(_backupsDirectory, _backups[index].filename))) {
|
||||
_lastError = "Couldn't delete " + _backups[index].filename;
|
||||
LOG_ERROR(_lastError);
|
||||
|
@ -317,8 +307,7 @@ ProfileManager::deleteBackup(std::size_t index) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ProfileManager::restoreBackup(std::size_t index) {
|
||||
auto ProfileManager::restoreBackup(std::size_t index) -> bool {
|
||||
const Backup& backup = _backups[index];
|
||||
|
||||
auto error_format = "Extraction of file {} failed: {}"_s;
|
||||
|
|
|
@ -45,20 +45,20 @@ 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<Profile> profiles();
|
||||
bool refreshProfiles();
|
||||
auto profiles() -> Containers::ArrayView<Profile>;
|
||||
auto refreshProfiles() -> bool;
|
||||
|
||||
Profile* getProfile(std::size_t index);
|
||||
bool deleteProfile(std::size_t index, bool delete_builds);
|
||||
bool backupProfile(std::size_t index, bool backup_builds);
|
||||
auto getProfile(std::size_t index) -> Profile*;
|
||||
auto deleteProfile(std::size_t index, bool delete_builds) -> bool;
|
||||
auto backupProfile(std::size_t index, bool backup_builds) -> bool;
|
||||
|
||||
Containers::ArrayView<Backup> backups();
|
||||
auto backups() -> Containers::ArrayView<Backup>;
|
||||
void refreshBackups();
|
||||
|
||||
bool deleteBackup(std::size_t index);
|
||||
bool restoreBackup(std::size_t index);
|
||||
auto deleteBackup(std::size_t index) -> bool;
|
||||
auto restoreBackup(std::size_t index) -> bool;
|
||||
|
||||
private:
|
||||
bool _ready = false;
|
||||
|
|
|
@ -165,8 +165,7 @@ SaveTool::~SaveTool() {
|
|||
LOG_INFO("Exiting.");
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawEvent() {
|
||||
void SaveTool::drawEvent() {
|
||||
#ifdef SAVETOOL_DEBUG_BUILD
|
||||
tweak.update();
|
||||
#endif
|
||||
|
@ -186,54 +185,45 @@ SaveTool::drawEvent() {
|
|||
_timeline.nextFrame();
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::viewportEvent(ViewportEvent& event) {
|
||||
void SaveTool::viewportEvent(ViewportEvent& event) {
|
||||
GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()});
|
||||
|
||||
const Vector2 size = Vector2{windowSize()}/dpiScaling();
|
||||
_imgui.relayout(size, windowSize(), framebufferSize());
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::keyPressEvent(KeyEvent& event) {
|
||||
void SaveTool::keyPressEvent(KeyEvent& event) {
|
||||
if(_imgui.handleKeyPressEvent(event)) return;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::keyReleaseEvent(KeyEvent& event) {
|
||||
void SaveTool::keyReleaseEvent(KeyEvent& event) {
|
||||
if(_imgui.handleKeyReleaseEvent(event)) return;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::mousePressEvent(MouseEvent& event) {
|
||||
void SaveTool::mousePressEvent(MouseEvent& event) {
|
||||
if(_imgui.handleMousePressEvent(event)) return;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::mouseReleaseEvent(MouseEvent& event) {
|
||||
void SaveTool::mouseReleaseEvent(MouseEvent& event) {
|
||||
if(_imgui.handleMouseReleaseEvent(event)) return;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::mouseMoveEvent(MouseMoveEvent& event) {
|
||||
void SaveTool::mouseMoveEvent(MouseMoveEvent& event) {
|
||||
if(_imgui.handleMouseMoveEvent(event)) return;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::mouseScrollEvent(MouseScrollEvent& event) {
|
||||
void SaveTool::mouseScrollEvent(MouseScrollEvent& event) {
|
||||
if(_imgui.handleMouseScrollEvent(event)) {
|
||||
event.setAccepted();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::textInputEvent(TextInputEvent& event) {
|
||||
void SaveTool::textInputEvent(TextInputEvent& event) {
|
||||
if(_imgui.handleTextInputEvent(event)) return;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::anyEvent(SDL_Event& event) {
|
||||
void SaveTool::anyEvent(SDL_Event& event) {
|
||||
if(event.type == _initEventId) {
|
||||
initEvent(event);
|
||||
}
|
||||
|
@ -245,8 +235,7 @@ SaveTool::anyEvent(SDL_Event& event) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawImGui() {
|
||||
void SaveTool::drawImGui() {
|
||||
_imgui.newFrame();
|
||||
|
||||
if(ImGui::GetIO().WantTextInput && !isTextInputActive()) {
|
||||
|
@ -263,8 +252,7 @@ SaveTool::drawImGui() {
|
|||
_imgui.drawFrame();
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawGui() {
|
||||
void SaveTool::drawGui() {
|
||||
drawMainMenu();
|
||||
|
||||
switch(_uiState) {
|
||||
|
@ -306,8 +294,7 @@ SaveTool::drawGui() {
|
|||
_queue.draw(windowSize());
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawDisclaimer() {
|
||||
void SaveTool::drawDisclaimer() {
|
||||
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
|
||||
|
||||
if(ImGui::Begin("Disclaimer##DisclaimerWindow", nullptr,
|
||||
|
@ -368,8 +355,7 @@ SaveTool::drawDisclaimer() {
|
|||
ImGui::End();
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawInitialisation() {
|
||||
void SaveTool::drawInitialisation() {
|
||||
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
|
||||
|
||||
if(ImGui::BeginPopupModal("##InitPopup", nullptr,
|
||||
|
@ -382,8 +368,7 @@ SaveTool::drawInitialisation() {
|
|||
ImGui::OpenPopup("##InitPopup");
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawGameState() {
|
||||
void SaveTool::drawGameState() {
|
||||
ImGui::TextUnformatted("Game state:");
|
||||
ImGui::SameLine();
|
||||
{
|
||||
|
@ -404,14 +389,12 @@ SaveTool::drawGameState() {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawHelpMarker(Containers::StringView text, Float wrap_pos) {
|
||||
void SaveTool::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) {
|
||||
void SaveTool::drawTooltip(Containers::StringView text, Float wrap_pos) {
|
||||
if(ImGui::IsItemHovered()){
|
||||
ImGui::BeginTooltip();
|
||||
if(wrap_pos > 0.0f) {
|
||||
|
@ -430,13 +413,11 @@ SaveTool::drawCheckbox(Containers::StringView label, bool value) {
|
|||
return ImGui::Checkbox(label.data(), &value);
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::openUri(Containers::StringView uri) {
|
||||
void SaveTool::openUri(Containers::StringView uri) {
|
||||
ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri.data()), nullptr, nullptr, SW_SHOWDEFAULT);
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::checkGameState() {
|
||||
void SaveTool::checkGameState() {
|
||||
WTS_PROCESS_INFOW* process_infos = nullptr;
|
||||
unsigned long process_count = 0;
|
||||
|
||||
|
|
|
@ -103,8 +103,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
|||
void initialiseConfiguration();
|
||||
void initialiseGui();
|
||||
void initialiseManager();
|
||||
bool initialiseToolDirectories();
|
||||
bool findGameDataDirectory();
|
||||
auto initialiseToolDirectories() -> bool;
|
||||
auto findGameDataDirectory() -> bool;
|
||||
void initialiseMassManager();
|
||||
void initialiseFileWatcher();
|
||||
|
||||
|
@ -116,21 +116,21 @@ 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<char> name_view);
|
||||
auto drawIntEditPopup(int* value_to_edit, int max) -> bool;
|
||||
auto drawRenamePopup(Containers::ArrayView<char> name_view) -> bool;
|
||||
void drawGeneralInfo();
|
||||
void drawResearchInventory();
|
||||
template<typename Getter, typename Setter>
|
||||
void drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter);
|
||||
void drawUnavailableMaterialRow(Containers::StringView name, Int 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();
|
||||
|
@ -148,14 +148,14 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
|||
void drawTuning();
|
||||
void drawDecalEditor(Decal& decal);
|
||||
void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view);
|
||||
Containers::StringView getStyleName(Int id, Containers::ArrayView<CustomStyle> view);
|
||||
auto getStyleName(Int id, Containers::ArrayView<CustomStyle> view) -> Containers::StringView;
|
||||
|
||||
enum DCSResult {
|
||||
DCS_Fail,
|
||||
DCS_ResetStyle,
|
||||
DCS_Save
|
||||
};
|
||||
DCSResult drawCustomStyle(CustomStyle& style);
|
||||
auto drawCustomStyle(CustomStyle& style) -> DCSResult;
|
||||
|
||||
void drawAbout();
|
||||
void drawGameState();
|
||||
|
@ -166,7 +166,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
|||
bool drawCheckbox(Containers::StringView label, bool value);
|
||||
|
||||
template<typename Functor, typename... Args>
|
||||
bool drawUnsafeWidget(Functor func, Args... args) {
|
||||
auto drawUnsafeWidget(Functor func, Args... args) -> bool {
|
||||
GameState game_state = _gameState; // Copying the value to reduce the risk of a data race.
|
||||
ImGui::BeginDisabled(game_state != GameState::NotRunning);
|
||||
bool result = func(std::forward<Args>(args)...);
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
#include "SaveTool.h"
|
||||
|
||||
void
|
||||
SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||
void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||
const std::string&,
|
||||
const std::string& filename,
|
||||
efsw::Action action,
|
||||
|
@ -61,8 +60,7 @@ SaveTool::handleFileAction(efsw::WatchID watch_id,
|
|||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::fileUpdateEvent(SDL_Event& event) {
|
||||
void SaveTool::fileUpdateEvent(SDL_Event& event) {
|
||||
Containers::String filename{static_cast<char*>(event.user.data1),
|
||||
std::strlen(static_cast<char*>(event.user.data1)), nullptr};
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
|
||||
#include "SaveTool.h"
|
||||
|
||||
void
|
||||
SaveTool::initEvent(SDL_Event& event) {
|
||||
void SaveTool::initEvent(SDL_Event& event) {
|
||||
_initThread.join();
|
||||
|
||||
switch(event.user.code) {
|
||||
|
@ -50,16 +49,14 @@ SaveTool::initEvent(SDL_Event& event) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::initialiseConfiguration() {
|
||||
void SaveTool::initialiseConfiguration() {
|
||||
LOG_INFO("Reading configuration file.");
|
||||
|
||||
setSwapInterval(conf().swapInterval());
|
||||
setMinimalLoopPeriod(0);
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::initialiseGui() {
|
||||
void SaveTool::initialiseGui() {
|
||||
LOG_INFO("Initialising Dear ImGui.");
|
||||
|
||||
ImGui::CreateContext();
|
||||
|
@ -111,8 +108,7 @@ SaveTool::initialiseGui() {
|
|||
style.Colors[ImGuiCol_WindowBg] = ImColor(0xff1f1f1f);
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::initialiseManager() {
|
||||
void SaveTool::initialiseManager() {
|
||||
LOG_INFO("Initialising the profile manager.");
|
||||
|
||||
SDL_Event event;
|
||||
|
@ -130,8 +126,7 @@ SaveTool::initialiseManager() {
|
|||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
auto
|
||||
SaveTool::initialiseToolDirectories() -> bool {
|
||||
auto SaveTool::initialiseToolDirectories() -> bool {
|
||||
LOG_INFO("Initialising Save Tool directories.");
|
||||
|
||||
_backupsDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "backups");
|
||||
|
@ -192,8 +187,7 @@ SaveTool::initialiseToolDirectories() -> bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
auto
|
||||
SaveTool::findGameDataDirectory() -> bool {
|
||||
auto SaveTool::findGameDataDirectory() -> bool {
|
||||
LOG_INFO("Searching for the game's save directory.");
|
||||
|
||||
wchar_t* localappdata_path = nullptr;
|
||||
|
@ -219,14 +213,12 @@ SaveTool::findGameDataDirectory() -> bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::initialiseMassManager() {
|
||||
void SaveTool::initialiseMassManager() {
|
||||
LOG_INFO("Initialising the M.A.S.S. manager.");
|
||||
_massManager.emplace(_saveDir, _currentProfile->account(), _currentProfile->isDemo(), _stagingDir);
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::initialiseFileWatcher() {
|
||||
void SaveTool::initialiseFileWatcher() {
|
||||
LOG_INFO("Initialising the file watcher.");
|
||||
_fileWatcher.emplace();
|
||||
_watchIDs[SaveDir] = _fileWatcher->addWatch(_saveDir, this, false);
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
#include "SaveTool.h"
|
||||
|
||||
void
|
||||
SaveTool::drawManager() {
|
||||
void SaveTool::drawManager() {
|
||||
ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize({Float(windowSize().x()), Float(windowSize().y()) - ImGui::GetItemRectSize().y},
|
||||
ImGuiCond_Always);
|
||||
|
@ -96,8 +95,7 @@ SaveTool::drawManager() {
|
|||
ImGui::End();
|
||||
}
|
||||
|
||||
bool
|
||||
SaveTool::drawIntEditPopup(int* value_to_edit, int max) {
|
||||
auto SaveTool::drawIntEditPopup(int* value_to_edit, int max) -> bool {
|
||||
bool apply = false;
|
||||
if(ImGui::BeginPopup("int_edit")) {
|
||||
ImGui::Text("Please enter a value between 0 and %i:", max);
|
||||
|
@ -120,8 +118,7 @@ SaveTool::drawIntEditPopup(int* value_to_edit, int max) {
|
|||
return apply;
|
||||
}
|
||||
|
||||
bool
|
||||
SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) {
|
||||
auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool {
|
||||
bool apply = false;
|
||||
if(ImGui::BeginPopup("name_edit")) {
|
||||
ImGui::TextUnformatted("Please enter a new name. Conditions:");
|
||||
|
@ -173,8 +170,7 @@ SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) {
|
|||
return apply;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawGeneralInfo() {
|
||||
void SaveTool::drawGeneralInfo() {
|
||||
if(!_currentProfile) {
|
||||
return;
|
||||
}
|
||||
|
@ -282,8 +278,7 @@ SaveTool::drawGeneralInfo() {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawResearchInventory() {
|
||||
void SaveTool::drawResearchInventory() {
|
||||
if(!_currentProfile) {
|
||||
return;
|
||||
}
|
||||
|
@ -397,8 +392,7 @@ SaveTool::drawResearchInventory() {
|
|||
}
|
||||
|
||||
template<typename Getter, typename Setter>
|
||||
void
|
||||
SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter) {
|
||||
void SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter) {
|
||||
static_assert(std::is_same<decltype(getter()), Int>::value, "getter doesn't return an Int, and/or doesn't take zero arguments.");
|
||||
static_assert(std::is_same<decltype(setter(0)), bool>::value, "setter doesn't return a bool, and/or doesn't take a single Int as an argument.");
|
||||
|
||||
|
@ -432,8 +426,7 @@ SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) {
|
||||
void SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::Text("T%i", tier);
|
||||
|
@ -443,8 +436,7 @@ SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) {
|
|||
ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION);
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawMassManager() {
|
||||
void SaveTool::drawMassManager() {
|
||||
if(!_massManager) {
|
||||
return;
|
||||
}
|
||||
|
@ -641,8 +633,7 @@ SaveTool::drawMassManager() {
|
|||
drawDeleteStagedMassPopup(staged_mass_to_delete);
|
||||
}
|
||||
|
||||
ImGuiID
|
||||
SaveTool::drawDeleteMassPopup(int mass_index) {
|
||||
auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
|
||||
if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
|
@ -698,8 +689,7 @@ SaveTool::drawDeleteMassPopup(int mass_index) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ImGuiID
|
||||
SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) {
|
||||
auto SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID {
|
||||
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
|
||||
#include "SaveTool.h"
|
||||
|
||||
void
|
||||
SaveTool::drawMassViewer() {
|
||||
void SaveTool::drawMassViewer() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
_currentMass = nullptr;
|
||||
_currentWeapon = nullptr;
|
||||
|
@ -155,8 +154,7 @@ SaveTool::drawMassViewer() {
|
|||
ImGui::End();
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawGlobalStyles() {
|
||||
void SaveTool::drawGlobalStyles() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
@ -192,8 +190,7 @@ SaveTool::drawGlobalStyles() {
|
|||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawTuning() {
|
||||
void SaveTool::drawTuning() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
@ -289,8 +286,7 @@ SaveTool::drawTuning() {
|
|||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
SaveTool::DCSResult
|
||||
SaveTool::drawCustomStyle(CustomStyle& style) {
|
||||
auto SaveTool::drawCustomStyle(CustomStyle& style) -> DCSResult {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return DCS_Fail;
|
||||
}
|
||||
|
@ -395,8 +391,7 @@ SaveTool::drawCustomStyle(CustomStyle& style) {
|
|||
return return_value;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawDecalEditor(Decal& decal) {
|
||||
void SaveTool::drawDecalEditor(Decal& decal) {
|
||||
ImGui::Text("ID: %i", decal.id);
|
||||
|
||||
if(ImGui::BeginTable("##DecalTable", conf().advancedMode() ? 2 : 1, ImGuiTableFlags_BordersInnerV)) {
|
||||
|
@ -500,8 +495,7 @@ SaveTool::drawDecalEditor(Decal& decal) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view) {
|
||||
void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view) {
|
||||
if(accessory.id < 1) {
|
||||
ImGui::TextUnformatted("Accessory: <none>");
|
||||
}
|
||||
|
@ -739,8 +733,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<Custom
|
|||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
SaveTool::getStyleName(Int id, Containers::ArrayView<CustomStyle> view) {
|
||||
auto SaveTool::getStyleName(Int id, Containers::ArrayView<CustomStyle> view) -> Containers::StringView {
|
||||
if(id >= 0 && id <= 15) {
|
||||
return view[id].name;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
|
||||
#include "SaveTool.h"
|
||||
|
||||
void
|
||||
SaveTool::drawArmour() {
|
||||
void SaveTool::drawArmour() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
@ -289,8 +288,7 @@ SaveTool::drawArmour() {
|
|||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawCustomArmourStyles() {
|
||||
void SaveTool::drawCustomArmourStyles() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "../FontAwesome/IconsFontAwesome5.h"
|
||||
|
||||
#include "../Maps/StyleNames.h"
|
||||
|
||||
#include "SaveTool.h"
|
||||
|
||||
void
|
||||
SaveTool::drawFrameInfo() {
|
||||
void SaveTool::drawFrameInfo() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
@ -73,8 +73,7 @@ SaveTool::drawFrameInfo() {
|
|||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawJointSliders() {
|
||||
void SaveTool::drawJointSliders() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
@ -196,8 +195,7 @@ SaveTool::drawJointSliders() {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawFrameStyles() {
|
||||
void SaveTool::drawFrameStyles() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
@ -247,8 +245,7 @@ SaveTool::drawFrameStyles() {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawEyeColourPicker() {
|
||||
void SaveTool::drawEyeColourPicker() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
@ -281,8 +278,7 @@ SaveTool::drawEyeColourPicker() {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawCustomFrameStyles() {
|
||||
void SaveTool::drawCustomFrameStyles() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
|
||||
#include "SaveTool.h"
|
||||
|
||||
void
|
||||
SaveTool::drawWeapons() {
|
||||
void SaveTool::drawWeapons() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
_currentWeapon = nullptr;
|
||||
return;
|
||||
|
@ -255,8 +254,7 @@ SaveTool::drawWeapons() {
|
|||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<Weapon> weapons_view, bool& dirty,
|
||||
void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<Weapon> weapons_view, bool& dirty,
|
||||
Containers::StringView payload_type, Containers::StringView payload_tooltip)
|
||||
{
|
||||
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
||||
|
@ -319,8 +317,7 @@ SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<
|
|||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::drawWeaponEditor(Weapon& weapon) {
|
||||
void SaveTool::drawWeaponEditor(Weapon& weapon) {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid || !_currentWeapon) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
|
||||
extern const ImVec2 center_pivot;
|
||||
|
||||
void
|
||||
SaveTool::drawProfileManager() {
|
||||
void SaveTool::drawProfileManager() {
|
||||
static std::size_t profile_index = 0;
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
|
||||
|
@ -126,8 +125,7 @@ SaveTool::drawProfileManager() {
|
|||
ImGui::End();
|
||||
}
|
||||
|
||||
ImGuiID
|
||||
SaveTool::drawBackupListPopup() {
|
||||
auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
|
||||
if(!ImGui::BeginPopupModal("Backups##BackupsModal", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
||||
|
@ -326,8 +324,7 @@ SaveTool::drawBackupListPopup() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ImGuiID
|
||||
SaveTool::drawBackupProfilePopup(std::size_t profile_index) {
|
||||
auto SaveTool::drawBackupProfilePopup(std::size_t profile_index) -> ImGuiID {
|
||||
if(!ImGui::BeginPopupModal("Include builds ?##IncludeBuildsDialog", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
|
@ -371,8 +368,7 @@ SaveTool::drawBackupProfilePopup(std::size_t profile_index) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ImGuiID
|
||||
SaveTool::drawDeleteProfilePopup(std::size_t profile_index) {
|
||||
auto SaveTool::drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID {
|
||||
if(!ImGui::BeginPopupModal("Confirmation##DeleteProfileConfirmation", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
|
||||
#include "SaveTool.h"
|
||||
|
||||
void
|
||||
SaveTool::updateCheckEvent(SDL_Event& event) {
|
||||
void SaveTool::updateCheckEvent(SDL_Event& event) {
|
||||
_updateThread.join();
|
||||
|
||||
if(event.user.code == CurlInitFailed) {
|
||||
|
@ -124,16 +123,13 @@ SaveTool::updateCheckEvent(SDL_Event& event) {
|
|||
}
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
writeData(char* ptr, std::size_t size, std::size_t nmemb, Containers::String* buf) {
|
||||
inline auto writeData(char* ptr, std::size_t size, std::size_t nmemb, Containers::String* buf)-> std::size_t {
|
||||
if(!ptr || !buf) return 0;
|
||||
(*buf) = Utility::format("{}{}", *buf, Containers::StringView{ptr, size * nmemb});
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::checkForUpdates() {
|
||||
void SaveTool::checkForUpdates() {
|
||||
SDL_Event event;
|
||||
SDL_zero(event);
|
||||
event.type = _updateEventId;
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
|
||||
extern const ImVec2 center_pivot;
|
||||
|
||||
void
|
||||
SaveTool::drawAbout() {
|
||||
void SaveTool::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);
|
||||
|
||||
|
@ -89,7 +88,7 @@ SaveTool::drawAbout() {
|
|||
if(ImGui::BeginChild("##GPL", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
|
||||
static auto licence = _rs.getRaw("COPYING");
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(licence.begin(), licence.end());
|
||||
ImGui::TextEx(licence.data(), licence.data() + licence.size(), ImGuiTextFlags_None);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
@ -118,7 +117,7 @@ SaveTool::drawAbout() {
|
|||
static auto corrade_licence = _rs.getRaw("COPYING.Corrade");
|
||||
if(ImGui::BeginChild("##CorradeLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(corrade_licence.begin(), corrade_licence.end());
|
||||
ImGui::TextEx(corrade_licence.data(), corrade_licence.data() + corrade_licence.size(), ImGuiTextFlags_None);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
@ -146,7 +145,7 @@ SaveTool::drawAbout() {
|
|||
static auto magnum_licence = _rs.getRaw("COPYING.Magnum");
|
||||
if(ImGui::BeginChild("##MagnumLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(magnum_licence.begin(), magnum_licence.end());
|
||||
ImGui::TextEx(magnum_licence.data(), magnum_licence.data() + magnum_licence.size(), ImGuiTextFlags_None);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
@ -172,7 +171,7 @@ SaveTool::drawAbout() {
|
|||
static auto imgui_licence = _rs.getRaw("LICENSE.ImGui");
|
||||
if(ImGui::BeginChild("##ImGuiLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(imgui_licence.begin(), imgui_licence.end());
|
||||
ImGui::TextEx(imgui_licence.data(), imgui_licence.data() + imgui_licence.size(), ImGuiTextFlags_None);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
@ -198,7 +197,7 @@ SaveTool::drawAbout() {
|
|||
static auto sdl_licence = _rs.getRaw("LICENSE.SDL");
|
||||
if(ImGui::BeginChild("##SDLLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(sdl_licence.begin(), sdl_licence.end());
|
||||
ImGui::TextEx(sdl_licence.data(), sdl_licence.data() + sdl_licence.size(), ImGuiTextFlags_None);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
@ -224,7 +223,7 @@ SaveTool::drawAbout() {
|
|||
static auto libzip_licence = _rs.getRaw("LICENSE.libzip");
|
||||
if(ImGui::BeginChild("##libzipLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(libzip_licence.begin(), libzip_licence.end());
|
||||
ImGui::TextEx(libzip_licence.data(), libzip_licence.data() + libzip_licence.size(), ImGuiTextFlags_None);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
@ -249,7 +248,7 @@ SaveTool::drawAbout() {
|
|||
static auto efsw_licence = _rs.getRaw("LICENSE.efsw");
|
||||
if(ImGui::BeginChild("##efswLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(efsw_licence.begin(), efsw_licence.end());
|
||||
ImGui::TextEx(efsw_licence.data(), efsw_licence.data() + efsw_licence.size(), ImGuiTextFlags_None);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
@ -275,7 +274,7 @@ SaveTool::drawAbout() {
|
|||
static auto curl_licence = _rs.getRaw("LICENSE.curl");
|
||||
if(ImGui::BeginChild("##libcurlLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(curl_licence.begin(), curl_licence.end());
|
||||
ImGui::TextEx(curl_licence.data(), curl_licence.data() + curl_licence.size(), ImGuiTextFlags_None);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
|
||||
#include "SaveTool.h"
|
||||
|
||||
void
|
||||
SaveTool::drawMainMenu() {
|
||||
void SaveTool::drawMainMenu() {
|
||||
if(!ImGui::BeginMainMenuBar()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -37,10 +37,7 @@ constexpr Vector2 padding{20.0f, 20.0f};
|
|||
constexpr Float toast_spacing = 10.0f;
|
||||
|
||||
Toast::Toast(Type type, Containers::StringView message, std::chrono::milliseconds timeout):
|
||||
_type{type},
|
||||
_message{message},
|
||||
_timeout{timeout},
|
||||
_creationTime{std::chrono::steady_clock::now()}
|
||||
_type{type}, _message{message}, _timeout{timeout}, _creationTime{std::chrono::steady_clock::now()}
|
||||
{
|
||||
_phaseTrack = Animation::Track<UnsignedInt, Phase>{{
|
||||
{0, Phase::FadeIn},
|
||||
|
@ -50,38 +47,31 @@ Toast::Toast(Type type, Containers::StringView message, std::chrono::millisecond
|
|||
}, Math::select, Animation::Extrapolation::Constant};
|
||||
}
|
||||
|
||||
Toast::Type
|
||||
Toast::type() {
|
||||
auto Toast::type() -> Type {
|
||||
return _type;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
Toast::message() {
|
||||
auto Toast::message() -> Containers::StringView {
|
||||
return _message;
|
||||
}
|
||||
|
||||
std::chrono::milliseconds
|
||||
Toast::timeout() {
|
||||
auto Toast::timeout() -> std::chrono::milliseconds {
|
||||
return _timeout;
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::time_point
|
||||
Toast::creationTime() {
|
||||
auto Toast::creationTime() -> std::chrono::steady_clock::time_point {
|
||||
return _creationTime;
|
||||
}
|
||||
|
||||
std::chrono::milliseconds
|
||||
Toast::elapsedTime() {
|
||||
auto Toast::elapsedTime() -> std::chrono::milliseconds {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - _creationTime);
|
||||
}
|
||||
|
||||
Toast::Phase
|
||||
Toast::phase() {
|
||||
auto Toast::phase() -> Phase {
|
||||
return _phaseTrack.at(elapsedTime().count());
|
||||
}
|
||||
|
||||
Float
|
||||
Toast::opacity() {
|
||||
auto Toast::opacity() -> Float {
|
||||
Phase phase = this->phase();
|
||||
Long elapsed_time = elapsedTime().count();
|
||||
|
||||
|
@ -95,18 +85,15 @@ Toast::opacity() {
|
|||
return 1.0f;
|
||||
}
|
||||
|
||||
void
|
||||
ToastQueue::addToast(Toast&& toast) {
|
||||
void ToastQueue::addToast(Toast&& toast) {
|
||||
_toasts.push_back(std::move(toast));
|
||||
}
|
||||
|
||||
void
|
||||
ToastQueue::addToast(Toast::Type type, Containers::StringView message, std::chrono::milliseconds timeout) {
|
||||
void ToastQueue::addToast(Toast::Type type, Containers::StringView message, std::chrono::milliseconds timeout) {
|
||||
_toasts.emplace_back(type, message, timeout);
|
||||
}
|
||||
|
||||
void
|
||||
ToastQueue::draw(Vector2i viewport_size) {
|
||||
void ToastQueue::draw(Vector2i viewport_size) {
|
||||
Float height = 0.0f;
|
||||
|
||||
for(UnsignedInt i = 0; i < _toasts.size(); i++) {
|
||||
|
@ -167,7 +154,6 @@ ToastQueue::draw(Vector2i viewport_size) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ToastQueue::removeToast(Long index) {
|
||||
void ToastQueue::removeToast(Long index) {
|
||||
_toasts.erase(_toasts.begin() + index);
|
||||
}
|
||||
|
|
|
@ -46,19 +46,19 @@ 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};
|
||||
|
|
|
@ -35,89 +35,72 @@ BinaryReader::~BinaryReader() {
|
|||
closeFile();
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::open() {
|
||||
auto BinaryReader::open() -> bool {
|
||||
return _file;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::eof() {
|
||||
auto BinaryReader::eof() -> bool {
|
||||
return std::feof(_file) != 0;
|
||||
}
|
||||
|
||||
Long
|
||||
BinaryReader::position() {
|
||||
auto BinaryReader::position() -> Long {
|
||||
return _ftelli64(_file);
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::seek(Long position) {
|
||||
auto BinaryReader::seek(Long position) -> bool {
|
||||
return _fseeki64(_file, position, SEEK_SET) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
BinaryReader::closeFile() {
|
||||
void BinaryReader::closeFile() {
|
||||
std::fclose(_file);
|
||||
_file = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readChar(char& value) {
|
||||
auto BinaryReader::readChar(char& value) -> bool {
|
||||
return std::fread(&value, sizeof(char), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readByte(Byte& value) {
|
||||
auto BinaryReader::readByte(Byte& value) -> bool {
|
||||
return std::fread(&value, sizeof(Byte), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readUnsignedByte(UnsignedByte& value) {
|
||||
auto BinaryReader::readUnsignedByte(UnsignedByte& value) -> bool {
|
||||
return std::fread(&value, sizeof(UnsignedByte), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readShort(Short& value) {
|
||||
auto BinaryReader::readShort(Short& value) -> bool {
|
||||
return std::fread(&value, sizeof(Short), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readUnsignedShort(UnsignedShort& value) {
|
||||
auto BinaryReader::readUnsignedShort(UnsignedShort& value) -> bool {
|
||||
return std::fread(&value, sizeof(UnsignedShort), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readInt(Int& value) {
|
||||
auto BinaryReader::readInt(Int& value) -> bool {
|
||||
return std::fread(&value, sizeof(Int), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readUnsignedInt(UnsignedInt& value) {
|
||||
auto BinaryReader::readUnsignedInt(UnsignedInt& value) -> bool {
|
||||
return std::fread(&value, sizeof(UnsignedInt), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readLong(Long& value) {
|
||||
auto BinaryReader::readLong(Long& value) -> bool {
|
||||
return std::fread(&value, sizeof(Long), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readUnsignedLong(UnsignedLong& value) {
|
||||
auto BinaryReader::readUnsignedLong(UnsignedLong& value) -> bool {
|
||||
return std::fread(&value, sizeof(UnsignedLong), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readFloat(Float& value) {
|
||||
auto BinaryReader::readFloat(Float& value) -> bool {
|
||||
return std::fread(&value, sizeof(Float), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readDouble(Double& value) {
|
||||
auto BinaryReader::readDouble(Double& value) -> bool {
|
||||
return std::fread(&value, sizeof(Double), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readArray(Containers::Array<char>& array, std::size_t count) {
|
||||
auto BinaryReader::readArray(Containers::Array<char>& array, std::size_t count) -> bool {
|
||||
if(array.size() < count) {
|
||||
array = Containers::Array<char>{ValueInit, count};
|
||||
}
|
||||
|
@ -125,8 +108,7 @@ BinaryReader::readArray(Containers::Array<char>& array, std::size_t count) {
|
|||
return std::fread(array.data(), sizeof(char), count, _file) == count;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryReader::readUEString(Containers::String& str) {
|
||||
auto BinaryReader::readUEString(Containers::String& str) -> bool {
|
||||
UnsignedInt length = 0;
|
||||
if(!readUnsignedInt(length) || length == 0) {
|
||||
return false;
|
||||
|
@ -137,8 +119,7 @@ BinaryReader::readUEString(Containers::String& str) {
|
|||
return std::fread(str.data(), sizeof(char), length, _file) == length;
|
||||
}
|
||||
|
||||
Int
|
||||
BinaryReader::peekChar() {
|
||||
auto BinaryReader::peekChar() -> Int {
|
||||
Int c;
|
||||
c = std::fgetc(_file);
|
||||
std::ungetc(c, _file);
|
||||
|
|
|
@ -32,40 +32,40 @@ class BinaryReader {
|
|||
explicit BinaryReader(Containers::StringView filename);
|
||||
~BinaryReader();
|
||||
|
||||
bool open();
|
||||
bool eof();
|
||||
Long position();
|
||||
auto open() -> bool;
|
||||
auto eof() -> bool;
|
||||
auto position() -> Long;
|
||||
|
||||
bool seek(Long position);
|
||||
auto seek(Long position) -> bool;
|
||||
|
||||
void closeFile();
|
||||
|
||||
bool readChar(char& value);
|
||||
bool readByte(Byte& value);
|
||||
bool readUnsignedByte(UnsignedByte& value);
|
||||
bool readShort(Short& value);
|
||||
bool readUnsignedShort(UnsignedShort& value);
|
||||
bool readInt(Int& value);
|
||||
bool readUnsignedInt(UnsignedInt& value);
|
||||
bool readLong(Long& value);
|
||||
bool readUnsignedLong(UnsignedLong& value);
|
||||
bool readFloat(Float& value);
|
||||
bool readDouble(Double& value);
|
||||
bool readArray(Containers::Array<char>& array, std::size_t count);
|
||||
auto readChar(char& value) -> bool;
|
||||
auto readByte(Byte& value) -> bool;
|
||||
auto readUnsignedByte(UnsignedByte& value) -> bool;
|
||||
auto readShort(Short& value) -> bool;
|
||||
auto readUnsignedShort(UnsignedShort& value) -> bool;
|
||||
auto readInt(Int& value) -> bool;
|
||||
auto readUnsignedInt(UnsignedInt& value) -> bool;
|
||||
auto readLong(Long& value) -> bool;
|
||||
auto readUnsignedLong(UnsignedLong& value) -> bool;
|
||||
auto readFloat(Float& value) -> bool;
|
||||
auto readDouble(Double& value) -> bool;
|
||||
auto readArray(Containers::Array<char>& array, std::size_t count) -> bool;
|
||||
|
||||
template<typename T>
|
||||
bool readValue(T& value) {
|
||||
auto readValue(T& value) -> bool {
|
||||
return fread(&value, sizeof(T), 1, _file) == sizeof(T);
|
||||
}
|
||||
|
||||
template<std::size_t S>
|
||||
bool readStaticArray(Containers::StaticArray<S, char>& array) {
|
||||
auto readStaticArray(Containers::StaticArray<S, char>& array) -> bool {
|
||||
return std::fread(array.data(), sizeof(char), S, _file) == S;
|
||||
}
|
||||
|
||||
bool readUEString(Containers::String& str);
|
||||
auto readUEString(Containers::String& str) -> bool;
|
||||
|
||||
Int peekChar();
|
||||
auto peekChar() -> Int;
|
||||
|
||||
private:
|
||||
std::FILE* _file = nullptr;
|
||||
|
|
|
@ -33,35 +33,29 @@ BinaryWriter::~BinaryWriter() {
|
|||
closeFile();
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::open() {
|
||||
auto BinaryWriter::open() -> bool {
|
||||
return _file;
|
||||
}
|
||||
|
||||
void
|
||||
BinaryWriter::closeFile() {
|
||||
void BinaryWriter::closeFile() {
|
||||
std::fflush(_file);
|
||||
std::fclose(_file);
|
||||
_file = nullptr;
|
||||
}
|
||||
|
||||
Long
|
||||
BinaryWriter::position() {
|
||||
auto BinaryWriter::position() -> Long {
|
||||
return _ftelli64(_file);
|
||||
}
|
||||
|
||||
Containers::ArrayView<const char>
|
||||
BinaryWriter::array() const {
|
||||
auto BinaryWriter::array() const -> Containers::ArrayView<const char> {
|
||||
return _data;
|
||||
}
|
||||
|
||||
UnsignedLong
|
||||
BinaryWriter::arrayPosition() const {
|
||||
auto BinaryWriter::arrayPosition() const -> UnsignedLong {
|
||||
return _index;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::flushToFile() {
|
||||
auto BinaryWriter::flushToFile() -> bool {
|
||||
bool ret = writeArray(_data);
|
||||
std::fflush(_file);
|
||||
_data = Containers::Array<char>{};
|
||||
|
@ -69,63 +63,51 @@ BinaryWriter::flushToFile() {
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeChar(char value) {
|
||||
auto BinaryWriter::writeChar(char value) -> bool {
|
||||
return std::fwrite(&value, sizeof(char), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeByte(Byte value) {
|
||||
auto BinaryWriter::writeByte(Byte value) -> bool {
|
||||
return std::fwrite(&value, sizeof(Byte), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeUnsignedByte(UnsignedByte value) {
|
||||
auto BinaryWriter::writeUnsignedByte(UnsignedByte value) -> bool {
|
||||
return std::fwrite(&value, sizeof(UnsignedByte), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeShort(Short value) {
|
||||
auto BinaryWriter::writeShort(Short value) -> bool {
|
||||
return std::fwrite(&value, sizeof(Short), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeUnsignedShort(UnsignedShort value) {
|
||||
auto BinaryWriter::writeUnsignedShort(UnsignedShort value) -> bool {
|
||||
return std::fwrite(&value, sizeof(UnsignedShort), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeInt(Int value) {
|
||||
auto BinaryWriter::writeInt(Int value) -> bool {
|
||||
return std::fwrite(&value, sizeof(Int), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeUnsignedInt(UnsignedInt value) {
|
||||
auto BinaryWriter::writeUnsignedInt(UnsignedInt value) -> bool {
|
||||
return std::fwrite(&value, sizeof(UnsignedInt), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeLong(Long value) {
|
||||
auto BinaryWriter::writeLong(Long value) -> bool {
|
||||
return std::fwrite(&value, sizeof(Long), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeUnsignedLong(UnsignedLong value) {
|
||||
auto BinaryWriter::writeUnsignedLong(UnsignedLong value) -> bool {
|
||||
return std::fwrite(&value, sizeof(UnsignedLong), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeFloat(Float value) {
|
||||
auto BinaryWriter::writeFloat(Float value) -> bool {
|
||||
return std::fwrite(&value, sizeof(Float), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeDouble(Double value) {
|
||||
auto BinaryWriter::writeDouble(Double value) -> bool {
|
||||
return std::fwrite(&value, sizeof(Double), 1, _file) == 1;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeArray(Containers::ArrayView<const char> array) {
|
||||
auto BinaryWriter::writeArray(Containers::ArrayView<const char> array) -> bool {
|
||||
if(array.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -133,8 +115,7 @@ BinaryWriter::writeArray(Containers::ArrayView<const char> array) {
|
|||
return std::fwrite(array.data(), sizeof(char), array.size(), _file) == array.size();
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryWriter::writeUEString(Containers::StringView str) {
|
||||
auto BinaryWriter::writeUEString(Containers::StringView str) -> bool {
|
||||
if(str.size() > UINT32_MAX) {
|
||||
LOG_ERROR_FORMAT("String is too big. Expected size() < UINT32_MAX, got {} instead.", str.size());
|
||||
return false;
|
||||
|
@ -151,8 +132,7 @@ BinaryWriter::writeUEString(Containers::StringView str) {
|
|||
return writeChar('\0');
|
||||
}
|
||||
|
||||
UnsignedLong
|
||||
BinaryWriter::writeUEStringToArray(Containers::StringView value) {
|
||||
auto BinaryWriter::writeUEStringToArray(Containers::StringView value) -> UnsignedLong {
|
||||
return writeValueToArray<UnsignedInt>(UnsignedInt(value.size()) + 1u) +
|
||||
writeDataToArray(Containers::ArrayView<const char>{value}) +
|
||||
writeValueToArray<char>('\0');
|
||||
|
|
|
@ -39,47 +39,47 @@ class BinaryWriter {
|
|||
BinaryWriter(BinaryWriter&& other) = default;
|
||||
BinaryWriter& operator=(BinaryWriter&& other) = default;
|
||||
|
||||
bool open();
|
||||
auto open() -> bool;
|
||||
|
||||
void closeFile();
|
||||
|
||||
Long position();
|
||||
auto position() -> Long;
|
||||
|
||||
Containers::ArrayView<const char> array() const;
|
||||
UnsignedLong arrayPosition() const;
|
||||
bool flushToFile();
|
||||
auto array() const -> Containers::ArrayView<const char>;
|
||||
auto arrayPosition() const -> UnsignedLong;
|
||||
auto flushToFile() -> bool;
|
||||
|
||||
bool writeByte(Byte value);
|
||||
bool writeChar(char value);
|
||||
bool writeUnsignedByte(UnsignedByte value);
|
||||
bool writeShort(Short value);
|
||||
bool writeUnsignedShort(UnsignedShort value);
|
||||
bool writeInt(Int value);
|
||||
bool writeUnsignedInt(UnsignedInt value);
|
||||
bool writeLong(Long value);
|
||||
bool writeUnsignedLong(UnsignedLong value);
|
||||
bool writeFloat(Float value);
|
||||
bool writeDouble(Double value);
|
||||
bool writeArray(Containers::ArrayView<const char> array);
|
||||
auto writeByte(Byte value) -> bool;
|
||||
auto writeChar(char value) -> bool;
|
||||
auto writeUnsignedByte(UnsignedByte value) -> bool;
|
||||
auto writeShort(Short value) -> bool;
|
||||
auto writeUnsignedShort(UnsignedShort value) -> bool;
|
||||
auto writeInt(Int value) -> bool;
|
||||
auto writeUnsignedInt(UnsignedInt value) -> bool;
|
||||
auto writeLong(Long value) -> bool;
|
||||
auto writeUnsignedLong(UnsignedLong value) -> bool;
|
||||
auto writeFloat(Float value) -> bool;
|
||||
auto writeDouble(Double value) -> bool;
|
||||
auto writeArray(Containers::ArrayView<const char> array) -> bool;
|
||||
template<std::size_t size>
|
||||
bool writeString(const char(&str)[size]) {
|
||||
auto writeString(const char(&str)[size]) -> bool {
|
||||
return writeArray({str, size - 1});
|
||||
}
|
||||
|
||||
template<std::size_t S>
|
||||
bool writeStaticArray(Containers::StaticArrayView<S, const char> array) {
|
||||
auto writeStaticArray(Containers::StaticArrayView<S, const char> array) -> bool {
|
||||
return std::fwrite(array.data(), sizeof(char), S, _file) == S;
|
||||
}
|
||||
|
||||
bool writeUEString(Containers::StringView str);
|
||||
auto writeUEString(Containers::StringView str) -> bool;
|
||||
|
||||
template<typename T, typename U = std::conditional_t<std::is_trivially_copyable<T>::value, T, T&>>
|
||||
UnsignedLong writeValueToArray(U value) {
|
||||
auto writeValueToArray(U value) -> UnsignedLong {
|
||||
Containers::ArrayView<T> view{&value, 1};
|
||||
return writeDataToArray(view);
|
||||
}
|
||||
|
||||
UnsignedLong writeUEStringToArray(Containers::StringView value);
|
||||
auto writeUEStringToArray(Containers::StringView value) -> UnsignedLong;
|
||||
|
||||
template<typename T>
|
||||
void writeValueToArrayAt(T& value, UnsignedLong position) {
|
||||
|
@ -88,7 +88,7 @@ class BinaryWriter {
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
UnsignedLong writeDataToArray(Containers::ArrayView<T> view) {
|
||||
auto writeDataToArray(Containers::ArrayView<T> view) -> UnsignedLong {
|
||||
arrayAppend(_data, Containers::arrayCast<const char>(view));
|
||||
_index += sizeof(T) * view.size();
|
||||
return sizeof(T) * view.size();
|
||||
|
|
|
@ -22,20 +22,17 @@
|
|||
|
||||
#include "Debug.h"
|
||||
|
||||
Utility::Debug&
|
||||
operator<<(Utility::Debug& debug, const ArrayProperty* prop) {
|
||||
Utility::Debug& operator<<(Utility::Debug& debug, const 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) {
|
||||
Utility::Debug& operator<<(Utility::Debug& debug, const 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) {
|
||||
Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* prop) {
|
||||
debug << (*prop->name) << Utility::Debug::nospace << ":" <<
|
||||
prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace <<
|
||||
") Contents:";
|
||||
|
@ -45,8 +42,7 @@ operator<<(Utility::Debug& debug, const GenericStructProperty* prop) {
|
|||
return debug;
|
||||
}
|
||||
|
||||
Utility::Debug&
|
||||
operator<<(Utility::Debug& debug, const StructProperty* prop) {
|
||||
Utility::Debug& operator<<(Utility::Debug& debug, const StructProperty* prop) {
|
||||
auto cast = dynamic_cast<const GenericStructProperty*>(prop);
|
||||
if(cast) {
|
||||
return debug << cast;
|
||||
|
@ -56,8 +52,7 @@ operator<<(Utility::Debug& debug, const StructProperty* prop) {
|
|||
prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace << ")";
|
||||
}
|
||||
|
||||
Utility::Debug&
|
||||
operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop) {
|
||||
Utility::Debug& operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop) {
|
||||
if(prop->propertyType == "ArrayProperty") {
|
||||
auto array_prop = dynamic_cast<const ArrayProperty*>(prop);
|
||||
if(array_prop) {
|
||||
|
|
|
@ -67,14 +67,12 @@ PropertySerialiser::PropertySerialiser() {
|
|||
arrayAppend(_collectionSerialisers, Containers::pointer<StructSerialiser>());
|
||||
}
|
||||
|
||||
PropertySerialiser&
|
||||
PropertySerialiser::instance() {
|
||||
auto PropertySerialiser::instance() -> PropertySerialiser& {
|
||||
static PropertySerialiser serialiser;
|
||||
return serialiser;
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
PropertySerialiser::read(BinaryReader& reader) {
|
||||
auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr {
|
||||
if(reader.peekChar() < 0 || reader.eof()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -101,10 +99,8 @@ PropertySerialiser::read(BinaryReader& reader) {
|
|||
return deserialise(std::move(name), std::move(type), value_length, reader);
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length,
|
||||
Containers::String name)
|
||||
{
|
||||
auto PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length,
|
||||
Containers::String name) -> UnrealPropertyBase::ptr {
|
||||
if(reader.peekChar() < 0 || reader.eof()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -112,8 +108,9 @@ PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, Unsi
|
|||
return deserialise(std::move(name), std::move(type), value_length, reader);
|
||||
}
|
||||
|
||||
Containers::Array<UnrealPropertyBase::ptr>
|
||||
PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, UnsignedInt count) {
|
||||
auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type,
|
||||
UnsignedInt count) -> Containers::Array<UnrealPropertyBase::ptr>
|
||||
{
|
||||
if(reader.peekChar() < 0 || reader.eof()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -156,9 +153,8 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty
|
|||
return array;
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
PropertySerialiser::deserialise(Containers::String name, Containers::String type, UnsignedLong value_length,
|
||||
BinaryReader& reader)
|
||||
auto PropertySerialiser::deserialise(Containers::String name, Containers::String type, UnsignedLong value_length,
|
||||
BinaryReader& reader) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
UnrealPropertyBase::ptr prop;
|
||||
auto serialiser = getSerialiser(type);
|
||||
|
@ -180,8 +176,8 @@ PropertySerialiser::deserialise(Containers::String name, Containers::String type
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer)
|
||||
auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool
|
||||
{
|
||||
auto serialiser = getSerialiser(item_type);
|
||||
if(!serialiser) {
|
||||
|
@ -190,8 +186,7 @@ bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St
|
|||
return serialiser->serialise(prop, bytes_written, writer, *this);
|
||||
}
|
||||
|
||||
bool
|
||||
PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) {
|
||||
auto PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool {
|
||||
if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) {
|
||||
bytes_written += writer.writeUEStringToArray(*prop->name);
|
||||
return true;
|
||||
|
@ -214,9 +209,8 @@ PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_wri
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer)
|
||||
auto PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool
|
||||
{
|
||||
if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) {
|
||||
bytes_written += writer.writeUEStringToArray(*prop->name);
|
||||
|
@ -226,8 +220,9 @@ PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringV
|
|||
return serialise(prop, item_type, bytes_written, writer);
|
||||
}
|
||||
|
||||
bool PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props,
|
||||
Containers::StringView item_type, UnsignedLong& bytes_written, BinaryWriter& writer)
|
||||
auto PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props,
|
||||
Containers::StringView item_type, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer) -> bool
|
||||
{
|
||||
auto serialiser = getCollectionSerialiser(item_type);
|
||||
if(serialiser) {
|
||||
|
@ -244,8 +239,7 @@ bool PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr>
|
|||
}
|
||||
}
|
||||
|
||||
AbstractUnrealPropertySerialiser*
|
||||
PropertySerialiser::getSerialiser(Containers::StringView item_type) {
|
||||
auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser* {
|
||||
for(auto& item : _serialisers) {
|
||||
for(auto serialiser_type : item->types()) {
|
||||
if(item_type == serialiser_type) {
|
||||
|
@ -257,8 +251,7 @@ PropertySerialiser::getSerialiser(Containers::StringView item_type) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
AbstractUnrealCollectionPropertySerialiser*
|
||||
PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) {
|
||||
auto PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) -> AbstractUnrealCollectionPropertySerialiser* {
|
||||
for(auto& item : _collectionSerialisers) {
|
||||
for(Containers::StringView serialiser_type : item->types()) {
|
||||
if(item_type == serialiser_type) {
|
||||
|
|
|
@ -32,29 +32,28 @@ class BinaryWriter;
|
|||
|
||||
class PropertySerialiser {
|
||||
public:
|
||||
static PropertySerialiser& instance();
|
||||
static auto instance() -> PropertySerialiser&;
|
||||
|
||||
UnrealPropertyBase::ptr read(BinaryReader& reader);
|
||||
UnrealPropertyBase::ptr readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length,
|
||||
Containers::String name);
|
||||
Containers::Array<UnrealPropertyBase::ptr> readSet(BinaryReader& reader, Containers::StringView item_type,
|
||||
UnsignedInt count);
|
||||
UnrealPropertyBase::ptr deserialise(Containers::String name, Containers::String type, UnsignedLong value_length,
|
||||
BinaryReader& reader);
|
||||
auto read(BinaryReader& reader) -> UnrealPropertyBase::ptr;
|
||||
auto readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length,
|
||||
Containers::String name) -> UnrealPropertyBase::ptr;
|
||||
auto readSet(BinaryReader& reader, Containers::StringView item_type, UnsignedInt count) -> Containers::Array<UnrealPropertyBase::ptr>;
|
||||
auto deserialise(Containers::String name, Containers::String type, UnsignedLong value_length,
|
||||
BinaryReader& reader) -> UnrealPropertyBase::ptr;
|
||||
|
||||
bool serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer);
|
||||
bool write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer);
|
||||
bool writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer);
|
||||
bool writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer);
|
||||
auto serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer) -> bool;
|
||||
auto write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool;
|
||||
auto writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer) -> bool;
|
||||
auto writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool;
|
||||
|
||||
private:
|
||||
PropertySerialiser();
|
||||
|
||||
AbstractUnrealPropertySerialiser* getSerialiser(Containers::StringView item_type);
|
||||
AbstractUnrealCollectionPropertySerialiser* getCollectionSerialiser(Containers::StringView item_type);
|
||||
auto getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser*;
|
||||
auto getCollectionSerialiser(Containers::StringView item_type) -> AbstractUnrealCollectionPropertySerialiser*;
|
||||
|
||||
Containers::Array<AbstractUnrealPropertySerialiser::ptr> _serialisers;
|
||||
Containers::Array<AbstractUnrealCollectionPropertySerialiser::ptr> _collectionSerialisers;
|
||||
|
|
|
@ -32,20 +32,17 @@ class BinaryReader;
|
|||
class BinaryWriter;
|
||||
class PropertySerialiser;
|
||||
|
||||
using PropertyArray = Containers::Array<UnrealPropertyBase::ptr>;
|
||||
using PropertyArrayView = Containers::ArrayView<UnrealPropertyBase::ptr>;
|
||||
|
||||
class AbstractUnrealCollectionPropertySerialiser {
|
||||
public:
|
||||
using ptr = Containers::Pointer<AbstractUnrealCollectionPropertySerialiser>;
|
||||
|
||||
virtual ~AbstractUnrealCollectionPropertySerialiser() = default;
|
||||
|
||||
virtual StringArrayView types() = 0;
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
|
||||
|
||||
virtual PropertyArray deserialise(Containers::StringView name, Containers::StringView type,
|
||||
virtual auto deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, UnsignedInt count, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) = 0;
|
||||
PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> = 0;
|
||||
|
||||
virtual auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0;
|
||||
|
|
|
@ -31,20 +31,17 @@ class BinaryReader;
|
|||
class BinaryWriter;
|
||||
class PropertySerialiser;
|
||||
|
||||
using StringArrayView = Containers::ArrayView<const Containers::String>;
|
||||
|
||||
class AbstractUnrealPropertySerialiser {
|
||||
public:
|
||||
using ptr = Containers::Pointer<AbstractUnrealPropertySerialiser>;
|
||||
|
||||
virtual ~AbstractUnrealPropertySerialiser() = default;
|
||||
|
||||
virtual StringArrayView types() = 0;
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
|
||||
|
||||
virtual UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) = 0;
|
||||
virtual auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr = 0;
|
||||
|
||||
virtual bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) = 0;
|
||||
virtual auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool = 0;
|
||||
};
|
||||
|
|
|
@ -37,10 +37,10 @@ class AbstractUnrealStructSerialiser {
|
|||
|
||||
virtual ~AbstractUnrealStructSerialiser() = default;
|
||||
|
||||
virtual bool supportsType(Containers::StringView type) = 0;
|
||||
virtual auto supportsType(Containers::StringView type) -> bool = 0;
|
||||
|
||||
virtual UnrealPropertyBase::ptr deserialise(BinaryReader& reader) = 0;
|
||||
virtual auto deserialise(BinaryReader& reader) -> UnrealPropertyBase::ptr = 0;
|
||||
|
||||
virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer,
|
||||
UnsignedLong& bytes_written) = 0;
|
||||
virtual auto serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer,
|
||||
UnsignedLong& bytes_written) -> bool = 0;
|
||||
};
|
||||
|
|
|
@ -23,10 +23,9 @@
|
|||
|
||||
#include "ArrayPropertySerialiser.h"
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
Containers::String item_type;
|
||||
if(!reader.readUEString(item_type)) {
|
||||
|
@ -53,9 +52,8 @@ ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Contai
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto array_prop = dynamic_cast<ArrayProperty*>(prop.get());
|
||||
if(!array_prop) {
|
||||
|
|
|
@ -32,9 +32,8 @@ class ArrayPropertySerialiser : public UnrealPropertySerialiser<ArrayProperty> {
|
|||
using ptr = Containers::Pointer<ArrayPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,16 +20,15 @@
|
|||
|
||||
#include "BoolPropertySerialiser.h"
|
||||
|
||||
StringArrayView
|
||||
BoolPropertySerialiser::types() {
|
||||
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"BoolProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser)
|
||||
auto BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
if(value_length != 0) {
|
||||
LOG_ERROR_FORMAT("Invalid value length for bool property {}. Expected 0, got {} instead.", name, value_length);
|
||||
|
@ -53,9 +52,8 @@ BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::Str
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser)
|
||||
auto BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto bool_prop = dynamic_cast<BoolProperty*>(prop.get());
|
||||
if(!bool_prop) {
|
||||
|
|
|
@ -29,12 +29,11 @@ class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<BoolPropertySerialiser>;
|
||||
|
||||
StringArrayView types() override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
||||
bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,16 +20,15 @@
|
|||
|
||||
#include "BytePropertySerialiser.h"
|
||||
|
||||
StringArrayView
|
||||
BytePropertySerialiser::types() {
|
||||
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"ByteProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser)
|
||||
auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<ByteProperty>();
|
||||
|
||||
|
@ -65,9 +64,8 @@ BytePropertySerialiser::deserialise(Containers::StringView name, Containers::Str
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser)
|
||||
auto BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto byte_prop = dynamic_cast<ByteProperty*>(prop.get());
|
||||
if(!byte_prop) {
|
||||
|
|
|
@ -27,12 +27,11 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<BytePropertySerialiser>;
|
||||
|
||||
StringArrayView types() override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
||||
bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
|
||||
#include "ColourPropertySerialiser.h"
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<ColourStructProperty>();
|
||||
|
||||
|
@ -37,9 +36,8 @@ ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Conta
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto colour_prop = dynamic_cast<ColourStructProperty*>(prop.get());
|
||||
if(!colour_prop) {
|
||||
|
@ -47,10 +45,8 @@ ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsig
|
|||
return false;
|
||||
}
|
||||
|
||||
bytes_written += writer.writeValueToArray<Float>(colour_prop->r) +
|
||||
writer.writeValueToArray<Float>(colour_prop->g) +
|
||||
writer.writeValueToArray<Float>(colour_prop->b) +
|
||||
writer.writeValueToArray<Float>(colour_prop->a);
|
||||
bytes_written += writer.writeValueToArray<Float>(colour_prop->r) + writer.writeValueToArray<Float>(colour_prop->g) +
|
||||
writer.writeValueToArray<Float>(colour_prop->b) + writer.writeValueToArray<Float>(colour_prop->a);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,9 +29,8 @@ class ColourPropertySerialiser : public UnrealPropertySerialiser<ColourStructPro
|
|||
using ptr = Containers::Pointer<ColourPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
|
||||
#include "DateTimePropertySerialiser.h"
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<DateTimeStructProperty>();
|
||||
|
||||
|
@ -35,9 +34,8 @@ DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Con
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto dt_prop = dynamic_cast<DateTimeStructProperty*>(prop.get());
|
||||
if(!dt_prop) {
|
||||
|
|
|
@ -27,9 +27,8 @@ class DateTimePropertySerialiser : public UnrealPropertySerialiser<DateTimeStruc
|
|||
using ptr = Containers::Pointer<DateTimePropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,16 +20,15 @@
|
|||
|
||||
#include "EnumPropertySerialiser.h"
|
||||
|
||||
StringArrayView
|
||||
EnumPropertySerialiser::types() {
|
||||
auto EnumPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"EnumProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser)
|
||||
auto EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<EnumProperty>();
|
||||
|
||||
|
@ -52,9 +51,8 @@ EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::Str
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser)
|
||||
auto EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto enum_prop = dynamic_cast<EnumProperty*>(prop.get());
|
||||
if(!enum_prop) {
|
||||
|
|
|
@ -27,12 +27,11 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<EnumPropertySerialiser>;
|
||||
|
||||
StringArrayView types() override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
||||
bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,16 +20,15 @@
|
|||
|
||||
#include "FloatPropertySerialiser.h"
|
||||
|
||||
StringArrayView
|
||||
FloatPropertySerialiser::types() {
|
||||
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"FloatProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser)
|
||||
auto FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<FloatProperty>();
|
||||
|
||||
|
@ -47,9 +46,8 @@ FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::St
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser)
|
||||
auto FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto float_prop = dynamic_cast<FloatProperty*>(prop.get());
|
||||
if(!float_prop) {
|
||||
|
|
|
@ -27,12 +27,11 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<FloatPropertySerialiser>;
|
||||
|
||||
StringArrayView types() override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
||||
bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -22,10 +22,9 @@
|
|||
|
||||
using namespace Containers::Literals;
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<GuidStructProperty>();
|
||||
|
||||
|
@ -37,9 +36,8 @@ GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto guid_prop = dynamic_cast<GuidStructProperty*>(prop.get());
|
||||
if(!guid_prop) {
|
||||
|
|
|
@ -27,9 +27,8 @@ class GuidPropertySerialiser : public UnrealPropertySerialiser<GuidStructPropert
|
|||
using ptr = Containers::Pointer<GuidPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
|
||||
#include "IntPropertySerialiser.h"
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<IntProperty>();
|
||||
|
||||
|
@ -53,9 +52,8 @@ IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto int_prop = dynamic_cast<IntProperty*>(prop.get());
|
||||
if(!int_prop) {
|
||||
|
|
|
@ -27,9 +27,8 @@ class IntPropertySerialiser : public UnrealPropertySerialiser<IntProperty> {
|
|||
using ptr = Containers::Pointer<IntPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -24,10 +24,9 @@
|
|||
|
||||
using namespace Containers::Literals;
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<MapProperty>();
|
||||
|
||||
|
@ -108,9 +107,8 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto map_prop = dynamic_cast<MapProperty*>(prop.get());
|
||||
if(!map_prop) {
|
||||
|
|
|
@ -27,9 +27,8 @@ class MapPropertySerialiser : public UnrealPropertySerialiser<MapProperty> {
|
|||
using ptr = Containers::Pointer<MapPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -25,10 +25,9 @@
|
|||
|
||||
using namespace Containers::Literals;
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<ResourceItemValue>();
|
||||
|
||||
|
@ -78,9 +77,8 @@ ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Con
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto res_prop = dynamic_cast<ResourceItemValue*>(prop.get());
|
||||
if(!res_prop) {
|
||||
|
|
|
@ -27,9 +27,8 @@ class ResourcePropertySerialiser : public UnrealPropertySerialiser<ResourceItemV
|
|||
using ptr = Containers::Pointer<ResourcePropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
|
||||
#include "RotatorPropertySerialiser.h"
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<RotatorStructProperty>();
|
||||
|
||||
|
@ -35,9 +34,8 @@ RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Cont
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto rotator = dynamic_cast<RotatorStructProperty*>(prop.get());
|
||||
if(!rotator) {
|
||||
|
|
|
@ -27,9 +27,8 @@ class RotatorPropertySerialiser : public UnrealPropertySerialiser<RotatorStructP
|
|||
using ptr = Containers::Pointer<RotatorPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
|
||||
#include "SetPropertySerialiser.h"
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
Containers::String item_type;
|
||||
if(!reader.readUEString(item_type)) {
|
||||
|
@ -57,9 +56,8 @@ SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto set_prop = dynamic_cast<SetProperty*>(prop.get());
|
||||
if(!set_prop) {
|
||||
|
|
|
@ -27,9 +27,8 @@ class SetPropertySerialiser : public UnrealPropertySerialiser<SetProperty> {
|
|||
using ptr = Containers::Pointer<SetPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,18 +20,17 @@
|
|||
|
||||
#include "StringPropertySerialiser.h"
|
||||
|
||||
StringArrayView
|
||||
StringPropertySerialiser::types() {
|
||||
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {
|
||||
"NameProperty"_s, "StrProperty"_s, "SoftObjectProperty"_s, "ObjectProperty"_s
|
||||
}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit,
|
||||
{"NameProperty"_s, "StrProperty"_s,
|
||||
"SoftObjectProperty"_s, "ObjectProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser)
|
||||
auto StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<StringProperty>(type);
|
||||
|
||||
|
@ -53,9 +52,8 @@ StringPropertySerialiser::deserialise(Containers::StringView name, Containers::S
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser)
|
||||
auto StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto str_prop = dynamic_cast<StringProperty*>(prop.get());
|
||||
if(!str_prop) {
|
||||
|
|
|
@ -27,12 +27,11 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<StringPropertySerialiser>;
|
||||
|
||||
StringArrayView types() override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
||||
bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -25,16 +25,14 @@
|
|||
|
||||
#include "StructSerialiser.h"
|
||||
|
||||
StringArrayView
|
||||
StructSerialiser::types() {
|
||||
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"StructProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
Containers::Array<UnrealPropertyBase::ptr>
|
||||
StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser)
|
||||
auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr>
|
||||
{
|
||||
Containers::String item_type;
|
||||
if(!reader.readUEString(item_type)) {
|
||||
|
@ -85,9 +83,8 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie
|
|||
return array;
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser)
|
||||
auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
Containers::String item_type;
|
||||
if(!reader.readUEString(item_type)) {
|
||||
|
@ -123,9 +120,8 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
bytes_written += writer.writeUEStringToArray(*(props.front()->name));
|
||||
bytes_written += writer.writeUEStringToArray(item_type);
|
||||
|
@ -167,9 +163,8 @@ StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser)
|
||||
auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto struct_prop = dynamic_cast<StructProperty*>(prop.get());
|
||||
if(!struct_prop) {
|
||||
|
@ -194,9 +189,8 @@ StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_w
|
|||
return true;
|
||||
}
|
||||
|
||||
StructProperty::ptr
|
||||
StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser)
|
||||
auto StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr
|
||||
{
|
||||
auto st_prop = Containers::pointer<GenericStructProperty>();
|
||||
st_prop->structType = type;
|
||||
|
@ -218,9 +212,8 @@ StructSerialiser::readStructValue(Containers::StringView name, Containers::Strin
|
|||
return st_prop;
|
||||
}
|
||||
|
||||
bool
|
||||
StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser)
|
||||
auto StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto struct_prop = dynamic_cast<GenericStructProperty*>(prop);
|
||||
if(!struct_prop) {
|
||||
|
|
|
@ -29,23 +29,20 @@ class StructSerialiser : public AbstractUnrealPropertySerialiser, public Abstrac
|
|||
public:
|
||||
using ptr = Containers::Pointer<StructSerialiser>;
|
||||
|
||||
StringArrayView types() override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
PropertyArray deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) override;
|
||||
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> override;
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
||||
bool serialise(PropertyArrayView props, Containers::StringView item_type, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) override;
|
||||
bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
|
||||
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
|
||||
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
|
||||
|
||||
private:
|
||||
StructProperty::ptr readStructValue(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser);
|
||||
bool writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser);
|
||||
auto readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr;
|
||||
auto writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool;
|
||||
};
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
|
||||
#include "TextPropertySerialiser.h"
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<TextProperty>();
|
||||
|
||||
|
@ -69,9 +68,8 @@ TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto text_prop = dynamic_cast<TextProperty*>(prop.get());
|
||||
|
||||
|
|
|
@ -27,9 +27,8 @@ class TextPropertySerialiser : public UnrealPropertySerialiser<TextProperty> {
|
|||
using ptr = Containers::Pointer<TextPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -32,14 +32,12 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<UnrealPropertySerialiser<T>>;
|
||||
|
||||
StringArrayView types() override {
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override {
|
||||
static const Containers::Array<Containers::String> types = []{
|
||||
Containers::Array<Containers::String> array;
|
||||
Containers::Pointer<T> p(new T);
|
||||
if(std::is_base_of<StructProperty, T>::value) {
|
||||
array = Containers::Array<Containers::String>{InPlaceInit, {
|
||||
dynamic_cast<StructProperty*>(p.get())->structType
|
||||
}};
|
||||
array = Containers::Array<Containers::String>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}};
|
||||
}
|
||||
else {
|
||||
array = Containers::Array<Containers::String>{InPlaceInit, {p->propertyType}};
|
||||
|
@ -49,24 +47,23 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
return types;
|
||||
}
|
||||
|
||||
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override
|
||||
{
|
||||
return deserialiseProperty(name, type, value_length, reader, serialiser);
|
||||
}
|
||||
|
||||
bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override
|
||||
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override
|
||||
{
|
||||
return serialiseProperty(prop, bytes_written, writer, serialiser);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
virtual auto deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) = 0;
|
||||
PropertySerialiser& serialiser) -> typename UnrealPropertyBase::ptr = 0;
|
||||
|
||||
virtual bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) = 0;
|
||||
virtual auto serialiseProperty(typename UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0;
|
||||
};
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
|
||||
#include "Vector2DPropertySerialiser.h"
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<Vector2DStructProperty>();
|
||||
|
||||
|
@ -35,9 +34,8 @@ Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto vector = dynamic_cast<Vector2DStructProperty*>(prop.get());
|
||||
if(!vector) {
|
||||
|
|
|
@ -27,9 +27,8 @@ class Vector2DPropertySerialiser : public UnrealPropertySerialiser<Vector2DStruc
|
|||
using ptr = Containers::Pointer<Vector2DPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
|
||||
#include "VectorPropertySerialiser.h"
|
||||
|
||||
UnrealPropertyBase::ptr
|
||||
VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
auto VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser)
|
||||
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<VectorStructProperty>();
|
||||
|
||||
|
@ -35,9 +34,8 @@ VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Conta
|
|||
return prop;
|
||||
}
|
||||
|
||||
bool
|
||||
VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser)
|
||||
auto VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto vector = dynamic_cast<VectorStructProperty*>(prop.get());
|
||||
if(!vector) {
|
||||
|
|
|
@ -27,9 +27,8 @@ class VectorPropertySerialiser : public UnrealPropertySerialiser<VectorStructPro
|
|||
using ptr = Containers::Pointer<VectorPropertySerialiser>;
|
||||
|
||||
private:
|
||||
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, BinaryReader& reader,
|
||||
PropertySerialiser& serialiser) override;
|
||||
bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) override;
|
||||
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
|
||||
PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
||||
|
|
|
@ -45,7 +45,7 @@ struct GenericStructProperty : public StructProperty {
|
|||
atMove(Containers::StringView name) {
|
||||
for(auto& item : properties) {
|
||||
if(item && item->name == name) {
|
||||
return Containers::pointerCast<T>(std::move(item));
|
||||
return Containers::Pointer<T>{static_cast<T*>(item.release())};
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
@ -33,18 +33,15 @@ UESaveFile::UESaveFile(Containers::String filepath):
|
|||
loadData();
|
||||
}
|
||||
|
||||
bool
|
||||
UESaveFile::valid() const {
|
||||
auto UESaveFile::valid() const -> bool {
|
||||
return _valid;
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
UESaveFile::lastError() const {
|
||||
auto UESaveFile::lastError() const -> Containers::StringView {
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
bool
|
||||
UESaveFile::reloadData() {
|
||||
auto UESaveFile::reloadData() -> bool {
|
||||
if(_noReloadAfterSave) {
|
||||
_noReloadAfterSave = false;
|
||||
return valid();
|
||||
|
@ -55,25 +52,21 @@ UESaveFile::reloadData() {
|
|||
return valid();
|
||||
}
|
||||
|
||||
Containers::StringView
|
||||
UESaveFile::saveType() {
|
||||
auto UESaveFile::saveType() -> Containers::StringView {
|
||||
return _saveType;
|
||||
}
|
||||
|
||||
void
|
||||
UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) {
|
||||
void UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) {
|
||||
auto none_prop = std::move(_properties.back());
|
||||
_properties.back() = std::move(prop);
|
||||
arrayAppend(_properties, std::move(none_prop));
|
||||
}
|
||||
|
||||
Containers::ArrayView<UnrealPropertyBase::ptr>
|
||||
UESaveFile::props() {
|
||||
auto UESaveFile::props() -> Containers::ArrayView<UnrealPropertyBase::ptr> {
|
||||
return _properties;
|
||||
}
|
||||
|
||||
bool
|
||||
UESaveFile::saveToFile() {
|
||||
auto UESaveFile::saveToFile() -> bool {
|
||||
LOG_INFO_FORMAT("Writing to {}.", _filepath);
|
||||
|
||||
bool temp_file = _filepath.hasSuffix(".tmp");
|
||||
|
@ -162,8 +155,7 @@ UESaveFile::saveToFile() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
UESaveFile::loadData() {
|
||||
void UESaveFile::loadData() {
|
||||
LOG_INFO_FORMAT("Reading data from {}.", _filepath);
|
||||
|
||||
_valid = false;
|
||||
|
|
|
@ -36,12 +36,12 @@ class UESaveFile {
|
|||
public:
|
||||
explicit UESaveFile(Containers::String filepath);
|
||||
|
||||
bool valid() const;
|
||||
Containers::StringView lastError() const;
|
||||
auto valid() const -> bool;
|
||||
auto lastError() const -> Containers::StringView;
|
||||
|
||||
bool reloadData();
|
||||
auto reloadData() -> bool;
|
||||
|
||||
Containers::StringView saveType();
|
||||
auto saveType() -> Containers::StringView;
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, T*>
|
||||
|
@ -56,9 +56,9 @@ class UESaveFile {
|
|||
|
||||
void appendProperty(UnrealPropertyBase::ptr prop);
|
||||
|
||||
Containers::ArrayView<UnrealPropertyBase::ptr> props();
|
||||
auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr>;
|
||||
|
||||
bool saveToFile();
|
||||
auto saveToFile() -> bool;
|
||||
|
||||
private:
|
||||
void loadData();
|
||||
|
|
Loading…
Reference in a new issue