Compare commits
7 commits
0826d4aede
...
76e36791d7
Author | SHA1 | Date | |
---|---|---|---|
76e36791d7 | |||
50a7b1d7f0 | |||
1caa472833 | |||
d3d065c945 | |||
b8b156a724 | |||
9c1aeb753e | |||
0006c90a21 |
14 changed files with 453 additions and 1044 deletions
|
@ -52,6 +52,8 @@ add_library(UESaveFile STATIC EXCLUDE_FROM_ALL
|
||||||
UESaveFile/Serialisers/IntPropertySerialiser.cpp
|
UESaveFile/Serialisers/IntPropertySerialiser.cpp
|
||||||
UESaveFile/Serialisers/MapPropertySerialiser.h
|
UESaveFile/Serialisers/MapPropertySerialiser.h
|
||||||
UESaveFile/Serialisers/MapPropertySerialiser.cpp
|
UESaveFile/Serialisers/MapPropertySerialiser.cpp
|
||||||
|
UESaveFile/Serialisers/ResourcePropertySerialiser.h
|
||||||
|
UESaveFile/Serialisers/ResourcePropertySerialiser.cpp
|
||||||
UESaveFile/Serialisers/RotatorPropertySerialiser.h
|
UESaveFile/Serialisers/RotatorPropertySerialiser.h
|
||||||
UESaveFile/Serialisers/RotatorPropertySerialiser.cpp
|
UESaveFile/Serialisers/RotatorPropertySerialiser.cpp
|
||||||
UESaveFile/Serialisers/StringPropertySerialiser.h
|
UESaveFile/Serialisers/StringPropertySerialiser.h
|
||||||
|
@ -84,6 +86,7 @@ add_library(UESaveFile STATIC EXCLUDE_FROM_ALL
|
||||||
UESaveFile/Types/SetProperty.h
|
UESaveFile/Types/SetProperty.h
|
||||||
UESaveFile/Types/StringProperty.h
|
UESaveFile/Types/StringProperty.h
|
||||||
UESaveFile/Types/StructProperty.h
|
UESaveFile/Types/StructProperty.h
|
||||||
|
UESaveFile/Types/ResourceItemValue.h
|
||||||
UESaveFile/Types/TextProperty.h
|
UESaveFile/Types/TextProperty.h
|
||||||
UESaveFile/Types/UnrealProperty.h
|
UESaveFile/Types/UnrealProperty.h
|
||||||
UESaveFile/Types/UnrealPropertyBase.h
|
UESaveFile/Types/UnrealPropertyBase.h
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// MassBuilderSaveTool
|
|
||||||
// Copyright (C) 2021 Guillaume Jacquemin
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
constexpr char company_name_locator[] = "CompanyName\0\f\0\0\0StrProperty";
|
|
||||||
constexpr char active_slot_locator[] = "ActiveFrameSlot\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char credits_locator[] = "Credit\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char story_progress_locator[] = "StoryProgress\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char last_mission_id_locator[] = "LastMissionID\0\f\0\0\0IntProperty";
|
|
||||||
|
|
||||||
constexpr char verse_steel_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x00\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char undinium_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x01\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char necrium_alloy_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x02\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char lunarite_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x03\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char asterite_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x04\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
|
|
||||||
constexpr char ednil_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x0a\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char nuflalt_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x0b\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char aurelene_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\f\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char soldus_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x0d\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char synthesized_n_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x0e\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
|
|
||||||
constexpr char alcarbonite_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x14\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char keriphene_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x15\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char nitinol_cm_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x16\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char quarkium_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x17\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char alterene_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x18\x35\f\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
|
|
||||||
constexpr char mixed_composition_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa0\xbb\x0d\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char void_residue_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa1\xbb\x0d\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char muscular_construction_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa2\xbb\x0d\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char mineral_exoskeletology_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa3\xbb\x0d\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
constexpr char carbonized_skin_locator[] =
|
|
||||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa4\xbb\x0d\0,\0\0\0"
|
|
||||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
|
||||||
|
|
||||||
constexpr char engine_inventory_locator[] = "InventoryEngine\0\x0e\0\0\0ArrayProperty";
|
|
||||||
constexpr char gear_inventory_locator[] = "InventoryGear\0\x0e\0\0\0ArrayProperty";
|
|
||||||
constexpr char os_inventory_locator[] = "InventoryOS\0\x0e\0\0\0ArrayProperty";
|
|
||||||
constexpr char module_inventory_locator[] = "InventoryModule\0\x0e\0\0\0ArrayProperty";
|
|
||||||
constexpr char arch_inventory_locator[] = "InventoryArchitect\0\x0e\0\0\0ArrayProperty";
|
|
||||||
constexpr char tech_inventory_locator[] = "InventoryTech\0\x0e\0\0\0ArrayProperty";
|
|
File diff suppressed because it is too large
Load diff
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include <Magnum/Magnum.h>
|
#include <Magnum/Magnum.h>
|
||||||
|
|
||||||
|
#include "../UESaveFile/UESaveFile.h"
|
||||||
|
|
||||||
using namespace Magnum;
|
using namespace Magnum;
|
||||||
|
|
||||||
enum class ProfileType : UnsignedByte {
|
enum class ProfileType : UnsignedByte {
|
||||||
|
@ -43,144 +45,92 @@ class Profile {
|
||||||
|
|
||||||
void refreshValues();
|
void refreshValues();
|
||||||
|
|
||||||
auto companyName() const -> std::string const&;
|
auto companyName() -> std::string const&;
|
||||||
auto getCompanyName() -> std::string const&;
|
|
||||||
auto renameCompany(const std::string& new_name) -> bool;
|
auto renameCompany(const std::string& new_name) -> bool;
|
||||||
|
|
||||||
auto activeFrameSlot() const -> Int;
|
auto activeFrameSlot() -> Int;
|
||||||
auto getActiveFrameSlot() -> Int;
|
|
||||||
|
|
||||||
auto credits() const -> Int;
|
auto credits() -> Int;
|
||||||
auto getCredits() -> Int;
|
|
||||||
auto setCredits(Int credits) -> bool;
|
auto setCredits(Int credits) -> bool;
|
||||||
|
|
||||||
auto storyProgress() const -> Int;
|
auto storyProgress() -> Int;
|
||||||
auto getStoryProgress() -> Int;
|
|
||||||
auto setStoryProgress(Int progress) -> bool;
|
auto setStoryProgress(Int progress) -> bool;
|
||||||
|
|
||||||
auto lastMissionId() const -> Int;
|
auto lastMissionId() -> Int;
|
||||||
auto getLastMissionId() -> Int;
|
|
||||||
|
|
||||||
auto verseSteel() const -> Int;
|
auto verseSteel() -> Int;
|
||||||
auto getVerseSteel() -> Int;
|
|
||||||
auto setVerseSteel(Int amount) -> bool;
|
auto setVerseSteel(Int amount) -> bool;
|
||||||
|
|
||||||
auto undinium() const -> Int;
|
auto undinium() -> Int;
|
||||||
auto getUndinium() -> Int;
|
|
||||||
auto setUndinium(Int amount) -> bool;
|
auto setUndinium(Int amount) -> bool;
|
||||||
|
|
||||||
auto necriumAlloy() const -> Int;
|
auto necriumAlloy() -> Int;
|
||||||
auto getNecriumAlloy() -> Int;
|
|
||||||
auto setNecriumAlloy(Int amount) -> bool;
|
auto setNecriumAlloy(Int amount) -> bool;
|
||||||
|
|
||||||
auto lunarite() const -> Int;
|
auto lunarite() -> Int;
|
||||||
auto getLunarite() -> Int;
|
|
||||||
auto setLunarite(Int amount) -> bool;
|
auto setLunarite(Int amount) -> bool;
|
||||||
|
|
||||||
auto asterite() const -> Int;
|
auto asterite() -> Int;
|
||||||
auto getAsterite() -> Int;
|
|
||||||
auto setAsterite(Int amount) -> bool;
|
auto setAsterite(Int amount) -> bool;
|
||||||
|
|
||||||
auto ednil() const -> Int;
|
auto ednil() -> Int;
|
||||||
auto getEdnil() -> Int;
|
|
||||||
auto setEdnil(Int amount) -> bool;
|
auto setEdnil(Int amount) -> bool;
|
||||||
|
|
||||||
auto nuflalt() const -> Int;
|
auto nuflalt() -> Int;
|
||||||
auto getNuflalt() -> Int;
|
|
||||||
auto setNuflalt(Int amount) -> bool;
|
auto setNuflalt(Int amount) -> bool;
|
||||||
|
|
||||||
auto aurelene() const -> Int;
|
auto aurelene() -> Int;
|
||||||
auto getAurelene() -> Int;
|
|
||||||
auto setAurelene(Int amount) -> bool;
|
auto setAurelene(Int amount) -> bool;
|
||||||
|
|
||||||
auto soldus() const -> Int;
|
auto soldus() -> Int;
|
||||||
auto getSoldus() -> Int;
|
|
||||||
auto setSoldus(Int amount) -> bool;
|
auto setSoldus(Int amount) -> bool;
|
||||||
|
|
||||||
auto synthesizedN() const -> Int;
|
auto synthesizedN() -> Int;
|
||||||
auto getSynthesizedN() -> Int;
|
|
||||||
auto setSynthesizedN(Int amount) -> bool;
|
auto setSynthesizedN(Int amount) -> bool;
|
||||||
|
|
||||||
auto alcarbonite() const -> Int;
|
auto alcarbonite() -> Int;
|
||||||
auto getAlcarbonite() -> Int;
|
|
||||||
auto setAlcarbonite(Int amount) -> bool;
|
auto setAlcarbonite(Int amount) -> bool;
|
||||||
|
|
||||||
auto keriphene() const -> Int;
|
auto keriphene() -> Int;
|
||||||
auto getKeriphene() -> Int;
|
|
||||||
auto setKeriphene(Int amount) -> bool;
|
auto setKeriphene(Int amount) -> bool;
|
||||||
|
|
||||||
auto nitinolCM() const -> Int;
|
auto nitinolCM() -> Int;
|
||||||
auto getNitinolCM() -> Int;
|
|
||||||
auto setNitinolCM(Int amount) -> bool;
|
auto setNitinolCM(Int amount) -> bool;
|
||||||
|
|
||||||
auto quarkium() const -> Int;
|
auto quarkium() -> Int;
|
||||||
auto getQuarkium() -> Int;
|
|
||||||
auto setQuarkium(Int amount) -> bool;
|
auto setQuarkium(Int amount) -> bool;
|
||||||
|
|
||||||
auto alterene() const -> Int;
|
auto alterene() -> Int;
|
||||||
auto getAlterene() -> Int;
|
|
||||||
auto setAlterene(Int amount) -> bool;
|
auto setAlterene(Int amount) -> bool;
|
||||||
|
|
||||||
auto mixedComposition() const -> Int;
|
auto mixedComposition() -> Int;
|
||||||
auto getMixedComposition() -> Int;
|
|
||||||
auto setMixedComposition(Int amount) -> bool;
|
auto setMixedComposition(Int amount) -> bool;
|
||||||
|
|
||||||
auto voidResidue() const -> Int;
|
auto voidResidue() -> Int;
|
||||||
auto getVoidResidue() -> Int;
|
|
||||||
auto setVoidResidue(Int amount) -> bool;
|
auto setVoidResidue(Int amount) -> bool;
|
||||||
|
|
||||||
auto muscularConstruction() const -> Int;
|
auto muscularConstruction() -> Int;
|
||||||
auto getMuscularConstruction() -> Int;
|
|
||||||
auto setMuscularConstruction(Int amount) -> bool;
|
auto setMuscularConstruction(Int amount) -> bool;
|
||||||
|
|
||||||
auto mineralExoskeletology() const -> Int;
|
auto mineralExoskeletology() -> Int;
|
||||||
auto getMineralExoskeletology() -> Int;
|
|
||||||
auto setMineralExoskeletology(Int amount) -> bool;
|
auto setMineralExoskeletology(Int amount) -> bool;
|
||||||
|
|
||||||
auto carbonizedSkin() const -> Int;
|
auto carbonizedSkin() -> Int;
|
||||||
auto getCarbonizedSkin() -> Int;
|
|
||||||
auto setCarbonizedSkin(Int amount) -> bool;
|
auto setCarbonizedSkin(Int amount) -> bool;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
auto resource(const char* container, Int id) -> Int;
|
||||||
|
auto setResource(const char* container, Int id, Int amount) -> bool;
|
||||||
|
|
||||||
std::string _profileDirectory;
|
std::string _profileDirectory;
|
||||||
std::string _filename;
|
std::string _filename;
|
||||||
|
|
||||||
ProfileType _type;
|
ProfileType _type;
|
||||||
|
|
||||||
|
UESaveFile _profile;
|
||||||
|
|
||||||
std::string _steamId;
|
std::string _steamId;
|
||||||
|
|
||||||
bool _valid = false;
|
bool _valid = false;
|
||||||
std::string _lastError;
|
std::string _lastError;
|
||||||
|
|
||||||
std::string _companyName;
|
|
||||||
|
|
||||||
Int _activeFrameSlot = 0;
|
|
||||||
|
|
||||||
Int _credits;
|
|
||||||
|
|
||||||
Int _storyProgress;
|
|
||||||
|
|
||||||
Int _lastMissionId;
|
|
||||||
|
|
||||||
Int _verseSteel;
|
|
||||||
Int _undinium;
|
|
||||||
Int _necriumAlloy;
|
|
||||||
Int _lunarite;
|
|
||||||
Int _asterite;
|
|
||||||
Int _ednil;
|
|
||||||
Int _nuflalt;
|
|
||||||
Int _aurelene;
|
|
||||||
Int _soldus;
|
|
||||||
Int _synthesizedN;
|
|
||||||
Int _alcarbonite;
|
|
||||||
Int _keriphene;
|
|
||||||
Int _nitinolCM;
|
|
||||||
Int _quarkium;
|
|
||||||
Int _alterene;
|
|
||||||
|
|
||||||
Int _mixedComposition;
|
|
||||||
Int _voidResidue;
|
|
||||||
Int _muscularConstruction;
|
|
||||||
Int _mineralExoskeletology;
|
|
||||||
Int _carbonizedSkin;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
|
|
||||||
#include "ProfileManager.h"
|
#include "ProfileManager.h"
|
||||||
|
|
||||||
using namespace Corrade;
|
|
||||||
|
|
||||||
ProfileManager::ProfileManager(const std::string& save_dir, const std::string& backup_dir):
|
ProfileManager::ProfileManager(const std::string& save_dir, const std::string& backup_dir):
|
||||||
_saveDirectory{save_dir},
|
_saveDirectory{save_dir},
|
||||||
_backupsDirectory{backup_dir}
|
_backupsDirectory{backup_dir}
|
||||||
|
@ -48,12 +46,12 @@ auto ProfileManager::lastError() -> std::string const& {
|
||||||
return _lastError;
|
return _lastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProfileManager::profiles() -> std::vector<Profile> const& {
|
auto ProfileManager::profiles() -> Containers::ArrayView<Profile> {
|
||||||
return _profiles;
|
return _profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProfileManager::refreshProfiles() -> bool {
|
auto ProfileManager::refreshProfiles() -> bool {
|
||||||
_profiles.clear();
|
_profiles = Containers::Array<Profile>{};
|
||||||
|
|
||||||
using Utility::Directory::Flag;
|
using Utility::Directory::Flag;
|
||||||
std::vector<std::string> files = Utility::Directory::list(_saveDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
|
std::vector<std::string> files = Utility::Directory::list(_saveDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
|
||||||
|
@ -74,7 +72,7 @@ auto ProfileManager::refreshProfiles() -> bool {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_profiles.push_back(std::move(profile));
|
arrayAppend(_profiles, std::move(profile));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_profiles.empty()) {
|
if(_profiles.empty()) {
|
||||||
|
@ -86,14 +84,14 @@ auto ProfileManager::refreshProfiles() -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProfileManager::getProfile(std::size_t index) -> Profile* {
|
auto ProfileManager::getProfile(std::size_t index) -> Profile* {
|
||||||
return &(_profiles.at(index));
|
return index <= _profiles.size() ? &(_profiles[index]) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> bool {
|
auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> bool {
|
||||||
if(!Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _profiles.at(index).filename()))) {
|
if(!Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _profiles[index].filename()))) {
|
||||||
_lastError = Utility::formatString("Couldn't delete {} (filename: {}).",
|
_lastError = Utility::formatString("Couldn't delete {} (filename: {}).",
|
||||||
_profiles.at(index).companyName(),
|
_profiles[index].companyName(),
|
||||||
_profiles.at(index).filename());
|
_profiles[index].filename());
|
||||||
refreshProfiles();
|
refreshProfiles();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -101,13 +99,18 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo
|
||||||
if(delete_builds) {
|
if(delete_builds) {
|
||||||
for(UnsignedByte i = 0; i < 32; ++i) {
|
for(UnsignedByte i = 0; i < 32; ++i) {
|
||||||
std::string filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
std::string filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
||||||
_profiles.at(index).type() == ProfileType::Demo ? "Demo": "",
|
_profiles[index].type() == ProfileType::Demo ? "Demo": "",
|
||||||
i, _profiles.at(index).steamId());
|
i, _profiles[index].steamId());
|
||||||
Utility::Directory::rm(Utility::Directory::join(_saveDirectory, filename));
|
Utility::Directory::rm(Utility::Directory::join(_saveDirectory, filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_profiles.erase(_profiles.cbegin() + index);
|
std::string file = _profiles[index].filename();
|
||||||
|
auto it = std::remove_if(_profiles.begin(), _profiles.end(), [&file](Profile& profile){return profile.filename() == file;});
|
||||||
|
|
||||||
|
if(it != _profiles.end()) {
|
||||||
|
arrayRemoveSuffix(_profiles, 1);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +120,7 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
||||||
std::tm* time = std::localtime(×tamp);
|
std::tm* time = std::localtime(×tamp);
|
||||||
|
|
||||||
std::string filename = Utility::formatString("{}_{}{:.2d}{:.2d}_{:.2d}{:.2d}{:.2d}.mbprofbackup",
|
std::string filename = Utility::formatString("{}_{}{:.2d}{:.2d}_{:.2d}{:.2d}{:.2d}.mbprofbackup",
|
||||||
Utility::String::replaceAll(_profiles.at(index).companyName(), " ", "_"),
|
Utility::String::replaceAll(_profiles[index].companyName(), " ", "_"),
|
||||||
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
|
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
|
||||||
time->tm_hour, time->tm_min, time->tm_sec);
|
time->tm_hour, time->tm_min, time->tm_sec);
|
||||||
|
|
||||||
|
@ -130,21 +133,21 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
zip_source_t* profile_source = zip_source_file(zip, Utility::Directory::toNativeSeparators(Utility::Directory::join(_saveDirectory, _profiles.at(index).filename())).c_str(), 0, 0);
|
zip_source_t* profile_source = zip_source_file(zip, Utility::Directory::toNativeSeparators(Utility::Directory::join(_saveDirectory, _profiles[index].filename())).c_str(), 0, 0);
|
||||||
if(profile_source == nullptr) {
|
if(profile_source == nullptr) {
|
||||||
_lastError = zip_strerror(zip);
|
_lastError = zip_strerror(zip);
|
||||||
zip_source_free(profile_source);
|
zip_source_free(profile_source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(zip_file_add(zip, _profiles.at(index).filename().c_str(), profile_source, ZIP_FL_ENC_UTF_8) == -1) {
|
if(zip_file_add(zip, _profiles[index].filename().c_str(), profile_source, ZIP_FL_ENC_UTF_8) == -1) {
|
||||||
_lastError = zip_strerror(zip);
|
_lastError = zip_strerror(zip);
|
||||||
zip_source_free(profile_source);
|
zip_source_free(profile_source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string comment = Utility::String::join({_profiles.at(index).companyName(),
|
std::string comment = Utility::String::join({_profiles[index].companyName(),
|
||||||
_profiles.at(index).type() == ProfileType::Demo ? "demo" : "full",
|
_profiles[index].type() == ProfileType::Demo ? "demo" : "full",
|
||||||
Utility::formatString("{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}",
|
Utility::formatString("{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}",
|
||||||
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
|
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
|
||||||
time->tm_hour, time->tm_min, time->tm_sec)
|
time->tm_hour, time->tm_min, time->tm_sec)
|
||||||
|
@ -154,8 +157,8 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
||||||
if(backup_builds) {
|
if(backup_builds) {
|
||||||
for(UnsignedByte i = 0; i < 32; ++i) {
|
for(UnsignedByte i = 0; i < 32; ++i) {
|
||||||
std::string build_filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
std::string build_filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
||||||
_profiles.at(index).type() == ProfileType::Demo ? "Demo": "",
|
_profiles[index].type() == ProfileType::Demo ? "Demo": "",
|
||||||
i, _profiles.at(index).steamId());
|
i, _profiles[index].steamId());
|
||||||
|
|
||||||
if(!Utility::Directory::exists(Utility::Directory::join(_saveDirectory, build_filename))) {
|
if(!Utility::Directory::exists(Utility::Directory::join(_saveDirectory, build_filename))) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -184,12 +187,12 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProfileManager::backups() -> std::vector<Backup> const& {
|
auto ProfileManager::backups() -> Containers::ArrayView<Backup> {
|
||||||
return _backups;
|
return _backups;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileManager::refreshBackups() {
|
void ProfileManager::refreshBackups() {
|
||||||
_backups.clear();
|
_backups = Containers::Array<Backup>{};
|
||||||
|
|
||||||
using Utility::Directory::Flag;
|
using Utility::Directory::Flag;
|
||||||
std::vector<std::string> files = Utility::Directory::list(_backupsDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
|
std::vector<std::string> files = Utility::Directory::list(_backupsDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
|
||||||
|
@ -255,29 +258,34 @@ void ProfileManager::refreshBackups() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
backup.includedFiles.reserve(num_entries);
|
arrayReserve(backup.includedFiles, num_entries);
|
||||||
|
|
||||||
for(Long i = 0; i < num_entries; i++) {
|
for(Long i = 0; i < num_entries; i++) {
|
||||||
backup.includedFiles.emplace_back(zip_get_name(zip, i, ZIP_FL_UNCHANGED));
|
arrayAppend(backup.includedFiles, InPlaceInit, zip_get_name(zip, i, ZIP_FL_UNCHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
_backups.push_back(std::move(backup));
|
arrayAppend(_backups, std::move(backup));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProfileManager::deleteBackup(std::size_t index) -> bool {
|
auto ProfileManager::deleteBackup(std::size_t index) -> bool {
|
||||||
if(!Utility::Directory::rm(Utility::Directory::join(_backupsDirectory, _backups.at(index).filename))) {
|
if(!Utility::Directory::rm(Utility::Directory::join(_backupsDirectory, _backups[index].filename))) {
|
||||||
_lastError = "Couldn't delete " + _backups.at(index).filename;
|
_lastError = "Couldn't delete " + _backups[index].filename;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_backups.erase(_backups.begin() + index);
|
std::string file = _backups[index].filename;
|
||||||
|
auto it = std::remove_if(_backups.begin(), _backups.end(), [&file](Backup& backup){return backup.filename == file;});
|
||||||
|
|
||||||
|
if(it != _backups.end()) {
|
||||||
|
arrayRemoveSuffix(_backups, 1);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProfileManager::restoreBackup(std::size_t index) -> bool {
|
auto ProfileManager::restoreBackup(std::size_t index) -> bool {
|
||||||
const Backup& backup = _backups.at(index);
|
const Backup& backup = _backups[index];
|
||||||
|
|
||||||
static const char* error_format = "Extraction of file {} failed: {}";
|
static const char* error_format = "Extraction of file {} failed: {}";
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,13 @@
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
#include <Corrade/Containers/Array.h>
|
||||||
|
|
||||||
#include "../Profile/Profile.h"
|
#include "../Profile/Profile.h"
|
||||||
|
|
||||||
|
using namespace Corrade;
|
||||||
|
|
||||||
struct Backup {
|
struct Backup {
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string company;
|
std::string company;
|
||||||
|
@ -33,7 +36,7 @@ struct Backup {
|
||||||
int minute;
|
int minute;
|
||||||
int second;
|
int second;
|
||||||
} timestamp;
|
} timestamp;
|
||||||
std::vector<std::string> includedFiles;
|
Containers::Array<std::string> includedFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProfileManager {
|
class ProfileManager {
|
||||||
|
@ -43,14 +46,14 @@ class ProfileManager {
|
||||||
auto ready() const -> bool;
|
auto ready() const -> bool;
|
||||||
auto lastError() -> std::string const&;
|
auto lastError() -> std::string const&;
|
||||||
|
|
||||||
auto profiles() -> std::vector<Profile> const&;
|
auto profiles() -> Containers::ArrayView<Profile>;
|
||||||
auto refreshProfiles() -> bool;
|
auto refreshProfiles() -> bool;
|
||||||
|
|
||||||
auto getProfile(std::size_t index) -> Profile*;
|
auto getProfile(std::size_t index) -> Profile*;
|
||||||
auto deleteProfile(std::size_t index, bool delete_builds) -> bool;
|
auto deleteProfile(std::size_t index, bool delete_builds) -> bool;
|
||||||
auto backupProfile(std::size_t index, bool backup_builds) -> bool;
|
auto backupProfile(std::size_t index, bool backup_builds) -> bool;
|
||||||
|
|
||||||
auto backups() -> std::vector<Backup> const&;
|
auto backups() -> Containers::ArrayView<Backup>;
|
||||||
void refreshBackups();
|
void refreshBackups();
|
||||||
|
|
||||||
auto deleteBackup(std::size_t index) -> bool;
|
auto deleteBackup(std::size_t index) -> bool;
|
||||||
|
@ -63,6 +66,6 @@ class ProfileManager {
|
||||||
const std::string& _saveDirectory;
|
const std::string& _saveDirectory;
|
||||||
const std::string& _backupsDirectory;
|
const std::string& _backupsDirectory;
|
||||||
|
|
||||||
std::vector<Profile> _profiles;
|
Containers::Array<Profile> _profiles;
|
||||||
std::vector<Backup> _backups;
|
Containers::Array<Backup> _backups;
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,7 +81,7 @@ void SaveTool::drawProfileManager() {
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
ImGui::PushID(i);
|
ImGui::PushID(i);
|
||||||
if(ImGui::Selectable(_profileManager->profiles().at(i).companyName().c_str(), false,
|
if(ImGui::Selectable(_profileManager->profiles()[i].companyName().c_str(), false,
|
||||||
ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap))
|
ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap))
|
||||||
{
|
{
|
||||||
_currentProfile = _profileManager->getProfile(i);
|
_currentProfile = _profileManager->getProfile(i);
|
||||||
|
@ -90,7 +90,7 @@ void SaveTool::drawProfileManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
ImGui::TextUnformatted(_profileManager->profiles().at(i).type() == ProfileType::Demo ? "Demo" : "Full");
|
ImGui::TextUnformatted(_profileManager->profiles()[i].type() == ProfileType::Demo ? "Demo" : "Full");
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(2);
|
ImGui::TableSetColumnIndex(2);
|
||||||
if(ImGui::SmallButton(ICON_FA_FILE_ARCHIVE)) {
|
if(ImGui::SmallButton(ICON_FA_FILE_ARCHIVE)) {
|
||||||
|
@ -132,13 +132,13 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||||
{
|
{
|
||||||
ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
|
ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
|
||||||
ImGui::Text("Are you sure you want to restore the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? Any existing data will be overwritten.",
|
ImGui::Text("Are you sure you want to restore the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? Any existing data will be overwritten.",
|
||||||
_profileManager->backups().at(backup_index).company.c_str(),
|
_profileManager->backups()[backup_index].company.c_str(),
|
||||||
_profileManager->backups().at(backup_index).timestamp.year,
|
_profileManager->backups()[backup_index].timestamp.year,
|
||||||
_profileManager->backups().at(backup_index).timestamp.month,
|
_profileManager->backups()[backup_index].timestamp.month,
|
||||||
_profileManager->backups().at(backup_index).timestamp.day,
|
_profileManager->backups()[backup_index].timestamp.day,
|
||||||
_profileManager->backups().at(backup_index).timestamp.hour,
|
_profileManager->backups()[backup_index].timestamp.hour,
|
||||||
_profileManager->backups().at(backup_index).timestamp.minute,
|
_profileManager->backups()[backup_index].timestamp.minute,
|
||||||
_profileManager->backups().at(backup_index).timestamp.second);
|
_profileManager->backups()[backup_index].timestamp.second);
|
||||||
ImGui::PopTextWrapPos();
|
ImGui::PopTextWrapPos();
|
||||||
|
|
||||||
if(ImGui::BeginTable("##RestoreBackupLayout", 2)) {
|
if(ImGui::BeginTable("##RestoreBackupLayout", 2)) {
|
||||||
|
@ -172,13 +172,13 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||||
{
|
{
|
||||||
ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
|
ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
|
||||||
ImGui::Text("Are you sure you want to delete the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? This operation is irreversible.",
|
ImGui::Text("Are you sure you want to delete the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? This operation is irreversible.",
|
||||||
_profileManager->backups().at(backup_index).company.c_str(),
|
_profileManager->backups()[backup_index].company.c_str(),
|
||||||
_profileManager->backups().at(backup_index).timestamp.year,
|
_profileManager->backups()[backup_index].timestamp.year,
|
||||||
_profileManager->backups().at(backup_index).timestamp.month,
|
_profileManager->backups()[backup_index].timestamp.month,
|
||||||
_profileManager->backups().at(backup_index).timestamp.day,
|
_profileManager->backups()[backup_index].timestamp.day,
|
||||||
_profileManager->backups().at(backup_index).timestamp.hour,
|
_profileManager->backups()[backup_index].timestamp.hour,
|
||||||
_profileManager->backups().at(backup_index).timestamp.minute,
|
_profileManager->backups()[backup_index].timestamp.minute,
|
||||||
_profileManager->backups().at(backup_index).timestamp.second);
|
_profileManager->backups()[backup_index].timestamp.second);
|
||||||
ImGui::PopTextWrapPos();
|
ImGui::PopTextWrapPos();
|
||||||
|
|
||||||
if(ImGui::BeginTable("##DeleteBackupLayout", 2)) {
|
if(ImGui::BeginTable("##DeleteBackupLayout", 2)) {
|
||||||
|
@ -251,10 +251,10 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
ImGui::TextUnformatted(_profileManager->backups().at(i).company.c_str());
|
ImGui::TextUnformatted(_profileManager->backups()[i].company.c_str());
|
||||||
if(ImGui::IsItemHovered()) {
|
if(ImGui::IsItemHovered()) {
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
for(const auto& file : _profileManager->backups().at(i).includedFiles) {
|
for(const auto& file : _profileManager->backups()[i].includedFiles) {
|
||||||
ImGui::TextUnformatted(file.c_str());
|
ImGui::TextUnformatted(file.c_str());
|
||||||
}
|
}
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
|
@ -262,15 +262,15 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
ImGui::Text("%.4i-%.2i-%.2i %.2i:%.2i:%.2i",
|
ImGui::Text("%.4i-%.2i-%.2i %.2i:%.2i:%.2i",
|
||||||
_profileManager->backups().at(i).timestamp.year,
|
_profileManager->backups()[i].timestamp.year,
|
||||||
_profileManager->backups().at(i).timestamp.month,
|
_profileManager->backups()[i].timestamp.month,
|
||||||
_profileManager->backups().at(i).timestamp.day,
|
_profileManager->backups()[i].timestamp.day,
|
||||||
_profileManager->backups().at(i).timestamp.hour,
|
_profileManager->backups()[i].timestamp.hour,
|
||||||
_profileManager->backups().at(i).timestamp.minute,
|
_profileManager->backups()[i].timestamp.minute,
|
||||||
_profileManager->backups().at(i).timestamp.second);
|
_profileManager->backups()[i].timestamp.second);
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(2);
|
ImGui::TableSetColumnIndex(2);
|
||||||
ImGui::TextUnformatted(_profileManager->backups().at(i).type == ProfileType::Demo ? "Demo" : "Full");
|
ImGui::TextUnformatted(_profileManager->backups()[i].type == ProfileType::Demo ? "Demo" : "Full");
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(3);
|
ImGui::TableSetColumnIndex(3);
|
||||||
ImGui::PushID(i);
|
ImGui::PushID(i);
|
||||||
|
@ -363,8 +363,8 @@ auto SaveTool::drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID {
|
||||||
|
|
||||||
ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
|
ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
|
||||||
ImGui::Text("Are you sure you want to delete the %s %s profile ? This operation is irreversible.",
|
ImGui::Text("Are you sure you want to delete the %s %s profile ? This operation is irreversible.",
|
||||||
_profileManager->profiles().at(profile_index).companyName().c_str(),
|
_profileManager->profiles()[profile_index].companyName().c_str(),
|
||||||
_profileManager->profiles().at(profile_index).type() == ProfileType::Demo ? "demo" : "full game");
|
_profileManager->profiles()[profile_index].type() == ProfileType::Demo ? "demo" : "full game");
|
||||||
ImGui::PopTextWrapPos();
|
ImGui::PopTextWrapPos();
|
||||||
|
|
||||||
if(ImGui::BeginTable("##DeleteProfileLayout", 2)) {
|
if(ImGui::BeginTable("##DeleteProfileLayout", 2)) {
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "Serialisers/GuidPropertySerialiser.h"
|
#include "Serialisers/GuidPropertySerialiser.h"
|
||||||
#include "Serialisers/IntPropertySerialiser.h"
|
#include "Serialisers/IntPropertySerialiser.h"
|
||||||
#include "Serialisers/MapPropertySerialiser.h"
|
#include "Serialisers/MapPropertySerialiser.h"
|
||||||
|
#include "Serialisers/ResourcePropertySerialiser.h"
|
||||||
#include "Serialisers/RotatorPropertySerialiser.h"
|
#include "Serialisers/RotatorPropertySerialiser.h"
|
||||||
#include "Serialisers/StringPropertySerialiser.h"
|
#include "Serialisers/StringPropertySerialiser.h"
|
||||||
#include "Serialisers/SetPropertySerialiser.h"
|
#include "Serialisers/SetPropertySerialiser.h"
|
||||||
|
@ -53,6 +54,7 @@ PropertySerialiser::PropertySerialiser() {
|
||||||
arrayAppend(_serialisers, Containers::pointer<GuidPropertySerialiser>());
|
arrayAppend(_serialisers, Containers::pointer<GuidPropertySerialiser>());
|
||||||
arrayAppend(_serialisers, Containers::pointer<IntPropertySerialiser>());
|
arrayAppend(_serialisers, Containers::pointer<IntPropertySerialiser>());
|
||||||
arrayAppend(_serialisers, Containers::pointer<MapPropertySerialiser>());
|
arrayAppend(_serialisers, Containers::pointer<MapPropertySerialiser>());
|
||||||
|
arrayAppend(_serialisers, Containers::pointer<ResourcePropertySerialiser>());
|
||||||
arrayAppend(_serialisers, Containers::pointer<RotatorPropertySerialiser>());
|
arrayAppend(_serialisers, Containers::pointer<RotatorPropertySerialiser>());
|
||||||
arrayAppend(_serialisers, Containers::pointer<StringPropertySerialiser>());
|
arrayAppend(_serialisers, Containers::pointer<StringPropertySerialiser>());
|
||||||
arrayAppend(_serialisers, Containers::pointer<SetPropertySerialiser>());
|
arrayAppend(_serialisers, Containers::pointer<SetPropertySerialiser>());
|
||||||
|
|
103
src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp
Normal file
103
src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
// MassBuilderSaveTool
|
||||||
|
// Copyright (C) 2021 Guillaume Jacquemin
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "../BinaryReader.h"
|
||||||
|
#include "../BinaryWriter.h"
|
||||||
|
#include "../PropertySerialiser.h"
|
||||||
|
|
||||||
|
#include "../Types/IntProperty.h"
|
||||||
|
#include "../Types/NoneProperty.h"
|
||||||
|
|
||||||
|
#include "ResourcePropertySerialiser.h"
|
||||||
|
|
||||||
|
auto ResourcePropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
|
||||||
|
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||||
|
{
|
||||||
|
auto prop = Containers::pointer<ResourceItemValue>();
|
||||||
|
|
||||||
|
std::string str;
|
||||||
|
if(!reader.readUEString(str) || str != "ID_4_AAE08F17428E229EC7A2209F51081A21") {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reader.readUEString(str) || str != "IntProperty") {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reader.readUnsignedLong(value_length) || value_length != 4ull) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
char terminator;
|
||||||
|
if(!reader.readChar(terminator) || terminator != '\0') {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reader.readInt(prop->id)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reader.readUEString(str) || str != "Quantity_3_560F09B5485C365D3041888910019CE3") {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reader.readUEString(str) || str != "IntProperty") {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reader.readUnsignedLong(value_length) || value_length != 4ull) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reader.readChar(terminator) || terminator != '\0') {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reader.readInt(prop->quantity)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reader.readUEString(str) || str != "None") {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||||
|
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||||
|
{
|
||||||
|
auto res_prop = dynamic_cast<ResourceItemValue*>(prop.get());
|
||||||
|
if(!res_prop) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes_written += writer.writeUEStringToArray("ID_4_AAE08F17428E229EC7A2209F51081A21") +
|
||||||
|
writer.writeUEStringToArray("IntProperty") +
|
||||||
|
writer.writeValueToArray<UnsignedLong>(4ull) +
|
||||||
|
writer.writeValueToArray<char>('\0') +
|
||||||
|
writer.writeValueToArray<Int>(res_prop->id);
|
||||||
|
|
||||||
|
bytes_written += writer.writeUEStringToArray("Quantity_3_560F09B5485C365D3041888910019CE3") +
|
||||||
|
writer.writeUEStringToArray("IntProperty") +
|
||||||
|
writer.writeValueToArray<UnsignedLong>(4ull) +
|
||||||
|
writer.writeValueToArray<char>('\0') +
|
||||||
|
writer.writeValueToArray<Int>(res_prop->quantity);
|
||||||
|
|
||||||
|
bytes_written += writer.writeUEStringToArray("None");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
30
src/UESaveFile/Serialisers/ResourcePropertySerialiser.h
Normal file
30
src/UESaveFile/Serialisers/ResourcePropertySerialiser.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// MassBuilderSaveTool
|
||||||
|
// Copyright (C) 2021 Guillaume Jacquemin
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "UnrealPropertySerialiser.h"
|
||||||
|
|
||||||
|
#include "../Types/ResourceItemValue.h"
|
||||||
|
|
||||||
|
class ResourcePropertySerialiser : public UnrealPropertySerialiser<ResourceItemValue> {
|
||||||
|
public:
|
||||||
|
using ptr = Containers::Pointer<ResourcePropertySerialiser>;
|
||||||
|
|
||||||
|
private:
|
||||||
|
auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||||
|
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
|
||||||
|
};
|
|
@ -55,13 +55,19 @@ auto StructSerialiser::deserialise(const std::string& name, const std::string& t
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(UnsignedInt i = 0; i < count; i++) {
|
for(UnsignedInt i = 0; i < count; i++) {
|
||||||
auto prop = readStructValue(name, item_type, value_length, reader, serialiser);
|
auto prop = Containers::pointer<UnrealPropertyBase>();
|
||||||
|
|
||||||
|
prop = serialiser.readItem(reader, item_type, UnsignedLong(-1), name);
|
||||||
|
|
||||||
|
if(!prop) {
|
||||||
|
prop = readStructValue(name, item_type, value_length, reader, serialiser);
|
||||||
|
}
|
||||||
|
|
||||||
if(!prop) {
|
if(!prop) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop->structGuid = guid;
|
static_cast<StructProperty*>(prop.get())->structGuid = guid;
|
||||||
|
|
||||||
arrayAppend(array, std::move(prop));
|
arrayAppend(array, std::move(prop));
|
||||||
}
|
}
|
||||||
|
@ -131,10 +137,12 @@ auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!serialiser.writeItem(prop, struct_prop->structType, bytes_written_here, writer)) {
|
||||||
if(!writeStructValue(struct_prop, bytes_written_here, writer, serialiser)) {
|
if(!writeStructValue(struct_prop, bytes_written_here, writer, serialiser)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UnsignedLong vl_stop = writer.arrayPosition() - vl_start;
|
UnsignedLong vl_stop = writer.arrayPosition() - vl_start;
|
||||||
writer.writeValueToArrayAt(vl_stop, vl_pos);
|
writer.writeValueToArrayAt(vl_stop, vl_pos);
|
||||||
|
|
30
src/UESaveFile/Types/ResourceItemValue.h
Normal file
30
src/UESaveFile/Types/ResourceItemValue.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// MassBuilderSaveTool
|
||||||
|
// Copyright (C) 2021 Guillaume Jacquemin
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "StructProperty.h"
|
||||||
|
|
||||||
|
struct ResourceItemValue : public StructProperty {
|
||||||
|
using ptr = Containers::Pointer<ResourceItemValue>;
|
||||||
|
|
||||||
|
ResourceItemValue() {
|
||||||
|
structType = "sttResourceItemValue";
|
||||||
|
structGuid = Containers::StaticArray<16, char>{'\xB7', '\xA7', '\x77', '\xAB', '\xD3', '\x1B', '\xA6', '\x43', '\xAF', '\x42', '\xE5', '\x9E', '\xBF', '\xFD', '\x37', '\x55'};
|
||||||
|
}
|
||||||
|
|
||||||
|
Int id = 0, quantity = 0;
|
||||||
|
};
|
|
@ -47,6 +47,12 @@ auto UESaveFile::reloadData() -> bool {
|
||||||
return valid();
|
return valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) {
|
||||||
|
auto none_prop = std::move(_properties.back());
|
||||||
|
_properties.back() = std::move(prop);
|
||||||
|
arrayAppend(_properties, std::move(none_prop));
|
||||||
|
}
|
||||||
|
|
||||||
auto UESaveFile::props() -> Containers::ArrayView<UnrealPropertyBase::ptr> {
|
auto UESaveFile::props() -> Containers::ArrayView<UnrealPropertyBase::ptr> {
|
||||||
return _properties;
|
return _properties;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +61,7 @@ auto UESaveFile::saveToFile() -> bool {
|
||||||
BinaryWriter writer{_filepath + ".tmp"};
|
BinaryWriter writer{_filepath + ".tmp"};
|
||||||
|
|
||||||
if(!writer.open()) {
|
if(!writer.open()) {
|
||||||
|
_lastError = "Couldn't open the file for saving.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,12 +74,14 @@ auto UESaveFile::saveToFile() -> bool {
|
||||||
!writer.writeUnsignedInt(_engineVersion.build) ||
|
!writer.writeUnsignedInt(_engineVersion.build) ||
|
||||||
!writer.writeUEString(_engineVersion.buildId))
|
!writer.writeUEString(_engineVersion.buildId))
|
||||||
{
|
{
|
||||||
|
_lastError = "Couldn't write the header.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!writer.writeUnsignedInt(_customFormatVersion) ||
|
if(!writer.writeUnsignedInt(_customFormatVersion) ||
|
||||||
!writer.writeUnsignedInt(_customFormatData.size()))
|
!writer.writeUnsignedInt(_customFormatData.size()))
|
||||||
{
|
{
|
||||||
|
_lastError = "Couldn't write the header.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,21 +89,25 @@ auto UESaveFile::saveToFile() -> bool {
|
||||||
if(!writer.writeStaticArray(Containers::StaticArrayView<16, const char>{_customFormatData[i].id}) ||
|
if(!writer.writeStaticArray(Containers::StaticArrayView<16, const char>{_customFormatData[i].id}) ||
|
||||||
!writer.writeUnsignedInt(_customFormatData[i].value))
|
!writer.writeUnsignedInt(_customFormatData[i].value))
|
||||||
{
|
{
|
||||||
|
_lastError = "Couldn't write the header.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!writer.writeUEString(_saveType)) {
|
if(!writer.writeUEString(_saveType)) {
|
||||||
|
_lastError = "Couldn't write the header.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& prop : _properties) {
|
for(auto& prop : _properties) {
|
||||||
UnsignedLong bytes_written = 0;
|
UnsignedLong bytes_written = 0;
|
||||||
if(!_propSerialiser.write(prop, bytes_written, writer)) {
|
if(!_propSerialiser.write(prop, bytes_written, writer)) {
|
||||||
|
_lastError = "Couldn't write the property " + *prop->name + " to the array.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!writer.flushToFile()) {
|
if(!writer.flushToFile()) {
|
||||||
|
_lastError = "Couldn't write the property " + *prop->name + " to the file.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,5 +210,9 @@ void UESaveFile::loadData() {
|
||||||
arrayAppend(_properties, std::move(prop));
|
arrayAppend(_properties, std::move(prop));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_properties.back()->name != "None" && _properties.back()->propertyType != "NoneProperty") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_valid = true;
|
_valid = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,8 @@ class UESaveFile {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void appendProperty(UnrealPropertyBase::ptr prop);
|
||||||
|
|
||||||
auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr>;
|
auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr>;
|
||||||
|
|
||||||
auto saveToFile() -> bool;
|
auto saveToFile() -> bool;
|
||||||
|
|
Loading…
Reference in a new issue