mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Qt: Add menu item to perform online update
This commit is contained in:
@ -19,6 +19,8 @@ set(SRCS
|
|||||||
Resources.cpp
|
Resources.cpp
|
||||||
Settings.cpp
|
Settings.cpp
|
||||||
ToolBar.cpp
|
ToolBar.cpp
|
||||||
|
WiiUpdate.cpp
|
||||||
|
WiiUpdate.h
|
||||||
Config/ControllersWindow.cpp
|
Config/ControllersWindow.cpp
|
||||||
Config/FilesystemWidget.cpp
|
Config/FilesystemWidget.cpp
|
||||||
Config/InfoWidget.cpp
|
Config/InfoWidget.cpp
|
||||||
|
@ -164,6 +164,7 @@
|
|||||||
<ClCompile Include="Settings\InterfacePane.cpp" />
|
<ClCompile Include="Settings\InterfacePane.cpp" />
|
||||||
<ClCompile Include="Settings\PathPane.cpp" />
|
<ClCompile Include="Settings\PathPane.cpp" />
|
||||||
<ClCompile Include="ToolBar.cpp" />
|
<ClCompile Include="ToolBar.cpp" />
|
||||||
|
<ClCompile Include="WiiUpdate.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!--Put standard C/C++ headers here-->
|
<!--Put standard C/C++ headers here-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -185,6 +186,7 @@
|
|||||||
<ClInclude Include="QtUtils\ElidedButton.h" />
|
<ClInclude Include="QtUtils\ElidedButton.h" />
|
||||||
<ClInclude Include="Resources.h" />
|
<ClInclude Include="Resources.h" />
|
||||||
<ClInclude Include="Settings\PathPane.h" />
|
<ClInclude Include="Settings\PathPane.h" />
|
||||||
|
<ClInclude Include="WiiUpdate.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="CMakeLists.txt" />
|
<Text Include="CMakeLists.txt" />
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include "DolphinQt2/AboutDialog.h"
|
#include "DolphinQt2/AboutDialog.h"
|
||||||
#include "DolphinQt2/Config/ControllersWindow.h"
|
#include "DolphinQt2/Config/ControllersWindow.h"
|
||||||
|
|
||||||
#include "DolphinQt2/Config/Mapping/MappingWindow.h"
|
#include "DolphinQt2/Config/Mapping/MappingWindow.h"
|
||||||
#include "DolphinQt2/Config/SettingsWindow.h"
|
#include "DolphinQt2/Config/SettingsWindow.h"
|
||||||
#include "DolphinQt2/Host.h"
|
#include "DolphinQt2/Host.h"
|
||||||
@ -39,6 +38,7 @@
|
|||||||
#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"
|
||||||
|
#include "DolphinQt2/WiiUpdate.h"
|
||||||
|
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
|
|
||||||
@ -165,6 +165,9 @@ void MainWindow::ConnectMenuBar()
|
|||||||
// Options
|
// Options
|
||||||
connect(m_menu_bar, &MenuBar::ConfigureHotkeys, this, &MainWindow::ShowHotkeyDialog);
|
connect(m_menu_bar, &MenuBar::ConfigureHotkeys, this, &MainWindow::ShowHotkeyDialog);
|
||||||
|
|
||||||
|
// Tools
|
||||||
|
connect(m_menu_bar, &MenuBar::PerformOnlineUpdate, this, &MainWindow::PerformOnlineUpdate);
|
||||||
|
|
||||||
// View
|
// View
|
||||||
connect(m_menu_bar, &MenuBar::ShowTable, m_game_list, &GameList::SetTableView);
|
connect(m_menu_bar, &MenuBar::ShowTable, m_game_list, &GameList::SetTableView);
|
||||||
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
||||||
@ -530,6 +533,13 @@ void MainWindow::SetStateSlot(int slot)
|
|||||||
m_state_slot = slot;
|
m_state_slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::PerformOnlineUpdate(const std::string& region)
|
||||||
|
{
|
||||||
|
WiiUpdate::PerformOnlineUpdate(region, this);
|
||||||
|
// Since the update may have installed a newer system menu, refresh the tools menu.
|
||||||
|
m_menu_bar->UpdateToolsMenu(false);
|
||||||
|
}
|
||||||
|
|
||||||
bool MainWindow::eventFilter(QObject* object, QEvent* event)
|
bool MainWindow::eventFilter(QObject* object, QEvent* event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::Close && !Stop())
|
if (event->type() == QEvent::Close && !Stop())
|
||||||
|
@ -56,6 +56,8 @@ private slots:
|
|||||||
void StateSaveOldest();
|
void StateSaveOldest();
|
||||||
void SetStateSlot(int slot);
|
void SetStateSlot(int slot);
|
||||||
|
|
||||||
|
void PerformOnlineUpdate(const std::string& region);
|
||||||
|
|
||||||
void FullScreen();
|
void FullScreen();
|
||||||
void ScreenShot();
|
void ScreenShot();
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "Core/CommonTitles.h"
|
||||||
|
#include "Core/IOS/ES/ES.h"
|
||||||
|
#include "Core/IOS/IOS.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
#include "DolphinQt2/AboutDialog.h"
|
#include "DolphinQt2/AboutDialog.h"
|
||||||
#include "DolphinQt2/GameList/GameFile.h"
|
#include "DolphinQt2/GameList/GameFile.h"
|
||||||
@ -43,6 +46,7 @@ void MenuBar::EmulationStarted()
|
|||||||
m_state_load_menu->setEnabled(true);
|
m_state_load_menu->setEnabled(true);
|
||||||
m_state_save_menu->setEnabled(true);
|
m_state_save_menu->setEnabled(true);
|
||||||
UpdateStateSlotMenu();
|
UpdateStateSlotMenu();
|
||||||
|
UpdateToolsMenu(true);
|
||||||
}
|
}
|
||||||
void MenuBar::EmulationPaused()
|
void MenuBar::EmulationPaused()
|
||||||
{
|
{
|
||||||
@ -66,6 +70,7 @@ void MenuBar::EmulationStopped()
|
|||||||
m_state_load_menu->setEnabled(false);
|
m_state_load_menu->setEnabled(false);
|
||||||
m_state_save_menu->setEnabled(false);
|
m_state_save_menu->setEnabled(false);
|
||||||
UpdateStateSlotMenu();
|
UpdateStateSlotMenu();
|
||||||
|
UpdateToolsMenu(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::AddFileMenu()
|
void MenuBar::AddFileMenu()
|
||||||
@ -79,6 +84,17 @@ void MenuBar::AddToolsMenu()
|
|||||||
{
|
{
|
||||||
QMenu* tools_menu = addMenu(tr("Tools"));
|
QMenu* tools_menu = addMenu(tr("Tools"));
|
||||||
m_wad_install_action = tools_menu->addAction(tr("Install WAD..."), this, SLOT(InstallWAD()));
|
m_wad_install_action = tools_menu->addAction(tr("Install WAD..."), this, SLOT(InstallWAD()));
|
||||||
|
|
||||||
|
m_perform_online_update_menu = tools_menu->addMenu(tr("Perform Online System Update"));
|
||||||
|
m_perform_online_update_for_current_region = m_perform_online_update_menu->addAction(
|
||||||
|
tr("Current Region"), [this] { emit PerformOnlineUpdate(""); });
|
||||||
|
m_perform_online_update_menu->addSeparator();
|
||||||
|
m_perform_online_update_menu->addAction(tr("Europe"),
|
||||||
|
[this] { emit PerformOnlineUpdate("EUR"); });
|
||||||
|
m_perform_online_update_menu->addAction(tr("Japan"), [this] { emit PerformOnlineUpdate("JPN"); });
|
||||||
|
m_perform_online_update_menu->addAction(tr("Korea"), [this] { emit PerformOnlineUpdate("KOR"); });
|
||||||
|
m_perform_online_update_menu->addAction(tr("United States"),
|
||||||
|
[this] { emit PerformOnlineUpdate("USA"); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::AddEmulationMenu()
|
void MenuBar::AddEmulationMenu()
|
||||||
@ -248,6 +264,20 @@ void MenuBar::AddTableColumnsMenu(QMenu* view_menu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuBar::UpdateToolsMenu(bool emulation_started)
|
||||||
|
{
|
||||||
|
const bool enable_wii_tools = !emulation_started || !Settings::Instance().IsWiiGameRunning();
|
||||||
|
m_perform_online_update_menu->setEnabled(enable_wii_tools);
|
||||||
|
if (enable_wii_tools)
|
||||||
|
{
|
||||||
|
IOS::HLE::Kernel ios;
|
||||||
|
const auto tmd = ios.GetES()->FindInstalledTMD(Titles::SYSTEM_MENU);
|
||||||
|
for (QAction* action : m_perform_online_update_menu->actions())
|
||||||
|
action->setEnabled(!tmd.IsValid());
|
||||||
|
m_perform_online_update_for_current_region->setEnabled(tmd.IsValid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MenuBar::InstallWAD()
|
void MenuBar::InstallWAD()
|
||||||
{
|
{
|
||||||
QString wad_file = QFileDialog::getOpenFileName(this, tr("Select a title to install to NAND"),
|
QString wad_file = QFileDialog::getOpenFileName(this, tr("Select a title to install to NAND"),
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
|
||||||
@ -38,6 +40,8 @@ signals:
|
|||||||
void StateSaveOldest();
|
void StateSaveOldest();
|
||||||
void SetStateSlot(int slot);
|
void SetStateSlot(int slot);
|
||||||
|
|
||||||
|
void PerformOnlineUpdate(const std::string& region);
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
void ConfigureHotkeys();
|
void ConfigureHotkeys();
|
||||||
|
|
||||||
@ -53,6 +57,7 @@ public slots:
|
|||||||
void EmulationPaused();
|
void EmulationPaused();
|
||||||
void EmulationStopped();
|
void EmulationStopped();
|
||||||
void UpdateStateSlotMenu();
|
void UpdateStateSlotMenu();
|
||||||
|
void UpdateToolsMenu(bool emulation_started);
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
void InstallWAD();
|
void InstallWAD();
|
||||||
@ -79,6 +84,8 @@ private:
|
|||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
QAction* m_wad_install_action;
|
QAction* m_wad_install_action;
|
||||||
|
QMenu* m_perform_online_update_menu;
|
||||||
|
QAction* m_perform_online_update_for_current_region;
|
||||||
|
|
||||||
// Emulation
|
// Emulation
|
||||||
QAction* m_play_action;
|
QAction* m_play_action;
|
||||||
|
119
Source/Core/DolphinQt2/WiiUpdate.cpp
Normal file
119
Source/Core/DolphinQt2/WiiUpdate.cpp
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
// Copyright 2017 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "DolphinQt2/WiiUpdate.h"
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <future>
|
||||||
|
|
||||||
|
#include <QCloseEvent>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "Common/FileUtil.h"
|
||||||
|
#include "Common/Flag.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
|
#include "Core/WiiUtils.h"
|
||||||
|
#include "DiscIO/NANDImporter.h"
|
||||||
|
|
||||||
|
namespace WiiUpdate
|
||||||
|
{
|
||||||
|
void PerformOnlineUpdate(const std::string& region, QWidget* parent)
|
||||||
|
{
|
||||||
|
const int confirm = QMessageBox::question(
|
||||||
|
parent, QObject::tr("Confirm"),
|
||||||
|
QObject::tr("Connect to the Internet and perform an online system update?"));
|
||||||
|
if (confirm != QMessageBox::Yes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Do not allow the user to close the dialog. Instead, wait until the update is finished
|
||||||
|
// or cancelled.
|
||||||
|
class UpdateProgressDialog final : public QProgressDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using QProgressDialog::QProgressDialog;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void reject() override {}
|
||||||
|
};
|
||||||
|
|
||||||
|
UpdateProgressDialog dialog{parent};
|
||||||
|
dialog.setLabelText(QObject::tr("Preparing to update...\nThis can take a while."));
|
||||||
|
dialog.setWindowTitle(QObject::tr("Updating"));
|
||||||
|
// QProgressDialog doesn't set its minimum size correctly.
|
||||||
|
dialog.setMinimumSize(360, 150);
|
||||||
|
|
||||||
|
// QProgressDialog doesn't allow us to disable the cancel button when it's pressed,
|
||||||
|
// so we have to pass it our own push button. Note: the dialog takes ownership of it.
|
||||||
|
auto* cancel_button = new QPushButton(QObject::tr("&Cancel"), parent);
|
||||||
|
dialog.setCancelButton(cancel_button);
|
||||||
|
Common::Flag was_cancelled;
|
||||||
|
QObject::disconnect(&dialog, &QProgressDialog::canceled, &dialog, &QProgressDialog::cancel);
|
||||||
|
QObject::connect(&dialog, &QProgressDialog::canceled, [&] {
|
||||||
|
dialog.setLabelText(QObject::tr("Finishing the update...\nThis can take a while."));
|
||||||
|
cancel_button->setEnabled(false);
|
||||||
|
was_cancelled.Set();
|
||||||
|
});
|
||||||
|
|
||||||
|
std::future<WiiUtils::UpdateResult> result = std::async(std::launch::async, [&] {
|
||||||
|
const WiiUtils::UpdateResult res = WiiUtils::DoOnlineUpdate(
|
||||||
|
[&](size_t processed, size_t total, u64 title_id) {
|
||||||
|
Core::QueueHostJob(
|
||||||
|
[&dialog, &was_cancelled, processed, total, title_id]() {
|
||||||
|
if (was_cancelled.IsSet())
|
||||||
|
return;
|
||||||
|
|
||||||
|
dialog.setRange(0, static_cast<int>(total));
|
||||||
|
dialog.setValue(static_cast<int>(processed));
|
||||||
|
dialog.setLabelText(QObject::tr("Updating title %1...\nThis can take a while.")
|
||||||
|
.arg(title_id, 16, 16, QLatin1Char('0')));
|
||||||
|
},
|
||||||
|
true);
|
||||||
|
return !was_cancelled.IsSet();
|
||||||
|
},
|
||||||
|
region);
|
||||||
|
Core::QueueHostJob([&dialog] { dialog.close(); }, true);
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.exec();
|
||||||
|
|
||||||
|
switch (result.get())
|
||||||
|
{
|
||||||
|
case WiiUtils::UpdateResult::Succeeded:
|
||||||
|
QMessageBox::information(parent, QObject::tr("Update completed"),
|
||||||
|
QObject::tr("The emulated Wii console has been updated."));
|
||||||
|
DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX));
|
||||||
|
break;
|
||||||
|
case WiiUtils::UpdateResult::AlreadyUpToDate:
|
||||||
|
QMessageBox::information(parent, QObject::tr("Update completed"),
|
||||||
|
QObject::tr("The emulated Wii console is already up-to-date."));
|
||||||
|
DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX));
|
||||||
|
break;
|
||||||
|
case WiiUtils::UpdateResult::ServerFailed:
|
||||||
|
QMessageBox::critical(parent, QObject::tr("Update failed"),
|
||||||
|
QObject::tr("Could not download update information from Nintendo. "
|
||||||
|
"Please check your Internet connection and try again."));
|
||||||
|
break;
|
||||||
|
case WiiUtils::UpdateResult::DownloadFailed:
|
||||||
|
QMessageBox::critical(parent, QObject::tr("Update failed"),
|
||||||
|
QObject::tr("Could not download update files from Nintendo. "
|
||||||
|
"Please check your Internet connection and try again."));
|
||||||
|
break;
|
||||||
|
case WiiUtils::UpdateResult::ImportFailed:
|
||||||
|
QMessageBox::critical(parent, QObject::tr("Update failed"),
|
||||||
|
QObject::tr("Could not install an update to the Wii system memory. "
|
||||||
|
"Please refer to logs for more information."));
|
||||||
|
break;
|
||||||
|
case WiiUtils::UpdateResult::Cancelled:
|
||||||
|
QMessageBox::warning(
|
||||||
|
parent, QObject::tr("Update cancelled"),
|
||||||
|
QObject::tr("The update has been cancelled. It is strongly recommended to "
|
||||||
|
"finish it in order to avoid inconsistent system software versions."));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}; // namespace WiiUpdate
|
14
Source/Core/DolphinQt2/WiiUpdate.h
Normal file
14
Source/Core/DolphinQt2/WiiUpdate.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2017 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
|
namespace WiiUpdate
|
||||||
|
{
|
||||||
|
void PerformOnlineUpdate(const std::string& region, QWidget* parent = nullptr);
|
||||||
|
}; // namespace WiiUpdate
|
Reference in New Issue
Block a user