diff --git a/src/SaveTool/SaveTool.cpp b/src/Application/Application.cpp
similarity index 91%
rename from src/SaveTool/SaveTool.cpp
rename to src/Application/Application.cpp
index 2859392..ff5efea 100644
--- a/src/SaveTool/SaveTool.cpp
+++ b/src/Application/Application.cpp
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-#include "SaveTool.h"
-
#include
#include
@@ -37,6 +35,8 @@
#include "../Configuration/Configuration.h"
#include "../Logger/Logger.h"
+#include "Application.h"
+
using namespace Containers::Literals;
extern const ImVec2 center_pivot = {0.5f, 0.5f};
@@ -45,7 +45,9 @@ extern const ImVec2 center_pivot = {0.5f, 0.5f};
Utility::Tweakable tweak;
#endif
-SaveTool::SaveTool(const Arguments& arguments):
+namespace mbst {
+
+Application::Application(const Arguments& arguments):
Platform::Sdl2Application{arguments,
Configuration{}.setTitle("M.A.S.S. Builder Save Tool " SAVETOOL_VERSION_STRING " (\"" SAVETOOL_CODENAME "\")")
.setSize({960, 720})}
@@ -82,7 +84,7 @@ SaveTool::SaveTool(const Arguments& arguments):
LOG_INFO("Registering custom events.");
if((_initEventId = SDL_RegisterEvents(3)) == std::uint32_t(-1)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
- "SDL_RegisterEvents() failed in SaveTool::SaveTool(). Exiting...", window());
+ "SDL_RegisterEvents() failed in Application::SaveTool(). Exiting...", window());
exit(EXIT_FAILURE);
return;
}
@@ -118,7 +120,7 @@ SaveTool::SaveTool(const Arguments& arguments):
checkGameState();
_gameCheckTimerId = SDL_AddTimer(2000,
[](std::uint32_t interval, void* param)->std::uint32_t{
- static_cast(param)->checkGameState();
+ static_cast(param)->checkGameState();
return interval;
}, this);
if(_gameCheckTimerId == 0) {
@@ -149,7 +151,7 @@ SaveTool::SaveTool(const Arguments& arguments):
_timeline.start();
}
-SaveTool::~SaveTool() {
+Application::~Application() {
LOG_INFO("Cleaning up.");
SDL_RemoveTimer(_gameCheckTimerId);
@@ -162,7 +164,7 @@ SaveTool::~SaveTool() {
}
void
-SaveTool::drawEvent() {
+Application::drawEvent() {
#ifdef SAVETOOL_DEBUG_BUILD
tweak.update();
#endif
@@ -183,7 +185,7 @@ SaveTool::drawEvent() {
}
void
-SaveTool::viewportEvent(ViewportEvent& event) {
+Application::viewportEvent(ViewportEvent& event) {
GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()});
const Vector2 size = Vector2{windowSize()}/dpiScaling();
@@ -191,32 +193,32 @@ SaveTool::viewportEvent(ViewportEvent& event) {
}
void
-SaveTool::keyPressEvent(KeyEvent& event) {
+Application::keyPressEvent(KeyEvent& event) {
if(_imgui.handleKeyPressEvent(event)) return;
}
void
-SaveTool::keyReleaseEvent(KeyEvent& event) {
+Application::keyReleaseEvent(KeyEvent& event) {
if(_imgui.handleKeyReleaseEvent(event)) return;
}
void
-SaveTool::mousePressEvent(MouseEvent& event) {
+Application::mousePressEvent(MouseEvent& event) {
if(_imgui.handleMousePressEvent(event)) return;
}
void
-SaveTool::mouseReleaseEvent(MouseEvent& event) {
+Application::mouseReleaseEvent(MouseEvent& event) {
if(_imgui.handleMouseReleaseEvent(event)) return;
}
void
-SaveTool::mouseMoveEvent(MouseMoveEvent& event) {
+Application::mouseMoveEvent(MouseMoveEvent& event) {
if(_imgui.handleMouseMoveEvent(event)) return;
}
void
-SaveTool::mouseScrollEvent(MouseScrollEvent& event) {
+Application::mouseScrollEvent(MouseScrollEvent& event) {
if(_imgui.handleMouseScrollEvent(event)) {
event.setAccepted();
return;
@@ -224,12 +226,12 @@ SaveTool::mouseScrollEvent(MouseScrollEvent& event) {
}
void
-SaveTool::textInputEvent(TextInputEvent& event) {
+Application::textInputEvent(TextInputEvent& event) {
if(_imgui.handleTextInputEvent(event)) return;
}
void
-SaveTool::anyEvent(SDL_Event& event) {
+Application::anyEvent(SDL_Event& event) {
if(event.type == _initEventId) {
initEvent(event);
}
@@ -242,7 +244,7 @@ SaveTool::anyEvent(SDL_Event& event) {
}
void
-SaveTool::drawImGui() {
+Application::drawImGui() {
_imgui.newFrame();
if(ImGui::GetIO().WantTextInput && !isTextInputActive()) {
@@ -260,7 +262,7 @@ SaveTool::drawImGui() {
}
void
-SaveTool::drawGui() {
+Application::drawGui() {
drawMainMenu();
switch(_uiState) {
@@ -303,7 +305,7 @@ SaveTool::drawGui() {
}
void
-SaveTool::drawDisclaimer() {
+Application::drawDisclaimer() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot);
if(ImGui::Begin("Disclaimer##DisclaimerWindow", nullptr,
@@ -371,7 +373,7 @@ SaveTool::drawDisclaimer() {
}
void
-SaveTool::drawInitialisation() {
+Application::drawInitialisation() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot);
if(ImGui::BeginPopupModal("##InitPopup", nullptr,
@@ -385,7 +387,7 @@ SaveTool::drawInitialisation() {
}
void
-SaveTool::drawGameState() {
+Application::drawGameState() {
ImGui::TextUnformatted("Game state:");
ImGui::SameLine();
{
@@ -407,13 +409,13 @@ SaveTool::drawGameState() {
}
void
-SaveTool::drawHelpMarker(Containers::StringView text, float wrap_pos) {
+Application::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) {
+Application::drawTooltip(Containers::StringView text, float wrap_pos) {
if(ImGui::IsItemHovered()){
ImGui::BeginTooltip();
if(wrap_pos > 0.0f) {
@@ -428,12 +430,12 @@ SaveTool::drawTooltip(Containers::StringView text, float wrap_pos) {
}
bool
-SaveTool::drawCheckbox(Containers::StringView label, bool value) {
+Application::drawCheckbox(Containers::StringView label, bool value) {
return ImGui::Checkbox(label.data(), &value);
}
void
-SaveTool::openUri(Containers::StringView uri) {
+Application::openUri(Containers::StringView uri) {
if(!conf().isRunningInWine()) {
ShellExecuteA(nullptr, nullptr, uri.data(), nullptr, nullptr, SW_SHOWDEFAULT);
}
@@ -443,7 +445,7 @@ SaveTool::openUri(Containers::StringView uri) {
}
void
-SaveTool::checkGameState() {
+Application::checkGameState() {
WTS_PROCESS_INFOW* process_infos = nullptr;
unsigned long process_count = 0;
@@ -464,3 +466,5 @@ SaveTool::checkGameState() {
_gameState = GameState::Unknown;
}
}
+
+}
diff --git a/src/SaveTool/SaveTool.h b/src/Application/Application.h
similarity index 77%
rename from src/SaveTool/SaveTool.h
rename to src/Application/Application.h
index e1a3077..2f30b0e 100644
--- a/src/SaveTool/SaveTool.h
+++ b/src/Application/Application.h
@@ -51,11 +51,13 @@ using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum;
-class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener {
- public:
- explicit SaveTool(const Arguments& arguments);
+namespace mbst {
- ~SaveTool() override;
+class Application: public Platform::Sdl2Application, public efsw::FileWatchListener {
+ public:
+ explicit Application(const Arguments& arguments);
+
+ ~Application() override;
void handleFileAction(efsw::WatchID watch_id,
const std::string& dir,
@@ -113,20 +115,20 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawInitialisation();
void drawProfileManager();
- ImGuiID drawBackupListPopup();
- ImGuiID drawBackupProfilePopup(std::size_t profile_index);
- ImGuiID drawDeleteProfilePopup(std::size_t profile_index);
+ auto drawBackupListPopup() -> ImGuiID;
+ auto drawBackupProfilePopup(std::size_t profile_index) -> ImGuiID;
+ auto drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID;
void drawManager();
bool drawIntEditPopup(int* value_to_edit, int max);
bool drawRenamePopup(Containers::ArrayView name_view);
void drawGeneralInfo();
void drawResearchInventory();
- void drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id);
+ void drawMaterialRow(Containers::StringView name, std::int32_t tier, GameData::MaterialID id);
void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
void drawMassManager();
- ImGuiID drawDeleteMassPopup(int mass_index);
- ImGuiID drawDeleteStagedMassPopup(Containers::StringView filename);
+ auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
+ auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID;
void drawMassViewer();
void drawFrameInfo();
@@ -137,21 +139,24 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawArmour();
void drawCustomArmourStyles();
void drawWeapons();
- void drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view, bool& dirty,
- Containers::StringView payload_type, Containers::StringView payload_tooltip);
- void drawWeaponEditor(Weapon& weapon);
+ void drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view,
+ bool& dirty, Containers::StringView payload_type,
+ Containers::StringView payload_tooltip);
+ void drawWeaponEditor(GameObjects::Weapon& weapon);
void drawGlobalStyles();
void drawTuning();
- void drawDecalEditor(Decal& decal);
- void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView style_view);
- Containers::StringView getStyleName(std::int32_t id, Containers::ArrayView view);
+ void drawDecalEditor(GameObjects::Decal& decal);
+ void drawAccessoryEditor(GameObjects::Accessory& accessory,
+ Containers::ArrayView style_view);
+ auto getStyleName(std::int32_t id, Containers::ArrayView view)
+ -> Containers::StringView;
enum DCSResult {
DCS_Fail,
DCS_ResetStyle,
DCS_Save
};
- DCSResult drawCustomStyle(CustomStyle& style);
+ auto drawCustomStyle(GameObjects::CustomStyle& style) -> DCSResult;
void drawAbout();
void drawGameState();
@@ -206,11 +211,11 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
MassViewer
} _uiState{UiState::Disclaimer};
- bool _aboutPopup{false};
+ bool _aboutPopup = false;
#ifdef SAVETOOL_DEBUG_BUILD
- bool _demoWindow{false};
- bool _styleEditor{false};
- bool _metricsWindow{false};
+ bool _demoWindow = false;
+ bool _styleEditor = false;
+ bool _metricsWindow = false;
#endif
ToastQueue _queue;
@@ -243,12 +248,12 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
SDL_TimerID _gameCheckTimerId = 0;
Containers::Pointer _profileManager;
- Profile* _currentProfile{nullptr};
+ GameObjects::Profile* _currentProfile = nullptr;
Containers::Pointer _massManager;
- Mass* _currentMass{nullptr};
+ GameObjects::Mass* _currentMass = nullptr;
- Weapon* _currentWeapon = nullptr;
+ GameObjects::Weapon* _currentWeapon = nullptr;
Containers::Pointer _fileWatcher;
enum watchID {
@@ -258,24 +263,27 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
Containers::StaticArray<2, efsw::WatchID> _watchIDs;
Containers::Optional _checker{Containers::NullOpt};
- std::mutex _checkerMutex;
+ std::mutex _checkerMutex;
+
+ bool _modifiedBySaveTool = false;
+ bool _jointsDirty = false;
+ bool _stylesDirty = false;
+ bool _eyeFlareDirty = false;
+ bool _meleeDirty = false;
+ bool _shieldsDirty = false;
+ bool _bShootersDirty = false;
+ bool _eShootersDirty = false;
+ bool _bLaunchersDirty = false;
+ bool _eLaunchersDirty = false;
- bool _modifiedBySaveTool{false};
- bool _jointsDirty{false};
- bool _stylesDirty{false};
- bool _eyeFlareDirty{false};
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};
- bool _eShootersDirty{false};
- bool _bLaunchersDirty{false};
- bool _eLaunchersDirty{false};
+ std::int32_t _selectedBLPlacement = 0;
+ std::int32_t _selectedWeaponPart = 0;
+ std::int32_t _selectedWeaponDecal = 0;
+ std::int32_t _selectedWeaponAccessory = 0;
Timeline _timeline;
};
+
+}
diff --git a/src/SaveTool/SaveTool_FileWatcher.cpp b/src/Application/Application_FileWatcher.cpp
similarity index 97%
rename from src/SaveTool/SaveTool_FileWatcher.cpp
rename to src/Application/Application_FileWatcher.cpp
index c35b233..f99f40b 100644
--- a/src/SaveTool/SaveTool_FileWatcher.cpp
+++ b/src/Application/Application_FileWatcher.cpp
@@ -24,10 +24,12 @@
#include
#include
-#include "SaveTool.h"
+#include "Application.h"
+
+namespace mbst {
void
-SaveTool::handleFileAction(efsw::WatchID watch_id,
+Application::handleFileAction(efsw::WatchID watch_id,
const std::string&,
const std::string& filename,
efsw::Action action,
@@ -64,7 +66,7 @@ SaveTool::handleFileAction(efsw::WatchID watch_id,
}
void
-SaveTool::fileUpdateEvent(SDL_Event& event) {
+Application::fileUpdateEvent(SDL_Event& event) {
Containers::String filename{static_cast(event.user.data1),
std::strlen(static_cast(event.user.data1)), nullptr};
@@ -153,3 +155,5 @@ SaveTool::fileUpdateEvent(SDL_Event& event) {
_queue.addToast(Toast::Type::Warning, "Unknown file action type"_s);
}
}
+
+}
diff --git a/src/SaveTool/SaveTool_Initialisation.cpp b/src/Application/Application_Initialisation.cpp
similarity index 95%
rename from src/SaveTool/SaveTool_Initialisation.cpp
rename to src/Application/Application_Initialisation.cpp
index b6f6449..606f7cc 100644
--- a/src/SaveTool/SaveTool_Initialisation.cpp
+++ b/src/Application/Application_Initialisation.cpp
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-#include
#include
#include
#include
@@ -29,10 +28,12 @@
#include "../FontAwesome/IconsFontAwesome5Brands.h"
#include "../Logger/Logger.h"
-#include "SaveTool.h"
+#include "Application.h"
+
+namespace mbst {
void
-SaveTool::initEvent(SDL_Event& event) {
+Application::initEvent(SDL_Event& event) {
_initThread.join();
switch(event.user.code) {
@@ -51,7 +52,7 @@ SaveTool::initEvent(SDL_Event& event) {
}
void
-SaveTool::initialiseConfiguration() {
+Application::initialiseConfiguration() {
LOG_INFO("Reading configuration file.");
setSwapInterval(conf().swapInterval());
@@ -59,7 +60,7 @@ SaveTool::initialiseConfiguration() {
}
void
-SaveTool::initialiseGui() {
+Application::initialiseGui() {
LOG_INFO("Initialising Dear ImGui.");
auto ctx = ImGui::CreateContext();
@@ -107,7 +108,7 @@ SaveTool::initialiseGui() {
}
void
-SaveTool::initialiseManager() {
+Application::initialiseManager() {
LOG_INFO("Initialising the profile manager.");
SDL_Event event;
@@ -126,7 +127,7 @@ SaveTool::initialiseManager() {
}
auto
-SaveTool::initialiseToolDirectories() -> bool {
+Application::initialiseToolDirectories() -> bool {
LOG_INFO("Initialising Save Tool directories.");
_backupsDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "backups");
@@ -188,7 +189,7 @@ SaveTool::initialiseToolDirectories() -> bool {
}
auto
-SaveTool::findGameDataDirectory() -> bool {
+Application::findGameDataDirectory() -> bool {
LOG_INFO("Searching for the game's save directory.");
wchar_t* localappdata_path = nullptr;
@@ -223,16 +224,18 @@ SaveTool::findGameDataDirectory() -> bool {
}
void
-SaveTool::initialiseMassManager() {
+Application::initialiseMassManager() {
LOG_INFO("Initialising the M.A.S.S. manager.");
_massManager.emplace(_saveDir, _currentProfile->account(), _currentProfile->isDemo(), _stagingDir);
}
void
-SaveTool::initialiseFileWatcher() {
+Application::initialiseFileWatcher() {
LOG_INFO("Initialising the file watcher.");
_fileWatcher.emplace();
_watchIDs[SaveDir] = _fileWatcher->addWatch(_saveDir, this, false);
_watchIDs[StagingDir] = _fileWatcher->addWatch(_stagingDir, this, false);
_fileWatcher->watch();
}
+
+}
diff --git a/src/SaveTool/SaveTool_MainManager.cpp b/src/Application/Application_MainManager.cpp
similarity index 85%
rename from src/SaveTool/SaveTool_MainManager.cpp
rename to src/Application/Application_MainManager.cpp
index b95df8d..e9861c6 100644
--- a/src/SaveTool/SaveTool_MainManager.cpp
+++ b/src/Application/Application_MainManager.cpp
@@ -28,10 +28,12 @@
#include "../Maps/LastMissionId.h"
#include "../Maps/StoryProgress.h"
-#include "SaveTool.h"
+#include "Application.h"
+
+namespace mbst {
void
-SaveTool::drawManager() {
+Application::drawManager() {
ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2{Vector2{float(windowSize().x()), float(windowSize().y()) - ImGui::GetItemRectSize().y} / dpiScaling()},
ImGuiCond_Always);
@@ -99,7 +101,7 @@ SaveTool::drawManager() {
}
bool
-SaveTool::drawIntEditPopup(int* value_to_edit, int max) {
+Application::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);
@@ -123,7 +125,7 @@ SaveTool::drawIntEditPopup(int* value_to_edit, int max) {
}
bool
-SaveTool::drawRenamePopup(Containers::ArrayView name_view) {
+Application::drawRenamePopup(Containers::ArrayView name_view) {
bool apply = false;
if(ImGui::BeginPopup("name_edit")) {
ImGui::TextUnformatted("Please enter a new name. Conditions:");
@@ -178,16 +180,16 @@ SaveTool::drawRenamePopup(Containers::ArrayView name_view) {
}
void
-SaveTool::drawGeneralInfo() {
+Application::drawGeneralInfo() {
if(!_currentProfile) {
return;
}
ImGui::Text("Credits: %i", _currentProfile->credits());
- auto it = std::find_if(story_progress.begin(), story_progress.end(),
- [this](const StoryProgressPoint& p){ return p.id == _currentProfile->storyProgress(); });
- if(it != story_progress.end())
+ auto it = std::find_if(GameData::story_progress.begin(), GameData::story_progress.end(),
+ [this](const GameData::StoryProgressPoint& p){ return p.id == _currentProfile->storyProgress(); });
+ if(it != GameData::story_progress.end())
{
ImGui::TextUnformatted("Story progress:");
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.x / 4.0f);
@@ -202,8 +204,8 @@ SaveTool::drawGeneralInfo() {
ImGui::Text("Story progress: 0x%x", _currentProfile->storyProgress());
}
- if(mission_id_map.find(_currentProfile->lastMissionId()) != mission_id_map.cend()) {
- ImGui::Text("Last mission: %s", mission_id_map.at(_currentProfile->lastMissionId()).data());
+ if(GameData::mission_id_map.find(_currentProfile->lastMissionId()) != GameData::mission_id_map.cend()) {
+ ImGui::Text("Last mission: %s", GameData::mission_id_map.at(_currentProfile->lastMissionId()).data());
}
else if(_currentProfile->lastMissionId() == -1) {
ImGui::TextUnformatted("Last mission: none");
@@ -260,7 +262,7 @@ SaveTool::drawGeneralInfo() {
if(_gameState != GameState::NotRunning) {
ImGui::CloseCurrentPopup();
}
- for(const auto& sp : story_progress) {
+ for(const auto& sp : GameData::story_progress) {
if(ImGui::BeginMenu(sp.chapter.data())) {
if(!sp.after) {
if(ImGui::MenuItem(sp.point.data())) {
@@ -287,7 +289,7 @@ SaveTool::drawGeneralInfo() {
}
void
-SaveTool::drawResearchInventory() {
+Application::drawResearchInventory() {
if(!_currentProfile) {
return;
}
@@ -304,48 +306,48 @@ SaveTool::drawResearchInventory() {
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted("Engine materials");
- 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);
+ drawMaterialRow("Verse steel", 1, GameData::MaterialID::VerseSteel);
+ drawMaterialRow("Undinium", 2, GameData::MaterialID::Undinium);
+ drawMaterialRow("Necrium alloy", 3, GameData::MaterialID::NecriumAlloy);
+ drawMaterialRow("Lunarite", 4, GameData::MaterialID::Lunarite);
+ drawMaterialRow("Asterite", 5, GameData::MaterialID::Asterite);
+ drawMaterialRow("Hallite fragma", 6, GameData::MaterialID::HalliteFragma);
drawUnavailableMaterialRow("Unnoctinium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted("OS materials");
- 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);
+ drawMaterialRow("Ednil", 1, GameData::MaterialID::Ednil);
+ drawMaterialRow("Nuflalt", 2, GameData::MaterialID::Nuflalt);
+ drawMaterialRow("Aurelene", 3, GameData::MaterialID::Aurelene);
+ drawMaterialRow("Soldus", 4, GameData::MaterialID::Soldus);
+ drawMaterialRow("Synthesized N", 5, GameData::MaterialID::SynthesisedN);
+ drawMaterialRow("Nanoc", 6, GameData::MaterialID::Nanoc);
drawUnavailableMaterialRow("Abyssillite", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted("Architect materials");
- 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);
+ drawMaterialRow("Alcarbonite", 1, GameData::MaterialID::Alcarbonite);
+ drawMaterialRow("Keriphene", 2, GameData::MaterialID::Keriphene);
+ drawMaterialRow("Nitinol-CM", 3, GameData::MaterialID::NitinolCM);
+ drawMaterialRow("Quarkium", 4, GameData::MaterialID::Quarkium);
+ drawMaterialRow("Alterene", 5, GameData::MaterialID::Alterene);
+ drawMaterialRow("Cosmium", 6, GameData::MaterialID::Cosmium);
drawUnavailableMaterialRow("Purified quarkium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted("Quark data");
- 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);
+ drawMaterialRow("Mixed composition", 1, GameData::MaterialID::MixedComposition);
+ drawMaterialRow("Void residue", 2, GameData::MaterialID::VoidResidue);
+ drawMaterialRow("Muscular construction", 3, GameData::MaterialID::MuscularConstruction);
+ drawMaterialRow("Mineral exoskeletology", 4, GameData::MaterialID::MineralExoskeletology);
+ drawMaterialRow("Carbonized skin", 5, GameData::MaterialID::CarbonisedSkin);
+ drawMaterialRow("Isolated void particle", 6, GameData::MaterialID::IsolatedVoidParticle);
drawUnavailableMaterialRow("Weaponised physiology", 7);
ImGui::EndTable();
@@ -353,7 +355,7 @@ SaveTool::drawResearchInventory() {
}
void
-SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id) {
+Application::drawMaterialRow(Containers::StringView name, std::int32_t tier, GameData::MaterialID id) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier);
@@ -380,7 +382,7 @@ SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, Materi
}
void
-SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) {
+Application::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier);
@@ -391,7 +393,7 @@ SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t t
}
void
-SaveTool::drawMassManager() {
+Application::drawMassManager() {
if(!_massManager) {
return;
}
@@ -426,7 +428,7 @@ SaveTool::drawMassManager() {
ImGui::TableSetColumnIndex(0);
ImGui::Selectable(Utility::format("{:.2d}", i + 1).data(),
false, ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap);
- if(_massManager->hangar(i).state() == Mass::State::Valid &&
+ if(_massManager->hangar(i).state() == GameObjects::Mass::State::Valid &&
ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceNoHoldToOpenOthers))
{
drag_drop_index = i;
@@ -440,7 +442,7 @@ SaveTool::drawMassManager() {
if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("StagedMass")) {
if(payload->DataSize != sizeof(Containers::String)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal error",
- "payload->DataSize != sizeof(Containers::String) in SaveTool::drawMassManager()",
+ "payload->DataSize != sizeof(Containers::String) in Application::drawMassManager()",
window());
exit(EXIT_FAILURE);
}
@@ -454,7 +456,7 @@ SaveTool::drawMassManager() {
else if((payload = ImGui::AcceptDragDropPayload("Mass"))) {
if(payload->DataSize != sizeof(int)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal error",
- "payload->DataSize != sizeof(int) in SaveTool::drawMassManager()",
+ "payload->DataSize != sizeof(int) in Application::drawMassManager()",
window());
exit(EXIT_FAILURE);
}
@@ -471,13 +473,13 @@ SaveTool::drawMassManager() {
ImGui::TableSetColumnIndex(1);
switch(_massManager->hangar(i).state()) {
- case Mass::State::Empty:
+ case GameObjects::Mass::State::Empty:
ImGui::TextDisabled("");
break;
- case Mass::State::Invalid:
+ case GameObjects::Mass::State::Invalid:
ImGui::TextDisabled("");
break;
- case Mass::State::Valid:
+ case GameObjects::Mass::State::Valid:
ImGui::TextUnformatted(_massManager->hangar(i).name().data());
break;
}
@@ -488,10 +490,10 @@ SaveTool::drawMassManager() {
drawTooltip("This is the currently active frame slot.");
}
- if(_massManager->hangar(i).state() != Mass::State::Empty) {
+ if(_massManager->hangar(i).state() != GameObjects::Mass::State::Empty) {
ImGui::TableSetColumnIndex(3);
ImGui::PushID(i);
- if(_massManager->hangar(i).state() == Mass::State::Valid) {
+ if(_massManager->hangar(i).state() == GameObjects::Mass::State::Valid) {
if(ImGui::SmallButton(ICON_FA_SEARCH)) {
_currentMass = &_massManager->hangar(i);
_uiState = UiState::MassViewer;
@@ -570,7 +572,7 @@ SaveTool::drawMassManager() {
if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("Mass")) {
if(payload->DataSize != sizeof(int)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal error",
- "payload->DataSize != sizeof(int) in SaveTool::drawMassManager()",
+ "payload->DataSize != sizeof(int) in Application::drawMassManager()",
window());
exit(EXIT_FAILURE);
}
@@ -589,14 +591,14 @@ SaveTool::drawMassManager() {
}
ImGuiID
-SaveTool::drawDeleteMassPopup(int mass_index) {
+Application::drawDeleteMassPopup(int mass_index) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{
return ImGui::GetID("Confirmation##DeleteMassConfirmation");
}
- if(_massManager->hangar(mass_index).state() == Mass::State::Empty) {
+ if(_massManager->hangar(mass_index).state() == GameObjects::Mass::State::Empty) {
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
return 0;
@@ -609,7 +611,7 @@ SaveTool::drawDeleteMassPopup(int mass_index) {
}
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
- if(_massManager->hangar(mass_index).state() == Mass::State::Invalid) {
+ if(_massManager->hangar(mass_index).state() == GameObjects::Mass::State::Invalid) {
ImGui::Text("Are you sure you want to delete the invalid M.A.S.S. data in hangar %.2i ? This operation is irreversible.",
mass_index + 1);
}
@@ -646,7 +648,7 @@ SaveTool::drawDeleteMassPopup(int mass_index) {
}
ImGuiID
-SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) {
+Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{
@@ -683,3 +685,5 @@ SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) {
return 0;
}
+
+}
diff --git a/src/SaveTool/SaveTool_MassViewer.cpp b/src/Application/Application_MassViewer.cpp
similarity index 92%
rename from src/SaveTool/SaveTool_MassViewer.cpp
rename to src/Application/Application_MassViewer.cpp
index 4bb3da2..6af7887 100644
--- a/src/SaveTool/SaveTool_MassViewer.cpp
+++ b/src/Application/Application_MassViewer.cpp
@@ -25,11 +25,13 @@
#define STYLENAMES_DEFINITION
#include "../Maps/StyleNames.h"
-#include "SaveTool.h"
+#include "Application.h"
+
+namespace mbst {
void
-SaveTool::drawMassViewer() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawMassViewer() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
_currentMass = nullptr;
_currentWeapon = nullptr;
_uiState = UiState::MainManager;
@@ -156,8 +158,8 @@ SaveTool::drawMassViewer() {
}
void
-SaveTool::drawGlobalStyles() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawGlobalStyles() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
}
@@ -193,8 +195,8 @@ SaveTool::drawGlobalStyles() {
}
void
-SaveTool::drawTuning() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawTuning() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
}
@@ -289,9 +291,9 @@ SaveTool::drawTuning() {
ImGui::EndTable();
}
-SaveTool::DCSResult
-SaveTool::drawCustomStyle(CustomStyle& style) {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::DCSResult
+Application::drawCustomStyle(GameObjects::CustomStyle& style) {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return DCS_Fail;
}
@@ -396,7 +398,7 @@ SaveTool::drawCustomStyle(CustomStyle& style) {
}
void
-SaveTool::drawDecalEditor(Decal& decal) {
+Application::drawDecalEditor(GameObjects::Decal& decal) {
ImGui::Text("ID: %i", decal.id);
if(ImGui::BeginTable("##DecalTable", conf().advancedMode() ? 2 : 1, ImGuiTableFlags_BordersInnerV)) {
@@ -501,12 +503,12 @@ SaveTool::drawDecalEditor(Decal& decal) {
}
void
-SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView style_view) {
+Application::drawAccessoryEditor(GameObjects::Accessory& accessory, Containers::ArrayView style_view) {
if(accessory.id < 1) {
ImGui::TextUnformatted("Accessory: ");
}
- else if(accessories.find(accessory.id) != accessories.cend()) {
- ImGui::Text("Accessory #%.4i - %s", accessory.id, accessories.at(accessory.id).name.data());
+ else if(GameData::accessories.find(accessory.id) != GameData::accessories.cend()) {
+ ImGui::Text("Accessory #%.4i - %s", accessory.id, GameData::accessories.at(accessory.id).name.data());
}
else {
ImGui::Text("Accessory #%i", accessory.id);
@@ -516,7 +518,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView size = Containers::NullOpt;
+ static Containers::Optional size = Containers::NullOpt;
if(ImGui::SmallButton("Change")) {
ImGui::OpenPopup("##AccessoryPopup");
if(accessory.id >= 3000) {
@@ -574,45 +576,45 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView= tab * 1000 && acc.first < ((tab + 1) * 1000) && (!size || *size == acc.second.size)) {
if(ImGui::Selectable(Utility::format("#{:.4d} - {} ({})", acc.first, acc.second.name, size_labels[acc.second.size]).data(),
acc.first == accessory.id))
@@ -658,7 +660,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView view) {
+Application::getStyleName(std::int32_t id, Containers::ArrayView view) {
if(id >= 0 && id <= 15) {
return view[id].name;
}
@@ -748,6 +750,8 @@ SaveTool::getStyleName(std::int32_t id, Containers::ArrayView view)
return _currentMass->globalStyles()[id - 50].name;
}
else {
- return style_names.at(id);
+ return GameData::style_names.at(id);
}
}
+
+}
diff --git a/src/SaveTool/SaveTool_MassViewer_Armour.cpp b/src/Application/Application_MassViewer_Armour.cpp
similarity index 88%
rename from src/SaveTool/SaveTool_MassViewer_Armour.cpp
rename to src/Application/Application_MassViewer_Armour.cpp
index 2733a78..769dcc3 100644
--- a/src/SaveTool/SaveTool_MassViewer_Armour.cpp
+++ b/src/Application/Application_MassViewer_Armour.cpp
@@ -19,11 +19,13 @@
#include "../Maps/ArmourSets.h"
#include "../Maps/StyleNames.h"
-#include "SaveTool.h"
+#include "Application.h"
+
+namespace mbst {
void
-SaveTool::drawArmour() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawArmour() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
}
@@ -52,11 +54,17 @@ 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[std::uint32_t(part.slot)].data(), armour_sets.at(part.id).name.data(), std::uint32_t(part.slot));
+ if(GameData::armour_sets.find(part.id) != GameData::armour_sets.cend()) {
+ std::snprintf(header, 128, "%s: %s###%u",
+ slot_labels[std::uint32_t(part.slot)].data(),
+ GameData::armour_sets.at(part.id).name.data(),
+ std::uint32_t(part.slot));
}
else {
- std::snprintf(header, 128, "%s: %i###%u", slot_labels[std::uint32_t(part.slot)].data(), part.id, std::uint32_t(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)) {
@@ -65,14 +73,14 @@ SaveTool::drawArmour() {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.491f);
if(ImGui::BeginListBox("##ChangePart")) {
if(std::strncmp("Neck", slot_labels[std::uint32_t(part.slot)].data(), 4) != 0) {
- for(auto& set : armour_sets) {
+ for(auto& set : GameData::armour_sets) {
if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) {
part.id = set.first;
}
}
}
else {
- for(auto& set : armour_sets) {
+ for(auto& set : GameData::armour_sets) {
if(!set.second.neck_compatible) {
continue;
}
@@ -106,7 +114,7 @@ SaveTool::drawArmour() {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - 2.0f);
if(ImGui::BeginCombo("##Style", getStyleName(part.styles[j], _currentMass->armourCustomStyles()).data())) {
- for(const auto& style : style_names) {
+ for(const auto& style : GameData::style_names) {
if(ImGui::Selectable(getStyleName(style.first, _currentMass->armourCustomStyles()).data(), part.styles[j] == style.first)) {
part.styles[j] = style.first;
}
@@ -164,19 +172,19 @@ SaveTool::drawArmour() {
ImGui::PopID();
}
- if(_currentMass->bulletLauncherAttachmentStyle() != BulletLauncherAttachmentStyle::NotFound &&
+ if(_currentMass->bulletLauncherAttachmentStyle() != GameObjects::BulletLauncherAttachmentStyle::NotFound &&
ImGui::CollapsingHeader("Bullet launcher placement"))
{
drawAlignedText("Attachment style:"_s);
ImGui::SameLine();
ImGui::RadioButton("Active one",
- _currentMass->bulletLauncherAttachmentStyle() == BulletLauncherAttachmentStyle::ActiveOne);
+ _currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::ActiveOne);
ImGui::SameLine();
ImGui::RadioButton("Active one per slot",
- _currentMass->bulletLauncherAttachmentStyle() == BulletLauncherAttachmentStyle::ActiveOnePerSlot);
+ _currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::ActiveOnePerSlot);
ImGui::SameLine();
ImGui::RadioButton("All equipped",
- _currentMass->bulletLauncherAttachmentStyle() == BulletLauncherAttachmentStyle::AllEquipped);
+ _currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::AllEquipped);
ImGui::Separator();
@@ -203,13 +211,13 @@ SaveTool::drawArmour() {
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(i);
+ placement.socket = static_cast(i);
}
}
ImGui::EndCombo();
}
- if(placement.socket != BulletLauncherSocket::Auto) {
+ if(placement.socket != GameObjects::BulletLauncherAttachment::Socket::Auto) {
ImGui::BeginGroup();
drawAlignedText("Relative position:");
drawAlignedText("Offset position:");
@@ -290,8 +298,8 @@ SaveTool::drawArmour() {
}
void
-SaveTool::drawCustomArmourStyles() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawCustomArmourStyles() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
}
@@ -325,3 +333,5 @@ SaveTool::drawCustomArmourStyles() {
ImGui::EndChild();
}
+
+}
diff --git a/src/SaveTool/SaveTool_MassViewer_Frame.cpp b/src/Application/Application_MassViewer_Frame.cpp
similarity index 93%
rename from src/SaveTool/SaveTool_MassViewer_Frame.cpp
rename to src/Application/Application_MassViewer_Frame.cpp
index 7b93155..445b561 100644
--- a/src/SaveTool/SaveTool_MassViewer_Frame.cpp
+++ b/src/Application/Application_MassViewer_Frame.cpp
@@ -17,11 +17,13 @@
#include "../FontAwesome/IconsFontAwesome5.h"
#include "../Maps/StyleNames.h"
-#include "SaveTool.h"
+#include "Application.h"
+
+namespace mbst {
void
-SaveTool::drawFrameInfo() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawFrameInfo() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
}
@@ -81,8 +83,8 @@ SaveTool::drawFrameInfo() {
}
void
-SaveTool::drawJointSliders() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawJointSliders() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
}
@@ -204,8 +206,8 @@ SaveTool::drawJointSliders() {
}
void
-SaveTool::drawFrameStyles() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawFrameStyles() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
}
@@ -217,7 +219,7 @@ SaveTool::drawFrameStyles() {
ImGui::PushID(i);
if(ImGui::BeginCombo("##Style", getStyleName(_currentMass->frameStyles()[i], _currentMass->frameCustomStyles()).data())) {
- for(const auto& style : style_names) {
+ for(const auto& style : GameData::style_names) {
if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()).data(), _currentMass->frameStyles()[i] == style.first)) {
_currentMass->frameStyles()[i] = style.first;
_stylesDirty = true;
@@ -255,8 +257,8 @@ SaveTool::drawFrameStyles() {
}
void
-SaveTool::drawEyeColourPicker() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawEyeColourPicker() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
}
@@ -289,8 +291,8 @@ SaveTool::drawEyeColourPicker() {
}
void
-SaveTool::drawCustomFrameStyles() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawCustomFrameStyles() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
}
@@ -324,3 +326,5 @@ SaveTool::drawCustomFrameStyles() {
ImGui::EndChild();
}
+
+}
diff --git a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp b/src/Application/Application_MassViewer_Weapons.cpp
similarity index 79%
rename from src/SaveTool/SaveTool_MassViewer_Weapons.cpp
rename to src/Application/Application_MassViewer_Weapons.cpp
index c60cdc9..6f56390 100644
--- a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp
+++ b/src/Application/Application_MassViewer_Weapons.cpp
@@ -19,11 +19,13 @@
#include "../Maps/StyleNames.h"
#include "../Maps/WeaponParts.h"
-#include "SaveTool.h"
+#include "Application.h"
+
+namespace mbst {
void
-SaveTool::drawWeapons() {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
+Application::drawWeapons() {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
_currentWeapon = nullptr;
return;
}
@@ -179,37 +181,37 @@ SaveTool::drawWeapons() {
if(drawUnsafeWidget([](){ return ImGui::Button(ICON_FA_SAVE " Save changes to weapon category"); })) {
_modifiedBySaveTool = true;
switch(_currentWeapon->type) {
- case WeaponType::Melee:
+ case GameObjects::Weapon::Type::Melee:
if(!_currentMass->writeMeleeWeapons()) {
_modifiedBySaveTool = false;
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
}
break;
- case WeaponType::Shield:
+ case GameObjects::Weapon::Type::Shield:
if(!_currentMass->writeShields()) {
_modifiedBySaveTool = false;
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
}
break;
- case WeaponType::BulletShooter:
+ case GameObjects::Weapon::Type::BulletShooter:
if(!_currentMass->writeBulletShooters()) {
_modifiedBySaveTool = false;
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
}
break;
- case WeaponType::EnergyShooter:
+ case GameObjects::Weapon::Type::EnergyShooter:
if(!_currentMass->writeEnergyShooters()) {
_modifiedBySaveTool = false;
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
}
break;
- case WeaponType::BulletLauncher:
+ case GameObjects::Weapon::Type::BulletLauncher:
if(!_currentMass->writeBulletLaunchers()) {
_modifiedBySaveTool = false;
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
}
break;
- case WeaponType::EnergyLauncher:
+ case GameObjects::Weapon::Type::EnergyLauncher:
if(!_currentMass->writeEnergyLaunchers()) {
_modifiedBySaveTool = false;
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
@@ -225,22 +227,22 @@ SaveTool::drawWeapons() {
if(ImGui::Button(ICON_FA_UNDO_ALT " Reset weapon category")) {
switch(_currentWeapon->type) {
- case WeaponType::Melee:
+ case GameObjects::Weapon::Type::Melee:
_currentMass->getMeleeWeapons();
break;
- case WeaponType::Shield:
+ case GameObjects::Weapon::Type::Shield:
_currentMass->getShields();
break;
- case WeaponType::BulletShooter:
+ case GameObjects::Weapon::Type::BulletShooter:
_currentMass->getBulletShooters();
break;
- case WeaponType::EnergyShooter:
+ case GameObjects::Weapon::Type::EnergyShooter:
_currentMass->getEnergyShooters();
break;
- case WeaponType::BulletLauncher:
+ case GameObjects::Weapon::Type::BulletLauncher:
_currentMass->getBulletLaunchers();
break;
- case WeaponType::EnergyLauncher:
+ case GameObjects::Weapon::Type::EnergyLauncher:
_currentMass->getEnergyLaunchers();
break;
default:
@@ -252,7 +254,7 @@ SaveTool::drawWeapons() {
}
void
-SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view, bool& dirty,
+Application::drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view, bool& dirty,
Containers::StringView payload_type, Containers::StringView payload_tooltip)
{
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
@@ -316,8 +318,8 @@ SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<
}
void
-SaveTool::drawWeaponEditor(Weapon& weapon) {
- if(!_currentMass || _currentMass->state() != Mass::State::Valid || !_currentWeapon) {
+Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
+ if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid || !_currentWeapon) {
return;
}
@@ -346,11 +348,11 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::BeginGroup();
drawAlignedText("Equipped:");
- if(weapon.type != WeaponType::Shield) {
+ if(weapon.type != GameObjects::Weapon::Type::Shield) {
drawAlignedText("Damage type:");
}
- if(weapon.type == WeaponType::Melee) {
+ if(weapon.type == GameObjects::Weapon::Type::Melee) {
drawAlignedText("Dual-wield:");
drawAlignedText("Custom effect mode:");
@@ -364,48 +366,48 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::BeginGroup();
ImGui::Checkbox("##EquippedCheckbox", &weapon.attached);
- if(weapon.type != WeaponType::Shield) {
- if(weapon.type == WeaponType::Melee &&
- ImGui::RadioButton("Physical##NoElement", weapon.damageType == DamageType::Physical))
+ if(weapon.type != GameObjects::Weapon::Type::Shield) {
+ if(weapon.type == GameObjects::Weapon::Type::Melee &&
+ ImGui::RadioButton("Physical##NoElement", weapon.damageType == GameObjects::Weapon::DamageType::Physical))
{
- weapon.damageType = DamageType::Physical;
+ weapon.damageType = GameObjects::Weapon::DamageType::Physical;
}
- else if((weapon.type == WeaponType::BulletShooter || weapon.type == WeaponType::BulletLauncher) &&
- ImGui::RadioButton("Piercing##NoElement", weapon.damageType == DamageType::Piercing))
+ else if((weapon.type == GameObjects::Weapon::Type::BulletShooter || weapon.type == GameObjects::Weapon::Type::BulletLauncher) &&
+ ImGui::RadioButton("Piercing##NoElement", weapon.damageType == GameObjects::Weapon::DamageType::Piercing))
{
- weapon.damageType = DamageType::Piercing;
+ weapon.damageType = GameObjects::Weapon::DamageType::Piercing;
}
- else if((weapon.type == WeaponType::EnergyShooter || weapon.type == WeaponType::EnergyLauncher) &&
- ImGui::RadioButton("Plasma##NoElement", weapon.damageType == DamageType::Plasma))
+ else if((weapon.type == GameObjects::Weapon::Type::EnergyShooter || weapon.type == GameObjects::Weapon::Type::EnergyLauncher) &&
+ ImGui::RadioButton("Plasma##NoElement", weapon.damageType == GameObjects::Weapon::DamageType::Plasma))
{
- weapon.damageType = DamageType::Plasma;
+ weapon.damageType = GameObjects::Weapon::DamageType::Plasma;
}
ImGui::SameLine();
- if(ImGui::RadioButton("Heat##Heat", weapon.damageType == DamageType::Heat)) {
- weapon.damageType = DamageType::Heat;
+ if(ImGui::RadioButton("Heat##Heat", weapon.damageType == GameObjects::Weapon::DamageType::Heat)) {
+ weapon.damageType = GameObjects::Weapon::DamageType::Heat;
}
ImGui::SameLine();
- if(ImGui::RadioButton("Freeze##Freeze", weapon.damageType == DamageType::Freeze)) {
- weapon.damageType = DamageType::Freeze;
+ if(ImGui::RadioButton("Freeze##Freeze", weapon.damageType == GameObjects::Weapon::DamageType::Freeze)) {
+ weapon.damageType = GameObjects::Weapon::DamageType::Freeze;
}
ImGui::SameLine();
- if(ImGui::RadioButton("Shock##Shock", weapon.damageType == DamageType::Shock)) {
- weapon.damageType = DamageType::Shock;
+ if(ImGui::RadioButton("Shock##Shock", weapon.damageType == GameObjects::Weapon::DamageType::Shock)) {
+ weapon.damageType = GameObjects::Weapon::DamageType::Shock;
}
}
- if(weapon.type == WeaponType::Melee) {
+ if(weapon.type == GameObjects::Weapon::Type::Melee) {
ImGui::Checkbox("##DualWield", &weapon.dualWield);
- if(ImGui::RadioButton("Default##Default", weapon.effectColourMode == EffectColourMode::Default)) {
- weapon.effectColourMode = EffectColourMode::Default;
+ if(ImGui::RadioButton("Default##Default", weapon.effectColourMode == GameObjects::Weapon::EffectColourMode::Default)) {
+ weapon.effectColourMode = GameObjects::Weapon::EffectColourMode::Default;
}
ImGui::SameLine();
- if(ImGui::RadioButton("Custom##Custom", weapon.effectColourMode == EffectColourMode::Custom)) {
- weapon.effectColourMode = EffectColourMode::Custom;
+ if(ImGui::RadioButton("Custom##Custom", weapon.effectColourMode == GameObjects::Weapon::EffectColourMode::Custom)) {
+ weapon.effectColourMode = GameObjects::Weapon::EffectColourMode::Custom;
}
- bool custom_effect = (weapon.effectColourMode == EffectColourMode::Custom);
+ bool custom_effect = (weapon.effectColourMode == GameObjects::Weapon::EffectColourMode::Custom);
if(!custom_effect) {
ImGui::BeginDisabled();
}
@@ -436,18 +438,18 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
const auto* map = [this, &weapon]()-> const std::map* {
switch(weapon.type) {
- case WeaponType::Melee:
- return _selectedWeaponPart == 0 ? &melee_grips : &melee_assaulters;
- case WeaponType::Shield:
- return _selectedWeaponPart == 0 ? &shield_handles : &shield_shells;
- case WeaponType::BulletShooter:
- return _selectedWeaponPart == 0 ? &bshooter_triggers : &bshooter_barrels;
- case WeaponType::EnergyShooter:
- return _selectedWeaponPart == 0 ? &eshooter_triggers : &eshooter_busters;
- case WeaponType::BulletLauncher:
- return _selectedWeaponPart == 0 ? &blauncher_pods : &blauncher_projectiles;
- case WeaponType::EnergyLauncher:
- return _selectedWeaponPart == 0 ? &elauncher_generators : &elauncher_pods;
+ case GameObjects::Weapon::Type::Melee:
+ return _selectedWeaponPart == 0 ? &GameData::melee_grips : &GameData::melee_assaulters;
+ case GameObjects::Weapon::Type::Shield:
+ return _selectedWeaponPart == 0 ? &GameData::shield_handles : &GameData::shield_shells;
+ case GameObjects::Weapon::Type::BulletShooter:
+ return _selectedWeaponPart == 0 ? &GameData::bshooter_triggers : &GameData::bshooter_barrels;
+ case GameObjects::Weapon::Type::EnergyShooter:
+ return _selectedWeaponPart == 0 ? &GameData::eshooter_triggers : &GameData::eshooter_busters;
+ case GameObjects::Weapon::Type::BulletLauncher:
+ return _selectedWeaponPart == 0 ? &GameData::blauncher_pods : &GameData::blauncher_projectiles;
+ case GameObjects::Weapon::Type::EnergyLauncher:
+ return _selectedWeaponPart == 0 ? &GameData::elauncher_generators : &GameData::elauncher_pods;
}
return nullptr;
@@ -489,14 +491,14 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
}
}
- if(weapon.type == WeaponType::Shield ||
- (weapon.type == WeaponType::BulletLauncher && _selectedWeaponPart != 0))
+ if(weapon.type == GameObjects::Weapon::Type::Shield ||
+ (weapon.type == GameObjects::Weapon::Type::BulletLauncher && _selectedWeaponPart != 0))
{
ImGui::SameLine();
if(ImGui::SmallButton("Unequip")) {
part.id = -1;
}
- if(weapon.type == WeaponType::Shield && _selectedWeaponPart == 0) {
+ if(weapon.type == GameObjects::Weapon::Type::Shield && _selectedWeaponPart == 0) {
drawTooltip("This will make the whole shield and its accessories invisible.");
}
else {
@@ -515,7 +517,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::PushID(i);
if(ImGui::BeginCombo("##Style", getStyleName(part.styles[i], weapon.customStyles).data())) {
- for(const auto& style: style_names) {
+ for(const auto& style: GameData::style_names) {
if(ImGui::Selectable(getStyleName(style.first, weapon.customStyles).data(),
part.styles[i] == style.first)) {
part.styles[i] = style.first;
@@ -562,3 +564,5 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::EndChild();
}
}
+
+}
diff --git a/src/SaveTool/SaveTool_ProfileManager.cpp b/src/Application/Application_ProfileManager.cpp
similarity index 97%
rename from src/SaveTool/SaveTool_ProfileManager.cpp
rename to src/Application/Application_ProfileManager.cpp
index cdeb37e..548a096 100644
--- a/src/SaveTool/SaveTool_ProfileManager.cpp
+++ b/src/Application/Application_ProfileManager.cpp
@@ -20,12 +20,14 @@
#include "../FontAwesome/IconsFontAwesome5.h"
-#include "SaveTool.h"
+#include "Application.h"
extern const ImVec2 center_pivot;
+namespace mbst {
+
void
-SaveTool::drawProfileManager() {
+Application::drawProfileManager() {
static std::size_t profile_index = 0;
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot);
@@ -81,7 +83,7 @@ SaveTool::drawProfileManager() {
ImGui::TextUnformatted("Actions");
for(std::size_t i = 0; i < _profileManager->profiles().size(); ++i) {
- Profile& profile = _profileManager->profiles()[i];
+ GameObjects::Profile& profile = _profileManager->profiles()[i];
ImGui::TableNextRow();
@@ -127,7 +129,7 @@ SaveTool::drawProfileManager() {
}
ImGuiID
-SaveTool::drawBackupListPopup() {
+Application::drawBackupListPopup() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot);
if(!ImGui::BeginPopupModal("Backups##BackupsModal", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
@@ -283,7 +285,7 @@ SaveTool::drawBackupListPopup() {
backup.timestamp.second);
ImGui::TableSetColumnIndex(2);
- ImGui::TextUnformatted(backup.type == ProfileType::Demo ? "Demo" : "Full");
+ ImGui::TextUnformatted(backup.demo ? "Demo" : "Full");
ImGui::TableSetColumnIndex(3);
ImGui::PushID(int(i));
@@ -327,7 +329,7 @@ SaveTool::drawBackupListPopup() {
}
ImGuiID
-SaveTool::drawBackupProfilePopup(std::size_t profile_index) {
+Application::drawBackupProfilePopup(std::size_t profile_index) {
if(!ImGui::BeginPopupModal("Include builds ?##IncludeBuildsDialog", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{
@@ -372,7 +374,7 @@ SaveTool::drawBackupProfilePopup(std::size_t profile_index) {
}
ImGuiID
-SaveTool::drawDeleteProfilePopup(std::size_t profile_index) {
+Application::drawDeleteProfilePopup(std::size_t profile_index) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteProfileConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{
@@ -417,3 +419,5 @@ SaveTool::drawDeleteProfilePopup(std::size_t profile_index) {
return 0;
}
+
+}
diff --git a/src/SaveTool/SaveTool_UpdateChecker.cpp b/src/Application/Application_UpdateChecker.cpp
similarity index 96%
rename from src/SaveTool/SaveTool_UpdateChecker.cpp
rename to src/Application/Application_UpdateChecker.cpp
index 4492f75..6fe63c1 100644
--- a/src/SaveTool/SaveTool_UpdateChecker.cpp
+++ b/src/Application/Application_UpdateChecker.cpp
@@ -20,10 +20,12 @@
#include "../Logger/Logger.h"
-#include "SaveTool.h"
+#include "Application.h"
+
+namespace mbst {
void
-SaveTool::updateCheckEvent(SDL_Event& event) {
+Application::updateCheckEvent(SDL_Event& event) {
_updateThread.join();
switch(static_cast(event.user.code)) {
@@ -72,7 +74,7 @@ SaveTool::updateCheckEvent(SDL_Event& event) {
}
void
-SaveTool::checkForUpdates() {
+Application::checkForUpdates() {
SDL_Event event;
SDL_zero(event);
event.type = _updateEventId;
@@ -89,3 +91,5 @@ SaveTool::checkForUpdates() {
SDL_PushEvent(&event);
}
+
+}
diff --git a/src/SaveTool/SaveTool_drawAbout.cpp b/src/Application/Application_drawAbout.cpp
similarity index 98%
rename from src/SaveTool/SaveTool_drawAbout.cpp
rename to src/Application/Application_drawAbout.cpp
index 1598e35..c68472d 100644
--- a/src/SaveTool/SaveTool_drawAbout.cpp
+++ b/src/Application/Application_drawAbout.cpp
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-#include "SaveTool.h"
-
#include
#include
@@ -29,10 +27,14 @@
#include "../FontAwesome/IconsFontAwesome5.h"
#include "../FontAwesome/IconsFontAwesome5Brands.h"
+#include "Application.h"
+
extern const ImVec2 center_pivot;
+namespace mbst {
+
void
-SaveTool::drawAbout() {
+Application::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);
@@ -60,7 +62,7 @@ SaveTool::drawAbout() {
ImGui::TextWrapped("This application, made for the M.A.S.S. Builder community by Guillaume Jacquemin (aka William JCM), "
"is a rewrite of the wxWidgets-powered M.A.S.S. Builder Save Tool (formerly known as wxMASSManager).");
- auto website = "https://williamjcm.ovh/coding/mbst";
+ auto website = "https://williamjcm.ovh/mbst";
drawAlignedText(ICON_FA_GLOBE " %s", website);
ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) {
@@ -267,3 +269,5 @@ SaveTool::drawAbout() {
ImGui::EndPopup();
}
+
+}
diff --git a/src/SaveTool/SaveTool_drawMainMenu.cpp b/src/Application/Application_drawMainMenu.cpp
similarity index 99%
rename from src/SaveTool/SaveTool_drawMainMenu.cpp
rename to src/Application/Application_drawMainMenu.cpp
index 46d930e..290e8cd 100644
--- a/src/SaveTool/SaveTool_drawMainMenu.cpp
+++ b/src/Application/Application_drawMainMenu.cpp
@@ -20,10 +20,12 @@
#include "../FontAwesome/IconsFontAwesome5.h"
#include "../FontAwesome/IconsFontAwesome5Brands.h"
-#include "SaveTool.h"
+#include "Application.h"
+
+namespace mbst {
void
-SaveTool::drawMainMenu() {
+Application::drawMainMenu() {
if(!ImGui::BeginMainMenuBar()) {
return;
}
@@ -239,3 +241,5 @@ SaveTool::drawMainMenu() {
ImGui::EndMainMenuBar();
}
+
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index eebfbe4..f72df89 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -37,7 +37,7 @@ set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
corrade_add_resource(Assets assets.conf)
add_subdirectory(Logger EXCLUDE_FROM_ALL)
-add_subdirectory(UESaveFile EXCLUDE_FROM_ALL)
+add_subdirectory(Gvas EXCLUDE_FROM_ALL)
if(CORRADE_TARGET_WINDOWS)
set(SAVETOOL_RC_FILE resource.rc)
@@ -45,19 +45,19 @@ endif()
add_executable(MassBuilderSaveTool
main.cpp
- SaveTool/SaveTool.h
- SaveTool/SaveTool.cpp
- SaveTool/SaveTool_drawAbout.cpp
- SaveTool/SaveTool_drawMainMenu.cpp
- SaveTool/SaveTool_FileWatcher.cpp
- SaveTool/SaveTool_Initialisation.cpp
- SaveTool/SaveTool_MainManager.cpp
- SaveTool/SaveTool_MassViewer.cpp
- SaveTool/SaveTool_MassViewer_Frame.cpp
- SaveTool/SaveTool_MassViewer_Armour.cpp
- SaveTool/SaveTool_MassViewer_Weapons.cpp
- SaveTool/SaveTool_ProfileManager.cpp
- SaveTool/SaveTool_UpdateChecker.cpp
+ Application/Application.h
+ Application/Application.cpp
+ Application/Application_drawAbout.cpp
+ Application/Application_drawMainMenu.cpp
+ Application/Application_FileWatcher.cpp
+ Application/Application_Initialisation.cpp
+ Application/Application_MainManager.cpp
+ Application/Application_MassViewer.cpp
+ Application/Application_MassViewer_Frame.cpp
+ Application/Application_MassViewer_Armour.cpp
+ Application/Application_MassViewer_Weapons.cpp
+ Application/Application_ProfileManager.cpp
+ Application/Application_UpdateChecker.cpp
Configuration/Configuration.h
Configuration/Configuration.cpp
ProfileManager/ProfileManager.h
@@ -102,7 +102,9 @@ add_executable(MassBuilderSaveTool
UpdateChecker/UpdateChecker.h
UpdateChecker/UpdateChecker.cpp
Utilities/Crc32.h
+ Utilities/Crc32.cpp
Version/Version.h
+ Version/Version.cpp
FontAwesome/IconsFontAwesome5.h
FontAwesome/IconsFontAwesome5Brands.h
${SAVETOOL_RC_FILE}
@@ -145,7 +147,7 @@ target_link_libraries(MassBuilderSaveTool PRIVATE
Magnum::Sdl2Application
MagnumIntegration::ImGui
Logger
- UESaveFile
+ Gvas
CURL::libcurl_static
)
diff --git a/src/Configuration/Configuration.cpp b/src/Configuration/Configuration.cpp
index 12c5555..038b5c8 100644
--- a/src/Configuration/Configuration.cpp
+++ b/src/Configuration/Configuration.cpp
@@ -20,6 +20,8 @@
#include "Configuration.h"
+namespace mbst {
+
Configuration::Configuration() {
Containers::String exe_path = Utility::Path::split(*Utility::Path::executableLocation()).first();
_conf = Utility::Configuration{Utility::Path::join(exe_path, "MassBuilderSaveTool.ini")};
@@ -174,3 +176,5 @@ Configuration&
conf() {
return Configuration::instance();
}
+
+}
diff --git a/src/Configuration/Configuration.h b/src/Configuration/Configuration.h
index a685e30..c3be643 100644
--- a/src/Configuration/Configuration.h
+++ b/src/Configuration/Configuration.h
@@ -20,18 +20,20 @@
using namespace Corrade;
+namespace mbst {
+
class Configuration {
public:
- static Configuration& instance();
+ static auto instance() -> Configuration&;
~Configuration();
void save();
- int swapInterval() const;
+ auto swapInterval() const -> int;
void setSwapInterval(int interval);
- float fpsCap() const;
+ auto fpsCap() const -> float;
void setFpsCap(float cap);
bool cheatMode() const;
@@ -54,14 +56,16 @@ class Configuration {
Utility::Configuration _conf;
- int _swapInterval = 1;
+ int _swapInterval = 1;
float _fpsCap = 60.0f;
- bool _cheatMode = false;
- bool _advancedMode = false;
- bool _checkUpdatesOnStartup = true;
- bool _skipDisclaimer = false;
+ bool _cheatMode = false;
+ bool _advancedMode = false;
+ bool _checkUpdatesOnStartup = true;
+ bool _skipDisclaimer = false;
bool _isRunningInWine = false;
};
Configuration& conf();
+
+}
diff --git a/src/UESaveFile/BinaryReader.cpp b/src/Gvas/BinaryReader.cpp
similarity index 99%
rename from src/UESaveFile/BinaryReader.cpp
rename to src/Gvas/BinaryReader.cpp
index 131607d..91e69c8 100644
--- a/src/UESaveFile/BinaryReader.cpp
+++ b/src/Gvas/BinaryReader.cpp
@@ -23,6 +23,8 @@
#include "BinaryReader.h"
+namespace Gvas {
+
BinaryReader::BinaryReader(Containers::StringView filename) {
_file = std::fopen(filename.data(), "rb");
@@ -144,3 +146,5 @@ BinaryReader::peekChar() {
std::ungetc(c, _file);
return c;
}
+
+}
diff --git a/src/UESaveFile/BinaryReader.h b/src/Gvas/BinaryReader.h
similarity index 95%
rename from src/UESaveFile/BinaryReader.h
rename to src/Gvas/BinaryReader.h
index e04d711..d6c9d36 100644
--- a/src/UESaveFile/BinaryReader.h
+++ b/src/Gvas/BinaryReader.h
@@ -25,6 +25,8 @@
using namespace Corrade;
+namespace Gvas {
+
class BinaryReader {
public:
explicit BinaryReader(Containers::StringView filename);
@@ -32,7 +34,7 @@ class BinaryReader {
bool open();
bool eof();
- std::int64_t position();
+ auto position() -> std::int64_t;
bool seek(std::int64_t position);
@@ -63,8 +65,10 @@ class BinaryReader {
bool readUEString(Containers::String& str);
- std::int32_t peekChar();
+ auto peekChar() -> std::int32_t;
private:
std::FILE* _file = nullptr;
};
+
+}
diff --git a/src/UESaveFile/BinaryWriter.cpp b/src/Gvas/BinaryWriter.cpp
similarity index 99%
rename from src/UESaveFile/BinaryWriter.cpp
rename to src/Gvas/BinaryWriter.cpp
index ab0ebba..05a04e0 100644
--- a/src/UESaveFile/BinaryWriter.cpp
+++ b/src/Gvas/BinaryWriter.cpp
@@ -22,6 +22,8 @@
using namespace Containers::Literals;
+namespace Gvas {
+
BinaryWriter::BinaryWriter(Containers::StringView filename) {
_file = std::fopen(filename.data(), "wb");
if(!_file) {
@@ -157,3 +159,5 @@ BinaryWriter::writeUEStringToArray(Containers::StringView value) {
writeDataToArray(Containers::ArrayView{value}) +
writeValueToArray('\0');
}
+
+}
diff --git a/src/UESaveFile/BinaryWriter.h b/src/Gvas/BinaryWriter.h
similarity index 89%
rename from src/UESaveFile/BinaryWriter.h
rename to src/Gvas/BinaryWriter.h
index 3c11eed..7dfceba 100644
--- a/src/UESaveFile/BinaryWriter.h
+++ b/src/Gvas/BinaryWriter.h
@@ -26,6 +26,8 @@
using namespace Corrade;
+namespace Gvas {
+
class BinaryWriter {
public:
explicit BinaryWriter(Containers::StringView filename);
@@ -41,10 +43,10 @@ class BinaryWriter {
void closeFile();
- std::int64_t position();
+ auto position() -> std::int64_t;
- Containers::ArrayView array() const;
- std::size_t arrayPosition() const;
+ auto array() const -> Containers::ArrayView;
+ auto arrayPosition() const -> std::size_t;
bool flushToFile();
bool writeChar(char value);
@@ -72,12 +74,12 @@ class BinaryWriter {
bool writeUEString(Containers::StringView str);
template::value, T, T&>>
- std::size_t writeValueToArray(U value) {
+ auto writeValueToArray(U value) -> std::size_t {
Containers::ArrayView view{&value, 1};
return writeDataToArray(view);
}
- std::size_t writeUEStringToArray(Containers::StringView value);
+ auto writeUEStringToArray(Containers::StringView value) -> std::size_t;
template
void writeValueToArrayAt(T& value, std::size_t position) {
@@ -86,7 +88,7 @@ class BinaryWriter {
}
template
- std::size_t writeDataToArray(Containers::ArrayView view) {
+ auto writeDataToArray(Containers::ArrayView view) -> std::size_t {
arrayAppend(_data, Containers::arrayCast(view));
_index += sizeof(T) * view.size();
return sizeof(T) * view.size();
@@ -106,3 +108,5 @@ class BinaryWriter {
Containers::Array _data;
std::size_t _index = 0;
};
+
+}
diff --git a/src/Gvas/CMakeLists.txt b/src/Gvas/CMakeLists.txt
new file mode 100644
index 0000000..c635c3c
--- /dev/null
+++ b/src/Gvas/CMakeLists.txt
@@ -0,0 +1,102 @@
+# MassBuilderSaveTool
+# Copyright (C) 2021-2023 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 .
+
+add_library(Gvas STATIC EXCLUDE_FROM_ALL
+ Serialisers/Serialisers.h
+ Serialisers/AbstractUnrealCollectionProperty.h
+ Serialisers/AbstractUnrealProperty.h
+ Serialisers/AbstractUnrealStruct.h
+ Serialisers/ArrayProperty.h
+ Serialisers/ArrayProperty.cpp
+ Serialisers/BoolProperty.h
+ Serialisers/BoolProperty.cpp
+ Serialisers/ByteProperty.h
+ Serialisers/ByteProperty.cpp
+ Serialisers/ColourProperty.h
+ Serialisers/ColourProperty.cpp
+ Serialisers/DateTimeProperty.h
+ Serialisers/DateTimeProperty.cpp
+ Serialisers/EnumProperty.h
+ Serialisers/EnumProperty.cpp
+ Serialisers/FloatProperty.h
+ Serialisers/FloatProperty.cpp
+ Serialisers/GuidProperty.h
+ Serialisers/GuidProperty.cpp
+ Serialisers/IntProperty.h
+ Serialisers/IntProperty.cpp
+ Serialisers/MapProperty.h
+ Serialisers/MapProperty.cpp
+ Serialisers/ResourceProperty.h
+ Serialisers/ResourceProperty.cpp
+ Serialisers/RotatorProperty.h
+ Serialisers/RotatorProperty.cpp
+ Serialisers/StringProperty.h
+ Serialisers/StringProperty.cpp
+ Serialisers/SetProperty.h
+ Serialisers/SetProperty.cpp
+ Serialisers/Struct.h
+ Serialisers/Struct.cpp
+ Serialisers/TextProperty.h
+ Serialisers/TextProperty.cpp
+ Serialisers/UnrealProperty.h
+ Serialisers/VectorProperty.h
+ Serialisers/VectorProperty.cpp
+ Serialisers/Vector2DProperty.h
+ Serialisers/Vector2DProperty.cpp
+
+ Types/Types.h
+ Types/ArrayProperty.h
+ Types/BoolProperty.h
+ Types/ByteProperty.h
+ Types/ColourStructProperty.h
+ Types/DateTimeStructProperty.h
+ Types/EnumProperty.h
+ Types/FloatProperty.h
+ Types/GenericStructProperty.h
+ Types/GuidStructProperty.h
+ Types/IntProperty.h
+ Types/MapProperty.h
+ Types/NoneProperty.h
+ Types/RotatorStructProperty.h
+ Types/SetProperty.h
+ Types/StringProperty.h
+ Types/StructProperty.h
+ Types/ResourceItemValue.h
+ Types/TextProperty.h
+ Types/UnrealProperty.h
+ Types/UnrealPropertyBase.h
+ Types/Vector2DStructProperty.h
+ Types/VectorStructProperty.h
+
+ Gvas.h
+ Debug.h
+ Debug.cpp
+ File.h
+ File.cpp
+ BinaryReader.h
+ BinaryReader.cpp
+ BinaryWriter.h
+ BinaryWriter.cpp
+ PropertySerialiser.h
+ PropertySerialiser.cpp
+)
+
+target_link_libraries(Gvas PRIVATE
+ Corrade::Containers
+ Corrade::Utility
+ Magnum::Magnum
+ Logger
+)
diff --git a/src/UESaveFile/Debug.cpp b/src/Gvas/Debug.cpp
similarity index 77%
rename from src/UESaveFile/Debug.cpp
rename to src/Gvas/Debug.cpp
index 050fa4c..56f2141 100644
--- a/src/UESaveFile/Debug.cpp
+++ b/src/Gvas/Debug.cpp
@@ -23,19 +23,19 @@
#include "Debug.h"
Utility::Debug&
-operator<<(Utility::Debug& debug, const ArrayProperty* prop) {
+operator<<(Utility::Debug& debug, const Gvas::Types::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) {
+operator<<(Utility::Debug& debug, const Gvas::Types::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) {
+operator<<(Utility::Debug& debug, const Gvas::Types::GenericStructProperty* prop) {
debug << (*prop->name) << Utility::Debug::nospace << ":" <<
prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace <<
") Contents:";
@@ -46,8 +46,8 @@ operator<<(Utility::Debug& debug, const GenericStructProperty* prop) {
}
Utility::Debug&
-operator<<(Utility::Debug& debug, const StructProperty* prop) {
- auto cast = dynamic_cast(prop);
+operator<<(Utility::Debug& debug, const Gvas::Types::StructProperty* prop) {
+ auto cast = dynamic_cast(prop);
if(cast) {
return debug << cast;
}
@@ -57,21 +57,21 @@ operator<<(Utility::Debug& debug, const StructProperty* prop) {
}
Utility::Debug&
-operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop) {
+operator<<(Utility::Debug& debug, const Gvas::Types::UnrealPropertyBase* prop) {
if(prop->propertyType == "ArrayProperty") {
- auto array_prop = dynamic_cast(prop);
+ auto array_prop = dynamic_cast(prop);
if(array_prop) {
return debug << array_prop;
}
}
else if(prop->propertyType == "SetProperty") {
- auto set_prop = dynamic_cast(prop);
+ auto set_prop = dynamic_cast(prop);
if(set_prop) {
return debug << set_prop;
}
}
else if(prop->propertyType == "StructProperty") {
- auto struct_prop = dynamic_cast(prop);
+ auto struct_prop = dynamic_cast(prop);
if(struct_prop) {
return debug << struct_prop;
}
diff --git a/src/Gvas/Debug.h b/src/Gvas/Debug.h
new file mode 100644
index 0000000..55dacd2
--- /dev/null
+++ b/src/Gvas/Debug.h
@@ -0,0 +1,29 @@
+#pragma once
+
+// MassBuilderSaveTool
+// Copyright (C) 2021-2023 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 .
+
+#include
+
+#include "Types/Types.h"
+
+using namespace Corrade;
+
+Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::ArrayProperty* prop);
+Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::SetProperty* prop);
+Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::GenericStructProperty* prop);
+Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::StructProperty* prop);
+Utility::Debug& operator<<(Utility::Debug& debug, const Gvas::Types::UnrealPropertyBase* prop);
diff --git a/src/UESaveFile/UESaveFile.cpp b/src/Gvas/File.cpp
similarity index 93%
rename from src/UESaveFile/UESaveFile.cpp
rename to src/Gvas/File.cpp
index af44e10..c9b9d24 100644
--- a/src/UESaveFile/UESaveFile.cpp
+++ b/src/Gvas/File.cpp
@@ -17,15 +17,18 @@
#include
#include
-#include "BinaryReader.h"
-#include "BinaryWriter.h"
#include "../Logger/Logger.h"
-#include "UESaveFile.h"
+#include "BinaryReader.h"
+#include "BinaryWriter.h"
+
+#include "File.h"
using namespace Containers::Literals;
-UESaveFile::UESaveFile(Containers::String filepath):
+namespace Gvas {
+
+File::File(Containers::String filepath):
_propSerialiser{PropertySerialiser::instance()}
{
_filepath = std::move(filepath);
@@ -34,46 +37,46 @@ UESaveFile::UESaveFile(Containers::String filepath):
}
bool
-UESaveFile::valid() const {
+File::valid() const {
return _valid;
}
Containers::StringView
-UESaveFile::lastError() const {
+File::lastError() const {
return _lastError;
}
bool
-UESaveFile::reloadData() {
+File::reloadData() {
if(_noReloadAfterSave) {
_noReloadAfterSave = false;
return valid();
}
- _properties = Containers::Array{};
+ _properties = Containers::Array{};
loadData();
return valid();
}
Containers::StringView
-UESaveFile::saveType() {
+File::saveType() {
return _saveType;
}
void
-UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) {
+File::appendProperty(Types::UnrealPropertyBase::ptr prop) {
auto none_prop = std::move(_properties.back());
_properties.back() = std::move(prop);
arrayAppend(_properties, std::move(none_prop));
}
-Containers::ArrayView
-UESaveFile::props() {
+Containers::ArrayView
+File::props() {
return _properties;
}
bool
-UESaveFile::saveToFile() {
+File::saveToFile() {
LOG_INFO_FORMAT("Writing to {}.", _filepath);
bool temp_file = _filepath.hasSuffix(".tmp");
@@ -161,7 +164,7 @@ UESaveFile::saveToFile() {
}
void
-UESaveFile::loadData() {
+File::loadData() {
LOG_INFO_FORMAT("Reading data from {}.", _filepath);
_valid = false;
@@ -244,7 +247,7 @@ UESaveFile::loadData() {
return;
}
- UnrealPropertyBase::ptr prop;
+ Types::UnrealPropertyBase::ptr prop;
while((prop = _propSerialiser->read(reader)) != nullptr) {
arrayAppend(_properties, std::move(prop));
}
@@ -265,3 +268,5 @@ UESaveFile::loadData() {
_valid = true;
}
+
+}
diff --git a/src/UESaveFile/UESaveFile.h b/src/Gvas/File.h
similarity index 83%
rename from src/UESaveFile/UESaveFile.h
rename to src/Gvas/File.h
index 7aa72f2..0af071c 100644
--- a/src/UESaveFile/UESaveFile.h
+++ b/src/Gvas/File.h
@@ -29,19 +29,21 @@
using namespace Corrade;
-class UESaveFile {
+namespace Gvas {
+
+class File {
public:
- explicit UESaveFile(Containers::String filepath);
+ explicit File(Containers::String filepath);
bool valid() const;
- Containers::StringView lastError() const;
+ auto lastError() const -> Containers::StringView;
bool reloadData();
- Containers::StringView saveType();
+ auto saveType() -> Containers::StringView;
template
- std::enable_if_t::value, T*>
+ std::enable_if_t::value, T*>
at(Containers::StringView name) {
for(auto& prop : _properties) {
if(prop->name == name) {
@@ -51,9 +53,9 @@ class UESaveFile {
return nullptr;
}
- void appendProperty(UnrealPropertyBase::ptr prop);
+ void appendProperty(Types::UnrealPropertyBase::ptr prop);
- Containers::ArrayView props();
+ auto props() -> Containers::ArrayView;
bool saveToFile();
@@ -88,7 +90,9 @@ class UESaveFile {
Containers::String _saveType;
- Containers::Array _properties;
+ Containers::Array _properties;
Containers::Reference _propSerialiser;
};
+
+}
diff --git a/src/Gvas/Gvas.h b/src/Gvas/Gvas.h
new file mode 100644
index 0000000..fad929c
--- /dev/null
+++ b/src/Gvas/Gvas.h
@@ -0,0 +1,26 @@
+#pragma once
+
+// MassBuilderSaveTool
+// Copyright (C) 2021-2023 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 .
+
+namespace Gvas {
+
+class BinaryReader;
+class BinaryWriter;
+class File;
+class PropertySerialiser;
+
+}
diff --git a/src/UESaveFile/PropertySerialiser.cpp b/src/Gvas/PropertySerialiser.cpp
similarity index 64%
rename from src/UESaveFile/PropertySerialiser.cpp
rename to src/Gvas/PropertySerialiser.cpp
index 1e89498..2aa5c10 100644
--- a/src/UESaveFile/PropertySerialiser.cpp
+++ b/src/Gvas/PropertySerialiser.cpp
@@ -16,55 +16,57 @@
#include
-#include "Serialisers/ArrayPropertySerialiser.h"
-#include "Serialisers/BoolPropertySerialiser.h"
-#include "Serialisers/BytePropertySerialiser.h"
-#include "Serialisers/ColourPropertySerialiser.h"
-#include "Serialisers/DateTimePropertySerialiser.h"
-#include "Serialisers/EnumPropertySerialiser.h"
-#include "Serialisers/FloatPropertySerialiser.h"
-#include "Serialisers/GuidPropertySerialiser.h"
-#include "Serialisers/IntPropertySerialiser.h"
-#include "Serialisers/MapPropertySerialiser.h"
-#include "Serialisers/ResourcePropertySerialiser.h"
-#include "Serialisers/RotatorPropertySerialiser.h"
-#include "Serialisers/StringPropertySerialiser.h"
-#include "Serialisers/SetPropertySerialiser.h"
-#include "Serialisers/StructSerialiser.h"
-#include "Serialisers/TextPropertySerialiser.h"
-#include "Serialisers/VectorPropertySerialiser.h"
-#include "Serialisers/Vector2DPropertySerialiser.h"
+#include "../Logger/Logger.h"
+
+#include "Serialisers/ArrayProperty.h"
+#include "Serialisers/BoolProperty.h"
+#include "Serialisers/ByteProperty.h"
+#include "Serialisers/ColourProperty.h"
+#include "Serialisers/DateTimeProperty.h"
+#include "Serialisers/EnumProperty.h"
+#include "Serialisers/FloatProperty.h"
+#include "Serialisers/GuidProperty.h"
+#include "Serialisers/IntProperty.h"
+#include "Serialisers/MapProperty.h"
+#include "Serialisers/ResourceProperty.h"
+#include "Serialisers/RotatorProperty.h"
+#include "Serialisers/StringProperty.h"
+#include "Serialisers/SetProperty.h"
+#include "Serialisers/Struct.h"
+#include "Serialisers/TextProperty.h"
+#include "Serialisers/VectorProperty.h"
+#include "Serialisers/Vector2DProperty.h"
#include "Types/NoneProperty.h"
#include "BinaryReader.h"
#include "BinaryWriter.h"
-#include "../Logger/Logger.h"
-
#include "PropertySerialiser.h"
-PropertySerialiser::PropertySerialiser() {
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
- arrayAppend(_serialisers, Containers::pointer());
+namespace Gvas {
- arrayAppend(_collectionSerialisers, Containers::pointer());
+PropertySerialiser::PropertySerialiser() {
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+ arrayAppend(_serialisers, Containers::pointer());
+
+ arrayAppend(_collectionSerialisers, Containers::pointer());
}
PropertySerialiser&
@@ -73,7 +75,7 @@ PropertySerialiser::instance() {
return serialiser;
}
-UnrealPropertyBase::ptr
+Types::UnrealPropertyBase::ptr
PropertySerialiser::read(BinaryReader& reader) {
if(reader.peekChar() < 0 || reader.eof()) {
return nullptr;
@@ -85,7 +87,7 @@ PropertySerialiser::read(BinaryReader& reader) {
}
if(name == "None") {
- return Containers::pointer();
+ return Containers::pointer();
}
Containers::String type;
@@ -101,7 +103,7 @@ PropertySerialiser::read(BinaryReader& reader) {
return deserialise(std::move(name), std::move(type), value_length, reader);
}
-UnrealPropertyBase::ptr
+Types::UnrealPropertyBase::ptr
PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, std::size_t value_length,
Containers::String name)
{
@@ -112,7 +114,7 @@ PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, std:
return deserialise(std::move(name), std::move(type), value_length, reader);
}
-Containers::Array
+Containers::Array
PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, std::uint32_t count) {
if(reader.peekChar() < 0 || reader.eof()) {
return nullptr;
@@ -120,7 +122,7 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty
auto serialiser = getCollectionSerialiser(item_type);
- Containers::Array array;
+ Containers::Array array;
if(serialiser) {
Containers::String name;
@@ -156,11 +158,11 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty
return array;
}
-UnrealPropertyBase::ptr
+Types::UnrealPropertyBase::ptr
PropertySerialiser::deserialise(Containers::String name, Containers::String type, std::size_t value_length,
BinaryReader& reader)
{
- UnrealPropertyBase::ptr prop;
+ Types::UnrealPropertyBase::ptr prop;
auto serialiser = getSerialiser(type);
if(serialiser == nullptr) {
@@ -180,7 +182,7 @@ PropertySerialiser::deserialise(Containers::String name, Containers::String type
return prop;
}
-bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
+bool PropertySerialiser::serialise(Types::UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
std::size_t& bytes_written, BinaryWriter& writer)
{
auto serialiser = getSerialiser(item_type);
@@ -191,8 +193,8 @@ bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St
}
bool
-PropertySerialiser::write(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer) {
- if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) {
+PropertySerialiser::write(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer) {
+ if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) {
bytes_written += writer.writeUEStringToArray(*prop->name);
return true;
}
@@ -215,10 +217,10 @@ PropertySerialiser::write(UnrealPropertyBase::ptr& prop, std::size_t& bytes_writ
}
bool
-PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
+PropertySerialiser::writeItem(Types::UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
std::size_t& bytes_written, BinaryWriter& writer)
{
- if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) {
+ if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) {
bytes_written += writer.writeUEStringToArray(*prop->name);
return true;
}
@@ -226,7 +228,7 @@ PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringV
return serialise(prop, item_type, bytes_written, writer);
}
-bool PropertySerialiser::writeSet(Containers::ArrayView props,
+bool PropertySerialiser::writeSet(Containers::ArrayView props,
Containers::StringView item_type, std::size_t& bytes_written, BinaryWriter& writer)
{
auto serialiser = getCollectionSerialiser(item_type);
@@ -244,7 +246,7 @@ bool PropertySerialiser::writeSet(Containers::ArrayView
}
}
-AbstractUnrealPropertySerialiser*
+Serialisers::AbstractUnrealProperty*
PropertySerialiser::getSerialiser(Containers::StringView item_type) {
for(auto& item : _serialisers) {
for(auto serialiser_type : item->types()) {
@@ -257,7 +259,7 @@ PropertySerialiser::getSerialiser(Containers::StringView item_type) {
return nullptr;
}
-AbstractUnrealCollectionPropertySerialiser*
+Serialisers::AbstractUnrealCollectionProperty*
PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) {
for(auto& item : _collectionSerialisers) {
for(Containers::StringView serialiser_type : item->types()) {
@@ -269,3 +271,5 @@ PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) {
return nullptr;
}
+
+}
diff --git a/src/Gvas/PropertySerialiser.h b/src/Gvas/PropertySerialiser.h
new file mode 100644
index 0000000..79889d9
--- /dev/null
+++ b/src/Gvas/PropertySerialiser.h
@@ -0,0 +1,64 @@
+#pragma once
+
+// MassBuilderSaveTool
+// Copyright (C) 2021-2023 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 .
+
+#include
+#include
+#include
+
+#include "Serialisers/AbstractUnrealProperty.h"
+#include "Serialisers/AbstractUnrealCollectionProperty.h"
+
+#include "Types/UnrealPropertyBase.h"
+
+#include "Gvas.h"
+
+using namespace Corrade;
+
+namespace Gvas {
+
+class PropertySerialiser {
+ public:
+ static auto instance() -> PropertySerialiser&;
+
+ auto read(BinaryReader& reader) -> Types::UnrealPropertyBase::ptr;
+ auto readItem(BinaryReader& reader, Containers::String type, std::size_t value_length, Containers::String name)
+ -> Types::UnrealPropertyBase::ptr;
+ auto readSet(BinaryReader& reader, Containers::StringView item_type, std::uint32_t count)
+ -> Containers::Array;
+ auto deserialise(Containers::String name, Containers::String type, std::size_t value_length,
+ BinaryReader& reader) -> Types::UnrealPropertyBase::ptr;
+
+ bool serialise(Types::UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
+ std::size_t& bytes_written, BinaryWriter& writer);
+ bool write(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer);
+ bool writeItem(Types::UnrealPropertyBase::ptr& prop, Containers::StringView item_type,
+ std::size_t& bytes_written, BinaryWriter& writer);
+ bool writeSet(Containers::ArrayView props, Containers::StringView item_type,
+ std::size_t& bytes_written, BinaryWriter& writer);
+
+ private:
+ PropertySerialiser();
+
+ auto getSerialiser(Containers::StringView item_type) -> Serialisers::AbstractUnrealProperty*;
+ auto getCollectionSerialiser(Containers::StringView item_type) -> Serialisers::AbstractUnrealCollectionProperty*;
+
+ Containers::Array _serialisers;
+ Containers::Array _collectionSerialisers;
+};
+
+}
diff --git a/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h b/src/Gvas/Serialisers/AbstractUnrealCollectionProperty.h
similarity index 58%
rename from src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h
rename to src/Gvas/Serialisers/AbstractUnrealCollectionProperty.h
index 4a974ab..8d7a390 100644
--- a/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h
+++ b/src/Gvas/Serialisers/AbstractUnrealCollectionProperty.h
@@ -21,29 +21,31 @@
#include
#include
+#include "../Gvas.h"
#include "../Types/UnrealPropertyBase.h"
using namespace Corrade;
-class BinaryReader;
-class BinaryWriter;
-class PropertySerialiser;
+namespace Gvas { namespace Serialisers {
-using PropertyArray = Containers::Array;
-using PropertyArrayView = Containers::ArrayView;
+using PropertyArray = Containers::Array;
+using PropertyArrayView = Containers::ArrayView;
+using StringArrayView = Containers::ArrayView;
-class AbstractUnrealCollectionPropertySerialiser {
+class AbstractUnrealCollectionProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
- virtual ~AbstractUnrealCollectionPropertySerialiser() = default;
+ virtual ~AbstractUnrealCollectionProperty() = default;
- virtual StringArrayView types() = 0;
+ virtual auto types() -> StringArrayView = 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 deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser)
+ -> PropertyArray = 0;
- virtual bool serialise(Containers::ArrayView props, Containers::StringView item_type,
+ virtual bool serialise(PropertyArrayView props, Containers::StringView item_type,
std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) = 0;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h b/src/Gvas/Serialisers/AbstractUnrealProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h
rename to src/Gvas/Serialisers/AbstractUnrealProperty.h
index 6b2e615..11c8359 100644
--- a/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h
+++ b/src/Gvas/Serialisers/AbstractUnrealProperty.h
@@ -20,28 +20,30 @@
#include
#include
+#include "../Gvas.h"
#include "../Types/UnrealPropertyBase.h"
using namespace Corrade;
-class BinaryReader;
-class BinaryWriter;
-class PropertySerialiser;
+
+namespace Gvas { namespace Serialisers {
using StringArrayView = Containers::ArrayView;
-class AbstractUnrealPropertySerialiser {
+class AbstractUnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
- virtual ~AbstractUnrealPropertySerialiser() = default;
+ virtual ~AbstractUnrealProperty() = default;
- virtual StringArrayView types() = 0;
+ virtual auto types() -> StringArrayView = 0;
- virtual UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser) = 0;
+ virtual auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr = 0;
- virtual bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ virtual bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) = 0;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h b/src/Gvas/Serialisers/AbstractUnrealStruct.h
similarity index 69%
rename from src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h
rename to src/Gvas/Serialisers/AbstractUnrealStruct.h
index 57e79d7..e08dfc9 100644
--- a/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h
+++ b/src/Gvas/Serialisers/AbstractUnrealStruct.h
@@ -21,22 +21,25 @@
#include
#include
+#include "../Gvas.h"
#include "../Types/UnrealPropertyBase.h"
using namespace Corrade;
-class BinaryReader;
-class BinaryWriter;
+namespace Gvas { namespace Serialisers {
-class AbstractUnrealStructSerialiser {
+class AbstractUnrealStruct {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
- virtual ~AbstractUnrealStructSerialiser() = default;
+ virtual ~AbstractUnrealStruct() = default;
virtual bool supportsType(Containers::StringView type) = 0;
- virtual UnrealPropertyBase::ptr deserialise(BinaryReader& reader) = 0;
+ virtual auto deserialise(BinaryReader& reader) -> Types::UnrealPropertyBase::ptr = 0;
- virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, std::size_t& bytes_written) = 0;
+ virtual bool serialise(Types::UnrealPropertyBase::ptr& structProp, BinaryWriter& writer,
+ std::size_t& bytes_written) = 0;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp b/src/Gvas/Serialisers/ArrayProperty.cpp
similarity index 77%
rename from src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp
rename to src/Gvas/Serialisers/ArrayProperty.cpp
index ed412af..83829ae 100644
--- a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/ArrayProperty.cpp
@@ -21,12 +21,13 @@
#include "../PropertySerialiser.h"
#include "../../Logger/Logger.h"
-#include "ArrayPropertySerialiser.h"
+#include "ArrayProperty.h"
-UnrealPropertyBase::ptr
-ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser)
+namespace Gvas { namespace Serialisers {
+
+Types::UnrealPropertyBase::ptr
+ArrayProperty::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)) {
@@ -46,7 +47,7 @@ ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Contai
return nullptr;
}
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
prop->itemType = std::move(item_type);
prop->items = serialiser.readSet(reader, prop->itemType, item_count);
@@ -54,10 +55,10 @@ ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Contai
}
bool
-ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
- BinaryWriter& writer, PropertySerialiser& serialiser)
+ArrayProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ PropertySerialiser& serialiser)
{
- auto array_prop = dynamic_cast(prop.get());
+ auto array_prop = dynamic_cast(prop.get());
if(!array_prop) {
LOG_ERROR("The property is not a valid array property.");
return false;
@@ -74,3 +75,5 @@ ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::s
return ret;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h b/src/Gvas/Serialisers/ArrayProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/ArrayPropertySerialiser.h
rename to src/Gvas/Serialisers/ArrayProperty.h
index 6f6b741..6f50b95 100644
--- a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h
+++ b/src/Gvas/Serialisers/ArrayProperty.h
@@ -18,20 +18,24 @@
#include
-#include "UnrealPropertySerialiser.h"
-
+#include "../Gvas.h"
+#include "UnrealProperty.h"
#include "../Types/ArrayProperty.h"
using namespace Corrade;
-class ArrayPropertySerialiser : public UnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class ArrayProperty : public UnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
private:
- 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,
+ auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
+ bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp b/src/Gvas/Serialisers/BoolProperty.cpp
similarity index 74%
rename from src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp
rename to src/Gvas/Serialisers/BoolProperty.cpp
index 8e2c1ea..c67e6ec 100644
--- a/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/BoolProperty.cpp
@@ -18,18 +18,20 @@
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
-#include "BoolPropertySerialiser.h"
+#include "BoolProperty.h"
+
+namespace Gvas { namespace Serialisers {
StringArrayView
-BoolPropertySerialiser::types() {
+BoolProperty::types() {
using namespace Containers::Literals;
static const Containers::Array types{InPlaceInit, {"BoolProperty"_s}};
return types;
}
-UnrealPropertyBase::ptr
-BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
- BinaryReader& reader, PropertySerialiser& serialiser)
+Types::UnrealPropertyBase::ptr
+BoolProperty::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);
@@ -47,17 +49,17 @@ BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::Str
return nullptr;
}
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
prop->value = value;
return prop;
}
bool
-BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
- PropertySerialiser& serialiser)
+BoolProperty::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ PropertySerialiser& serialiser)
{
- auto bool_prop = dynamic_cast(prop.get());
+ auto bool_prop = dynamic_cast(prop.get());
if(!bool_prop) {
LOG_ERROR("The property is not a valid bool property.");
return false;
@@ -67,3 +69,5 @@ BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& by
return true;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/BoolPropertySerialiser.h b/src/Gvas/Serialisers/BoolProperty.h
similarity index 61%
rename from src/UESaveFile/Serialisers/BoolPropertySerialiser.h
rename to src/Gvas/Serialisers/BoolProperty.h
index 6e41afc..58171e4 100644
--- a/src/UESaveFile/Serialisers/BoolPropertySerialiser.h
+++ b/src/Gvas/Serialisers/BoolProperty.h
@@ -19,22 +19,26 @@
#include
#include
-#include "AbstractUnrealPropertySerialiser.h"
+#include "AbstractUnrealProperty.h"
#include "../Types/BoolProperty.h"
using namespace Corrade;
-class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class BoolProperty : public AbstractUnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
- StringArrayView types() override;
+ auto types() -> StringArrayView override;
- UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser) override;
+ auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
- bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp b/src/Gvas/Serialisers/ByteProperty.cpp
similarity index 82%
rename from src/UESaveFile/Serialisers/BytePropertySerialiser.cpp
rename to src/Gvas/Serialisers/ByteProperty.cpp
index 45b7934..1463798 100644
--- a/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/ByteProperty.cpp
@@ -18,20 +18,22 @@
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
-#include "BytePropertySerialiser.h"
+#include "ByteProperty.h"
+
+namespace Gvas { namespace Serialisers {
StringArrayView
-BytePropertySerialiser::types() {
+ByteProperty::types() {
using namespace Containers::Literals;
static const Containers::Array types{InPlaceInit, {"ByteProperty"_s}};
return types;
}
-UnrealPropertyBase::ptr
-BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+Types::UnrealPropertyBase::ptr
+ByteProperty::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
BinaryReader& reader, PropertySerialiser& serialiser)
{
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
if(value_length != std::size_t(-1)) {
if(!reader.readUEString(prop->enumType)) {
@@ -66,10 +68,10 @@ BytePropertySerialiser::deserialise(Containers::StringView name, Containers::Str
}
bool
-BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
- PropertySerialiser& serialiser)
+ByteProperty::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ PropertySerialiser& serialiser)
{
- auto byte_prop = dynamic_cast(prop.get());
+ auto byte_prop = dynamic_cast(prop.get());
if(!byte_prop) {
LOG_ERROR("The property is not a valid byte property.");
return false;
@@ -88,3 +90,5 @@ BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& by
return true;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/BytePropertySerialiser.h b/src/Gvas/Serialisers/ByteProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/BytePropertySerialiser.h
rename to src/Gvas/Serialisers/ByteProperty.h
index fb2b2d4..adb4201 100644
--- a/src/UESaveFile/Serialisers/BytePropertySerialiser.h
+++ b/src/Gvas/Serialisers/ByteProperty.h
@@ -19,20 +19,24 @@
#include
#include
-#include "AbstractUnrealPropertySerialiser.h"
+#include "AbstractUnrealProperty.h"
#include "../Types/ByteProperty.h"
-class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class ByteProperty : public AbstractUnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
- StringArrayView types() override;
+ auto types() -> StringArrayView override;
- UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser) override;
+ auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
- bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp b/src/Gvas/Serialisers/ColourProperty.cpp
similarity index 69%
rename from src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp
rename to src/Gvas/Serialisers/ColourProperty.cpp
index 9e5cd9a..1af0ea1 100644
--- a/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/ColourProperty.cpp
@@ -18,14 +18,15 @@
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
-#include "ColourPropertySerialiser.h"
+#include "ColourProperty.h"
-UnrealPropertyBase::ptr
-ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser)
+namespace Gvas { namespace Serialisers {
+
+Types::UnrealPropertyBase::ptr
+ColourProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
{
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
if(!reader.readFloat(prop->r) || !reader.readFloat(prop->g) ||
!reader.readFloat(prop->b) || !reader.readFloat(prop->a))
@@ -38,10 +39,10 @@ ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Conta
}
bool
-ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
- BinaryWriter& writer, PropertySerialiser& serialiser)
+ColourProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
+ BinaryWriter& writer, PropertySerialiser& serialiser)
{
- auto colour_prop = dynamic_cast(prop.get());
+ auto colour_prop = dynamic_cast(prop.get());
if(!colour_prop) {
LOG_ERROR("The property is not a valid colour property.");
return false;
@@ -54,3 +55,5 @@ ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::
return true;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/ColourPropertySerialiser.h b/src/Gvas/Serialisers/ColourProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/ColourPropertySerialiser.h
rename to src/Gvas/Serialisers/ColourProperty.h
index 812f7a9..173c6f2 100644
--- a/src/UESaveFile/Serialisers/ColourPropertySerialiser.h
+++ b/src/Gvas/Serialisers/ColourProperty.h
@@ -18,20 +18,24 @@
#include
-#include "UnrealPropertySerialiser.h"
+#include "UnrealProperty.h"
#include "../Types/ColourStructProperty.h"
using namespace Corrade;
-class ColourPropertySerialiser : public UnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class ColourProperty : public UnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
private:
- 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,
+ auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
+ bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp b/src/Gvas/Serialisers/DateTimeProperty.cpp
similarity index 64%
rename from src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp
rename to src/Gvas/Serialisers/DateTimeProperty.cpp
index 9724dfb..1be9685 100644
--- a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/DateTimeProperty.cpp
@@ -18,14 +18,15 @@
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
-#include "DateTimePropertySerialiser.h"
+#include "DateTimeProperty.h"
-UnrealPropertyBase::ptr
-DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser)
+namespace Gvas { namespace Serialisers {
+
+Types::UnrealPropertyBase::ptr
+DateTimeProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type,
+ std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser)
{
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
if(!reader.readInt64(prop->timestamp)) {
LOG_ERROR_FORMAT("Couldn't read date/time property {}'s value.", name);
@@ -36,10 +37,10 @@ DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Con
}
bool
-DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
- BinaryWriter& writer, PropertySerialiser& serialiser)
+DateTimeProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
+ BinaryWriter& writer, PropertySerialiser& serialiser)
{
- auto dt_prop = dynamic_cast(prop.get());
+ auto dt_prop = dynamic_cast(prop.get());
if(!dt_prop) {
LOG_ERROR("The property is not a valid date/time property.");
return false;
@@ -49,3 +50,5 @@ DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std
return true;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h b/src/Gvas/Serialisers/DateTimeProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/DateTimePropertySerialiser.h
rename to src/Gvas/Serialisers/DateTimeProperty.h
index 68f2476..ca604a2 100644
--- a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h
+++ b/src/Gvas/Serialisers/DateTimeProperty.h
@@ -18,18 +18,22 @@
#include
-#include "UnrealPropertySerialiser.h"
+#include "UnrealProperty.h"
#include "../Types/DateTimeStructProperty.h"
-class DateTimePropertySerialiser : public UnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class DateTimeProperty : public UnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
private:
- 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,
+ auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
+ bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp b/src/Gvas/Serialisers/EnumProperty.cpp
similarity index 74%
rename from src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp
rename to src/Gvas/Serialisers/EnumProperty.cpp
index f7e1246..4e8125a 100644
--- a/src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/EnumProperty.cpp
@@ -18,20 +18,22 @@
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
-#include "EnumPropertySerialiser.h"
+#include "EnumProperty.h"
+
+namespace Gvas { namespace Serialisers {
StringArrayView
-EnumPropertySerialiser::types() {
+EnumProperty::types() {
using namespace Containers::Literals;
static const Containers::Array types{InPlaceInit, {"EnumProperty"_s}};
return types;
}
-UnrealPropertyBase::ptr
-EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
- BinaryReader& reader, PropertySerialiser& serialiser)
+Types::UnrealPropertyBase::ptr
+EnumProperty::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
{
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
if(!reader.readUEString(prop->enumType)) {
LOG_ERROR_FORMAT("Couldn't read enum property {}'s enum type.", name);
@@ -53,10 +55,10 @@ EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::Str
}
bool
-EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
- PropertySerialiser& serialiser)
+EnumProperty::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ PropertySerialiser& serialiser)
{
- auto enum_prop = dynamic_cast(prop.get());
+ auto enum_prop = dynamic_cast(prop.get());
if(!enum_prop) {
LOG_ERROR("The property is not a valid enum property.");
return false;
@@ -68,3 +70,5 @@ EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& by
return true;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/EnumPropertySerialiser.h b/src/Gvas/Serialisers/EnumProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/EnumPropertySerialiser.h
rename to src/Gvas/Serialisers/EnumProperty.h
index 077eeae..be1ade7 100644
--- a/src/UESaveFile/Serialisers/EnumPropertySerialiser.h
+++ b/src/Gvas/Serialisers/EnumProperty.h
@@ -19,20 +19,24 @@
#include
#include
-#include "AbstractUnrealPropertySerialiser.h"
+#include "AbstractUnrealProperty.h"
#include "../Types/EnumProperty.h"
-class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class EnumProperty : public AbstractUnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
- StringArrayView types() override;
+ auto types() -> StringArrayView override;
- UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser) override;
+ auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
- bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp b/src/Gvas/Serialisers/FloatProperty.cpp
similarity index 72%
rename from src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp
rename to src/Gvas/Serialisers/FloatProperty.cpp
index d643ca0..e3cf14c 100644
--- a/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/FloatProperty.cpp
@@ -18,20 +18,22 @@
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
-#include "FloatPropertySerialiser.h"
+#include "FloatProperty.h"
+
+namespace Gvas { namespace Serialisers {
StringArrayView
-FloatPropertySerialiser::types() {
+FloatProperty::types() {
using namespace Containers::Literals;
static const Containers::Array types{InPlaceInit, {"FloatProperty"_s}};
return types;
}
-UnrealPropertyBase::ptr
-FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser)
+Types::UnrealPropertyBase::ptr
+FloatProperty::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
{
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
@@ -48,10 +50,10 @@ FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::St
}
bool
-FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
- PropertySerialiser& serialiser)
+FloatProperty::serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ PropertySerialiser& serialiser)
{
- auto float_prop = dynamic_cast(prop.get());
+ auto float_prop = dynamic_cast(prop.get());
if(!float_prop) {
LOG_ERROR("The property is not a valid float property.");
return false;
@@ -62,3 +64,5 @@ FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& b
return true;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/FloatPropertySerialiser.h b/src/Gvas/Serialisers/FloatProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/FloatPropertySerialiser.h
rename to src/Gvas/Serialisers/FloatProperty.h
index 9aa8ee9..bde9188 100644
--- a/src/UESaveFile/Serialisers/FloatPropertySerialiser.h
+++ b/src/Gvas/Serialisers/FloatProperty.h
@@ -19,20 +19,24 @@
#include
#include
-#include "AbstractUnrealPropertySerialiser.h"
+#include "AbstractUnrealProperty.h"
#include "../Types/FloatProperty.h"
-class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class FloatProperty : public AbstractUnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
- StringArrayView types() override;
+ auto types() -> StringArrayView override;
- UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser) override;
+ auto deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
- bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ bool serialise(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp b/src/Gvas/Serialisers/GuidProperty.cpp
similarity index 62%
rename from src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp
rename to src/Gvas/Serialisers/GuidProperty.cpp
index 46715b6..ff173b8 100644
--- a/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/GuidProperty.cpp
@@ -18,16 +18,17 @@
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
-#include "GuidPropertySerialiser.h"
+#include "GuidProperty.h"
using namespace Containers::Literals;
-UnrealPropertyBase::ptr
-GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser)
+namespace Gvas { namespace Serialisers {
+
+Types::UnrealPropertyBase::ptr
+GuidProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
{
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
if(!reader.readStaticArray(prop->guid)) {
LOG_ERROR_FORMAT("Couldn't read GUID property {}'s value.", name);
@@ -38,12 +39,12 @@ GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain
}
bool
-GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
- BinaryWriter& writer, PropertySerialiser& serialiser)
+GuidProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ PropertySerialiser& serialiser)
{
- auto guid_prop = dynamic_cast(prop.get());
+ auto guid_prop = dynamic_cast(prop.get());
if(!guid_prop) {
- LOG_ERROR("The property is not a valid byte property.");
+ LOG_ERROR("The property is not a valid GUID property.");
return false;
}
@@ -51,3 +52,5 @@ GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::si
return true;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/GuidPropertySerialiser.h b/src/Gvas/Serialisers/GuidProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/GuidPropertySerialiser.h
rename to src/Gvas/Serialisers/GuidProperty.h
index 1a2a7c4..8de587c 100644
--- a/src/UESaveFile/Serialisers/GuidPropertySerialiser.h
+++ b/src/Gvas/Serialisers/GuidProperty.h
@@ -18,18 +18,22 @@
#include
-#include "UnrealPropertySerialiser.h"
+#include "UnrealProperty.h"
#include "../Types/GuidStructProperty.h"
-class GuidPropertySerialiser : public UnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class GuidProperty : public UnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
private:
- 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,
+ auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
+ bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/IntPropertySerialiser.cpp b/src/Gvas/Serialisers/IntProperty.cpp
similarity index 73%
rename from src/UESaveFile/Serialisers/IntPropertySerialiser.cpp
rename to src/Gvas/Serialisers/IntProperty.cpp
index 76a8443..94f51d7 100644
--- a/src/UESaveFile/Serialisers/IntPropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/IntProperty.cpp
@@ -18,14 +18,15 @@
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
-#include "IntPropertySerialiser.h"
+#include "IntProperty.h"
-UnrealPropertyBase::ptr
-IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser)
+namespace Gvas { namespace Serialisers {
+
+Types::UnrealPropertyBase::ptr
+IntProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
{
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
if(value_length == std::size_t(-1)) {
if(!reader.readInt32(prop->value)) {
@@ -54,10 +55,10 @@ IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
}
bool
-IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
- BinaryWriter& writer, PropertySerialiser& serialiser)
+IntProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ PropertySerialiser& serialiser)
{
- auto int_prop = dynamic_cast(prop.get());
+ auto int_prop = dynamic_cast(prop.get());
if(!int_prop) {
LOG_ERROR("The property is not a valid int property.");
return false;
@@ -71,3 +72,5 @@ IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::siz
return true;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/IntPropertySerialiser.h b/src/Gvas/Serialisers/IntProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/IntPropertySerialiser.h
rename to src/Gvas/Serialisers/IntProperty.h
index 4cf7c93..777d625 100644
--- a/src/UESaveFile/Serialisers/IntPropertySerialiser.h
+++ b/src/Gvas/Serialisers/IntProperty.h
@@ -18,18 +18,22 @@
#include
-#include "UnrealPropertySerialiser.h"
+#include "UnrealProperty.h"
#include "../Types/IntProperty.h"
-class IntPropertySerialiser : public UnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class IntProperty : public UnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
private:
- 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,
+ auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
+ bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp b/src/Gvas/Serialisers/MapProperty.cpp
similarity index 85%
rename from src/UESaveFile/Serialisers/MapPropertySerialiser.cpp
rename to src/Gvas/Serialisers/MapProperty.cpp
index b2f9057..7893447 100644
--- a/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/MapProperty.cpp
@@ -20,16 +20,17 @@
#include "../Types/NoneProperty.h"
#include "../../Logger/Logger.h"
-#include "MapPropertySerialiser.h"
+#include "MapProperty.h"
using namespace Containers::Literals;
-UnrealPropertyBase::ptr
-MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser)
+namespace Gvas { namespace Serialisers {
+
+Types::UnrealPropertyBase::ptr
+MapProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
{
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
if(!reader.readUEString(prop->keyType)) {
LOG_ERROR_FORMAT("Couldn't read map property {}'s key type.", name);
@@ -65,7 +66,7 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
arrayReserve(prop->map, count);
for(std::uint32_t i = 0; i < count; i++) {
- MapProperty::KeyValuePair pair;
+ Types::MapProperty::KeyValuePair pair;
if(prop->keyType == "IntProperty"_s || prop->keyType == "StrProperty"_s) {
pair.key = serialiser.readItem(reader, prop->keyType, -1, name);
@@ -79,14 +80,14 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
return nullptr;
}
- UnrealPropertyBase::ptr value_item;
+ Types::UnrealPropertyBase::ptr value_item;
if(prop->valueType == "StructProperty"_s) {
while((value_item = serialiser.read(reader)) != nullptr) {
arrayAppend(pair.values, std::move(value_item));
if(pair.values.back()->name == "None"_s &&
pair.values.back()->propertyType == "NoneProperty"_s &&
- dynamic_cast(pair.values.back().get()) != nullptr)
+ dynamic_cast(pair.values.back().get()) != nullptr)
{
break;
}
@@ -109,10 +110,10 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
}
bool
-MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
- BinaryWriter& writer, PropertySerialiser& serialiser)
+MapProperty::serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
+ PropertySerialiser& serialiser)
{
- auto map_prop = dynamic_cast(prop.get());
+ auto map_prop = dynamic_cast(prop.get());
if(!map_prop) {
LOG_ERROR("The property is not a valid map property.");
return false;
@@ -154,3 +155,5 @@ MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::siz
return true;
}
+
+}}
diff --git a/src/UESaveFile/Serialisers/MapPropertySerialiser.h b/src/Gvas/Serialisers/MapProperty.h
similarity index 60%
rename from src/UESaveFile/Serialisers/MapPropertySerialiser.h
rename to src/Gvas/Serialisers/MapProperty.h
index 0b59b4d..f992653 100644
--- a/src/UESaveFile/Serialisers/MapPropertySerialiser.h
+++ b/src/Gvas/Serialisers/MapProperty.h
@@ -18,18 +18,22 @@
#include
-#include "UnrealPropertySerialiser.h"
+#include "UnrealProperty.h"
#include "../Types/MapProperty.h"
-class MapPropertySerialiser : public UnrealPropertySerialiser {
+namespace Gvas { namespace Serialisers {
+
+class MapProperty : public UnrealProperty {
public:
- using ptr = Containers::Pointer;
+ using ptr = Containers::Pointer;
private:
- 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,
+ auto deserialiseProperty(Containers::StringView name, Containers::StringView type, std::size_t value_length,
+ BinaryReader& reader, PropertySerialiser& serialiser)
+ -> Types::UnrealPropertyBase::ptr override;
+ bool serialiseProperty(Types::UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) override;
};
+
+}}
diff --git a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp b/src/Gvas/Serialisers/ResourceProperty.cpp
similarity index 75%
rename from src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp
rename to src/Gvas/Serialisers/ResourceProperty.cpp
index 9182591..da63c1e 100644
--- a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp
+++ b/src/Gvas/Serialisers/ResourceProperty.cpp
@@ -21,16 +21,17 @@
#include "../Types/NoneProperty.h"
#include "../../Logger/Logger.h"
-#include "ResourcePropertySerialiser.h"
+#include "ResourceProperty.h"
using namespace Containers::Literals;
-UnrealPropertyBase::ptr
-ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
- std::size_t value_length, BinaryReader& reader,
- PropertySerialiser& serialiser)
+namespace Gvas { namespace Serialisers {
+
+Types::UnrealPropertyBase::ptr
+ResourceProperty::deserialiseProperty(Containers::StringView name, Containers::StringView type,
+ std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser)
{
- auto prop = Containers::pointer();
+ auto prop = Containers::pointer();
auto id_prop = serialiser.read(reader);
if(!id_prop) {
@@ -40,13 +41,13 @@ ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Con
if((*id_prop->name) != "ID_4_AAE08F17428E229EC7A2209F51081A21"_s ||
id_prop->propertyType != "IntProperty"_s ||
- dynamic_cast(id_prop.get()) == nullptr)
+ dynamic_cast(id_prop.get()) == nullptr)
{
LOG_ERROR("The ID property is invalid."_s);
return nullptr;
}
- prop->id = dynamic_cast