From e795e276dad29946890105c4254a8aa235e52b56 Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 21 Nov 2022 19:03:00 +0100 Subject: [PATCH] Profile(Manager),SaveTool: get rid of that legacy nonsense. --- src/Profile/Profile.cpp | 15 --------------- src/Profile/Profile.h | 9 --------- src/ProfileManager/ProfileManager.cpp | 24 ++++-------------------- src/ProfileManager/ProfileManager.h | 1 - src/SaveTool/SaveTool_ProfileManager.cpp | 8 ++------ 5 files changed, 6 insertions(+), 51 deletions(-) diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index ed0d9d4..4082120 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -56,13 +56,6 @@ Profile::Profile(Containers::StringView path): } _account = account_prop->value; - if(_account.hasPrefix("PMCSlot"_s)) { - _version = ProfileVersion::Normal; - } - else { - _version = ProfileVersion::Legacy; - } - refreshValues(); } @@ -86,14 +79,6 @@ auto Profile::isDemo() const -> bool { return _type == ProfileType::Demo; } -auto Profile::version() const -> ProfileVersion { - return _version; -} - -auto Profile::isLegacy() const -> bool { - return _version == ProfileVersion::Legacy; -} - auto Profile::account() const -> Containers::StringView { return _account; } diff --git a/src/Profile/Profile.h b/src/Profile/Profile.h index ddc95e2..403a2db 100644 --- a/src/Profile/Profile.h +++ b/src/Profile/Profile.h @@ -33,11 +33,6 @@ enum class ProfileType : UnsignedByte { FullGame }; -enum class ProfileVersion : UnsignedByte { - Legacy, // pre-0.8 - Normal // 0.8 and later -}; - class Profile { public: explicit Profile(Containers::StringView path); @@ -51,9 +46,6 @@ class Profile { auto type() const -> ProfileType; auto isDemo() const -> bool; - auto version() const -> ProfileVersion; - auto isLegacy() const -> bool; - auto account() const -> Containers::StringView; void refreshValues(); @@ -138,7 +130,6 @@ class Profile { Containers::String _filename; ProfileType _type; - ProfileVersion _version; UESaveFile _profile; diff --git a/src/ProfileManager/ProfileManager.cpp b/src/ProfileManager/ProfileManager.cpp index e9b3c57..575be61 100644 --- a/src/ProfileManager/ProfileManager.cpp +++ b/src/ProfileManager/ProfileManager.cpp @@ -18,8 +18,6 @@ #include #include -#include -#include #include #include @@ -65,10 +63,7 @@ auto ProfileManager::refreshProfiles() -> bool { } 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::cmatch m; - return !std::regex_match(file.data(), m, legacy_regex) && !std::regex_match(file.data(), m, new_regex); + return !((file.hasPrefix("DemoProfile") || file.hasPrefix("Profile")) && file.hasSuffix(".sav")); }; auto files_view = files->exceptSuffix(files->end() - std::remove_if(files->begin(), files->end(), predicate)); @@ -156,10 +151,9 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo return false; } - auto comment = Utility::format("{}|{}{}|{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}", + auto comment = Utility::format("{}|{}|{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}", profile.companyName(), profile.isDemo() ? "demo"_s : "full"_s, - profile.isLegacy() ? ""_s : "_new"_s, time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec); zip_set_archive_comment(zip, comment.data(), comment.size()); @@ -252,21 +246,11 @@ void ProfileManager::refreshBackups() { backup.company = info[0]; - if(info[1] == "full") { + if(info[1].hasPrefix("full")) { backup.type = ProfileType::FullGame; - backup.version = ProfileVersion::Legacy; } - else if(info[1] == "demo") { + else if(info[1].hasPrefix("demo")) { backup.type = ProfileType::Demo; - backup.version = ProfileVersion::Legacy; - } - else if(info[1] == "full_new") { - backup.type = ProfileType::FullGame; - backup.version = ProfileVersion::Normal; - } - else if(info[1] == "demo_new") { - backup.type = ProfileType::Demo; - backup.version = ProfileVersion::Normal; } else { continue; diff --git a/src/ProfileManager/ProfileManager.h b/src/ProfileManager/ProfileManager.h index 75950f0..0fe9e11 100644 --- a/src/ProfileManager/ProfileManager.h +++ b/src/ProfileManager/ProfileManager.h @@ -29,7 +29,6 @@ struct Backup { Containers::String filename; Containers::String company; ProfileType type; - ProfileVersion version; struct { int year; int month; diff --git a/src/SaveTool/SaveTool_ProfileManager.cpp b/src/SaveTool/SaveTool_ProfileManager.cpp index a7c2287..08a037d 100644 --- a/src/SaveTool/SaveTool_ProfileManager.cpp +++ b/src/SaveTool/SaveTool_ProfileManager.cpp @@ -95,9 +95,7 @@ void SaveTool::drawProfileManager() { } ImGui::TableSetColumnIndex(1); - ImGui::Text("%s%s", - profile.isDemo() ? "Demo" : "Full", - profile.isLegacy() ? " (legacy)" : ""); + ImGui::TextUnformatted(profile.isDemo() ? "Demo" : "Full"); ImGui::TableSetColumnIndex(2); if(ImGui::SmallButton(ICON_FA_FILE_ARCHIVE)) { @@ -278,9 +276,7 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID { backup.timestamp.second); ImGui::TableSetColumnIndex(2); - ImGui::Text("%s%s", - backup.type == ProfileType::Demo ? "Demo" : "Full", - backup.version == ProfileVersion::Legacy ? " (legacy)" : ""); + ImGui::TextUnformatted(backup.type == ProfileType::Demo ? "Demo" : "Full"); ImGui::TableSetColumnIndex(3); ImGui::PushID(i);