diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index c00526cdb8..cd7e9def60 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -261,6 +261,8 @@ add_executable(dolphin-emu NetPlay/NetPlaySetupDialog.h NetPlay/PadMappingDialog.cpp NetPlay/PadMappingDialog.h + NANDRepairDialog.cpp + NANDRepairDialog.h NKitWarningDialog.cpp NKitWarningDialog.h QtUtils/AspectRatioWidget.cpp diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 9747da0769..fce9c11813 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -166,6 +166,7 @@ + Create @@ -355,6 +356,7 @@ + diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index a119240f59..2b8c5bd9d9 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -52,6 +52,7 @@ #include "DolphinQt/AboutDialog.h" #include "DolphinQt/Host.h" +#include "DolphinQt/NANDRepairDialog.h" #include "DolphinQt/QtUtils/DolphinFileDialog.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/ParallelProgressDialog.h" @@ -1126,47 +1127,7 @@ void MenuBar::CheckNAND() return; } - QString message = tr("The emulated NAND is damaged. System titles such as the Wii Menu and " - "the Wii Shop Channel may not work correctly.\n\n" - "Do you want to try to repair the NAND?"); - if (!result.titles_to_remove.empty()) - { - std::string title_listings; - Core::TitleDatabase title_db; - const DiscIO::Language language = SConfig::GetInstance().GetCurrentLanguage(true); - for (const u64 title_id : result.titles_to_remove) - { - title_listings += StringFromFormat("%016" PRIx64, title_id); - - const std::string database_name = title_db.GetChannelName(title_id, language); - if (!database_name.empty()) - { - title_listings += " - " + database_name; - } - else - { - DiscIO::WiiSaveBanner banner(title_id); - if (banner.IsValid()) - { - title_listings += " - " + banner.GetName(); - const std::string description = banner.GetDescription(); - if (!StripWhitespace(description).empty()) - title_listings += " - " + description; - } - } - - title_listings += "\n"; - } - - message += tr("\n\nWARNING: Fixing this NAND requires the deletion of titles that have " - "incomplete data on the NAND, including all associated save data. " - "By continuing, the following title(s) will be removed:\n\n" - "%1" - "\nLaunching these titles may also fix the issues.") - .arg(QString::fromStdString(title_listings)); - } - - if (ModalMessageBox::question(this, tr("NAND Check"), message) != QMessageBox::Yes) + if (NANDRepairDialog(result, this).exec() != QDialog::Accepted) return; if (WiiUtils::RepairNAND(ios)) diff --git a/Source/Core/DolphinQt/NANDRepairDialog.cpp b/Source/Core/DolphinQt/NANDRepairDialog.cpp new file mode 100644 index 0000000000..f88f666740 --- /dev/null +++ b/Source/Core/DolphinQt/NANDRepairDialog.cpp @@ -0,0 +1,109 @@ +// Copyright 2022 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "DolphinQt/NANDRepairDialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "Common/StringUtil.h" +#include "Core/ConfigManager.h" +#include "Core/TitleDatabase.h" +#include "Core/WiiUtils.h" +#include "DiscIO/WiiSaveBanner.h" +#include "DolphinQt/Resources.h" + +NANDRepairDialog::NANDRepairDialog(const WiiUtils::NANDCheckResult& result, QWidget* parent) + : QDialog(parent) +{ + setWindowTitle(tr("NAND Check")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + setWindowIcon(Resources::GetAppIcon()); + + QVBoxLayout* main_layout = new QVBoxLayout(); + + QLabel* damaged_label = + new QLabel(tr("The emulated NAND is damaged. System titles such as the Wii Menu and " + "the Wii Shop Channel may not work correctly.")); + damaged_label->setWordWrap(true); + main_layout->addWidget(damaged_label); + + if (!result.titles_to_remove.empty()) + { + QLabel* warning_label = + new QLabel(tr("WARNING: Fixing this NAND requires the deletion of titles that have " + "incomplete data on the NAND, including all associated save data. " + "By continuing, the following title(s) will be removed:")); + warning_label->setWordWrap(true); + main_layout->addWidget(warning_label); + + std::string title_listings; + Core::TitleDatabase title_db; + const DiscIO::Language language = SConfig::GetInstance().GetCurrentLanguage(true); + for (const u64 title_id : result.titles_to_remove) + { + title_listings += fmt::format("{:016x}", title_id); + + const std::string database_name = title_db.GetChannelName(title_id, language); + if (!database_name.empty()) + { + title_listings += " - " + database_name; + } + else + { + DiscIO::WiiSaveBanner banner(title_id); + if (banner.IsValid()) + { + title_listings += " - " + banner.GetName(); + const std::string description = banner.GetDescription(); + if (!StripWhitespace(description).empty()) + title_listings += " - " + description; + } + } + + title_listings += "\n"; + } + + QPlainTextEdit* title_box = new QPlainTextEdit(QString::fromStdString(title_listings)); + title_box->setReadOnly(true); + main_layout->addWidget(title_box); + + QLabel* maybe_fix_label = new QLabel(tr("Launching these titles may also fix the issues.")); + maybe_fix_label->setWordWrap(true); + main_layout->addWidget(maybe_fix_label); + } + + QLabel* question_label = new QLabel(tr("Do you want to try to repair the NAND?")); + question_label->setWordWrap(true); + main_layout->addWidget(question_label); + + QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No); + main_layout->addWidget(button_box); + + QHBoxLayout* top_layout = new QHBoxLayout(); + + QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); + QLabel* icon_label = new QLabel; + icon_label->setPixmap(icon.pixmap(100)); + icon_label->setAlignment(Qt::AlignTop); + top_layout->addWidget(icon_label); + top_layout->addSpacing(10); + + top_layout->addLayout(main_layout); + + setLayout(top_layout); + resize(600, 400); + + connect(button_box->button(QDialogButtonBox::Yes), &QPushButton::clicked, this, &QDialog::accept); + connect(button_box->button(QDialogButtonBox::No), &QPushButton::clicked, this, &QDialog::reject); +} diff --git a/Source/Core/DolphinQt/NANDRepairDialog.h b/Source/Core/DolphinQt/NANDRepairDialog.h new file mode 100644 index 0000000000..c5255340cb --- /dev/null +++ b/Source/Core/DolphinQt/NANDRepairDialog.h @@ -0,0 +1,21 @@ +// Copyright 2022 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +class QWidget; + +namespace WiiUtils +{ +struct NANDCheckResult; +} + +class NANDRepairDialog final : public QDialog +{ + Q_OBJECT + +public: + explicit NANDRepairDialog(const WiiUtils::NANDCheckResult& result, QWidget* parent = nullptr); +};