From 45bc2b97d9c0a40e128be8dec2e8884e18cda831 Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 21 Nov 2022 18:58:01 +0100 Subject: [PATCH] Profile: add property names. --- src/CMakeLists.txt | 1 + src/Profile/Profile.cpp | 97 +++++++++++++++++++------------------ src/Profile/PropertyNames.h | 10 ++++ 3 files changed, 60 insertions(+), 48 deletions(-) create mode 100644 src/Profile/PropertyNames.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 902f8e5..3afb5e3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -143,6 +143,7 @@ add_executable(MassBuilderSaveTool WIN32 ProfileManager/ProfileManager.cpp Profile/Profile.h Profile/Profile.cpp + Profile/PropertyNames.h Profile/ResourceIDs.h MassManager/MassManager.h MassManager/MassManager.cpp diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index 5e3a65f..e0609b4 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -22,6 +22,7 @@ #include #include +#include "PropertyNames.h" #include "../UESaveFile/Types/ArrayProperty.h" #include "../UESaveFile/Types/ResourceItemValue.h" #include "../UESaveFile/Types/IntProperty.h" @@ -49,7 +50,7 @@ Profile::Profile(Containers::StringView path): _type = ProfileType::FullGame; } - auto account_prop = _profile.at("Account"_s); + auto account_prop = _profile.at(PROFILE_ACCOUNT); if(!account_prop) { _lastError = "Couldn't find an account ID in "_s + _filename; _valid = false; @@ -110,7 +111,7 @@ void Profile::refreshValues() { Utility::Error{} << _filename << "is not a valid profile save."; } - auto name_prop = _profile.at("CompanyName"_s); + auto name_prop = _profile.at(PROFILE_NAME); if(!name_prop) { _lastError = "No company name in "_s + _filename; _valid = false; @@ -118,41 +119,41 @@ void Profile::refreshValues() { } _name = name_prop->value; - auto prop = _profile.at("ActiveFrameSlot"_s); + auto prop = _profile.at(PROFILE_ACTIVE_FRAME_SLOT); _activeFrameSlot = prop ? prop->value : 0; - prop = _profile.at("Credit"_s); + prop = _profile.at(PROFILE_CREDITS); _credits = prop ? prop->value : 0; - prop = _profile.at("StoryProgress"_s); + prop = _profile.at(PROFILE_STORY_PROGRESS); _storyProgress = prop ? prop->value : 0; - prop = _profile.at("LastMissionID"_s); + prop = _profile.at(PROFILE_LAST_MISSION_ID); _lastMissionId = prop ? prop->value : 0; - _verseSteel = getResource("ResourceMaterial"_s, VerseSteel); - _undinium = getResource("ResourceMaterial"_s, Undinium); - _necriumAlloy = getResource("ResourceMaterial"_s, NecriumAlloy); - _lunarite = getResource("ResourceMaterial"_s, Lunarite); - _asterite = getResource("ResourceMaterial"_s, Asterite); + _verseSteel = getResource(PROFILE_MATERIAL, VerseSteel); + _undinium = getResource(PROFILE_MATERIAL, Undinium); + _necriumAlloy = getResource(PROFILE_MATERIAL, NecriumAlloy); + _lunarite = getResource(PROFILE_MATERIAL, Lunarite); + _asterite = getResource(PROFILE_MATERIAL, Asterite); - _ednil = getResource("ResourceMaterial"_s, Ednil); - _nuflalt = getResource("ResourceMaterial"_s, Nuflalt); - _aurelene = getResource("ResourceMaterial"_s, Aurelene); - _soldus = getResource("ResourceMaterial"_s, Soldus); - _synthesisedN = getResource("ResourceMaterial"_s, SynthesisedN); + _ednil = getResource(PROFILE_MATERIAL, Ednil); + _nuflalt = getResource(PROFILE_MATERIAL, Nuflalt); + _aurelene = getResource(PROFILE_MATERIAL, Aurelene); + _soldus = getResource(PROFILE_MATERIAL, Soldus); + _synthesisedN = getResource(PROFILE_MATERIAL, SynthesisedN); - _alcarbonite = getResource("ResourceMaterial"_s, Alcarbonite); - _keriphene = getResource("ResourceMaterial"_s, Keriphene); - _nitinolCM = getResource("ResourceMaterial"_s, NitinolCM); - _quarkium = getResource("ResourceMaterial"_s, Quarkium); - _alterene = getResource("ResourceMaterial"_s, Alterene); + _alcarbonite = getResource(PROFILE_MATERIAL, Alcarbonite); + _keriphene = getResource(PROFILE_MATERIAL, Keriphene); + _nitinolCM = getResource(PROFILE_MATERIAL, NitinolCM); + _quarkium = getResource(PROFILE_MATERIAL, Quarkium); + _alterene = getResource(PROFILE_MATERIAL, Alterene); - _mixedComposition = getResource("ResourceQuarkData"_s, MixedComposition); - _voidResidue = getResource("ResourceQuarkData"_s, VoidResidue); - _muscularConstruction = getResource("ResourceQuarkData"_s, MuscularConstruction); - _mineralExoskeletology = getResource("ResourceQuarkData"_s, MineralExoskeletology); - _carbonisedSkin = getResource("ResourceQuarkData"_s, CarbonisedSkin); + _mixedComposition = getResource(PROFILE_QUARK_DATA, MixedComposition); + _voidResidue = getResource(PROFILE_QUARK_DATA, VoidResidue); + _muscularConstruction = getResource(PROFILE_QUARK_DATA, MuscularConstruction); + _mineralExoskeletology = getResource(PROFILE_QUARK_DATA, MineralExoskeletology); + _carbonisedSkin = getResource(PROFILE_QUARK_DATA, CarbonisedSkin); _valid = true; } @@ -162,7 +163,7 @@ auto Profile::companyName() const -> Containers::StringView { } auto Profile::renameCompany(Containers::StringView new_name) -> bool { - auto name_prop = _profile.at("CompanyName"_s); + auto name_prop = _profile.at(PROFILE_NAME); if(!name_prop) { _lastError = "No company name in "_s + _filename; _valid = false; @@ -188,7 +189,7 @@ auto Profile::credits() const -> Int { } auto Profile::setCredits(Int amount) -> bool { - auto credits_prop = _profile.at("Credit"_s); + auto credits_prop = _profile.at(PROFILE_CREDITS); if(!credits_prop) { credits_prop = new IntProperty; @@ -238,7 +239,7 @@ auto Profile::verseSteel() const -> Int { } auto Profile::setVerseSteel(Int amount) -> bool { - return setResource("ResourceMaterial"_s, VerseSteel, amount); + return setResource(PROFILE_MATERIAL, VerseSteel, amount); } auto Profile::undinium() const -> Int { @@ -246,7 +247,7 @@ auto Profile::undinium() const -> Int { } auto Profile::setUndinium(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Undinium, amount); + return setResource(PROFILE_MATERIAL, Undinium, amount); } auto Profile::necriumAlloy() const -> Int { @@ -254,7 +255,7 @@ auto Profile::necriumAlloy() const -> Int { } auto Profile::setNecriumAlloy(Int amount) -> bool { - return setResource("ResourceMaterial"_s, NecriumAlloy, amount); + return setResource(PROFILE_MATERIAL, NecriumAlloy, amount); } auto Profile::lunarite() const -> Int { @@ -262,7 +263,7 @@ auto Profile::lunarite() const -> Int { } auto Profile::setLunarite(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Lunarite, amount); + return setResource(PROFILE_MATERIAL, Lunarite, amount); } auto Profile::asterite() const -> Int { @@ -270,7 +271,7 @@ auto Profile::asterite() const -> Int { } auto Profile::setAsterite(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Asterite, amount); + return setResource(PROFILE_MATERIAL, Asterite, amount); } auto Profile::ednil() const -> Int { @@ -278,7 +279,7 @@ auto Profile::ednil() const -> Int { } auto Profile::setEdnil(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Ednil, amount); + return setResource(PROFILE_MATERIAL, Ednil, amount); } auto Profile::nuflalt() const -> Int { @@ -286,7 +287,7 @@ auto Profile::nuflalt() const -> Int { } auto Profile::setNuflalt(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Nuflalt, amount); + return setResource(PROFILE_MATERIAL, Nuflalt, amount); } auto Profile::aurelene() const -> Int { @@ -294,7 +295,7 @@ auto Profile::aurelene() const -> Int { } auto Profile::setAurelene(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Aurelene, amount); + return setResource(PROFILE_MATERIAL, Aurelene, amount); } auto Profile::soldus() const -> Int { @@ -302,7 +303,7 @@ auto Profile::soldus() const -> Int { } auto Profile::setSoldus(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Soldus, amount); + return setResource(PROFILE_MATERIAL, Soldus, amount); } auto Profile::synthesisedN() const -> Int { @@ -310,7 +311,7 @@ auto Profile::synthesisedN() const -> Int { } auto Profile::setSynthesisedN(Int amount) -> bool { - return setResource("ResourceMaterial"_s, SynthesisedN, amount); + return setResource(PROFILE_MATERIAL, SynthesisedN, amount); } auto Profile::alcarbonite() const -> Int { @@ -318,7 +319,7 @@ auto Profile::alcarbonite() const -> Int { } auto Profile::setAlcarbonite(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Alcarbonite, amount); + return setResource(PROFILE_MATERIAL, Alcarbonite, amount); } auto Profile::keriphene() const -> Int { @@ -326,7 +327,7 @@ auto Profile::keriphene() const -> Int { } auto Profile::setKeriphene(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Keriphene, amount); + return setResource(PROFILE_MATERIAL, Keriphene, amount); } auto Profile::nitinolCM() const -> Int { @@ -334,7 +335,7 @@ auto Profile::nitinolCM() const -> Int { } auto Profile::setNitinolCM(Int amount) -> bool { - return setResource("ResourceMaterial"_s, NitinolCM, amount); + return setResource(PROFILE_MATERIAL, NitinolCM, amount); } auto Profile::quarkium() const -> Int { @@ -342,7 +343,7 @@ auto Profile::quarkium() const -> Int { } auto Profile::setQuarkium(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Quarkium, amount); + return setResource(PROFILE_MATERIAL, Quarkium, amount); } auto Profile::alterene() const -> Int { @@ -350,7 +351,7 @@ auto Profile::alterene() const -> Int { } auto Profile::setAlterene(Int amount) -> bool { - return setResource("ResourceMaterial"_s, Alterene, amount); + return setResource(PROFILE_MATERIAL, Alterene, amount); } auto Profile::mixedComposition() const -> Int { @@ -358,7 +359,7 @@ auto Profile::mixedComposition() const -> Int { } auto Profile::setMixedComposition(Int amount) -> bool { - return setResource("ResourceQuarkData"_s, MixedComposition, amount); + return setResource(PROFILE_QUARK_DATA, MixedComposition, amount); } auto Profile::voidResidue() const -> Int { @@ -366,7 +367,7 @@ auto Profile::voidResidue() const -> Int { } auto Profile::setVoidResidue(Int amount) -> bool { - return setResource("ResourceQuarkData"_s, VoidResidue, amount); + return setResource(PROFILE_QUARK_DATA, VoidResidue, amount); } auto Profile::muscularConstruction() const -> Int { @@ -374,7 +375,7 @@ auto Profile::muscularConstruction() const -> Int { } auto Profile::setMuscularConstruction(Int amount) -> bool { - return setResource("ResourceQuarkData"_s, MuscularConstruction, amount); + return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount); } auto Profile::mineralExoskeletology() const -> Int { @@ -382,7 +383,7 @@ auto Profile::mineralExoskeletology() const -> Int { } auto Profile::setMineralExoskeletology(Int amount) -> bool { - return setResource("ResourceQuarkData"_s, MineralExoskeletology, amount); + return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount); } auto Profile::carbonisedSkin() const -> Int { @@ -390,7 +391,7 @@ auto Profile::carbonisedSkin() const -> Int { } auto Profile::setCarbonisedSkin(Int amount) -> bool { - return setResource("ResourceQuarkData"_s, CarbonisedSkin, amount); + return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount); } auto Profile::getResource(Containers::StringView container, MaterialID id) -> Int { diff --git a/src/Profile/PropertyNames.h b/src/Profile/PropertyNames.h new file mode 100644 index 0000000..73ebbe3 --- /dev/null +++ b/src/Profile/PropertyNames.h @@ -0,0 +1,10 @@ +#pragma once + +#define PROFILE_NAME "CompanyName" +#define PROFILE_ACTIVE_FRAME_SLOT "ActiveFrameSlot" +#define PROFILE_CREDITS "Credit" +#define PROFILE_STORY_PROGRESS "StoryProgress" +#define PROFILE_LAST_MISSION_ID "LastMissionID" +#define PROFILE_MATERIAL "ResourceMaterial" +#define PROFILE_QUARK_DATA "ResourceQuarkData" +#define PROFILE_ACCOUNT "Account"