2021-06-11 19:24:52 +02:00
|
|
|
// MassBuilderSaveTool
|
2024-03-08 20:25:32 +01:00
|
|
|
// Copyright (C) 2021-2024 Guillaume Jacquemin
|
2021-06-11 19:24:52 +02:00
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#include <Magnum/ImGuiIntegration/Integration.h>
|
|
|
|
|
2022-11-21 09:49:01 +01:00
|
|
|
#include <SDL_messagebox.h>
|
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
#include "../FontAwesome/IconsFontAwesome5.h"
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
#include "Application.h"
|
2022-11-21 09:49:01 +01:00
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
extern const ImVec2 center_pivot;
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
namespace mbst {
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawProfileManager() {
|
2021-06-11 19:24:52 +02:00
|
|
|
static std::size_t profile_index = 0;
|
|
|
|
|
2023-09-02 14:28:28 +02:00
|
|
|
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot);
|
2021-06-11 19:24:52 +02:00
|
|
|
if(ImGui::Begin("Profile management##ProfileManager", nullptr,
|
2021-07-25 10:52:54 +02:00
|
|
|
ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoBringToFrontOnFocus|
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_MenuBar))
|
|
|
|
{
|
|
|
|
if(ImGui::BeginMenuBar()) {
|
|
|
|
ImGui::TextUnformatted("Profile manager");
|
|
|
|
ImGui::EndMenuBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
static ImGuiID backup_list_popup_id = drawBackupListPopup();
|
|
|
|
static ImGuiID backup_popup_id = drawBackupProfilePopup(profile_index);
|
|
|
|
static ImGuiID delete_popup_id = drawDeleteProfilePopup(profile_index);
|
|
|
|
|
|
|
|
if(ImGui::BeginTable("##ManagerLayout", 2)) {
|
|
|
|
ImGui::TableSetupColumn("##Label", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableSetupColumn("##Refresh", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
ImGui::TextUnformatted("Here are the detected profiles:");
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
if(ImGui::SmallButton("Refresh")) {
|
|
|
|
if(!_profileManager->refreshProfiles()) {
|
2022-11-21 19:09:18 +01:00
|
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
|
|
|
_profileManager->lastError().data(), window());
|
2021-06-11 19:24:52 +02:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::SmallButton("Backups")) {
|
|
|
|
_profileManager->refreshBackups();
|
|
|
|
ImGui::OpenPopup(backup_list_popup_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ImGui::BeginTable("##Profiles", 3, ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg)) {
|
|
|
|
ImGui::TableSetupColumn("Company name", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
ImGui::TableSetupColumn("##Buttons", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
|
|
|
|
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
ImGui::TextUnformatted("Company name");
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
ImGui::TextUnformatted("Type");
|
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
ImGui::TextUnformatted("Actions");
|
|
|
|
|
|
|
|
for(std::size_t i = 0; i < _profileManager->profiles().size(); ++i) {
|
2023-11-29 12:33:26 +01:00
|
|
|
GameObjects::Profile& profile = _profileManager->profiles()[i];
|
2022-03-06 14:42:24 +01:00
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
2022-11-21 20:47:09 +01:00
|
|
|
ImGui::PushID(int(i));
|
2022-03-06 14:42:24 +01:00
|
|
|
if(ImGui::Selectable(profile.companyName().data(), false,
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap))
|
|
|
|
{
|
|
|
|
_currentProfile = _profileManager->getProfile(i);
|
|
|
|
initialiseMassManager();
|
2022-03-30 14:18:08 +02:00
|
|
|
initialiseFileWatcher();
|
2021-06-11 19:24:52 +02:00
|
|
|
_uiState = UiState::MainManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
2022-11-21 19:03:00 +01:00
|
|
|
ImGui::TextUnformatted(profile.isDemo() ? "Demo" : "Full");
|
2021-06-11 19:24:52 +02:00
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
if(ImGui::SmallButton(ICON_FA_FILE_ARCHIVE)) {
|
|
|
|
profile_index = i;
|
|
|
|
ImGui::OpenPopup(backup_popup_id);
|
|
|
|
}
|
2022-03-20 09:14:46 +01:00
|
|
|
drawTooltip("Backup");
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::SameLine(0.0f, 2.0f);
|
2021-07-10 16:49:47 +02:00
|
|
|
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
|
2021-06-11 19:24:52 +02:00
|
|
|
profile_index = i;
|
|
|
|
ImGui::OpenPopup(delete_popup_id);
|
|
|
|
}
|
2022-03-20 09:14:46 +01:00
|
|
|
drawTooltip("Delete");
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::TextUnformatted("Click a profile to manage it.");
|
|
|
|
}
|
|
|
|
|
|
|
|
drawBackupListPopup();
|
|
|
|
drawBackupProfilePopup(profile_index);
|
|
|
|
drawDeleteProfilePopup(profile_index);
|
|
|
|
|
|
|
|
ImGui::End();
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
ImGuiID
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawBackupListPopup() {
|
2023-09-02 14:28:28 +02:00
|
|
|
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f} / dpiScaling()}, ImGuiCond_Always, center_pivot);
|
2021-06-11 19:24:52 +02:00
|
|
|
if(!ImGui::BeginPopupModal("Backups##BackupsModal", nullptr,
|
|
|
|
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
|
|
|
{
|
|
|
|
return ImGui::GetID("Backups##BackupsModal");
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::size_t backup_index;
|
|
|
|
|
|
|
|
if(ImGui::BeginPopupModal("Restore backup", nullptr,
|
|
|
|
ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize))
|
|
|
|
{
|
2022-11-21 20:47:09 +01:00
|
|
|
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::Text("Are you sure you want to restore the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? Any existing data will be overwritten.",
|
2022-03-04 21:18:55 +01:00
|
|
|
_profileManager->backups()[backup_index].company.data(),
|
2021-09-23 19:01:42 +02:00
|
|
|
_profileManager->backups()[backup_index].timestamp.year,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.month,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.day,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.hour,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.minute,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.second);
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::PopTextWrapPos();
|
|
|
|
|
|
|
|
if(ImGui::BeginTable("##RestoreBackupLayout", 2)) {
|
|
|
|
ImGui::TableSetupColumn("##Dummy", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableSetupColumn("##YesNo", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
if(ImGui::Button("Yes")) {
|
|
|
|
if(!_profileManager->restoreBackup(backup_index)) {
|
2022-02-26 14:48:45 +01:00
|
|
|
_queue.addToast(Toast::Type::Error, _profileManager->lastError());
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
2022-11-21 19:09:18 +01:00
|
|
|
if(!_profileManager->refreshProfiles()) {
|
|
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
|
|
|
_profileManager->lastError().data(), window());
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button("No", ImGui::GetItemRectSize())) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ImGui::BeginPopupModal("Delete backup", nullptr,
|
|
|
|
ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize))
|
|
|
|
{
|
2022-11-21 20:47:09 +01:00
|
|
|
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::Text("Are you sure you want to delete the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? This operation is irreversible.",
|
2022-03-04 21:18:55 +01:00
|
|
|
_profileManager->backups()[backup_index].company.data(),
|
2021-09-23 19:01:42 +02:00
|
|
|
_profileManager->backups()[backup_index].timestamp.year,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.month,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.day,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.hour,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.minute,
|
|
|
|
_profileManager->backups()[backup_index].timestamp.second);
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::PopTextWrapPos();
|
|
|
|
|
|
|
|
if(ImGui::BeginTable("##DeleteBackupLayout", 2)) {
|
|
|
|
ImGui::TableSetupColumn("##Dummy", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableSetupColumn("##YesNo", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
if(ImGui::Button("Yes")) {
|
|
|
|
if(!_profileManager->deleteBackup(backup_index)) {
|
2022-02-26 14:48:45 +01:00
|
|
|
_queue.addToast(Toast::Type::Error, _profileManager->lastError());
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button("No", ImGui::GetItemRectSize())) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
static ImGuiID restore_backup_popup_id = ImGui::GetID("Restore backup");
|
|
|
|
static ImGuiID delete_backup_popup_id = ImGui::GetID("Delete backup");
|
|
|
|
|
|
|
|
if(ImGui::BeginTable("##BackupsLabelLayout", 2)) {
|
|
|
|
ImGui::TableSetupColumn("##Label", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableSetupColumn("##Refresh", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
ImGui::TextUnformatted("Here's a list of detected backups:");
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
if(ImGui::SmallButton("Refresh")) {
|
|
|
|
_profileManager->refreshBackups();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
|
2022-07-06 17:22:40 +02:00
|
|
|
if(_profileManager->backups().isEmpty()) {
|
2021-06-20 14:10:09 +02:00
|
|
|
ImGui::TextDisabled("No backups were found.");
|
|
|
|
}
|
|
|
|
else if(ImGui::BeginTable("##Backups", 4,
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg))
|
|
|
|
{
|
|
|
|
ImGui::TableSetupScrollFreeze(0, 1);
|
|
|
|
ImGui::TableSetupColumn("##CompanyName", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
ImGui::TableSetupColumn("##BackupDate", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
ImGui::TableSetupColumn("##Type", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
ImGui::TableSetupColumn("##Actions", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
|
|
|
|
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
ImGui::TextUnformatted("Company name");
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
ImGui::TextUnformatted("Backup date");
|
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
ImGui::TextUnformatted("Type");
|
|
|
|
ImGui::TableSetColumnIndex(3);
|
|
|
|
ImGui::TextUnformatted("Actions");
|
|
|
|
|
|
|
|
for(std::size_t i = 0; i < _profileManager->backups().size(); ++i) {
|
2022-03-20 09:14:11 +01:00
|
|
|
auto& backup = _profileManager->backups()[i];
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
2024-02-08 11:08:14 +01:00
|
|
|
ImGui::TextUnformatted(backup.company.cbegin(), backup.company.cend());
|
2021-06-11 19:24:52 +02:00
|
|
|
if(ImGui::IsItemHovered()) {
|
|
|
|
ImGui::BeginTooltip();
|
2022-03-20 09:14:11 +01:00
|
|
|
for(const auto& file : backup.includedFiles) {
|
2024-02-08 11:08:14 +01:00
|
|
|
ImGui::TextUnformatted(file.cbegin());
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
ImGui::EndTooltip();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
ImGui::Text("%.4i-%.2i-%.2i %.2i:%.2i:%.2i",
|
2022-03-20 09:14:11 +01:00
|
|
|
backup.timestamp.year,
|
|
|
|
backup.timestamp.month,
|
|
|
|
backup.timestamp.day,
|
|
|
|
backup.timestamp.hour,
|
|
|
|
backup.timestamp.minute,
|
|
|
|
backup.timestamp.second);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(2);
|
2023-11-29 12:33:26 +01:00
|
|
|
ImGui::TextUnformatted(backup.demo ? "Demo" : "Full");
|
2021-06-11 19:24:52 +02:00
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(3);
|
2022-11-21 20:47:09 +01:00
|
|
|
ImGui::PushID(int(i));
|
2021-06-11 19:24:52 +02:00
|
|
|
if(ImGui::SmallButton(ICON_FA_UNDO)) {
|
|
|
|
backup_index = i;
|
|
|
|
ImGui::OpenPopup(restore_backup_popup_id);
|
|
|
|
}
|
2022-03-20 09:14:46 +01:00
|
|
|
drawTooltip("Restore");
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::SameLine(0.0f, 2.0f);
|
|
|
|
if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) {
|
|
|
|
backup_index = i;
|
|
|
|
ImGui::OpenPopup(delete_backup_popup_id);
|
|
|
|
}
|
2022-03-20 09:14:46 +01:00
|
|
|
drawTooltip("Delete");
|
2021-06-20 14:11:18 +02:00
|
|
|
ImGui::PopID();
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
|
2023-11-29 13:12:18 +01:00
|
|
|
ImGui::PushTextWrapPos(ImGui::GetContentRegionAvail().x);
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::TextUnformatted("Hover over a company name to see which files are included in the backup.");
|
|
|
|
ImGui::PopTextWrapPos();
|
|
|
|
|
|
|
|
if(ImGui::BeginTable("##BackupListCloseLayout", 2)) {
|
|
|
|
ImGui::TableSetupColumn("##Dummy", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableSetupColumn("##Close", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
if(ImGui::Button("Close")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
ImGuiID
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawBackupProfilePopup(std::size_t profile_index) {
|
2021-06-11 19:24:52 +02:00
|
|
|
if(!ImGui::BeginPopupModal("Include builds ?##IncludeBuildsDialog", nullptr,
|
|
|
|
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
|
|
|
{
|
|
|
|
return ImGui::GetID("Include builds ?##IncludeBuildsDialog");
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::TextUnformatted("Should builds be added to the backup ?");
|
|
|
|
|
|
|
|
if(ImGui::BeginTable("##NameBackupLayout", 2)) {
|
|
|
|
ImGui::TableSetupColumn("##Dummy", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableSetupColumn("##YesNo", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
if(ImGui::Button("Yes")) {
|
2022-11-21 19:22:03 +01:00
|
|
|
if(!_profileManager->backupProfile(profile_index, true)) {
|
|
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
|
|
|
_profileManager->lastError().data(), window());
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button("No", ImGui::GetItemRectSize())) {
|
2022-11-21 19:22:03 +01:00
|
|
|
if(!_profileManager->backupProfile(profile_index, false)) {
|
|
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
|
|
|
_profileManager->lastError().data(), window());
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button("Cancel")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
ImGuiID
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawDeleteProfilePopup(std::size_t profile_index) {
|
2021-06-11 19:24:52 +02:00
|
|
|
if(!ImGui::BeginPopupModal("Confirmation##DeleteProfileConfirmation", nullptr,
|
|
|
|
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
|
|
|
{
|
|
|
|
return ImGui::GetID("Confirmation##DeleteProfileConfirmation");
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool delete_builds = false;
|
|
|
|
if(ImGui::IsWindowAppearing()) {
|
|
|
|
delete_builds = false;
|
|
|
|
}
|
|
|
|
|
2022-11-21 20:47:09 +01:00
|
|
|
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
|
2022-03-09 13:27:21 +01:00
|
|
|
ImGui::Text("Are you sure you want to delete the %s profile named %s ? This operation is irreversible.",
|
|
|
|
_profileManager->profiles()[profile_index].isDemo() ? "demo" : "full game",
|
|
|
|
_profileManager->profiles()[profile_index].companyName().data());
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::PopTextWrapPos();
|
|
|
|
|
|
|
|
if(ImGui::BeginTable("##DeleteProfileLayout", 2)) {
|
|
|
|
ImGui::TableSetupColumn("##Checkbox", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableSetupColumn("##YesNo", ImGuiTableColumnFlags_WidthFixed);
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
ImGui::Checkbox("Delete builds", &delete_builds);
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
if(ImGui::Button("Yes")) {
|
|
|
|
if(!_profileManager->deleteProfile(profile_index, delete_builds)) {
|
2022-02-26 14:48:45 +01:00
|
|
|
_queue.addToast(Toast::Type::Error, _profileManager->lastError());
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button("No", ImGui::GetItemRectSize())) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2023-11-29 12:33:26 +01:00
|
|
|
|
|
|
|
}
|