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