Profile: use Logger.
This commit is contained in:
parent
e795e276da
commit
8cf5351f0b
1 changed files with 17 additions and 2 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <Corrade/Utility/Path.h>
|
||||
|
||||
#include "PropertyNames.h"
|
||||
#include "../Logger/Logger.h"
|
||||
#include "../UESaveFile/Types/ArrayProperty.h"
|
||||
#include "../UESaveFile/Types/ResourceItemValue.h"
|
||||
#include "../UESaveFile/Types/IntProperty.h"
|
||||
|
@ -33,6 +34,8 @@ using namespace Containers::Literals;
|
|||
Profile::Profile(Containers::StringView path):
|
||||
_profile(path)
|
||||
{
|
||||
LOG_INFO_FORMAT("Reading profile at {}.", path);
|
||||
|
||||
if(!_profile.valid()) {
|
||||
_lastError = _profile.lastError();
|
||||
_valid = false;
|
||||
|
@ -85,35 +88,44 @@ auto Profile::account() const -> Containers::StringView {
|
|||
|
||||
void Profile::refreshValues() {
|
||||
if(!_profile.reloadData()) {
|
||||
_lastError = _profile.lastError();
|
||||
LOG_ERROR(_profile.lastError());
|
||||
_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(_profile.saveType() != "/Game/Core/Save/bpSaveGameProfile.bpSaveGameProfile_C"_s) {
|
||||
Utility::Error{} << _filename << "is not a valid profile save.";
|
||||
LOG_ERROR_FORMAT("{} is not a valid profile save.", _filename);
|
||||
_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INFO("Getting the company name.");
|
||||
auto name_prop = _profile.at<StringProperty>(PROFILE_NAME);
|
||||
if(!name_prop) {
|
||||
_lastError = "No company name in "_s + _filename;
|
||||
LOG_ERROR(_lastError);
|
||||
_valid = false;
|
||||
return;
|
||||
}
|
||||
_name = name_prop->value;
|
||||
|
||||
LOG_INFO("Getting the active frame slot.");
|
||||
auto prop = _profile.at<IntProperty>(PROFILE_ACTIVE_FRAME_SLOT);
|
||||
_activeFrameSlot = prop ? prop->value : 0;
|
||||
|
||||
LOG_INFO("Getting the credits.");
|
||||
prop = _profile.at<IntProperty>(PROFILE_CREDITS);
|
||||
_credits = prop ? prop->value : 0;
|
||||
|
||||
LOG_INFO("Getting the story progress.");
|
||||
prop = _profile.at<IntProperty>(PROFILE_STORY_PROGRESS);
|
||||
_storyProgress = prop ? prop->value : 0;
|
||||
|
||||
LOG_INFO("Getting the last mission ID.");
|
||||
prop = _profile.at<IntProperty>(PROFILE_LAST_MISSION_ID);
|
||||
_lastMissionId = prop ? prop->value : 0;
|
||||
|
||||
LOG_INFO("Getting the materials.");
|
||||
_verseSteel = getResource(PROFILE_MATERIAL, VerseSteel);
|
||||
_undinium = getResource(PROFILE_MATERIAL, Undinium);
|
||||
_necriumAlloy = getResource(PROFILE_MATERIAL, NecriumAlloy);
|
||||
|
@ -149,6 +161,7 @@ auto Profile::renameCompany(Containers::StringView new_name) -> bool {
|
|||
auto name_prop = _profile.at<StringProperty>(PROFILE_NAME);
|
||||
if(!name_prop) {
|
||||
_lastError = "No company name in "_s + _filename;
|
||||
LOG_ERROR(_lastError);
|
||||
_valid = false;
|
||||
return false;
|
||||
}
|
||||
|
@ -177,6 +190,7 @@ auto Profile::setCredits(Int amount) -> bool {
|
|||
if(!credits_prop) {
|
||||
credits_prop = new IntProperty;
|
||||
credits_prop->name.emplace("Credit"_s);
|
||||
credits_prop->valueLength = sizeof(Int);
|
||||
_profile.appendProperty(IntProperty::ptr{credits_prop});
|
||||
}
|
||||
|
||||
|
@ -200,6 +214,7 @@ auto Profile::setStoryProgress(Int progress) -> bool {
|
|||
if(!story_progress_prop) {
|
||||
story_progress_prop = new IntProperty;
|
||||
story_progress_prop->name.emplace("StoryProgress"_s);
|
||||
story_progress_prop->valueLength = sizeof(Int);
|
||||
_profile.appendProperty(IntProperty::ptr{story_progress_prop});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue