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;
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;
}

View file

@ -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;

View file

@ -18,8 +18,6 @@
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <regex>
#include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/StaticArray.h>
@ -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;

View file

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

View file

@ -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);