Compare commits

..

No commits in common. "db6836ec33c077229a8db6338cdb17e7ec6f86fe" and "fdb7567aea4bd9edc0e66936c24e44dbea59a369" have entirely different histories.

21 changed files with 41 additions and 48 deletions

View file

@ -36,21 +36,16 @@ using namespace Containers::Literals;
Profile::Profile(Containers::StringView path):
_profile(path)
{
if(!_profile.valid()) {
_lastError = _profile.lastError();
return;
}
_filename = Utility::Directory::filename(path);
if(_filename.hasPrefix("Demo"_s)) {
if(Utility::String::beginsWith(_filename, "Demo"_s)) {
_type = ProfileType::Demo;
}
else {
_type = ProfileType::FullGame;
}
auto account_prop = _profile.at<StringProperty>("Account"_s);
auto account_prop = _profile.at<StringProperty>("Account");
if(!account_prop) {
_lastError = "Couldn't find an account ID in "_s + _filename;
_valid = false;
@ -58,7 +53,7 @@ Profile::Profile(Containers::StringView path):
}
_account = account_prop->value;
if(_account.hasPrefix("PMCSlot"_s)) {
if(Utility::String::beginsWith(_account, "PMCSlot"_s)) {
_version = ProfileVersion::Normal;
}
else {

View file

@ -60,10 +60,9 @@ auto ProfileManager::refreshProfiles() -> bool {
auto files = Utility::Directory::list(_saveDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
auto predicate = [](Containers::StringView file)->bool{
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::regex regex("(Demo)?Profile[0-9]{17}\\.sav", std::regex::nosubs);
std::cmatch m;
return !std::regex_match(file.data(), m, legacy_regex) && !std::regex_match(file.data(), m, new_regex);
return !std::regex_match(file.data(), m, regex);
};
files.erase(std::remove_if(files.begin(), files.end(), predicate), files.end());

View file

@ -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.data(), it->point.data());
ImGui::TextWrapped("%s - %s", it->chapter, it->point);
}
else {
ImGui::TextWrapped("%s - %s - %s", it->chapter.data(), it->after.data(), it->point.data());
ImGui::TextWrapped("%s - %s - %s", it->chapter, it->after, it->point);
}
}
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()).data());
ImGui::Text("Last mission: %s", mission_id_map.at(_currentProfile->lastMissionId()));
}
else if(_currentProfile->lastMissionId() == -1) {
ImGui::TextUnformatted("Last mission: none");

View file

@ -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).data());
ImGui::Text("Accessory #%i - %s", accessory.id, accessories.at(accessory.id));
}
else {
ImGui::Text("Accessory #%i", accessory.id);

View file

@ -77,13 +77,11 @@ 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(profile.companyName().data(), false,
if(ImGui::Selectable(_profileManager->profiles()[i].companyName().data(), false,
ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap))
{
_currentProfile = _profileManager->getProfile(i);
@ -92,9 +90,7 @@ void SaveTool::drawProfileManager() {
}
ImGui::TableSetColumnIndex(1);
ImGui::Text("%s%s",
profile.type() == ProfileType::Demo ? "Demo" : "Full",
profile.version() == ProfileVersion::Legacy ? " (legacy)" : "");
ImGui::TextUnformatted(_profileManager->profiles()[i].type() == ProfileType::Demo ? "Demo (legacy)" : "Full (legacy)");
ImGui::TableSetColumnIndex(2);
if(ImGui::SmallButton(ICON_FA_FILE_ARCHIVE)) {

View file

@ -238,8 +238,10 @@ 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();
}

View file

@ -38,7 +38,7 @@ class AbstractUnrealCollectionPropertySerialiser {
virtual ~AbstractUnrealCollectionPropertySerialiser() = default;
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
virtual auto types() -> Containers::ArrayView<const Containers::StringView> = 0;
virtual auto deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, UnsignedInt count, BinaryReader& reader,

View file

@ -37,7 +37,7 @@ class AbstractUnrealPropertySerialiser {
virtual ~AbstractUnrealPropertySerialiser() = default;
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
virtual auto types() -> Containers::ArrayView<const Containers::StringView> = 0;
virtual auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr = 0;

View file

@ -19,9 +19,9 @@
#include "BoolPropertySerialiser.h"
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"BoolProperty"_s}};
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"BoolProperty"_s}};
return types;
}

View file

@ -29,7 +29,7 @@ class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<BoolPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;

View file

@ -19,9 +19,9 @@
#include "BytePropertySerialiser.h"
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"ByteProperty"_s}};
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"ByteProperty"_s}};
return types;
}

View file

@ -27,7 +27,7 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<BytePropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;

View file

@ -19,9 +19,9 @@
#include "EnumPropertySerialiser.h"
auto EnumPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
auto EnumPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"EnumProperty"_s}};
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"EnumProperty"_s}};
return types;
}

View file

@ -27,7 +27,7 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<EnumPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;

View file

@ -19,9 +19,10 @@
#include "FloatPropertySerialiser.h"
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"FloatProperty"_s}};
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"FloatProperty"_s}};
return types;
}

View file

@ -27,7 +27,7 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<FloatPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;

View file

@ -19,9 +19,9 @@
#include "StringPropertySerialiser.h"
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit,
static const Containers::Array<Containers::StringView> types{InPlaceInit,
{"NameProperty"_s, "StrProperty"_s,
"SoftObjectProperty"_s, "ObjectProperty"_s}};
return types;

View file

@ -27,7 +27,7 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<StringPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;

View file

@ -25,9 +25,9 @@
#include "StructSerialiser.h"
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::String> {
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
using namespace Containers::Literals;
static const Containers::Array<Containers::String> types{InPlaceInit, {"StructProperty"_s}};
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"StructProperty"_s}};
return types;
}

View file

@ -29,7 +29,7 @@ class StructSerialiser : public AbstractUnrealPropertySerialiser, public Abstrac
public:
using ptr = Containers::Pointer<StructSerialiser>;
auto types() -> Containers::ArrayView<const Containers::String> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> override;

View file

@ -32,15 +32,15 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<UnrealPropertySerialiser<T>>;
auto types() -> Containers::ArrayView<const Containers::String> override {
static const Containers::Array<Containers::String> types = []{
Containers::Array<Containers::String> array;
auto types() -> Containers::ArrayView<const Containers::StringView> override {
static const Containers::Array<Containers::StringView> types = []{
Containers::Array<Containers::StringView> array;
Containers::Pointer<T> p(new T);
if(std::is_base_of<StructProperty, T>::value) {
array = Containers::Array<Containers::String>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}};
array = Containers::Array<Containers::StringView>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}};
}
else {
array = Containers::Array<Containers::String>{InPlaceInit, {p->propertyType}};
array = Containers::Array<Containers::StringView>{InPlaceInit, {p->propertyType}};
}
return array;
}();