diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2016-10-03 05:35:27 -0700 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2016-10-03 15:34:49 -0700 |
| commit | 41e7c43d0d2809bf7f0bc99f6fac4bb4e20539ae (patch) | |
| tree | 95e0615fe9ddb3228114d0843fba677e3b627e80 /Source/Core/DolphinWX/GameListCtrl.cpp | |
| parent | 46b6a32b467f51b5e38e7f9b6c2738bc914627e1 (diff) | |
NetPlay: add one click host
Add a context menu entry in main game list to host a netplay game
based on saved settings.
Original commit:
commit 91aaa958e6af0275c07b63443938a0be471e0669
Author: Aestek <thib.gilles@gmail.com>
Date: Sun Jul 24 14:51:37 2016 +0200
Diffstat (limited to 'Source/Core/DolphinWX/GameListCtrl.cpp')
| -rw-r--r-- | Source/Core/DolphinWX/GameListCtrl.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index e382588b75..2bb88f10ab 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -59,6 +59,7 @@ #include "DolphinWX/ISOFile.h" #include "DolphinWX/ISOProperties.h" #include "DolphinWX/Main.h" +#include "DolphinWX/NetPlay/NetPlayLauncher.h" #include "DolphinWX/WxUtils.h" struct CompressionProgress final @@ -176,6 +177,7 @@ CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoin Bind(wxEVT_MENU, &CGameListCtrl::OnMultiDecompressISO, this, IDM_MULTI_DECOMPRESS_ISO); Bind(wxEVT_MENU, &CGameListCtrl::OnDeleteISO, this, IDM_DELETE_ISO); Bind(wxEVT_MENU, &CGameListCtrl::OnChangeDisc, this, IDM_LIST_CHANGE_DISC); + Bind(wxEVT_MENU, &CGameListCtrl::OnNetPlayHost, this, IDM_START_NETPLAY); wxTheApp->Bind(DOLPHIN_EVT_LOCAL_INI_CHANGED, &CGameListCtrl::OnLocalIniModified, this); } @@ -972,6 +974,8 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event) if (platform == DiscIO::Platform::WII_WAD) popupMenu.Append(IDM_LIST_INSTALL_WAD, _("Install to Wii Menu")); + popupMenu.Append(IDM_START_NETPLAY, _("Host with Netplay")); + PopupMenu(&popupMenu); } } @@ -1119,6 +1123,29 @@ void CGameListCtrl::OnWiki(wxCommandEvent& WXUNUSED(event)) WxUtils::Launch(wikiUrl); } +void CGameListCtrl::OnNetPlayHost(wxCommandEvent& WXUNUSED(event)) +{ + const GameListItem* iso = GetSelectedISO(); + if (!iso) + return; + + IniFile ini_file; + const std::string dolphin_ini = File::GetUserPath(F_DOLPHINCONFIG_IDX); + ini_file.Load(dolphin_ini); + IniFile::Section& netplay_section = *ini_file.GetOrCreateSection("NetPlay"); + + NetPlayHostConfig config; + config.FromIniConfig(netplay_section); + config.game_name = iso->GetUniqueIdentifier(); + config.game_list_ctrl = this; + config.parent_window = m_parent; + + netplay_section.Set("SelectedHostGame", config.game_name); + ini_file.Save(dolphin_ini); + + NetPlayLauncher::Host(config); +} + bool CGameListCtrl::MultiCompressCB(const std::string& text, float percent, void* arg) { CompressionProgress* progress = static_cast<CompressionProgress*>(arg); |
