Compare commits
3 commits
fdb7567aea
...
db6836ec33
Author | SHA1 | Date | |
---|---|---|---|
db6836ec33 | |||
89bba618fb | |||
88afaaceec |
21 changed files with 48 additions and 41 deletions
|
@ -36,16 +36,21 @@ using namespace Containers::Literals;
|
|||
Profile::Profile(Containers::StringView path):
|
||||
_profile(path)
|
||||
{
|
||||
if(!_profile.valid()) {
|
||||
_lastError = _profile.lastError();
|
||||
return;
|
||||
}
|
||||
|
||||
_filename = Utility::Directory::filename(path);
|
||||
|
||||
if(Utility::String::beginsWith(_filename, "Demo"_s)) {
|
||||
if(_filename.hasPrefix("Demo"_s)) {
|
||||
_type = ProfileType::Demo;
|
||||
}
|
||||
else {
|
||||
_type = ProfileType::FullGame;
|
||||
}
|
||||
|
||||
auto account_prop = _profile.at<StringProperty>("Account");
|
||||
auto account_prop = _profile.at<StringProperty>("Account"_s);
|
||||
if(!account_prop) {
|
||||
_lastError = "Couldn't find an account ID in "_s + _filename;
|
||||
_valid = false;
|
||||
|
@ -53,7 +58,7 @@ Profile::Profile(Containers::StringView path):
|
|||
}
|
||||
_account = account_prop->value;
|
||||
|
||||
if(Utility::String::beginsWith(_account, "PMCSlot"_s)) {
|
||||
if(_account.hasPrefix("PMCSlot"_s)) {
|
||||
_version = ProfileVersion::Normal;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -60,9 +60,10 @@ auto ProfileManager::refreshProfiles() -> bool {
|
|||
auto files = Utility::Directory::list(_saveDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
|
||||
|
||||
auto predicate = [](Containers::StringView file)->bool{
|
||||
std::regex regex("(Demo)?Profile[0-9]{17}\\.sav", std::regex::nosubs);
|
||||
std::regex legacy_regex("(Demo)?Profile[0-9]{17}\\.sav", std::regex::nosubs);
|
||||
std::regex new_regex("(Demo)?ProfilePMCSlot[0-9]{3}\\.sav", std::regex::nosubs);
|
||||
std::cmatch m;
|
||||
return !std::regex_match(file.data(), m, regex);
|
||||
return !std::regex_match(file.data(), m, legacy_regex) && !std::regex_match(file.data(), m, new_regex);
|
||||
};
|
||||
|
||||
files.erase(std::remove_if(files.begin(), files.end(), predicate), files.end());
|
||||
|
|
|
@ -188,10 +188,10 @@ void SaveTool::drawGeneralInfo() {
|
|||
ImGui::TextUnformatted("Story progress:");
|
||||
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.x / 4.0f);
|
||||
if(!it->after) {
|
||||
ImGui::TextWrapped("%s - %s", it->chapter, it->point);
|
||||
ImGui::TextWrapped("%s - %s", it->chapter.data(), it->point.data());
|
||||
}
|
||||
else {
|
||||
ImGui::TextWrapped("%s - %s - %s", it->chapter, it->after, it->point);
|
||||
ImGui::TextWrapped("%s - %s - %s", it->chapter.data(), it->after.data(), it->point.data());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -199,7 +199,7 @@ void SaveTool::drawGeneralInfo() {
|
|||
}
|
||||
|
||||
if(mission_id_map.find(_currentProfile->lastMissionId()) != mission_id_map.cend()) {
|
||||
ImGui::Text("Last mission: %s", mission_id_map.at(_currentProfile->lastMissionId()));
|
||||
ImGui::Text("Last mission: %s", mission_id_map.at(_currentProfile->lastMissionId()).data());
|
||||
}
|
||||
else if(_currentProfile->lastMissionId() == -1) {
|
||||
ImGui::TextUnformatted("Last mission: none");
|
||||
|
|
|
@ -491,7 +491,7 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
|
|||
ImGui::TextUnformatted("Accessory: <none>");
|
||||
}
|
||||
else if(accessories.find(accessory.id) != accessories.cend()) {
|
||||
ImGui::Text("Accessory #%i - %s", accessory.id, accessories.at(accessory.id));
|
||||
ImGui::Text("Accessory #%i - %s", accessory.id, accessories.at(accessory.id).data());
|
||||
}
|
||||
else {
|
||||
ImGui::Text("Accessory #%i", accessory.id);
|
||||
|
|
|
@ -77,11 +77,13 @@ void SaveTool::drawProfileManager() {
|
|||
ImGui::TextUnformatted("Actions");
|
||||
|
||||
for(std::size_t i = 0; i < _profileManager->profiles().size(); ++i) {
|
||||
Profile& profile = _profileManager->profiles()[i];
|
||||
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::PushID(i);
|
||||
if(ImGui::Selectable(_profileManager->profiles()[i].companyName().data(), false,
|
||||
if(ImGui::Selectable(profile.companyName().data(), false,
|
||||
ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap))
|
||||
{
|
||||
_currentProfile = _profileManager->getProfile(i);
|
||||
|
@ -90,7 +92,9 @@ void SaveTool::drawProfileManager() {
|
|||
}
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextUnformatted(_profileManager->profiles()[i].type() == ProfileType::Demo ? "Demo (legacy)" : "Full (legacy)");
|
||||
ImGui::Text("%s%s",
|
||||
profile.type() == ProfileType::Demo ? "Demo" : "Full",
|
||||
profile.version() == ProfileVersion::Legacy ? " (legacy)" : "");
|
||||
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
if(ImGui::SmallButton(ICON_FA_FILE_ARCHIVE)) {
|
||||
|
|
|
@ -238,10 +238,8 @@ auto PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr>
|
|||
}
|
||||
|
||||
auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser* {
|
||||
!Utility::Debug{};
|
||||
for(auto& item : _serialisers) {
|
||||
for(auto serialiser_type : item->types()) {
|
||||
Utility::Debug{} << serialiser_type;
|
||||
if(item_type == serialiser_type) {
|
||||
return item.get();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class AbstractUnrealCollectionPropertySerialiser {
|
|||
|
||||
virtual ~AbstractUnrealCollectionPropertySerialiser() = default;
|
||||
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::StringView> = 0;
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
|
||||
|
||||
virtual auto deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, UnsignedInt count, BinaryReader& reader,
|
||||
|
|
|
@ -37,7 +37,7 @@ class AbstractUnrealPropertySerialiser {
|
|||
|
||||
virtual ~AbstractUnrealPropertySerialiser() = default;
|
||||
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::StringView> = 0;
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
|
||||
|
||||
virtual auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr = 0;
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "BoolPropertySerialiser.h"
|
||||
|
||||
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"BoolProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"BoolProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<BoolPropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "BytePropertySerialiser.h"
|
||||
|
||||
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"ByteProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"ByteProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<BytePropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "EnumPropertySerialiser.h"
|
||||
|
||||
auto EnumPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto EnumPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"EnumProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"EnumProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<EnumPropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
|
||||
#include "FloatPropertySerialiser.h"
|
||||
|
||||
|
||||
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"FloatProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"FloatProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<FloatPropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
#include "StringPropertySerialiser.h"
|
||||
|
||||
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit,
|
||||
{"NameProperty"_s, "StrProperty"_s,
|
||||
"SoftObjectProperty"_s, "ObjectProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit,
|
||||
{"NameProperty"_s, "StrProperty"_s,
|
||||
"SoftObjectProperty"_s, "ObjectProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<StringPropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
#include "StructSerialiser.h"
|
||||
|
||||
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"StructProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"StructProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class StructSerialiser : public AbstractUnrealPropertySerialiser, public Abstrac
|
|||
public:
|
||||
using ptr = Containers::Pointer<StructSerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> override;
|
||||
|
|
|
@ -32,15 +32,15 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<UnrealPropertySerialiser<T>>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override {
|
||||
static const Containers::Array<Containers::StringView> types = []{
|
||||
Containers::Array<Containers::StringView> array;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override {
|
||||
static const Containers::Array<Containers::String> types = []{
|
||||
Containers::Array<Containers::String> array;
|
||||
Containers::Pointer<T> p(new T);
|
||||
if(std::is_base_of<StructProperty, T>::value) {
|
||||
array = Containers::Array<Containers::StringView>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}};
|
||||
array = Containers::Array<Containers::String>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}};
|
||||
}
|
||||
else {
|
||||
array = Containers::Array<Containers::StringView>{InPlaceInit, {p->propertyType}};
|
||||
array = Containers::Array<Containers::String>{InPlaceInit, {p->propertyType}};
|
||||
}
|
||||
return array;
|
||||
}();
|
||||
|
|
Loading…
Reference in a new issue