Profile: add property names.

This commit is contained in:
Guillaume Jacquemin 2022-11-21 18:58:01 +01:00
parent 9de62db449
commit 45bc2b97d9
3 changed files with 60 additions and 48 deletions

View file

@ -143,6 +143,7 @@ add_executable(MassBuilderSaveTool WIN32
ProfileManager/ProfileManager.cpp ProfileManager/ProfileManager.cpp
Profile/Profile.h Profile/Profile.h
Profile/Profile.cpp Profile/Profile.cpp
Profile/PropertyNames.h
Profile/ResourceIDs.h Profile/ResourceIDs.h
MassManager/MassManager.h MassManager/MassManager.h
MassManager/MassManager.cpp MassManager/MassManager.cpp

View file

@ -22,6 +22,7 @@
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#include <Corrade/Utility/Format.h> #include <Corrade/Utility/Format.h>
#include "PropertyNames.h"
#include "../UESaveFile/Types/ArrayProperty.h" #include "../UESaveFile/Types/ArrayProperty.h"
#include "../UESaveFile/Types/ResourceItemValue.h" #include "../UESaveFile/Types/ResourceItemValue.h"
#include "../UESaveFile/Types/IntProperty.h" #include "../UESaveFile/Types/IntProperty.h"
@ -49,7 +50,7 @@ Profile::Profile(Containers::StringView path):
_type = ProfileType::FullGame; _type = ProfileType::FullGame;
} }
auto account_prop = _profile.at<StringProperty>("Account"_s); auto account_prop = _profile.at<StringProperty>(PROFILE_ACCOUNT);
if(!account_prop) { if(!account_prop) {
_lastError = "Couldn't find an account ID in "_s + _filename; _lastError = "Couldn't find an account ID in "_s + _filename;
_valid = false; _valid = false;
@ -110,7 +111,7 @@ void Profile::refreshValues() {
Utility::Error{} << _filename << "is not a valid profile save."; Utility::Error{} << _filename << "is not a valid profile save.";
} }
auto name_prop = _profile.at<StringProperty>("CompanyName"_s); auto name_prop = _profile.at<StringProperty>(PROFILE_NAME);
if(!name_prop) { if(!name_prop) {
_lastError = "No company name in "_s + _filename; _lastError = "No company name in "_s + _filename;
_valid = false; _valid = false;
@ -118,41 +119,41 @@ void Profile::refreshValues() {
} }
_name = name_prop->value; _name = name_prop->value;
auto prop = _profile.at<IntProperty>("ActiveFrameSlot"_s); auto prop = _profile.at<IntProperty>(PROFILE_ACTIVE_FRAME_SLOT);
_activeFrameSlot = prop ? prop->value : 0; _activeFrameSlot = prop ? prop->value : 0;
prop = _profile.at<IntProperty>("Credit"_s); prop = _profile.at<IntProperty>(PROFILE_CREDITS);
_credits = prop ? prop->value : 0; _credits = prop ? prop->value : 0;
prop = _profile.at<IntProperty>("StoryProgress"_s); prop = _profile.at<IntProperty>(PROFILE_STORY_PROGRESS);
_storyProgress = prop ? prop->value : 0; _storyProgress = prop ? prop->value : 0;
prop = _profile.at<IntProperty>("LastMissionID"_s); prop = _profile.at<IntProperty>(PROFILE_LAST_MISSION_ID);
_lastMissionId = prop ? prop->value : 0; _lastMissionId = prop ? prop->value : 0;
_verseSteel = getResource("ResourceMaterial"_s, VerseSteel); _verseSteel = getResource(PROFILE_MATERIAL, VerseSteel);
_undinium = getResource("ResourceMaterial"_s, Undinium); _undinium = getResource(PROFILE_MATERIAL, Undinium);
_necriumAlloy = getResource("ResourceMaterial"_s, NecriumAlloy); _necriumAlloy = getResource(PROFILE_MATERIAL, NecriumAlloy);
_lunarite = getResource("ResourceMaterial"_s, Lunarite); _lunarite = getResource(PROFILE_MATERIAL, Lunarite);
_asterite = getResource("ResourceMaterial"_s, Asterite); _asterite = getResource(PROFILE_MATERIAL, Asterite);
_ednil = getResource("ResourceMaterial"_s, Ednil); _ednil = getResource(PROFILE_MATERIAL, Ednil);
_nuflalt = getResource("ResourceMaterial"_s, Nuflalt); _nuflalt = getResource(PROFILE_MATERIAL, Nuflalt);
_aurelene = getResource("ResourceMaterial"_s, Aurelene); _aurelene = getResource(PROFILE_MATERIAL, Aurelene);
_soldus = getResource("ResourceMaterial"_s, Soldus); _soldus = getResource(PROFILE_MATERIAL, Soldus);
_synthesisedN = getResource("ResourceMaterial"_s, SynthesisedN); _synthesisedN = getResource(PROFILE_MATERIAL, SynthesisedN);
_alcarbonite = getResource("ResourceMaterial"_s, Alcarbonite); _alcarbonite = getResource(PROFILE_MATERIAL, Alcarbonite);
_keriphene = getResource("ResourceMaterial"_s, Keriphene); _keriphene = getResource(PROFILE_MATERIAL, Keriphene);
_nitinolCM = getResource("ResourceMaterial"_s, NitinolCM); _nitinolCM = getResource(PROFILE_MATERIAL, NitinolCM);
_quarkium = getResource("ResourceMaterial"_s, Quarkium); _quarkium = getResource(PROFILE_MATERIAL, Quarkium);
_alterene = getResource("ResourceMaterial"_s, Alterene); _alterene = getResource(PROFILE_MATERIAL, Alterene);
_mixedComposition = getResource("ResourceQuarkData"_s, MixedComposition); _mixedComposition = getResource(PROFILE_QUARK_DATA, MixedComposition);
_voidResidue = getResource("ResourceQuarkData"_s, VoidResidue); _voidResidue = getResource(PROFILE_QUARK_DATA, VoidResidue);
_muscularConstruction = getResource("ResourceQuarkData"_s, MuscularConstruction); _muscularConstruction = getResource(PROFILE_QUARK_DATA, MuscularConstruction);
_mineralExoskeletology = getResource("ResourceQuarkData"_s, MineralExoskeletology); _mineralExoskeletology = getResource(PROFILE_QUARK_DATA, MineralExoskeletology);
_carbonisedSkin = getResource("ResourceQuarkData"_s, CarbonisedSkin); _carbonisedSkin = getResource(PROFILE_QUARK_DATA, CarbonisedSkin);
_valid = true; _valid = true;
} }
@ -162,7 +163,7 @@ auto Profile::companyName() const -> Containers::StringView {
} }
auto Profile::renameCompany(Containers::StringView new_name) -> bool { auto Profile::renameCompany(Containers::StringView new_name) -> bool {
auto name_prop = _profile.at<StringProperty>("CompanyName"_s); auto name_prop = _profile.at<StringProperty>(PROFILE_NAME);
if(!name_prop) { if(!name_prop) {
_lastError = "No company name in "_s + _filename; _lastError = "No company name in "_s + _filename;
_valid = false; _valid = false;
@ -188,7 +189,7 @@ auto Profile::credits() const -> Int {
} }
auto Profile::setCredits(Int amount) -> bool { auto Profile::setCredits(Int amount) -> bool {
auto credits_prop = _profile.at<IntProperty>("Credit"_s); auto credits_prop = _profile.at<IntProperty>(PROFILE_CREDITS);
if(!credits_prop) { if(!credits_prop) {
credits_prop = new IntProperty; credits_prop = new IntProperty;
@ -238,7 +239,7 @@ auto Profile::verseSteel() const -> Int {
} }
auto Profile::setVerseSteel(Int amount) -> bool { auto Profile::setVerseSteel(Int amount) -> bool {
return setResource("ResourceMaterial"_s, VerseSteel, amount); return setResource(PROFILE_MATERIAL, VerseSteel, amount);
} }
auto Profile::undinium() const -> Int { auto Profile::undinium() const -> Int {
@ -246,7 +247,7 @@ auto Profile::undinium() const -> Int {
} }
auto Profile::setUndinium(Int amount) -> bool { auto Profile::setUndinium(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Undinium, amount); return setResource(PROFILE_MATERIAL, Undinium, amount);
} }
auto Profile::necriumAlloy() const -> Int { auto Profile::necriumAlloy() const -> Int {
@ -254,7 +255,7 @@ auto Profile::necriumAlloy() const -> Int {
} }
auto Profile::setNecriumAlloy(Int amount) -> bool { auto Profile::setNecriumAlloy(Int amount) -> bool {
return setResource("ResourceMaterial"_s, NecriumAlloy, amount); return setResource(PROFILE_MATERIAL, NecriumAlloy, amount);
} }
auto Profile::lunarite() const -> Int { auto Profile::lunarite() const -> Int {
@ -262,7 +263,7 @@ auto Profile::lunarite() const -> Int {
} }
auto Profile::setLunarite(Int amount) -> bool { auto Profile::setLunarite(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Lunarite, amount); return setResource(PROFILE_MATERIAL, Lunarite, amount);
} }
auto Profile::asterite() const -> Int { auto Profile::asterite() const -> Int {
@ -270,7 +271,7 @@ auto Profile::asterite() const -> Int {
} }
auto Profile::setAsterite(Int amount) -> bool { auto Profile::setAsterite(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Asterite, amount); return setResource(PROFILE_MATERIAL, Asterite, amount);
} }
auto Profile::ednil() const -> Int { auto Profile::ednil() const -> Int {
@ -278,7 +279,7 @@ auto Profile::ednil() const -> Int {
} }
auto Profile::setEdnil(Int amount) -> bool { auto Profile::setEdnil(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Ednil, amount); return setResource(PROFILE_MATERIAL, Ednil, amount);
} }
auto Profile::nuflalt() const -> Int { auto Profile::nuflalt() const -> Int {
@ -286,7 +287,7 @@ auto Profile::nuflalt() const -> Int {
} }
auto Profile::setNuflalt(Int amount) -> bool { auto Profile::setNuflalt(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Nuflalt, amount); return setResource(PROFILE_MATERIAL, Nuflalt, amount);
} }
auto Profile::aurelene() const -> Int { auto Profile::aurelene() const -> Int {
@ -294,7 +295,7 @@ auto Profile::aurelene() const -> Int {
} }
auto Profile::setAurelene(Int amount) -> bool { auto Profile::setAurelene(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Aurelene, amount); return setResource(PROFILE_MATERIAL, Aurelene, amount);
} }
auto Profile::soldus() const -> Int { auto Profile::soldus() const -> Int {
@ -302,7 +303,7 @@ auto Profile::soldus() const -> Int {
} }
auto Profile::setSoldus(Int amount) -> bool { auto Profile::setSoldus(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Soldus, amount); return setResource(PROFILE_MATERIAL, Soldus, amount);
} }
auto Profile::synthesisedN() const -> Int { auto Profile::synthesisedN() const -> Int {
@ -310,7 +311,7 @@ auto Profile::synthesisedN() const -> Int {
} }
auto Profile::setSynthesisedN(Int amount) -> bool { auto Profile::setSynthesisedN(Int amount) -> bool {
return setResource("ResourceMaterial"_s, SynthesisedN, amount); return setResource(PROFILE_MATERIAL, SynthesisedN, amount);
} }
auto Profile::alcarbonite() const -> Int { auto Profile::alcarbonite() const -> Int {
@ -318,7 +319,7 @@ auto Profile::alcarbonite() const -> Int {
} }
auto Profile::setAlcarbonite(Int amount) -> bool { auto Profile::setAlcarbonite(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Alcarbonite, amount); return setResource(PROFILE_MATERIAL, Alcarbonite, amount);
} }
auto Profile::keriphene() const -> Int { auto Profile::keriphene() const -> Int {
@ -326,7 +327,7 @@ auto Profile::keriphene() const -> Int {
} }
auto Profile::setKeriphene(Int amount) -> bool { auto Profile::setKeriphene(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Keriphene, amount); return setResource(PROFILE_MATERIAL, Keriphene, amount);
} }
auto Profile::nitinolCM() const -> Int { auto Profile::nitinolCM() const -> Int {
@ -334,7 +335,7 @@ auto Profile::nitinolCM() const -> Int {
} }
auto Profile::setNitinolCM(Int amount) -> bool { auto Profile::setNitinolCM(Int amount) -> bool {
return setResource("ResourceMaterial"_s, NitinolCM, amount); return setResource(PROFILE_MATERIAL, NitinolCM, amount);
} }
auto Profile::quarkium() const -> Int { auto Profile::quarkium() const -> Int {
@ -342,7 +343,7 @@ auto Profile::quarkium() const -> Int {
} }
auto Profile::setQuarkium(Int amount) -> bool { auto Profile::setQuarkium(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Quarkium, amount); return setResource(PROFILE_MATERIAL, Quarkium, amount);
} }
auto Profile::alterene() const -> Int { auto Profile::alterene() const -> Int {
@ -350,7 +351,7 @@ auto Profile::alterene() const -> Int {
} }
auto Profile::setAlterene(Int amount) -> bool { auto Profile::setAlterene(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Alterene, amount); return setResource(PROFILE_MATERIAL, Alterene, amount);
} }
auto Profile::mixedComposition() const -> Int { auto Profile::mixedComposition() const -> Int {
@ -358,7 +359,7 @@ auto Profile::mixedComposition() const -> Int {
} }
auto Profile::setMixedComposition(Int amount) -> bool { auto Profile::setMixedComposition(Int amount) -> bool {
return setResource("ResourceQuarkData"_s, MixedComposition, amount); return setResource(PROFILE_QUARK_DATA, MixedComposition, amount);
} }
auto Profile::voidResidue() const -> Int { auto Profile::voidResidue() const -> Int {
@ -366,7 +367,7 @@ auto Profile::voidResidue() const -> Int {
} }
auto Profile::setVoidResidue(Int amount) -> bool { auto Profile::setVoidResidue(Int amount) -> bool {
return setResource("ResourceQuarkData"_s, VoidResidue, amount); return setResource(PROFILE_QUARK_DATA, VoidResidue, amount);
} }
auto Profile::muscularConstruction() const -> Int { auto Profile::muscularConstruction() const -> Int {
@ -374,7 +375,7 @@ auto Profile::muscularConstruction() const -> Int {
} }
auto Profile::setMuscularConstruction(Int amount) -> bool { auto Profile::setMuscularConstruction(Int amount) -> bool {
return setResource("ResourceQuarkData"_s, MuscularConstruction, amount); return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount);
} }
auto Profile::mineralExoskeletology() const -> Int { auto Profile::mineralExoskeletology() const -> Int {
@ -382,7 +383,7 @@ auto Profile::mineralExoskeletology() const -> Int {
} }
auto Profile::setMineralExoskeletology(Int amount) -> bool { auto Profile::setMineralExoskeletology(Int amount) -> bool {
return setResource("ResourceQuarkData"_s, MineralExoskeletology, amount); return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount);
} }
auto Profile::carbonisedSkin() const -> Int { auto Profile::carbonisedSkin() const -> Int {
@ -390,7 +391,7 @@ auto Profile::carbonisedSkin() const -> Int {
} }
auto Profile::setCarbonisedSkin(Int amount) -> bool { 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 { auto Profile::getResource(Containers::StringView container, MaterialID id) -> Int {

View file

@ -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"