From 51c77e8eeae8244818a1cbb716c3410940826973 Mon Sep 17 00:00:00 2001 From: Aestek Date: Thu, 14 Jul 2016 00:45:38 +0200 Subject: Add md5 testing to netplay Allows to test current game, an arbitrary game or the sdcard of all players at once. --- Source/Core/DolphinWX/NetPlay/NetWindow.cpp | 113 ++++++++++++++++++++++++++-- 1 file changed, 108 insertions(+), 5 deletions(-) (limited to 'Source/Core/DolphinWX/NetPlay/NetWindow.cpp') diff --git a/Source/Core/DolphinWX/NetPlay/NetWindow.cpp b/Source/Core/DolphinWX/NetPlay/NetWindow.cpp index c1c5881db2..62597831ef 100644 --- a/Source/Core/DolphinWX/NetPlay/NetWindow.cpp +++ b/Source/Core/DolphinWX/NetPlay/NetWindow.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include "DolphinWX/NetPlay/NetWindow.h" #include "DolphinWX/NetPlay/PadMapDialog.h" #include "DolphinWX/WxUtils.h" +#include "MD5Dialog.h" NetPlayServer* NetPlayDialog::netplay_server = nullptr; NetPlayClient* NetPlayDialog::netplay_client = nullptr; @@ -120,7 +122,8 @@ NetPlayDialog::NetPlayDialog(wxWindow* const parent, const CGameListCtrl* const wxPanel* const panel = new wxPanel(this); - // top crap + wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL); + m_game_btn = new wxButton(panel, wxID_ANY, StrToWxStr(m_selected_game).Prepend(_(" Game : ")), wxDefaultPosition, wxDefaultSize, wxBU_LEFT); @@ -129,6 +132,21 @@ NetPlayDialog::NetPlayDialog(wxWindow* const parent, const CGameListCtrl* const else m_game_btn->Disable(); + top_szr->Add(m_game_btn, 1, wxALL | wxEXPAND); + + if (m_is_hosting) + { + m_MD5_choice = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(150, -1)); + m_MD5_choice->Bind(wxEVT_CHOICE, &NetPlayDialog::OnMD5ComputeRequested, this); + m_MD5_choice->Append(_("MD5 check...")); + m_MD5_choice->Append(_("Curent game")); + m_MD5_choice->Append(_("Other game")); + m_MD5_choice->Append(_("SD card")); + m_MD5_choice->SetSelection(0); + + top_szr->Add(m_MD5_choice, 0, wxALL); + } + // middle crap // chat @@ -232,7 +250,7 @@ NetPlayDialog::NetPlayDialog(wxWindow* const parent, const CGameListCtrl* const // main sizer wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL); - main_szr->Add(m_game_btn, 0, wxEXPAND | wxALL, 5); + main_szr->Add(top_szr, 0, wxEXPAND | wxALL, 5); main_szr->Add(mid_szr, 1, wxEXPAND | wxLEFT | wxRIGHT, 5); main_szr->Add(bottom_szr, 0, wxEXPAND | wxALL, 5); @@ -471,6 +489,31 @@ void NetPlayDialog::OnThread(wxThreadEvent& event) netplay_client->StopGame(); } break; + case NP_GUI_EVT_DISPLAY_MD5_DIALOG: + { + m_MD5_dialog = new MD5Dialog(this, netplay_server, netplay_client->GetPlayers(), + event.GetString().ToStdString()); + m_MD5_dialog->Show(); + } + break; + case NP_GUI_EVT_MD5_PROGRESS: + { + if (m_MD5_dialog == nullptr || m_MD5_dialog->IsBeingDeleted()) + break; + + std::pair payload = event.GetPayload>(); + m_MD5_dialog->SetProgress(payload.first, payload.second); + } + break; + case NP_GUI_EVT_MD5_RESULT: + { + if (m_MD5_dialog == nullptr || m_MD5_dialog->IsBeingDeleted()) + break; + + std::pair payload = event.GetPayload>(); + m_MD5_dialog->SetResult(payload.first, payload.second); + } + break; } // chat messages @@ -485,10 +528,10 @@ void NetPlayDialog::OnThread(wxThreadEvent& event) void NetPlayDialog::OnChangeGame(wxCommandEvent&) { - ChangeGameDialog cgd(this, m_game_list); - cgd.ShowModal(); + ChangeGameDialog change_game_dialog(this, m_game_list); + change_game_dialog.ShowModal(); - wxString game_name = cgd.GetChosenGameName(); + wxString game_name = change_game_dialog.GetChosenGameName(); if (game_name.empty()) return; @@ -497,6 +540,66 @@ void NetPlayDialog::OnChangeGame(wxCommandEvent&) m_game_btn->SetLabel(game_name.Prepend(_(" Game : "))); } +void NetPlayDialog::OnMD5ComputeRequested(wxCommandEvent&) +{ + MD5Target selection = static_cast(m_MD5_choice->GetSelection()); + std::string file_identifier; + ChangeGameDialog change_game_dialog(this, m_game_list); + + m_MD5_choice->SetSelection(0); + + switch (selection) + { + case MD5Target::CurrentGame: + file_identifier = m_selected_game; + break; + + case MD5Target::OtherGame: + change_game_dialog.ShowModal(); + + file_identifier = WxStrToStr(change_game_dialog.GetChosenGameName()); + if (file_identifier.empty()) + return; + break; + + case MD5Target::SdCard: + file_identifier = "sd.raw"; + break; + + default: + return; + } + + netplay_server->ComputeMD5(file_identifier); +} + +void NetPlayDialog::ShowMD5Dialog(const std::string& file_identifier) +{ + wxThreadEvent evt(wxEVT_THREAD, NP_GUI_EVT_DISPLAY_MD5_DIALOG); + evt.SetString(file_identifier); + GetEventHandler()->AddPendingEvent(evt); +} + +void NetPlayDialog::SetMD5Progress(int pid, int progress) +{ + wxThreadEvent evt(wxEVT_THREAD, NP_GUI_EVT_MD5_PROGRESS); + evt.SetPayload(std::pair(pid, progress)); + GetEventHandler()->AddPendingEvent(evt); +} + +void NetPlayDialog::SetMD5Result(int pid, const std::string& result) +{ + wxThreadEvent evt(wxEVT_THREAD, NP_GUI_EVT_MD5_RESULT); + evt.SetPayload(std::pair(pid, result)); + GetEventHandler()->AddPendingEvent(evt); +} + +void NetPlayDialog::AbortMD5() +{ + if (m_MD5_dialog != nullptr && !m_MD5_dialog->IsBeingDeleted()) + m_MD5_dialog->Destroy(); +} + void NetPlayDialog::OnAssignPads(wxCommandEvent&) { PadMapDialog pmd(this, netplay_server, netplay_client); -- cgit v1.2.3 From 9c5b546e2e61be91ae35c4becf04ea24151e2c77 Mon Sep 17 00:00:00 2001 From: Aestek Date: Sat, 16 Jul 2016 21:40:19 +0200 Subject: Add Wii sdcard to CommonPaths --- Source/Core/DolphinWX/NetPlay/NetWindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source/Core/DolphinWX/NetPlay/NetWindow.cpp') diff --git a/Source/Core/DolphinWX/NetPlay/NetWindow.cpp b/Source/Core/DolphinWX/NetPlay/NetWindow.cpp index 62597831ef..ee81bb4e91 100644 --- a/Source/Core/DolphinWX/NetPlay/NetWindow.cpp +++ b/Source/Core/DolphinWX/NetPlay/NetWindow.cpp @@ -24,6 +24,7 @@ #include #include +#include "Common/CommonPaths.h" #include "Common/CommonTypes.h" #include "Common/FifoQueue.h" #include "Common/FileUtil.h" @@ -563,7 +564,7 @@ void NetPlayDialog::OnMD5ComputeRequested(wxCommandEvent&) break; case MD5Target::SdCard: - file_identifier = "sd.raw"; + file_identifier = WII_SDCARD; break; default: -- cgit v1.2.3