Compare commits
No commits in common. "ce0ca07afc3641052c785f4bbe0c15dd55b75bb5" and "75d77413f6f9851c6592fc8e58c11586ede65703" have entirely different histories.
ce0ca07afc
...
75d77413f6
6 changed files with 22 additions and 46 deletions
|
@ -127,10 +127,9 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo
|
||||||
auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> bool {
|
auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> bool {
|
||||||
std::time_t timestamp = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
std::time_t timestamp = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||||
std::tm* time = std::localtime(×tamp);
|
std::tm* time = std::localtime(×tamp);
|
||||||
auto& profile = _profiles[index];
|
|
||||||
|
|
||||||
auto filename = Utility::format("{}_{}{:.2d}{:.2d}_{:.2d}{:.2d}{:.2d}.mbprofbackup",
|
auto filename = Utility::format("{}_{}{:.2d}{:.2d}_{:.2d}{:.2d}{:.2d}.mbprofbackup",
|
||||||
Utility::String::replaceAll(profile.companyName().data(), " ", "_").c_str(),
|
Utility::String::replaceAll(_profiles[index].companyName().data(), " ", "_").c_str(),
|
||||||
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);
|
||||||
|
|
||||||
|
@ -143,32 +142,31 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
zip_source_t* profile_source = zip_source_file(zip, Utility::Path::toNativeSeparators(Utility::Path::join(_saveDirectory, profile.filename())).data(), 0, 0);
|
zip_source_t* profile_source = zip_source_file(zip, Utility::Path::toNativeSeparators(Utility::Path::join(_saveDirectory, _profiles[index].filename())).data(), 0, 0);
|
||||||
if(profile_source == nullptr) {
|
if(profile_source == nullptr) {
|
||||||
_lastError = zip_strerror(zip);
|
_lastError = zip_strerror(zip);
|
||||||
zip_source_free(profile_source);
|
zip_source_free(profile_source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(zip_file_add(zip, profile.filename().data(), profile_source, ZIP_FL_ENC_UTF_8) == -1) {
|
if(zip_file_add(zip, _profiles[index].filename().data(), profile_source, ZIP_FL_ENC_UTF_8) == -1) {
|
||||||
_lastError = zip_strerror(zip);
|
_lastError = zip_strerror(zip);
|
||||||
zip_source_free(profile_source);
|
zip_source_free(profile_source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto comment = Utility::format("{}|{}{}|{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}",
|
auto comment = "|"_s.join({_profiles[index].companyName(),
|
||||||
profile.companyName(),
|
_profiles[index].type() == ProfileType::Demo ? "demo"_s : "full"_s,
|
||||||
profile.isDemo() ? "demo"_s : "full"_s,
|
Utility::format("{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}",
|
||||||
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());
|
||||||
|
|
||||||
if(backup_builds) {
|
if(backup_builds) {
|
||||||
for(UnsignedByte i = 0; i < 32; ++i) {
|
for(UnsignedByte i = 0; i < 32; ++i) {
|
||||||
auto build_filename = Utility::format("{}Unit{:.2d}{}.sav",
|
auto build_filename = Utility::format("{}Unit{:.2d}{}.sav",
|
||||||
profile.isDemo() ? "Demo"_s : ""_s, i,
|
_profiles[index].type() == ProfileType::Demo ? "Demo"_s : ""_s, i,
|
||||||
profile.account());
|
_profiles[index].account());
|
||||||
|
|
||||||
if(!Utility::Path::exists(Utility::Path::join(_saveDirectory, build_filename))) {
|
if(!Utility::Path::exists(Utility::Path::join(_saveDirectory, build_filename))) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -254,19 +252,9 @@ void ProfileManager::refreshBackups() {
|
||||||
|
|
||||||
if(info[1] == "full") {
|
if(info[1] == "full") {
|
||||||
backup.type = ProfileType::FullGame;
|
backup.type = ProfileType::FullGame;
|
||||||
backup.version = ProfileVersion::Legacy;
|
|
||||||
}
|
}
|
||||||
else if(info[1] == "demo") {
|
else if(info[1] == "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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -404,7 +404,6 @@ void SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter get
|
||||||
(var) = getter();
|
(var) = getter();
|
||||||
ImGui::OpenPopup("int_edit");
|
ImGui::OpenPopup("int_edit");
|
||||||
}
|
}
|
||||||
drawTooltip("Edit");
|
|
||||||
if(drawIntEditPopup(&(var), 9999)) {
|
if(drawIntEditPopup(&(var), 9999)) {
|
||||||
if(!setter(var)) {
|
if(!setter(var)) {
|
||||||
_queue.addToast(Toast::Type::Error, _currentProfile->lastError());
|
_queue.addToast(Toast::Type::Error, _currentProfile->lastError());
|
||||||
|
@ -533,19 +532,17 @@ void SaveTool::drawMassManager() {
|
||||||
_currentMass = &_massManager->hangar(i);
|
_currentMass = &_massManager->hangar(i);
|
||||||
_uiState = UiState::MassViewer;
|
_uiState = UiState::MassViewer;
|
||||||
}
|
}
|
||||||
drawTooltip("Open in M.A.S.S. editor");
|
ImGui::SameLine(0.0f, 2.0f);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.0f);
|
||||||
ImGui::SmallButton(ICON_FA_SEARCH);
|
ImGui::SmallButton(ICON_FA_SEARCH);
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
}
|
}
|
||||||
ImGui::SameLine(0.0f, 2.0f);
|
|
||||||
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
|
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
|
||||||
mass_to_delete = i;
|
mass_to_delete = i;
|
||||||
ImGui::OpenPopup(mass_deletion_popup_ID);
|
ImGui::OpenPopup(mass_deletion_popup_ID);
|
||||||
}
|
}
|
||||||
drawTooltip("Delete");
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -597,7 +594,6 @@ void SaveTool::drawMassManager() {
|
||||||
staged_mass_to_delete = pair.first;
|
staged_mass_to_delete = pair.first;
|
||||||
ImGui::OpenPopup(staged_mass_deletion_popup_ID);
|
ImGui::OpenPopup(staged_mass_deletion_popup_ID);
|
||||||
}
|
}
|
||||||
drawTooltip("Delete");
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ void SaveTool::drawArmour() {
|
||||||
_currentMass->getArmourParts();
|
_currentMass->getArmourParts();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ImGui::BeginChild("##ArmourParts", {0.0f, 0.0f}, true)) {
|
if(!ImGui::BeginChild("##ArmourParts")) {
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,13 +101,11 @@ void SaveTool::drawProfileManager() {
|
||||||
profile_index = i;
|
profile_index = i;
|
||||||
ImGui::OpenPopup(backup_popup_id);
|
ImGui::OpenPopup(backup_popup_id);
|
||||||
}
|
}
|
||||||
drawTooltip("Backup");
|
|
||||||
ImGui::SameLine(0.0f, 2.0f);
|
ImGui::SameLine(0.0f, 2.0f);
|
||||||
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
|
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
|
||||||
profile_index = i;
|
profile_index = i;
|
||||||
ImGui::OpenPopup(delete_popup_id);
|
ImGui::OpenPopup(delete_popup_id);
|
||||||
}
|
}
|
||||||
drawTooltip("Delete");
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
|
@ -252,14 +250,13 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||||
ImGui::TextUnformatted("Actions");
|
ImGui::TextUnformatted("Actions");
|
||||||
|
|
||||||
for(std::size_t i = 0; i < _profileManager->backups().size(); ++i) {
|
for(std::size_t i = 0; i < _profileManager->backups().size(); ++i) {
|
||||||
auto& backup = _profileManager->backups()[i];
|
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
ImGui::TextUnformatted(backup.company.data());
|
ImGui::TextUnformatted(_profileManager->backups()[i].company.data());
|
||||||
if(ImGui::IsItemHovered()) {
|
if(ImGui::IsItemHovered()) {
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
for(const auto& file : backup.includedFiles) {
|
for(const auto& file : _profileManager->backups()[i].includedFiles) {
|
||||||
ImGui::TextUnformatted(file.data());
|
ImGui::TextUnformatted(file.data());
|
||||||
}
|
}
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
|
@ -267,17 +264,15 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
ImGui::Text("%.4i-%.2i-%.2i %.2i:%.2i:%.2i",
|
ImGui::Text("%.4i-%.2i-%.2i %.2i:%.2i:%.2i",
|
||||||
backup.timestamp.year,
|
_profileManager->backups()[i].timestamp.year,
|
||||||
backup.timestamp.month,
|
_profileManager->backups()[i].timestamp.month,
|
||||||
backup.timestamp.day,
|
_profileManager->backups()[i].timestamp.day,
|
||||||
backup.timestamp.hour,
|
_profileManager->backups()[i].timestamp.hour,
|
||||||
backup.timestamp.minute,
|
_profileManager->backups()[i].timestamp.minute,
|
||||||
backup.timestamp.second);
|
_profileManager->backups()[i].timestamp.second);
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(2);
|
ImGui::TableSetColumnIndex(2);
|
||||||
ImGui::Text("%s%s",
|
ImGui::TextUnformatted(_profileManager->backups()[i].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);
|
||||||
|
@ -285,13 +280,11 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||||
backup_index = i;
|
backup_index = i;
|
||||||
ImGui::OpenPopup(restore_backup_popup_id);
|
ImGui::OpenPopup(restore_backup_popup_id);
|
||||||
}
|
}
|
||||||
drawTooltip("Restore");
|
|
||||||
ImGui::SameLine(0.0f, 2.0f);
|
ImGui::SameLine(0.0f, 2.0f);
|
||||||
if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) {
|
if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) {
|
||||||
backup_index = i;
|
backup_index = i;
|
||||||
ImGui::OpenPopup(delete_backup_popup_id);
|
ImGui::OpenPopup(delete_backup_popup_id);
|
||||||
}
|
}
|
||||||
drawTooltip("Delete");
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
|
|
|
@ -179,7 +179,7 @@ void SaveTool::drawMainMenu() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(ImGui::BeginMenu("Help")) {
|
if(ImGui::BeginMenu("Help")) {
|
||||||
if(ImGui::BeginMenu(ICON_FA_KEYBOARD " Keyboard shortcuts")) {
|
if(ImGui::BeginMenu(ICON_FA_BOOK " ImGui user guide")) {
|
||||||
ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
|
ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
|
||||||
ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
|
ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
|
||||||
ImGui::BulletText("While inputing text:\n");
|
ImGui::BulletText("While inputing text:\n");
|
||||||
|
|
Loading…
Reference in a new issue