1.5: Fuckin' UE5... #38

Manually merged
williamjcm merged 126 commits from one-point-five into master 2024-07-22 11:06:13 +02:00
80 changed files with 1079 additions and 715 deletions
Showing only changes of commit 3c2cb001ff - Show all commits

View file

@ -49,7 +49,7 @@ class Logger {
Logger(Logger&&) = delete; Logger(Logger&&) = delete;
Logger& operator=(Logger&&) = delete; Logger& operator=(Logger&&) = delete;
static auto instance() -> Logger&; static Logger& instance();
void initialise(); void initialise();
@ -73,7 +73,7 @@ class Logger {
std::mutex _logMutex{}; std::mutex _logMutex{};
}; };
auto logger() -> Logger&; Logger& logger();
#define LOG(entry_type, message) logger().lockMutex(); \ #define LOG(entry_type, message) logger().lockMutex(); \
logger().log(EntryType::entry_type, \ logger().log(EntryType::entry_type, \

View file

@ -16,7 +16,12 @@
#include "MagnumLogBuffer.h" #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; MagnumLogBuffer::~MagnumLogBuffer() = default;

View file

@ -42,11 +42,13 @@ Mass::Mass(Containers::StringView path) {
refreshValues(); refreshValues();
} }
auto Mass::lastError() -> Containers::StringView { Containers::StringView
Mass::lastError() {
return _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)) { if(!Utility::Path::exists(path)) {
LOG_ERROR_FORMAT("{} couldn't be found.", path); LOG_ERROR_FORMAT("{} couldn't be found.", path);
return Containers::NullOpt; return Containers::NullOpt;
@ -76,7 +78,8 @@ auto Mass::getNameFromFile(Containers::StringView path) -> Containers::Optional<
return {name_prop->value}; return {name_prop->value};
} }
void Mass::refreshValues() { void
Mass::refreshValues() {
LOG_INFO_FORMAT("Refreshing values for {}.", _filename); LOG_INFO_FORMAT("Refreshing values for {}.", _filename);
logger().lockMutex(); logger().lockMutex();
@ -229,16 +232,19 @@ void Mass::refreshValues() {
_state = State::Valid; _state = State::Valid;
} }
auto Mass::filename() -> Containers::StringView { Containers::StringView
Mass::filename() {
return _filename; return _filename;
} }
auto Mass::name() -> Containers::StringView { Containers::StringView
Mass::name() {
CORRADE_INTERNAL_ASSERT(_name); CORRADE_INTERNAL_ASSERT(_name);
return *_name; return *_name;
} }
auto Mass::setName(Containers::StringView new_name) -> bool { bool
Mass::setName(Containers::StringView new_name) {
_name = {new_name}; _name = {new_name};
auto unit_data = _mass->at<GenericStructProperty>("UnitData"_s); auto unit_data = _mass->at<GenericStructProperty>("UnitData"_s);
@ -267,19 +273,22 @@ auto Mass::setName(Containers::StringView new_name) -> bool {
return true; return true;
} }
auto Mass::state() -> State { Mass::State
Mass::state() {
return _state; return _state;
} }
auto Mass::dirty() const -> bool { bool Mass::dirty() const {
return _dirty; return _dirty;
} }
void Mass::setDirty(bool dirty) { void
Mass::setDirty(bool dirty) {
_dirty = dirty; _dirty = dirty;
} }
void Mass::getTuning() { void
Mass::getTuning() {
getTuningCategory(MASS_ENGINE, _tuning.engineId, getTuningCategory(MASS_ENGINE, _tuning.engineId,
MASS_GEARS, _tuning.gearIds); MASS_GEARS, _tuning.gearIds);
if(_state == State::Invalid) { if(_state == State::Invalid) {
@ -299,35 +308,43 @@ void Mass::getTuning() {
} }
} }
auto Mass::engine() -> Int& { Int&
Mass::engine() {
return _tuning.engineId; return _tuning.engineId;
} }
auto Mass::gears() -> Containers::ArrayView<Int> { Containers::ArrayView<Int>
Mass::gears() {
return _tuning.gearIds; return _tuning.gearIds;
} }
auto Mass::os() -> Int& { Int&
Mass::os() {
return _tuning.osId; return _tuning.osId;
} }
auto Mass::modules() -> Containers::ArrayView<Int> { Containers::ArrayView<Int>
Mass::modules() {
return _tuning.moduleIds; return _tuning.moduleIds;
} }
auto Mass::architecture() -> Int& { Int&
Mass::architecture() {
return _tuning.archId; return _tuning.archId;
} }
auto Mass::techs() -> Containers::ArrayView<Int> { Containers::ArrayView<Int>
Mass::techs() {
return _tuning.techIds; return _tuning.techIds;
} }
auto Mass::account() -> Containers::StringView { Containers::StringView
Mass::account() {
return _account; return _account;
} }
auto Mass::updateAccount(Containers::StringView new_account) -> bool { bool
Mass::updateAccount(Containers::StringView new_account) {
_account = new_account; _account = new_account;
auto account = _mass->at<StringProperty>(MASS_ACCOUNT); auto account = _mass->at<StringProperty>(MASS_ACCOUNT);
@ -347,7 +364,8 @@ auto Mass::updateAccount(Containers::StringView new_account) -> bool {
return true; 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) Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids)
{ {
LOG_INFO_FORMAT("Getting tuning data ({}, {}).", big_node_prop_name, small_nodes_prop_name); LOG_INFO_FORMAT("Getting tuning data ({}, {}).", big_node_prop_name, small_nodes_prop_name);

View file

@ -45,10 +45,6 @@ struct ArrayProperty;
class Mass { class Mass {
public: public:
enum class State : UnsignedByte {
Empty, Invalid, Valid
};
explicit Mass(Containers::StringView path); explicit Mass(Containers::StringView path);
Mass(const Mass&) = delete; Mass(const Mass&) = delete;
@ -57,96 +53,100 @@ class Mass {
Mass(Mass&&) = default; Mass(Mass&&) = default;
Mass& operator=(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(); void refreshValues();
auto filename() -> Containers::StringView; Containers::StringView filename();
auto name() -> Containers::StringView; Containers::StringView name();
auto setName(Containers::StringView new_name) -> bool; 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); void setDirty(bool dirty = true);
auto jointSliders() -> Joints&; Joints& jointSliders();
void getJointSliders(); void getJointSliders();
auto writeJointSliders() -> bool; bool writeJointSliders();
auto frameStyles() -> Containers::ArrayView<Int>; Containers::ArrayView<Int> frameStyles();
void getFrameStyles(); void getFrameStyles();
auto writeFrameStyles() -> bool; bool writeFrameStyles();
auto eyeFlareColour() -> Color4&; Color4& eyeFlareColour();
void getEyeFlareColour(); void getEyeFlareColour();
auto writeEyeFlareColour() -> bool; bool writeEyeFlareColour();
auto frameCustomStyles() -> Containers::ArrayView<CustomStyle>; Containers::ArrayView<CustomStyle> frameCustomStyles();
void getFrameCustomStyles(); void getFrameCustomStyles();
auto writeFrameCustomStyle(UnsignedLong index) -> bool; bool writeFrameCustomStyle(UnsignedLong index);
auto armourParts() -> Containers::ArrayView<ArmourPart>; Containers::ArrayView<ArmourPart> armourParts();
void getArmourParts(); void getArmourParts();
auto writeArmourPart(ArmourSlot slot) -> bool; bool writeArmourPart(ArmourSlot slot);
auto bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle&; BulletLauncherAttachmentStyle& bulletLauncherAttachmentStyle();
auto bulletLauncherAttachments() -> Containers::ArrayView<BulletLauncherAttachment>; Containers::ArrayView<BulletLauncherAttachment> bulletLauncherAttachments();
void getBulletLauncherAttachments(); void getBulletLauncherAttachments();
auto writeBulletLauncherAttachments() -> bool; bool writeBulletLauncherAttachments();
auto armourCustomStyles() -> Containers::ArrayView<CustomStyle>; Containers::ArrayView<CustomStyle> armourCustomStyles();
void getArmourCustomStyles(); void getArmourCustomStyles();
auto writeArmourCustomStyle(UnsignedLong index) -> bool; bool writeArmourCustomStyle(UnsignedLong index);
auto meleeWeapons() -> Containers::ArrayView<Weapon>; Containers::ArrayView<Weapon> meleeWeapons();
void getMeleeWeapons(); void getMeleeWeapons();
auto writeMeleeWeapons() -> bool; bool writeMeleeWeapons();
auto shields() -> Containers::ArrayView<Weapon>; Containers::ArrayView<Weapon> shields();
void getShields(); void getShields();
auto writeShields() -> bool; bool writeShields();
auto bulletShooters() -> Containers::ArrayView<Weapon>; Containers::ArrayView<Weapon> bulletShooters();
void getBulletShooters(); void getBulletShooters();
auto writeBulletShooters() -> bool; bool writeBulletShooters();
auto energyShooters() -> Containers::ArrayView<Weapon>; Containers::ArrayView<Weapon> energyShooters();
void getEnergyShooters(); void getEnergyShooters();
auto writeEnergyShooters() -> bool; bool writeEnergyShooters();
auto bulletLaunchers() -> Containers::ArrayView<Weapon>; Containers::ArrayView<Weapon> bulletLaunchers();
void getBulletLaunchers(); void getBulletLaunchers();
auto writeBulletLaunchers() -> bool; bool writeBulletLaunchers();
auto energyLaunchers() -> Containers::ArrayView<Weapon>; Containers::ArrayView<Weapon> energyLaunchers();
void getEnergyLaunchers(); void getEnergyLaunchers();
auto writeEnergyLaunchers() -> bool; bool writeEnergyLaunchers();
auto globalStyles() -> Containers::ArrayView<CustomStyle>; Containers::ArrayView<CustomStyle> globalStyles();
void getGlobalStyles(); void getGlobalStyles();
auto writeGlobalStyle(UnsignedLong index) -> bool; bool writeGlobalStyle(UnsignedLong index);
void getTuning(); void getTuning();
auto engine() -> Int&; Int& engine();
auto gears() -> Containers::ArrayView<Int>; Containers::ArrayView<Int> gears();
auto os() -> Int&; Int& os();
auto modules() -> Containers::ArrayView<Int>; Containers::ArrayView<Int> modules();
auto architecture() -> Int&; Int& architecture();
auto techs() -> Containers::ArrayView<Int>; Containers::ArrayView<Int> techs();
auto account() -> Containers::StringView; Containers::StringView account();
auto updateAccount(Containers::StringView new_account) -> bool; bool updateAccount(Containers::StringView new_account);
private: private:
void getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array); 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 getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
void writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array); void writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
@ -155,7 +155,7 @@ class Mass {
void writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array); void writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array);
void getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array); void getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array);
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, void getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id,
Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids); Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids);

View file

@ -29,11 +29,13 @@
using namespace Containers::Literals; using namespace Containers::Literals;
auto Mass::armourParts() -> Containers::ArrayView<ArmourPart> { Containers::ArrayView<ArmourPart>
Mass::armourParts() {
return _armour.parts; return _armour.parts;
} }
void Mass::getArmourParts() { void
Mass::getArmourParts() {
LOG_INFO("Getting armour parts."); LOG_INFO("Getting armour parts.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -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)); LOG_INFO_FORMAT("Writing armour part in slot {}.", static_cast<int>(slot));
auto& part = *std::find_if(_armour.parts.begin(), _armour.parts.end(), [&slot](const ArmourPart& part){ return slot == part.slot; }); auto& part = *std::find_if(_armour.parts.begin(), _armour.parts.end(), [&slot](const ArmourPart& part){ return slot == part.slot; });
@ -195,15 +198,18 @@ auto Mass::writeArmourPart(ArmourSlot slot) -> bool {
return true; return true;
} }
auto Mass::bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle& { BulletLauncherAttachmentStyle&
Mass::bulletLauncherAttachmentStyle() {
return _armour.blAttachmentStyle; return _armour.blAttachmentStyle;
} }
auto Mass::bulletLauncherAttachments() -> Containers::ArrayView<BulletLauncherAttachment> { Containers::ArrayView<BulletLauncherAttachment>
Mass::bulletLauncherAttachments() {
return _armour.blAttachment; return _armour.blAttachment;
} }
void Mass::getBulletLauncherAttachments() { void
Mass::getBulletLauncherAttachments() {
LOG_INFO("Getting the bullet launcher attachment data."); LOG_INFO("Getting the bullet launcher attachment data.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -274,7 +280,8 @@ void Mass::getBulletLauncherAttachments() {
} }
} }
auto Mass::writeBulletLauncherAttachments() -> bool { bool
Mass::writeBulletLauncherAttachments() {
LOG_INFO("Writing bullet launcher attachments."); LOG_INFO("Writing bullet launcher attachments.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -373,11 +380,13 @@ auto Mass::writeBulletLauncherAttachments() -> bool {
return true; return true;
} }
auto Mass::armourCustomStyles() -> Containers::ArrayView<CustomStyle> { Containers::ArrayView<CustomStyle>
Mass::armourCustomStyles() {
return _armour.customStyles; return _armour.customStyles;
} }
void Mass::getArmourCustomStyles() { void
Mass::getArmourCustomStyles() {
LOG_INFO("Getting the custom armour styles."); LOG_INFO("Getting the custom armour styles.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -404,7 +413,8 @@ void Mass::getArmourCustomStyles() {
getCustomStyles(_armour.customStyles, armour_styles); getCustomStyles(_armour.customStyles, armour_styles);
} }
auto Mass::writeArmourCustomStyle(UnsignedLong index) -> bool { bool
Mass::writeArmourCustomStyle(UnsignedLong index) {
LOG_INFO_FORMAT("Writing custom armour style {}.", index); LOG_INFO_FORMAT("Writing custom armour style {}.", index);
if(index > _armour.customStyles.size()) { if(index > _armour.customStyles.size()) {

View file

@ -29,7 +29,8 @@
using namespace Containers::Literals; 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++) { for(UnsignedInt i = 0; i < decal_array->items.size(); i++) {
auto decal_prop = decal_array->at<GenericStructProperty>(i); auto decal_prop = decal_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(decal_prop); CORRADE_INTERNAL_ASSERT(decal_prop);
@ -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++) { for(UnsignedInt i = 0; i < decal_array->items.size(); i++) {
auto decal_prop = decal_array->at<GenericStructProperty>(i); auto decal_prop = decal_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(decal_prop); CORRADE_INTERNAL_ASSERT(decal_prop);
@ -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++) { for(UnsignedInt i = 0; i < accessory_array->items.size(); i++) {
auto acc_prop = accessory_array->at<GenericStructProperty>(i); auto acc_prop = accessory_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(acc_prop); CORRADE_INTERNAL_ASSERT(acc_prop);
@ -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++) { for(UnsignedInt i = 0; i < accs_array->items.size(); i++) {
auto acc_prop = accs_array->at<GenericStructProperty>(i); auto acc_prop = accs_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(acc_prop); CORRADE_INTERNAL_ASSERT(acc_prop);

View file

@ -26,11 +26,13 @@
using namespace Containers::Literals; using namespace Containers::Literals;
auto Mass::jointSliders() -> Joints& { Joints&
Mass::jointSliders() {
return _frame.joints; return _frame.joints;
} }
void Mass::getJointSliders() { void
Mass::getJointSliders() {
LOG_INFO("Getting joint sliders."); LOG_INFO("Getting joint sliders.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -65,7 +67,8 @@ void Mass::getJointSliders() {
_frame.joints.lowerLegs = (length ? length->value : 0.0f); _frame.joints.lowerLegs = (length ? length->value : 0.0f);
} }
auto Mass::writeJointSliders() -> bool { bool
Mass::writeJointSliders() {
LOG_INFO("Writing joint sliders"); LOG_INFO("Writing joint sliders");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -181,11 +184,13 @@ auto Mass::writeJointSliders() -> bool {
return true; return true;
} }
auto Mass::frameStyles() -> Containers::ArrayView<Int> { Containers::ArrayView<Int>
Mass::frameStyles() {
return _frame.styles; return _frame.styles;
} }
void Mass::getFrameStyles() { void
Mass::getFrameStyles() {
LOG_INFO("Getting frame styles."); LOG_INFO("Getting frame styles.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -221,7 +226,8 @@ void Mass::getFrameStyles() {
} }
} }
auto Mass::writeFrameStyles() -> bool { bool
Mass::writeFrameStyles() {
LOG_INFO("Writing frame styles."); LOG_INFO("Writing frame styles.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -260,11 +266,13 @@ auto Mass::writeFrameStyles() -> bool {
return true; return true;
} }
auto Mass::eyeFlareColour() -> Color4& { Color4&
Mass::eyeFlareColour() {
return _frame.eyeFlare; return _frame.eyeFlare;
} }
void Mass::getEyeFlareColour() { void
Mass::getEyeFlareColour() {
LOG_INFO("Getting the eye flare colour."); LOG_INFO("Getting the eye flare colour.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -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}; _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."); LOG_INFO("Writing the eye flare colour.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -331,11 +340,13 @@ auto Mass::writeEyeFlareColour() -> bool {
return true; return true;
} }
auto Mass::frameCustomStyles() -> Containers::ArrayView<CustomStyle> { Containers::ArrayView<CustomStyle>
Mass::frameCustomStyles() {
return _frame.customStyles; return _frame.customStyles;
} }
void Mass::getFrameCustomStyles() { void
Mass::getFrameCustomStyles() {
LOG_INFO("Getting the frame's custom styles."); LOG_INFO("Getting the frame's custom styles.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -362,7 +373,8 @@ void Mass::getFrameCustomStyles() {
getCustomStyles(_frame.customStyles, frame_styles); 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); LOG_INFO_FORMAT("Writing frame custom style number {}.", index);
if(index > _frame.customStyles.size()) { if(index > _frame.customStyles.size()) {

View file

@ -27,11 +27,13 @@
using namespace Containers::Literals; using namespace Containers::Literals;
auto Mass::globalStyles() -> Containers::ArrayView<CustomStyle> { Containers::ArrayView<CustomStyle>
Mass::globalStyles() {
return _globalStyles; return _globalStyles;
} }
void Mass::getGlobalStyles() { void
Mass::getGlobalStyles() {
LOG_INFO("Getting global styles."); LOG_INFO("Getting global styles.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -55,7 +57,8 @@ void Mass::getGlobalStyles() {
getCustomStyles(_globalStyles, global_styles); getCustomStyles(_globalStyles, global_styles);
} }
auto Mass::writeGlobalStyle(UnsignedLong index) -> bool { bool
Mass::writeGlobalStyle(UnsignedLong index) {
LOG_INFO_FORMAT("Writing global style number {}.", index); LOG_INFO_FORMAT("Writing global style number {}.", index);
if(index > _globalStyles.size()) { if(index > _globalStyles.size()) {
@ -83,7 +86,8 @@ auto Mass::writeGlobalStyle(UnsignedLong index) -> bool {
return writeCustomStyle(_globalStyles[index], index, global_styles); 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++) { for(UnsignedInt i = 0; i < style_array->items.size(); i++) {
auto style_prop = style_array->at<GenericStructProperty>(i); auto style_prop = style_array->at<GenericStructProperty>(i);
auto& style = styles[i]; auto& style = styles[i];
@ -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) { if(!style_array) {
_lastError = "style_array is null."_s; _lastError = "style_array is null."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);

View file

@ -28,91 +28,110 @@
using namespace Containers::Literals; using namespace Containers::Literals;
auto Mass::meleeWeapons() -> Containers::ArrayView<Weapon> { Containers::ArrayView<Weapon>
Mass::meleeWeapons() {
return _weapons.melee; return _weapons.melee;
} }
void Mass::getMeleeWeapons() { void
Mass::getMeleeWeapons() {
LOG_INFO("Getting melee weapons."); LOG_INFO("Getting melee weapons.");
getWeaponType(MASS_WEAPONS_MELEE, _weapons.melee); getWeaponType(MASS_WEAPONS_MELEE, _weapons.melee);
} }
auto Mass::writeMeleeWeapons() -> bool { bool
Mass::writeMeleeWeapons() {
LOG_INFO("Writing melee weapons."); LOG_INFO("Writing melee weapons.");
return writeWeaponType(MASS_WEAPONS_MELEE, _weapons.melee); return writeWeaponType(MASS_WEAPONS_MELEE, _weapons.melee);
} }
auto Mass::shields() -> Containers::ArrayView<Weapon> { Containers::ArrayView<Weapon>
Mass::shields() {
return _weapons.shields; return _weapons.shields;
} }
void Mass::getShields() { void
Mass::getShields() {
LOG_INFO("Getting shields."); LOG_INFO("Getting shields.");
getWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields); getWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields);
} }
auto Mass::writeShields() -> bool { bool
Mass::writeShields() {
LOG_INFO("Writing shields."); LOG_INFO("Writing shields.");
return writeWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields); return writeWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields);
} }
auto Mass::bulletShooters() -> Containers::ArrayView<Weapon> { Containers::ArrayView<Weapon>
Mass::bulletShooters() {
return _weapons.bulletShooters; return _weapons.bulletShooters;
} }
void Mass::getBulletShooters() { void
Mass::getBulletShooters() {
LOG_INFO("Getting bullet shooters."); LOG_INFO("Getting bullet shooters.");
getWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters); getWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters);
} }
auto Mass::writeBulletShooters() -> bool { bool
Mass::writeBulletShooters() {
LOG_INFO("Writing bullet shooters."); LOG_INFO("Writing bullet shooters.");
return writeWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters); return writeWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters);
} }
auto Mass::energyShooters() -> Containers::ArrayView<Weapon> { Containers::ArrayView<Weapon>
Mass::energyShooters() {
return _weapons.energyShooters; return _weapons.energyShooters;
} }
void Mass::getEnergyShooters() { void
Mass::getEnergyShooters() {
LOG_INFO("Getting energy shooters."); LOG_INFO("Getting energy shooters.");
getWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters); getWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters);
} }
auto Mass::writeEnergyShooters() -> bool { bool
Mass::writeEnergyShooters() {
LOG_INFO("Writing energy shooters."); LOG_INFO("Writing energy shooters.");
return writeWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters); return writeWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters);
} }
auto Mass::bulletLaunchers() -> Containers::ArrayView<Weapon> { Containers::ArrayView<Weapon>
Mass::bulletLaunchers() {
return _weapons.bulletLaunchers; return _weapons.bulletLaunchers;
} }
void Mass::getBulletLaunchers() { void
Mass::getBulletLaunchers() {
LOG_INFO("Getting bullet launchers."); LOG_INFO("Getting bullet launchers.");
getWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers); getWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers);
} }
auto Mass::writeBulletLaunchers() -> bool { bool
Mass::writeBulletLaunchers() {
LOG_INFO("Writing bullet launchers."); LOG_INFO("Writing bullet launchers.");
return writeWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers); return writeWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers);
} }
auto Mass::energyLaunchers() -> Containers::ArrayView<Weapon> { Containers::ArrayView<Weapon>
Mass::energyLaunchers() {
return _weapons.energyLaunchers; return _weapons.energyLaunchers;
} }
void Mass::getEnergyLaunchers() { void
Mass::getEnergyLaunchers() {
LOG_INFO("Getting energy launchers."); LOG_INFO("Getting energy launchers.");
getWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers); getWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers);
} }
auto Mass::writeEnergyLaunchers() -> bool { bool
Mass::writeEnergyLaunchers() {
LOG_INFO("Writing energy launchers."); LOG_INFO("Writing energy launchers.");
return writeWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers); return writeWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers);
} }
void 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); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
if(!unit_data) { if(!unit_data) {
LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename);
@ -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); auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
if(!unit_data) { if(!unit_data) {
_lastError = "No unit data in "_s + _filename; _lastError = "No unit data in "_s + _filename;

View file

@ -39,15 +39,18 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie
refreshStagedMasses(); refreshStagedMasses();
} }
auto MassManager::lastError() -> Containers::StringView { Containers::StringView
MassManager::lastError() {
return _lastError; return _lastError;
} }
auto MassManager::hangar(Int hangar) -> Mass& { Mass&
MassManager::hangar(Int hangar) {
return _hangars[hangar]; return _hangars[hangar];
} }
void MassManager::refreshHangar(Int hangar) { void
MassManager::refreshHangar(Int hangar) {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."; _lastError = "Hangar index out of range.";
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -60,7 +63,8 @@ void MassManager::refreshHangar(Int hangar) {
_hangars[hangar] = Mass{mass_filename}; _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) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."; _lastError = "Hangar index out of range.";
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -102,7 +106,8 @@ auto MassManager::importMass(Containers::StringView staged_fn, Int hangar) -> bo
return true; return true;
} }
auto MassManager::exportMass(Int hangar) -> bool { bool
MassManager::exportMass(Int hangar) {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."_s; _lastError = "Hangar index out of range."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -128,7 +133,8 @@ auto MassManager::exportMass(Int hangar) -> bool {
return true; return true;
} }
auto MassManager::moveMass(Int source, Int destination) -> bool { bool
MassManager::moveMass(Int source, Int destination) {
if(source < 0 || source >= 32) { if(source < 0 || source >= 32) {
_lastError = "Source hangar index out of range."_s; _lastError = "Source hangar index out of range."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -165,7 +171,8 @@ auto MassManager::moveMass(Int source, Int destination) -> bool {
return true; return true;
} }
auto MassManager::deleteMass(Int hangar) -> bool { bool
MassManager::deleteMass(Int hangar) {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."_s; _lastError = "Hangar index out of range."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -181,11 +188,13 @@ auto MassManager::deleteMass(Int hangar) -> bool {
return true; return true;
} }
auto MassManager::stagedMasses() -> std::map<Containers::String, Containers::String> const& { const std::map<Containers::String, Containers::String>&
MassManager::stagedMasses() {
return _stagedMasses; return _stagedMasses;
} }
void MassManager::refreshStagedMasses() { void
MassManager::refreshStagedMasses() {
_stagedMasses.clear(); _stagedMasses.clear();
using Utility::Path::ListFlag; 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); LOG_INFO_FORMAT("Refreshing staged unit with filename {}.", filename);
bool file_exists = Utility::Path::exists(Utility::Path::join(_stagingAreaDirectory, filename)); bool file_exists = Utility::Path::exists(Utility::Path::join(_stagingAreaDirectory, filename));
@ -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()) { if(_stagedMasses.find(filename) == _stagedMasses.cend()) {
_lastError = "The file "_s + filename + " couldn't be found in the list of staged M.A.S.S.es."_s; _lastError = "The file "_s + filename + " couldn't be found in the list of staged M.A.S.S.es."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);

View file

@ -30,22 +30,22 @@ class MassManager {
public: public:
MassManager(Containers::StringView save_path, Containers::StringView account, bool demo, Containers::StringView staging_dir); MassManager(Containers::StringView save_path, Containers::StringView account, bool demo, Containers::StringView staging_dir);
auto lastError() -> Containers::StringView; Containers::StringView lastError();
auto hangar(int hangar) -> Mass&; Mass& hangar(int hangar);
void refreshHangar(int hangar); void refreshHangar(int hangar);
auto importMass(Containers::StringView staged_fn, int hangar) -> bool; bool importMass(Containers::StringView staged_fn, int hangar);
auto exportMass(int hangar) -> bool; bool exportMass(int hangar);
auto moveMass(int source, int destination) -> bool; bool moveMass(int source, int destination);
auto deleteMass(int hangar) -> bool; bool deleteMass(int hangar);
auto stagedMasses() -> std::map<Containers::String, Containers::String> const&; std::map<Containers::String, Containers::String> const& stagedMasses();
void refreshStagedMasses(); void refreshStagedMasses();
void refreshStagedMass(Containers::StringView filename); void refreshStagedMass(Containers::StringView filename);
auto deleteStagedMass(Containers::StringView filename) -> bool; bool deleteStagedMass(Containers::StringView filename);
private: private:
Containers::StringView _saveDirectory; Containers::StringView _saveDirectory;

View file

@ -62,31 +62,38 @@ Profile::Profile(Containers::StringView path):
refreshValues(); refreshValues();
} }
auto Profile::valid() const -> bool { bool
Profile::valid() const {
return _valid; return _valid;
} }
auto Profile::lastError() const -> Containers::StringView { Containers::StringView
Profile::lastError() const {
return _lastError; return _lastError;
} }
auto Profile::filename() const -> Containers::StringView { Containers::StringView
Profile::filename() const {
return _filename; return _filename;
} }
auto Profile::type() const -> ProfileType { ProfileType
Profile::type() const {
return _type; return _type;
} }
auto Profile::isDemo() const -> bool { bool
Profile::isDemo() const {
return _type == ProfileType::Demo; return _type == ProfileType::Demo;
} }
auto Profile::account() const -> Containers::StringView { Containers::StringView
Profile::account() const {
return _account; return _account;
} }
void Profile::refreshValues() { void
Profile::refreshValues() {
if(!_profile.reloadData()) { if(!_profile.reloadData()) {
LOG_ERROR(_profile.lastError()); LOG_ERROR(_profile.lastError());
_valid = false; _valid = false;
@ -157,11 +164,13 @@ void Profile::refreshValues() {
_valid = true; _valid = true;
} }
auto Profile::companyName() const -> Containers::StringView { Containers::StringView
Profile::companyName() const {
return _name; 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); auto name_prop = _profile.at<StringProperty>(PROFILE_NAME);
if(!name_prop) { if(!name_prop) {
_lastError = "No company name in "_s + _filename; _lastError = "No company name in "_s + _filename;
@ -180,15 +189,18 @@ auto Profile::renameCompany(Containers::StringView new_name) -> bool {
return true; return true;
} }
auto Profile::activeFrameSlot() const -> Int { Int
Profile::activeFrameSlot() const {
return _activeFrameSlot; return _activeFrameSlot;
} }
auto Profile::credits() const -> Int { Int
Profile::credits() const {
return _credits; return _credits;
} }
auto Profile::setCredits(Int amount) -> bool { bool
Profile::setCredits(Int amount) {
auto credits_prop = _profile.at<IntProperty>(PROFILE_CREDITS); auto credits_prop = _profile.at<IntProperty>(PROFILE_CREDITS);
if(!credits_prop) { if(!credits_prop) {
@ -208,11 +220,13 @@ auto Profile::setCredits(Int amount) -> bool {
return true; return true;
} }
auto Profile::storyProgress() const -> Int { Int
Profile::storyProgress() const {
return _storyProgress; return _storyProgress;
} }
auto Profile::setStoryProgress(Int progress) -> bool { bool
Profile::setStoryProgress(Int progress) {
auto story_progress_prop = _profile.at<IntProperty>("StoryProgress"_s); auto story_progress_prop = _profile.at<IntProperty>("StoryProgress"_s);
if(!story_progress_prop) { if(!story_progress_prop) {
@ -232,47 +246,58 @@ auto Profile::setStoryProgress(Int progress) -> bool {
return true; return true;
} }
auto Profile::lastMissionId() const -> Int { Int
Profile::lastMissionId() const {
return _lastMissionId; return _lastMissionId;
} }
auto Profile::verseSteel() const -> Int { Int
Profile::verseSteel() const {
return _verseSteel; return _verseSteel;
} }
auto Profile::setVerseSteel(Int amount) -> bool { bool
Profile::setVerseSteel(Int amount) {
return setResource(PROFILE_MATERIAL, VerseSteel, amount); return setResource(PROFILE_MATERIAL, VerseSteel, amount);
} }
auto Profile::undinium() const -> Int { Int
Profile::undinium() const {
return _undinium; return _undinium;
} }
auto Profile::setUndinium(Int amount) -> bool { bool
Profile::setUndinium(Int amount) {
return setResource(PROFILE_MATERIAL, Undinium, amount); return setResource(PROFILE_MATERIAL, Undinium, amount);
} }
auto Profile::necriumAlloy() const -> Int { Int
Profile::necriumAlloy() const {
return _necriumAlloy; return _necriumAlloy;
} }
auto Profile::setNecriumAlloy(Int amount) -> bool { bool
Profile::setNecriumAlloy(Int amount) {
return setResource(PROFILE_MATERIAL, NecriumAlloy, amount); return setResource(PROFILE_MATERIAL, NecriumAlloy, amount);
} }
auto Profile::lunarite() const -> Int { Int
Profile::lunarite() const {
return _lunarite; return _lunarite;
} }
auto Profile::setLunarite(Int amount) -> bool { bool
Profile::setLunarite(Int amount) {
return setResource(PROFILE_MATERIAL, Lunarite, amount); return setResource(PROFILE_MATERIAL, Lunarite, amount);
} }
auto Profile::asterite() const -> Int { Int
Profile::asterite() const {
return _asterite; return _asterite;
} }
auto Profile::setAsterite(Int amount) -> bool { bool
Profile::setAsterite(Int amount) {
return setResource(PROFILE_MATERIAL, Asterite, amount); return setResource(PROFILE_MATERIAL, Asterite, amount);
} }
@ -286,43 +311,53 @@ Profile::setHalliteFragma(Int amount) {
return setResource(PROFILE_MATERIAL, HalliteFragma, amount); return setResource(PROFILE_MATERIAL, HalliteFragma, amount);
} }
auto Profile::ednil() const -> Int { Int
Profile::ednil() const {
return _ednil; return _ednil;
} }
auto Profile::setEdnil(Int amount) -> bool { bool
Profile::setEdnil(Int amount) {
return setResource(PROFILE_MATERIAL, Ednil, amount); return setResource(PROFILE_MATERIAL, Ednil, amount);
} }
auto Profile::nuflalt() const -> Int { Int
Profile::nuflalt() const {
return _nuflalt; return _nuflalt;
} }
auto Profile::setNuflalt(Int amount) -> bool { bool
Profile::setNuflalt(Int amount) {
return setResource(PROFILE_MATERIAL, Nuflalt, amount); return setResource(PROFILE_MATERIAL, Nuflalt, amount);
} }
auto Profile::aurelene() const -> Int { Int
Profile::aurelene() const {
return _aurelene; return _aurelene;
} }
auto Profile::setAurelene(Int amount) -> bool { bool
Profile::setAurelene(Int amount) {
return setResource(PROFILE_MATERIAL, Aurelene, amount); return setResource(PROFILE_MATERIAL, Aurelene, amount);
} }
auto Profile::soldus() const -> Int { Int
Profile::soldus() const {
return _soldus; return _soldus;
} }
auto Profile::setSoldus(Int amount) -> bool { bool
Profile::setSoldus(Int amount) {
return setResource(PROFILE_MATERIAL, Soldus, amount); return setResource(PROFILE_MATERIAL, Soldus, amount);
} }
auto Profile::synthesisedN() const -> Int { Int
Profile::synthesisedN() const {
return _synthesisedN; return _synthesisedN;
} }
auto Profile::setSynthesisedN(Int amount) -> bool { bool
Profile::setSynthesisedN(Int amount) {
return setResource(PROFILE_MATERIAL, SynthesisedN, amount); return setResource(PROFILE_MATERIAL, SynthesisedN, amount);
} }
@ -336,43 +371,53 @@ Profile::setNanoc(Int amount) {
return setResource(PROFILE_MATERIAL, Nanoc, amount); return setResource(PROFILE_MATERIAL, Nanoc, amount);
} }
auto Profile::alcarbonite() const -> Int { Int
Profile::alcarbonite() const {
return _alcarbonite; return _alcarbonite;
} }
auto Profile::setAlcarbonite(Int amount) -> bool { bool
Profile::setAlcarbonite(Int amount) {
return setResource(PROFILE_MATERIAL, Alcarbonite, amount); return setResource(PROFILE_MATERIAL, Alcarbonite, amount);
} }
auto Profile::keriphene() const -> Int { Int
Profile::keriphene() const {
return _keriphene; return _keriphene;
} }
auto Profile::setKeriphene(Int amount) -> bool { bool
Profile::setKeriphene(Int amount) {
return setResource(PROFILE_MATERIAL, Keriphene, amount); return setResource(PROFILE_MATERIAL, Keriphene, amount);
} }
auto Profile::nitinolCM() const -> Int { Int
Profile::nitinolCM() const {
return _nitinolCM; return _nitinolCM;
} }
auto Profile::setNitinolCM(Int amount) -> bool { bool
Profile::setNitinolCM(Int amount) {
return setResource(PROFILE_MATERIAL, NitinolCM, amount); return setResource(PROFILE_MATERIAL, NitinolCM, amount);
} }
auto Profile::quarkium() const -> Int { Int
Profile::quarkium() const {
return _quarkium; return _quarkium;
} }
auto Profile::setQuarkium(Int amount) -> bool { bool
Profile::setQuarkium(Int amount) {
return setResource(PROFILE_MATERIAL, Quarkium, amount); return setResource(PROFILE_MATERIAL, Quarkium, amount);
} }
auto Profile::alterene() const -> Int { Int
Profile::alterene() const {
return _alterene; return _alterene;
} }
auto Profile::setAlterene(Int amount) -> bool { bool
Profile::setAlterene(Int amount) {
return setResource(PROFILE_MATERIAL, Alterene, amount); return setResource(PROFILE_MATERIAL, Alterene, amount);
} }
@ -386,43 +431,53 @@ Profile::setCosmium(Int amount) {
return setResource(PROFILE_MATERIAL, Cosmium, amount); return setResource(PROFILE_MATERIAL, Cosmium, amount);
} }
auto Profile::mixedComposition() const -> Int { Int
Profile::mixedComposition() const {
return _mixedComposition; return _mixedComposition;
} }
auto Profile::setMixedComposition(Int amount) -> bool { bool
Profile::setMixedComposition(Int amount) {
return setResource(PROFILE_QUARK_DATA, MixedComposition, amount); return setResource(PROFILE_QUARK_DATA, MixedComposition, amount);
} }
auto Profile::voidResidue() const -> Int { Int
Profile::voidResidue() const {
return _voidResidue; return _voidResidue;
} }
auto Profile::setVoidResidue(Int amount) -> bool { bool
Profile::setVoidResidue(Int amount) {
return setResource(PROFILE_QUARK_DATA, VoidResidue, amount); return setResource(PROFILE_QUARK_DATA, VoidResidue, amount);
} }
auto Profile::muscularConstruction() const -> Int { Int
Profile::muscularConstruction() const {
return _muscularConstruction; return _muscularConstruction;
} }
auto Profile::setMuscularConstruction(Int amount) -> bool { bool
Profile::setMuscularConstruction(Int amount) {
return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount); return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount);
} }
auto Profile::mineralExoskeletology() const -> Int { Int
Profile::mineralExoskeletology() const {
return _mineralExoskeletology; return _mineralExoskeletology;
} }
auto Profile::setMineralExoskeletology(Int amount) -> bool { bool
Profile::setMineralExoskeletology(Int amount) {
return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount); return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount);
} }
auto Profile::carbonisedSkin() const -> Int { Int
Profile::carbonisedSkin() const {
return _carbonisedSkin; return _carbonisedSkin;
} }
auto Profile::setCarbonisedSkin(Int amount) -> bool { bool
Profile::setCarbonisedSkin(Int amount) {
return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount); return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount);
} }
@ -436,7 +491,8 @@ Profile::setIsolatedVoidParticle(Int amount) {
return setResource(PROFILE_QUARK_DATA, IsolatedVoidParticle, 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); auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) { 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; 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); auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) { if(!mats_prop) {

View file

@ -51,93 +51,93 @@ class Profile {
void refreshValues(); void refreshValues();
auto companyName() const -> Containers::StringView; auto companyName() const -> Containers::StringView;
auto renameCompany(Containers::StringView new_name) -> bool; bool renameCompany(Containers::StringView new_name);
auto activeFrameSlot() const -> Int; auto activeFrameSlot() const -> Int;
auto credits() const -> Int; auto credits() const -> Int;
auto setCredits(Int credits) -> bool; bool setCredits(Int credits);
auto storyProgress() const -> Int; auto storyProgress() const -> Int;
auto setStoryProgress(Int progress) -> bool; bool setStoryProgress(Int progress);
auto lastMissionId() const -> Int; auto lastMissionId() const -> Int;
auto verseSteel() const -> Int; auto verseSteel() const -> Int;
auto setVerseSteel(Int amount) -> bool; bool setVerseSteel(Int amount);
auto undinium() const -> Int; auto undinium() const -> Int;
auto setUndinium(Int amount) -> bool; bool setUndinium(Int amount);
auto necriumAlloy() const -> Int; auto necriumAlloy() const -> Int;
auto setNecriumAlloy(Int amount) -> bool; bool setNecriumAlloy(Int amount);
auto lunarite() const -> Int; auto lunarite() const -> Int;
auto setLunarite(Int amount) -> bool; bool setLunarite(Int amount);
auto asterite() const -> Int; auto asterite() const -> Int;
auto setAsterite(Int amount) -> bool; bool setAsterite(Int amount);
Int halliteFragma() const; Int halliteFragma() const;
bool setHalliteFragma(Int amount); bool setHalliteFragma(Int amount);
auto ednil() const -> Int; auto ednil() const -> Int;
auto setEdnil(Int amount) -> bool; bool setEdnil(Int amount);
auto nuflalt() const -> Int; auto nuflalt() const -> Int;
auto setNuflalt(Int amount) -> bool; bool setNuflalt(Int amount);
auto aurelene() const -> Int; auto aurelene() const -> Int;
auto setAurelene(Int amount) -> bool; bool setAurelene(Int amount);
auto soldus() const -> Int; auto soldus() const -> Int;
auto setSoldus(Int amount) -> bool; bool setSoldus(Int amount);
auto synthesisedN() const -> Int; auto synthesisedN() const -> Int;
auto setSynthesisedN(Int amount) -> bool; bool setSynthesisedN(Int amount);
Int nanoc() const; Int nanoc() const;
bool setNanoc(Int amount); bool setNanoc(Int amount);
auto alcarbonite() const -> Int; auto alcarbonite() const -> Int;
auto setAlcarbonite(Int amount) -> bool; bool setAlcarbonite(Int amount);
auto keriphene() const -> Int; auto keriphene() const -> Int;
auto setKeriphene(Int amount) -> bool; bool setKeriphene(Int amount);
auto nitinolCM() const -> Int; auto nitinolCM() const -> Int;
auto setNitinolCM(Int amount) -> bool; bool setNitinolCM(Int amount);
auto quarkium() const -> Int; auto quarkium() const -> Int;
auto setQuarkium(Int amount) -> bool; bool setQuarkium(Int amount);
auto alterene() const -> Int; auto alterene() const -> Int;
auto setAlterene(Int amount) -> bool; bool setAlterene(Int amount);
Int cosmium() const; Int cosmium() const;
bool setCosmium(Int amount); bool setCosmium(Int amount);
auto mixedComposition() const -> Int; auto mixedComposition() const -> Int;
auto setMixedComposition(Int amount) -> bool; bool setMixedComposition(Int amount);
auto voidResidue() const -> Int; auto voidResidue() const -> Int;
auto setVoidResidue(Int amount) -> bool; bool setVoidResidue(Int amount);
auto muscularConstruction() const -> Int; auto muscularConstruction() const -> Int;
auto setMuscularConstruction(Int amount) -> bool; bool setMuscularConstruction(Int amount);
auto mineralExoskeletology() const -> Int; auto mineralExoskeletology() const -> Int;
auto setMineralExoskeletology(Int amount) -> bool; bool setMineralExoskeletology(Int amount);
auto carbonisedSkin() const -> Int; auto carbonisedSkin() const -> Int;
auto setCarbonisedSkin(Int amount) -> bool; bool setCarbonisedSkin(Int amount);
Int isolatedVoidParticle() const; Int isolatedVoidParticle() const;
bool setIsolatedVoidParticle(Int amount); bool setIsolatedVoidParticle(Int amount);
private: private:
auto getResource(Containers::StringView container, MaterialID id) -> Int; Int getResource(Containers::StringView container, MaterialID id);
auto setResource(Containers::StringView container, MaterialID id, Int amount) -> bool; bool setResource(Containers::StringView container, MaterialID id, Int amount);
Containers::String _filename; Containers::String _filename;

View file

@ -40,19 +40,23 @@ ProfileManager::ProfileManager(Containers::StringView save_dir, Containers::Stri
_ready = refreshProfiles(); _ready = refreshProfiles();
} }
auto ProfileManager::ready() const -> bool { bool
ProfileManager::ready() const {
return _ready; return _ready;
} }
auto ProfileManager::lastError() -> Containers::StringView { Containers::StringView
ProfileManager::lastError() {
return _lastError; return _lastError;
} }
auto ProfileManager::profiles() -> Containers::ArrayView<Profile> { Containers::ArrayView<Profile>
ProfileManager::profiles() {
return _profiles; return _profiles;
} }
auto ProfileManager::refreshProfiles() -> bool { bool
ProfileManager::refreshProfiles() {
LOG_INFO("Refreshing profiles."); LOG_INFO("Refreshing profiles.");
_profiles = Containers::Array<Profile>{}; _profiles = Containers::Array<Profile>{};
@ -93,11 +97,13 @@ auto ProfileManager::refreshProfiles() -> bool {
return true; return true;
} }
auto ProfileManager::getProfile(std::size_t index) -> Profile* { Profile*
ProfileManager::getProfile(std::size_t index) {
return index <= _profiles.size() ? &(_profiles[index]) : nullptr; 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()))) { if(!Utility::Path::remove(Utility::Path::join(_saveDirectory, _profiles[index].filename()))) {
_lastError = Utility::format("Couldn't delete {} (filename: {}).", _lastError = Utility::format("Couldn't delete {} (filename: {}).",
_profiles[index].companyName(), _profiles[index].companyName(),
@ -126,7 +132,8 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo
return true; 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::time_t timestamp = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm* time = std::localtime(&timestamp); std::tm* time = std::localtime(&timestamp);
auto& profile = _profiles[index]; auto& profile = _profiles[index];
@ -202,11 +209,13 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
return true; return true;
} }
auto ProfileManager::backups() -> Containers::ArrayView<Backup> { Containers::ArrayView<Backup>
ProfileManager::backups() {
return _backups; return _backups;
} }
void ProfileManager::refreshBackups() { void
ProfileManager::refreshBackups() {
_backups = Containers::Array<Backup>{}; _backups = Containers::Array<Backup>{};
using Utility::Path::ListFlag; 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))) { if(!Utility::Path::remove(Utility::Path::join(_backupsDirectory, _backups[index].filename))) {
_lastError = "Couldn't delete " + _backups[index].filename; _lastError = "Couldn't delete " + _backups[index].filename;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -307,7 +317,8 @@ auto ProfileManager::deleteBackup(std::size_t index) -> bool {
return true; return true;
} }
auto ProfileManager::restoreBackup(std::size_t index) -> bool { bool
ProfileManager::restoreBackup(std::size_t index) {
const Backup& backup = _backups[index]; const Backup& backup = _backups[index];
auto error_format = "Extraction of file {} failed: {}"_s; auto error_format = "Extraction of file {} failed: {}"_s;

View file

@ -45,20 +45,20 @@ class ProfileManager {
explicit ProfileManager(Containers::StringView save_dir, Containers::StringView backup_dir); explicit ProfileManager(Containers::StringView save_dir, Containers::StringView backup_dir);
auto ready() const -> bool; auto ready() const -> bool;
auto lastError() -> Containers::StringView; Containers::StringView lastError();
auto profiles() -> Containers::ArrayView<Profile>; Containers::ArrayView<Profile> profiles();
auto refreshProfiles() -> bool; bool refreshProfiles();
auto getProfile(std::size_t index) -> Profile*; Profile* getProfile(std::size_t index);
auto deleteProfile(std::size_t index, bool delete_builds) -> bool; bool deleteProfile(std::size_t index, bool delete_builds);
auto backupProfile(std::size_t index, bool backup_builds) -> bool; bool backupProfile(std::size_t index, bool backup_builds);
auto backups() -> Containers::ArrayView<Backup>; Containers::ArrayView<Backup> backups();
void refreshBackups(); void refreshBackups();
auto deleteBackup(std::size_t index) -> bool; bool deleteBackup(std::size_t index);
auto restoreBackup(std::size_t index) -> bool; bool restoreBackup(std::size_t index);
private: private:
bool _ready = false; bool _ready = false;

View file

@ -165,7 +165,8 @@ SaveTool::~SaveTool() {
LOG_INFO("Exiting."); LOG_INFO("Exiting.");
} }
void SaveTool::drawEvent() { void
SaveTool::drawEvent() {
#ifdef SAVETOOL_DEBUG_BUILD #ifdef SAVETOOL_DEBUG_BUILD
tweak.update(); tweak.update();
#endif #endif
@ -185,45 +186,54 @@ void SaveTool::drawEvent() {
_timeline.nextFrame(); _timeline.nextFrame();
} }
void SaveTool::viewportEvent(ViewportEvent& event) { void
SaveTool::viewportEvent(ViewportEvent& event) {
GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()}); GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()});
const Vector2 size = Vector2{windowSize()}/dpiScaling(); const Vector2 size = Vector2{windowSize()}/dpiScaling();
_imgui.relayout(size, windowSize(), framebufferSize()); _imgui.relayout(size, windowSize(), framebufferSize());
} }
void SaveTool::keyPressEvent(KeyEvent& event) { void
SaveTool::keyPressEvent(KeyEvent& event) {
if(_imgui.handleKeyPressEvent(event)) return; if(_imgui.handleKeyPressEvent(event)) return;
} }
void SaveTool::keyReleaseEvent(KeyEvent& event) { void
SaveTool::keyReleaseEvent(KeyEvent& event) {
if(_imgui.handleKeyReleaseEvent(event)) return; if(_imgui.handleKeyReleaseEvent(event)) return;
} }
void SaveTool::mousePressEvent(MouseEvent& event) { void
SaveTool::mousePressEvent(MouseEvent& event) {
if(_imgui.handleMousePressEvent(event)) return; if(_imgui.handleMousePressEvent(event)) return;
} }
void SaveTool::mouseReleaseEvent(MouseEvent& event) { void
SaveTool::mouseReleaseEvent(MouseEvent& event) {
if(_imgui.handleMouseReleaseEvent(event)) return; if(_imgui.handleMouseReleaseEvent(event)) return;
} }
void SaveTool::mouseMoveEvent(MouseMoveEvent& event) { void
SaveTool::mouseMoveEvent(MouseMoveEvent& event) {
if(_imgui.handleMouseMoveEvent(event)) return; if(_imgui.handleMouseMoveEvent(event)) return;
} }
void SaveTool::mouseScrollEvent(MouseScrollEvent& event) { void
SaveTool::mouseScrollEvent(MouseScrollEvent& event) {
if(_imgui.handleMouseScrollEvent(event)) { if(_imgui.handleMouseScrollEvent(event)) {
event.setAccepted(); event.setAccepted();
return; return;
} }
} }
void SaveTool::textInputEvent(TextInputEvent& event) { void
SaveTool::textInputEvent(TextInputEvent& event) {
if(_imgui.handleTextInputEvent(event)) return; if(_imgui.handleTextInputEvent(event)) return;
} }
void SaveTool::anyEvent(SDL_Event& event) { void
SaveTool::anyEvent(SDL_Event& event) {
if(event.type == _initEventId) { if(event.type == _initEventId) {
initEvent(event); initEvent(event);
} }
@ -235,7 +245,8 @@ void SaveTool::anyEvent(SDL_Event& event) {
} }
} }
void SaveTool::drawImGui() { void
SaveTool::drawImGui() {
_imgui.newFrame(); _imgui.newFrame();
if(ImGui::GetIO().WantTextInput && !isTextInputActive()) { if(ImGui::GetIO().WantTextInput && !isTextInputActive()) {
@ -252,7 +263,8 @@ void SaveTool::drawImGui() {
_imgui.drawFrame(); _imgui.drawFrame();
} }
void SaveTool::drawGui() { void
SaveTool::drawGui() {
drawMainMenu(); drawMainMenu();
switch(_uiState) { switch(_uiState) {
@ -294,7 +306,8 @@ void SaveTool::drawGui() {
_queue.draw(windowSize()); _queue.draw(windowSize());
} }
void SaveTool::drawDisclaimer() { void
SaveTool::drawDisclaimer() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
if(ImGui::Begin("Disclaimer##DisclaimerWindow", nullptr, if(ImGui::Begin("Disclaimer##DisclaimerWindow", nullptr,
@ -355,7 +368,8 @@ void SaveTool::drawDisclaimer() {
ImGui::End(); ImGui::End();
} }
void SaveTool::drawInitialisation() { void
SaveTool::drawInitialisation() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
if(ImGui::BeginPopupModal("##InitPopup", nullptr, if(ImGui::BeginPopupModal("##InitPopup", nullptr,
@ -368,7 +382,8 @@ void SaveTool::drawInitialisation() {
ImGui::OpenPopup("##InitPopup"); ImGui::OpenPopup("##InitPopup");
} }
void SaveTool::drawGameState() { void
SaveTool::drawGameState() {
ImGui::TextUnformatted("Game state:"); ImGui::TextUnformatted("Game state:");
ImGui::SameLine(); 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); ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE);
drawTooltip(text, wrap_pos); 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()){ if(ImGui::IsItemHovered()){
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if(wrap_pos > 0.0f) { if(wrap_pos > 0.0f) {
@ -413,11 +430,13 @@ SaveTool::drawCheckbox(Containers::StringView label, bool value) {
return ImGui::Checkbox(label.data(), &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); ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri.data()), nullptr, nullptr, SW_SHOWDEFAULT);
} }
void SaveTool::checkGameState() { void
SaveTool::checkGameState() {
WTS_PROCESS_INFOW* process_infos = nullptr; WTS_PROCESS_INFOW* process_infos = nullptr;
unsigned long process_count = 0; unsigned long process_count = 0;

View file

@ -103,8 +103,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void initialiseConfiguration(); void initialiseConfiguration();
void initialiseGui(); void initialiseGui();
void initialiseManager(); void initialiseManager();
auto initialiseToolDirectories() -> bool; bool initialiseToolDirectories();
auto findGameDataDirectory() -> bool; bool findGameDataDirectory();
void initialiseMassManager(); void initialiseMassManager();
void initialiseFileWatcher(); void initialiseFileWatcher();
@ -116,21 +116,21 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawInitialisation(); void drawInitialisation();
void drawProfileManager(); void drawProfileManager();
auto drawBackupListPopup() -> ImGuiID; ImGuiID drawBackupListPopup();
auto drawBackupProfilePopup(std::size_t profile_index) -> ImGuiID; ImGuiID drawBackupProfilePopup(std::size_t profile_index);
auto drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID; ImGuiID drawDeleteProfilePopup(std::size_t profile_index);
void drawManager(); void drawManager();
auto drawIntEditPopup(int* value_to_edit, int max) -> bool; bool drawIntEditPopup(int* value_to_edit, int max);
auto drawRenamePopup(Containers::ArrayView<char> name_view) -> bool; bool drawRenamePopup(Containers::ArrayView<char> name_view);
void drawGeneralInfo(); void drawGeneralInfo();
void drawResearchInventory(); void drawResearchInventory();
template<typename Getter, typename Setter> template<typename Getter, typename Setter>
void drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter); void drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter);
void drawUnavailableMaterialRow(Containers::StringView name, Int tier); void drawUnavailableMaterialRow(Containers::StringView name, Int tier);
void drawMassManager(); void drawMassManager();
auto drawDeleteMassPopup(int mass_index) -> ImGuiID; ImGuiID drawDeleteMassPopup(int mass_index);
auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID; ImGuiID drawDeleteStagedMassPopup(Containers::StringView filename);
void drawMassViewer(); void drawMassViewer();
void drawFrameInfo(); void drawFrameInfo();
@ -148,14 +148,14 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawTuning(); void drawTuning();
void drawDecalEditor(Decal& decal); void drawDecalEditor(Decal& decal);
void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view); void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view);
auto getStyleName(Int id, Containers::ArrayView<CustomStyle> view) -> Containers::StringView; Containers::StringView getStyleName(Int id, Containers::ArrayView<CustomStyle> view);
enum DCSResult { enum DCSResult {
DCS_Fail, DCS_Fail,
DCS_ResetStyle, DCS_ResetStyle,
DCS_Save DCS_Save
}; };
auto drawCustomStyle(CustomStyle& style) -> DCSResult; DCSResult drawCustomStyle(CustomStyle& style);
void drawAbout(); void drawAbout();
void drawGameState(); void drawGameState();
@ -166,7 +166,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
bool drawCheckbox(Containers::StringView label, bool value); bool drawCheckbox(Containers::StringView label, bool value);
template<typename Functor, typename... Args> template<typename Functor, typename... Args>
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. GameState game_state = _gameState; // Copying the value to reduce the risk of a data race.
ImGui::BeginDisabled(game_state != GameState::NotRunning); ImGui::BeginDisabled(game_state != GameState::NotRunning);
bool result = func(std::forward<Args>(args)...); bool result = func(std::forward<Args>(args)...);

View file

@ -26,7 +26,8 @@
#include "SaveTool.h" #include "SaveTool.h"
void SaveTool::handleFileAction(efsw::WatchID watch_id, void
SaveTool::handleFileAction(efsw::WatchID watch_id,
const std::string&, const std::string&,
const std::string& filename, const std::string& filename,
efsw::Action action, efsw::Action action,
@ -60,7 +61,8 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
void SaveTool::fileUpdateEvent(SDL_Event& event) { void
SaveTool::fileUpdateEvent(SDL_Event& event) {
Containers::String filename{static_cast<char*>(event.user.data1), Containers::String filename{static_cast<char*>(event.user.data1),
std::strlen(static_cast<char*>(event.user.data1)), nullptr}; std::strlen(static_cast<char*>(event.user.data1)), nullptr};

View file

@ -31,7 +31,8 @@
#include "SaveTool.h" #include "SaveTool.h"
void SaveTool::initEvent(SDL_Event& event) { void
SaveTool::initEvent(SDL_Event& event) {
_initThread.join(); _initThread.join();
switch(event.user.code) { 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."); LOG_INFO("Reading configuration file.");
setSwapInterval(conf().swapInterval()); setSwapInterval(conf().swapInterval());
setMinimalLoopPeriod(0); setMinimalLoopPeriod(0);
} }
void SaveTool::initialiseGui() { void
SaveTool::initialiseGui() {
LOG_INFO("Initialising Dear ImGui."); LOG_INFO("Initialising Dear ImGui.");
ImGui::CreateContext(); ImGui::CreateContext();
@ -108,7 +111,8 @@ void SaveTool::initialiseGui() {
style.Colors[ImGuiCol_WindowBg] = ImColor(0xff1f1f1f); style.Colors[ImGuiCol_WindowBg] = ImColor(0xff1f1f1f);
} }
void SaveTool::initialiseManager() { void
SaveTool::initialiseManager() {
LOG_INFO("Initialising the profile manager."); LOG_INFO("Initialising the profile manager.");
SDL_Event event; SDL_Event event;
@ -126,7 +130,8 @@ void SaveTool::initialiseManager() {
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
auto SaveTool::initialiseToolDirectories() -> bool { auto
SaveTool::initialiseToolDirectories() -> bool {
LOG_INFO("Initialising Save Tool directories."); LOG_INFO("Initialising Save Tool directories.");
_backupsDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "backups"); _backupsDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "backups");
@ -187,7 +192,8 @@ auto SaveTool::initialiseToolDirectories() -> bool {
return true; return true;
} }
auto SaveTool::findGameDataDirectory() -> bool { auto
SaveTool::findGameDataDirectory() -> bool {
LOG_INFO("Searching for the game's save directory."); LOG_INFO("Searching for the game's save directory.");
wchar_t* localappdata_path = nullptr; wchar_t* localappdata_path = nullptr;
@ -213,12 +219,14 @@ auto SaveTool::findGameDataDirectory() -> bool {
return true; return true;
} }
void SaveTool::initialiseMassManager() { void
SaveTool::initialiseMassManager() {
LOG_INFO("Initialising the M.A.S.S. manager."); LOG_INFO("Initialising the M.A.S.S. manager.");
_massManager.emplace(_saveDir, _currentProfile->account(), _currentProfile->isDemo(), _stagingDir); _massManager.emplace(_saveDir, _currentProfile->account(), _currentProfile->isDemo(), _stagingDir);
} }
void SaveTool::initialiseFileWatcher() { void
SaveTool::initialiseFileWatcher() {
LOG_INFO("Initialising the file watcher."); LOG_INFO("Initialising the file watcher.");
_fileWatcher.emplace(); _fileWatcher.emplace();
_watchIDs[SaveDir] = _fileWatcher->addWatch(_saveDir, this, false); _watchIDs[SaveDir] = _fileWatcher->addWatch(_saveDir, this, false);

View file

@ -28,7 +28,8 @@
#include "SaveTool.h" #include "SaveTool.h"
void SaveTool::drawManager() { void
SaveTool::drawManager() {
ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always); ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always);
ImGui::SetNextWindowSize({Float(windowSize().x()), Float(windowSize().y()) - ImGui::GetItemRectSize().y}, ImGui::SetNextWindowSize({Float(windowSize().x()), Float(windowSize().y()) - ImGui::GetItemRectSize().y},
ImGuiCond_Always); ImGuiCond_Always);
@ -95,7 +96,8 @@ void SaveTool::drawManager() {
ImGui::End(); ImGui::End();
} }
auto SaveTool::drawIntEditPopup(int* value_to_edit, int max) -> bool { bool
SaveTool::drawIntEditPopup(int* value_to_edit, int max) {
bool apply = false; bool apply = false;
if(ImGui::BeginPopup("int_edit")) { if(ImGui::BeginPopup("int_edit")) {
ImGui::Text("Please enter a value between 0 and %i:", max); ImGui::Text("Please enter a value between 0 and %i:", max);
@ -118,7 +120,8 @@ auto SaveTool::drawIntEditPopup(int* value_to_edit, int max) -> bool {
return apply; return apply;
} }
auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool { bool
SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) {
bool apply = false; bool apply = false;
if(ImGui::BeginPopup("name_edit")) { if(ImGui::BeginPopup("name_edit")) {
ImGui::TextUnformatted("Please enter a new name. Conditions:"); ImGui::TextUnformatted("Please enter a new name. Conditions:");
@ -170,7 +173,8 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool {
return apply; return apply;
} }
void SaveTool::drawGeneralInfo() { void
SaveTool::drawGeneralInfo() {
if(!_currentProfile) { if(!_currentProfile) {
return; return;
} }
@ -278,7 +282,8 @@ void SaveTool::drawGeneralInfo() {
} }
} }
void SaveTool::drawResearchInventory() { void
SaveTool::drawResearchInventory() {
if(!_currentProfile) { if(!_currentProfile) {
return; return;
} }
@ -392,7 +397,8 @@ void SaveTool::drawResearchInventory() {
} }
template<typename Getter, typename Setter> 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(getter()), Int>::value, "getter doesn't return an Int, and/or doesn't take zero arguments.");
static_assert(std::is_same<decltype(setter(0)), bool>::value, "setter doesn't return a bool, and/or doesn't take a single Int as an argument."); static_assert(std::is_same<decltype(setter(0)), bool>::value, "setter doesn't return a bool, and/or doesn't take a single Int as an argument.");
@ -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::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier); 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); ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION);
} }
void SaveTool::drawMassManager() { void
SaveTool::drawMassManager() {
if(!_massManager) { if(!_massManager) {
return; return;
} }
@ -633,7 +641,8 @@ void SaveTool::drawMassManager() {
drawDeleteStagedMassPopup(staged_mass_to_delete); drawDeleteStagedMassPopup(staged_mass_to_delete);
} }
auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID { ImGuiID
SaveTool::drawDeleteMassPopup(int mass_index) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr, if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{ {
@ -689,7 +698,8 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
return 0; return 0;
} }
auto SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID { ImGuiID
SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr, if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{ {

View file

@ -27,7 +27,8 @@
#include "SaveTool.h" #include "SaveTool.h"
void SaveTool::drawMassViewer() { void
SaveTool::drawMassViewer() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
_currentMass = nullptr; _currentMass = nullptr;
_currentWeapon = nullptr; _currentWeapon = nullptr;
@ -154,7 +155,8 @@ void SaveTool::drawMassViewer() {
ImGui::End(); ImGui::End();
} }
void SaveTool::drawGlobalStyles() { void
SaveTool::drawGlobalStyles() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return; return;
} }
@ -190,7 +192,8 @@ void SaveTool::drawGlobalStyles() {
ImGui::EndChild(); ImGui::EndChild();
} }
void SaveTool::drawTuning() { void
SaveTool::drawTuning() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return; return;
} }
@ -286,7 +289,8 @@ void SaveTool::drawTuning() {
ImGui::EndTable(); ImGui::EndTable();
} }
auto SaveTool::drawCustomStyle(CustomStyle& style) -> DCSResult { SaveTool::DCSResult
SaveTool::drawCustomStyle(CustomStyle& style) {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return DCS_Fail; return DCS_Fail;
} }
@ -391,7 +395,8 @@ auto SaveTool::drawCustomStyle(CustomStyle& style) -> DCSResult {
return return_value; return return_value;
} }
void SaveTool::drawDecalEditor(Decal& decal) { void
SaveTool::drawDecalEditor(Decal& decal) {
ImGui::Text("ID: %i", decal.id); ImGui::Text("ID: %i", decal.id);
if(ImGui::BeginTable("##DecalTable", conf().advancedMode() ? 2 : 1, ImGuiTableFlags_BordersInnerV)) { if(ImGui::BeginTable("##DecalTable", conf().advancedMode() ? 2 : 1, ImGuiTableFlags_BordersInnerV)) {
@ -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) { if(accessory.id < 1) {
ImGui::TextUnformatted("Accessory: <none>"); ImGui::TextUnformatted("Accessory: <none>");
} }
@ -733,7 +739,8 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::EndGroup(); 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) { if(id >= 0 && id <= 15) {
return view[id].name; return view[id].name;
} }

View file

@ -21,7 +21,8 @@
#include "SaveTool.h" #include "SaveTool.h"
void SaveTool::drawArmour() { void
SaveTool::drawArmour() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return; return;
} }
@ -288,7 +289,8 @@ void SaveTool::drawArmour() {
ImGui::EndChild(); ImGui::EndChild();
} }
void SaveTool::drawCustomArmourStyles() { void
SaveTool::drawCustomArmourStyles() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return; return;
} }

View file

@ -15,12 +15,12 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "../FontAwesome/IconsFontAwesome5.h" #include "../FontAwesome/IconsFontAwesome5.h"
#include "../Maps/StyleNames.h" #include "../Maps/StyleNames.h"
#include "SaveTool.h" #include "SaveTool.h"
void SaveTool::drawFrameInfo() { void
SaveTool::drawFrameInfo() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return; return;
} }
@ -73,7 +73,8 @@ void SaveTool::drawFrameInfo() {
ImGui::EndChild(); ImGui::EndChild();
} }
void SaveTool::drawJointSliders() { void
SaveTool::drawJointSliders() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return; return;
} }
@ -195,7 +196,8 @@ void SaveTool::drawJointSliders() {
} }
} }
void SaveTool::drawFrameStyles() { void
SaveTool::drawFrameStyles() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return; return;
} }
@ -245,7 +247,8 @@ void SaveTool::drawFrameStyles() {
} }
} }
void SaveTool::drawEyeColourPicker() { void
SaveTool::drawEyeColourPicker() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return; return;
} }
@ -278,7 +281,8 @@ void SaveTool::drawEyeColourPicker() {
} }
} }
void SaveTool::drawCustomFrameStyles() { void
SaveTool::drawCustomFrameStyles() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return; return;
} }

View file

@ -21,7 +21,8 @@
#include "SaveTool.h" #include "SaveTool.h"
void SaveTool::drawWeapons() { void
SaveTool::drawWeapons() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
_currentWeapon = nullptr; _currentWeapon = nullptr;
return; return;
@ -254,7 +255,8 @@ void SaveTool::drawWeapons() {
ImGui::EndGroup(); 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) Containers::StringView payload_type, Containers::StringView payload_tooltip)
{ {
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
@ -317,7 +319,8 @@ void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::Array
ImGui::PopID(); ImGui::PopID();
} }
void SaveTool::drawWeaponEditor(Weapon& weapon) { void
SaveTool::drawWeaponEditor(Weapon& weapon) {
if(!_currentMass || _currentMass->state() != Mass::State::Valid || !_currentWeapon) { if(!_currentMass || _currentMass->state() != Mass::State::Valid || !_currentWeapon) {
return; return;
} }

View file

@ -24,7 +24,8 @@
extern const ImVec2 center_pivot; extern const ImVec2 center_pivot;
void SaveTool::drawProfileManager() { void
SaveTool::drawProfileManager() {
static std::size_t profile_index = 0; static std::size_t profile_index = 0;
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
@ -125,7 +126,8 @@ void SaveTool::drawProfileManager() {
ImGui::End(); ImGui::End();
} }
auto SaveTool::drawBackupListPopup() -> ImGuiID { ImGuiID
SaveTool::drawBackupListPopup() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
if(!ImGui::BeginPopupModal("Backups##BackupsModal", nullptr, if(!ImGui::BeginPopupModal("Backups##BackupsModal", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
@ -324,7 +326,8 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
return 0; 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, if(!ImGui::BeginPopupModal("Include builds ?##IncludeBuildsDialog", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{ {
@ -368,7 +371,8 @@ auto SaveTool::drawBackupProfilePopup(std::size_t profile_index) -> ImGuiID {
return 0; 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, if(!ImGui::BeginPopupModal("Confirmation##DeleteProfileConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{ {

View file

@ -24,7 +24,8 @@
#include "SaveTool.h" #include "SaveTool.h"
void SaveTool::updateCheckEvent(SDL_Event& event) { void
SaveTool::updateCheckEvent(SDL_Event& event) {
_updateThread.join(); _updateThread.join();
if(event.user.code == CurlInitFailed) { 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; if(!ptr || !buf) return 0;
(*buf) = Utility::format("{}{}", *buf, Containers::StringView{ptr, size * nmemb}); (*buf) = Utility::format("{}{}", *buf, Containers::StringView{ptr, size * nmemb});
return size * nmemb; return size * nmemb;
} }
void SaveTool::checkForUpdates() { void
SaveTool::checkForUpdates() {
SDL_Event event; SDL_Event event;
SDL_zero(event); SDL_zero(event);
event.type = _updateEventId; event.type = _updateEventId;

View file

@ -31,7 +31,8 @@
extern const ImVec2 center_pivot; extern const ImVec2 center_pivot;
void SaveTool::drawAbout() { void
SaveTool::drawAbout() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
ImGui::SetNextWindowSize({float(windowSize().x()) * 0.8f, float(windowSize().y()) * 0.75f}, ImGuiCond_Always); ImGui::SetNextWindowSize({float(windowSize().x()) * 0.8f, float(windowSize().y()) * 0.75f}, ImGuiCond_Always);
@ -88,7 +89,7 @@ void SaveTool::drawAbout() {
if(ImGui::BeginChild("##GPL", {0.0f, float(windowSize().y()) * 0.3f}, true)) { if(ImGui::BeginChild("##GPL", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
static auto licence = _rs.getRaw("COPYING"); static auto licence = _rs.getRaw("COPYING");
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(licence.data(), licence.data() + licence.size(), ImGuiTextFlags_None); ImGui::TextUnformatted(licence.begin(), licence.end());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -117,7 +118,7 @@ void SaveTool::drawAbout() {
static auto corrade_licence = _rs.getRaw("COPYING.Corrade"); static auto corrade_licence = _rs.getRaw("COPYING.Corrade");
if(ImGui::BeginChild("##CorradeLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { if(ImGui::BeginChild("##CorradeLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(corrade_licence.data(), corrade_licence.data() + corrade_licence.size(), ImGuiTextFlags_None); ImGui::TextUnformatted(corrade_licence.begin(), corrade_licence.end());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -145,7 +146,7 @@ void SaveTool::drawAbout() {
static auto magnum_licence = _rs.getRaw("COPYING.Magnum"); static auto magnum_licence = _rs.getRaw("COPYING.Magnum");
if(ImGui::BeginChild("##MagnumLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { if(ImGui::BeginChild("##MagnumLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(magnum_licence.data(), magnum_licence.data() + magnum_licence.size(), ImGuiTextFlags_None); ImGui::TextUnformatted(magnum_licence.begin(), magnum_licence.end());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -171,7 +172,7 @@ void SaveTool::drawAbout() {
static auto imgui_licence = _rs.getRaw("LICENSE.ImGui"); static auto imgui_licence = _rs.getRaw("LICENSE.ImGui");
if(ImGui::BeginChild("##ImGuiLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { if(ImGui::BeginChild("##ImGuiLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(imgui_licence.data(), imgui_licence.data() + imgui_licence.size(), ImGuiTextFlags_None); ImGui::TextUnformatted(imgui_licence.begin(), imgui_licence.end());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -197,7 +198,7 @@ void SaveTool::drawAbout() {
static auto sdl_licence = _rs.getRaw("LICENSE.SDL"); static auto sdl_licence = _rs.getRaw("LICENSE.SDL");
if(ImGui::BeginChild("##SDLLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { if(ImGui::BeginChild("##SDLLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(sdl_licence.data(), sdl_licence.data() + sdl_licence.size(), ImGuiTextFlags_None); ImGui::TextUnformatted(sdl_licence.begin(), sdl_licence.end());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -223,7 +224,7 @@ void SaveTool::drawAbout() {
static auto libzip_licence = _rs.getRaw("LICENSE.libzip"); static auto libzip_licence = _rs.getRaw("LICENSE.libzip");
if(ImGui::BeginChild("##libzipLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { if(ImGui::BeginChild("##libzipLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(libzip_licence.data(), libzip_licence.data() + libzip_licence.size(), ImGuiTextFlags_None); ImGui::TextUnformatted(libzip_licence.begin(), libzip_licence.end());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -248,7 +249,7 @@ void SaveTool::drawAbout() {
static auto efsw_licence = _rs.getRaw("LICENSE.efsw"); static auto efsw_licence = _rs.getRaw("LICENSE.efsw");
if(ImGui::BeginChild("##efswLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { if(ImGui::BeginChild("##efswLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(efsw_licence.data(), efsw_licence.data() + efsw_licence.size(), ImGuiTextFlags_None); ImGui::TextUnformatted(efsw_licence.begin(), efsw_licence.end());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -274,7 +275,7 @@ void SaveTool::drawAbout() {
static auto curl_licence = _rs.getRaw("LICENSE.curl"); static auto curl_licence = _rs.getRaw("LICENSE.curl");
if(ImGui::BeginChild("##libcurlLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { if(ImGui::BeginChild("##libcurlLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(curl_licence.data(), curl_licence.data() + curl_licence.size(), ImGuiTextFlags_None); ImGui::TextUnformatted(curl_licence.begin(), curl_licence.end());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();

View file

@ -22,7 +22,8 @@
#include "SaveTool.h" #include "SaveTool.h"
void SaveTool::drawMainMenu() { void
SaveTool::drawMainMenu() {
if(!ImGui::BeginMainMenuBar()) { if(!ImGui::BeginMainMenuBar()) {
return; return;
} }

View file

@ -37,7 +37,10 @@ constexpr Vector2 padding{20.0f, 20.0f};
constexpr Float toast_spacing = 10.0f; constexpr Float toast_spacing = 10.0f;
Toast::Toast(Type type, Containers::StringView message, std::chrono::milliseconds timeout): Toast::Toast(Type type, Containers::StringView message, std::chrono::milliseconds timeout):
_type{type}, _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>{{ _phaseTrack = Animation::Track<UnsignedInt, Phase>{{
{0, Phase::FadeIn}, {0, Phase::FadeIn},
@ -47,31 +50,38 @@ Toast::Toast(Type type, Containers::StringView message, std::chrono::millisecond
}, Math::select, Animation::Extrapolation::Constant}; }, Math::select, Animation::Extrapolation::Constant};
} }
auto Toast::type() -> Type { Toast::Type
Toast::type() {
return _type; return _type;
} }
auto Toast::message() -> Containers::StringView { Containers::StringView
Toast::message() {
return _message; return _message;
} }
auto Toast::timeout() -> std::chrono::milliseconds { std::chrono::milliseconds
Toast::timeout() {
return _timeout; return _timeout;
} }
auto Toast::creationTime() -> std::chrono::steady_clock::time_point { std::chrono::steady_clock::time_point
Toast::creationTime() {
return _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); 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()); return _phaseTrack.at(elapsedTime().count());
} }
auto Toast::opacity() -> Float { Float
Toast::opacity() {
Phase phase = this->phase(); Phase phase = this->phase();
Long elapsed_time = elapsedTime().count(); Long elapsed_time = elapsedTime().count();
@ -85,15 +95,18 @@ auto Toast::opacity() -> Float {
return 1.0f; return 1.0f;
} }
void ToastQueue::addToast(Toast&& toast) { void
ToastQueue::addToast(Toast&& toast) {
_toasts.push_back(std::move(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); _toasts.emplace_back(type, message, timeout);
} }
void ToastQueue::draw(Vector2i viewport_size) { void
ToastQueue::draw(Vector2i viewport_size) {
Float height = 0.0f; Float height = 0.0f;
for(UnsignedInt i = 0; i < _toasts.size(); i++) { for(UnsignedInt i = 0; i < _toasts.size(); i++) {
@ -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); _toasts.erase(_toasts.begin() + index);
} }

View file

@ -46,19 +46,19 @@ class Toast {
Toast(Toast&& other) = default; Toast(Toast&& other) = default;
Toast& operator=(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: private:
Type _type{Type::Default}; Type _type{Type::Default};

View file

@ -35,72 +35,89 @@ BinaryReader::~BinaryReader() {
closeFile(); closeFile();
} }
auto BinaryReader::open() -> bool { bool
BinaryReader::open() {
return _file; return _file;
} }
auto BinaryReader::eof() -> bool { bool
BinaryReader::eof() {
return std::feof(_file) != 0; return std::feof(_file) != 0;
} }
auto BinaryReader::position() -> Long { Long
BinaryReader::position() {
return _ftelli64(_file); return _ftelli64(_file);
} }
auto BinaryReader::seek(Long position) -> bool { bool
BinaryReader::seek(Long position) {
return _fseeki64(_file, position, SEEK_SET) == 0; return _fseeki64(_file, position, SEEK_SET) == 0;
} }
void BinaryReader::closeFile() { void
BinaryReader::closeFile() {
std::fclose(_file); std::fclose(_file);
_file = nullptr; _file = nullptr;
} }
auto BinaryReader::readChar(char& value) -> bool { bool
BinaryReader::readChar(char& value) {
return std::fread(&value, sizeof(char), 1, _file) == 1; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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) { if(array.size() < count) {
array = Containers::Array<char>{ValueInit, 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; 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; UnsignedInt length = 0;
if(!readUnsignedInt(length) || length == 0) { if(!readUnsignedInt(length) || length == 0) {
return false; return false;
@ -119,7 +137,8 @@ auto BinaryReader::readUEString(Containers::String& str) -> bool {
return std::fread(str.data(), sizeof(char), length, _file) == length; return std::fread(str.data(), sizeof(char), length, _file) == length;
} }
auto BinaryReader::peekChar() -> Int { Int
BinaryReader::peekChar() {
Int c; Int c;
c = std::fgetc(_file); c = std::fgetc(_file);
std::ungetc(c, _file); std::ungetc(c, _file);

View file

@ -32,40 +32,40 @@ class BinaryReader {
explicit BinaryReader(Containers::StringView filename); explicit BinaryReader(Containers::StringView filename);
~BinaryReader(); ~BinaryReader();
auto open() -> bool; bool open();
auto eof() -> bool; bool eof();
auto position() -> Long; Long position();
auto seek(Long position) -> bool; bool seek(Long position);
void closeFile(); void closeFile();
auto readChar(char& value) -> bool; bool readChar(char& value);
auto readByte(Byte& value) -> bool; bool readByte(Byte& value);
auto readUnsignedByte(UnsignedByte& value) -> bool; bool readUnsignedByte(UnsignedByte& value);
auto readShort(Short& value) -> bool; bool readShort(Short& value);
auto readUnsignedShort(UnsignedShort& value) -> bool; bool readUnsignedShort(UnsignedShort& value);
auto readInt(Int& value) -> bool; bool readInt(Int& value);
auto readUnsignedInt(UnsignedInt& value) -> bool; bool readUnsignedInt(UnsignedInt& value);
auto readLong(Long& value) -> bool; bool readLong(Long& value);
auto readUnsignedLong(UnsignedLong& value) -> bool; bool readUnsignedLong(UnsignedLong& value);
auto readFloat(Float& value) -> bool; bool readFloat(Float& value);
auto readDouble(Double& value) -> bool; bool readDouble(Double& value);
auto readArray(Containers::Array<char>& array, std::size_t count) -> bool; bool readArray(Containers::Array<char>& array, std::size_t count);
template<typename T> template<typename T>
auto readValue(T& value) -> bool { bool readValue(T& value) {
return fread(&value, sizeof(T), 1, _file) == sizeof(T); return fread(&value, sizeof(T), 1, _file) == sizeof(T);
} }
template<std::size_t S> template<std::size_t S>
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; 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: private:
std::FILE* _file = nullptr; std::FILE* _file = nullptr;

View file

@ -33,29 +33,35 @@ BinaryWriter::~BinaryWriter() {
closeFile(); closeFile();
} }
auto BinaryWriter::open() -> bool { bool
BinaryWriter::open() {
return _file; return _file;
} }
void BinaryWriter::closeFile() { void
BinaryWriter::closeFile() {
std::fflush(_file); std::fflush(_file);
std::fclose(_file); std::fclose(_file);
_file = nullptr; _file = nullptr;
} }
auto BinaryWriter::position() -> Long { Long
BinaryWriter::position() {
return _ftelli64(_file); return _ftelli64(_file);
} }
auto BinaryWriter::array() const -> Containers::ArrayView<const char> { Containers::ArrayView<const char>
BinaryWriter::array() const {
return _data; return _data;
} }
auto BinaryWriter::arrayPosition() const -> UnsignedLong { UnsignedLong
BinaryWriter::arrayPosition() const {
return _index; return _index;
} }
auto BinaryWriter::flushToFile() -> bool { bool
BinaryWriter::flushToFile() {
bool ret = writeArray(_data); bool ret = writeArray(_data);
std::fflush(_file); std::fflush(_file);
_data = Containers::Array<char>{}; _data = Containers::Array<char>{};
@ -63,51 +69,63 @@ auto BinaryWriter::flushToFile() -> bool {
return ret; return ret;
} }
auto BinaryWriter::writeChar(char value) -> bool { bool
BinaryWriter::writeChar(char value) {
return std::fwrite(&value, sizeof(char), 1, _file) == 1; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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) { if(array.size() == 0) {
return false; 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(); 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) { if(str.size() > UINT32_MAX) {
LOG_ERROR_FORMAT("String is too big. Expected size() < UINT32_MAX, got {} instead.", str.size()); LOG_ERROR_FORMAT("String is too big. Expected size() < UINT32_MAX, got {} instead.", str.size());
return false; return false;
@ -132,7 +151,8 @@ auto BinaryWriter::writeUEString(Containers::StringView str) -> bool {
return writeChar('\0'); return writeChar('\0');
} }
auto BinaryWriter::writeUEStringToArray(Containers::StringView value) -> UnsignedLong { UnsignedLong
BinaryWriter::writeUEStringToArray(Containers::StringView value) {
return writeValueToArray<UnsignedInt>(UnsignedInt(value.size()) + 1u) + return writeValueToArray<UnsignedInt>(UnsignedInt(value.size()) + 1u) +
writeDataToArray(Containers::ArrayView<const char>{value}) + writeDataToArray(Containers::ArrayView<const char>{value}) +
writeValueToArray<char>('\0'); writeValueToArray<char>('\0');

View file

@ -39,47 +39,47 @@ class BinaryWriter {
BinaryWriter(BinaryWriter&& other) = default; BinaryWriter(BinaryWriter&& other) = default;
BinaryWriter& operator=(BinaryWriter&& other) = default; BinaryWriter& operator=(BinaryWriter&& other) = default;
auto open() -> bool; bool open();
void closeFile(); void closeFile();
auto position() -> Long; Long position();
auto array() const -> Containers::ArrayView<const char>; Containers::ArrayView<const char> array() const;
auto arrayPosition() const -> UnsignedLong; UnsignedLong arrayPosition() const;
auto flushToFile() -> bool; bool flushToFile();
auto writeByte(Byte value) -> bool; bool writeByte(Byte value);
auto writeChar(char value) -> bool; bool writeChar(char value);
auto writeUnsignedByte(UnsignedByte value) -> bool; bool writeUnsignedByte(UnsignedByte value);
auto writeShort(Short value) -> bool; bool writeShort(Short value);
auto writeUnsignedShort(UnsignedShort value) -> bool; bool writeUnsignedShort(UnsignedShort value);
auto writeInt(Int value) -> bool; bool writeInt(Int value);
auto writeUnsignedInt(UnsignedInt value) -> bool; bool writeUnsignedInt(UnsignedInt value);
auto writeLong(Long value) -> bool; bool writeLong(Long value);
auto writeUnsignedLong(UnsignedLong value) -> bool; bool writeUnsignedLong(UnsignedLong value);
auto writeFloat(Float value) -> bool; bool writeFloat(Float value);
auto writeDouble(Double value) -> bool; bool writeDouble(Double value);
auto writeArray(Containers::ArrayView<const char> array) -> bool; bool writeArray(Containers::ArrayView<const char> array);
template<std::size_t size> template<std::size_t size>
auto writeString(const char(&str)[size]) -> bool { bool writeString(const char(&str)[size]) {
return writeArray({str, size - 1}); return writeArray({str, size - 1});
} }
template<std::size_t S> 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; 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&>> 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}; Containers::ArrayView<T> view{&value, 1};
return writeDataToArray(view); return writeDataToArray(view);
} }
auto writeUEStringToArray(Containers::StringView value) -> UnsignedLong; UnsignedLong writeUEStringToArray(Containers::StringView value);
template<typename T> template<typename T>
void writeValueToArrayAt(T& value, UnsignedLong position) { void writeValueToArrayAt(T& value, UnsignedLong position) {
@ -88,7 +88,7 @@ class BinaryWriter {
} }
template<typename T> template<typename T>
auto writeDataToArray(Containers::ArrayView<T> view) -> UnsignedLong { UnsignedLong writeDataToArray(Containers::ArrayView<T> view) {
arrayAppend(_data, Containers::arrayCast<const char>(view)); arrayAppend(_data, Containers::arrayCast<const char>(view));
_index += sizeof(T) * view.size(); _index += sizeof(T) * view.size();
return sizeof(T) * view.size(); return sizeof(T) * view.size();

View file

@ -22,17 +22,20 @@
#include "Debug.h" #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 << ":" << return debug << (*prop->name) << Utility::Debug::nospace << ":" <<
prop->propertyType << "of" << prop->items.size() << prop->itemType; prop->propertyType << "of" << prop->items.size() << prop->itemType;
} }
Utility::Debug& operator<<(Utility::Debug& debug, const SetProperty* prop) { Utility::Debug&
operator<<(Utility::Debug& debug, const SetProperty* prop) {
return debug << (*prop->name) << Utility::Debug::nospace << ":" << return debug << (*prop->name) << Utility::Debug::nospace << ":" <<
prop->propertyType << "of" << prop->items.size() << prop->itemType; prop->propertyType << "of" << prop->items.size() << prop->itemType;
} }
Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* prop) { Utility::Debug&
operator<<(Utility::Debug& debug, const GenericStructProperty* prop) {
debug << (*prop->name) << Utility::Debug::nospace << ":" << debug << (*prop->name) << Utility::Debug::nospace << ":" <<
prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace << prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace <<
") Contents:"; ") Contents:";
@ -42,7 +45,8 @@ Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* p
return debug; 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); auto cast = dynamic_cast<const GenericStructProperty*>(prop);
if(cast) { if(cast) {
return debug << 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 << ")"; 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") { if(prop->propertyType == "ArrayProperty") {
auto array_prop = dynamic_cast<const ArrayProperty*>(prop); auto array_prop = dynamic_cast<const ArrayProperty*>(prop);
if(array_prop) { if(array_prop) {

View file

@ -67,12 +67,14 @@ PropertySerialiser::PropertySerialiser() {
arrayAppend(_collectionSerialisers, Containers::pointer<StructSerialiser>()); arrayAppend(_collectionSerialisers, Containers::pointer<StructSerialiser>());
} }
auto PropertySerialiser::instance() -> PropertySerialiser& { PropertySerialiser&
PropertySerialiser::instance() {
static PropertySerialiser serialiser; static PropertySerialiser serialiser;
return serialiser; return serialiser;
} }
auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr { UnrealPropertyBase::ptr
PropertySerialiser::read(BinaryReader& reader) {
if(reader.peekChar() < 0 || reader.eof()) { if(reader.peekChar() < 0 || reader.eof()) {
return nullptr; return nullptr;
} }
@ -99,8 +101,10 @@ auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr {
return deserialise(std::move(name), std::move(type), value_length, reader); return deserialise(std::move(name), std::move(type), value_length, reader);
} }
auto PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, UnrealPropertyBase::ptr
Containers::String name) -> UnrealPropertyBase::ptr { PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length,
Containers::String name)
{
if(reader.peekChar() < 0 || reader.eof()) { if(reader.peekChar() < 0 || reader.eof()) {
return nullptr; 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); return deserialise(std::move(name), std::move(type), value_length, reader);
} }
auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, Containers::Array<UnrealPropertyBase::ptr>
UnsignedInt count) -> Containers::Array<UnrealPropertyBase::ptr> PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, UnsignedInt count) {
{
if(reader.peekChar() < 0 || reader.eof()) { if(reader.peekChar() < 0 || reader.eof()) {
return nullptr; return nullptr;
} }
@ -153,8 +156,9 @@ auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView it
return array; return array;
} }
auto PropertySerialiser::deserialise(Containers::String name, Containers::String type, UnsignedLong value_length, UnrealPropertyBase::ptr
BinaryReader& reader) -> UnrealPropertyBase::ptr PropertySerialiser::deserialise(Containers::String name, Containers::String type, UnsignedLong value_length,
BinaryReader& reader)
{ {
UnrealPropertyBase::ptr prop; UnrealPropertyBase::ptr prop;
auto serialiser = getSerialiser(type); auto serialiser = getSerialiser(type);
@ -176,8 +180,8 @@ auto PropertySerialiser::deserialise(Containers::String name, Containers::String
return prop; return prop;
} }
auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool UnsignedLong& bytes_written, BinaryWriter& writer)
{ {
auto serialiser = getSerialiser(item_type); auto serialiser = getSerialiser(item_type);
if(!serialiser) { if(!serialiser) {
@ -186,7 +190,8 @@ auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St
return serialiser->serialise(prop, bytes_written, writer, *this); 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())) { if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) {
bytes_written += writer.writeUEStringToArray(*prop->name); bytes_written += writer.writeUEStringToArray(*prop->name);
return true; return true;
@ -209,8 +214,9 @@ auto PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& byte
return ret; return ret;
} }
auto PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, bool
UnsignedLong& bytes_written, BinaryWriter& writer) -> 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())) { if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) {
bytes_written += writer.writeUEStringToArray(*prop->name); 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); return serialise(prop, item_type, bytes_written, writer);
} }
auto PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, bool PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props,
Containers::StringView item_type, UnsignedLong& bytes_written, Containers::StringView item_type, UnsignedLong& bytes_written, BinaryWriter& writer)
BinaryWriter& writer) -> bool
{ {
auto serialiser = getCollectionSerialiser(item_type); auto serialiser = getCollectionSerialiser(item_type);
if(serialiser) { 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& item : _serialisers) {
for(auto serialiser_type : item->types()) { for(auto serialiser_type : item->types()) {
if(item_type == serialiser_type) { if(item_type == serialiser_type) {
@ -251,7 +257,8 @@ auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> Abst
return nullptr; return nullptr;
} }
auto PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) -> AbstractUnrealCollectionPropertySerialiser* { AbstractUnrealCollectionPropertySerialiser*
PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) {
for(auto& item : _collectionSerialisers) { for(auto& item : _collectionSerialisers) {
for(Containers::StringView serialiser_type : item->types()) { for(Containers::StringView serialiser_type : item->types()) {
if(item_type == serialiser_type) { if(item_type == serialiser_type) {

View file

@ -32,28 +32,29 @@ class BinaryWriter;
class PropertySerialiser { class PropertySerialiser {
public: public:
static auto instance() -> PropertySerialiser&; static PropertySerialiser& instance();
auto read(BinaryReader& reader) -> UnrealPropertyBase::ptr; UnrealPropertyBase::ptr read(BinaryReader& reader);
auto readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, UnrealPropertyBase::ptr readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length,
Containers::String name) -> UnrealPropertyBase::ptr; Containers::String name);
auto readSet(BinaryReader& reader, Containers::StringView item_type, UnsignedInt count) -> Containers::Array<UnrealPropertyBase::ptr>; Containers::Array<UnrealPropertyBase::ptr> readSet(BinaryReader& reader, Containers::StringView item_type,
auto deserialise(Containers::String name, Containers::String type, UnsignedLong value_length, UnsignedInt count);
BinaryReader& reader) -> UnrealPropertyBase::ptr; 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, bool serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written,
BinaryWriter& writer) -> bool; BinaryWriter& writer);
auto write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool; bool write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer);
auto writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written, bool writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written,
BinaryWriter& writer) -> bool; BinaryWriter& writer);
auto writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type, bool writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool; UnsignedLong& bytes_written, BinaryWriter& writer);
private: private:
PropertySerialiser(); PropertySerialiser();
auto getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser*; AbstractUnrealPropertySerialiser* getSerialiser(Containers::StringView item_type);
auto getCollectionSerialiser(Containers::StringView item_type) -> AbstractUnrealCollectionPropertySerialiser*; AbstractUnrealCollectionPropertySerialiser* getCollectionSerialiser(Containers::StringView item_type);
Containers::Array<AbstractUnrealPropertySerialiser::ptr> _serialisers; Containers::Array<AbstractUnrealPropertySerialiser::ptr> _serialisers;
Containers::Array<AbstractUnrealCollectionPropertySerialiser::ptr> _collectionSerialisers; Containers::Array<AbstractUnrealCollectionPropertySerialiser::ptr> _collectionSerialisers;

View file

@ -32,17 +32,20 @@ class BinaryReader;
class BinaryWriter; class BinaryWriter;
class PropertySerialiser; class PropertySerialiser;
using PropertyArray = Containers::Array<UnrealPropertyBase::ptr>;
using PropertyArrayView = Containers::ArrayView<UnrealPropertyBase::ptr>;
class AbstractUnrealCollectionPropertySerialiser { class AbstractUnrealCollectionPropertySerialiser {
public: public:
using ptr = Containers::Pointer<AbstractUnrealCollectionPropertySerialiser>; using ptr = Containers::Pointer<AbstractUnrealCollectionPropertySerialiser>;
virtual ~AbstractUnrealCollectionPropertySerialiser() = default; virtual ~AbstractUnrealCollectionPropertySerialiser() = default;
virtual 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, 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, virtual auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0; UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0;

View file

@ -31,17 +31,20 @@ class BinaryReader;
class BinaryWriter; class BinaryWriter;
class PropertySerialiser; class PropertySerialiser;
using StringArrayView = Containers::ArrayView<const Containers::String>;
class AbstractUnrealPropertySerialiser { class AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<AbstractUnrealPropertySerialiser>; using ptr = Containers::Pointer<AbstractUnrealPropertySerialiser>;
virtual ~AbstractUnrealPropertySerialiser() = default; virtual ~AbstractUnrealPropertySerialiser() = default;
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0; virtual StringArrayView types() = 0;
virtual auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, virtual UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr = 0; UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) = 0;
virtual auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, virtual bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool = 0; PropertySerialiser& serialiser) = 0;
}; };

View file

@ -37,10 +37,10 @@ class AbstractUnrealStructSerialiser {
virtual ~AbstractUnrealStructSerialiser() = default; 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, virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer,
UnsignedLong& bytes_written) -> bool = 0; UnsignedLong& bytes_written) = 0;
}; };

View file

@ -23,9 +23,10 @@
#include "ArrayPropertySerialiser.h" #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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
Containers::String item_type; Containers::String item_type;
if(!reader.readUEString(item_type)) { if(!reader.readUEString(item_type)) {
@ -52,8 +53,9 @@ auto ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, C
return prop; return prop;
} }
auto ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto array_prop = dynamic_cast<ArrayProperty*>(prop.get()); auto array_prop = dynamic_cast<ArrayProperty*>(prop.get());
if(!array_prop) { if(!array_prop) {

View file

@ -32,8 +32,9 @@ class ArrayPropertySerialiser : public UnrealPropertySerialiser<ArrayProperty> {
using ptr = Containers::Pointer<ArrayPropertySerialiser>; using ptr = Containers::Pointer<ArrayPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -20,15 +20,16 @@
#include "BoolPropertySerialiser.h" #include "BoolPropertySerialiser.h"
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> { StringArrayView
BoolPropertySerialiser::types() {
using namespace Containers::Literals; using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"BoolProperty"_s}}; static const Containers::Array<Containers::String> types{InPlaceInit, {"BoolProperty"_s}};
return types; return types;
} }
auto BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr
UnsignedLong value_length, BinaryReader& reader, BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr BinaryReader& reader, PropertySerialiser& serialiser)
{ {
if(value_length != 0) { if(value_length != 0) {
LOG_ERROR_FORMAT("Invalid value length for bool property {}. Expected 0, got {} instead.", name, value_length); LOG_ERROR_FORMAT("Invalid value length for bool property {}. Expected 0, got {} instead.", name, value_length);
@ -52,8 +53,9 @@ auto BoolPropertySerialiser::deserialise(Containers::StringView name, Containers
return prop; return prop;
} }
auto BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{ {
auto bool_prop = dynamic_cast<BoolProperty*>(prop.get()); auto bool_prop = dynamic_cast<BoolProperty*>(prop.get());
if(!bool_prop) { if(!bool_prop) {

View file

@ -29,11 +29,12 @@ class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<BoolPropertySerialiser>; 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, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override; PropertySerialiser& serialiser) override;
}; };

View file

@ -20,15 +20,16 @@
#include "BytePropertySerialiser.h" #include "BytePropertySerialiser.h"
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::String> { StringArrayView
BytePropertySerialiser::types() {
using namespace Containers::Literals; using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"ByteProperty"_s}}; static const Containers::Array<Containers::String> types{InPlaceInit, {"ByteProperty"_s}};
return types; return types;
} }
auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr
UnsignedLong value_length, BinaryReader& reader, BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr BinaryReader& reader, PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<ByteProperty>(); auto prop = Containers::pointer<ByteProperty>();
@ -64,8 +65,9 @@ auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers
return prop; return prop;
} }
auto BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{ {
auto byte_prop = dynamic_cast<ByteProperty*>(prop.get()); auto byte_prop = dynamic_cast<ByteProperty*>(prop.get());
if(!byte_prop) { if(!byte_prop) {

View file

@ -27,11 +27,12 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<BytePropertySerialiser>; 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, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override; PropertySerialiser& serialiser) override;
}; };

View file

@ -20,9 +20,10 @@
#include "ColourPropertySerialiser.h" #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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<ColourStructProperty>(); auto prop = Containers::pointer<ColourStructProperty>();
@ -36,8 +37,9 @@ auto ColourPropertySerialiser::deserialiseProperty(Containers::StringView name,
return prop; return prop;
} }
auto ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto colour_prop = dynamic_cast<ColourStructProperty*>(prop.get()); auto colour_prop = dynamic_cast<ColourStructProperty*>(prop.get());
if(!colour_prop) { if(!colour_prop) {
@ -45,8 +47,10 @@ auto ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop,
return false; return false;
} }
bytes_written += writer.writeValueToArray<Float>(colour_prop->r) + writer.writeValueToArray<Float>(colour_prop->g) + bytes_written += writer.writeValueToArray<Float>(colour_prop->r) +
writer.writeValueToArray<Float>(colour_prop->b) + writer.writeValueToArray<Float>(colour_prop->a); writer.writeValueToArray<Float>(colour_prop->g) +
writer.writeValueToArray<Float>(colour_prop->b) +
writer.writeValueToArray<Float>(colour_prop->a);
return true; return true;
} }

View file

@ -29,8 +29,9 @@ class ColourPropertySerialiser : public UnrealPropertySerialiser<ColourStructPro
using ptr = Containers::Pointer<ColourPropertySerialiser>; using ptr = Containers::Pointer<ColourPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -20,9 +20,10 @@
#include "DateTimePropertySerialiser.h" #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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<DateTimeStructProperty>(); auto prop = Containers::pointer<DateTimeStructProperty>();
@ -34,8 +35,9 @@ auto DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name
return prop; return prop;
} }
auto DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto dt_prop = dynamic_cast<DateTimeStructProperty*>(prop.get()); auto dt_prop = dynamic_cast<DateTimeStructProperty*>(prop.get());
if(!dt_prop) { if(!dt_prop) {

View file

@ -27,8 +27,9 @@ class DateTimePropertySerialiser : public UnrealPropertySerialiser<DateTimeStruc
using ptr = Containers::Pointer<DateTimePropertySerialiser>; using ptr = Containers::Pointer<DateTimePropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -20,15 +20,16 @@
#include "EnumPropertySerialiser.h" #include "EnumPropertySerialiser.h"
auto EnumPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> { StringArrayView
EnumPropertySerialiser::types() {
using namespace Containers::Literals; using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"EnumProperty"_s}}; static const Containers::Array<Containers::String> types{InPlaceInit, {"EnumProperty"_s}};
return types; return types;
} }
auto EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr
UnsignedLong value_length, BinaryReader& reader, EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr BinaryReader& reader, PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<EnumProperty>(); auto prop = Containers::pointer<EnumProperty>();
@ -51,8 +52,9 @@ auto EnumPropertySerialiser::deserialise(Containers::StringView name, Containers
return prop; return prop;
} }
auto EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{ {
auto enum_prop = dynamic_cast<EnumProperty*>(prop.get()); auto enum_prop = dynamic_cast<EnumProperty*>(prop.get());
if(!enum_prop) { if(!enum_prop) {

View file

@ -27,11 +27,12 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<EnumPropertySerialiser>; 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, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override; PropertySerialiser& serialiser) override;
}; };

View file

@ -20,15 +20,16 @@
#include "FloatPropertySerialiser.h" #include "FloatPropertySerialiser.h"
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> { StringArrayView
FloatPropertySerialiser::types() {
using namespace Containers::Literals; using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"FloatProperty"_s}}; static const Containers::Array<Containers::String> types{InPlaceInit, {"FloatProperty"_s}};
return types; return types;
} }
auto FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr
UnsignedLong value_length, BinaryReader& reader, FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<FloatProperty>(); auto prop = Containers::pointer<FloatProperty>();
@ -46,8 +47,9 @@ auto FloatPropertySerialiser::deserialise(Containers::StringView name, Container
return prop; return prop;
} }
auto FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{ {
auto float_prop = dynamic_cast<FloatProperty*>(prop.get()); auto float_prop = dynamic_cast<FloatProperty*>(prop.get());
if(!float_prop) { if(!float_prop) {

View file

@ -27,11 +27,12 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<FloatPropertySerialiser>; 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, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override; PropertySerialiser& serialiser) override;
}; };

View file

@ -22,9 +22,10 @@
using namespace Containers::Literals; 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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<GuidStructProperty>(); auto prop = Containers::pointer<GuidStructProperty>();
@ -36,8 +37,9 @@ auto GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Co
return prop; return prop;
} }
auto GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto guid_prop = dynamic_cast<GuidStructProperty*>(prop.get()); auto guid_prop = dynamic_cast<GuidStructProperty*>(prop.get());
if(!guid_prop) { if(!guid_prop) {

View file

@ -27,8 +27,9 @@ class GuidPropertySerialiser : public UnrealPropertySerialiser<GuidStructPropert
using ptr = Containers::Pointer<GuidPropertySerialiser>; using ptr = Containers::Pointer<GuidPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -20,9 +20,10 @@
#include "IntPropertySerialiser.h" #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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<IntProperty>(); auto prop = Containers::pointer<IntProperty>();
@ -52,8 +53,9 @@ auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
return prop; return prop;
} }
auto IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto int_prop = dynamic_cast<IntProperty*>(prop.get()); auto int_prop = dynamic_cast<IntProperty*>(prop.get());
if(!int_prop) { if(!int_prop) {

View file

@ -27,8 +27,9 @@ class IntPropertySerialiser : public UnrealPropertySerialiser<IntProperty> {
using ptr = Containers::Pointer<IntPropertySerialiser>; using ptr = Containers::Pointer<IntPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -24,9 +24,10 @@
using namespace Containers::Literals; 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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<MapProperty>(); auto prop = Containers::pointer<MapProperty>();
@ -107,8 +108,9 @@ auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
return prop; return prop;
} }
auto MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto map_prop = dynamic_cast<MapProperty*>(prop.get()); auto map_prop = dynamic_cast<MapProperty*>(prop.get());
if(!map_prop) { if(!map_prop) {

View file

@ -27,8 +27,9 @@ class MapPropertySerialiser : public UnrealPropertySerialiser<MapProperty> {
using ptr = Containers::Pointer<MapPropertySerialiser>; using ptr = Containers::Pointer<MapPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -25,9 +25,10 @@
using namespace Containers::Literals; 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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<ResourceItemValue>(); auto prop = Containers::pointer<ResourceItemValue>();
@ -77,8 +78,9 @@ auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name
return prop; return prop;
} }
auto ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto res_prop = dynamic_cast<ResourceItemValue*>(prop.get()); auto res_prop = dynamic_cast<ResourceItemValue*>(prop.get());
if(!res_prop) { if(!res_prop) {

View file

@ -27,8 +27,9 @@ class ResourcePropertySerialiser : public UnrealPropertySerialiser<ResourceItemV
using ptr = Containers::Pointer<ResourcePropertySerialiser>; using ptr = Containers::Pointer<ResourcePropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -20,9 +20,10 @@
#include "RotatorPropertySerialiser.h" #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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<RotatorStructProperty>(); auto prop = Containers::pointer<RotatorStructProperty>();
@ -34,8 +35,9 @@ auto RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name,
return prop; return prop;
} }
auto RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto rotator = dynamic_cast<RotatorStructProperty*>(prop.get()); auto rotator = dynamic_cast<RotatorStructProperty*>(prop.get());
if(!rotator) { if(!rotator) {

View file

@ -27,8 +27,9 @@ class RotatorPropertySerialiser : public UnrealPropertySerialiser<RotatorStructP
using ptr = Containers::Pointer<RotatorPropertySerialiser>; using ptr = Containers::Pointer<RotatorPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -21,9 +21,10 @@
#include "SetPropertySerialiser.h" #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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
Containers::String item_type; Containers::String item_type;
if(!reader.readUEString(item_type)) { if(!reader.readUEString(item_type)) {
@ -56,8 +57,9 @@ auto SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
return prop; return prop;
} }
auto SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto set_prop = dynamic_cast<SetProperty*>(prop.get()); auto set_prop = dynamic_cast<SetProperty*>(prop.get());
if(!set_prop) { if(!set_prop) {

View file

@ -27,8 +27,9 @@ class SetPropertySerialiser : public UnrealPropertySerialiser<SetProperty> {
using ptr = Containers::Pointer<SetPropertySerialiser>; using ptr = Containers::Pointer<SetPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -20,17 +20,18 @@
#include "StringPropertySerialiser.h" #include "StringPropertySerialiser.h"
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> { StringArrayView
StringPropertySerialiser::types() {
using namespace Containers::Literals; using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, static const Containers::Array<Containers::String> types{InPlaceInit, {
{"NameProperty"_s, "StrProperty"_s, "NameProperty"_s, "StrProperty"_s, "SoftObjectProperty"_s, "ObjectProperty"_s
"SoftObjectProperty"_s, "ObjectProperty"_s}}; }};
return types; return types;
} }
auto StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr
UnsignedLong value_length, BinaryReader& reader, StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<StringProperty>(type); auto prop = Containers::pointer<StringProperty>(type);
@ -52,8 +53,9 @@ auto StringPropertySerialiser::deserialise(Containers::StringView name, Containe
return prop; return prop;
} }
auto StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{ {
auto str_prop = dynamic_cast<StringProperty*>(prop.get()); auto str_prop = dynamic_cast<StringProperty*>(prop.get());
if(!str_prop) { if(!str_prop) {

View file

@ -27,11 +27,12 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<StringPropertySerialiser>; 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, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override; PropertySerialiser& serialiser) override;
}; };

View file

@ -25,14 +25,16 @@
#include "StructSerialiser.h" #include "StructSerialiser.h"
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::String> { StringArrayView
StructSerialiser::types() {
using namespace Containers::Literals; using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"StructProperty"_s}}; static const Containers::Array<Containers::String> types{InPlaceInit, {"StructProperty"_s}};
return types; return types;
} }
auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, Containers::Array<UnrealPropertyBase::ptr>
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> 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; Containers::String item_type;
if(!reader.readUEString(item_type)) { if(!reader.readUEString(item_type)) {
@ -83,8 +85,9 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
return array; return array;
} }
auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser)
{ {
Containers::String item_type; Containers::String item_type;
if(!reader.readUEString(item_type)) { if(!reader.readUEString(item_type)) {
@ -120,8 +123,9 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
return prop; return prop;
} }
auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type, bool
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> 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(*(props.front()->name));
bytes_written += writer.writeUEStringToArray(item_type); bytes_written += writer.writeUEStringToArray(item_type);
@ -163,8 +167,9 @@ auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr>
return true; return true;
} }
auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{ {
auto struct_prop = dynamic_cast<StructProperty*>(prop.get()); auto struct_prop = dynamic_cast<StructProperty*>(prop.get());
if(!struct_prop) { if(!struct_prop) {
@ -189,8 +194,9 @@ auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& by
return true; return true;
} }
auto StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, StructProperty::ptr
BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser)
{ {
auto st_prop = Containers::pointer<GenericStructProperty>(); auto st_prop = Containers::pointer<GenericStructProperty>();
st_prop->structType = type; st_prop->structType = type;
@ -212,8 +218,9 @@ auto StructSerialiser::readStructValue(Containers::StringView name, Containers::
return st_prop; return st_prop;
} }
auto StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{ {
auto struct_prop = dynamic_cast<GenericStructProperty*>(prop); auto struct_prop = dynamic_cast<GenericStructProperty*>(prop);
if(!struct_prop) { if(!struct_prop) {

View file

@ -29,20 +29,23 @@ class StructSerialiser : public AbstractUnrealPropertySerialiser, public Abstrac
public: public:
using ptr = Containers::Pointer<StructSerialiser>; 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, PropertyArray deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> override; UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type, bool serialise(PropertyArrayView props, Containers::StringView item_type, UnsignedLong& bytes_written,
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override; BinaryWriter& writer, PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override; PropertySerialiser& serialiser) override;
private: private:
auto readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, StructProperty::ptr readStructValue(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr; UnsignedLong value_length, BinaryReader& reader,
auto writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool; PropertySerialiser& serialiser);
bool writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser);
} ; } ;

View file

@ -21,9 +21,10 @@
#include "TextPropertySerialiser.h" #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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<TextProperty>(); auto prop = Containers::pointer<TextProperty>();
@ -68,8 +69,9 @@ auto TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Co
return prop; return prop;
} }
auto TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto text_prop = dynamic_cast<TextProperty*>(prop.get()); auto text_prop = dynamic_cast<TextProperty*>(prop.get());

View file

@ -27,8 +27,9 @@ class TextPropertySerialiser : public UnrealPropertySerialiser<TextProperty> {
using ptr = Containers::Pointer<TextPropertySerialiser>; using ptr = Containers::Pointer<TextPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -32,12 +32,14 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<UnrealPropertySerialiser<T>>; using ptr = Containers::Pointer<UnrealPropertySerialiser<T>>;
auto types() -> Containers::ArrayView<const Containers::String> override { StringArrayView types() override {
static const Containers::Array<Containers::String> types = []{ static const Containers::Array<Containers::String> types = []{
Containers::Array<Containers::String> array; Containers::Array<Containers::String> array;
Containers::Pointer<T> p(new T); Containers::Pointer<T> p(new T);
if(std::is_base_of<StructProperty, T>::value) { if(std::is_base_of<StructProperty, T>::value) {
array = Containers::Array<Containers::String>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}}; array = Containers::Array<Containers::String>{InPlaceInit, {
dynamic_cast<StructProperty*>(p.get())->structType
}};
} }
else { else {
array = Containers::Array<Containers::String>{InPlaceInit, {p->propertyType}}; array = Containers::Array<Containers::String>{InPlaceInit, {p->propertyType}};
@ -47,23 +49,24 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
return types; return types;
} }
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override
{ {
return deserialiseProperty(name, type, value_length, reader, serialiser); return deserialiseProperty(name, type, value_length, reader, serialiser);
} }
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override PropertySerialiser& serialiser) override
{ {
return serialiseProperty(prop, bytes_written, writer, serialiser); return serialiseProperty(prop, bytes_written, writer, serialiser);
} }
private: 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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> typename UnrealPropertyBase::ptr = 0; PropertySerialiser& serialiser) = 0;
virtual auto serialiseProperty(typename UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, virtual bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0; PropertySerialiser& serialiser) = 0;
}; };

View file

@ -20,9 +20,10 @@
#include "Vector2DPropertySerialiser.h" #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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<Vector2DStructProperty>(); auto prop = Containers::pointer<Vector2DStructProperty>();
@ -34,8 +35,9 @@ auto Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name
return prop; return prop;
} }
auto Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto vector = dynamic_cast<Vector2DStructProperty*>(prop.get()); auto vector = dynamic_cast<Vector2DStructProperty*>(prop.get());
if(!vector) { if(!vector) {

View file

@ -27,8 +27,9 @@ class Vector2DPropertySerialiser : public UnrealPropertySerialiser<Vector2DStruc
using ptr = Containers::Pointer<Vector2DPropertySerialiser>; using ptr = Containers::Pointer<Vector2DPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -20,9 +20,10 @@
#include "VectorPropertySerialiser.h" #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, UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<VectorStructProperty>(); auto prop = Containers::pointer<VectorStructProperty>();
@ -34,8 +35,9 @@ auto VectorPropertySerialiser::deserialiseProperty(Containers::StringView name,
return prop; return prop;
} }
auto VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, bool
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto vector = dynamic_cast<VectorStructProperty*>(prop.get()); auto vector = dynamic_cast<VectorStructProperty*>(prop.get());
if(!vector) { if(!vector) {

View file

@ -27,8 +27,9 @@ class VectorPropertySerialiser : public UnrealPropertySerialiser<VectorStructPro
using ptr = Containers::Pointer<VectorPropertySerialiser>; using ptr = Containers::Pointer<VectorPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; UnsignedLong value_length, BinaryReader& reader,
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override;
PropertySerialiser& serialiser) -> bool override; bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
}; };

View file

@ -45,7 +45,7 @@ struct GenericStructProperty : public StructProperty {
atMove(Containers::StringView name) { atMove(Containers::StringView name) {
for(auto& item : properties) { for(auto& item : properties) {
if(item && item->name == name) { if(item && item->name == name) {
return Containers::Pointer<T>{static_cast<T*>(item.release())}; return Containers::pointerCast<T>(std::move(item));
} }
} }
return nullptr; return nullptr;

View file

@ -33,15 +33,18 @@ UESaveFile::UESaveFile(Containers::String filepath):
loadData(); loadData();
} }
auto UESaveFile::valid() const -> bool { bool
UESaveFile::valid() const {
return _valid; return _valid;
} }
auto UESaveFile::lastError() const -> Containers::StringView { Containers::StringView
UESaveFile::lastError() const {
return _lastError; return _lastError;
} }
auto UESaveFile::reloadData() -> bool { bool
UESaveFile::reloadData() {
if(_noReloadAfterSave) { if(_noReloadAfterSave) {
_noReloadAfterSave = false; _noReloadAfterSave = false;
return valid(); return valid();
@ -52,21 +55,25 @@ auto UESaveFile::reloadData() -> bool {
return valid(); return valid();
} }
auto UESaveFile::saveType() -> Containers::StringView { Containers::StringView
UESaveFile::saveType() {
return _saveType; return _saveType;
} }
void UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) { void
UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) {
auto none_prop = std::move(_properties.back()); auto none_prop = std::move(_properties.back());
_properties.back() = std::move(prop); _properties.back() = std::move(prop);
arrayAppend(_properties, std::move(none_prop)); arrayAppend(_properties, std::move(none_prop));
} }
auto UESaveFile::props() -> Containers::ArrayView<UnrealPropertyBase::ptr> { Containers::ArrayView<UnrealPropertyBase::ptr>
UESaveFile::props() {
return _properties; return _properties;
} }
auto UESaveFile::saveToFile() -> bool { bool
UESaveFile::saveToFile() {
LOG_INFO_FORMAT("Writing to {}.", _filepath); LOG_INFO_FORMAT("Writing to {}.", _filepath);
bool temp_file = _filepath.hasSuffix(".tmp"); bool temp_file = _filepath.hasSuffix(".tmp");
@ -155,7 +162,8 @@ auto UESaveFile::saveToFile() -> bool {
return true; return true;
} }
void UESaveFile::loadData() { void
UESaveFile::loadData() {
LOG_INFO_FORMAT("Reading data from {}.", _filepath); LOG_INFO_FORMAT("Reading data from {}.", _filepath);
_valid = false; _valid = false;

View file

@ -36,12 +36,12 @@ class UESaveFile {
public: public:
explicit UESaveFile(Containers::String filepath); explicit UESaveFile(Containers::String filepath);
auto valid() const -> bool; bool valid() const;
auto lastError() const -> Containers::StringView; Containers::StringView lastError() const;
auto reloadData() -> bool; bool reloadData();
auto saveType() -> Containers::StringView; Containers::StringView saveType();
template<typename T> template<typename T>
std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, T*> std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, T*>
@ -56,9 +56,9 @@ class UESaveFile {
void appendProperty(UnrealPropertyBase::ptr prop); void appendProperty(UnrealPropertyBase::ptr prop);
auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr>; Containers::ArrayView<UnrealPropertyBase::ptr> props();
auto saveToFile() -> bool; bool saveToFile();
private: private:
void loadData(); void loadData();