Profile(Manager),SaveTool: get rid of that legacy nonsense.

This commit is contained in:
Guillaume Jacquemin 2022-11-21 19:03:00 +01:00
parent bf820f65ec
commit e795e276da
5 changed files with 6 additions and 51 deletions

View file

@ -56,13 +56,6 @@ Profile::Profile(Containers::StringView path):
} }
_account = account_prop->value; _account = account_prop->value;
if(_account.hasPrefix("PMCSlot"_s)) {
_version = ProfileVersion::Normal;
}
else {
_version = ProfileVersion::Legacy;
}
refreshValues(); refreshValues();
} }
@ -86,14 +79,6 @@ auto Profile::isDemo() const -> bool {
return _type == ProfileType::Demo; 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 { auto Profile::account() const -> Containers::StringView {
return _account; return _account;
} }

View file

@ -33,11 +33,6 @@ enum class ProfileType : UnsignedByte {
FullGame FullGame
}; };
enum class ProfileVersion : UnsignedByte {
Legacy, // pre-0.8
Normal // 0.8 and later
};
class Profile { class Profile {
public: public:
explicit Profile(Containers::StringView path); explicit Profile(Containers::StringView path);
@ -51,9 +46,6 @@ class Profile {
auto type() const -> ProfileType; auto type() const -> ProfileType;
auto isDemo() const -> bool; auto isDemo() const -> bool;
auto version() const -> ProfileVersion;
auto isLegacy() const -> bool;
auto account() const -> Containers::StringView; auto account() const -> Containers::StringView;
void refreshValues(); void refreshValues();
@ -138,7 +130,6 @@ class Profile {
Containers::String _filename; Containers::String _filename;
ProfileType _type; ProfileType _type;
ProfileVersion _version;
UESaveFile _profile; UESaveFile _profile;

View file

@ -18,8 +18,6 @@
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <iomanip>
#include <regex>
#include <Corrade/Containers/ScopeGuard.h> #include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
@ -65,10 +63,7 @@ auto ProfileManager::refreshProfiles() -> bool {
} }
auto predicate = [](Containers::StringView file)->bool{ auto predicate = [](Containers::StringView file)->bool{
std::regex legacy_regex("(Demo)?Profile[0-9]{17}\\.sav", std::regex::nosubs); return !((file.hasPrefix("DemoProfile") || file.hasPrefix("Profile")) && file.hasSuffix(".sav"));
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);
}; };
auto files_view = files->exceptSuffix(files->end() - std::remove_if(files->begin(), files->end(), predicate)); 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; return false;
} }
auto comment = Utility::format("{}|{}{}|{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}", auto comment = Utility::format("{}|{}|{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}",
profile.companyName(), profile.companyName(),
profile.isDemo() ? "demo"_s : "full"_s, profile.isDemo() ? "demo"_s : "full"_s,
profile.isLegacy() ? ""_s : "_new"_s,
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
time->tm_hour, time->tm_min, time->tm_sec); time->tm_hour, time->tm_min, time->tm_sec);
zip_set_archive_comment(zip, comment.data(), comment.size()); zip_set_archive_comment(zip, comment.data(), comment.size());
@ -252,21 +246,11 @@ void ProfileManager::refreshBackups() {
backup.company = info[0]; backup.company = info[0];
if(info[1] == "full") { if(info[1].hasPrefix("full")) {
backup.type = ProfileType::FullGame; backup.type = ProfileType::FullGame;
backup.version = ProfileVersion::Legacy;
} }
else if(info[1] == "demo") { else if(info[1].hasPrefix("demo")) {
backup.type = ProfileType::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 { else {
continue; continue;

View file

@ -29,7 +29,6 @@ struct Backup {
Containers::String filename; Containers::String filename;
Containers::String company; Containers::String company;
ProfileType type; ProfileType type;
ProfileVersion version;
struct { struct {
int year; int year;
int month; int month;

View file

@ -95,9 +95,7 @@ void SaveTool::drawProfileManager() {
} }
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("%s%s", ImGui::TextUnformatted(profile.isDemo() ? "Demo" : "Full");
profile.isDemo() ? "Demo" : "Full",
profile.isLegacy() ? " (legacy)" : "");
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
if(ImGui::SmallButton(ICON_FA_FILE_ARCHIVE)) { if(ImGui::SmallButton(ICON_FA_FILE_ARCHIVE)) {
@ -278,9 +276,7 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
backup.timestamp.second); backup.timestamp.second);
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
ImGui::Text("%s%s", ImGui::TextUnformatted(backup.type == ProfileType::Demo ? "Demo" : "Full");
backup.type == ProfileType::Demo ? "Demo" : "Full",
backup.version == ProfileVersion::Legacy ? " (legacy)" : "");
ImGui::TableSetColumnIndex(3); ImGui::TableSetColumnIndex(3);
ImGui::PushID(i); ImGui::PushID(i);