mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 07:09:48 -06:00
Qt: Implement "Import BootMii NAND Backup"
This commit is contained in:
@ -12,9 +12,11 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
|
#include <future>
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
#include "Common/Compat/optional"
|
|
||||||
|
|
||||||
#include "Core/Boot/Boot.h"
|
#include "Core/Boot/Boot.h"
|
||||||
#include "Core/BootManager.h"
|
#include "Core/BootManager.h"
|
||||||
@ -34,6 +36,8 @@
|
|||||||
#include "Core/NetPlayServer.h"
|
#include "Core/NetPlayServer.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
|
|
||||||
|
#include "DiscIO/NANDImporter.h"
|
||||||
|
|
||||||
#include "DolphinQt2/AboutDialog.h"
|
#include "DolphinQt2/AboutDialog.h"
|
||||||
#include "DolphinQt2/Config/ControllersWindow.h"
|
#include "DolphinQt2/Config/ControllersWindow.h"
|
||||||
#include "DolphinQt2/Config/Graphics/GraphicsWindow.h"
|
#include "DolphinQt2/Config/Graphics/GraphicsWindow.h"
|
||||||
@ -45,6 +49,7 @@
|
|||||||
#include "DolphinQt2/MainWindow.h"
|
#include "DolphinQt2/MainWindow.h"
|
||||||
#include "DolphinQt2/NetPlay/NetPlayDialog.h"
|
#include "DolphinQt2/NetPlay/NetPlayDialog.h"
|
||||||
#include "DolphinQt2/NetPlay/NetPlaySetupDialog.h"
|
#include "DolphinQt2/NetPlay/NetPlaySetupDialog.h"
|
||||||
|
#include "DolphinQt2/QtUtils/QueueOnObject.h"
|
||||||
#include "DolphinQt2/QtUtils/WindowActivationEventFilter.h"
|
#include "DolphinQt2/QtUtils/WindowActivationEventFilter.h"
|
||||||
#include "DolphinQt2/Resources.h"
|
#include "DolphinQt2/Resources.h"
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
@ -201,6 +206,7 @@ void MainWindow::ConnectMenuBar()
|
|||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
connect(m_menu_bar, &MenuBar::BootGameCubeIPL, this, &MainWindow::OnBootGameCubeIPL);
|
connect(m_menu_bar, &MenuBar::BootGameCubeIPL, this, &MainWindow::OnBootGameCubeIPL);
|
||||||
|
connect(m_menu_bar, &MenuBar::ImportNANDBackup, this, &MainWindow::OnImportNANDBackup);
|
||||||
connect(m_menu_bar, &MenuBar::PerformOnlineUpdate, this, &MainWindow::PerformOnlineUpdate);
|
connect(m_menu_bar, &MenuBar::PerformOnlineUpdate, this, &MainWindow::PerformOnlineUpdate);
|
||||||
connect(m_menu_bar, &MenuBar::BootWiiSystemMenu, this, &MainWindow::BootWiiSystemMenu);
|
connect(m_menu_bar, &MenuBar::BootWiiSystemMenu, this, &MainWindow::BootWiiSystemMenu);
|
||||||
connect(m_menu_bar, &MenuBar::StartNetPlay, this, &MainWindow::ShowNetPlaySetupDialog);
|
connect(m_menu_bar, &MenuBar::StartNetPlay, this, &MainWindow::ShowNetPlaySetupDialog);
|
||||||
@ -832,3 +838,47 @@ void MainWindow::OnBootGameCubeIPL(DiscIO::Region region)
|
|||||||
{
|
{
|
||||||
StartGame(std::make_unique<BootParameters>(BootParameters::IPL{region}));
|
StartGame(std::make_unique<BootParameters>(BootParameters::IPL{region}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::OnImportNANDBackup()
|
||||||
|
{
|
||||||
|
auto response = QMessageBox::question(
|
||||||
|
this, tr("Question"),
|
||||||
|
tr("Merging a new NAND over your currently selected NAND will overwrite any channels "
|
||||||
|
"and savegames that already exist. This process is not reversible, so it is "
|
||||||
|
"recommended that you keep backups of both NANDs. Are you sure you want to "
|
||||||
|
"continue?"));
|
||||||
|
|
||||||
|
if (response == QMessageBox::No)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString file = QFileDialog::getOpenFileName(this, tr("Select the save file"), QDir::currentPath(),
|
||||||
|
tr("BootMii NAND backup file (*.bin);;"
|
||||||
|
"All Files (*)"));
|
||||||
|
|
||||||
|
if (file.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QProgressDialog* dialog = new QProgressDialog(this);
|
||||||
|
dialog->setMinimum(0);
|
||||||
|
dialog->setMaximum(0);
|
||||||
|
dialog->setLabelText(tr("Importing NAND backup"));
|
||||||
|
dialog->setCancelButton(nullptr);
|
||||||
|
|
||||||
|
auto beginning = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||||
|
|
||||||
|
auto result = std::async(std::launch::async, [&] {
|
||||||
|
DiscIO::NANDImporter().ImportNANDBin(file.toStdString(), [&dialog, beginning] {
|
||||||
|
QueueOnObject(dialog, [&dialog, beginning] {
|
||||||
|
dialog->setLabelText(tr("Importing NAND backup\n Time elapsed: %1s")
|
||||||
|
.arg(QDateTime::currentDateTime().toSecsSinceEpoch() - beginning));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
QueueOnObject(dialog, [dialog] { dialog->close(); });
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog->exec();
|
||||||
|
|
||||||
|
result.wait();
|
||||||
|
|
||||||
|
m_menu_bar->UpdateToolsMenu(Core::IsRunning());
|
||||||
|
}
|
||||||
|
@ -104,6 +104,7 @@ private:
|
|||||||
void NetPlayQuit();
|
void NetPlayQuit();
|
||||||
|
|
||||||
void OnBootGameCubeIPL(DiscIO::Region region);
|
void OnBootGameCubeIPL(DiscIO::Region region);
|
||||||
|
void OnImportNANDBackup();
|
||||||
void OnStopComplete();
|
void OnStopComplete();
|
||||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||||
void dropEvent(QDropEvent* event) override;
|
void dropEvent(QDropEvent* event) override;
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "DolphinQt2/MenuBar.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@ -17,9 +19,9 @@
|
|||||||
#include "Core/IOS/ES/ES.h"
|
#include "Core/IOS/ES/ES.h"
|
||||||
#include "Core/IOS/IOS.h"
|
#include "Core/IOS/IOS.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
|
#include "DiscIO/NANDImporter.h"
|
||||||
#include "DolphinQt2/AboutDialog.h"
|
#include "DolphinQt2/AboutDialog.h"
|
||||||
#include "DolphinQt2/GameList/GameFile.h"
|
#include "DolphinQt2/GameList/GameFile.h"
|
||||||
#include "DolphinQt2/MenuBar.h"
|
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
|
|
||||||
MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
|
MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
|
||||||
@ -112,6 +114,9 @@ void MenuBar::AddToolsMenu()
|
|||||||
|
|
||||||
// Label will be set by a NANDRefresh later
|
// Label will be set by a NANDRefresh later
|
||||||
m_boot_sysmenu = tools_menu->addAction(QStringLiteral(""), [this] { emit BootWiiSystemMenu(); });
|
m_boot_sysmenu = tools_menu->addAction(QStringLiteral(""), [this] { emit BootWiiSystemMenu(); });
|
||||||
|
m_import_backup = tools_menu->addAction(tr("Import BootMii NAND Backup..."),
|
||||||
|
[this] { emit ImportNANDBackup(); });
|
||||||
|
|
||||||
m_boot_sysmenu->setEnabled(false);
|
m_boot_sysmenu->setEnabled(false);
|
||||||
|
|
||||||
connect(&Settings::Instance(), &Settings::NANDRefresh, [this] { UpdateToolsMenu(false); });
|
connect(&Settings::Instance(), &Settings::NANDRefresh, [this] { UpdateToolsMenu(false); });
|
||||||
@ -393,6 +398,7 @@ void MenuBar::UpdateToolsMenu(bool emulation_started)
|
|||||||
File::Exists(SConfig::GetInstance().GetBootROMPath(USA_DIR)));
|
File::Exists(SConfig::GetInstance().GetBootROMPath(USA_DIR)));
|
||||||
m_pal_ipl->setEnabled(!emulation_started &&
|
m_pal_ipl->setEnabled(!emulation_started &&
|
||||||
File::Exists(SConfig::GetInstance().GetBootROMPath(EUR_DIR)));
|
File::Exists(SConfig::GetInstance().GetBootROMPath(EUR_DIR)));
|
||||||
|
m_import_backup->setEnabled(!emulation_started);
|
||||||
|
|
||||||
if (!emulation_started)
|
if (!emulation_started)
|
||||||
{
|
{
|
||||||
@ -451,3 +457,4 @@ void MenuBar::ExportWiiSaves()
|
|||||||
{
|
{
|
||||||
CWiiSaveCrypted::ExportAllSaves();
|
CWiiSaveCrypted::ExportAllSaves();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
|
||||||
|
namespace DiscIO
|
||||||
|
{
|
||||||
|
enum class Region;
|
||||||
|
};
|
||||||
|
|
||||||
class MenuBar final : public QMenuBar
|
class MenuBar final : public QMenuBar
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -22,11 +27,6 @@ public:
|
|||||||
void UpdateStateSlotMenu();
|
void UpdateStateSlotMenu();
|
||||||
void UpdateToolsMenu(bool emulation_started);
|
void UpdateToolsMenu(bool emulation_started);
|
||||||
|
|
||||||
// Tools
|
|
||||||
void InstallWAD();
|
|
||||||
void ImportWiiSave();
|
|
||||||
void ExportWiiSaves();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// File
|
// File
|
||||||
void Open();
|
void Open();
|
||||||
@ -52,6 +52,7 @@ signals:
|
|||||||
void StateSaveOldest();
|
void StateSaveOldest();
|
||||||
void SetStateSlot(int slot);
|
void SetStateSlot(int slot);
|
||||||
void BootWiiSystemMenu();
|
void BootWiiSystemMenu();
|
||||||
|
void ImportNANDBackup();
|
||||||
|
|
||||||
void PerformOnlineUpdate(const std::string& region);
|
void PerformOnlineUpdate(const std::string& region);
|
||||||
|
|
||||||
@ -92,6 +93,10 @@ private:
|
|||||||
void AddToolsMenu();
|
void AddToolsMenu();
|
||||||
void AddHelpMenu();
|
void AddHelpMenu();
|
||||||
|
|
||||||
|
void InstallWAD();
|
||||||
|
void ImportWiiSave();
|
||||||
|
void ExportWiiSaves();
|
||||||
|
|
||||||
// File
|
// File
|
||||||
QAction* m_open_action;
|
QAction* m_open_action;
|
||||||
QAction* m_exit_action;
|
QAction* m_exit_action;
|
||||||
@ -103,6 +108,7 @@ private:
|
|||||||
QAction* m_ntscj_ipl;
|
QAction* m_ntscj_ipl;
|
||||||
QAction* m_ntscu_ipl;
|
QAction* m_ntscu_ipl;
|
||||||
QAction* m_pal_ipl;
|
QAction* m_pal_ipl;
|
||||||
|
QAction* m_import_backup;
|
||||||
|
|
||||||
// Emulation
|
// Emulation
|
||||||
QAction* m_play_action;
|
QAction* m_play_action;
|
||||||
|
Reference in New Issue
Block a user