summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2017-06-14 01:22:03 +0200
committerLéo Lam <leo@innovatetechnologi.es>2017-06-28 11:22:10 +0200
commitf06367febcc6be391bf68b5db41ad4253f60689c (patch)
tree1da1e31d2c96f674fd12526eff4535bd7c02b051 /Source/Core
parent42d217b9a8c6090f7af2743537fecb4747d63797 (diff)
WX: Add menu item to perform online update
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinWX/Frame.h1
-rw-r--r--Source/Core/DolphinWX/FrameTools.cpp101
-rw-r--r--Source/Core/DolphinWX/Globals.h5
-rw-r--r--Source/Core/DolphinWX/MainMenuBar.cpp36
-rw-r--r--Source/Core/DolphinWX/MainMenuBar.h6
5 files changed, 139 insertions, 10 deletions
diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h
index 26fdf74455..a4489b83da 100644
--- a/Source/Core/DolphinWX/Frame.h
+++ b/Source/Core/DolphinWX/Frame.h
@@ -345,6 +345,7 @@ private:
void OnUninstallWAD(wxCommandEvent& event);
void OnImportBootMiiBackup(wxCommandEvent& event);
void OnExtractCertificates(wxCommandEvent& event);
+ void OnPerformOnlineWiiUpdate(wxCommandEvent& event);
void OnFifoPlayer(wxCommandEvent& event);
void OnConnectWiimote(wxCommandEvent& event);
void GameListChanged(wxCommandEvent& event);
diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp
index bb7c28a1c5..a403118000 100644
--- a/Source/Core/DolphinWX/FrameTools.cpp
+++ b/Source/Core/DolphinWX/FrameTools.cpp
@@ -3,8 +3,11 @@
// Refer to the license.txt file included.
#include <array>
+#include <chrono>
+#include <cinttypes>
#include <cstdarg>
#include <cstdio>
+#include <future>
#include <mutex>
#include <string>
#include <vector>
@@ -18,7 +21,6 @@
#include <wx/panel.h>
#include <wx/progdlg.h>
#include <wx/statusbr.h>
-#include <wx/thread.h>
#include <wx/toolbar.h>
#include <wx/toplevel.h>
@@ -182,6 +184,12 @@ void CFrame::BindMenuBarEvents()
Bind(wxEVT_MENU, &CFrame::OnLoadWiiMenu, this, IDM_LOAD_WII_MENU);
Bind(wxEVT_MENU, &CFrame::OnImportBootMiiBackup, this, IDM_IMPORT_NAND);
Bind(wxEVT_MENU, &CFrame::OnExtractCertificates, this, IDM_EXTRACT_CERTIFICATES);
+ for (const int idm : {IDM_PERFORM_ONLINE_UPDATE_CURRENT, IDM_PERFORM_ONLINE_UPDATE_EUR,
+ IDM_PERFORM_ONLINE_UPDATE_JPN, IDM_PERFORM_ONLINE_UPDATE_KOR,
+ IDM_PERFORM_ONLINE_UPDATE_USA})
+ {
+ Bind(wxEVT_MENU, &CFrame::OnPerformOnlineWiiUpdate, this, idm);
+ }
Bind(wxEVT_MENU, &CFrame::OnFifoPlayer, this, IDM_FIFOPLAYER);
Bind(wxEVT_MENU, &CFrame::OnConnectWiimote, this, IDM_CONNECT_WIIMOTE1, IDM_CONNECT_BALANCEBOARD);
@@ -1293,6 +1301,93 @@ void CFrame::OnExtractCertificates(wxCommandEvent& WXUNUSED(event))
DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX));
}
+static std::string GetUpdateRegionFromIdm(int idm)
+{
+ switch (idm)
+ {
+ case IDM_PERFORM_ONLINE_UPDATE_EUR:
+ return "EUR";
+ case IDM_PERFORM_ONLINE_UPDATE_JPN:
+ return "JPN";
+ case IDM_PERFORM_ONLINE_UPDATE_KOR:
+ return "KOR";
+ case IDM_PERFORM_ONLINE_UPDATE_USA:
+ return "USA";
+ case IDM_PERFORM_ONLINE_UPDATE_CURRENT:
+ default:
+ return "";
+ }
+}
+
+void CFrame::OnPerformOnlineWiiUpdate(wxCommandEvent& event)
+{
+ int confirm = wxMessageBox(_("Connect to the Internet and perform an online system update?"),
+ _("System Update"), wxYES_NO, this);
+ if (confirm != wxYES)
+ return;
+
+ wxProgressDialog dialog(_("Updating"), _("Preparing to update...\nThis can take a while."), 1,
+ this, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_SMOOTH | wxPD_CAN_ABORT);
+
+ const std::string region = GetUpdateRegionFromIdm(event.GetId());
+ 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, processed, total, title_id] {
+ dialog.SetRange(total);
+ dialog.Update(processed, wxString::Format(_("Updating title %016" PRIx64 "...\n"
+ "This can take a while."),
+ title_id));
+ dialog.Fit();
+ },
+ true);
+ return !dialog.WasCancelled();
+ },
+ region);
+ Core::QueueHostJob([&dialog] { dialog.EndModal(0); }, true);
+ return res;
+ });
+
+ dialog.ShowModal();
+
+ switch (result.get())
+ {
+ case WiiUtils::UpdateResult::Succeeded:
+ wxMessageBox(_("The emulated Wii console has been updated."), _("Update completed"),
+ wxOK | wxICON_INFORMATION);
+ DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX));
+ break;
+ case WiiUtils::UpdateResult::AlreadyUpToDate:
+ wxMessageBox(_("The emulated Wii console is already up-to-date."), _("Update completed"),
+ wxOK | wxICON_INFORMATION);
+ DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX));
+ break;
+ case WiiUtils::UpdateResult::ServerFailed:
+ wxMessageBox(_("Could not download update information from Nintendo. "
+ "Please check your Internet connection and try again."),
+ _("Update failed"), wxOK | wxICON_ERROR);
+ break;
+ case WiiUtils::UpdateResult::DownloadFailed:
+ wxMessageBox(_("Could not download update files from Nintendo. "
+ "Please check your Internet connection and try again."),
+ _("Update failed"), wxOK | wxICON_ERROR);
+ break;
+ case WiiUtils::UpdateResult::ImportFailed:
+ wxMessageBox(_("Could not install an update to the Wii system memory. "
+ "Please refer to logs for more information."),
+ _("Update failed"), wxOK | wxICON_ERROR);
+ break;
+ case WiiUtils::UpdateResult::Cancelled:
+ wxMessageBox(_("The update has been cancelled. It is strongly recommended to "
+ "finish it in order to avoid inconsistent system software versions."),
+ _("Update cancelled"), wxOK | wxICON_WARNING);
+ break;
+ }
+
+ UpdateLoadWiiMenuItem();
+}
+
void CFrame::UpdateLoadWiiMenuItem() const
{
GetMenuBar()->Refresh(true, nullptr);
@@ -1492,10 +1587,6 @@ void CFrame::UpdateGUI()
GetMenuBar()
->FindItem(IDM_LOAD_GC_IPL_EUR)
->Enable(!Initialized && File::Exists(SConfig::GetInstance().GetBootROMPath(EUR_DIR)));
- if (DiscIO::NANDContentManager::Access()
- .GetNANDLoader(Titles::SYSTEM_MENU, Common::FROM_CONFIGURED_ROOT)
- .IsValid())
- GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(!Initialized);
// Tools
GetMenuBar()->FindItem(IDM_CHEATS)->Enable(SConfig::GetInstance().bEnableCheats);
diff --git a/Source/Core/DolphinWX/Globals.h b/Source/Core/DolphinWX/Globals.h
index ac066872ee..3abcec98f3 100644
--- a/Source/Core/DolphinWX/Globals.h
+++ b/Source/Core/DolphinWX/Globals.h
@@ -104,6 +104,11 @@ enum
IDM_LIST_UNINSTALL_WAD,
IDM_IMPORT_NAND,
IDM_EXTRACT_CERTIFICATES,
+ IDM_PERFORM_ONLINE_UPDATE_CURRENT,
+ IDM_PERFORM_ONLINE_UPDATE_EUR,
+ IDM_PERFORM_ONLINE_UPDATE_JPN,
+ IDM_PERFORM_ONLINE_UPDATE_KOR,
+ IDM_PERFORM_ONLINE_UPDATE_USA,
IDM_FIFOPLAYER,
IDM_LOAD_GC_IPL_JAP,
IDM_LOAD_GC_IPL_USA,
diff --git a/Source/Core/DolphinWX/MainMenuBar.cpp b/Source/Core/DolphinWX/MainMenuBar.cpp
index c9bdb25289..a9324565d1 100644
--- a/Source/Core/DolphinWX/MainMenuBar.cpp
+++ b/Source/Core/DolphinWX/MainMenuBar.cpp
@@ -235,6 +235,16 @@ wxMenu* MainMenuBar::CreateToolsMenu() const
tools_menu->Append(IDM_LOAD_WII_MENU, dummy_string);
tools_menu->Append(IDM_IMPORT_NAND, _("Import BootMii NAND Backup..."));
tools_menu->Append(IDM_EXTRACT_CERTIFICATES, _("Extract Certificates from NAND"));
+ auto* const online_update_menu = new wxMenu;
+ online_update_menu->Append(IDM_PERFORM_ONLINE_UPDATE_CURRENT, _("Current Region"));
+ online_update_menu->AppendSeparator();
+ online_update_menu->Append(IDM_PERFORM_ONLINE_UPDATE_EUR, _("Europe"));
+ online_update_menu->Append(IDM_PERFORM_ONLINE_UPDATE_JPN, _("Japan"));
+ online_update_menu->Append(IDM_PERFORM_ONLINE_UPDATE_KOR, _("Korean"));
+ online_update_menu->Append(IDM_PERFORM_ONLINE_UPDATE_USA, _("United States"));
+ tools_menu->AppendSubMenu(
+ online_update_menu, _("Perform Online System Update"),
+ _("Update the Wii system software to the latest version from Nintendo."));
tools_menu->AppendSeparator();
tools_menu->AppendSubMenu(wiimote_menu, _("Connect Wii Remotes"));
@@ -562,8 +572,6 @@ void MainMenuBar::RefreshSaveStateMenuLabels() const
void MainMenuBar::RefreshWiiToolsLabels() const
{
- RefreshWiiSystemMenuLabel();
-
// The Install WAD option should not be enabled while emulation is running, because
// having unexpected title changes can confuse emulated software; and of course, this is
// not possible on a real Wii and won't be if we have IOS LLE (or simply more accurate IOS HLE).
@@ -571,10 +579,26 @@ void MainMenuBar::RefreshWiiToolsLabels() const
// For similar reasons, it should not be possible to export or import saves, because this can
// result in the emulated software being confused, or even worse, exported saves having
// inconsistent data.
- for (const int index : {IDM_MENU_INSTALL_WAD, IDM_EXPORT_ALL_SAVE, IDM_IMPORT_SAVE,
- IDM_IMPORT_NAND, IDM_EXTRACT_CERTIFICATES})
+ const bool enable_wii_tools = !Core::IsRunning() || !SConfig::GetInstance().bWii;
+ for (const int index :
+ {IDM_MENU_INSTALL_WAD, IDM_EXPORT_ALL_SAVE, IDM_IMPORT_SAVE, IDM_IMPORT_NAND,
+ IDM_EXTRACT_CERTIFICATES, IDM_LOAD_WII_MENU, IDM_PERFORM_ONLINE_UPDATE_CURRENT,
+ IDM_PERFORM_ONLINE_UPDATE_EUR, IDM_PERFORM_ONLINE_UPDATE_JPN, IDM_PERFORM_ONLINE_UPDATE_KOR,
+ IDM_PERFORM_ONLINE_UPDATE_USA})
+ {
+ FindItem(index)->Enable(enable_wii_tools);
+ }
+ if (enable_wii_tools)
+ RefreshWiiSystemMenuLabel();
+}
+
+void MainMenuBar::EnableUpdateMenu(UpdateMenuMode mode) const
+{
+ FindItem(IDM_PERFORM_ONLINE_UPDATE_CURRENT)->Enable(mode == UpdateMenuMode::CurrentRegionOnly);
+ for (const int idm : {IDM_PERFORM_ONLINE_UPDATE_EUR, IDM_PERFORM_ONLINE_UPDATE_JPN,
+ IDM_PERFORM_ONLINE_UPDATE_KOR, IDM_PERFORM_ONLINE_UPDATE_USA})
{
- FindItem(index)->Enable(!Core::IsRunning() || !SConfig::GetInstance().bWii);
+ FindItem(idm)->Enable(mode == UpdateMenuMode::SpecificRegionsOnly);
}
}
@@ -591,11 +615,13 @@ void MainMenuBar::RefreshWiiSystemMenuLabel() const
const wxString version_string = StrToWxStr(DiscIO::GetSysMenuVersionString(version_number));
item->Enable();
item->SetItemLabel(wxString::Format(_("Load Wii System Menu %s"), version_string));
+ EnableUpdateMenu(UpdateMenuMode::CurrentRegionOnly);
}
else
{
item->Enable(false);
item->SetItemLabel(_("Load Wii System Menu"));
+ EnableUpdateMenu(UpdateMenuMode::SpecificRegionsOnly);
}
}
diff --git a/Source/Core/DolphinWX/MainMenuBar.h b/Source/Core/DolphinWX/MainMenuBar.h
index ca005640cb..d7e3d692dc 100644
--- a/Source/Core/DolphinWX/MainMenuBar.h
+++ b/Source/Core/DolphinWX/MainMenuBar.h
@@ -48,6 +48,12 @@ private:
void RefreshSaveStateMenuLabels() const;
void RefreshWiiToolsLabels() const;
void RefreshWiiSystemMenuLabel() const;
+ enum class UpdateMenuMode
+ {
+ CurrentRegionOnly,
+ SpecificRegionsOnly,
+ };
+ void EnableUpdateMenu(UpdateMenuMode mode) const;
void ClearSavedPerspectivesMenu() const;
void PopulateSavedPerspectivesMenu(const std::vector<std::string>& label_names) const;