Compare commits

...

11 commits

Author SHA1 Message Date
2ec415f2b5 CMakeLists: we're working on 1.5 now. 2022-12-13 21:15:06 +01:00
274d8ce014 CMakeLists: change how defines are handled. 2022-12-13 21:11:54 +01:00
267226a386 Profile,SaveTool: change how materials are handled. 2022-12-13 21:11:54 +01:00
d21e2cbabb SaveTool: update a TextUnformatted() call. 2022-12-13 21:11:54 +01:00
457bb5e89f Update coding style.
Magnum's type names are fine, but I'd rather limit what depends on
Magnum as much as possible. Vector types are still allowed, though. No
way I'll write my own.
2022-12-13 21:11:54 +01:00
5144121812 Match the new coding style I use. 2022-12-13 21:11:53 +01:00
cf69d3396f Configuration: add missing licence text. 2022-12-13 21:11:53 +01:00
3403feb668 SaveTool: move the configuration to its own class. 2022-12-13 21:11:53 +01:00
6450572f97 SaveTool: add a wrapper over ImGui::Checkbox().
This way, I can make it work like radio buttons or selectables.
2022-12-13 21:11:53 +01:00
81b35476a0 CMakeLists: bump version number. 2022-12-13 21:08:30 +01:00
b909f0ac13 Profile: fix bug in material saving when array doesn't exist. 2022-12-13 21:03:43 +01:00
109 changed files with 1905 additions and 1797 deletions

View file

@ -18,7 +18,7 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(SAVETOOL_PROJECT_VERSION 1.4.1)
set(SAVETOOL_PROJECT_VERSION 1.5.0-pre)
find_package(Corrade REQUIRED Main Containers Utility)
find_package(Magnum REQUIRED GL Sdl2Application)
@ -139,6 +139,8 @@ add_executable(MassBuilderSaveTool WIN32
SaveTool/SaveTool_MassViewer_Weapons.cpp
SaveTool/SaveTool_ProfileManager.cpp
SaveTool/SaveTool_UpdateChecker.cpp
Configuration/Configuration.h
Configuration/Configuration.cpp
ProfileManager/ProfileManager.h
ProfileManager/ProfileManager.cpp
Profile/Profile.h
@ -186,11 +188,12 @@ add_executable(MassBuilderSaveTool WIN32
)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_compile_definitions(SAVETOOL_DEBUG_BUILD)
target_compile_definitions(Logger PRIVATE SAVETOOL_DEBUG_BUILD)
target_compile_definitions(MassBuilderSaveTool PRIVATE SAVETOOL_DEBUG_BUILD)
endif()
add_compile_definitions(
target_compile_definitions(MassBuilderSaveTool PRIVATE
SAVETOOL_VERSION="${SAVETOOL_PROJECT_VERSION}"
SAVETOOL_CODENAME="Enigmatic Ellenier"
SAVETOOL_CODENAME="Friendly Valkyrie"
SUPPORTED_GAME_VERSION="0.9.x"
)

View file

@ -0,0 +1,168 @@
// MassBuilderSaveTool
// Copyright (C) 2021-2022 Guillaume Jacquemin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/Path.h>
#include "Configuration.h"
Configuration::Configuration() {
Containers::String exe_path = Utility::Path::split(*Utility::Path::executableLocation()).first();
_conf = Utility::Configuration{Utility::Path::join(exe_path, "MassBuilderSaveTool.ini")};
if(_conf.hasValue("swap_interval")) {
_swapInterval = _conf.value<int>("swap_interval");
}
else {
_conf.setValue("swap_interval", 1);
}
if(_conf.hasValue("frame_limit")) {
std::string frame_limit = _conf.value("frame_limit");
if(frame_limit == "half_vsync") {
_swapInterval = 2;
}
_conf.removeValue("frame_limit");
}
if(_conf.hasValue("fps_cap")) {
_fpsCap = _conf.value<float>("fps_cap");
}
else {
_conf.setValue("fps_cap", 60.0f);
}
if(_conf.hasValue("cheat_mode")) {
_cheatMode = _conf.value<bool>("cheat_mode");
}
else {
_conf.setValue("cheat_mode", _cheatMode);
}
if(_conf.hasValue("advanced_mode")) {
_advancedMode = _conf.value<bool>("advanced_mode");
}
else {
_conf.setValue("advanced_mode", _advancedMode);
}
if(_conf.hasValue("startup_update_check")) {
_checkUpdatesOnStartup = _conf.value<bool>("startup_update_check");
}
else {
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
}
if(_conf.hasValue("skip_disclaimer")) {
_skipDisclaimer = _conf.value<bool>("skip_disclaimer");
}
else {
_conf.setValue("skip_disclaimer", _skipDisclaimer);
}
}
Configuration::~Configuration() {
save();
}
void
Configuration::save() {
_conf.save();
}
int
Configuration::swapInterval() const {
return _swapInterval;
}
void
Configuration::setSwapInterval(int interval) {
_swapInterval = interval;
_conf.setValue("swap_interval", _swapInterval);
_conf.save();
}
float
Configuration::fpsCap() const {
return _fpsCap;
}
void
Configuration::setFpsCap(float cap) {
_fpsCap = cap;
_conf.setValue("fps_cap", _fpsCap);
_conf.save();
}
bool
Configuration::cheatMode() const {
return _cheatMode;
}
void
Configuration::setCheatMode(bool enabled) {
_cheatMode = enabled;
_conf.setValue("cheat_mode", _cheatMode);
_conf.save();
}
bool
Configuration::advancedMode() const {
return _advancedMode;
}
void
Configuration::setAdvancedMode(bool enabled) {
_advancedMode = enabled;
_conf.setValue("advanced_mode", _advancedMode);
_conf.save();
}
bool
Configuration::checkUpdatesOnStartup() const {
return _checkUpdatesOnStartup;
}
void
Configuration::setCheckUpdatesOnStartup(bool mode) {
_checkUpdatesOnStartup = mode;
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
_conf.save();
}
bool
Configuration::skipDisclaimer() const {
return _skipDisclaimer;
}
void
Configuration::setSkipDisclaimer(bool mode) {
_skipDisclaimer = mode;
_conf.setValue("skip_disclaimer", _skipDisclaimer);
_conf.save();
}
Configuration&
Configuration::instance() {
static Configuration conf{};
return conf;
}
Configuration&
conf() {
return Configuration::instance();
}

View file

@ -0,0 +1,62 @@
#pragma once
// MassBuilderSaveTool
// Copyright (C) 2021-2022 Guillaume Jacquemin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Utility/Configuration.h>
using namespace Corrade;
class Configuration {
public:
static Configuration& instance();
~Configuration();
void save();
int swapInterval() const;
void setSwapInterval(int interval);
float fpsCap() const;
void setFpsCap(float cap);
bool cheatMode() const;
void setCheatMode(bool enabled);
bool advancedMode() const;
void setAdvancedMode(bool enabled);
bool checkUpdatesOnStartup() const;
void setCheckUpdatesOnStartup(bool mode);
bool skipDisclaimer() const;
void setSkipDisclaimer(bool mode);
private:
explicit Configuration();
Utility::Configuration _conf;
int _swapInterval = 1;
float _fpsCap = 60.0f;
bool _cheatMode = false;
bool _advancedMode = false;
bool _checkUpdatesOnStartup = true;
bool _skipDisclaimer = false;
};
Configuration& conf();

View file

@ -25,8 +25,6 @@ using Utility::Debug;
using Utility::Warning;
using Utility::Error;
using namespace Magnum;
Logger&
Logger::instance() {
static Logger logger;
@ -89,7 +87,7 @@ Logger::log(EntryType type, StringView location, StringView message) {
d << "["_s << Debug::nospace << location << Debug::nospace << "]";
for(UnsignedInt i = 0; i < _indentLevel; i++) {
for(auto i = 0u; i < _indentLevel; i++) {
d << Debug::nospace << " "_s << Debug::nospace;
}

View file

@ -27,8 +27,6 @@
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Utility/Format.h>
#include <Magnum/Types.h>
#include "EntryType.h"
using namespace Corrade;
@ -37,8 +35,6 @@ using Containers::ArrayView;
using Containers::String;
using Containers::StringView;
using namespace Magnum;
using namespace Containers::Literals;
class Logger {
@ -49,7 +45,7 @@ class Logger {
Logger(Logger&&) = delete;
Logger& operator=(Logger&&) = delete;
static auto instance() -> Logger&;
static Logger& instance();
void initialise();
@ -68,12 +64,12 @@ class Logger {
std::ofstream _logFile;
#endif
UnsignedInt _indentLevel = 0;
std::uint32_t _indentLevel = 0;
std::mutex _logMutex{};
};
auto logger() -> Logger&;
Logger& logger();
#define LOG(entry_type, message) logger().lockMutex(); \
logger().log(EntryType::entry_type, \

View file

@ -16,7 +16,12 @@
#include "MagnumLogBuffer.h"
MagnumLogBuffer::MagnumLogBuffer(EntryType type): std::stringbuf(std::ios_base::out), _type{type} {}
MagnumLogBuffer::MagnumLogBuffer(EntryType type):
std::stringbuf(std::ios_base::out),
_type{type}
{
//ctor
}
MagnumLogBuffer::~MagnumLogBuffer() = default;

View file

@ -16,15 +16,14 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <map>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum;
enum AccessorySize {
S,
@ -38,7 +37,7 @@ struct AccessoryData{
AccessorySize size = AccessorySize::S;
};
static const std::map<Int, AccessoryData> accessories {
static const std::map<std::int32_t, AccessoryData> accessories {
// region Primitives
{1, {"Cube"_s, AccessorySize::S}},
{2, {"Pentagon"_s, AccessorySize::S}},

View file

@ -16,22 +16,21 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <map>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum;
struct ArmourSet {
Containers::StringView name;
bool neck_compatible;
};
static const std::map<Int, ArmourSet> armour_sets {
static const std::map<std::int32_t, ArmourSet> armour_sets {
{-1, {"<unequipped>"_s, true}},
{0, {"Vanguard"_s, true}},
{1, {"Assault Mk.I"_s, true}},

View file

@ -20,13 +20,10 @@
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum;
static const std::map<Int, Containers::StringView> mission_id_map {{
static const std::map<std::int32_t, Containers::StringView> mission_id_map {{
// Story missions
{0x0064, "Mission 1 - Training"_s},
{0x0065, "Mission 2 - Patrol Operation"_s},

View file

@ -19,14 +19,11 @@
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum;
struct StoryProgressPoint {
Int id;
std::int32_t id;
Containers::StringView chapter;
Containers::StringView point;
Containers::StringView after = nullptr;

View file

@ -16,17 +16,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <map>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Magnum.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum;
extern const std::map<Int, Containers::StringView> style_names
extern const std::map<std::int32_t, Containers::StringView> style_names
#ifdef STYLENAMES_DEFINITION
{
{0, "Custom Style 1"_s},

View file

@ -15,19 +15,18 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <map>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade;
using namespace Magnum;
using namespace Containers::Literals;
// region Melee
static const std::map<Int, Containers::StringView> melee_grips {
static const std::map<std::int32_t, Containers::StringView> melee_grips {
{0, "Combat Grip (1H)"_s},
{1, "Knuckle Guard Grip (1H)"_s},
{2, "Dual Guard Grip (1H)"_s},
@ -78,7 +77,7 @@ static const std::map<Int, Containers::StringView> melee_grips {
{2404, "Arched Twin Blade (2H)"_s},
};
static const std::map<Int, Containers::StringView> melee_assaulters {
static const std::map<std::int32_t, Containers::StringView> melee_assaulters {
{0, "Long Metal Blade"_s},
{1, "Long Assault Blade"_s},
{2, "Long Fin Blade"_s},
@ -172,7 +171,7 @@ static const std::map<Int, Containers::StringView> melee_assaulters {
// endregion
// region Shields
static const std::map<Int, Containers::StringView> shield_handles {
static const std::map<std::int32_t, Containers::StringView> shield_handles {
{0, "Balanced Handle"_s},
{1, "Expanded Handle"_s},
{2, "Lowguard Handle"_s},
@ -191,7 +190,7 @@ static const std::map<Int, Containers::StringView> shield_handles {
{101, "Star Handle"_s},
};
static const std::map<Int, Containers::StringView> shield_shells {
static const std::map<std::int32_t, Containers::StringView> shield_shells {
{0, "Balanced Shell"_s},
{1, "Compass Shell"_s},
{2, "Uppoint Shell"_s},
@ -212,7 +211,7 @@ static const std::map<Int, Containers::StringView> shield_shells {
// endregion
// region Bullet Shooters
static const std::map<Int, Containers::StringView> bshooter_triggers {
static const std::map<std::int32_t, Containers::StringView> bshooter_triggers {
{0, "BL-Combat Trigger (1H)"_s},
{1, "Light Machine Trigger (1H)"_s},
{2, "Tactical Trigger (1H)"_s},
@ -230,7 +229,7 @@ static const std::map<Int, Containers::StringView> bshooter_triggers {
{199, "2H Base Trigger (2H)"_s},
};
static const std::map<Int, Containers::StringView> bshooter_barrels {
static const std::map<std::int32_t, Containers::StringView> bshooter_barrels {
{0, "BL-Combat Barrel (1 shot)"_s},
{1, "Shock Absorb Barrel (1 shot) (Motion)"_s},
{2, "Muzzlemod Barrel (1 shot)"_s},
@ -267,7 +266,7 @@ static const std::map<Int, Containers::StringView> bshooter_barrels {
// endregion
//region Energy Shooters
static const std::map<Int, Containers::StringView> eshooter_triggers {
static const std::map<std::int32_t, Containers::StringView> eshooter_triggers {
{0, "EN-Rifle Trigger (1H)"_s},
{1, "Underarm Trigger (1H)"_s},
{2, "EN-Inverted Trigger (1H)"_s},
@ -285,7 +284,7 @@ static const std::map<Int, Containers::StringView> eshooter_triggers {
{199, "2H Base EnTrigger (2H)"_s},
};
static const std::map<Int, Containers::StringView> eshooter_busters {
static const std::map<std::int32_t, Containers::StringView> eshooter_busters {
{0, "EN-Combat Buster (1 shot)"_s},
{1, "Delta Cycler (1 shot) (Motion)"_s},
{2, "EN-Longbarrel Buster (1 shot)"_s},
@ -321,7 +320,7 @@ static const std::map<Int, Containers::StringView> eshooter_busters {
// endregion
// region Bullet Launchers
static const std::map<Int, Containers::StringView> blauncher_pods {
static const std::map<std::int32_t, Containers::StringView> blauncher_pods {
{0, "BL-Delta Pack Launcher (Missile x12)"_s},
{1, "BL-Twin Pack Launcher (Missile x12)"_s},
{2, "Detector Launcher (Missile x12)"_s},
@ -351,7 +350,7 @@ static const std::map<Int, Containers::StringView> blauncher_pods {
{399, "C Base Pod (Cluster x40)"_s},
};
static const std::map<Int, Containers::StringView> blauncher_projectiles {
static const std::map<std::int32_t, Containers::StringView> blauncher_projectiles {
{0, "Flathead Missile"_s},
{1, "Warhead Missile"_s},
{2, "Pointhead Missile"_s},
@ -361,7 +360,7 @@ static const std::map<Int, Containers::StringView> blauncher_projectiles {
// endregion
// region Energy Launchers
static const std::map<Int, Containers::StringView> elauncher_generators {
static const std::map<std::int32_t, Containers::StringView> elauncher_generators {
{0, "Fly Unit"_s},
{1, "Assault Unit (Motion)"_s},
{2, "Falcon Unit"_s},
@ -393,7 +392,7 @@ static const std::map<Int, Containers::StringView> elauncher_generators {
{99, "Base Generator"},
};
static const std::map<Int, Containers::StringView> elauncher_pods {
static const std::map<std::int32_t, Containers::StringView> elauncher_pods {
{0, "EN-Dual Claw Launcher (Echo) (Motion)"_s},
{1, "EN-Assault Launcher (Echo)"_s},
{2, "EN-Tactical Launcher (Echo)"_s},

View file

@ -25,9 +25,9 @@ using namespace Corrade;
using namespace Magnum;
struct Accessory {
Int attachIndex = -1;
Int id = -1;
Containers::StaticArray<2, Int> styles{ValueInit};
std::int32_t attachIndex = -1;
std::int32_t id = -1;
Containers::StaticArray<2, std::int32_t> styles{ValueInit};
Vector3 relativePosition{0.0f};
Vector3 relativePositionOffset{0.0f};
Vector3 relativeRotation{0.0f};

View file

@ -19,13 +19,10 @@
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h>
#include <Magnum/Types.h>
#include "Decal.h"
#include "Accessory.h"
using namespace Corrade;
using namespace Magnum;
enum class ArmourSlot {
#define c(enumerator, enumstr, name) enumerator,
@ -35,8 +32,8 @@ enum class ArmourSlot {
struct ArmourPart {
ArmourSlot slot = ArmourSlot::Face;
Int id = 0;
Containers::StaticArray<4, Int> styles{ValueInit};
std::int32_t id = 0;
Containers::StaticArray<4, std::int32_t> styles{ValueInit};
Containers::Array<Decal> decals;
Containers::Array<Accessory> accessories;
};

View file

@ -28,13 +28,13 @@ using namespace Magnum;
struct CustomStyle {
Containers::String name;
Color4 colour{0.0f};
Float metallic = 0.5f;
Float gloss = 0.5f;
float metallic = 0.5f;
float gloss = 0.5f;
bool glow = false;
Int patternId = 0;
Float opacity = 0.5f;
std::int32_t patternId = 0;
float opacity = 0.5f;
Vector2 offset{0.5f};
Float rotation = 0.0f;
Float scale = 0.5f;
float rotation = 0.0f;
float scale = 0.5f;
};

View file

@ -19,18 +19,19 @@
#include <Magnum/Magnum.h>
#include <Magnum/Math/Color.h>
#include <Magnum/Math/Vector2.h>
#include <Magnum/Math/Vector3.h>
using namespace Magnum;
struct Decal {
Int id = -1;
std::int32_t id = -1;
Color4 colour{0.0f};
Vector3 position{0.0f};
Vector3 uAxis{0.0f};
Vector3 vAxis{0.0f};
Vector2 offset{0.5f};
Float scale = 0.5f;
Float rotation = 0.0f;
float scale = 0.5f;
float rotation = 0.0f;
bool flip = false;
bool wrap = false;
};

View file

@ -16,17 +16,13 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Magnum/Types.h>
using namespace Magnum;
struct Joints {
Float neck = 0.0f;
Float body = 0.0f;
Float shoulders = 0.0f;
Float hips = 0.0f;
Float upperArms = 0.0f;
Float lowerArms = 0.0f;
Float upperLegs = 0.0f;
Float lowerLegs = 0.0f;
float neck = 0.0f;
float body = 0.0f;
float shoulders = 0.0f;
float hips = 0.0f;
float upperArms = 0.0f;
float lowerArms = 0.0f;
float upperLegs = 0.0f;
float lowerLegs = 0.0f;
};

View file

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

View file

@ -45,10 +45,6 @@ struct ArrayProperty;
class Mass {
public:
enum class State : UnsignedByte {
Empty, Invalid, Valid
};
explicit Mass(Containers::StringView path);
Mass(const Mass&) = delete;
@ -57,96 +53,100 @@ class Mass {
Mass(Mass&&) = default;
Mass& operator=(Mass&&) = default;
auto lastError() -> Containers::StringView;
Containers::StringView lastError();
static auto getNameFromFile(Containers::StringView path) -> Containers::Optional<Containers::String>;
static Containers::Optional<Containers::String> getNameFromFile(Containers::StringView path);
void refreshValues();
auto filename() -> Containers::StringView;
Containers::StringView filename();
auto name() -> Containers::StringView;
auto setName(Containers::StringView new_name) -> bool;
Containers::StringView name();
bool setName(Containers::StringView new_name);
auto state() -> State;
enum class State: std::uint8_t {
Empty, Invalid, Valid
};
auto dirty() const -> bool;
State state();
bool dirty() const;
void setDirty(bool dirty = true);
auto jointSliders() -> Joints&;
Joints& jointSliders();
void getJointSliders();
auto writeJointSliders() -> bool;
bool writeJointSliders();
auto frameStyles() -> Containers::ArrayView<Int>;
Containers::ArrayView<std::int32_t> frameStyles();
void getFrameStyles();
auto writeFrameStyles() -> bool;
bool writeFrameStyles();
auto eyeFlareColour() -> Color4&;
Color4& eyeFlareColour();
void getEyeFlareColour();
auto writeEyeFlareColour() -> bool;
bool writeEyeFlareColour();
auto frameCustomStyles() -> Containers::ArrayView<CustomStyle>;
Containers::ArrayView<CustomStyle> frameCustomStyles();
void getFrameCustomStyles();
auto writeFrameCustomStyle(UnsignedLong index) -> bool;
bool writeFrameCustomStyle(std::size_t index);
auto armourParts() -> Containers::ArrayView<ArmourPart>;
Containers::ArrayView<ArmourPart> armourParts();
void getArmourParts();
auto writeArmourPart(ArmourSlot slot) -> bool;
bool writeArmourPart(ArmourSlot slot);
auto bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle&;
auto bulletLauncherAttachments() -> Containers::ArrayView<BulletLauncherAttachment>;
BulletLauncherAttachmentStyle& bulletLauncherAttachmentStyle();
Containers::ArrayView<BulletLauncherAttachment> bulletLauncherAttachments();
void getBulletLauncherAttachments();
auto writeBulletLauncherAttachments() -> bool;
bool writeBulletLauncherAttachments();
auto armourCustomStyles() -> Containers::ArrayView<CustomStyle>;
Containers::ArrayView<CustomStyle> armourCustomStyles();
void getArmourCustomStyles();
auto writeArmourCustomStyle(UnsignedLong index) -> bool;
bool writeArmourCustomStyle(std::size_t index);
auto meleeWeapons() -> Containers::ArrayView<Weapon>;
Containers::ArrayView<Weapon> meleeWeapons();
void getMeleeWeapons();
auto writeMeleeWeapons() -> bool;
bool writeMeleeWeapons();
auto shields() -> Containers::ArrayView<Weapon>;
Containers::ArrayView<Weapon> shields();
void getShields();
auto writeShields() -> bool;
bool writeShields();
auto bulletShooters() -> Containers::ArrayView<Weapon>;
Containers::ArrayView<Weapon> bulletShooters();
void getBulletShooters();
auto writeBulletShooters() -> bool;
bool writeBulletShooters();
auto energyShooters() -> Containers::ArrayView<Weapon>;
Containers::ArrayView<Weapon> energyShooters();
void getEnergyShooters();
auto writeEnergyShooters() -> bool;
bool writeEnergyShooters();
auto bulletLaunchers() -> Containers::ArrayView<Weapon>;
Containers::ArrayView<Weapon> bulletLaunchers();
void getBulletLaunchers();
auto writeBulletLaunchers() -> bool;
bool writeBulletLaunchers();
auto energyLaunchers() -> Containers::ArrayView<Weapon>;
Containers::ArrayView<Weapon> energyLaunchers();
void getEnergyLaunchers();
auto writeEnergyLaunchers() -> bool;
bool writeEnergyLaunchers();
auto globalStyles() -> Containers::ArrayView<CustomStyle>;
Containers::ArrayView<CustomStyle> globalStyles();
void getGlobalStyles();
auto writeGlobalStyle(UnsignedLong index) -> bool;
bool writeGlobalStyle(std::size_t index);
void getTuning();
auto engine() -> Int&;
auto gears() -> Containers::ArrayView<Int>;
std::int32_t& engine();
Containers::ArrayView<std::int32_t> gears();
auto os() -> Int&;
auto modules() -> Containers::ArrayView<Int>;
std::int32_t& os();
Containers::ArrayView<std::int32_t> modules();
auto architecture() -> Int&;
auto techs() -> Containers::ArrayView<Int>;
std::int32_t& architecture();
Containers::ArrayView<std::int32_t> techs();
auto account() -> Containers::StringView;
auto updateAccount(Containers::StringView new_account) -> bool;
Containers::StringView account();
bool updateAccount(Containers::StringView new_account);
private:
void getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array);
auto writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool;
bool writeCustomStyle(const CustomStyle& style, std::size_t index, ArrayProperty* style_array);
void getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
void writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
@ -155,10 +155,11 @@ class Mass {
void writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array);
void getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array);
auto writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) -> bool;
bool writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array);
void getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id,
Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids);
void getTuningCategory(Containers::StringView big_node_prop_name, std::int32_t& big_node_id,
Containers::StringView small_nodes_prop_name,
Containers::ArrayView<std::int32_t> small_nodes_ids);
Containers::Optional<UESaveFile> _mass;
@ -174,7 +175,7 @@ class Mass {
struct {
Joints joints{};
Containers::StaticArray<4, Int> styles{ValueInit};
Containers::StaticArray<4, std::int32_t> styles{ValueInit};
Color4 eyeFlare{0.0f};
Containers::StaticArray<16, CustomStyle> customStyles;
} _frame;
@ -198,14 +199,14 @@ class Mass {
Containers::Array<CustomStyle> _globalStyles;
struct {
Int engineId;
Containers::StaticArray<7, Int> gearIds;
std::int32_t engineId;
Containers::StaticArray<7, std::int32_t> gearIds;
Int osId;
Containers::StaticArray<7, Int> moduleIds;
std::int32_t osId;
Containers::StaticArray<7, std::int32_t> moduleIds;
Int archId;
Containers::StaticArray<7, Int> techIds;
std::int32_t archId;
Containers::StaticArray<7, std::int32_t> techIds;
} _tuning;
Containers::String _account;

View file

@ -29,11 +29,13 @@
using namespace Containers::Literals;
auto Mass::armourParts() -> Containers::ArrayView<ArmourPart> {
Containers::ArrayView<ArmourPart>
Mass::armourParts() {
return _armour.parts;
}
void Mass::getArmourParts() {
void
Mass::getArmourParts() {
LOG_INFO("Getting armour parts.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -57,7 +59,7 @@ void Mass::getArmourParts() {
return;
}
for(UnsignedInt i = 0; i < armour_array->items.size(); i++) {
for(std::uint32_t i = 0; i < armour_array->items.size(); i++) {
auto part_prop = armour_array->at<GenericStructProperty>(i);
auto& part = _armour.parts[i];
@ -87,7 +89,7 @@ void Mass::getArmourParts() {
return;
}
for(UnsignedInt j = 0; j < part_styles->items.size(); j++) {
for(std::uint32_t j = 0; j < part_styles->items.size(); j++) {
part.styles[j] = part_styles->at<IntProperty>(j)->value;
}
@ -117,7 +119,8 @@ void Mass::getArmourParts() {
}
}
auto Mass::writeArmourPart(ArmourSlot slot) -> bool {
bool
Mass::writeArmourPart(ArmourSlot slot) {
LOG_INFO_FORMAT("Writing armour part in slot {}.", static_cast<int>(slot));
auto& part = *std::find_if(_armour.parts.begin(), _armour.parts.end(), [&slot](const ArmourPart& part){ return slot == part.slot; });
@ -149,7 +152,7 @@ auto Mass::writeArmourPart(ArmourSlot slot) -> bool {
GenericStructProperty* part_prop = nullptr;
for(UnsignedInt i = 0; i < armour_array->items.size(); i++) {
for(std::uint32_t i = 0; i < armour_array->items.size(); i++) {
part_prop = armour_array->at<GenericStructProperty>(i);
if(slot_str == part_prop->at<ByteProperty>(MASS_ARMOUR_SLOT)->enumValue) {
break;
@ -175,7 +178,7 @@ auto Mass::writeArmourPart(ArmourSlot slot) -> bool {
part_prop->at<IntProperty>(MASS_ARMOUR_ID)->value = part.id;
auto part_styles = part_prop->at<ArrayProperty>(MASS_ARMOUR_STYLES);
for(UnsignedInt i = 0; i < part.styles.size(); i++) {
for(std::uint32_t i = 0; i < part.styles.size(); i++) {
part_styles->at<IntProperty>(i)->value = part.styles[i];
}
@ -195,15 +198,18 @@ auto Mass::writeArmourPart(ArmourSlot slot) -> bool {
return true;
}
auto Mass::bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle& {
BulletLauncherAttachmentStyle&
Mass::bulletLauncherAttachmentStyle() {
return _armour.blAttachmentStyle;
}
auto Mass::bulletLauncherAttachments() -> Containers::ArrayView<BulletLauncherAttachment> {
Containers::ArrayView<BulletLauncherAttachment>
Mass::bulletLauncherAttachments() {
return _armour.blAttachment;
}
void Mass::getBulletLauncherAttachments() {
void
Mass::getBulletLauncherAttachments() {
LOG_INFO("Getting the bullet launcher attachment data.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -232,7 +238,7 @@ void Mass::getBulletLauncherAttachments() {
if(attach_array->items.size() == _weapons.bulletLaunchers.size() &&
attach_array->items.size() == _armour.blAttachment.size())
{
for(UnsignedInt i = 0; i < attach_array->items.size(); i++) {
for(std::uint32_t i = 0; i < attach_array->items.size(); i++) {
auto attachment_prop = attach_array->at<GenericStructProperty>(i);
auto& attachment = _armour.blAttachment[i];
@ -274,7 +280,8 @@ void Mass::getBulletLauncherAttachments() {
}
}
auto Mass::writeBulletLauncherAttachments() -> bool {
bool
Mass::writeBulletLauncherAttachments() {
LOG_INFO("Writing bullet launcher attachments.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -306,7 +313,7 @@ auto Mass::writeBulletLauncherAttachments() -> bool {
if(attach_array->items.size() == _weapons.bulletLaunchers.size() &&
attach_array->items.size() == _armour.blAttachment.size())
{
for(UnsignedInt i = 0; i < attach_array->items.size(); i++) {
for(std::uint32_t i = 0; i < attach_array->items.size(); i++) {
auto attachment_prop = attach_array->at<GenericStructProperty>(i);
auto& attachment = _armour.blAttachment[i];
@ -373,11 +380,13 @@ auto Mass::writeBulletLauncherAttachments() -> bool {
return true;
}
auto Mass::armourCustomStyles() -> Containers::ArrayView<CustomStyle> {
Containers::ArrayView<CustomStyle>
Mass::armourCustomStyles() {
return _armour.customStyles;
}
void Mass::getArmourCustomStyles() {
void
Mass::getArmourCustomStyles() {
LOG_INFO("Getting the custom armour styles.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -404,7 +413,8 @@ void Mass::getArmourCustomStyles() {
getCustomStyles(_armour.customStyles, armour_styles);
}
auto Mass::writeArmourCustomStyle(UnsignedLong index) -> bool {
bool
Mass::writeArmourCustomStyle(std::size_t index) {
LOG_INFO_FORMAT("Writing custom armour style {}.", index);
if(index > _armour.customStyles.size()) {

View file

@ -29,8 +29,9 @@
using namespace Containers::Literals;
void Mass::getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) {
for(UnsignedInt i = 0; i < decal_array->items.size(); i++) {
void
Mass::getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) {
for(std::uint32_t i = 0; i < decal_array->items.size(); i++) {
auto decal_prop = decal_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(decal_prop);
auto& decal = decals[i];
@ -53,8 +54,9 @@ void Mass::getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_a
}
}
void Mass::writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) {
for(UnsignedInt i = 0; i < decal_array->items.size(); i++) {
void
Mass::writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) {
for(std::uint32_t i = 0; i < decal_array->items.size(); i++) {
auto decal_prop = decal_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(decal_prop);
auto& decal = decals[i];
@ -87,8 +89,9 @@ void Mass::writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal
}
}
void Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accessory_array) {
for(UnsignedInt i = 0; i < accessory_array->items.size(); i++) {
void
Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accessory_array) {
for(std::uint32_t i = 0; i < accessory_array->items.size(); i++) {
auto acc_prop = accessory_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(acc_prop);
auto& accessory = accessories[i];
@ -96,7 +99,7 @@ void Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayPro
accessory.attachIndex = acc_prop->at<IntProperty>(MASS_ACCESSORY_ATTACH_INDEX)->value;
accessory.id = acc_prop->at<IntProperty>(MASS_ACCESSORY_ID)->value;
auto acc_styles = acc_prop->at<ArrayProperty>(MASS_ACCESSORY_STYLES);
for(UnsignedInt j = 0; j < acc_styles->items.size(); j++) {
for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) {
accessory.styles[j] = acc_styles->at<IntProperty>(j)->value;
}
auto rel_pos_prop = acc_prop->at<VectorStructProperty>(MASS_ACCESSORY_RELPOS);
@ -112,8 +115,9 @@ void Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayPro
}
}
void Mass::writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array) {
for(UnsignedInt i = 0; i < accs_array->items.size(); i++) {
void
Mass::writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array) {
for(std::uint32_t i = 0; i < accs_array->items.size(); i++) {
auto acc_prop = accs_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(acc_prop);
auto& accessory = accessories[i];
@ -121,7 +125,7 @@ void Mass::writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayP
acc_prop->at<IntProperty>(MASS_ACCESSORY_ATTACH_INDEX)->value = accessory.attachIndex;
acc_prop->at<IntProperty>(MASS_ACCESSORY_ID)->value = accessory.id;
auto acc_styles = acc_prop->at<ArrayProperty>(MASS_ACCESSORY_STYLES);
for(UnsignedInt j = 0; j < acc_styles->items.size(); j++) {
for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) {
acc_styles->at<IntProperty>(j)->value = accessory.styles[j];
}
auto rel_pos_prop = acc_prop->at<VectorStructProperty>(MASS_ACCESSORY_RELPOS);

View file

@ -26,11 +26,13 @@
using namespace Containers::Literals;
auto Mass::jointSliders() -> Joints& {
Joints&
Mass::jointSliders() {
return _frame.joints;
}
void Mass::getJointSliders() {
void
Mass::getJointSliders() {
LOG_INFO("Getting joint sliders.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -65,7 +67,8 @@ void Mass::getJointSliders() {
_frame.joints.lowerLegs = (length ? length->value : 0.0f);
}
auto Mass::writeJointSliders() -> bool {
bool
Mass::writeJointSliders() {
LOG_INFO("Writing joint sliders");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -181,11 +184,13 @@ auto Mass::writeJointSliders() -> bool {
return true;
}
auto Mass::frameStyles() -> Containers::ArrayView<Int> {
Containers::ArrayView<std::int32_t>
Mass::frameStyles() {
return _frame.styles;
}
void Mass::getFrameStyles() {
void
Mass::getFrameStyles() {
LOG_INFO("Getting frame styles.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -216,12 +221,13 @@ void Mass::getFrameStyles() {
return;
}
for(UnsignedInt i = 0; i < frame_styles->items.size(); i++) {
for(std::uint32_t i = 0; i < frame_styles->items.size(); i++) {
_frame.styles[i] = frame_styles->at<IntProperty>(i)->value;
}
}
auto Mass::writeFrameStyles() -> bool {
bool
Mass::writeFrameStyles() {
LOG_INFO("Writing frame styles.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -248,7 +254,7 @@ auto Mass::writeFrameStyles() -> bool {
return false;
}
for(UnsignedInt i = 0; i < frame_styles->items.size(); i++) {
for(std::uint32_t i = 0; i < frame_styles->items.size(); i++) {
frame_styles->at<IntProperty>(i)->value = _frame.styles[i];
}
@ -260,11 +266,13 @@ auto Mass::writeFrameStyles() -> bool {
return true;
}
auto Mass::eyeFlareColour() -> Color4& {
Color4&
Mass::eyeFlareColour() {
return _frame.eyeFlare;
}
void Mass::getEyeFlareColour() {
void
Mass::getEyeFlareColour() {
LOG_INFO("Getting the eye flare colour.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -291,7 +299,8 @@ void Mass::getEyeFlareColour() {
_frame.eyeFlare = Color4{eye_flare_prop->r, eye_flare_prop->g, eye_flare_prop->b, eye_flare_prop->a};
}
auto Mass::writeEyeFlareColour() -> bool {
bool
Mass::writeEyeFlareColour() {
LOG_INFO("Writing the eye flare colour.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -331,11 +340,13 @@ auto Mass::writeEyeFlareColour() -> bool {
return true;
}
auto Mass::frameCustomStyles() -> Containers::ArrayView<CustomStyle> {
Containers::ArrayView<CustomStyle>
Mass::frameCustomStyles() {
return _frame.customStyles;
}
void Mass::getFrameCustomStyles() {
void
Mass::getFrameCustomStyles() {
LOG_INFO("Getting the frame's custom styles.");
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
@ -362,7 +373,8 @@ void Mass::getFrameCustomStyles() {
getCustomStyles(_frame.customStyles, frame_styles);
}
auto Mass::writeFrameCustomStyle(UnsignedLong index) -> bool {
bool
Mass::writeFrameCustomStyle(std::size_t index) {
LOG_INFO_FORMAT("Writing frame custom style number {}.", index);
if(index > _frame.customStyles.size()) {

View file

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

View file

@ -28,91 +28,110 @@
using namespace Containers::Literals;
auto Mass::meleeWeapons() -> Containers::ArrayView<Weapon> {
Containers::ArrayView<Weapon>
Mass::meleeWeapons() {
return _weapons.melee;
}
void Mass::getMeleeWeapons() {
void
Mass::getMeleeWeapons() {
LOG_INFO("Getting melee weapons.");
getWeaponType(MASS_WEAPONS_MELEE, _weapons.melee);
}
auto Mass::writeMeleeWeapons() -> bool {
bool
Mass::writeMeleeWeapons() {
LOG_INFO("Writing melee weapons.");
return writeWeaponType(MASS_WEAPONS_MELEE, _weapons.melee);
}
auto Mass::shields() -> Containers::ArrayView<Weapon> {
Containers::ArrayView<Weapon>
Mass::shields() {
return _weapons.shields;
}
void Mass::getShields() {
void
Mass::getShields() {
LOG_INFO("Getting shields.");
getWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields);
}
auto Mass::writeShields() -> bool {
bool
Mass::writeShields() {
LOG_INFO("Writing shields.");
return writeWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields);
}
auto Mass::bulletShooters() -> Containers::ArrayView<Weapon> {
Containers::ArrayView<Weapon>
Mass::bulletShooters() {
return _weapons.bulletShooters;
}
void Mass::getBulletShooters() {
void
Mass::getBulletShooters() {
LOG_INFO("Getting bullet shooters.");
getWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters);
}
auto Mass::writeBulletShooters() -> bool {
bool
Mass::writeBulletShooters() {
LOG_INFO("Writing bullet shooters.");
return writeWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters);
}
auto Mass::energyShooters() -> Containers::ArrayView<Weapon> {
Containers::ArrayView<Weapon>
Mass::energyShooters() {
return _weapons.energyShooters;
}
void Mass::getEnergyShooters() {
void
Mass::getEnergyShooters() {
LOG_INFO("Getting energy shooters.");
getWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters);
}
auto Mass::writeEnergyShooters() -> bool {
bool
Mass::writeEnergyShooters() {
LOG_INFO("Writing energy shooters.");
return writeWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters);
}
auto Mass::bulletLaunchers() -> Containers::ArrayView<Weapon> {
Containers::ArrayView<Weapon>
Mass::bulletLaunchers() {
return _weapons.bulletLaunchers;
}
void Mass::getBulletLaunchers() {
void
Mass::getBulletLaunchers() {
LOG_INFO("Getting bullet launchers.");
getWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers);
}
auto Mass::writeBulletLaunchers() -> bool {
bool
Mass::writeBulletLaunchers() {
LOG_INFO("Writing bullet launchers.");
return writeWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers);
}
auto Mass::energyLaunchers() -> Containers::ArrayView<Weapon> {
Containers::ArrayView<Weapon>
Mass::energyLaunchers() {
return _weapons.energyLaunchers;
}
void Mass::getEnergyLaunchers() {
void
Mass::getEnergyLaunchers() {
LOG_INFO("Getting energy launchers.");
getWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers);
}
auto Mass::writeEnergyLaunchers() -> bool {
bool
Mass::writeEnergyLaunchers() {
LOG_INFO("Writing energy launchers.");
return writeWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers);
}
void Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) {
void
Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) {
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
if(!unit_data) {
LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename);
@ -134,7 +153,7 @@ void Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView
return;
}
for(UnsignedInt i = 0; i < weapon_array.size(); i++) {
for(std::uint32_t i = 0; i < weapon_array.size(); i++) {
auto weapon_prop = prop->at<GenericStructProperty>(i);
auto& weapon = weapon_array[i];
@ -152,14 +171,14 @@ void Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView
auto parts_prop = weapon_prop->at<ArrayProperty>(MASS_WEAPON_ELEMENT);
weapon.parts = Containers::Array<WeaponPart>{ValueInit, parts_prop->items.size()};
for(UnsignedInt j = 0; j < parts_prop->items.size(); j++) {
for(std::uint32_t j = 0; j < parts_prop->items.size(); j++) {
auto part_prop = parts_prop->at<GenericStructProperty>(j);
auto& part = weapon.parts[j];
part.id = part_prop->at<IntProperty>(MASS_WEAPON_PART_ID)->value;
auto part_styles = part_prop->at<ArrayProperty>(MASS_WEAPON_PART_STYLES);
for(UnsignedInt k = 0; k < part_styles->items.size(); k++) {
for(std::uint32_t k = 0; k < part_styles->items.size(); k++) {
part.styles[k] = part_styles->at<IntProperty>(k)->value;
}
@ -223,7 +242,8 @@ void Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView
}
}
auto Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) -> bool {
bool
Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) {
auto unit_data = _mass->at<GenericStructProperty>(MASS_UNIT_DATA);
if(!unit_data) {
_lastError = "No unit data in "_s + _filename;
@ -248,7 +268,7 @@ auto Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayVi
return false;
}
for(UnsignedInt i = 0; i < weapon_array.size(); i++) {
for(std::uint32_t i = 0; i < weapon_array.size(); i++) {
auto weapon_prop = prop->at<GenericStructProperty>(i);
auto& weapon = weapon_array[i];
@ -272,14 +292,14 @@ auto Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayVi
return false;
}
for(UnsignedInt j = 0; j < parts_prop->items.size(); j++) {
for(std::uint32_t j = 0; j < parts_prop->items.size(); j++) {
auto part_prop = parts_prop->at<GenericStructProperty>(j);
auto& part = weapon.parts[j];
part_prop->at<IntProperty>(MASS_WEAPON_PART_ID)->value = part.id;
auto part_styles = part_prop->at<ArrayProperty>(MASS_WEAPON_PART_STYLES);
for(UnsignedInt k = 0; k < part_styles->items.size(); k++) {
for(std::uint32_t k = 0; k < part_styles->items.size(); k++) {
part_styles->at<IntProperty>(k)->value = part.styles[k];
}
@ -318,7 +338,7 @@ auto Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayVi
return false;
}
for(UnsignedInt j = 0; j < weapon.customStyles.size(); j++) {
for(std::uint32_t j = 0; j < weapon.customStyles.size(); j++) {
writeCustomStyle(weapon.customStyles[j], j, custom_styles);
}

View file

@ -20,7 +20,7 @@ Weapon::Weapon(const Weapon& other) {
name = other.name;
type = other.type;
parts = Containers::Array<WeaponPart>{other.parts.size()};
for(UnsignedInt i = 0; i < parts.size(); i++) {
for(std::uint32_t i = 0; i < parts.size(); i++) {
parts[i] = other.parts[i];
}
customStyles = other.customStyles;
@ -35,7 +35,7 @@ Weapon& Weapon::operator=(const Weapon& other) {
name = other.name;
type = other.type;
parts = Containers::Array<WeaponPart>{other.parts.size()};
for(UnsignedInt i = 0; i < parts.size(); i++) {
for(std::uint32_t i = 0; i < parts.size(); i++) {
parts[i] = other.parts[i];
}
customStyles = other.customStyles;

View file

@ -19,13 +19,10 @@
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h>
#include <Magnum/Types.h>
#include "Decal.h"
#include "Accessory.h"
using namespace Corrade;
using namespace Magnum;
struct WeaponPart {
WeaponPart() = default;
@ -34,11 +31,11 @@ struct WeaponPart {
id = other.id;
styles = other.styles;
decals = Containers::Array<Decal>{other.decals.size()};
for(UnsignedInt i = 0; i < decals.size(); i++) {
for(auto i = 0u; i < decals.size(); i++) {
decals[i] = other.decals[i];
}
accessories = Containers::Array<Accessory>{other.accessories.size()};
for(UnsignedInt i = 0; i < accessories.size(); i++) {
for(auto i = 0u; i < accessories.size(); i++) {
accessories[i] = other.accessories[i];
}
}
@ -46,11 +43,11 @@ struct WeaponPart {
id = other.id;
styles = other.styles;
decals = Containers::Array<Decal>{other.decals.size()};
for(UnsignedInt i = 0; i < decals.size(); i++) {
for(auto i = 0u; i < decals.size(); i++) {
decals[i] = other.decals[i];
}
accessories = Containers::Array<Accessory>{other.accessories.size()};
for(UnsignedInt i = 0; i < accessories.size(); i++) {
for(auto i = 0u; i < accessories.size(); i++) {
accessories[i] = other.accessories[i];
}
return *this;
@ -59,8 +56,8 @@ struct WeaponPart {
WeaponPart(WeaponPart&& other) = default;
WeaponPart& operator=(WeaponPart&& other) = default;
Int id = 0;
Containers::StaticArray<4, Int> styles{ValueInit};
std::int32_t id = 0;
Containers::StaticArray<4, std::int32_t> styles{ValueInit};
Containers::Array<Decal> decals{};
Containers::Array<Accessory> accessories{};
};

View file

@ -30,7 +30,7 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie
_saveDirectory{save_path}, _account{account}, _demo{demo}, _stagingAreaDirectory{staging_dir}
{
Containers::String mass_filename = "";
for(UnsignedInt i = 0; i < _hangars.size(); i++) {
for(std::uint32_t i = 0; i < _hangars.size(); i++) {
mass_filename = Utility::Path::join(_saveDirectory,
Utility::format("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account));
new(&_hangars[i]) Mass{mass_filename};
@ -39,15 +39,18 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie
refreshStagedMasses();
}
auto MassManager::lastError() -> Containers::StringView {
Containers::StringView
MassManager::lastError() {
return _lastError;
}
auto MassManager::hangar(Int hangar) -> Mass& {
Mass&
MassManager::hangar(std::int32_t hangar) {
return _hangars[hangar];
}
void MassManager::refreshHangar(Int hangar) {
void
MassManager::refreshHangar(std::int32_t hangar) {
if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range.";
LOG_ERROR(_lastError);
@ -60,7 +63,8 @@ void MassManager::refreshHangar(Int hangar) {
_hangars[hangar] = Mass{mass_filename};
}
auto MassManager::importMass(Containers::StringView staged_fn, Int hangar) -> bool {
bool
MassManager::importMass(Containers::StringView staged_fn, std::int32_t hangar) {
if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range.";
LOG_ERROR(_lastError);
@ -102,7 +106,8 @@ auto MassManager::importMass(Containers::StringView staged_fn, Int hangar) -> bo
return true;
}
auto MassManager::exportMass(Int hangar) -> bool {
bool
MassManager::exportMass(std::int32_t hangar) {
if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."_s;
LOG_ERROR(_lastError);
@ -128,7 +133,8 @@ auto MassManager::exportMass(Int hangar) -> bool {
return true;
}
auto MassManager::moveMass(Int source, Int destination) -> bool {
bool
MassManager::moveMass(std::int32_t source, std::int32_t destination) {
if(source < 0 || source >= 32) {
_lastError = "Source hangar index out of range."_s;
LOG_ERROR(_lastError);
@ -165,7 +171,8 @@ auto MassManager::moveMass(Int source, Int destination) -> bool {
return true;
}
auto MassManager::deleteMass(Int hangar) -> bool {
bool
MassManager::deleteMass(std::int32_t hangar) {
if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."_s;
LOG_ERROR(_lastError);
@ -181,11 +188,13 @@ auto MassManager::deleteMass(Int hangar) -> bool {
return true;
}
auto MassManager::stagedMasses() -> std::map<Containers::String, Containers::String> const& {
const std::map<Containers::String, Containers::String>&
MassManager::stagedMasses() {
return _stagedMasses;
}
void MassManager::refreshStagedMasses() {
void
MassManager::refreshStagedMasses() {
_stagedMasses.clear();
using Utility::Path::ListFlag;
@ -217,7 +226,8 @@ void MassManager::refreshStagedMasses() {
}
}
void MassManager::refreshStagedMass(Containers::StringView filename) {
void
MassManager::refreshStagedMass(Containers::StringView filename) {
LOG_INFO_FORMAT("Refreshing staged unit with filename {}.", filename);
bool file_exists = Utility::Path::exists(Utility::Path::join(_stagingAreaDirectory, filename));
@ -237,7 +247,8 @@ void MassManager::refreshStagedMass(Containers::StringView filename) {
}
}
auto MassManager::deleteStagedMass(Containers::StringView filename) -> bool {
bool
MassManager::deleteStagedMass(Containers::StringView filename) {
if(_stagedMasses.find(filename) == _stagedMasses.cend()) {
_lastError = "The file "_s + filename + " couldn't be found in the list of staged M.A.S.S.es."_s;
LOG_ERROR(_lastError);

View file

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

View file

@ -62,31 +62,38 @@ Profile::Profile(Containers::StringView path):
refreshValues();
}
auto Profile::valid() const -> bool {
bool
Profile::valid() const {
return _valid;
}
auto Profile::lastError() const -> Containers::StringView {
Containers::StringView
Profile::lastError() const {
return _lastError;
}
auto Profile::filename() const -> Containers::StringView {
Containers::StringView
Profile::filename() const {
return _filename;
}
auto Profile::type() const -> ProfileType {
ProfileType
Profile::type() const {
return _type;
}
auto Profile::isDemo() const -> bool {
bool
Profile::isDemo() const {
return _type == ProfileType::Demo;
}
auto Profile::account() const -> Containers::StringView {
Containers::StringView
Profile::account() const {
return _account;
}
void Profile::refreshValues() {
void
Profile::refreshValues() {
if(!_profile.reloadData()) {
LOG_ERROR(_profile.lastError());
_valid = false;
@ -126,42 +133,44 @@ void Profile::refreshValues() {
_lastMissionId = prop ? prop->value : 0;
LOG_INFO("Getting the materials.");
_verseSteel = getResource(PROFILE_MATERIAL, VerseSteel);
_undinium = getResource(PROFILE_MATERIAL, Undinium);
_necriumAlloy = getResource(PROFILE_MATERIAL, NecriumAlloy);
_lunarite = getResource(PROFILE_MATERIAL, Lunarite);
_asterite = getResource(PROFILE_MATERIAL, Asterite);
_halliteFragma = getResource(PROFILE_MATERIAL, HalliteFragma);
_materials[VerseSteel] = getResource(PROFILE_MATERIAL, VerseSteel);
_materials[Undinium] = getResource(PROFILE_MATERIAL, Undinium);
_materials[NecriumAlloy] = getResource(PROFILE_MATERIAL, NecriumAlloy);
_materials[Lunarite] = getResource(PROFILE_MATERIAL, Lunarite);
_materials[Asterite] = getResource(PROFILE_MATERIAL, Asterite);
_materials[HalliteFragma] = getResource(PROFILE_MATERIAL, HalliteFragma);
_ednil = getResource(PROFILE_MATERIAL, Ednil);
_nuflalt = getResource(PROFILE_MATERIAL, Nuflalt);
_aurelene = getResource(PROFILE_MATERIAL, Aurelene);
_soldus = getResource(PROFILE_MATERIAL, Soldus);
_synthesisedN = getResource(PROFILE_MATERIAL, SynthesisedN);
_nanoc = getResource(PROFILE_MATERIAL, Nanoc);
_materials[Ednil] = getResource(PROFILE_MATERIAL, Ednil);
_materials[Nuflalt] = getResource(PROFILE_MATERIAL, Nuflalt);
_materials[Aurelene] = getResource(PROFILE_MATERIAL, Aurelene);
_materials[Soldus] = getResource(PROFILE_MATERIAL, Soldus);
_materials[SynthesisedN] = getResource(PROFILE_MATERIAL, SynthesisedN);
_materials[Nanoc] = getResource(PROFILE_MATERIAL, Nanoc);
_alcarbonite = getResource(PROFILE_MATERIAL, Alcarbonite);
_keriphene = getResource(PROFILE_MATERIAL, Keriphene);
_nitinolCM = getResource(PROFILE_MATERIAL, NitinolCM);
_quarkium = getResource(PROFILE_MATERIAL, Quarkium);
_alterene = getResource(PROFILE_MATERIAL, Alterene);
_cosmium = getResource(PROFILE_MATERIAL, Cosmium);
_materials[Alcarbonite] = getResource(PROFILE_MATERIAL, Alcarbonite);
_materials[Keriphene] = getResource(PROFILE_MATERIAL, Keriphene);
_materials[NitinolCM] = getResource(PROFILE_MATERIAL, NitinolCM);
_materials[Quarkium] = getResource(PROFILE_MATERIAL, Quarkium);
_materials[Alterene] = getResource(PROFILE_MATERIAL, Alterene);
_materials[Cosmium] = getResource(PROFILE_MATERIAL, Cosmium);
_mixedComposition = getResource(PROFILE_QUARK_DATA, MixedComposition);
_voidResidue = getResource(PROFILE_QUARK_DATA, VoidResidue);
_muscularConstruction = getResource(PROFILE_QUARK_DATA, MuscularConstruction);
_mineralExoskeletology = getResource(PROFILE_QUARK_DATA, MineralExoskeletology);
_carbonisedSkin = getResource(PROFILE_QUARK_DATA, CarbonisedSkin);
_isolatedVoidParticle = getResource(PROFILE_QUARK_DATA, IsolatedVoidParticle);
_materials[MixedComposition] = getResource(PROFILE_QUARK_DATA, MixedComposition);
_materials[VoidResidue] = getResource(PROFILE_QUARK_DATA, VoidResidue);
_materials[MuscularConstruction] = getResource(PROFILE_QUARK_DATA, MuscularConstruction);
_materials[MineralExoskeletology] = getResource(PROFILE_QUARK_DATA, MineralExoskeletology);
_materials[CarbonisedSkin] = getResource(PROFILE_QUARK_DATA, CarbonisedSkin);
_materials[IsolatedVoidParticle] = getResource(PROFILE_QUARK_DATA, IsolatedVoidParticle);
_valid = true;
}
auto Profile::companyName() const -> Containers::StringView {
Containers::StringView
Profile::companyName() const {
return _name;
}
auto Profile::renameCompany(Containers::StringView new_name) -> bool {
bool
Profile::renameCompany(Containers::StringView new_name) {
auto name_prop = _profile.at<StringProperty>(PROFILE_NAME);
if(!name_prop) {
_lastError = "No company name in "_s + _filename;
@ -180,21 +189,24 @@ auto Profile::renameCompany(Containers::StringView new_name) -> bool {
return true;
}
auto Profile::activeFrameSlot() const -> Int {
std::int32_t
Profile::activeFrameSlot() const {
return _activeFrameSlot;
}
auto Profile::credits() const -> Int {
std::int32_t
Profile::credits() const {
return _credits;
}
auto Profile::setCredits(Int amount) -> bool {
bool
Profile::setCredits(std::int32_t amount) {
auto credits_prop = _profile.at<IntProperty>(PROFILE_CREDITS);
if(!credits_prop) {
credits_prop = new IntProperty;
credits_prop->name.emplace("Credit"_s);
credits_prop->valueLength = sizeof(Int);
credits_prop->valueLength = sizeof(std::int32_t);
_profile.appendProperty(IntProperty::ptr{credits_prop});
}
@ -208,17 +220,19 @@ auto Profile::setCredits(Int amount) -> bool {
return true;
}
auto Profile::storyProgress() const -> Int {
std::int32_t
Profile::storyProgress() const {
return _storyProgress;
}
auto Profile::setStoryProgress(Int progress) -> bool {
bool
Profile::setStoryProgress(std::int32_t progress) {
auto story_progress_prop = _profile.at<IntProperty>("StoryProgress"_s);
if(!story_progress_prop) {
story_progress_prop = new IntProperty;
story_progress_prop->name.emplace("StoryProgress"_s);
story_progress_prop->valueLength = sizeof(Int);
story_progress_prop->valueLength = sizeof(std::int32_t);
_profile.appendProperty(IntProperty::ptr{story_progress_prop});
}
@ -232,232 +246,25 @@ auto Profile::setStoryProgress(Int progress) -> bool {
return true;
}
auto Profile::lastMissionId() const -> Int {
std::int32_t
Profile::lastMissionId() const {
return _lastMissionId;
}
auto Profile::verseSteel() const -> Int {
return _verseSteel;
}
auto Profile::setVerseSteel(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, VerseSteel, amount);
}
auto Profile::undinium() const -> Int {
return _undinium;
}
auto Profile::setUndinium(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Undinium, amount);
}
auto Profile::necriumAlloy() const -> Int {
return _necriumAlloy;
}
auto Profile::setNecriumAlloy(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, NecriumAlloy, amount);
}
auto Profile::lunarite() const -> Int {
return _lunarite;
}
auto Profile::setLunarite(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Lunarite, amount);
}
auto Profile::asterite() const -> Int {
return _asterite;
}
auto Profile::setAsterite(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Asterite, amount);
}
Int
Profile::halliteFragma() const {
return _halliteFragma;
std::int32_t
Profile::material(MaterialID id) const {
return _materials.at(id);
}
bool
Profile::setHalliteFragma(Int amount) {
return setResource(PROFILE_MATERIAL, HalliteFragma, amount);
}
auto Profile::ednil() const -> Int {
return _ednil;
}
auto Profile::setEdnil(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Ednil, amount);
}
auto Profile::nuflalt() const -> Int {
return _nuflalt;
}
auto Profile::setNuflalt(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Nuflalt, amount);
}
auto Profile::aurelene() const -> Int {
return _aurelene;
}
auto Profile::setAurelene(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Aurelene, amount);
}
auto Profile::soldus() const -> Int {
return _soldus;
}
auto Profile::setSoldus(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Soldus, amount);
}
auto Profile::synthesisedN() const -> Int {
return _synthesisedN;
}
auto Profile::setSynthesisedN(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, SynthesisedN, amount);
}
Int
Profile::nanoc() const {
return _nanoc;
}
bool
Profile::setNanoc(Int amount) {
return setResource(PROFILE_MATERIAL, Nanoc, amount);
}
auto Profile::alcarbonite() const -> Int {
return _alcarbonite;
}
auto Profile::setAlcarbonite(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Alcarbonite, amount);
}
auto Profile::keriphene() const -> Int {
return _keriphene;
}
auto Profile::setKeriphene(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Keriphene, amount);
}
auto Profile::nitinolCM() const -> Int {
return _nitinolCM;
}
auto Profile::setNitinolCM(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, NitinolCM, amount);
}
auto Profile::quarkium() const -> Int {
return _quarkium;
}
auto Profile::setQuarkium(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Quarkium, amount);
}
auto Profile::alterene() const -> Int {
return _alterene;
}
auto Profile::setAlterene(Int amount) -> bool {
return setResource(PROFILE_MATERIAL, Alterene, amount);
}
Int
Profile::cosmium() const {
return _cosmium;
}
bool
Profile::setCosmium(Int amount) {
return setResource(PROFILE_MATERIAL, Cosmium, amount);
}
auto Profile::mixedComposition() const -> Int {
return _mixedComposition;
}
auto Profile::setMixedComposition(Int amount) -> bool {
return setResource(PROFILE_QUARK_DATA, MixedComposition, amount);
}
auto Profile::voidResidue() const -> Int {
return _voidResidue;
}
auto Profile::setVoidResidue(Int amount) -> bool {
return setResource(PROFILE_QUARK_DATA, VoidResidue, amount);
}
auto Profile::muscularConstruction() const -> Int {
return _muscularConstruction;
}
auto Profile::setMuscularConstruction(Int amount) -> bool {
return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount);
}
auto Profile::mineralExoskeletology() const -> Int {
return _mineralExoskeletology;
}
auto Profile::setMineralExoskeletology(Int amount) -> bool {
return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount);
}
auto Profile::carbonisedSkin() const -> Int {
return _carbonisedSkin;
}
auto Profile::setCarbonisedSkin(Int amount) -> bool {
return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount);
}
Int
Profile::isolatedVoidParticle() const {
return _isolatedVoidParticle;
}
bool
Profile::setIsolatedVoidParticle(Int amount) {
return setResource(PROFILE_QUARK_DATA, IsolatedVoidParticle, amount);
}
auto Profile::getResource(Containers::StringView container, MaterialID id) -> Int {
auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) {
return 0;
}
auto predicate = [&id](UnrealPropertyBase::ptr& prop){
auto res_prop = static_cast<ResourceItemValue*>(prop.get());
return res_prop->id == id;
};
auto it = std::find_if(mats_prop->items.begin(), mats_prop->items.end(), predicate);
return it != mats_prop->items.end() ? static_cast<ResourceItemValue*>(it->get())->quantity : 0;
}
auto Profile::setResource(Containers::StringView container, MaterialID id, Int amount) -> bool {
Profile::setMaterial(MaterialID id, std::int32_t amount) {
Containers::StringView container = id > MixedComposition ? PROFILE_QUARK_DATA : PROFILE_MATERIAL;
auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) {
mats_prop = new ArrayProperty;
mats_prop->name.emplace(container);
mats_prop->itemType = "StructProperty";
_profile.appendProperty(ArrayProperty::ptr{mats_prop});
}
@ -471,6 +278,9 @@ auto Profile::setResource(Containers::StringView container, MaterialID id, Int a
ResourceItemValue* res_prop;
if(it == mats_prop->items.end()) {
res_prop = new ResourceItemValue;
if(mats_prop->items.isEmpty()) {
res_prop->name.emplace("ResourceMaterial");
}
res_prop->id = id;
ResourceItemValue::ptr prop{res_prop};
arrayAppend(mats_prop->items, std::move(prop));
@ -488,3 +298,20 @@ auto Profile::setResource(Containers::StringView container, MaterialID id, Int a
return true;
}
std::int32_t
Profile::getResource(Containers::StringView container, MaterialID id) {
auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) {
return 0;
}
auto predicate = [&id](UnrealPropertyBase::ptr& prop){
auto res_prop = static_cast<ResourceItemValue*>(prop.get());
return res_prop->id == id;
};
auto it = std::find_if(mats_prop->items.begin(), mats_prop->items.end(), predicate);
return it != mats_prop->items.end() ? static_cast<ResourceItemValue*>(it->get())->quantity : 0;
}

View file

@ -16,19 +16,18 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <map>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Magnum.h>
#include "../UESaveFile/UESaveFile.h"
#include "ResourceIDs.h"
using namespace Corrade;
using namespace Magnum;
enum class ProfileType : UnsignedByte {
enum class ProfileType: std::uint8_t {
Demo,
FullGame
};
@ -37,107 +36,37 @@ class Profile {
public:
explicit Profile(Containers::StringView path);
auto valid() const -> bool;
bool valid() const;
auto lastError() const -> Containers::StringView;
auto filename() const -> Containers::StringView;
auto type() const -> ProfileType;
auto isDemo() const -> bool;
ProfileType type() const;
bool isDemo() const;
auto account() const -> Containers::StringView;
void refreshValues();
auto companyName() const -> Containers::StringView;
auto renameCompany(Containers::StringView new_name) -> bool;
bool renameCompany(Containers::StringView new_name);
auto activeFrameSlot() const -> Int;
std::int32_t activeFrameSlot() const;
auto credits() const -> Int;
auto setCredits(Int credits) -> bool;
std::int32_t credits() const;
bool setCredits(std::int32_t credits);
auto storyProgress() const -> Int;
auto setStoryProgress(Int progress) -> bool;
std::int32_t storyProgress() const;
bool setStoryProgress(std::int32_t progress);
auto lastMissionId() const -> Int;
std::int32_t lastMissionId() const;
auto verseSteel() const -> Int;
auto setVerseSteel(Int amount) -> bool;
auto undinium() const -> Int;
auto setUndinium(Int amount) -> bool;
auto necriumAlloy() const -> Int;
auto setNecriumAlloy(Int amount) -> bool;
auto lunarite() const -> Int;
auto setLunarite(Int amount) -> bool;
auto asterite() const -> Int;
auto setAsterite(Int amount) -> bool;
Int halliteFragma() const;
bool setHalliteFragma(Int amount);
auto ednil() const -> Int;
auto setEdnil(Int amount) -> bool;
auto nuflalt() const -> Int;
auto setNuflalt(Int amount) -> bool;
auto aurelene() const -> Int;
auto setAurelene(Int amount) -> bool;
auto soldus() const -> Int;
auto setSoldus(Int amount) -> bool;
auto synthesisedN() const -> Int;
auto setSynthesisedN(Int amount) -> bool;
Int nanoc() const;
bool setNanoc(Int amount);
auto alcarbonite() const -> Int;
auto setAlcarbonite(Int amount) -> bool;
auto keriphene() const -> Int;
auto setKeriphene(Int amount) -> bool;
auto nitinolCM() const -> Int;
auto setNitinolCM(Int amount) -> bool;
auto quarkium() const -> Int;
auto setQuarkium(Int amount) -> bool;
auto alterene() const -> Int;
auto setAlterene(Int amount) -> bool;
Int cosmium() const;
bool setCosmium(Int amount);
auto mixedComposition() const -> Int;
auto setMixedComposition(Int amount) -> bool;
auto voidResidue() const -> Int;
auto setVoidResidue(Int amount) -> bool;
auto muscularConstruction() const -> Int;
auto setMuscularConstruction(Int amount) -> bool;
auto mineralExoskeletology() const -> Int;
auto setMineralExoskeletology(Int amount) -> bool;
auto carbonisedSkin() const -> Int;
auto setCarbonisedSkin(Int amount) -> bool;
Int isolatedVoidParticle() const;
bool setIsolatedVoidParticle(Int amount);
std::int32_t material(MaterialID id) const;
bool setMaterial(MaterialID id, std::int32_t amount);
private:
auto getResource(Containers::StringView container, MaterialID id) -> Int;
auto setResource(Containers::StringView container, MaterialID id, Int amount) -> bool;
std::int32_t getResource(Containers::StringView container, MaterialID id);
Containers::String _filename;
@ -146,38 +75,12 @@ class Profile {
UESaveFile _profile;
Containers::String _name;
Int _activeFrameSlot = 0;
Int _credits = 0;
Int _storyProgress = 0;
Int _lastMissionId = 0;
std::int32_t _activeFrameSlot = 0;
std::int32_t _credits = 0;
std::int32_t _storyProgress = 0;
std::int32_t _lastMissionId = 0;
Int _verseSteel = 0;
Int _undinium = 0;
Int _necriumAlloy = 0;
Int _lunarite = 0;
Int _asterite = 0;
Int _halliteFragma = 0;
Int _ednil = 0;
Int _nuflalt = 0;
Int _aurelene = 0;
Int _soldus = 0;
Int _synthesisedN = 0;
Int _nanoc = 0;
Int _alcarbonite = 0;
Int _keriphene = 0;
Int _nitinolCM = 0;
Int _quarkium = 0;
Int _alterene = 0;
Int _cosmium = 0;
Int _mixedComposition = 0;
Int _voidResidue = 0;
Int _muscularConstruction = 0;
Int _mineralExoskeletology = 0;
Int _carbonisedSkin = 0;
Int _isolatedVoidParticle = 0;
std::map<MaterialID, std::int32_t> _materials;
Containers::String _account;

View file

@ -16,11 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Magnum/Types.h>
using namespace Magnum;
enum MaterialID : Int {
enum MaterialID : std::int32_t {
VerseSteel = 0xC3500,
Undinium = 0xC3501,
NecriumAlloy = 0xC3502,

View file

@ -40,19 +40,23 @@ ProfileManager::ProfileManager(Containers::StringView save_dir, Containers::Stri
_ready = refreshProfiles();
}
auto ProfileManager::ready() const -> bool {
bool
ProfileManager::ready() const {
return _ready;
}
auto ProfileManager::lastError() -> Containers::StringView {
Containers::StringView
ProfileManager::lastError() {
return _lastError;
}
auto ProfileManager::profiles() -> Containers::ArrayView<Profile> {
Containers::ArrayView<Profile>
ProfileManager::profiles() {
return _profiles;
}
auto ProfileManager::refreshProfiles() -> bool {
bool
ProfileManager::refreshProfiles() {
LOG_INFO("Refreshing profiles.");
_profiles = Containers::Array<Profile>{};
@ -93,11 +97,13 @@ auto ProfileManager::refreshProfiles() -> bool {
return true;
}
auto ProfileManager::getProfile(std::size_t index) -> Profile* {
Profile*
ProfileManager::getProfile(std::size_t index) {
return index <= _profiles.size() ? &(_profiles[index]) : nullptr;
}
auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> bool {
bool
ProfileManager::deleteProfile(std::size_t index, bool delete_builds) {
if(!Utility::Path::remove(Utility::Path::join(_saveDirectory, _profiles[index].filename()))) {
_lastError = Utility::format("Couldn't delete {} (filename: {}).",
_profiles[index].companyName(),
@ -108,7 +114,7 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo
}
if(delete_builds) {
for(UnsignedByte i = 0; i < 32; ++i) {
for(std::uint8_t i = 0; i < 32; ++i) {
auto filename = Utility::format("{}Unit{:.2d}{}.sav",
_profiles[index].type() == ProfileType::Demo ? "Demo": "",
i, _profiles[index].account());
@ -126,7 +132,8 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo
return true;
}
auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> bool {
bool
ProfileManager::backupProfile(std::size_t index, bool backup_builds) {
std::time_t timestamp = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm* time = std::localtime(&timestamp);
auto& profile = _profiles[index];
@ -169,7 +176,7 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
zip_set_archive_comment(zip, comment.data(), comment.size());
if(backup_builds) {
for(UnsignedByte i = 0; i < 32; ++i) {
for(std::uint8_t i = 0; i < 32; ++i) {
auto build_filename = Utility::format("{}Unit{:.2d}{}.sav",
profile.isDemo() ? "Demo"_s : ""_s, i,
profile.account());
@ -202,11 +209,13 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
return true;
}
auto ProfileManager::backups() -> Containers::ArrayView<Backup> {
Containers::ArrayView<Backup>
ProfileManager::backups() {
return _backups;
}
void ProfileManager::refreshBackups() {
void
ProfileManager::refreshBackups() {
_backups = Containers::Array<Backup>{};
using Utility::Path::ListFlag;
@ -238,7 +247,7 @@ void ProfileManager::refreshBackups() {
Containers::ScopeGuard guard{zip, zip_close};
Long num_entries = zip_get_num_entries(zip, ZIP_FL_UNCHANGED);
auto num_entries = zip_get_num_entries(zip, ZIP_FL_UNCHANGED);
if(num_entries == 0) {
continue;
@ -282,7 +291,7 @@ void ProfileManager::refreshBackups() {
arrayReserve(backup.includedFiles, num_entries);
for(Long i = 0; i < num_entries; i++) {
for(auto i = 0; i < num_entries; i++) {
arrayAppend(backup.includedFiles, InPlaceInit, zip_get_name(zip, i, ZIP_FL_UNCHANGED));
}
@ -290,7 +299,8 @@ void ProfileManager::refreshBackups() {
}
}
auto ProfileManager::deleteBackup(std::size_t index) -> bool {
bool
ProfileManager::deleteBackup(std::size_t index) {
if(!Utility::Path::remove(Utility::Path::join(_backupsDirectory, _backups[index].filename))) {
_lastError = "Couldn't delete " + _backups[index].filename;
LOG_ERROR(_lastError);
@ -307,7 +317,8 @@ auto ProfileManager::deleteBackup(std::size_t index) -> bool {
return true;
}
auto ProfileManager::restoreBackup(std::size_t index) -> bool {
bool
ProfileManager::restoreBackup(std::size_t index) {
const Backup& backup = _backups[index];
auto error_format = "Extraction of file {} failed: {}"_s;
@ -347,7 +358,7 @@ auto ProfileManager::restoreBackup(std::size_t index) -> bool {
Containers::StaticArray<8192, char> buf{ValueInit};
Long bytes_read = 0;
auto bytes_read = 0l;
while((bytes_read = zip_fread(zf, buf.data(), buf.size())) > 0) {
if(std::fwrite(buf.data(), sizeof(char), bytes_read, out) < static_cast<std::size_t>(bytes_read)) {
_lastError = Utility::format(error_format.data(), file, "not enough bytes written.");

View file

@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <string>
#include <Corrade/Containers/Array.h>
@ -30,12 +32,12 @@ struct Backup {
Containers::String company;
ProfileType type;
struct {
int year;
int month;
int day;
int hour;
int minute;
int second;
std::int32_t year;
std::int32_t month;
std::int32_t day;
std::int32_t hour;
std::int32_t minute;
std::int32_t second;
} timestamp;
Containers::Array<Containers::String> includedFiles;
};
@ -45,20 +47,20 @@ class ProfileManager {
explicit ProfileManager(Containers::StringView save_dir, Containers::StringView backup_dir);
auto ready() const -> bool;
auto lastError() -> Containers::StringView;
Containers::StringView lastError();
auto profiles() -> Containers::ArrayView<Profile>;
auto refreshProfiles() -> bool;
Containers::ArrayView<Profile> profiles();
bool refreshProfiles();
auto getProfile(std::size_t index) -> Profile*;
auto deleteProfile(std::size_t index, bool delete_builds) -> bool;
auto backupProfile(std::size_t index, bool backup_builds) -> bool;
Profile* getProfile(std::size_t index);
bool deleteProfile(std::size_t index, bool delete_builds);
bool backupProfile(std::size_t index, bool backup_builds);
auto backups() -> Containers::ArrayView<Backup>;
Containers::ArrayView<Backup> backups();
void refreshBackups();
auto deleteBackup(std::size_t index) -> bool;
auto restoreBackup(std::size_t index) -> bool;
bool deleteBackup(std::size_t index);
bool restoreBackup(std::size_t index);
private:
bool _ready = false;

View file

@ -35,6 +35,7 @@
#include <wtsapi32.h>
#include "../FontAwesome/IconsFontAwesome5.h"
#include "../Configuration/Configuration.h"
#include "../Logger/Logger.h"
using namespace Containers::Literals;
@ -57,8 +58,6 @@ SaveTool::SaveTool(const Arguments& arguments):
LOG_INFO("Configuring OpenGL renderer.");
GL::Renderer::enable(GL::Renderer::Feature::Blending);
GL::Renderer::enable(GL::Renderer::Feature::ScissorTest);
GL::Renderer::disable(GL::Renderer::Feature::FaceCulling);
GL::Renderer::disable(GL::Renderer::Feature::DepthTest);
GL::Renderer::setBlendFunction(GL::Renderer::BlendFunction::SourceAlpha,
GL::Renderer::BlendFunction::OneMinusSourceAlpha);
GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add,
@ -78,7 +77,7 @@ SaveTool::SaveTool(const Arguments& arguments):
#endif
LOG_INFO("Registering custom events.");
if((_initEventId = SDL_RegisterEvents(3)) == UnsignedInt(-1)) {
if((_initEventId = SDL_RegisterEvents(3)) == std::uint32_t(-1)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
"SDL_RegisterEvents() failed in SaveTool::SaveTool(). Exiting...", window());
exit(EXIT_FAILURE);
@ -115,7 +114,7 @@ SaveTool::SaveTool(const Arguments& arguments):
checkGameState();
_gameCheckTimerId = SDL_AddTimer(2000,
[](UnsignedInt interval, void* param)->UnsignedInt{
[](std::uint32_t interval, void* param)->std::uint32_t{
static_cast<SaveTool*>(param)->checkGameState();
return interval;
}, this);
@ -130,7 +129,7 @@ SaveTool::SaveTool(const Arguments& arguments):
LOG_INFO("Initialising update checker.");
curl_global_init(CURL_GLOBAL_DEFAULT);
if(_checkUpdatesOnStartup) {
if(conf().checkUpdatesOnStartup()) {
_queue.addToast(Toast::Type::Default, "Checking for updates..."_s);
_updateThread = std::thread{[this]{ checkForUpdates(); }};
}
@ -141,7 +140,7 @@ SaveTool::SaveTool(const Arguments& arguments):
GL::DebugOutput::setEnabled(GL::DebugOutput::Source::Api, GL::DebugOutput::Type::Other, {131185}, false);
}
if(_skipDisclaimer) {
if(conf().skipDisclaimer()) {
_uiState = UiState::Initialising;
_initThread = std::thread{[this]{ initialiseManager(); }};
}
@ -159,19 +158,13 @@ SaveTool::~SaveTool() {
LOG_INFO("Saving the configuration.");
_conf.setValue("cheat_mode"_s, _cheatMode);
_conf.setValue("advanced_mode"_s, _advancedMode);
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup);
_conf.setValue("skip_disclaimer"_s, _skipDisclaimer);
_conf.setValue("swap_interval"_s, _swapInterval);
_conf.setValue("fps_cap"_s, _fpsCap);
_conf.save();
conf().save();
LOG_INFO("Exiting.");
}
void SaveTool::drawEvent() {
void
SaveTool::drawEvent() {
#ifdef SAVETOOL_DEBUG_BUILD
tweak.update();
#endif
@ -182,8 +175,8 @@ void SaveTool::drawEvent() {
swapBuffers();
if(_swapInterval == 0 && _fpsCap < 301.0f) {
while(_timeline.currentFrameDuration() < (1.0f / _fpsCap));
if(conf().swapInterval() == 0 && conf().fpsCap() < 301.0f) {
while(_timeline.currentFrameDuration() < (1.0f / conf().fpsCap()));
}
redraw();
@ -191,45 +184,54 @@ void SaveTool::drawEvent() {
_timeline.nextFrame();
}
void SaveTool::viewportEvent(ViewportEvent& event) {
void
SaveTool::viewportEvent(ViewportEvent& event) {
GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()});
const Vector2 size = Vector2{windowSize()}/dpiScaling();
_imgui.relayout(size, windowSize(), framebufferSize());
}
void SaveTool::keyPressEvent(KeyEvent& event) {
void
SaveTool::keyPressEvent(KeyEvent& event) {
if(_imgui.handleKeyPressEvent(event)) return;
}
void SaveTool::keyReleaseEvent(KeyEvent& event) {
void
SaveTool::keyReleaseEvent(KeyEvent& event) {
if(_imgui.handleKeyReleaseEvent(event)) return;
}
void SaveTool::mousePressEvent(MouseEvent& event) {
void
SaveTool::mousePressEvent(MouseEvent& event) {
if(_imgui.handleMousePressEvent(event)) return;
}
void SaveTool::mouseReleaseEvent(MouseEvent& event) {
void
SaveTool::mouseReleaseEvent(MouseEvent& event) {
if(_imgui.handleMouseReleaseEvent(event)) return;
}
void SaveTool::mouseMoveEvent(MouseMoveEvent& event) {
void
SaveTool::mouseMoveEvent(MouseMoveEvent& event) {
if(_imgui.handleMouseMoveEvent(event)) return;
}
void SaveTool::mouseScrollEvent(MouseScrollEvent& event) {
void
SaveTool::mouseScrollEvent(MouseScrollEvent& event) {
if(_imgui.handleMouseScrollEvent(event)) {
event.setAccepted();
return;
}
}
void SaveTool::textInputEvent(TextInputEvent& event) {
void
SaveTool::textInputEvent(TextInputEvent& event) {
if(_imgui.handleTextInputEvent(event)) return;
}
void SaveTool::anyEvent(SDL_Event& event) {
void
SaveTool::anyEvent(SDL_Event& event) {
if(event.type == _initEventId) {
initEvent(event);
}
@ -241,7 +243,8 @@ void SaveTool::anyEvent(SDL_Event& event) {
}
}
void SaveTool::drawImGui() {
void
SaveTool::drawImGui() {
_imgui.newFrame();
if(ImGui::GetIO().WantTextInput && !isTextInputActive()) {
@ -258,7 +261,8 @@ void SaveTool::drawImGui() {
_imgui.drawFrame();
}
void SaveTool::drawGui() {
void
SaveTool::drawGui() {
drawMainMenu();
switch(_uiState) {
@ -300,7 +304,8 @@ void SaveTool::drawGui() {
_queue.draw(windowSize());
}
void SaveTool::drawDisclaimer() {
void
SaveTool::drawDisclaimer() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
if(ImGui::Begin("Disclaimer##DisclaimerWindow", nullptr,
@ -344,7 +349,9 @@ void SaveTool::drawDisclaimer() {
ImGui::Dummy({0.0f, 5.0f});
ImGui::Dummy({4.0f, 0.0f});
ImGui::SameLine();
ImGui::Checkbox("Don't show next time", &_skipDisclaimer);
if(drawCheckbox("Don't show next time", conf().skipDisclaimer())) {
conf().setSkipDisclaimer(!conf().skipDisclaimer());
}
ImGui::TableSetColumnIndex(1);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {24.0f, 12.0f});
if(ImGui::Button("I understand the risks")) {
@ -359,7 +366,8 @@ void SaveTool::drawDisclaimer() {
ImGui::End();
}
void SaveTool::drawInitialisation() {
void
SaveTool::drawInitialisation() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot);
if(ImGui::BeginPopupModal("##InitPopup", nullptr,
@ -372,7 +380,8 @@ void SaveTool::drawInitialisation() {
ImGui::OpenPopup("##InitPopup");
}
void SaveTool::drawGameState() {
void
SaveTool::drawGameState() {
ImGui::TextUnformatted("Game state:");
ImGui::SameLine();
{
@ -393,12 +402,14 @@ void SaveTool::drawGameState() {
}
}
void SaveTool::drawHelpMarker(Containers::StringView text, Float wrap_pos) {
void
SaveTool::drawHelpMarker(Containers::StringView text, float wrap_pos) {
ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE);
drawTooltip(text, wrap_pos);
}
void SaveTool::drawTooltip(Containers::StringView text, Float wrap_pos) {
void
SaveTool::drawTooltip(Containers::StringView text, float wrap_pos) {
if(ImGui::IsItemHovered()){
ImGui::BeginTooltip();
if(wrap_pos > 0.0f) {
@ -412,11 +423,18 @@ void SaveTool::drawTooltip(Containers::StringView text, Float wrap_pos) {
}
}
void SaveTool::openUri(Containers::StringView uri) {
bool
SaveTool::drawCheckbox(Containers::StringView label, bool value) {
return ImGui::Checkbox(label.data(), &value);
}
void
SaveTool::openUri(Containers::StringView uri) {
ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri.data()), nullptr, nullptr, SW_SHOWDEFAULT);
}
void SaveTool::checkGameState() {
void
SaveTool::checkGameState() {
WTS_PROCESS_INFOW* process_infos = nullptr;
unsigned long process_count = 0;

View file

@ -21,7 +21,6 @@
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Utility/Configuration.h>
#include <Corrade/Utility/Resource.h>
#ifdef SAVETOOL_DEBUG_BUILD
#include <Corrade/Utility/Tweakable.h>
@ -78,20 +77,20 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void anyEvent(SDL_Event& event) override;
enum InitStatus: Int {
enum InitStatus: std::int32_t {
InitSuccess,
ProfileManagerFailure
};
void initEvent(SDL_Event& event);
enum UpdateCheckStatus : Int {
enum UpdateCheckStatus : std::int32_t {
CurlInitFailed = 0,
CurlError = 1,
CurlTimeout = 2,
};
void updateCheckEvent(SDL_Event& event);
enum FileEventType: Int {
enum FileEventType: std::int32_t {
FileAdded = efsw::Action::Add,
FileDeleted = efsw::Action::Delete,
FileModified = efsw::Action::Modified,
@ -104,8 +103,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void initialiseConfiguration();
void initialiseGui();
void initialiseManager();
auto initialiseToolDirectories() -> bool;
auto findGameDataDirectory() -> bool;
bool initialiseToolDirectories();
bool findGameDataDirectory();
void initialiseMassManager();
void initialiseFileWatcher();
@ -117,21 +116,20 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawInitialisation();
void drawProfileManager();
auto drawBackupListPopup() -> ImGuiID;
auto drawBackupProfilePopup(std::size_t profile_index) -> ImGuiID;
auto drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID;
ImGuiID drawBackupListPopup();
ImGuiID drawBackupProfilePopup(std::size_t profile_index);
ImGuiID drawDeleteProfilePopup(std::size_t profile_index);
void drawManager();
auto drawIntEditPopup(int* value_to_edit, int max) -> bool;
auto drawRenamePopup(Containers::ArrayView<char> name_view) -> bool;
bool drawIntEditPopup(int* value_to_edit, int max);
bool drawRenamePopup(Containers::ArrayView<char> name_view);
void drawGeneralInfo();
void drawResearchInventory();
template<typename Getter, typename Setter>
void drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter);
void drawUnavailableMaterialRow(Containers::StringView name, Int tier);
void drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id);
void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
void drawMassManager();
auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID;
ImGuiID drawDeleteMassPopup(int mass_index);
ImGuiID drawDeleteStagedMassPopup(Containers::StringView filename);
void drawMassViewer();
void drawFrameInfo();
@ -149,24 +147,25 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawTuning();
void drawDecalEditor(Decal& decal);
void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view);
auto getStyleName(Int id, Containers::ArrayView<CustomStyle> view) -> Containers::StringView;
Containers::StringView getStyleName(std::int32_t id, Containers::ArrayView<CustomStyle> view);
enum DCSResult {
DCS_Fail,
DCS_ResetStyle,
DCS_Save
};
auto drawCustomStyle(CustomStyle& style) -> DCSResult;
DCSResult drawCustomStyle(CustomStyle& style);
void drawAbout();
void drawGameState();
// Convenience wrappers over ImGui stuff
void drawHelpMarker(Containers::StringView text, Float wrap_pos = 0.0f);
void drawTooltip(Containers::StringView text, Float wrap_pos = 0.0f);
void drawHelpMarker(Containers::StringView text, float wrap_pos = 0.0f);
void drawTooltip(Containers::StringView text, float wrap_pos = 0.0f);
bool drawCheckbox(Containers::StringView label, bool value);
template<typename Functor, typename... Args>
auto drawUnsafeWidget(Functor func, Args... args) -> bool {
bool drawUnsafeWidget(Functor func, Args... args) {
GameState game_state = _gameState; // Copying the value to reduce the risk of a data race.
ImGui::BeginDisabled(game_state != GameState::NotRunning);
bool result = func(std::forward<Args>(args)...);
@ -197,7 +196,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void checkForUpdates();
Utility::Configuration _conf{"MassBuilderSaveTool.ini"_s};
Utility::Resource _rs{"assets"_s};
// GUI-related members
@ -223,9 +221,9 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
std::thread _initThread;
std::thread _updateThread;
UnsignedInt _initEventId;
UnsignedInt _updateEventId;
UnsignedInt _fileEventId;
std::uint32_t _initEventId;
std::uint32_t _updateEventId;
std::uint32_t _fileEventId;
Containers::String _lastError;
@ -241,7 +239,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
//Containers::String _weaponsDir;
//Containers::String _stylesDir;
enum class GameState : UnsignedByte {
enum class GameState : std::uint8_t {
Unknown, NotRunning, Running
} _gameState{GameState::Unknown};
@ -262,12 +260,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
};
Containers::StaticArray<2, efsw::WatchID> _watchIDs;
int _swapInterval = 1;
float _fpsCap = 60.0f;
bool _skipDisclaimer{false};
bool _checkUpdatesOnStartup{true};
bool _updateAvailable{false};
Containers::String _latestVersion;
Containers::String _releaseLink;
@ -277,12 +269,12 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
bool _jointsDirty{false};
bool _stylesDirty{false};
bool _eyeFlareDirty{false};
Containers::StaticArray<38, Int> _selectedArmourDecals{ValueInit};
Containers::StaticArray<38, Int> _selectedArmourAccessories{ValueInit};
Int _selectedBLPlacement{0};
Int _selectedWeaponPart{0};
Int _selectedWeaponDecal{0};
Int _selectedWeaponAccessory{0};
Containers::StaticArray<38, std::int32_t> _selectedArmourDecals{ValueInit};
Containers::StaticArray<38, std::int32_t> _selectedArmourAccessories{ValueInit};
std::int32_t _selectedBLPlacement{0};
std::int32_t _selectedWeaponPart{0};
std::int32_t _selectedWeaponDecal{0};
std::int32_t _selectedWeaponAccessory{0};
bool _meleeDirty{false};
bool _shieldsDirty{false};
bool _bShootersDirty{false};
@ -290,8 +282,5 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
bool _bLaunchersDirty{false};
bool _eLaunchersDirty{false};
bool _cheatMode{false};
bool _advancedMode{false};
Timeline _timeline;
};

View file

@ -26,7 +26,8 @@
#include "SaveTool.h"
void SaveTool::handleFileAction(efsw::WatchID watch_id,
void
SaveTool::handleFileAction(efsw::WatchID watch_id,
const std::string&,
const std::string& filename,
efsw::Action action,
@ -60,7 +61,8 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
SDL_PushEvent(&event);
}
void SaveTool::fileUpdateEvent(SDL_Event& event) {
void
SaveTool::fileUpdateEvent(SDL_Event& event) {
Containers::String filename{static_cast<char*>(event.user.data1),
std::strlen(static_cast<char*>(event.user.data1)), nullptr};
@ -71,8 +73,8 @@ void SaveTool::fileUpdateEvent(SDL_Event& event) {
Containers::String old_filename;
Int index = 0;
Int old_index = 0;
std::int32_t index = 0;
std::int32_t old_index = 0;
bool is_current_profile = filename == _currentProfile->filename();
bool is_unit = filename.hasPrefix(_currentProfile->isDemo() ? "DemoUnit"_s : "Unit"_s);
if(is_unit) {

View file

@ -24,13 +24,15 @@
#include <shlobj.h>
#include "../Configuration/Configuration.h"
#include "../FontAwesome/IconsFontAwesome5.h"
#include "../FontAwesome/IconsFontAwesome5Brands.h"
#include "../Logger/Logger.h"
#include "SaveTool.h"
void SaveTool::initEvent(SDL_Event& event) {
void
SaveTool::initEvent(SDL_Event& event) {
_initThread.join();
switch(event.user.code) {
@ -48,68 +50,16 @@ void SaveTool::initEvent(SDL_Event& event) {
}
}
void SaveTool::initialiseConfiguration() {
void
SaveTool::initialiseConfiguration() {
LOG_INFO("Reading configuration file.");
if(_conf.hasValue("cheat_mode"_s)) {
_cheatMode = _conf.value<bool>("cheat_mode"_s);
}
else {
_conf.setValue("cheat_mode"_s, _cheatMode);
}
if(_conf.hasValue("advanced_mode"_s)) {
_advancedMode = _conf.value<bool>("advanced_mode"_s);
}
else {
_conf.setValue("advanced_mode"_s, _advancedMode);
}
if(_conf.hasValue("startup_update_check"_s)) {
_checkUpdatesOnStartup = _conf.value<bool>("startup_update_check"_s);
}
else {
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup);
}
if(_conf.hasValue("skip_disclaimer"_s)) {
_skipDisclaimer = _conf.value<bool>("skip_disclaimer"_s);
}
else {
_conf.setValue("skip_disclaimer"_s, _skipDisclaimer);
}
if(_conf.hasValue("swap_interval"_s)) {
_swapInterval = _conf.value<int>("swap_interval"_s);
}
else {
_conf.setValue("swap_interval"_s, 1);
}
if(_conf.hasValue("fps_cap"_s)) {
_fpsCap = _conf.value<float>("fps_cap");
}
else {
_conf.setValue("fps_cap", 60.0f);
}
if(_conf.hasValue("frame_limit"_s)) {
std::string frame_limit = _conf.value("frame_limit"_s);
if(frame_limit == "half_vsync"_s) {
_swapInterval = 2;
}
_conf.removeValue("frame_limit"_s);
}
setSwapInterval(_swapInterval);
if(_swapInterval == 0) {
setSwapInterval(conf().swapInterval());
setMinimalLoopPeriod(0);
}
_conf.save();
}
void SaveTool::initialiseGui() {
void
SaveTool::initialiseGui() {
LOG_INFO("Initialising Dear ImGui.");
ImGui::CreateContext();
@ -123,7 +73,7 @@ void SaveTool::initialiseGui() {
font_config.FontDataOwnedByAtlas = false;
std::strcpy(font_config.Name, "Source Sans Pro");
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(reg_font.data()), int(reg_font.size()),
20.0f * Float(framebufferSize().x()) / size.x(), &font_config);
20.0f * float(framebufferSize().x()) / size.x(), &font_config);
auto icon_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAS);
static const ImWchar icon_range[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
@ -134,12 +84,12 @@ void SaveTool::initialiseGui() {
icon_config.OversampleH = icon_config.OversampleV = 1;
icon_config.GlyphMinAdvanceX = 18.0f;
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(icon_font.data()), int(icon_font.size()),
16.0f * Float(framebufferSize().x()) / size.x(), &icon_config, icon_range);
16.0f * float(framebufferSize().x()) / size.x(), &icon_config, icon_range);
auto brand_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAB);
static const ImWchar brand_range[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 };
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(brand_font.data()), int(brand_font.size()),
16.0f * Float(framebufferSize().x()) / size.x(), &icon_config, brand_range);
16.0f * float(framebufferSize().x()) / size.x(), &icon_config, brand_range);
auto mono_font = _rs.getRaw("SourceCodePro-Regular.ttf"_s);
ImVector<ImWchar> range;
@ -148,7 +98,7 @@ void SaveTool::initialiseGui() {
builder.AddChar(u'š'); // This allows displaying Vladimír Vondruš' name in Corrade's and Magnum's licences.
builder.BuildRanges(&range);
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(mono_font.data()), int(mono_font.size()),
18.0f * Float(framebufferSize().x()) / size.x(), &font_config, range.Data);
18.0f * float(framebufferSize().x()) / size.x(), &font_config, range.Data);
_imgui = ImGuiIntegration::Context(*ImGui::GetCurrentContext(), windowSize());
@ -161,7 +111,8 @@ void SaveTool::initialiseGui() {
style.Colors[ImGuiCol_WindowBg] = ImColor(0xff1f1f1f);
}
void SaveTool::initialiseManager() {
void
SaveTool::initialiseManager() {
LOG_INFO("Initialising the profile manager.");
SDL_Event event;
@ -179,7 +130,8 @@ void SaveTool::initialiseManager() {
SDL_PushEvent(&event);
}
auto SaveTool::initialiseToolDirectories() -> bool {
auto
SaveTool::initialiseToolDirectories() -> bool {
LOG_INFO("Initialising Save Tool directories.");
_backupsDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "backups");
@ -240,7 +192,8 @@ auto SaveTool::initialiseToolDirectories() -> bool {
return true;
}
auto SaveTool::findGameDataDirectory() -> bool {
auto
SaveTool::findGameDataDirectory() -> bool {
LOG_INFO("Searching for the game's save directory.");
wchar_t* localappdata_path = nullptr;
@ -266,12 +219,14 @@ auto SaveTool::findGameDataDirectory() -> bool {
return true;
}
void SaveTool::initialiseMassManager() {
void
SaveTool::initialiseMassManager() {
LOG_INFO("Initialising the M.A.S.S. manager.");
_massManager.emplace(_saveDir, _currentProfile->account(), _currentProfile->isDemo(), _stagingDir);
}
void SaveTool::initialiseFileWatcher() {
void
SaveTool::initialiseFileWatcher() {
LOG_INFO("Initialising the file watcher.");
_fileWatcher.emplace();
_watchIDs[SaveDir] = _fileWatcher->addWatch(_saveDir, this, false);

View file

@ -21,15 +21,17 @@
#include <SDL_messagebox.h>
#include "../Configuration/Configuration.h"
#include "../FontAwesome/IconsFontAwesome5.h"
#include "../Maps/LastMissionId.h"
#include "../Maps/StoryProgress.h"
#include "SaveTool.h"
void SaveTool::drawManager() {
void
SaveTool::drawManager() {
ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always);
ImGui::SetNextWindowSize({Float(windowSize().x()), Float(windowSize().y()) - ImGui::GetItemRectSize().y},
ImGui::SetNextWindowSize({float(windowSize().x()), float(windowSize().y()) - ImGui::GetItemRectSize().y},
ImGuiCond_Always);
if(!ImGui::Begin("##MainWindow", nullptr,
ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove|
@ -94,7 +96,8 @@ void SaveTool::drawManager() {
ImGui::End();
}
auto SaveTool::drawIntEditPopup(int* value_to_edit, int max) -> bool {
bool
SaveTool::drawIntEditPopup(int* value_to_edit, int max) {
bool apply = false;
if(ImGui::BeginPopup("int_edit")) {
ImGui::Text("Please enter a value between 0 and %i:", max);
@ -103,7 +106,7 @@ auto SaveTool::drawIntEditPopup(int* value_to_edit, int max) -> bool {
drawHelpMarker("You can either drag the widget left or right to change the value,\n"
"or click on it while holding Ctrl to edit the value directly.");
ImGui::SameLine();
drawUnsafeWidget([](auto... args){ return ImGui::SliderInt("", args...); },
drawUnsafeWidget([](auto... args){ return ImGui::SliderInt("##IntSlider", args...); },
value_to_edit, 0, max, "%d", ImGuiSliderFlags_AlwaysClamp);
ImGui::SameLine();
if(drawUnsafeWidget([]{ return ImGui::Button("Apply"); })) {
@ -117,7 +120,8 @@ auto SaveTool::drawIntEditPopup(int* value_to_edit, int max) -> bool {
return apply;
}
auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool {
bool
SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) {
bool apply = false;
if(ImGui::BeginPopup("name_edit")) {
ImGui::TextUnformatted("Please enter a new name. Conditions:");
@ -133,13 +137,15 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool {
(name_view[0] != ' ' && name_view[len - 1] != ' ') ? ICON_FA_CHECK : ICON_FA_TIMES);
static auto callback = [](ImGuiInputTextCallbackData* data)->int {
if(data->EventChar < 256 && std::strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- ", char(data->EventChar))) {
if(data->EventChar < 256 &&
std::strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- ", char(data->EventChar)))
{
return 0;
}
return 1;
};
drawUnsafeWidget([](auto... args){ return ImGui::InputText("", args...); },
drawUnsafeWidget([](auto... args){ return ImGui::InputText("##NameField", args...); },
name_view.data(), name_view.size(),
ImGuiInputTextFlags_CallbackCharFilter,
callback, nullptr);
@ -169,7 +175,8 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool {
return apply;
}
void SaveTool::drawGeneralInfo() {
void
SaveTool::drawGeneralInfo() {
if(!_currentProfile) {
return;
}
@ -205,7 +212,7 @@ void SaveTool::drawGeneralInfo() {
drawTooltip("This is the last mission selected in the mission selection screen, not the last mission played.",
float(windowSize().x()) * 0.35f);
const Float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
ImGui::Dummy({ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y - footer_height_to_reserve});
ImGui::Separator();
@ -224,13 +231,13 @@ void SaveTool::drawGeneralInfo() {
}
}
if(!_cheatMode) {
if(!conf().cheatMode()) {
return;
}
ImGui::SameLine();
static Int credits;
static std::int32_t credits;
if(drawUnsafeWidget([]{ return ImGui::Button("Edit credits"); })) {
credits = _currentProfile->credits();
ImGui::OpenPopup("int_edit");
@ -277,7 +284,8 @@ void SaveTool::drawGeneralInfo() {
}
}
void SaveTool::drawResearchInventory() {
void
SaveTool::drawResearchInventory() {
if(!_currentProfile) {
return;
}
@ -292,150 +300,96 @@ void SaveTool::drawResearchInventory() {
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::Text("Engine materials");
ImGui::TextUnformatted("Engine materials");
drawMaterialRow("Verse steel", 1,
[this]{ return _currentProfile->verseSteel(); },
[this](Int amount){ return _currentProfile->setVerseSteel(amount); });
drawMaterialRow("Undinium", 2,
[this]{ return _currentProfile->undinium(); },
[this](Int amount){ return _currentProfile->setUndinium(amount); });
drawMaterialRow("Necrium alloy", 3,
[this]{ return _currentProfile->necriumAlloy(); },
[this](Int amount){ return _currentProfile->setNecriumAlloy(amount); });
drawMaterialRow("Lunarite", 4,
[this]{ return _currentProfile->lunarite(); },
[this](Int amount){ return _currentProfile->setLunarite(amount); });
drawMaterialRow("Asterite", 5,
[this]{ return _currentProfile->asterite(); },
[this](Int amount){ return _currentProfile->setAsterite(amount); });
drawMaterialRow("Hallite fragma", 6,
[this]{ return _currentProfile->halliteFragma(); },
[this](Int amount){ return _currentProfile->setHalliteFragma(amount); });
drawMaterialRow("Verse steel", 1, VerseSteel);
drawMaterialRow("Undinium", 2, Undinium);
drawMaterialRow("Necrium alloy", 3, NecriumAlloy);
drawMaterialRow("Lunarite", 4, Lunarite);
drawMaterialRow("Asterite", 5, Asterite);
drawMaterialRow("Hallite fragma", 6, HalliteFragma);
drawUnavailableMaterialRow("Unnoctinium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::Text("OS materials");
ImGui::TextUnformatted("OS materials");
drawMaterialRow("Ednil", 1,
[this]{ return _currentProfile->ednil(); },
[this](Int amount){ return _currentProfile->setEdnil(amount); });
drawMaterialRow("Nuflalt", 2,
[this]{ return _currentProfile->nuflalt(); },
[this](Int amount){ return _currentProfile->setNuflalt(amount); });
drawMaterialRow("Aurelene", 3,
[this]{ return _currentProfile->aurelene(); },
[this](Int amount){ return _currentProfile->setAurelene(amount); });
drawMaterialRow("Soldus", 4,
[this]{ return _currentProfile->soldus(); },
[this](Int amount){ return _currentProfile->setSoldus(amount); });
drawMaterialRow("Synthesized N", 5,
[this]{ return _currentProfile->synthesisedN(); },
[this](Int amount){ return _currentProfile->setSynthesisedN(amount); });
drawMaterialRow("Nanoc", 6,
[this]{ return _currentProfile->nanoc(); },
[this](Int amount){ return _currentProfile->setNanoc(amount); });
drawMaterialRow("Ednil", 1, Ednil);
drawMaterialRow("Nuflalt", 2, Nuflalt);
drawMaterialRow("Aurelene", 3, Aurelene);
drawMaterialRow("Soldus", 4, Soldus);
drawMaterialRow("Synthesized N", 5, SynthesisedN);
drawMaterialRow("Nanoc", 6, Nanoc);
drawUnavailableMaterialRow("Abyssillite", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::Text("Architect materials");
ImGui::TextUnformatted("Architect materials");
drawMaterialRow("Alcarbonite", 1,
[this]{ return _currentProfile->alcarbonite(); },
[this](Int amount){ return _currentProfile->setAlcarbonite(amount); });
drawMaterialRow("Keripehene", 2,
[this]{ return _currentProfile->keriphene(); },
[this](Int amount){ return _currentProfile->setKeriphene(amount); });
drawMaterialRow("Nitinol-CM", 3,
[this]{ return _currentProfile->nitinolCM(); },
[this](Int amount){ return _currentProfile->setNitinolCM(amount); });
drawMaterialRow("Quarkium", 4,
[this]{ return _currentProfile->quarkium(); },
[this](Int amount){ return _currentProfile->setQuarkium(amount); });
drawMaterialRow("Alterene", 5,
[this]{ return _currentProfile->alterene(); },
[this](Int amount){ return _currentProfile->setAlterene(amount); });
drawMaterialRow("Cosmium", 6,
[this]{ return _currentProfile->cosmium(); },
[this](Int amount){ return _currentProfile->setCosmium(amount); });
drawMaterialRow("Alcarbonite", 1, Alcarbonite);
drawMaterialRow("Keriphene", 2, Keriphene);
drawMaterialRow("Nitinol-CM", 3, NitinolCM);
drawMaterialRow("Quarkium", 4, Quarkium);
drawMaterialRow("Alterene", 5, Alterene);
drawMaterialRow("Cosmium", 6, Cosmium);
drawUnavailableMaterialRow("Purified quarkium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::Text("Quark data");
ImGui::TextUnformatted("Quark data");
drawMaterialRow("Mixed composition", 1,
[this]{ return _currentProfile->mixedComposition(); },
[this](Int amount){ return _currentProfile->setMixedComposition(amount); });
drawMaterialRow("Void residue", 2,
[this]{ return _currentProfile->voidResidue(); },
[this](Int amount){ return _currentProfile->setVoidResidue(amount); });
drawMaterialRow("Muscular construction", 3,
[this]{ return _currentProfile->muscularConstruction(); },
[this](Int amount){ return _currentProfile->setMuscularConstruction(amount); });
drawMaterialRow("Mineral exoskeletology", 4,
[this]{ return _currentProfile->mineralExoskeletology(); },
[this](Int amount){ return _currentProfile->setMineralExoskeletology(amount); });
drawMaterialRow("Carbonized skin", 5,
[this]{ return _currentProfile->carbonisedSkin(); },
[this](Int amount){ return _currentProfile->setCarbonisedSkin(amount); });
drawMaterialRow("Isolated void particle", 6,
[this]{ return _currentProfile->isolatedVoidParticle(); },
[this](Int amount){ return _currentProfile->setIsolatedVoidParticle(amount); });
drawMaterialRow("Mixed composition", 1, MixedComposition);
drawMaterialRow("Void residue", 2, VoidResidue);
drawMaterialRow("Muscular construction", 3, MuscularConstruction);
drawMaterialRow("Mineral exoskeletology", 4, MineralExoskeletology);
drawMaterialRow("Carbonized skin", 5, CarbonisedSkin);
drawMaterialRow("Isolated void particle", 6, IsolatedVoidParticle);
drawUnavailableMaterialRow("Weaponised physiology", 7);
ImGui::EndTable();
}
}
template<typename Getter, typename Setter>
void SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter) {
static_assert(std::is_same<decltype(getter()), Int>::value, "getter doesn't return an Int, and/or doesn't take zero arguments.");
static_assert(std::is_same<decltype(setter(0)), bool>::value, "setter doesn't return a bool, and/or doesn't take a single Int as an argument.");
void
SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.data());
ImGui::TableSetColumnIndex(2);
if(getter() != -1) {
ImGui::Text("%i", getter());
if(_cheatMode) {
ImGui::Text("%i", _currentProfile->material(id));
if(conf().cheatMode()) {
ImGui::TableSetColumnIndex(3);
ImGui::PushID(name.data());
static Int var = 0;
static std::int32_t var = 0;
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) {
(var) = getter();
var = _currentProfile->material(id);
ImGui::OpenPopup("int_edit");
}
drawTooltip("Edit");
if(drawIntEditPopup(&(var), 9999)) {
if(!setter(var)) {
if(drawIntEditPopup(&var, 9999)) {
if(!_currentProfile->setMaterial(id, var)) {
_queue.addToast(Toast::Type::Error, _currentProfile->lastError());
}
}
ImGui::PopID();
}
}
else {
ImGui::TextDisabled("Not found in the save file");
}
}
void SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) {
void
SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.data());
ImGui::TextUnformatted(name.begin(), name.end());
ImGui::TableSetColumnIndex(2);
ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION);
}
void SaveTool::drawMassManager() {
void
SaveTool::drawMassManager() {
if(!_massManager) {
return;
}
@ -632,7 +586,8 @@ void SaveTool::drawMassManager() {
drawDeleteStagedMassPopup(staged_mass_to_delete);
}
auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
ImGuiID
SaveTool::drawDeleteMassPopup(int mass_index) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{
@ -688,7 +643,8 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
return 0;
}
auto SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID {
ImGuiID
SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{

View file

@ -19,6 +19,7 @@
#include <Magnum/ImGuiIntegration/Integration.h>
#include "../Configuration/Configuration.h"
#include "../FontAwesome/IconsFontAwesome5.h"
#include "../Maps/Accessories.h"
#define STYLENAMES_DEFINITION
@ -26,7 +27,8 @@
#include "SaveTool.h"
void SaveTool::drawMassViewer() {
void
SaveTool::drawMassViewer() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
_currentMass = nullptr;
_currentWeapon = nullptr;
@ -36,7 +38,7 @@ void SaveTool::drawMassViewer() {
}
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);
if(!ImGui::Begin("##MassViewer", nullptr,
ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove|
@ -84,8 +86,8 @@ void SaveTool::drawMassViewer() {
_jointsDirty = false;
_stylesDirty = false;
_eyeFlareDirty = false;
_selectedArmourDecals = Containers::StaticArray<38, Int>{ValueInit};
_selectedArmourAccessories = Containers::StaticArray<38, Int>{ValueInit};
_selectedArmourDecals = Containers::StaticArray<38, std::int32_t>{ValueInit};
_selectedArmourAccessories = Containers::StaticArray<38, std::int32_t>{ValueInit};
_selectedBLPlacement = 0;
_selectedWeaponPart = 0;
_selectedWeaponDecal = 0;
@ -153,7 +155,8 @@ void SaveTool::drawMassViewer() {
ImGui::End();
}
void SaveTool::drawGlobalStyles() {
void
SaveTool::drawGlobalStyles() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
@ -165,7 +168,7 @@ void SaveTool::drawGlobalStyles() {
ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game.");
for(UnsignedInt i = 0; i < _currentMass->globalStyles().size(); i++) {
for(std::uint32_t i = 0; i < _currentMass->globalStyles().size(); i++) {
ImGui::PushID(int(i));
DCSResult result;
result = drawCustomStyle(_currentMass->globalStyles()[i]);
@ -189,7 +192,8 @@ void SaveTool::drawGlobalStyles() {
ImGui::EndChild();
}
void SaveTool::drawTuning() {
void
SaveTool::drawTuning() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
@ -221,7 +225,7 @@ void SaveTool::drawTuning() {
ImGui::TableNextColumn();
ImGui::TextUnformatted("Gears");
for(UnsignedInt i = 0; i < _currentMass->gears().size(); i++) {
for(std::uint32_t i = 0; i < _currentMass->gears().size(); i++) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%i", _currentMass->gears()[i]);
@ -247,7 +251,7 @@ void SaveTool::drawTuning() {
ImGui::TableNextColumn();
ImGui::TextUnformatted("Modules");
for(UnsignedInt i = 0; i < _currentMass->modules().size(); i++) {
for(std::uint32_t i = 0; i < _currentMass->modules().size(); i++) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%i", _currentMass->modules()[i]);
@ -273,7 +277,7 @@ void SaveTool::drawTuning() {
ImGui::TableNextColumn();
ImGui::TextUnformatted("Techs");
for(UnsignedInt i = 0; i < _currentMass->techs().size(); i++) {
for(std::uint32_t i = 0; i < _currentMass->techs().size(); i++) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%i", _currentMass->techs()[i]);
@ -285,7 +289,8 @@ void SaveTool::drawTuning() {
ImGui::EndTable();
}
auto SaveTool::drawCustomStyle(CustomStyle& style) -> DCSResult {
SaveTool::DCSResult
SaveTool::drawCustomStyle(CustomStyle& style) {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return DCS_Fail;
}
@ -390,13 +395,14 @@ auto SaveTool::drawCustomStyle(CustomStyle& style) -> DCSResult {
return return_value;
}
void SaveTool::drawDecalEditor(Decal& decal) {
void
SaveTool::drawDecalEditor(Decal& decal) {
ImGui::Text("ID: %i", decal.id);
if(ImGui::BeginTable("##DecalTable", _advancedMode ? 2 : 1, ImGuiTableFlags_BordersInnerV)) {
if(ImGui::BeginTable("##DecalTable", conf().advancedMode() ? 2 : 1, ImGuiTableFlags_BordersInnerV)) {
ImGui::TableSetupColumn("##Normal", ImGuiTableColumnFlags_WidthStretch);
if(_advancedMode) {
if(conf().advancedMode()) {
ImGui::TableSetupColumn("##Advanced", ImGuiTableColumnFlags_WidthStretch);
}
@ -442,7 +448,7 @@ void SaveTool::drawDecalEditor(Decal& decal) {
ImGui::Checkbox("##Wrap", &decal.wrap);
ImGui::EndGroup();
if(_advancedMode) {
if(conf().advancedMode()) {
ImGui::TableNextColumn();
ImGui::TextColored(ImColor(255, 255, 0), ICON_FA_EXCLAMATION_TRIANGLE);
@ -494,7 +500,8 @@ void SaveTool::drawDecalEditor(Decal& decal) {
}
}
void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view) {
void
SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view) {
if(accessory.id < 1) {
ImGui::TextUnformatted("Accessory: <none>");
}
@ -508,7 +515,7 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::SameLine();
static Int tab = 0;
static std::int32_t tab = 0;
static Containers::Optional<AccessorySize> size = Containers::NullOpt;
if(ImGui::SmallButton("Change")) {
ImGui::OpenPopup("##AccessoryPopup");
@ -532,7 +539,7 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
"L",
"XL"
};
static const Float selectable_width = 90.0f;
static const float selectable_width = 90.0f;
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f});
if(ImGui::Selectable("Primitives", tab == 0, ImGuiSelectableFlags_DontClosePopups, {selectable_width, 0.0f})) {
@ -635,11 +642,11 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::BeginGroup();
drawAlignedText("Styles:");
if(_advancedMode) {
if(conf().advancedMode()) {
drawAlignedText("Base position:");
}
drawAlignedText("Position offset:");
if(_advancedMode) {
if(conf().advancedMode()) {
drawAlignedText("Base rotation:");
}
drawAlignedText("Rotation offset:");
@ -672,7 +679,7 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
}
ImGui::PopItemWidth();
if(_advancedMode) {
if(conf().advancedMode()) {
ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth());
ImGui::DragFloat("##PosX", &accessory.relativePosition.x(), 1.0f, -FLT_MAX, +FLT_MAX, "X: %.3f");
ImGui::PopItemWidth();
@ -696,7 +703,7 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::SameLine();
drawHelpMarker("+/-500.0 = +/-250 in-game");
if(_advancedMode) {
if(conf().advancedMode()) {
ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth());
ImGui::DragFloat("##RotX", &accessory.relativeRotation.x(), 1.0f, -FLT_MAX, +FLT_MAX, "Roll: %.3f");
ImGui::PopItemWidth();
@ -732,7 +739,8 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::EndGroup();
}
auto SaveTool::getStyleName(Int id, Containers::ArrayView<CustomStyle> view) -> Containers::StringView {
Containers::StringView
SaveTool::getStyleName(std::int32_t id, Containers::ArrayView<CustomStyle> view) {
if(id >= 0 && id <= 15) {
return view[id].name;
}

View file

@ -21,7 +21,8 @@
#include "SaveTool.h"
void SaveTool::drawArmour() {
void
SaveTool::drawArmour() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
@ -42,7 +43,7 @@ void SaveTool::drawArmour() {
#undef c
};
for(UnsignedInt i = 0; i < _currentMass->armourParts().size(); i++) {
for(std::uint32_t i = 0; i < _currentMass->armourParts().size(); i++) {
ImGui::PushID(int(i));
auto& part = _currentMass->armourParts()[i];
@ -52,10 +53,10 @@ void SaveTool::drawArmour() {
std::memset(header, '\0', 129);
if(armour_sets.find(part.id) != armour_sets.cend()) {
std::snprintf(header, 128, "%s: %s###%u", slot_labels[UnsignedInt(part.slot)].data(), armour_sets.at(part.id).name.data(), UnsignedInt(part.slot));
std::snprintf(header, 128, "%s: %s###%u", slot_labels[std::uint32_t(part.slot)].data(), armour_sets.at(part.id).name.data(), std::uint32_t(part.slot));
}
else {
std::snprintf(header, 128, "%s: %i###%u", slot_labels[UnsignedInt(part.slot)].data(), part.id, UnsignedInt(part.slot));
std::snprintf(header, 128, "%s: %i###%u", slot_labels[std::uint32_t(part.slot)].data(), part.id, std::uint32_t(part.slot));
}
if(ImGui::CollapsingHeader(header)) {
@ -63,7 +64,7 @@ void SaveTool::drawArmour() {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.491f);
if(ImGui::BeginListBox("##ChangePart")) {
if(std::strncmp("Neck", slot_labels[UnsignedInt(part.slot)].data(), 4) != 0) {
if(std::strncmp("Neck", slot_labels[std::uint32_t(part.slot)].data(), 4) != 0) {
for(auto& set : armour_sets) {
if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) {
part.id = set.first;
@ -96,7 +97,7 @@ void SaveTool::drawArmour() {
ImGui::TextUnformatted("Styles:");
for(Int j = 0; j < 4; j++) {
for(std::int32_t j = 0; j < 4; j++) {
drawAlignedText("Slot %d:", j + 1);
ImGui::SameLine();
@ -124,7 +125,7 @@ void SaveTool::drawArmour() {
ImGui::PushID("Decal");
drawAlignedText("Showing/editing decal");
for(UnsignedInt j = 0; j < part.decals.size(); j++) {
for(std::uint32_t j = 0; j < part.decals.size(); j++) {
ImGui::SameLine();
ImGui::RadioButton(std::to_string(j + 1).c_str(), &_selectedArmourDecals[i], int(j));
}
@ -139,7 +140,7 @@ void SaveTool::drawArmour() {
ImGui::PushID("Accessory");
drawAlignedText("Showing/editing accessory");
for(UnsignedInt j = 0; j < part.accessories.size(); j++) {
for(std::uint32_t j = 0; j < part.accessories.size(); j++) {
ImGui::SameLine();
ImGui::RadioButton(std::string{char(65 + j)}.c_str(), &_selectedArmourAccessories[i], int(j));
}
@ -199,9 +200,9 @@ void SaveTool::drawArmour() {
drawAlignedText("Socket:");
ImGui::SameLine();
if(ImGui::BeginCombo("##Socket", socket_labels[UnsignedInt(placement.socket)].data())) {
for(UnsignedInt i = 0; i < (sizeof(socket_labels) / sizeof(socket_labels[0])); i++) {
if(ImGui::Selectable(socket_labels[i].data(), i == UnsignedInt(placement.socket), ImGuiSelectableFlags_SpanAvailWidth)) {
if(ImGui::BeginCombo("##Socket", socket_labels[std::uint32_t(placement.socket)].data())) {
for(std::uint32_t i = 0; i < (sizeof(socket_labels) / sizeof(socket_labels[0])); i++) {
if(ImGui::Selectable(socket_labels[i].data(), i == std::uint32_t(placement.socket), ImGuiSelectableFlags_SpanAvailWidth)) {
placement.socket = static_cast<BulletLauncherSocket>(i);
}
}
@ -288,7 +289,8 @@ void SaveTool::drawArmour() {
ImGui::EndChild();
}
void SaveTool::drawCustomArmourStyles() {
void
SaveTool::drawCustomArmourStyles() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
@ -300,7 +302,7 @@ void SaveTool::drawCustomArmourStyles() {
ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game.");
for(UnsignedInt i = 0; i < _currentMass->armourCustomStyles().size(); i++) {
for(std::uint32_t i = 0; i < _currentMass->armourCustomStyles().size(); i++) {
ImGui::PushID(int(i));
DCSResult result;
result = drawCustomStyle(_currentMass->armourCustomStyles()[i]);

View file

@ -15,12 +15,12 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "../FontAwesome/IconsFontAwesome5.h"
#include "../Maps/StyleNames.h"
#include "SaveTool.h"
void SaveTool::drawFrameInfo() {
void
SaveTool::drawFrameInfo() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
@ -73,7 +73,8 @@ void SaveTool::drawFrameInfo() {
ImGui::EndChild();
}
void SaveTool::drawJointSliders() {
void
SaveTool::drawJointSliders() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
@ -195,12 +196,13 @@ void SaveTool::drawJointSliders() {
}
}
void SaveTool::drawFrameStyles() {
void
SaveTool::drawFrameStyles() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
for(Int i = 0; i < 4; i++) {
for(std::int32_t i = 0; i < 4; i++) {
drawAlignedText("Slot %d:", i + 1);
ImGui::SameLine();
@ -245,7 +247,8 @@ void SaveTool::drawFrameStyles() {
}
}
void SaveTool::drawEyeColourPicker() {
void
SaveTool::drawEyeColourPicker() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
@ -278,7 +281,8 @@ void SaveTool::drawEyeColourPicker() {
}
}
void SaveTool::drawCustomFrameStyles() {
void
SaveTool::drawCustomFrameStyles() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
@ -290,7 +294,7 @@ void SaveTool::drawCustomFrameStyles() {
ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game.");
for(UnsignedInt i = 0; i < _currentMass->frameCustomStyles().size(); i++) {
for(std::uint32_t i = 0; i < _currentMass->frameCustomStyles().size(); i++) {
ImGui::PushID(int(i));
DCSResult result;
result = drawCustomStyle(_currentMass->frameCustomStyles()[i]);

View file

@ -21,13 +21,14 @@
#include "SaveTool.h"
void SaveTool::drawWeapons() {
void
SaveTool::drawWeapons() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
_currentWeapon = nullptr;
return;
}
const Float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
ImGui::BeginGroup();
@ -254,7 +255,8 @@ void SaveTool::drawWeapons() {
ImGui::EndGroup();
}
void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<Weapon> weapons_view, bool& dirty,
void
SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<Weapon> weapons_view, bool& dirty,
Containers::StringView payload_type, Containers::StringView payload_tooltip)
{
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
@ -263,7 +265,7 @@ void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::Array
ImGui::PushID(payload_type.data());
for(UnsignedInt i = 0; i < weapons_view.size(); i++) {
for(std::uint32_t i = 0; i < weapons_view.size(); i++) {
auto& weapon = weapons_view[i];
ImGui::TableNextRow();
@ -275,7 +277,7 @@ void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::Array
_currentWeapon = &weapon;
}
if(ImGui::BeginDragDropSource()) {
ImGui::SetDragDropPayload(payload_type.data(), &i, sizeof(UnsignedInt));
ImGui::SetDragDropPayload(payload_type.data(), &i, sizeof(std::uint32_t));
if(ImGui::GetIO().KeyCtrl) {
ImGui::Text("%s %i - %s (copy)", payload_tooltip.data(), i + 1, weapon.name.data());
}
@ -317,7 +319,8 @@ void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::Array
ImGui::PopID();
}
void SaveTool::drawWeaponEditor(Weapon& weapon) {
void
SaveTool::drawWeaponEditor(Weapon& weapon) {
if(!_currentMass || _currentMass->state() != Mass::State::Valid || !_currentWeapon) {
return;
}
@ -328,7 +331,7 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
#undef c
};
drawAlignedText("%s: %s", labels[UnsignedInt(weapon.type)].data(), weapon.name.data());
drawAlignedText("%s: %s", labels[std::uint32_t(weapon.type)].data(), weapon.name.data());
ImGui::SameLine();
@ -425,8 +428,8 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
if(ImGui::CollapsingHeader("Weapon parts")) {
drawAlignedText("Viewing/editing part:");
for(Int i = 0; UnsignedLong(i) < weapon.parts.size(); i++) {
if(UnsignedLong(_selectedWeaponPart) >= weapon.parts.size()) {
for(std::int32_t i = 0; std::size_t(i) < weapon.parts.size(); i++) {
if(std::size_t(_selectedWeaponPart) >= weapon.parts.size()) {
_selectedWeaponPart = 0;
}
ImGui::SameLine();
@ -435,7 +438,7 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
auto& part = weapon.parts[_selectedWeaponPart];
const auto* map = [this, &weapon]()-> const std::map<Int, Containers::StringView>* {
const auto* map = [this, &weapon]()-> const std::map<std::int32_t, Containers::StringView>* {
switch(weapon.type) {
case WeaponType::Melee:
return _selectedWeaponPart == 0 ? &melee_grips : &melee_assaulters;
@ -508,7 +511,7 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
if(ImGui::BeginChild("##PartDetails", {0.0f, 0.0f}, true)) {
ImGui::TextUnformatted("Styles:");
for(Int i = 0; i < 4; i++) {
for(std::int32_t i = 0; i < 4; i++) {
drawAlignedText("Slot %d:", i + 1);
ImGui::SameLine();
@ -534,7 +537,7 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::PushID("Decal");
drawAlignedText("Showing/editing decal");
for(UnsignedLong i = 0; i < part.decals.size(); i++) {
for(std::size_t i = 0; i < part.decals.size(); i++) {
ImGui::SameLine();
ImGui::RadioButton(std::to_string(i + 1).c_str(), &_selectedWeaponDecal, int(i));
}
@ -549,7 +552,7 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::PushID("Accessory");
drawAlignedText("Showing/editing accessory");
for(UnsignedLong i = 0; i < part.accessories.size(); i++) {
for(std::size_t i = 0; i < part.accessories.size(); i++) {
ImGui::SameLine();
ImGui::RadioButton(std::string{char(65 + i)}.c_str(), &_selectedWeaponAccessory, int(i));
}

View file

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

View file

@ -24,7 +24,8 @@
#include "SaveTool.h"
void SaveTool::updateCheckEvent(SDL_Event& event) {
void
SaveTool::updateCheckEvent(SDL_Event& event) {
_updateThread.join();
if(event.user.code == CurlInitFailed) {
@ -72,10 +73,10 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
prerelease = true;
}
}
Int fullVersion;
Int major = 0;
Int minor = 0;
Int patch = 0;
std::int32_t fullVersion;
std::int32_t major = 0;
std::int32_t minor = 0;
std::int32_t patch = 0;
bool prerelease = false;
bool operator==(const Version& other) const {
@ -123,13 +124,16 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
}
}
inline auto writeData(char* ptr, std::size_t size, std::size_t nmemb, Containers::String* buf)-> std::size_t {
inline
std::size_t
writeData(char* ptr, std::size_t size, std::size_t nmemb, Containers::String* buf) {
if(!ptr || !buf) return 0;
(*buf) = Utility::format("{}{}", *buf, Containers::StringView{ptr, size * nmemb});
return size * nmemb;
}
void SaveTool::checkForUpdates() {
void
SaveTool::checkForUpdates() {
SDL_Event event;
SDL_zero(event);
event.type = _updateEventId;
@ -157,7 +161,7 @@ void SaveTool::checkForUpdates() {
if(code == CURLE_OK) {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
event.user.code = Int(status);
event.user.code = std::int32_t(status);
event.user.data1 = response_body.release();
}
else if(code == CURLE_OPERATION_TIMEDOUT) {

View file

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

View file

@ -16,13 +16,18 @@
#include <Corrade/Utility/Path.h>
#include "../Configuration/Configuration.h"
#include "../FontAwesome/IconsFontAwesome5.h"
#include "../FontAwesome/IconsFontAwesome5Brands.h"
#include "SaveTool.h"
void SaveTool::drawMainMenu() {
if(ImGui::BeginMainMenuBar()) {
void
SaveTool::drawMainMenu() {
if(!ImGui::BeginMainMenuBar()) {
return;
}
if(ImGui::BeginMenu("Save Tool##SaveToolMenu")) {
if(ImGui::BeginMenu(ICON_FA_FOLDER_OPEN " Open game data directory", Utility::Path::exists(_gameDataDir))) {
if(ImGui::MenuItem(ICON_FA_COG " Configuration", nullptr, false, Utility::Path::exists(_configDir))) {
@ -57,7 +62,7 @@ void SaveTool::drawMainMenu() {
if(ImGui::BeginMenu(ICON_FA_COG " Settings")) {
ImGui::BeginGroup();
drawAlignedText("Vertical sync:");
if(_swapInterval == 0) {
if(conf().swapInterval() == 0) {
drawAlignedText("FPS cap:");
}
ImGui::EndGroup();
@ -75,10 +80,10 @@ void SaveTool::drawMainMenu() {
ImGui::PushItemWidth(300.0f);
if(ImGui::BeginCombo("##FrameLimit", framelimit_labels[_swapInterval])) {
if(ImGui::BeginCombo("##FrameLimit", framelimit_labels[conf().swapInterval()])) {
for(int i = 0; i <= 3; i++) {
if(ImGui::Selectable(framelimit_labels[i], _swapInterval == i)) {
_swapInterval = i;
if(ImGui::Selectable(framelimit_labels[i], conf().swapInterval() == i)) {
conf().setSwapInterval(i);
setSwapInterval(i);
if(i == 0) {
setMinimalLoopPeriod(0);
@ -89,28 +94,38 @@ void SaveTool::drawMainMenu() {
ImGui::EndCombo();
}
if(_swapInterval == 0) {
ImGui::SliderFloat("##FpsCapSlider", &_fpsCap, 15.0f, 301.0f,
_fpsCap != 301.0f ? "%.0f" : "Uncapped", ImGuiSliderFlags_AlwaysClamp);
if(conf().swapInterval() == 0) {
static float fps_cap = conf().fpsCap();
if(ImGui::SliderFloat("##FpsCapSlider", &fps_cap, 15.0f, 301.0f,
conf().fpsCap() != 301.0f ? "%.0f" : "Uncapped", ImGuiSliderFlags_AlwaysClamp))
{
conf().setFpsCap(fps_cap);
}
}
ImGui::PopItemWidth();
ImGui::EndGroup();
ImGui::Checkbox("Cheat mode", &_cheatMode);
if(drawCheckbox("Cheat mode", conf().cheatMode())) {
conf().setCheatMode(!conf().cheatMode());
}
ImGui::SameLine();
ImGui::AlignTextToFramePadding();
drawHelpMarker("This gives access to save edition features that can be considered cheats.",
Float(windowSize().x()) * 0.4f);
float(windowSize().x()) * 0.4f);
ImGui::Checkbox("Advanced mode", &_advancedMode);
if(drawCheckbox("Advanced mode", conf().advancedMode())) {
conf().setAdvancedMode(!conf().advancedMode());
}
ImGui::SameLine();
ImGui::AlignTextToFramePadding();
drawHelpMarker("This gives access to editing values that have unknown purposes or are undocumented.",
Float(windowSize().x()) * 0.4f);
float(windowSize().x()) * 0.4f);
ImGui::Checkbox("Check for updates on startup", &_checkUpdatesOnStartup);
if(drawCheckbox("Check for updates on startup", conf().checkUpdatesOnStartup())) {
conf().setCheckUpdatesOnStartup(!conf().checkUpdatesOnStartup());
}
ImGui::SameLine();
if(ImGui::Button(ICON_FA_SYNC_ALT " Check now")) {
_queue.addToast(Toast::Type::Default, "Checking for updates...");
@ -128,7 +143,9 @@ void SaveTool::drawMainMenu() {
}
}
ImGui::Checkbox("Skip disclaimer", &_skipDisclaimer);
if(drawCheckbox("Skip disclaimer", conf().skipDisclaimer())) {
conf().setSkipDisclaimer(!conf().skipDisclaimer());
}
ImGui::EndMenu();
}
@ -213,5 +230,4 @@ void SaveTool::drawMainMenu() {
}
ImGui::EndMainMenuBar();
}
}

View file

@ -26,20 +26,23 @@
using namespace Containers::Literals;
constexpr UnsignedInt success_colour = 0xff67d23bu;
constexpr UnsignedInt info_colour = 0xffcc832fu;
constexpr UnsignedInt warning_colour = 0xff2fcfc7u;
constexpr UnsignedInt error_colour = 0xff3134cdu;
constexpr std::uint32_t success_colour = 0xff67d23bu;
constexpr std::uint32_t info_colour = 0xffcc832fu;
constexpr std::uint32_t warning_colour = 0xff2fcfc7u;
constexpr std::uint32_t error_colour = 0xff3134cdu;
constexpr UnsignedInt fade_time = 150;
constexpr Float base_opacity = 1.0f;
constexpr std::uint32_t fade_time = 150;
constexpr float base_opacity = 1.0f;
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):
_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<std::uint32_t, Phase>{{
{0, Phase::FadeIn},
{fade_time, Phase::Wait},
{fade_time + timeout.count(), Phase::FadeOut},
@ -47,56 +50,66 @@ Toast::Toast(Type type, Containers::StringView message, std::chrono::millisecond
}, Math::select, Animation::Extrapolation::Constant};
}
auto Toast::type() -> Type {
Toast::Type
Toast::type() {
return _type;
}
auto Toast::message() -> Containers::StringView {
Containers::StringView
Toast::message() {
return _message;
}
auto Toast::timeout() -> std::chrono::milliseconds {
std::chrono::milliseconds
Toast::timeout() {
return _timeout;
}
auto Toast::creationTime() -> std::chrono::steady_clock::time_point {
std::chrono::steady_clock::time_point
Toast::creationTime() {
return _creationTime;
}
auto Toast::elapsedTime() -> std::chrono::milliseconds {
std::chrono::milliseconds
Toast::elapsedTime() {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - _creationTime);
}
auto Toast::phase() -> Phase {
Toast::Phase
Toast::phase() {
return _phaseTrack.at(elapsedTime().count());
}
auto Toast::opacity() -> Float {
float
Toast::opacity() {
Phase phase = this->phase();
Long elapsed_time = elapsedTime().count();
std::int64_t elapsed_time = elapsedTime().count();
if(phase == Phase::FadeIn) {
return Float(elapsed_time) / Float(fade_time);
return float(elapsed_time) / float(fade_time);
}
else if(phase == Phase::FadeOut) {
return 1.0f - ((Float(elapsed_time) - Float(fade_time) - Float(_timeout.count())) / Float(fade_time));
return 1.0f - ((float(elapsed_time) - float(fade_time) - float(_timeout.count())) / float(fade_time));
}
return 1.0f;
}
void ToastQueue::addToast(Toast&& toast) {
void
ToastQueue::addToast(Toast&& toast) {
_toasts.push_back(std::move(toast));
}
void ToastQueue::addToast(Toast::Type type, Containers::StringView message, std::chrono::milliseconds timeout) {
void
ToastQueue::addToast(Toast::Type type, Containers::StringView message, std::chrono::milliseconds timeout) {
_toasts.emplace_back(type, message, timeout);
}
void ToastQueue::draw(Vector2i viewport_size) {
Float height = 0.0f;
void
ToastQueue::draw(Vector2i viewport_size) {
float height = 0.0f;
for(UnsignedInt i = 0; i < _toasts.size(); i++) {
for(std::uint32_t i = 0; i < _toasts.size(); i++) {
Toast* current = &_toasts[i];
if(current->phase() == Toast::Phase::TimedOut) {
@ -106,11 +119,12 @@ void ToastQueue::draw(Vector2i viewport_size) {
Containers::String win_id = Utility::format("##Toast{}", i);
Float opacity = base_opacity * current->opacity();
float opacity = base_opacity * current->opacity();
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, opacity);
ImGui::SetNextWindowPos({viewport_size.x() - padding.x(), viewport_size.y() - padding.y() - height}, ImGuiCond_Always, {1.0f, 1.0f});
ImGui::SetNextWindowPos({float(viewport_size.x()) - padding.x(), float(viewport_size.y()) - padding.y() - height},
ImGuiCond_Always, {1.0f, 1.0f});
if(ImGui::Begin(win_id.data(), nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoDecoration|
ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoNav|ImGuiWindowFlags_NoFocusOnAppearing))
@ -154,6 +168,7 @@ void ToastQueue::draw(Vector2i viewport_size) {
}
}
void ToastQueue::removeToast(Long index) {
void
ToastQueue::removeToast(std::int64_t index) {
_toasts.erase(_toasts.begin() + index);
}

View file

@ -29,11 +29,11 @@ using namespace Magnum;
class Toast {
public:
enum class Type : UnsignedByte {
enum class Type: std::uint8_t {
Default, Success, Info, Warning, Error
};
enum class Phase : UnsignedByte {
enum class Phase: std::uint8_t {
FadeIn, Wait, FadeOut, TimedOut
};
@ -46,26 +46,26 @@ class Toast {
Toast(Toast&& other) = default;
Toast& operator=(Toast&& other) = default;
auto type() -> Type;
Type type();
auto message() -> Containers::StringView;
Containers::StringView message();
auto timeout() -> std::chrono::milliseconds;
std::chrono::milliseconds timeout();
auto creationTime() -> std::chrono::steady_clock::time_point;
std::chrono::steady_clock::time_point creationTime();
auto elapsedTime() -> std::chrono::milliseconds;
std::chrono::milliseconds elapsedTime();
auto phase() -> Phase;
Phase phase();
auto opacity() -> Float;
float opacity();
private:
Type _type{Type::Default};
Containers::String _message;
std::chrono::milliseconds _timeout;
std::chrono::steady_clock::time_point _creationTime;
Animation::Track<UnsignedInt, Phase> _phaseTrack;
Animation::Track<std::uint32_t, Phase> _phaseTrack;
};
class ToastQueue {
@ -78,7 +78,7 @@ class ToastQueue {
void draw(Vector2i viewport_size);
private:
void removeToast(Long index);
void removeToast(std::int64_t index);
std::vector<Toast> _toasts;
};

View file

@ -35,72 +35,89 @@ BinaryReader::~BinaryReader() {
closeFile();
}
auto BinaryReader::open() -> bool {
bool
BinaryReader::open() {
return _file;
}
auto BinaryReader::eof() -> bool {
bool
BinaryReader::eof() {
return std::feof(_file) != 0;
}
auto BinaryReader::position() -> Long {
std::int64_t
BinaryReader::position() {
return _ftelli64(_file);
}
auto BinaryReader::seek(Long position) -> bool {
bool
BinaryReader::seek(std::int64_t position) {
return _fseeki64(_file, position, SEEK_SET) == 0;
}
void BinaryReader::closeFile() {
void
BinaryReader::closeFile() {
std::fclose(_file);
_file = nullptr;
}
auto BinaryReader::readChar(char& value) -> bool {
bool
BinaryReader::readChar(char& value) {
return std::fread(&value, sizeof(char), 1, _file) == 1;
}
auto BinaryReader::readByte(Byte& value) -> bool {
return std::fread(&value, sizeof(Byte), 1, _file) == 1;
bool
BinaryReader::readInt8(std::int8_t& value) {
return std::fread(&value, sizeof(std::int8_t), 1, _file) == 1;
}
auto BinaryReader::readUnsignedByte(UnsignedByte& value) -> bool {
return std::fread(&value, sizeof(UnsignedByte), 1, _file) == 1;
bool
BinaryReader::readUint8(std::uint8_t& value) {
return std::fread(&value, sizeof(std::uint8_t), 1, _file) == 1;
}
auto BinaryReader::readShort(Short& value) -> bool {
return std::fread(&value, sizeof(Short), 1, _file) == 1;
bool
BinaryReader::readInt16(std::int16_t& value) {
return std::fread(&value, sizeof(std::int16_t), 1, _file) == 1;
}
auto BinaryReader::readUnsignedShort(UnsignedShort& value) -> bool {
return std::fread(&value, sizeof(UnsignedShort), 1, _file) == 1;
bool
BinaryReader::readUint16(std::uint16_t& value) {
return std::fread(&value, sizeof(std::uint16_t), 1, _file) == 1;
}
auto BinaryReader::readInt(Int& value) -> bool {
return std::fread(&value, sizeof(Int), 1, _file) == 1;
bool
BinaryReader::readInt32(std::int32_t& value) {
return std::fread(&value, sizeof(std::int32_t), 1, _file) == 1;
}
auto BinaryReader::readUnsignedInt(UnsignedInt& value) -> bool {
return std::fread(&value, sizeof(UnsignedInt), 1, _file) == 1;
bool
BinaryReader::readUint32(std::uint32_t& value) {
return std::fread(&value, sizeof(std::uint32_t), 1, _file) == 1;
}
auto BinaryReader::readLong(Long& value) -> bool {
return std::fread(&value, sizeof(Long), 1, _file) == 1;
bool
BinaryReader::readInt64(std::int64_t& value) {
return std::fread(&value, sizeof(std::int64_t), 1, _file) == 1;
}
auto BinaryReader::readUnsignedLong(UnsignedLong& value) -> bool {
return std::fread(&value, sizeof(UnsignedLong), 1, _file) == 1;
bool
BinaryReader::readUint64(std::uint64_t& value) {
return std::fread(&value, sizeof(std::uint64_t), 1, _file) == 1;
}
auto BinaryReader::readFloat(Float& value) -> bool {
return std::fread(&value, sizeof(Float), 1, _file) == 1;
bool
BinaryReader::readFloat(float& value) {
return std::fread(&value, sizeof(float), 1, _file) == 1;
}
auto BinaryReader::readDouble(Double& value) -> bool {
return std::fread(&value, sizeof(Double), 1, _file) == 1;
bool
BinaryReader::readDouble(double& value) {
return std::fread(&value, sizeof(double), 1, _file) == 1;
}
auto BinaryReader::readArray(Containers::Array<char>& array, std::size_t count) -> bool {
bool
BinaryReader::readArray(Containers::Array<char>& array, std::size_t count) {
if(array.size() < count) {
array = Containers::Array<char>{ValueInit, count};
}
@ -108,9 +125,10 @@ auto BinaryReader::readArray(Containers::Array<char>& array, std::size_t count)
return std::fread(array.data(), sizeof(char), count, _file) == count;
}
auto BinaryReader::readUEString(Containers::String& str) -> bool {
UnsignedInt length = 0;
if(!readUnsignedInt(length) || length == 0) {
bool
BinaryReader::readUEString(Containers::String& str) {
std::uint32_t length = 0;
if(!readUint32(length) || length == 0) {
return false;
}
@ -119,8 +137,9 @@ auto BinaryReader::readUEString(Containers::String& str) -> bool {
return std::fread(str.data(), sizeof(char), length, _file) == length;
}
auto BinaryReader::peekChar() -> Int {
Int c;
std::int32_t
BinaryReader::peekChar() {
std::int32_t c;
c = std::fgetc(_file);
std::ungetc(c, _file);
return c;

View file

@ -16,56 +16,54 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <cstdio>
#include <Corrade/Containers/Containers.h>
#include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade;
using namespace Magnum;
class BinaryReader {
public:
explicit BinaryReader(Containers::StringView filename);
~BinaryReader();
auto open() -> bool;
auto eof() -> bool;
auto position() -> Long;
bool open();
bool eof();
std::int64_t position();
auto seek(Long position) -> bool;
bool seek(std::int64_t position);
void closeFile();
auto readChar(char& value) -> bool;
auto readByte(Byte& value) -> bool;
auto readUnsignedByte(UnsignedByte& value) -> bool;
auto readShort(Short& value) -> bool;
auto readUnsignedShort(UnsignedShort& value) -> bool;
auto readInt(Int& value) -> bool;
auto readUnsignedInt(UnsignedInt& value) -> bool;
auto readLong(Long& value) -> bool;
auto readUnsignedLong(UnsignedLong& value) -> bool;
auto readFloat(Float& value) -> bool;
auto readDouble(Double& value) -> bool;
auto readArray(Containers::Array<char>& array, std::size_t count) -> bool;
bool readChar(char& value);
bool readInt8(std::int8_t& value);
bool readUint8(std::uint8_t& value);
bool readInt16(std::int16_t& value);
bool readUint16(std::uint16_t& value);
bool readInt32(std::int32_t& value);
bool readUint32(std::uint32_t& value);
bool readInt64(std::int64_t& value);
bool readUint64(std::uint64_t& value);
bool readFloat(float& value);
bool readDouble(double& value);
bool readArray(Containers::Array<char>& array, std::size_t count);
template<typename T>
auto readValue(T& value) -> bool {
bool readValue(T& value) {
return fread(&value, sizeof(T), 1, _file) == sizeof(T);
}
template<std::size_t S>
auto readStaticArray(Containers::StaticArray<S, char>& array) -> bool {
bool readStaticArray(Containers::StaticArray<S, char>& array) {
return std::fread(array.data(), sizeof(char), S, _file) == S;
}
auto readUEString(Containers::String& str) -> bool;
bool readUEString(Containers::String& str);
auto peekChar() -> Int;
std::int32_t peekChar();
private:
std::FILE* _file = nullptr;

View file

@ -33,29 +33,35 @@ BinaryWriter::~BinaryWriter() {
closeFile();
}
auto BinaryWriter::open() -> bool {
bool
BinaryWriter::open() {
return _file;
}
void BinaryWriter::closeFile() {
void
BinaryWriter::closeFile() {
std::fflush(_file);
std::fclose(_file);
_file = nullptr;
}
auto BinaryWriter::position() -> Long {
std::int64_t
BinaryWriter::position() {
return _ftelli64(_file);
}
auto BinaryWriter::array() const -> Containers::ArrayView<const char> {
Containers::ArrayView<const char>
BinaryWriter::array() const {
return _data;
}
auto BinaryWriter::arrayPosition() const -> UnsignedLong {
std::size_t
BinaryWriter::arrayPosition() const {
return _index;
}
auto BinaryWriter::flushToFile() -> bool {
bool
BinaryWriter::flushToFile() {
bool ret = writeArray(_data);
std::fflush(_file);
_data = Containers::Array<char>{};
@ -63,51 +69,63 @@ auto BinaryWriter::flushToFile() -> bool {
return ret;
}
auto BinaryWriter::writeChar(char value) -> bool {
bool
BinaryWriter::writeChar(char value) {
return std::fwrite(&value, sizeof(char), 1, _file) == 1;
}
auto BinaryWriter::writeByte(Byte value) -> bool {
return std::fwrite(&value, sizeof(Byte), 1, _file) == 1;
bool
BinaryWriter::writeInt8(std::int8_t value) {
return std::fwrite(&value, sizeof(std::int8_t), 1, _file) == 1;
}
auto BinaryWriter::writeUnsignedByte(UnsignedByte value) -> bool {
return std::fwrite(&value, sizeof(UnsignedByte), 1, _file) == 1;
bool
BinaryWriter::writeUint8(std::uint8_t value) {
return std::fwrite(&value, sizeof(std::uint8_t), 1, _file) == 1;
}
auto BinaryWriter::writeShort(Short value) -> bool {
return std::fwrite(&value, sizeof(Short), 1, _file) == 1;
bool
BinaryWriter::writeInt16(std::int16_t value) {
return std::fwrite(&value, sizeof(std::int16_t), 1, _file) == 1;
}
auto BinaryWriter::writeUnsignedShort(UnsignedShort value) -> bool {
return std::fwrite(&value, sizeof(UnsignedShort), 1, _file) == 1;
bool
BinaryWriter::writeUint16(std::uint16_t value) {
return std::fwrite(&value, sizeof(std::uint16_t), 1, _file) == 1;
}
auto BinaryWriter::writeInt(Int value) -> bool {
return std::fwrite(&value, sizeof(Int), 1, _file) == 1;
bool
BinaryWriter::writeInt32(std::int32_t value) {
return std::fwrite(&value, sizeof(std::int32_t), 1, _file) == 1;
}
auto BinaryWriter::writeUnsignedInt(UnsignedInt value) -> bool {
return std::fwrite(&value, sizeof(UnsignedInt), 1, _file) == 1;
bool
BinaryWriter::writeUint32(std::uint32_t value) {
return std::fwrite(&value, sizeof(std::uint32_t), 1, _file) == 1;
}
auto BinaryWriter::writeLong(Long value) -> bool {
return std::fwrite(&value, sizeof(Long), 1, _file) == 1;
bool
BinaryWriter::writeInt64(std::int64_t value) {
return std::fwrite(&value, sizeof(std::int64_t), 1, _file) == 1;
}
auto BinaryWriter::writeUnsignedLong(UnsignedLong value) -> bool {
return std::fwrite(&value, sizeof(UnsignedLong), 1, _file) == 1;
bool
BinaryWriter::writeUint64(std::uint64_t value) {
return std::fwrite(&value, sizeof(std::uint64_t), 1, _file) == 1;
}
auto BinaryWriter::writeFloat(Float value) -> bool {
return std::fwrite(&value, sizeof(Float), 1, _file) == 1;
bool
BinaryWriter::writeFloat(float value) {
return std::fwrite(&value, sizeof(float), 1, _file) == 1;
}
auto BinaryWriter::writeDouble(Double value) -> bool {
return std::fwrite(&value, sizeof(Double), 1, _file) == 1;
bool
BinaryWriter::writeDouble(double value) {
return std::fwrite(&value, sizeof(double), 1, _file) == 1;
}
auto BinaryWriter::writeArray(Containers::ArrayView<const char> array) -> bool {
bool
BinaryWriter::writeArray(Containers::ArrayView<const char> array) {
if(array.size() == 0) {
return false;
}
@ -115,13 +133,14 @@ auto BinaryWriter::writeArray(Containers::ArrayView<const char> array) -> bool {
return std::fwrite(array.data(), sizeof(char), array.size(), _file) == array.size();
}
auto BinaryWriter::writeUEString(Containers::StringView str) -> bool {
bool
BinaryWriter::writeUEString(Containers::StringView str) {
if(str.size() > UINT32_MAX) {
LOG_ERROR_FORMAT("String is too big. Expected size() < UINT32_MAX, got {} instead.", str.size());
return false;
}
writeUnsignedInt(static_cast<UnsignedInt>(str.size()) + 1);
writeUint32(static_cast<std::uint32_t>(str.size()) + 1);
if(str.size() > 0) {
std::size_t count = std::fwrite(str.data(), sizeof(char), str.size(), _file);
@ -132,8 +151,9 @@ auto BinaryWriter::writeUEString(Containers::StringView str) -> bool {
return writeChar('\0');
}
auto BinaryWriter::writeUEStringToArray(Containers::StringView value) -> UnsignedLong {
return writeValueToArray<UnsignedInt>(UnsignedInt(value.size()) + 1u) +
std::size_t
BinaryWriter::writeUEStringToArray(Containers::StringView value) {
return writeValueToArray<std::uint32_t>(std::uint32_t(value.size()) + 1u) +
writeDataToArray(Containers::ArrayView<const char>{value}) +
writeValueToArray<char>('\0');
}

View file

@ -16,6 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <cstdio>
#include <Corrade/Containers/ArrayView.h>
@ -23,10 +24,7 @@
#include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade;
using namespace Magnum;
class BinaryWriter {
public:
@ -39,65 +37,65 @@ class BinaryWriter {
BinaryWriter(BinaryWriter&& other) = default;
BinaryWriter& operator=(BinaryWriter&& other) = default;
auto open() -> bool;
bool open();
void closeFile();
auto position() -> Long;
std::int64_t position();
auto array() const -> Containers::ArrayView<const char>;
auto arrayPosition() const -> UnsignedLong;
auto flushToFile() -> bool;
Containers::ArrayView<const char> array() const;
std::size_t arrayPosition() const;
bool flushToFile();
auto writeByte(Byte value) -> bool;
auto writeChar(char value) -> bool;
auto writeUnsignedByte(UnsignedByte value) -> bool;
auto writeShort(Short value) -> bool;
auto writeUnsignedShort(UnsignedShort value) -> bool;
auto writeInt(Int value) -> bool;
auto writeUnsignedInt(UnsignedInt value) -> bool;
auto writeLong(Long value) -> bool;
auto writeUnsignedLong(UnsignedLong value) -> bool;
auto writeFloat(Float value) -> bool;
auto writeDouble(Double value) -> bool;
auto writeArray(Containers::ArrayView<const char> array) -> bool;
bool writeChar(char value);
bool writeInt8(std::int8_t value);
bool writeUint8(std::uint8_t value);
bool writeInt16(std::int16_t value);
bool writeUint16(std::uint16_t value);
bool writeInt32(std::int32_t value);
bool writeUint32(std::uint32_t value);
bool writeInt64(std::int64_t value);
bool writeUint64(std::uint64_t value);
bool writeFloat(float value);
bool writeDouble(double value);
bool writeArray(Containers::ArrayView<const char> array);
template<std::size_t size>
auto writeString(const char(&str)[size]) -> bool {
bool writeString(const char(&str)[size]) {
return writeArray({str, size - 1});
}
template<std::size_t S>
auto writeStaticArray(Containers::StaticArrayView<S, const char> array) -> bool {
bool writeStaticArray(Containers::StaticArrayView<S, const char> array) {
return std::fwrite(array.data(), sizeof(char), S, _file) == S;
}
auto writeUEString(Containers::StringView str) -> bool;
bool writeUEString(Containers::StringView str);
template<typename T, typename U = std::conditional_t<std::is_trivially_copyable<T>::value, T, T&>>
auto writeValueToArray(U value) -> UnsignedLong {
std::size_t writeValueToArray(U value) {
Containers::ArrayView<T> view{&value, 1};
return writeDataToArray(view);
}
auto writeUEStringToArray(Containers::StringView value) -> UnsignedLong;
std::size_t writeUEStringToArray(Containers::StringView value);
template<typename T>
void writeValueToArrayAt(T& value, UnsignedLong position) {
void writeValueToArrayAt(T& value, std::size_t position) {
Containers::ArrayView<T> view{&value, 1};
writeDataToArrayAt(view, position);
}
template<typename T>
auto writeDataToArray(Containers::ArrayView<T> view) -> UnsignedLong {
std::size_t writeDataToArray(Containers::ArrayView<T> view) {
arrayAppend(_data, Containers::arrayCast<const char>(view));
_index += sizeof(T) * view.size();
return sizeof(T) * view.size();
}
template<typename T>
void writeDataToArrayAt(Containers::ArrayView<T> view, UnsignedLong position) {
void writeDataToArrayAt(Containers::ArrayView<T> view, std::size_t position) {
auto casted_view = Containers::arrayCast<const char>(view);
for(UnsignedLong i = 0; i < casted_view.size(); i++) {
for(std::size_t i = 0; i < casted_view.size(); i++) {
_data[position + i] = casted_view[i];
}
}
@ -106,5 +104,5 @@ class BinaryWriter {
FILE* _file = nullptr;
Containers::Array<char> _data;
UnsignedLong _index = 0;
std::size_t _index = 0;
};

View file

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

View file

@ -67,12 +67,14 @@ PropertySerialiser::PropertySerialiser() {
arrayAppend(_collectionSerialisers, Containers::pointer<StructSerialiser>());
}
auto PropertySerialiser::instance() -> PropertySerialiser& {
PropertySerialiser&
PropertySerialiser::instance() {
static PropertySerialiser serialiser;
return serialiser;
}
auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr {
UnrealPropertyBase::ptr
PropertySerialiser::read(BinaryReader& reader) {
if(reader.peekChar() < 0 || reader.eof()) {
return nullptr;
}
@ -91,16 +93,18 @@ auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr {
return nullptr;
}
UnsignedLong value_length;
if(!reader.readUnsignedLong(value_length)) {
std::size_t value_length;
if(!reader.readUint64(value_length)) {
return nullptr;
}
return deserialise(std::move(name), std::move(type), value_length, reader);
}
auto PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length,
Containers::String name) -> UnrealPropertyBase::ptr {
UnrealPropertyBase::ptr
PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, std::size_t value_length,
Containers::String name)
{
if(reader.peekChar() < 0 || reader.eof()) {
return nullptr;
}
@ -108,9 +112,8 @@ auto PropertySerialiser::readItem(BinaryReader& reader, Containers::String type,
return deserialise(std::move(name), std::move(type), value_length, reader);
}
auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type,
UnsignedInt count) -> Containers::Array<UnrealPropertyBase::ptr>
{
Containers::Array<UnrealPropertyBase::ptr>
PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, std::uint32_t count) {
if(reader.peekChar() < 0 || reader.eof()) {
return nullptr;
}
@ -130,8 +133,8 @@ auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView it
return nullptr;
}
UnsignedLong value_length;
if(!reader.readUnsignedLong(value_length)) {
std::size_t value_length;
if(!reader.readUint64(value_length)) {
return nullptr;
}
@ -144,8 +147,8 @@ auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView it
}
}
else {
for(UnsignedInt i = 0; i < count; i++) {
auto item = readItem(reader, item_type, UnsignedLong(-1), "");
for(std::uint32_t i = 0; i < count; i++) {
auto item = readItem(reader, item_type, std::size_t(-1), "");
arrayAppend(array, std::move(item));
}
}
@ -153,8 +156,9 @@ auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView it
return array;
}
auto PropertySerialiser::deserialise(Containers::String name, Containers::String type, UnsignedLong value_length,
BinaryReader& reader) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
PropertySerialiser::deserialise(Containers::String name, Containers::String type, std::size_t value_length,
BinaryReader& reader)
{
UnrealPropertyBase::ptr prop;
auto serialiser = getSerialiser(type);
@ -176,8 +180,8 @@ auto PropertySerialiser::deserialise(Containers::String name, Containers::String
return prop;
}
auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool
bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
std::size_t& bytes_written, BinaryWriter& writer)
{
auto serialiser = getSerialiser(item_type);
if(!serialiser) {
@ -186,7 +190,8 @@ auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St
return serialiser->serialise(prop, bytes_written, writer, *this);
}
auto PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool {
bool
PropertySerialiser::write(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer) {
if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) {
bytes_written += writer.writeUEStringToArray(*prop->name);
return true;
@ -195,10 +200,10 @@ auto PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& byte
bytes_written += writer.writeUEStringToArray(*prop->name);
bytes_written += writer.writeUEStringToArray(prop->propertyType);
UnsignedLong value_length = 0;
UnsignedLong vl_position = writer.arrayPosition();
std::size_t value_length = 0;
std::size_t vl_position = writer.arrayPosition();
bytes_written += writer.writeValueToArray<UnsignedLong>(value_length);
bytes_written += writer.writeValueToArray<std::size_t>(value_length);
bool ret = serialise(prop, prop->propertyType, value_length, writer);
@ -209,8 +214,9 @@ auto PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& byte
return ret;
}
auto PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool
bool
PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
std::size_t& bytes_written, BinaryWriter& writer)
{
if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) {
bytes_written += writer.writeUEStringToArray(*prop->name);
@ -220,9 +226,8 @@ auto PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::St
return serialise(prop, item_type, bytes_written, writer);
}
auto PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props,
Containers::StringView item_type, UnsignedLong& bytes_written,
BinaryWriter& writer) -> bool
bool PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props,
Containers::StringView item_type, std::size_t& bytes_written, BinaryWriter& writer)
{
auto serialiser = getCollectionSerialiser(item_type);
if(serialiser) {
@ -239,7 +244,8 @@ auto PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr>
}
}
auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser* {
AbstractUnrealPropertySerialiser*
PropertySerialiser::getSerialiser(Containers::StringView item_type) {
for(auto& item : _serialisers) {
for(auto serialiser_type : item->types()) {
if(item_type == serialiser_type) {
@ -251,7 +257,8 @@ auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> Abst
return nullptr;
}
auto PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) -> AbstractUnrealCollectionPropertySerialiser* {
AbstractUnrealCollectionPropertySerialiser*
PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) {
for(auto& item : _collectionSerialisers) {
for(Containers::StringView serialiser_type : item->types()) {
if(item_type == serialiser_type) {

View file

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

View file

@ -21,29 +21,29 @@
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "../Types/UnrealPropertyBase.h"
using namespace Corrade;
using namespace Magnum;
class BinaryReader;
class BinaryWriter;
class PropertySerialiser;
using PropertyArray = Containers::Array<UnrealPropertyBase::ptr>;
using PropertyArrayView = Containers::ArrayView<UnrealPropertyBase::ptr>;
class AbstractUnrealCollectionPropertySerialiser {
public:
using ptr = Containers::Pointer<AbstractUnrealCollectionPropertySerialiser>;
virtual ~AbstractUnrealCollectionPropertySerialiser() = default;
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
virtual StringArrayView types() = 0;
virtual auto deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, UnsignedInt count, BinaryReader& reader,
PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> = 0;
virtual PropertyArray deserialise(Containers::StringView name, Containers::StringView type,
std::size_t value_length, std::uint32_t count, BinaryReader& reader,
PropertySerialiser& serialiser) = 0;
virtual auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0;
virtual bool serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) = 0;
};

View file

@ -20,28 +20,28 @@
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "../Types/UnrealPropertyBase.h"
using namespace Corrade;
using namespace Magnum;
class BinaryReader;
class BinaryWriter;
class PropertySerialiser;
using StringArrayView = Containers::ArrayView<const Containers::String>;
class AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<AbstractUnrealPropertySerialiser>;
virtual ~AbstractUnrealPropertySerialiser() = default;
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
virtual StringArrayView types() = 0;
virtual auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr = 0;
virtual UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) = 0;
virtual auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool = 0;
virtual bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) = 0;
};

View file

@ -21,12 +21,9 @@
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "../Types/UnrealPropertyBase.h"
using namespace Corrade;
using namespace Magnum;
class BinaryReader;
class BinaryWriter;
@ -37,10 +34,9 @@ class AbstractUnrealStructSerialiser {
virtual ~AbstractUnrealStructSerialiser() = default;
virtual auto supportsType(Containers::StringView type) -> bool = 0;
virtual bool supportsType(Containers::StringView type) = 0;
virtual auto deserialise(BinaryReader& reader) -> UnrealPropertyBase::ptr = 0;
virtual UnrealPropertyBase::ptr deserialise(BinaryReader& reader) = 0;
virtual auto serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer,
UnsignedLong& bytes_written) -> bool = 0;
virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, std::size_t& bytes_written) = 0;
};

View file

@ -23,9 +23,10 @@
#include "ArrayPropertySerialiser.h"
auto ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
Containers::String item_type;
if(!reader.readUEString(item_type)) {
@ -39,8 +40,8 @@ auto ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, C
return nullptr;
}
UnsignedInt item_count;
if(!reader.readUnsignedInt(item_count)) {
std::uint32_t item_count;
if(!reader.readUint32(item_count)) {
LOG_ERROR_FORMAT("Couldn't read array property {}'s item count.", name);
return nullptr;
}
@ -52,8 +53,9 @@ auto ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, C
return prop;
}
auto ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto array_prop = dynamic_cast<ArrayProperty*>(prop.get());
if(!array_prop) {
@ -63,10 +65,10 @@ auto ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, U
writer.writeUEStringToArray(array_prop->itemType);
writer.writeValueToArray<char>('\0');
bytes_written += writer.writeValueToArray<UnsignedInt>(UnsignedInt(array_prop->items.size()));
bytes_written += writer.writeValueToArray<std::uint32_t>(std::uint32_t(array_prop->items.size()));
UnsignedLong start_pos = writer.arrayPosition();
UnsignedLong dummy_bytes_written = 0;
std::size_t start_pos = writer.arrayPosition();
std::size_t dummy_bytes_written = 0;
bool ret = serialiser.writeSet(array_prop->items, array_prop->itemType, dummy_bytes_written, writer);
bytes_written += writer.arrayPosition() - start_pos;

View file

@ -18,22 +18,20 @@
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "UnrealPropertySerialiser.h"
#include "../Types/ArrayProperty.h"
using namespace Corrade;
using namespace Magnum;
class ArrayPropertySerialiser : public UnrealPropertySerialiser<ArrayProperty> {
public:
using ptr = Containers::Pointer<ArrayPropertySerialiser>;
private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};

View file

@ -20,23 +20,24 @@
#include "BoolPropertySerialiser.h"
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
StringArrayView
BoolPropertySerialiser::types() {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"BoolProperty"_s}};
return types;
}
auto BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
BinaryReader& reader, PropertySerialiser& serialiser)
{
if(value_length != 0) {
LOG_ERROR_FORMAT("Invalid value length for bool property {}. Expected 0, got {} instead.", name, value_length);
return nullptr;
}
Short value;
if(!reader.readShort(value)) {
std::int16_t value;
if(!reader.readInt16(value)) {
LOG_ERROR_FORMAT("Couldn't read bool property {}'s value.", name);
return nullptr;
}
@ -52,8 +53,9 @@ auto BoolPropertySerialiser::deserialise(Containers::StringView name, Containers
return prop;
}
auto BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{
auto bool_prop = dynamic_cast<BoolProperty*>(prop.get());
if(!bool_prop) {
@ -61,7 +63,7 @@ auto BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLo
return false;
}
writer.writeValueToArray<Short>(Short(bool_prop->value));
writer.writeValueToArray<std::int16_t>(std::int16_t(bool_prop->value));
return true;
}

View file

@ -29,11 +29,12 @@ class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<BoolPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
StringArrayView types() override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};

View file

@ -20,19 +20,20 @@
#include "BytePropertySerialiser.h"
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
StringArrayView
BytePropertySerialiser::types() {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"ByteProperty"_s}};
return types;
}
auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
BinaryReader& reader, PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<ByteProperty>();
if(value_length != UnsignedLong(-1)) {
if(value_length != std::size_t(-1)) {
if(!reader.readUEString(prop->enumType)) {
LOG_ERROR_FORMAT("Couldn't read byte property {}'s enum type.", name);
return nullptr;
@ -52,8 +53,8 @@ auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers
prop->valueLength = value_length;
//UnsignedInt count = 0;
//if(!reader.readUnsignedInt(count)) {
//std::uint32_t count = 0;
//if(!reader.readstd::uint32_t(count)) {
// return nullptr;
//}
@ -64,8 +65,9 @@ auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers
return prop;
}
auto BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{
auto byte_prop = dynamic_cast<ByteProperty*>(prop.get());
if(!byte_prop) {
@ -74,10 +76,10 @@ auto BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLo
}
//writer.writeValueToArray<char>('\0');
//bytes_written += writer.writeValueToArray<UnsignedInt>(byte_prop->value.size());
//bytes_written += writer.writeValueToArray<std::uint32_t>(byte_prop->value.size());
//bytes_written += writer.writeDataToArray<char>(byte_prop->value);
if(byte_prop->valueLength != UnsignedLong(-1)) {
if(byte_prop->valueLength != std::size_t(-1)) {
writer.writeUEStringToArray(byte_prop->enumType);
writer.writeValueToArray<char>('\0');
}

View file

@ -27,11 +27,12 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<BytePropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
StringArrayView types() override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};

View file

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

View file

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

View file

@ -20,13 +20,14 @@
#include "DateTimePropertySerialiser.h"
auto DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<DateTimeStructProperty>();
if(!reader.readUnsignedLong(prop->timestamp)) {
if(!reader.readInt64(prop->timestamp)) {
LOG_ERROR_FORMAT("Couldn't read date/time property {}'s value.", name);
return nullptr;
}
@ -34,8 +35,9 @@ auto DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name
return prop;
}
auto DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto dt_prop = dynamic_cast<DateTimeStructProperty*>(prop.get());
if(!dt_prop) {
@ -43,7 +45,7 @@ auto DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop
return false;
}
bytes_written += writer.writeValueToArray<UnsignedLong>(dt_prop->timestamp);
bytes_written += writer.writeValueToArray<std::int64_t>(dt_prop->timestamp);
return true;
}

View file

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

View file

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

View file

@ -27,11 +27,12 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<EnumPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
StringArrayView types() override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};

View file

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

View file

@ -27,11 +27,12 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<FloatPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
StringArrayView types() override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};

View file

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

View file

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

View file

@ -20,19 +20,20 @@
#include "IntPropertySerialiser.h"
auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<IntProperty>();
if(value_length == UnsignedLong(-1)) {
if(!reader.readInt(prop->value)) {
if(value_length == std::size_t(-1)) {
if(!reader.readInt32(prop->value)) {
LOG_ERROR("Couldn't read int property's value.");
return nullptr;
}
prop->valueLength = UnsignedLong(-1);
prop->valueLength = std::size_t(-1);
return prop;
}
@ -42,7 +43,7 @@ auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
return nullptr;
}
if(!reader.readInt(prop->value)) {
if(!reader.readInt32(prop->value)) {
LOG_ERROR_FORMAT("Couldn't read int property {}'s value.", name);
return nullptr;
}
@ -52,8 +53,9 @@ auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
return prop;
}
auto IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto int_prop = dynamic_cast<IntProperty*>(prop.get());
if(!int_prop) {
@ -61,11 +63,11 @@ auto IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
return false;
}
if(prop->valueLength != UnsignedLong(-1)) {
if(prop->valueLength != std::size_t(-1)) {
writer.writeValueToArray<char>('\0');
}
bytes_written += writer.writeValueToArray<Int>(int_prop->value);
bytes_written += writer.writeValueToArray<std::int32_t>(int_prop->value);
return true;
}

View file

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

View file

@ -24,9 +24,10 @@
using namespace Containers::Literals;
auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<MapProperty>();
@ -46,14 +47,14 @@ auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
return nullptr;
}
UnsignedInt null;
if(!reader.readUnsignedInt(null) || null != 0u) {
std::uint32_t null;
if(!reader.readUint32(null) || null != 0u) {
LOG_ERROR_FORMAT("Couldn't read a null int in map property {}.", name);
return nullptr;
}
UnsignedInt count;
if(!reader.readUnsignedInt(count)) {
std::uint32_t count;
if(!reader.readUint32(count)) {
LOG_ERROR_FORMAT("Couldn't read map property {}'s item count.", name);
return nullptr;
}
@ -63,7 +64,7 @@ auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
arrayReserve(prop->map, count);
for(UnsignedInt i = 0; i < count; i++) {
for(std::uint32_t i = 0; i < count; i++) {
MapProperty::KeyValuePair pair;
if(prop->keyType == "IntProperty"_s || prop->keyType == "StrProperty"_s) {
@ -107,8 +108,9 @@ auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
return prop;
}
auto MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto map_prop = dynamic_cast<MapProperty*>(prop.get());
if(!map_prop) {
@ -120,12 +122,12 @@ auto MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
writer.writeUEStringToArray(map_prop->valueType);
writer.writeValueToArray<char>('\0');
UnsignedLong value_start = writer.arrayPosition();
writer.writeValueToArray<UnsignedInt>(0u);
std::size_t value_start = writer.arrayPosition();
writer.writeValueToArray<std::uint32_t>(0u);
writer.writeValueToArray<UnsignedInt>(UnsignedInt(map_prop->map.size()));
writer.writeValueToArray<std::uint32_t>(std::uint32_t(map_prop->map.size()));
UnsignedLong dummy_bytes_written = 0;
std::size_t dummy_bytes_written = 0;
for(auto& pair : map_prop->map) {
if(!serialiser.writeItem(pair.key, map_prop->keyType, dummy_bytes_written, writer)) {
LOG_ERROR("Couldn't write a key.");

View file

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

View file

@ -25,9 +25,10 @@
using namespace Containers::Literals;
auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<ResourceItemValue>();
@ -77,8 +78,9 @@ auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name
return prop;
}
auto ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto res_prop = dynamic_cast<ResourceItemValue*>(prop.get());
if(!res_prop) {
@ -88,15 +90,15 @@ auto ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop
bytes_written += writer.writeUEStringToArray("ID_4_AAE08F17428E229EC7A2209F51081A21"_s) +
writer.writeUEStringToArray("IntProperty"_s) +
writer.writeValueToArray<UnsignedLong>(4ull) +
writer.writeValueToArray<std::size_t>(4ull) +
writer.writeValueToArray<char>('\0') +
writer.writeValueToArray<Int>(res_prop->id);
writer.writeValueToArray<std::int32_t>(res_prop->id);
bytes_written += writer.writeUEStringToArray("Quantity_3_560F09B5485C365D3041888910019CE3"_s) +
writer.writeUEStringToArray("IntProperty"_s) +
writer.writeValueToArray<UnsignedLong>(4ull) +
writer.writeValueToArray<std::size_t>(4ull) +
writer.writeValueToArray<char>('\0') +
writer.writeValueToArray<Int>(res_prop->quantity);
writer.writeValueToArray<std::int32_t>(res_prop->quantity);
bytes_written += writer.writeUEStringToArray("None"_s);

View file

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

View file

@ -20,9 +20,10 @@
#include "RotatorPropertySerialiser.h"
auto RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<RotatorStructProperty>();
@ -34,8 +35,9 @@ auto RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name,
return prop;
}
auto RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto rotator = dynamic_cast<RotatorStructProperty*>(prop.get());
if(!rotator) {
@ -43,8 +45,8 @@ auto RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop,
return false;
}
bytes_written += writer.writeValueToArray<Float>(rotator->x) + writer.writeValueToArray<Float>(rotator->y) +
writer.writeValueToArray<Float>(rotator->z);
bytes_written += writer.writeValueToArray<float>(rotator->x) + writer.writeValueToArray<float>(rotator->y) +
writer.writeValueToArray<float>(rotator->z);
return true;
}

View file

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

View file

@ -21,9 +21,10 @@
#include "SetPropertySerialiser.h"
auto SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
Containers::String item_type;
if(!reader.readUEString(item_type)) {
@ -37,14 +38,14 @@ auto SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
return nullptr;
}
UnsignedInt four_bytes;
if(!reader.readUnsignedInt(four_bytes) || four_bytes != 0u) {
std::uint32_t four_bytes;
if(!reader.readUint32(four_bytes) || four_bytes != 0u) {
LOG_ERROR_FORMAT("Couldn't read four null bytes in set property {}.", name);
return nullptr;
}
UnsignedInt item_count;
if(!reader.readUnsignedInt(item_count)) {
std::uint32_t item_count;
if(!reader.readUint32(item_count)) {
LOG_ERROR_FORMAT("Couldn't read set property {}'s item count.", name);
return nullptr;
}
@ -56,8 +57,9 @@ auto SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
return prop;
}
auto SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto set_prop = dynamic_cast<SetProperty*>(prop.get());
if(!set_prop) {
@ -68,11 +70,11 @@ auto SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
writer.writeUEStringToArray(set_prop->itemType);
writer.writeValueToArray<char>('\0');
bytes_written += writer.writeValueToArray<UnsignedInt>(0u);
bytes_written += writer.writeValueToArray<UnsignedInt>(UnsignedInt(set_prop->items.size()));
bytes_written += writer.writeValueToArray<std::uint32_t>(0u);
bytes_written += writer.writeValueToArray<std::uint32_t>(std::uint32_t(set_prop->items.size()));
UnsignedLong start_pos = writer.arrayPosition();
UnsignedLong dummy_bytes_written = 0;
std::size_t start_pos = writer.arrayPosition();
std::size_t dummy_bytes_written = 0;
serialiser.writeSet(set_prop->items, set_prop->itemType, dummy_bytes_written, writer);
bytes_written += writer.arrayPosition() - start_pos;

View file

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

View file

@ -20,21 +20,22 @@
#include "StringPropertySerialiser.h"
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
StringArrayView
StringPropertySerialiser::types() {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit,
{"NameProperty"_s, "StrProperty"_s,
"SoftObjectProperty"_s, "ObjectProperty"_s}};
static const Containers::Array<Containers::String> types{InPlaceInit, {
"NameProperty"_s, "StrProperty"_s, "SoftObjectProperty"_s, "ObjectProperty"_s
}};
return types;
}
auto StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<StringProperty>(type);
if(value_length != UnsignedLong(-1)) {
if(value_length != std::size_t(-1)) {
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in string property {}.", name);
@ -52,8 +53,9 @@ auto StringPropertySerialiser::deserialise(Containers::StringView name, Containe
return prop;
}
auto StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{
auto str_prop = dynamic_cast<StringProperty*>(prop.get());
if(!str_prop) {
@ -61,7 +63,7 @@ auto StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Unsigned
return false;
}
if(str_prop->valueLength != UnsignedLong(-1)) {
if(str_prop->valueLength != std::size_t(-1)) {
writer.writeValueToArray<char>('\0');
}

View file

@ -27,11 +27,12 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<StringPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
StringArrayView types() override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};

View file

@ -25,14 +25,16 @@
#include "StructSerialiser.h"
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::String> {
StringArrayView
StructSerialiser::types() {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"StructProperty"_s}};
return types;
}
auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr>
Containers::Array<UnrealPropertyBase::ptr>
StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser)
{
Containers::String item_type;
if(!reader.readUEString(item_type)) {
@ -60,10 +62,10 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
prop->structGuid = std::move(guid);
}
else {
for(UnsignedInt i = 0; i < count; i++) {
for(std::uint32_t i = 0; i < count; i++) {
auto prop = Containers::pointer<UnrealPropertyBase>();
prop = serialiser.readItem(reader, item_type, UnsignedLong(-1), name);
prop = serialiser.readItem(reader, item_type, std::size_t(-1), name);
if(!prop) {
prop = readStructValue(name, item_type, value_length, reader, serialiser);
@ -83,8 +85,9 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
return array;
}
auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
BinaryReader& reader, PropertySerialiser& serialiser)
{
Containers::String item_type;
if(!reader.readUEString(item_type)) {
@ -120,13 +123,14 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
return prop;
}
auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser)
{
bytes_written += writer.writeUEStringToArray(*(props.front()->name));
bytes_written += writer.writeUEStringToArray(item_type);
UnsignedLong vl_pos = writer.arrayPosition();
bytes_written += writer.writeValueToArray<UnsignedLong>(0ull);
std::size_t vl_pos = writer.arrayPosition();
bytes_written += writer.writeValueToArray<std::size_t>(0ull);
auto struct_prop = dynamic_cast<StructProperty*>(props.front().get());
if(!struct_prop) {
@ -138,9 +142,9 @@ auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr>
bytes_written += writer.writeDataToArray(arrayView(struct_prop->structGuid));
bytes_written += writer.writeValueToArray<char>('\0');
UnsignedLong vl_start = writer.arrayPosition();
std::size_t vl_start = writer.arrayPosition();
UnsignedLong bytes_written_here = 0;
std::size_t bytes_written_here = 0;
for(auto& prop : props) {
struct_prop = dynamic_cast<StructProperty*>(prop.get());
if(!struct_prop) {
@ -156,15 +160,16 @@ auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr>
}
}
UnsignedLong vl_stop = writer.arrayPosition() - vl_start;
std::size_t vl_stop = writer.arrayPosition() - vl_start;
writer.writeValueToArrayAt(vl_stop, vl_pos);
bytes_written += vl_stop;
return true;
}
auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{
auto struct_prop = dynamic_cast<StructProperty*>(prop.get());
if(!struct_prop) {
@ -177,8 +182,8 @@ auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& by
writer.writeValueToArray<char>('\0');
if(!serialiser.writeItem(prop, struct_prop->structType, bytes_written, writer)) {
UnsignedLong dummy_bytes_written = 0;
UnsignedLong vl_start = writer.arrayPosition();
std::size_t dummy_bytes_written = 0;
std::size_t vl_start = writer.arrayPosition();
if(!writeStructValue(struct_prop, dummy_bytes_written, writer, serialiser)) {
LOG_ERROR("Couldn't write the struct value.");
return false;
@ -189,8 +194,9 @@ auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& by
return true;
}
auto StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr
StructProperty::ptr
StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, std::size_t value_length,
BinaryReader& reader, PropertySerialiser& serialiser)
{
auto st_prop = Containers::pointer<GenericStructProperty>();
st_prop->structType = type;
@ -212,8 +218,9 @@ auto StructSerialiser::readStructValue(Containers::StringView name, Containers::
return st_prop;
}
auto StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
StructSerialiser::writeStructValue(StructProperty* prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser)
{
auto struct_prop = dynamic_cast<GenericStructProperty*>(prop);
if(!struct_prop) {

View file

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

View file

@ -21,13 +21,14 @@
#include "TextPropertySerialiser.h"
auto TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<TextProperty>();
Long start_position = reader.position();
auto start_position = reader.position();
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
@ -61,15 +62,16 @@ auto TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Co
arrayAppend(prop->data, std::move(str));
interval = reader.position() - start_position;
} while(UnsignedLong(interval) < value_length);
} while(std::size_t(interval) < value_length);
prop->value = prop->data.back();
return prop;
}
auto TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto text_prop = dynamic_cast<TextProperty*>(prop.get());

View file

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

View file

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

View file

@ -20,9 +20,10 @@
#include "Vector2DPropertySerialiser.h"
auto Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<Vector2DStructProperty>();
@ -34,8 +35,9 @@ auto Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name
return prop;
}
auto Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto vector = dynamic_cast<Vector2DStructProperty*>(prop.get());
if(!vector) {
@ -43,7 +45,7 @@ auto Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop
return false;
}
bytes_written += writer.writeValueToArray<Float>(vector->x) + writer.writeValueToArray<Float>(vector->y);
bytes_written += writer.writeValueToArray<float>(vector->x) + writer.writeValueToArray<float>(vector->y);
return true;
}

View file

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

View file

@ -20,9 +20,10 @@
#include "VectorPropertySerialiser.h"
auto VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
UnrealPropertyBase::ptr
VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser)
{
auto prop = Containers::pointer<VectorStructProperty>();
@ -34,8 +35,9 @@ auto VectorPropertySerialiser::deserialiseProperty(Containers::StringView name,
return prop;
}
auto VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
bool
VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser)
{
auto vector = dynamic_cast<VectorStructProperty*>(prop.get());
if(!vector) {
@ -43,8 +45,8 @@ auto VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop,
return false;
}
bytes_written += writer.writeValueToArray<Float>(vector->x) + writer.writeValueToArray<Float>(vector->y) +
writer.writeValueToArray<Float>(vector->z);
bytes_written += writer.writeValueToArray<float>(vector->x) + writer.writeValueToArray<float>(vector->y) +
writer.writeValueToArray<float>(vector->z);
return true;
}

View file

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

View file

@ -29,5 +29,5 @@ struct ColourStructProperty : public StructProperty {
using namespace Containers::Literals;
structType = "LinearColor"_s;
}
Float r = 0.0f, g = 0.0f, b = 0.0f, a = 0.0f;
float r = 0.0f, g = 0.0f, b = 0.0f, a = 0.0f;
};

View file

@ -19,12 +19,9 @@
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "StructProperty.h"
using namespace Corrade;
using namespace Magnum;
struct DateTimeStructProperty : public StructProperty {
using ptr = Containers::Pointer<DateTimeStructProperty>;
@ -34,5 +31,5 @@ struct DateTimeStructProperty : public StructProperty {
structType = "DateTime"_s;
}
UnsignedLong timestamp = 0;
std::int64_t timestamp = 0;
};

View file

@ -19,14 +19,11 @@
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "UnrealProperty.h"
using namespace Corrade;
using namespace Magnum;
struct FloatProperty : public UnrealProperty<Float> {
struct FloatProperty : public UnrealProperty<float> {
using ptr = Containers::Pointer<FloatProperty>;
FloatProperty() {

View file

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

View file

@ -23,7 +23,7 @@
using namespace Corrade;
struct IntProperty : public UnrealProperty<Int> {
struct IntProperty : public UnrealProperty<std::int32_t> {
using ptr = Containers::Pointer<IntProperty>;
IntProperty() {

Some files were not shown because too many files have changed in this diff Show more