Merge pull request #5746 from leoetlino/disc-updates

Add support for installing disc updates from the game list
This commit is contained in:
Leo Lam
2017-08-16 19:02:42 +08:00
committed by GitHub
17 changed files with 491 additions and 119 deletions
+1
View File
@@ -245,6 +245,7 @@ BEGIN_EVENT_TABLE(CFrame, CRenderFrame)
EVT_MENU_RANGE(IDM_FLOAT_LOG_WINDOW, IDM_FLOAT_CODE_WINDOW, CFrame::OnFloatWindow)
// Game list context menu
EVT_MENU(IDM_LIST_PERFORM_DISC_UPDATE, CFrame::OnPerformDiscWiiUpdate)
EVT_MENU(IDM_LIST_INSTALL_WAD, CFrame::OnInstallWAD)
EVT_MENU(IDM_LIST_UNINSTALL_WAD, CFrame::OnUninstallWAD)
+1
View File
@@ -349,6 +349,7 @@ private:
void OnImportBootMiiBackup(wxCommandEvent& event);
void OnExtractCertificates(wxCommandEvent& event);
void OnPerformOnlineWiiUpdate(wxCommandEvent& event);
void OnPerformDiscWiiUpdate(wxCommandEvent& event);
void OnFifoPlayer(wxCommandEvent& event);
void OnConnectWiimote(wxCommandEvent& event);
void GameListChanged(wxCommandEvent& event);
+67 -32
View File
@@ -1320,39 +1320,9 @@ static std::string GetUpdateRegionFromIdm(int idm)
}
}
void CFrame::OnPerformOnlineWiiUpdate(wxCommandEvent& event)
static void ShowUpdateResult(WiiUtils::UpdateResult result)
{
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())
switch (result)
{
case WiiUtils::UpdateResult::Succeeded:
wxMessageBox(_("The emulated Wii console has been updated."), _("Update completed"),
@@ -1384,8 +1354,73 @@ void CFrame::OnPerformOnlineWiiUpdate(wxCommandEvent& event)
"finish it in order to avoid inconsistent system software versions."),
_("Update cancelled"), wxOK | wxICON_WARNING);
break;
case WiiUtils::UpdateResult::RegionMismatch:
wxMessageBox(_("The game's region does not match your console's. "
"To avoid issues with the system menu, it is not possible to update "
"the emulated console using this disc."),
_("Update failed"), wxOK | wxICON_ERROR);
break;
case WiiUtils::UpdateResult::MissingUpdatePartition:
case WiiUtils::UpdateResult::DiscReadFailed:
wxMessageBox(_("The game disc does not contain any usable update information."),
_("Update failed"), wxOK | wxICON_ERROR);
break;
}
}
template <typename Callable, typename... Args>
static WiiUtils::UpdateResult ShowUpdateProgress(CFrame* frame, Callable function, Args&&... args)
{
wxProgressDialog dialog(_("Updating"), _("Preparing to update...\nThis can take a while."), 1,
frame, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_SMOOTH | wxPD_CAN_ABORT);
std::future<WiiUtils::UpdateResult> result = std::async(std::launch::async, [&] {
const WiiUtils::UpdateResult res = function(
[&](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();
},
std::forward<Args>(args)...);
Core::QueueHostJob([&dialog] { dialog.EndModal(0); }, true);
return res;
});
dialog.ShowModal();
return result.get();
}
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;
const std::string region = GetUpdateRegionFromIdm(event.GetId());
const WiiUtils::UpdateResult result = ShowUpdateProgress(this, WiiUtils::DoOnlineUpdate, region);
ShowUpdateResult(result);
UpdateLoadWiiMenuItem();
}
void CFrame::OnPerformDiscWiiUpdate(wxCommandEvent&)
{
const GameListItem* iso = m_game_list_ctrl->GetSelectedISO();
if (!iso)
return;
const std::string file_name = iso->GetFileName();
const WiiUtils::UpdateResult result = ShowUpdateProgress(this, WiiUtils::DoDiscUpdate, file_name);
ShowUpdateResult(result);
UpdateLoadWiiMenuItem();
}
+7
View File
@@ -1173,6 +1173,13 @@ void GameListCtrl::OnRightClick(wxMouseEvent& event)
changeDiscItem->Enable(Core::IsRunning());
}
if (platform == DiscIO::Platform::WII_DISC)
{
auto* const perform_update_item =
popupMenu.Append(IDM_LIST_PERFORM_DISC_UPDATE, _("Perform System Update"));
perform_update_item->Enable(!Core::IsRunning() || !SConfig::GetInstance().bWii);
}
if (platform == DiscIO::Platform::WII_WAD)
{
auto* const install_wad_item =
+1
View File
@@ -100,6 +100,7 @@ enum
IDM_GAME_WIKI,
IDM_LOAD_WII_MENU,
IDM_MENU_INSTALL_WAD,
IDM_LIST_PERFORM_DISC_UPDATE,
IDM_LIST_INSTALL_WAD,
IDM_LIST_UNINSTALL_WAD,
IDM_IMPORT_NAND,