mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #2289 from lioncash/netplay
DolphinWX: Break the netplay UI controls into separate classes.
This commit is contained in:
@@ -32,6 +32,10 @@ set(GUI_SRCS
|
||||
Debugger/RegisterWindow.cpp
|
||||
Debugger/WatchView.cpp
|
||||
Debugger/WatchWindow.cpp
|
||||
NetPlay/ChangeGameDialog.cpp
|
||||
NetPlay/NetPlaySetupFrame.cpp
|
||||
NetPlay/NetWindow.cpp
|
||||
NetPlay/PadMapDialog.cpp
|
||||
FifoPlayerDlg.cpp
|
||||
Frame.cpp
|
||||
FrameAui.cpp
|
||||
@@ -46,7 +50,6 @@ set(GUI_SRCS
|
||||
LogWindow.cpp
|
||||
Main.cpp
|
||||
MemcardManager.cpp
|
||||
NetWindow.cpp
|
||||
PatchAddEdit.cpp
|
||||
PostProcessingConfigDiag.cpp
|
||||
SoftwareVideoConfigDialog.cpp
|
||||
|
||||
@@ -80,6 +80,9 @@
|
||||
<ClCompile Include="Debugger\RegisterWindow.cpp" />
|
||||
<ClCompile Include="Debugger\WatchView.cpp" />
|
||||
<ClCompile Include="Debugger\WatchWindow.cpp" />
|
||||
<ClCompile Include="NetPlay\ChangeGameDialog.cpp" />
|
||||
<ClCompile Include="NetPlay\NetPlaySetupFrame.cpp" />
|
||||
<ClCompile Include="NetPlay\NetWindow.cpp" />
|
||||
<ClCompile Include="FifoPlayerDlg.cpp" />
|
||||
<ClCompile Include="Frame.cpp" />
|
||||
<ClCompile Include="FrameAui.cpp" />
|
||||
@@ -97,7 +100,7 @@
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MemcardManager.cpp" />
|
||||
<ClCompile Include="NetWindow.cpp" />
|
||||
<ClCompile Include="NetPlay\PadMapDialog.cpp" />
|
||||
<ClCompile Include="PatchAddEdit.cpp" />
|
||||
<ClCompile Include="SoftwareVideoConfigDialog.cpp" />
|
||||
<ClCompile Include="TASInputDlg.cpp" />
|
||||
@@ -115,6 +118,9 @@
|
||||
<ClInclude Include="Config\InterfaceConfigPane.h" />
|
||||
<ClInclude Include="Config\PathConfigPane.h" />
|
||||
<ClInclude Include="Config\WiiConfigPane.h" />
|
||||
<ClInclude Include="NetPlay\ChangeGameDialog.h" />
|
||||
<ClInclude Include="NetPlay\NetPlaySetupFrame.h" />
|
||||
<ClInclude Include="NetPlay\PadMapDialog.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="AboutDolphin.h" />
|
||||
<ClInclude Include="ARCodeAddEdit.h" />
|
||||
@@ -140,6 +146,7 @@
|
||||
<ClInclude Include="Debugger\RegisterWindow.h" />
|
||||
<ClInclude Include="Debugger\WatchView.h" />
|
||||
<ClInclude Include="Debugger\WatchWindow.h" />
|
||||
<ClInclude Include="NetPlay\NetWindow.h" />
|
||||
<ClInclude Include="FifoPlayerDlg.h" />
|
||||
<ClInclude Include="Frame.h" />
|
||||
<ClInclude Include="GameListCtrl.h" />
|
||||
@@ -152,7 +159,6 @@
|
||||
<ClInclude Include="LogWindow.h" />
|
||||
<ClInclude Include="Main.h" />
|
||||
<ClInclude Include="MemcardManager.h" />
|
||||
<ClInclude Include="NetWindow.h" />
|
||||
<ClInclude Include="PatchAddEdit.h" />
|
||||
<ClInclude Include="SoftwareVideoConfigDialog.h" />
|
||||
<ClInclude Include="TASInputDlg.h" />
|
||||
|
||||
@@ -97,15 +97,15 @@
|
||||
<ClCompile Include="Debugger\WatchWindow.cpp">
|
||||
<Filter>GUI\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NetPlay\NetWindow.cpp">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InputConfigDiag.cpp">
|
||||
<Filter>GUI\InputConfig</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InputConfigDiagBitmaps.cpp">
|
||||
<Filter>GUI\InputConfig</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NetWindow.cpp">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Debugger\DebuggerPanel.cpp">
|
||||
<Filter>GUI\Video</Filter>
|
||||
</ClCompile>
|
||||
@@ -190,6 +190,15 @@
|
||||
<ClCompile Include="Config\AdvancedConfigPane.cpp">
|
||||
<Filter>GUI\Config</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NetPlay\NetPlaySetupFrame.cpp">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NetPlay\ChangeGameDialog.cpp">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NetPlay\PadMapDialog.cpp">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Main.h" />
|
||||
@@ -255,12 +264,12 @@
|
||||
<ClInclude Include="Debugger\WatchWindow.h">
|
||||
<Filter>GUI\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NetPlay\NetWindow.h">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InputConfigDiag.h">
|
||||
<Filter>GUI\InputConfig</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NetWindow.h">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Debugger\DebuggerPanel.h">
|
||||
<Filter>GUI\Video</Filter>
|
||||
</ClInclude>
|
||||
@@ -345,6 +354,15 @@
|
||||
<ClInclude Include="Config\AdvancedConfigPane.h">
|
||||
<Filter>GUI\Config</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NetPlay\NetPlaySetupFrame.h">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NetPlay\ChangeGameDialog.h">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NetPlay\PadMapDialog.h">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="CMakeLists.txt" />
|
||||
|
||||
@@ -38,7 +38,7 @@ class CCodeWindow;
|
||||
class CLogWindow;
|
||||
class FifoPlayerDlg;
|
||||
class LogConfigWindow;
|
||||
class NetPlaySetupDiag;
|
||||
class NetPlaySetupFrame;
|
||||
class TASInputDlg;
|
||||
class wxCheatsWindow;
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
|
||||
// These have to be public
|
||||
CCodeWindow* g_pCodeWindow;
|
||||
NetPlaySetupDiag* g_NetPlaySetupDiag;
|
||||
NetPlaySetupFrame* g_NetPlaySetupDiag;
|
||||
wxCheatsWindow* g_CheatsWindow;
|
||||
TASInputDlg* g_TASInputDlg[8];
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@
|
||||
#include "DolphinWX/ISOFile.h"
|
||||
#include "DolphinWX/LogWindow.h"
|
||||
#include "DolphinWX/MemcardManager.h"
|
||||
#include "DolphinWX/NetWindow.h"
|
||||
#include "DolphinWX/TASInputDlg.h"
|
||||
#include "DolphinWX/WXInputBase.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
@@ -84,6 +83,8 @@
|
||||
#include "DolphinWX/Debugger/BreakpointWindow.h"
|
||||
#include "DolphinWX/Debugger/CodeWindow.h"
|
||||
#include "DolphinWX/Debugger/WatchWindow.h"
|
||||
#include "DolphinWX/NetPlay/NetPlaySetupFrame.h"
|
||||
#include "DolphinWX/NetPlay/NetWindow.h"
|
||||
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
@@ -1213,7 +1214,9 @@ void CFrame::DoStop()
|
||||
DoRecordingSave();
|
||||
if (Movie::IsMovieActive())
|
||||
Movie::EndPlayInput(false);
|
||||
NetPlay::StopGame();
|
||||
|
||||
if (NetPlayDialog::GetNetPlayClient())
|
||||
NetPlayDialog::GetNetPlayClient()->Stop();
|
||||
|
||||
BootManager::Stop();
|
||||
UpdateGUI();
|
||||
@@ -1450,10 +1453,10 @@ void CFrame::OnNetPlay(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
if (!g_NetPlaySetupDiag)
|
||||
{
|
||||
if (NetPlayDiag::GetInstance() != nullptr)
|
||||
NetPlayDiag::GetInstance()->Raise();
|
||||
if (NetPlayDialog::GetInstance() != nullptr)
|
||||
NetPlayDialog::GetInstance()->Raise();
|
||||
else
|
||||
g_NetPlaySetupDiag = new NetPlaySetupDiag(this, m_GameListCtrl);
|
||||
g_NetPlaySetupDiag = new NetPlaySetupFrame(this, m_GameListCtrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <wx/button.h>
|
||||
#include <wx/listbox.h>
|
||||
#include <wx/sizer.h>
|
||||
|
||||
#include "DolphinWX/NetPlay/ChangeGameDialog.h"
|
||||
#include "DolphinWX/NetPlay/NetWindow.h"
|
||||
|
||||
ChangeGameDialog::ChangeGameDialog(wxWindow* parent, const CGameListCtrl* const game_list, wxString& game_name)
|
||||
: wxDialog(parent, wxID_ANY, _("Change Game"))
|
||||
, m_game_name(game_name)
|
||||
{
|
||||
m_game_lbox = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_SORT);
|
||||
m_game_lbox->Bind(wxEVT_LISTBOX_DCLICK, &ChangeGameDialog::OnPick, this);
|
||||
|
||||
NetPlayDialog::FillWithGameNames(m_game_lbox, *game_list);
|
||||
|
||||
wxButton* const ok_btn = new wxButton(this, wxID_OK, _("Change"));
|
||||
ok_btn->Bind(wxEVT_BUTTON, &ChangeGameDialog::OnPick, this);
|
||||
|
||||
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
|
||||
szr->Add(m_game_lbox, 1, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 5);
|
||||
szr->Add(ok_btn, 0, wxALL | wxALIGN_RIGHT, 5);
|
||||
|
||||
SetSizerAndFit(szr);
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
void ChangeGameDialog::OnPick(wxCommandEvent& event)
|
||||
{
|
||||
// return the selected game name
|
||||
m_game_name = m_game_lbox->GetStringSelection();
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wx/dialog.h>
|
||||
|
||||
class CGameListCtrl;
|
||||
class wxListBox;
|
||||
|
||||
class ChangeGameDialog final : public wxDialog
|
||||
{
|
||||
public:
|
||||
ChangeGameDialog(wxWindow* parent, const CGameListCtrl* const game_list, wxString& game_name);
|
||||
|
||||
private:
|
||||
void OnPick(wxCommandEvent& event);
|
||||
|
||||
wxListBox* m_game_lbox;
|
||||
wxString& m_game_name;
|
||||
};
|
||||
@@ -0,0 +1,390 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <wx/button.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/listbox.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/textctrl.h>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Core/NetPlayClient.h"
|
||||
#include "Core/NetPlayServer.h"
|
||||
#include "DolphinWX/Frame.h"
|
||||
#include "DolphinWX/Main.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
#include "DolphinWX/NetPlay/NetPlaySetupFrame.h"
|
||||
#include "DolphinWX/NetPlay/NetWindow.h"
|
||||
|
||||
NetPlaySetupFrame::NetPlaySetupFrame(wxWindow* const parent, const CGameListCtrl* const game_list)
|
||||
: wxFrame(parent, wxID_ANY, _("Dolphin NetPlay Setup"))
|
||||
, m_game_list(game_list)
|
||||
{
|
||||
IniFile inifile;
|
||||
inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini");
|
||||
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");
|
||||
|
||||
wxPanel* const panel = new wxPanel(this);
|
||||
|
||||
// top row
|
||||
wxBoxSizer* const trav_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_direct_traversal = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(75, -1));
|
||||
m_direct_traversal->Bind(wxEVT_CHOICE, &NetPlaySetupFrame::OnChoice, this);
|
||||
m_direct_traversal->Append(_("Direct"));
|
||||
m_direct_traversal->Append(_("Traversal"));
|
||||
|
||||
std::string travChoice;
|
||||
netplay_section.Get("TraversalChoice", &travChoice, "direct");
|
||||
|
||||
if (travChoice == "traversal")
|
||||
{
|
||||
m_direct_traversal->Select(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_direct_traversal->Select(0);
|
||||
}
|
||||
|
||||
trav_szr->Add(m_direct_traversal, 0, wxRIGHT);
|
||||
|
||||
wxBoxSizer* const nick_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxStaticText* const nick_lbl = new wxStaticText(panel, wxID_ANY, _("Nickname :"));
|
||||
std::string nickname;
|
||||
netplay_section.Get("Nickname", &nickname, "Player");
|
||||
m_nickname_text = new wxTextCtrl(panel, wxID_ANY, StrToWxStr(nickname));
|
||||
nick_szr->Add(nick_lbl, 0, wxCENTER);
|
||||
nick_szr->Add(m_nickname_text, 0, wxALL, 5);
|
||||
|
||||
std::string centralServer;
|
||||
netplay_section.Get("TraversalServer", ¢ralServer, "");
|
||||
m_traversal_server_lbl = new wxStaticText(panel, wxID_ANY, _("Traversal:"));
|
||||
m_traversal_server = new wxTextCtrl(panel, wxID_ANY, StrToWxStr(centralServer));
|
||||
nick_szr->Add(m_traversal_server_lbl, 0, wxCENTER);
|
||||
nick_szr->Add(m_traversal_server, 0, wxALL, 5);
|
||||
|
||||
std::string centralPort;
|
||||
netplay_section.Get("TraversalPort", ¢ralPort, "");
|
||||
m_traversal_port_lbl = new wxStaticText(panel, wxID_ANY, _("Port:"));
|
||||
m_traversal_port = new wxTextCtrl(panel, wxID_ANY, StrToWxStr(centralPort));
|
||||
nick_szr->Add(m_traversal_port_lbl, 0, wxCENTER);
|
||||
nick_szr->Add(m_traversal_port, 0, wxALL, 5);
|
||||
|
||||
// tabs
|
||||
wxNotebook* const notebook = new wxNotebook(panel, wxID_ANY);
|
||||
wxPanel* const connect_tab = new wxPanel(notebook, wxID_ANY);
|
||||
notebook->AddPage(connect_tab, _("Connect"));
|
||||
wxPanel* const host_tab = new wxPanel(notebook, wxID_ANY);
|
||||
notebook->AddPage(host_tab, _("Host"));
|
||||
|
||||
// connect tab
|
||||
{
|
||||
m_ip_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Host Code :"));
|
||||
|
||||
std::string address;
|
||||
netplay_section.Get("HostCode", &address, "00000000");
|
||||
m_connect_ip_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(address));
|
||||
|
||||
m_client_port_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Port :"));
|
||||
|
||||
// string? w/e
|
||||
std::string port;
|
||||
netplay_section.Get("ConnectPort", &port, "2626");
|
||||
m_connect_port_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(port));
|
||||
|
||||
wxButton* const connect_btn = new wxButton(connect_tab, wxID_ANY, _("Connect"));
|
||||
connect_btn->Bind(wxEVT_BUTTON, &NetPlaySetupFrame::OnJoin, this);
|
||||
|
||||
wxStaticText* const alert_lbl = new wxStaticText(connect_tab, wxID_ANY,
|
||||
_("ALERT:\n\n"
|
||||
"Netplay will only work with the following settings:\n"
|
||||
" - DSP Emulator Engine Must be the same on all computers!\n"
|
||||
" - DSP on Dedicated Thread [OFF]\n"
|
||||
" - Manually set the extensions for each Wiimote\n"
|
||||
"\n"
|
||||
"All players should use the same Dolphin version and settings.\n"
|
||||
"All memory cards must be identical between players or disabled.\n"
|
||||
"Wiimote support is probably terrible. Don't use it.\n"
|
||||
"\n"
|
||||
"If connecting directly host must have the chosen UDP port open/forwarded!\n"));
|
||||
|
||||
wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
top_szr->Add(m_ip_lbl, 0, wxCENTER | wxRIGHT, 5);
|
||||
top_szr->Add(m_connect_ip_text, 3);
|
||||
top_szr->Add(m_client_port_lbl, 0, wxCENTER | wxRIGHT | wxLEFT, 5);
|
||||
top_szr->Add(m_connect_port_text, 1);
|
||||
|
||||
wxBoxSizer* const con_szr = new wxBoxSizer(wxVERTICAL);
|
||||
con_szr->Add(top_szr, 0, wxALL | wxEXPAND, 5);
|
||||
con_szr->AddStretchSpacer(1);
|
||||
con_szr->Add(alert_lbl, 0, wxLEFT | wxRIGHT | wxEXPAND, 5);
|
||||
con_szr->AddStretchSpacer(1);
|
||||
con_szr->Add(connect_btn, 0, wxALL | wxALIGN_RIGHT, 5);
|
||||
|
||||
connect_tab->SetSizerAndFit(con_szr);
|
||||
}
|
||||
|
||||
// host tab
|
||||
{
|
||||
m_host_port_lbl = new wxStaticText(host_tab, wxID_ANY, _("Port :"));
|
||||
|
||||
// string? w/e
|
||||
std::string port;
|
||||
netplay_section.Get("HostPort", &port, "2626");
|
||||
m_host_port_text = new wxTextCtrl(host_tab, wxID_ANY, StrToWxStr(port));
|
||||
|
||||
wxButton* const host_btn = new wxButton(host_tab, wxID_ANY, _("Host"));
|
||||
host_btn->Bind(wxEVT_BUTTON, &NetPlaySetupFrame::OnHost, this);
|
||||
|
||||
m_game_lbox = new wxListBox(host_tab, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_SORT);
|
||||
m_game_lbox->Bind(wxEVT_LISTBOX_DCLICK, &NetPlaySetupFrame::OnHost, this);
|
||||
|
||||
NetPlayDialog::FillWithGameNames(m_game_lbox, *game_list);
|
||||
|
||||
wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
top_szr->Add(m_host_port_lbl, 0, wxCENTER | wxRIGHT, 5);
|
||||
top_szr->Add(m_host_port_text, 0);
|
||||
#ifdef USE_UPNP
|
||||
m_upnp_chk = new wxCheckBox(host_tab, wxID_ANY, _("Forward port (UPnP)"));
|
||||
top_szr->Add(m_upnp_chk, 0, wxALL | wxALIGN_RIGHT, 5);
|
||||
#endif
|
||||
|
||||
wxBoxSizer* const host_szr = new wxBoxSizer(wxVERTICAL);
|
||||
host_szr->Add(top_szr, 0, wxALL | wxEXPAND, 5);
|
||||
host_szr->Add(m_game_lbox, 1, wxLEFT | wxRIGHT | wxEXPAND, 5);
|
||||
host_szr->Add(host_btn, 0, wxALL | wxALIGN_RIGHT, 5);
|
||||
|
||||
host_tab->SetSizerAndFit(host_szr);
|
||||
}
|
||||
|
||||
// bottom row
|
||||
wxButton* const quit_btn = new wxButton(panel, wxID_ANY, _("Quit"));
|
||||
quit_btn->Bind(wxEVT_BUTTON, &NetPlaySetupFrame::OnQuit, this);
|
||||
|
||||
// main sizer
|
||||
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
|
||||
main_szr->Add(trav_szr, 0, wxALL | wxALIGN_LEFT);
|
||||
main_szr->Add(nick_szr, 0, wxALL | wxALIGN_LEFT, 5);
|
||||
main_szr->Add(notebook, 1, wxLEFT | wxRIGHT | wxEXPAND, 5);
|
||||
main_szr->Add(quit_btn, 0, wxALL | wxALIGN_RIGHT, 5);
|
||||
|
||||
panel->SetSizerAndFit(main_szr);
|
||||
|
||||
//wxBoxSizer* const diag_szr = new wxBoxSizer(wxVERTICAL);
|
||||
//diag_szr->Add(panel, 1, wxEXPAND);
|
||||
//SetSizerAndFit(diag_szr);
|
||||
|
||||
main_szr->SetSizeHints(this);
|
||||
|
||||
Center();
|
||||
Show();
|
||||
|
||||
// Needs to be done last or it set up the spacing on the page correctly
|
||||
wxCommandEvent ev;
|
||||
OnChoice(ev);
|
||||
}
|
||||
|
||||
NetPlaySetupFrame::~NetPlaySetupFrame()
|
||||
{
|
||||
IniFile inifile;
|
||||
const std::string dolphin_ini = File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini";
|
||||
inifile.Load(dolphin_ini);
|
||||
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");
|
||||
|
||||
std::string travChoice = "traversal";
|
||||
if (m_direct_traversal->GetSelection() == 1)
|
||||
{
|
||||
netplay_section.Set("TraversalChoice", travChoice);
|
||||
}
|
||||
else
|
||||
{
|
||||
travChoice = "direct";
|
||||
netplay_section.Set("TraversalChoice", travChoice);
|
||||
}
|
||||
|
||||
netplay_section.Set("Nickname", WxStrToStr(m_nickname_text->GetValue()));
|
||||
netplay_section.Set("TraversalServer", WxStrToStr(m_traversal_server->GetValue()));
|
||||
netplay_section.Set("TraversalPort", WxStrToStr(m_traversal_port->GetValue()));
|
||||
|
||||
if (m_direct_traversal->GetCurrentSelection() == 0)
|
||||
{
|
||||
netplay_section.Set("Address", WxStrToStr(m_connect_ip_text->GetValue()));
|
||||
}
|
||||
else
|
||||
{
|
||||
netplay_section.Set("HostCode", WxStrToStr(m_connect_ip_text->GetValue()));
|
||||
}
|
||||
netplay_section.Set("ConnectPort", WxStrToStr(m_connect_port_text->GetValue()));
|
||||
netplay_section.Set("HostPort", WxStrToStr(m_host_port_text->GetValue()));
|
||||
|
||||
inifile.Save(dolphin_ini);
|
||||
main_frame->g_NetPlaySetupDiag = nullptr;
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::MakeNetPlayDiag(int port, const std::string &game, bool is_hosting)
|
||||
{
|
||||
NetPlayDialog*& npd = NetPlayDialog::GetInstance();
|
||||
NetPlayClient*& netplay_client = NetPlayDialog::GetNetPlayClient();
|
||||
|
||||
std::string ip;
|
||||
npd = new NetPlayDialog(m_parent, m_game_list, game, is_hosting);
|
||||
if (is_hosting)
|
||||
ip = "127.0.0.1";
|
||||
else
|
||||
ip = WxStrToStr(m_connect_ip_text->GetValue());
|
||||
|
||||
bool trav;
|
||||
if (!is_hosting && m_direct_traversal->GetCurrentSelection() == 1)
|
||||
trav = true;
|
||||
else
|
||||
trav = false;
|
||||
|
||||
unsigned long centralPort = 0;
|
||||
m_traversal_port->GetValue().ToULong(¢ralPort);
|
||||
netplay_client = new NetPlayClient(ip, (u16)port, npd, WxStrToStr(m_nickname_text->GetValue()), trav, WxStrToStr(m_traversal_server->GetValue()), (u16)centralPort);
|
||||
if (netplay_client->is_connected)
|
||||
{
|
||||
npd->Show();
|
||||
Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
npd->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::OnHost(wxCommandEvent&)
|
||||
{
|
||||
NetPlayDialog*& npd = NetPlayDialog::GetInstance();
|
||||
NetPlayServer*& netplay_server = NetPlayDialog::GetNetPlayServer();
|
||||
|
||||
if (npd)
|
||||
{
|
||||
WxUtils::ShowErrorDialog(_("A NetPlay window is already open!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_game_lbox->GetSelection() == wxNOT_FOUND)
|
||||
{
|
||||
WxUtils::ShowErrorDialog(_("You must choose a game!"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string game(WxStrToStr(m_game_lbox->GetStringSelection()));
|
||||
|
||||
bool trav;
|
||||
if (m_direct_traversal->GetCurrentSelection() == 1)
|
||||
trav = true;
|
||||
else
|
||||
trav = false;
|
||||
|
||||
unsigned long port = 0;
|
||||
m_host_port_text->GetValue().ToULong(&port);
|
||||
|
||||
unsigned long centralPort = 0;
|
||||
m_traversal_port->GetValue().ToULong(¢ralPort);
|
||||
netplay_server = new NetPlayServer((u16)port, trav, WxStrToStr(m_traversal_server->GetValue()), (u16)centralPort);
|
||||
if (netplay_server->is_connected)
|
||||
{
|
||||
netplay_server->ChangeGame(game);
|
||||
netplay_server->AdjustPadBufferSize(INITIAL_PAD_BUFFER_SIZE);
|
||||
#ifdef USE_UPNP
|
||||
if (m_upnp_chk->GetValue())
|
||||
netplay_server->TryPortmapping(port);
|
||||
#endif
|
||||
MakeNetPlayDiag(netplay_server->GetPort(), game, true);
|
||||
netplay_server->SetNetPlayUI(NetPlayDialog::GetInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
WxUtils::ShowErrorDialog(_("Failed to listen. Is another instance of the NetPlay server running?"));
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::OnJoin(wxCommandEvent&)
|
||||
{
|
||||
NetPlayDialog*& npd = NetPlayDialog::GetInstance();
|
||||
if (npd)
|
||||
{
|
||||
WxUtils::ShowErrorDialog(_("A NetPlay window is already open!"));
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned long port = 0;
|
||||
m_connect_port_text->GetValue().ToULong(&port);
|
||||
MakeNetPlayDiag(port, "", false);
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::OnChoice(wxCommandEvent& event)
|
||||
{
|
||||
int sel = m_direct_traversal->GetSelection();
|
||||
IniFile inifile;
|
||||
inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini");
|
||||
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");
|
||||
|
||||
if (sel == 1)
|
||||
{
|
||||
m_traversal_server_lbl->Show();
|
||||
m_traversal_server->Show();
|
||||
|
||||
m_traversal_port_lbl->Show();
|
||||
m_traversal_port->Show();
|
||||
|
||||
//Traversal
|
||||
//client tab
|
||||
{
|
||||
m_ip_lbl->SetLabelText("Host Code: ");
|
||||
|
||||
std::string address;
|
||||
netplay_section.Get("HostCode", &address, "00000000");
|
||||
m_connect_ip_text->SetLabelText(address);
|
||||
|
||||
m_client_port_lbl->Hide();
|
||||
m_connect_port_text->Hide();
|
||||
}
|
||||
|
||||
//server tab
|
||||
{
|
||||
m_host_port_lbl->Hide();
|
||||
m_host_port_text->Hide();
|
||||
m_upnp_chk->Hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_traversal_server_lbl->Hide();
|
||||
m_traversal_server->Hide();
|
||||
|
||||
m_traversal_port_lbl->Hide();
|
||||
m_traversal_port->Hide();
|
||||
// Direct
|
||||
// Client tab
|
||||
{
|
||||
m_ip_lbl->SetLabelText("IP Address :");
|
||||
|
||||
std::string address;
|
||||
netplay_section.Get("Address", &address, "127.0.0.1");
|
||||
m_connect_ip_text->SetLabelText(address);
|
||||
|
||||
m_client_port_lbl->Show();
|
||||
m_connect_port_text->Show();
|
||||
}
|
||||
|
||||
// Server tab
|
||||
m_host_port_lbl->Show();
|
||||
m_host_port_text->Show();
|
||||
m_upnp_chk->Show();
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::OnQuit(wxCommandEvent&)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <wx/frame.h>
|
||||
|
||||
class CGameListCtrl;
|
||||
class wxCheckBox;
|
||||
class wxChoice;
|
||||
class wxListBox;
|
||||
class wxStaticText;
|
||||
class wxTextCtrl;
|
||||
|
||||
class NetPlaySetupFrame final : public wxFrame
|
||||
{
|
||||
public:
|
||||
NetPlaySetupFrame(wxWindow* const parent, const CGameListCtrl* const game_list);
|
||||
~NetPlaySetupFrame();
|
||||
|
||||
private:
|
||||
void OnJoin(wxCommandEvent& event);
|
||||
void OnHost(wxCommandEvent& event);
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnChoice(wxCommandEvent& event);
|
||||
|
||||
void MakeNetPlayDiag(int port, const std::string& game, bool is_hosting);
|
||||
|
||||
wxStaticText* m_ip_lbl;
|
||||
wxStaticText* m_client_port_lbl;
|
||||
wxTextCtrl* m_nickname_text;
|
||||
wxStaticText* m_host_port_lbl;
|
||||
wxTextCtrl* m_host_port_text;
|
||||
wxTextCtrl* m_connect_port_text;
|
||||
wxTextCtrl* m_connect_ip_text;
|
||||
wxChoice* m_direct_traversal;
|
||||
wxStaticText* m_traversal_server_lbl;
|
||||
wxTextCtrl* m_traversal_server;
|
||||
wxStaticText* m_traversal_port_lbl;
|
||||
wxTextCtrl* m_traversal_port;
|
||||
|
||||
wxListBox* m_game_lbox;
|
||||
#ifdef USE_UPNP
|
||||
wxCheckBox* m_upnp_chk;
|
||||
#endif
|
||||
|
||||
const CGameListCtrl* const m_game_list;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,13 +6,12 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/frame.h>
|
||||
|
||||
#include "Common/FifoQueue.h"
|
||||
#include "Core/NetPlayClient.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "Core/NetPlayServer.h"
|
||||
|
||||
class CGameListCtrl;
|
||||
class wxButton;
|
||||
@@ -20,8 +19,8 @@ class wxCheckBox;
|
||||
class wxChoice;
|
||||
class wxListBox;
|
||||
class wxString;
|
||||
class wxStaticText;
|
||||
class wxTextCtrl;
|
||||
class wxWindow;
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -30,47 +29,17 @@ enum
|
||||
NP_GUI_EVT_STOP_GAME,
|
||||
};
|
||||
|
||||
class NetPlaySetupDiag : public wxFrame
|
||||
enum
|
||||
{
|
||||
public:
|
||||
NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* const game_list);
|
||||
~NetPlaySetupDiag();
|
||||
private:
|
||||
void OnJoin(wxCommandEvent& event);
|
||||
void OnHost(wxCommandEvent& event);
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
|
||||
void MakeNetPlayDiag(int port, const std::string &game, bool is_hosting);
|
||||
|
||||
void OnChoice(wxCommandEvent& event);
|
||||
|
||||
wxStaticText* m_ip_lbl;
|
||||
wxStaticText* m_client_port_lbl;
|
||||
wxTextCtrl* m_nickname_text;
|
||||
wxStaticText* m_host_port_lbl;
|
||||
wxTextCtrl* m_host_port_text;
|
||||
wxTextCtrl* m_connect_port_text;
|
||||
wxTextCtrl* m_connect_ip_text;
|
||||
wxChoice* m_direct_traversal;
|
||||
wxStaticText* m_traversal_server_lbl;
|
||||
wxTextCtrl* m_traversal_server;
|
||||
wxStaticText* m_traversal_port_lbl;
|
||||
wxTextCtrl* m_traversal_port;
|
||||
|
||||
wxListBox* m_game_lbox;
|
||||
#ifdef USE_UPNP
|
||||
wxCheckBox* m_upnp_chk;
|
||||
#endif
|
||||
|
||||
const CGameListCtrl* const m_game_list;
|
||||
INITIAL_PAD_BUFFER_SIZE = 5
|
||||
};
|
||||
|
||||
class NetPlayDiag : public wxFrame, public NetPlayUI
|
||||
class NetPlayDialog : public wxFrame, public NetPlayUI
|
||||
{
|
||||
public:
|
||||
NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game_list
|
||||
NetPlayDialog(wxWindow* parent, const CGameListCtrl* const game_list
|
||||
, const std::string& game, const bool is_hosting = false);
|
||||
~NetPlayDiag();
|
||||
~NetPlayDialog();
|
||||
|
||||
Common::FifoQueue<std::string> chat_msgs;
|
||||
|
||||
@@ -87,7 +56,10 @@ public:
|
||||
void OnMsgStartGame() override;
|
||||
void OnMsgStopGame() override;
|
||||
|
||||
static NetPlayDiag *&GetInstance() { return npd; };
|
||||
static NetPlayDialog*& GetInstance() { return npd; }
|
||||
static NetPlayClient*& GetNetPlayClient() { return netplay_client; }
|
||||
static NetPlayServer*& GetNetPlayServer() { return netplay_server; }
|
||||
static void FillWithGameNames(wxListBox* game_lbox, const CGameListCtrl& game_list);
|
||||
|
||||
bool IsRecording() override;
|
||||
|
||||
@@ -100,7 +72,7 @@ private:
|
||||
void OnConfigPads(wxCommandEvent& event);
|
||||
void OnKick(wxCommandEvent& event);
|
||||
void OnPlayerSelect(wxCommandEvent& event);
|
||||
void GetNetSettings(NetSettings &settings);
|
||||
void GetNetSettings(NetSettings& settings);
|
||||
std::string FindGame();
|
||||
|
||||
void OnCopyIP(wxCommandEvent&);
|
||||
@@ -128,36 +100,7 @@ private:
|
||||
|
||||
const CGameListCtrl* const m_game_list;
|
||||
|
||||
static NetPlayDiag* npd;
|
||||
static NetPlayDialog* npd;
|
||||
static NetPlayServer* netplay_server;
|
||||
static NetPlayClient* netplay_client;
|
||||
};
|
||||
|
||||
class ChangeGameDiag : public wxDialog
|
||||
{
|
||||
public:
|
||||
ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* const game_list, wxString& game_name);
|
||||
|
||||
private:
|
||||
void OnPick(wxCommandEvent& event);
|
||||
|
||||
wxListBox* m_game_lbox;
|
||||
wxString& m_game_name;
|
||||
};
|
||||
|
||||
class PadMapDiag : public wxDialog
|
||||
{
|
||||
public:
|
||||
PadMapDiag(wxWindow* const parent, PadMapping map[], PadMapping wiimotemap[], std::vector<const Player *>& player_list);
|
||||
|
||||
private:
|
||||
void OnAdjust(wxCommandEvent& event);
|
||||
|
||||
wxChoice* m_map_cbox[8];
|
||||
PadMapping* const m_mapping;
|
||||
PadMapping* const m_wiimapping;
|
||||
std::vector<const Player *>& m_player_list;
|
||||
};
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
void StopGame();
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <wx/choice.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
|
||||
#include "Core/NetPlayClient.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "DolphinWX/NetPlay/PadMapDialog.h"
|
||||
|
||||
PadMapDialog::PadMapDialog(wxWindow* parent, PadMapping map[], PadMapping wiimotemap[], std::vector<const Player*>& player_list)
|
||||
: wxDialog(parent, wxID_ANY, _("Configure Pads"))
|
||||
, m_mapping(map)
|
||||
, m_wiimapping(wiimotemap)
|
||||
, m_player_list(player_list)
|
||||
{
|
||||
wxBoxSizer* const h_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
h_szr->AddSpacer(10);
|
||||
|
||||
wxArrayString player_names;
|
||||
player_names.Add(_("None"));
|
||||
for (auto& player : m_player_list)
|
||||
player_names.Add(player->name);
|
||||
|
||||
for (unsigned int i = 0; i < 4; ++i)
|
||||
{
|
||||
wxBoxSizer* const v_szr = new wxBoxSizer(wxVERTICAL);
|
||||
v_szr->Add(new wxStaticText(this, wxID_ANY, (wxString(_("Pad ")) + (wxChar)('0' + i))),
|
||||
1, wxALIGN_CENTER_HORIZONTAL);
|
||||
|
||||
m_map_cbox[i] = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, player_names);
|
||||
m_map_cbox[i]->Bind(wxEVT_CHOICE, &PadMapDialog::OnAdjust, this);
|
||||
if (m_mapping[i] == -1)
|
||||
{
|
||||
m_map_cbox[i]->Select(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int j = 0; j < m_player_list.size(); j++)
|
||||
{
|
||||
if (m_mapping[i] == m_player_list[j]->pid)
|
||||
m_map_cbox[i]->Select(j + 1);
|
||||
}
|
||||
}
|
||||
|
||||
v_szr->Add(m_map_cbox[i], 1);
|
||||
|
||||
h_szr->Add(v_szr, 1, wxTOP | wxEXPAND, 20);
|
||||
h_szr->AddSpacer(10);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < 4; ++i)
|
||||
{
|
||||
wxBoxSizer* const v_szr = new wxBoxSizer(wxVERTICAL);
|
||||
v_szr->Add(new wxStaticText(this, wxID_ANY, (wxString(_("Wiimote ")) + (wxChar)('0' + i))),
|
||||
1, wxALIGN_CENTER_HORIZONTAL);
|
||||
|
||||
m_map_cbox[i + 4] = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, player_names);
|
||||
m_map_cbox[i + 4]->Bind(wxEVT_CHOICE, &PadMapDialog::OnAdjust, this);
|
||||
if (m_wiimapping[i] == -1)
|
||||
{
|
||||
m_map_cbox[i + 4]->Select(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int j = 0; j < m_player_list.size(); j++)
|
||||
{
|
||||
if (m_wiimapping[i] == m_player_list[j]->pid)
|
||||
m_map_cbox[i + 4]->Select(j + 1);
|
||||
}
|
||||
}
|
||||
|
||||
v_szr->Add(m_map_cbox[i + 4], 1);
|
||||
|
||||
h_szr->Add(v_szr, 1, wxTOP | wxEXPAND, 20);
|
||||
h_szr->AddSpacer(10);
|
||||
}
|
||||
|
||||
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
|
||||
main_szr->Add(h_szr);
|
||||
main_szr->AddSpacer(5);
|
||||
main_szr->Add(CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT, 20);
|
||||
main_szr->AddSpacer(5);
|
||||
SetSizerAndFit(main_szr);
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
void PadMapDialog::OnAdjust(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
{
|
||||
int player_idx = m_map_cbox[i]->GetSelection();
|
||||
if (player_idx > 0)
|
||||
m_mapping[i] = m_player_list[player_idx - 1]->pid;
|
||||
else
|
||||
m_mapping[i] = -1;
|
||||
|
||||
player_idx = m_map_cbox[i + 4]->GetSelection();
|
||||
if (player_idx > 0)
|
||||
m_wiimapping[i] = m_player_list[player_idx - 1]->pid;
|
||||
else
|
||||
m_wiimapping[i] = -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
#include "Core/NetPlayProto.h"
|
||||
|
||||
class Player;
|
||||
class wxChoice;
|
||||
|
||||
class PadMapDialog final : public wxDialog
|
||||
{
|
||||
public:
|
||||
PadMapDialog(wxWindow* parent, PadMapping map[], PadMapping wiimotemap[], std::vector<const Player*>& player_list);
|
||||
|
||||
private:
|
||||
void OnAdjust(wxCommandEvent& event);
|
||||
|
||||
wxChoice* m_map_cbox[8];
|
||||
PadMapping* const m_mapping;
|
||||
PadMapping* const m_wiimapping;
|
||||
std::vector<const Player*>& m_player_list;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user