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