mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Reformat all the things. Have fun with merge conflicts.
This commit is contained in:
@ -10,31 +10,32 @@
|
||||
#include "DolphinWX/NetPlay/NetWindow.h"
|
||||
|
||||
ChangeGameDialog::ChangeGameDialog(wxWindow* parent, const CGameListCtrl* const game_list)
|
||||
: wxDialog(parent, wxID_ANY, _("Change Game"))
|
||||
: wxDialog(parent, wxID_ANY, _("Change Game"))
|
||||
{
|
||||
m_game_lbox = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_SORT);
|
||||
m_game_lbox->Bind(wxEVT_LISTBOX_DCLICK, &ChangeGameDialog::OnPick, this);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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();
|
||||
SetSizerAndFit(szr);
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
wxString ChangeGameDialog::GetChosenGameName() const
|
||||
{
|
||||
return m_game_name;
|
||||
return m_game_name;
|
||||
}
|
||||
|
||||
void ChangeGameDialog::OnPick(wxCommandEvent& event)
|
||||
{
|
||||
m_game_name = m_game_lbox->GetStringSelection();
|
||||
EndModal(wxID_OK);
|
||||
m_game_name = m_game_lbox->GetStringSelection();
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
@ -12,13 +12,13 @@ class wxListBox;
|
||||
class ChangeGameDialog final : public wxDialog
|
||||
{
|
||||
public:
|
||||
ChangeGameDialog(wxWindow* parent, const CGameListCtrl* const game_list);
|
||||
ChangeGameDialog(wxWindow* parent, const CGameListCtrl* const game_list);
|
||||
|
||||
wxString GetChosenGameName() const;
|
||||
wxString GetChosenGameName() const;
|
||||
|
||||
private:
|
||||
void OnPick(wxCommandEvent& event);
|
||||
void OnPick(wxCommandEvent& event);
|
||||
|
||||
wxListBox* m_game_lbox;
|
||||
wxString m_game_name;
|
||||
wxListBox* m_game_lbox;
|
||||
wxString m_game_name;
|
||||
};
|
||||
|
@ -19,459 +19,472 @@
|
||||
#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"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
||||
static void GetTraversalPort(IniFile::Section& section, std::string* port)
|
||||
{
|
||||
section.Get("TraversalPort", port, "6262");
|
||||
port->erase(std::remove(port->begin(), port->end(), ' '), port->end());
|
||||
if (port->empty())
|
||||
*port = "6262";
|
||||
section.Get("TraversalPort", port, "6262");
|
||||
port->erase(std::remove(port->begin(), port->end(), ' '), port->end());
|
||||
if (port->empty())
|
||||
*port = "6262";
|
||||
}
|
||||
|
||||
static void GetTraversalServer(IniFile::Section& section, std::string* server)
|
||||
{
|
||||
section.Get("TraversalServer", server, "stun.dolphin-emu.org");
|
||||
server->erase(std::remove(server->begin(), server->end(), ' '), server->end());
|
||||
if (server->empty())
|
||||
*server = "stun.dolphin-emu.org";
|
||||
section.Get("TraversalServer", server, "stun.dolphin-emu.org");
|
||||
server->erase(std::remove(server->begin(), server->end(), ' '), server->end());
|
||||
if (server->empty())
|
||||
*server = "stun.dolphin-emu.org";
|
||||
}
|
||||
|
||||
NetPlaySetupFrame::NetPlaySetupFrame(wxWindow* const parent, const CGameListCtrl* const game_list)
|
||||
: wxFrame(parent, wxID_ANY, _("Dolphin NetPlay Setup"))
|
||||
, m_game_list(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");
|
||||
IniFile inifile;
|
||||
inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini");
|
||||
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");
|
||||
|
||||
wxPanel* const panel = new wxPanel(this);
|
||||
wxPanel* const panel = new wxPanel(this);
|
||||
|
||||
// top row
|
||||
wxBoxSizer* const trav_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer* const nick_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
{
|
||||
// Connection Config
|
||||
wxStaticText* const connectiontype_lbl = new wxStaticText(panel, wxID_ANY, _("Connection Type:"), wxDefaultPosition, wxSize(100, -1));
|
||||
// top row
|
||||
wxBoxSizer* const trav_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer* const nick_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
{
|
||||
// Connection Config
|
||||
wxStaticText* const connectiontype_lbl = new wxStaticText(
|
||||
panel, wxID_ANY, _("Connection Type:"), wxDefaultPosition, wxSize(100, -1));
|
||||
|
||||
m_direct_traversal = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(150, -1));
|
||||
m_direct_traversal->Bind(wxEVT_CHOICE, &NetPlaySetupFrame::OnChoice, this);
|
||||
m_direct_traversal->Append(_("Direct Connection"));
|
||||
m_direct_traversal->Append(_("Traversal Server"));
|
||||
m_direct_traversal = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(150, -1));
|
||||
m_direct_traversal->Bind(wxEVT_CHOICE, &NetPlaySetupFrame::OnChoice, this);
|
||||
m_direct_traversal->Append(_("Direct Connection"));
|
||||
m_direct_traversal->Append(_("Traversal Server"));
|
||||
|
||||
trav_szr->Add(connectiontype_lbl, 0, wxCENTER, 5);
|
||||
trav_szr->AddSpacer(5);
|
||||
trav_szr->Add(m_direct_traversal, 0, wxCENTER, 5);
|
||||
trav_szr->Add(connectiontype_lbl, 0, wxCENTER, 5);
|
||||
trav_szr->AddSpacer(5);
|
||||
trav_szr->Add(m_direct_traversal, 0, wxCENTER, 5);
|
||||
|
||||
m_trav_reset_btn = new wxButton(panel, wxID_ANY, _("Reset Traversal Settings"), wxDefaultPosition, wxSize(-1, 25));
|
||||
m_trav_reset_btn->Bind(wxEVT_BUTTON, &NetPlaySetupFrame::OnResetTraversal, this);
|
||||
m_trav_reset_btn = new wxButton(panel, wxID_ANY, _("Reset Traversal Settings"),
|
||||
wxDefaultPosition, wxSize(-1, 25));
|
||||
m_trav_reset_btn->Bind(wxEVT_BUTTON, &NetPlaySetupFrame::OnResetTraversal, this);
|
||||
|
||||
trav_szr->AddSpacer(5);
|
||||
trav_szr->AddSpacer(5);
|
||||
|
||||
trav_szr->Add(m_trav_reset_btn, 0, wxRIGHT);
|
||||
trav_szr->Add(m_trav_reset_btn, 0, wxRIGHT);
|
||||
|
||||
// Nickname
|
||||
wxStaticText* const nick_lbl = new wxStaticText(panel, wxID_ANY, _("Nickname:"), wxDefaultPosition, wxSize(100, -1));
|
||||
// Nickname
|
||||
wxStaticText* const nick_lbl =
|
||||
new wxStaticText(panel, wxID_ANY, _("Nickname:"), wxDefaultPosition, wxSize(100, -1));
|
||||
|
||||
std::string nickname;
|
||||
netplay_section.Get("Nickname", &nickname, "Player");
|
||||
std::string nickname;
|
||||
netplay_section.Get("Nickname", &nickname, "Player");
|
||||
|
||||
m_nickname_text = new wxTextCtrl(panel, wxID_ANY, StrToWxStr(nickname), wxDefaultPosition, wxSize(150, -1));
|
||||
m_nickname_text =
|
||||
new wxTextCtrl(panel, wxID_ANY, StrToWxStr(nickname), wxDefaultPosition, wxSize(150, -1));
|
||||
|
||||
nick_szr->Add(nick_lbl, 0, wxCENTER);
|
||||
nick_szr->Add(m_nickname_text, 0, wxALL, 5);
|
||||
nick_szr->Add(nick_lbl, 0, wxCENTER);
|
||||
nick_szr->Add(m_nickname_text, 0, wxALL, 5);
|
||||
|
||||
std::string travChoice;
|
||||
netplay_section.Get("TraversalChoice", &travChoice, "direct");
|
||||
if (travChoice == "traversal")
|
||||
{
|
||||
m_direct_traversal->Select(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_direct_traversal->Select(0);
|
||||
}
|
||||
std::string travChoice;
|
||||
netplay_section.Get("TraversalChoice", &travChoice, "direct");
|
||||
if (travChoice == "traversal")
|
||||
{
|
||||
m_direct_traversal->Select(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_direct_traversal->Select(0);
|
||||
}
|
||||
|
||||
std::string centralPort;
|
||||
GetTraversalPort(netplay_section, ¢ralPort);
|
||||
std::string centralServer;
|
||||
GetTraversalServer(netplay_section, ¢ralServer);
|
||||
std::string centralPort;
|
||||
GetTraversalPort(netplay_section, ¢ralPort);
|
||||
std::string centralServer;
|
||||
GetTraversalServer(netplay_section, ¢ralServer);
|
||||
|
||||
m_traversal_lbl = new wxStaticText(panel, wxID_ANY, _("Traversal Server:") + " " + centralServer + ":" + centralPort);
|
||||
}
|
||||
// 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"));
|
||||
m_traversal_lbl = new wxStaticText(panel, wxID_ANY, _("Traversal Server:") + " " +
|
||||
centralServer + ":" + centralPort);
|
||||
}
|
||||
// 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 :"));
|
||||
// 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));
|
||||
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 :"));
|
||||
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));
|
||||
// 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);
|
||||
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"
|
||||
"All players must use the same Dolphin version.\n"
|
||||
"All memory cards, SD cards and cheats must be identical between players or disabled.\n"
|
||||
"If DSP LLE is used, DSP ROMs must be identical between players.\n"
|
||||
"If connecting directly, the host must have the chosen UDP port open/forwarded!\n"
|
||||
"\n"
|
||||
"Wiimote support is broken in netplay and therefore disabled.\n"));
|
||||
wxStaticText* const alert_lbl = new wxStaticText(
|
||||
connect_tab, wxID_ANY,
|
||||
_("ALERT:\n\n"
|
||||
"All players must use the same Dolphin version.\n"
|
||||
"All memory cards, SD cards and cheats must be identical between players or disabled.\n"
|
||||
"If DSP LLE is used, DSP ROMs must be identical between players.\n"
|
||||
"If connecting directly, the host must have the chosen UDP port open/forwarded!\n"
|
||||
"\n"
|
||||
"Wiimote support is broken in netplay and therefore disabled.\n"));
|
||||
|
||||
wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
connect_tab->SetSizerAndFit(con_szr);
|
||||
}
|
||||
|
||||
// host tab
|
||||
{
|
||||
m_host_port_lbl = new wxStaticText(host_tab, wxID_ANY, _("Port :"));
|
||||
// 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));
|
||||
// string? w/e
|
||||
std::string port;
|
||||
netplay_section.Get("HostPort", &port, "2626");
|
||||
m_host_port_text = new wxTextCtrl(host_tab, wxID_ANY, StrToWxStr(port));
|
||||
|
||||
m_traversal_listen_port_enabled = new wxCheckBox(host_tab, wxID_ANY, _("Force Listen Port: "));
|
||||
m_traversal_listen_port = new wxSpinCtrl(host_tab, wxID_ANY, "", wxDefaultPosition, wxSize(80, -1), wxSP_ARROW_KEYS, 1, 65535);
|
||||
m_traversal_listen_port_enabled = new wxCheckBox(host_tab, wxID_ANY, _("Force Listen Port: "));
|
||||
m_traversal_listen_port = new wxSpinCtrl(host_tab, wxID_ANY, "", wxDefaultPosition,
|
||||
wxSize(80, -1), wxSP_ARROW_KEYS, 1, 65535);
|
||||
|
||||
unsigned int listen_port;
|
||||
netplay_section.Get("ListenPort", &listen_port, 0);
|
||||
m_traversal_listen_port_enabled->SetValue(listen_port != 0);
|
||||
m_traversal_listen_port->Enable(m_traversal_listen_port_enabled->IsChecked());
|
||||
m_traversal_listen_port->SetValue(listen_port);
|
||||
unsigned int listen_port;
|
||||
netplay_section.Get("ListenPort", &listen_port, 0);
|
||||
m_traversal_listen_port_enabled->SetValue(listen_port != 0);
|
||||
m_traversal_listen_port->Enable(m_traversal_listen_port_enabled->IsChecked());
|
||||
m_traversal_listen_port->SetValue(listen_port);
|
||||
|
||||
m_traversal_listen_port_enabled->Bind(wxEVT_CHECKBOX, &NetPlaySetupFrame::OnTraversalListenPortChanged, this);
|
||||
m_traversal_listen_port->Bind(wxEVT_TEXT, &NetPlaySetupFrame::OnTraversalListenPortChanged, this);
|
||||
m_traversal_listen_port_enabled->Bind(wxEVT_CHECKBOX,
|
||||
&NetPlaySetupFrame::OnTraversalListenPortChanged, this);
|
||||
m_traversal_listen_port->Bind(wxEVT_TEXT, &NetPlaySetupFrame::OnTraversalListenPortChanged,
|
||||
this);
|
||||
|
||||
wxButton* const host_btn = new wxButton(host_tab, wxID_ANY, _("Host"));
|
||||
host_btn->Bind(wxEVT_BUTTON, &NetPlaySetupFrame::OnHost, this);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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 bottom_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
bottom_szr->Add(m_traversal_listen_port_enabled, 0, wxCENTER | wxLEFT, 5);
|
||||
bottom_szr->Add(m_traversal_listen_port, 0, wxCENTER, 0);
|
||||
wxBoxSizer* const host_btn_szr = new wxBoxSizer(wxVERTICAL);
|
||||
host_btn_szr->Add(host_btn, 0, wxCENTER | wxALIGN_RIGHT, 0);
|
||||
bottom_szr->Add(host_btn_szr, 1, wxALL, 5);
|
||||
wxBoxSizer* const bottom_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
bottom_szr->Add(m_traversal_listen_port_enabled, 0, wxCENTER | wxLEFT, 5);
|
||||
bottom_szr->Add(m_traversal_listen_port, 0, wxCENTER, 0);
|
||||
wxBoxSizer* const host_btn_szr = new wxBoxSizer(wxVERTICAL);
|
||||
host_btn_szr->Add(host_btn, 0, wxCENTER | wxALIGN_RIGHT, 0);
|
||||
bottom_szr->Add(host_btn_szr, 1, wxALL, 5);
|
||||
|
||||
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(bottom_szr, 0, wxEXPAND, 0);
|
||||
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(bottom_szr, 0, wxEXPAND, 0);
|
||||
|
||||
host_tab->SetSizerAndFit(host_szr);
|
||||
}
|
||||
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);
|
||||
// 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, 5);
|
||||
main_szr->Add(nick_szr, 0, wxALL | wxALIGN_LEFT, 5);
|
||||
main_szr->Add(m_traversal_lbl, 0, wxALL | wxALIGN_LEFT, 5);
|
||||
main_szr->Add(notebook, 1, wxLEFT | wxRIGHT | wxEXPAND, 5);
|
||||
main_szr->Add(quit_btn, 0, wxALL | wxALIGN_RIGHT, 5);
|
||||
// main sizer
|
||||
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
|
||||
main_szr->Add(trav_szr, 0, wxALL | wxALIGN_LEFT, 5);
|
||||
main_szr->Add(nick_szr, 0, wxALL | wxALIGN_LEFT, 5);
|
||||
main_szr->Add(m_traversal_lbl, 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);
|
||||
panel->SetSizerAndFit(main_szr);
|
||||
|
||||
//wxBoxSizer* const diag_szr = new wxBoxSizer(wxVERTICAL);
|
||||
//diag_szr->Add(panel, 1, wxEXPAND);
|
||||
//SetSizerAndFit(diag_szr);
|
||||
// wxBoxSizer* const diag_szr = new wxBoxSizer(wxVERTICAL);
|
||||
// diag_szr->Add(panel, 1, wxEXPAND);
|
||||
// SetSizerAndFit(diag_szr);
|
||||
|
||||
main_szr->SetSizeHints(this);
|
||||
main_szr->SetSizeHints(this);
|
||||
|
||||
Center();
|
||||
Show();
|
||||
Center();
|
||||
Show();
|
||||
|
||||
// Needs to be done last or it set up the spacing on the page correctly
|
||||
wxCommandEvent ev;
|
||||
OnChoice(ev);
|
||||
// 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");
|
||||
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);
|
||||
}
|
||||
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("Nickname", WxStrToStr(m_nickname_text->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()));
|
||||
netplay_section.Set("ListenPort",
|
||||
m_traversal_listen_port_enabled->IsChecked() ? m_traversal_listen_port->GetValue() : 0);
|
||||
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()));
|
||||
netplay_section.Set("ListenPort", m_traversal_listen_port_enabled->IsChecked() ?
|
||||
m_traversal_listen_port->GetValue() :
|
||||
0);
|
||||
|
||||
inifile.Save(dolphin_ini);
|
||||
main_frame->g_NetPlaySetupDiag = nullptr;
|
||||
inifile.Save(dolphin_ini);
|
||||
main_frame->g_NetPlaySetupDiag = nullptr;
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::MakeNetPlayDiag(int port, const std::string &game, bool is_hosting)
|
||||
void NetPlaySetupFrame::MakeNetPlayDiag(int port, const std::string& game, bool is_hosting)
|
||||
{
|
||||
NetPlayDialog*& npd = NetPlayDialog::GetInstance();
|
||||
NetPlayClient*& netplay_client = NetPlayDialog::GetNetPlayClient();
|
||||
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());
|
||||
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;
|
||||
bool trav;
|
||||
if (!is_hosting && m_direct_traversal->GetCurrentSelection() == 1)
|
||||
trav = true;
|
||||
else
|
||||
trav = false;
|
||||
|
||||
IniFile inifile;
|
||||
inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini");
|
||||
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");
|
||||
IniFile inifile;
|
||||
inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini");
|
||||
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");
|
||||
|
||||
std::string centralPortString;
|
||||
GetTraversalPort(netplay_section, ¢ralPortString);
|
||||
unsigned long int centralPort;
|
||||
StrToWxStr(centralPortString).ToULong(¢ralPort);
|
||||
std::string centralPortString;
|
||||
GetTraversalPort(netplay_section, ¢ralPortString);
|
||||
unsigned long int centralPort;
|
||||
StrToWxStr(centralPortString).ToULong(¢ralPort);
|
||||
|
||||
std::string centralServer;
|
||||
GetTraversalServer(netplay_section, ¢ralServer);
|
||||
std::string centralServer;
|
||||
GetTraversalServer(netplay_section, ¢ralServer);
|
||||
|
||||
netplay_client = new NetPlayClient(ip, (u16)port, npd, WxStrToStr(m_nickname_text->GetValue()), trav, centralServer, (u16) centralPort);
|
||||
if (netplay_client->IsConnected())
|
||||
{
|
||||
npd->Show();
|
||||
Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
npd->Destroy();
|
||||
}
|
||||
netplay_client = new NetPlayClient(ip, (u16)port, npd, WxStrToStr(m_nickname_text->GetValue()),
|
||||
trav, centralServer, (u16)centralPort);
|
||||
if (netplay_client->IsConnected())
|
||||
{
|
||||
npd->Show();
|
||||
Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
npd->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::OnHost(wxCommandEvent&)
|
||||
{
|
||||
NetPlayDialog*& npd = NetPlayDialog::GetInstance();
|
||||
NetPlayServer*& netplay_server = NetPlayDialog::GetNetPlayServer();
|
||||
NetPlayDialog*& npd = NetPlayDialog::GetInstance();
|
||||
NetPlayServer*& netplay_server = NetPlayDialog::GetNetPlayServer();
|
||||
|
||||
if (npd)
|
||||
{
|
||||
WxUtils::ShowErrorDialog(_("A NetPlay window is already open!"));
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (m_game_lbox->GetSelection() == wxNOT_FOUND)
|
||||
{
|
||||
WxUtils::ShowErrorDialog(_("You must choose a game!"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string game(WxStrToStr(m_game_lbox->GetStringSelection()));
|
||||
std::string game(WxStrToStr(m_game_lbox->GetStringSelection()));
|
||||
|
||||
bool trav;
|
||||
unsigned long listen_port = 0;
|
||||
if (m_direct_traversal->GetCurrentSelection() == 1)
|
||||
{
|
||||
trav = true;
|
||||
listen_port = m_traversal_listen_port_enabled->IsChecked() ? m_traversal_listen_port->GetValue() : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
trav = false;
|
||||
m_host_port_text->GetValue().ToULong(&listen_port);
|
||||
}
|
||||
bool trav;
|
||||
unsigned long listen_port = 0;
|
||||
if (m_direct_traversal->GetCurrentSelection() == 1)
|
||||
{
|
||||
trav = true;
|
||||
listen_port =
|
||||
m_traversal_listen_port_enabled->IsChecked() ? m_traversal_listen_port->GetValue() : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
trav = false;
|
||||
m_host_port_text->GetValue().ToULong(&listen_port);
|
||||
}
|
||||
|
||||
IniFile inifile;
|
||||
inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini");
|
||||
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");
|
||||
IniFile inifile;
|
||||
inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini");
|
||||
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");
|
||||
|
||||
std::string centralPortString;
|
||||
GetTraversalPort(netplay_section, ¢ralPortString);
|
||||
unsigned long int centralPort;
|
||||
StrToWxStr(centralPortString).ToULong(¢ralPort);
|
||||
std::string centralPortString;
|
||||
GetTraversalPort(netplay_section, ¢ralPortString);
|
||||
unsigned long int centralPort;
|
||||
StrToWxStr(centralPortString).ToULong(¢ralPort);
|
||||
|
||||
std::string centralServer;
|
||||
GetTraversalServer(netplay_section, ¢ralServer);
|
||||
std::string centralServer;
|
||||
GetTraversalServer(netplay_section, ¢ralServer);
|
||||
|
||||
netplay_server = new NetPlayServer((u16)listen_port, trav, centralServer, (u16) centralPort);
|
||||
if (netplay_server->is_connected)
|
||||
{
|
||||
netplay_server->ChangeGame(game);
|
||||
netplay_server->AdjustPadBufferSize(INITIAL_PAD_BUFFER_SIZE);
|
||||
netplay_server = new NetPlayServer((u16)listen_port, trav, centralServer, (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(listen_port);
|
||||
if (m_upnp_chk->GetValue())
|
||||
netplay_server->TryPortmapping(listen_port);
|
||||
#endif
|
||||
MakeNetPlayDiag(netplay_server->GetPort(), game, true);
|
||||
netplay_server->SetNetPlayUI(NetPlayDialog::GetInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (trav && m_traversal_listen_port_enabled->IsChecked())
|
||||
WxUtils::ShowErrorDialog(
|
||||
_("Failed to listen. Someone is probably already listening on the port you specified."));
|
||||
else
|
||||
WxUtils::ShowErrorDialog(_("Failed to listen. Is another instance of the NetPlay server running?"));
|
||||
}
|
||||
MakeNetPlayDiag(netplay_server->GetPort(), game, true);
|
||||
netplay_server->SetNetPlayUI(NetPlayDialog::GetInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (trav && m_traversal_listen_port_enabled->IsChecked())
|
||||
WxUtils::ShowErrorDialog(
|
||||
_("Failed to listen. Someone is probably already listening on the port you specified."));
|
||||
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;
|
||||
}
|
||||
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);
|
||||
unsigned long port = 0;
|
||||
m_connect_port_text->GetValue().ToULong(&port);
|
||||
MakeNetPlayDiag(port, "", false);
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::OnResetTraversal(wxCommandEvent& event)
|
||||
{
|
||||
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");
|
||||
netplay_section.Set("TraversalServer", (std::string) "stun.dolphin-emu.org");
|
||||
netplay_section.Set("TraversalPort", (std::string) "6262");
|
||||
inifile.Save(dolphin_ini);
|
||||
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");
|
||||
netplay_section.Set("TraversalServer", (std::string) "stun.dolphin-emu.org");
|
||||
netplay_section.Set("TraversalPort", (std::string) "6262");
|
||||
inifile.Save(dolphin_ini);
|
||||
|
||||
m_traversal_lbl->SetLabelText(_("Traversal: ") + "stun.dolphin-emu.org:6262");
|
||||
m_traversal_lbl->SetLabelText(_("Traversal: ") + "stun.dolphin-emu.org:6262");
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::OnTraversalListenPortChanged(wxCommandEvent& event)
|
||||
{
|
||||
m_traversal_listen_port->Enable(m_traversal_listen_port_enabled->IsChecked());
|
||||
m_traversal_listen_port->Enable(m_traversal_listen_port_enabled->IsChecked());
|
||||
}
|
||||
|
||||
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");
|
||||
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_lbl->Show();
|
||||
m_trav_reset_btn->Show();
|
||||
//Traversal
|
||||
//client tab
|
||||
{
|
||||
m_ip_lbl->SetLabelText("Host Code: ");
|
||||
if (sel == 1)
|
||||
{
|
||||
m_traversal_lbl->Show();
|
||||
m_trav_reset_btn->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);
|
||||
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();
|
||||
}
|
||||
m_client_port_lbl->Hide();
|
||||
m_connect_port_text->Hide();
|
||||
}
|
||||
|
||||
//server tab
|
||||
{
|
||||
m_host_port_lbl->Hide();
|
||||
m_host_port_text->Hide();
|
||||
m_traversal_listen_port->Show();
|
||||
m_traversal_listen_port_enabled->Show();
|
||||
// server tab
|
||||
{
|
||||
m_host_port_lbl->Hide();
|
||||
m_host_port_text->Hide();
|
||||
m_traversal_listen_port->Show();
|
||||
m_traversal_listen_port_enabled->Show();
|
||||
#ifdef USE_UPNP
|
||||
m_upnp_chk->Hide();
|
||||
m_upnp_chk->Hide();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_traversal_lbl->Hide();
|
||||
m_trav_reset_btn->Hide();
|
||||
// Direct
|
||||
// Client tab
|
||||
{
|
||||
m_ip_lbl->SetLabelText("IP Address :");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_traversal_lbl->Hide();
|
||||
m_trav_reset_btn->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);
|
||||
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();
|
||||
}
|
||||
m_client_port_lbl->Show();
|
||||
m_connect_port_text->Show();
|
||||
}
|
||||
|
||||
// Server tab
|
||||
m_traversal_listen_port->Hide();
|
||||
m_traversal_listen_port_enabled->Hide();
|
||||
m_host_port_lbl->Show();
|
||||
m_host_port_text->Show();
|
||||
// Server tab
|
||||
m_traversal_listen_port->Hide();
|
||||
m_traversal_listen_port_enabled->Hide();
|
||||
m_host_port_lbl->Show();
|
||||
m_host_port_text->Show();
|
||||
#ifdef USE_UPNP
|
||||
m_upnp_chk->Show();
|
||||
m_upnp_chk->Show();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlaySetupFrame::OnQuit(wxCommandEvent&)
|
||||
{
|
||||
Destroy();
|
||||
Destroy();
|
||||
}
|
||||
|
@ -19,36 +19,36 @@ class wxTextCtrl;
|
||||
class NetPlaySetupFrame final : public wxFrame
|
||||
{
|
||||
public:
|
||||
NetPlaySetupFrame(wxWindow* const parent, const CGameListCtrl* const game_list);
|
||||
~NetPlaySetupFrame();
|
||||
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 OnResetTraversal(wxCommandEvent& event);
|
||||
void OnTraversalListenPortChanged(wxCommandEvent& event);
|
||||
void OnJoin(wxCommandEvent& event);
|
||||
void OnHost(wxCommandEvent& event);
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnChoice(wxCommandEvent& event);
|
||||
void OnResetTraversal(wxCommandEvent& event);
|
||||
void OnTraversalListenPortChanged(wxCommandEvent& event);
|
||||
|
||||
void MakeNetPlayDiag(int port, const std::string& game, bool is_hosting);
|
||||
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_lbl;
|
||||
wxButton* m_trav_reset_btn;
|
||||
wxCheckBox* m_traversal_listen_port_enabled;
|
||||
wxSpinCtrl* m_traversal_listen_port;
|
||||
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_lbl;
|
||||
wxButton* m_trav_reset_btn;
|
||||
wxCheckBox* m_traversal_listen_port_enabled;
|
||||
wxSpinCtrl* m_traversal_listen_port;
|
||||
|
||||
wxListBox* m_game_lbox;
|
||||
wxListBox* m_game_lbox;
|
||||
#ifdef USE_UPNP
|
||||
wxCheckBox* m_upnp_chk;
|
||||
wxCheckBox* m_upnp_chk;
|
||||
#endif
|
||||
|
||||
const CGameListCtrl* const m_game_list;
|
||||
const CGameListCtrl* const m_game_list;
|
||||
};
|
||||
|
@ -29,574 +29,572 @@
|
||||
#include "Common/IniFile.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/EXI_Device.h"
|
||||
#include "Core/NetPlayClient.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "Core/NetPlayServer.h"
|
||||
#include "Core/HW/EXI_Device.h"
|
||||
|
||||
#include "DolphinWX/Frame.h"
|
||||
#include "DolphinWX/GameListCtrl.h"
|
||||
#include "DolphinWX/ISOFile.h"
|
||||
#include "DolphinWX/Main.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
#include "DolphinWX/NetPlay/ChangeGameDialog.h"
|
||||
#include "DolphinWX/NetPlay/NetWindow.h"
|
||||
#include "DolphinWX/NetPlay/PadMapDialog.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
||||
NetPlayServer* NetPlayDialog::netplay_server = nullptr;
|
||||
NetPlayClient* NetPlayDialog::netplay_client = nullptr;
|
||||
NetPlayDialog *NetPlayDialog::npd = nullptr;
|
||||
NetPlayDialog* NetPlayDialog::npd = nullptr;
|
||||
|
||||
static wxString FailureReasonStringForHostLabel(int reason)
|
||||
{
|
||||
switch (reason)
|
||||
{
|
||||
case TraversalClient::BadHost:
|
||||
return _("(Error: Bad host)");
|
||||
case TraversalClient::VersionTooOld:
|
||||
return _("(Error: Dolphin too old)");
|
||||
case TraversalClient::ServerForgotAboutUs:
|
||||
return _("(Error: Disconnected)");
|
||||
case TraversalClient::SocketSendError:
|
||||
return _("(Error: Socket)");
|
||||
case TraversalClient::ResendTimeout:
|
||||
return _("(Error: Timeout)");
|
||||
default:
|
||||
return _("(Error: Unknown)");
|
||||
}
|
||||
switch (reason)
|
||||
{
|
||||
case TraversalClient::BadHost:
|
||||
return _("(Error: Bad host)");
|
||||
case TraversalClient::VersionTooOld:
|
||||
return _("(Error: Dolphin too old)");
|
||||
case TraversalClient::ServerForgotAboutUs:
|
||||
return _("(Error: Disconnected)");
|
||||
case TraversalClient::SocketSendError:
|
||||
return _("(Error: Socket)");
|
||||
case TraversalClient::ResendTimeout:
|
||||
return _("(Error: Timeout)");
|
||||
default:
|
||||
return _("(Error: Unknown)");
|
||||
}
|
||||
}
|
||||
|
||||
static std::string BuildGameName(const GameListItem& game)
|
||||
{
|
||||
// Lang needs to be consistent
|
||||
DiscIO::IVolume::ELanguage const lang = DiscIO::IVolume::LANGUAGE_ENGLISH;
|
||||
std::vector<std::string> info;
|
||||
if (!game.GetUniqueID().empty())
|
||||
info.push_back(game.GetUniqueID());
|
||||
if (game.GetRevision() != 0)
|
||||
{
|
||||
std::string rev_str = "Revision ";
|
||||
info.push_back(rev_str + std::to_string((long long)game.GetRevision()));
|
||||
}
|
||||
// Lang needs to be consistent
|
||||
DiscIO::IVolume::ELanguage const lang = DiscIO::IVolume::LANGUAGE_ENGLISH;
|
||||
std::vector<std::string> info;
|
||||
if (!game.GetUniqueID().empty())
|
||||
info.push_back(game.GetUniqueID());
|
||||
if (game.GetRevision() != 0)
|
||||
{
|
||||
std::string rev_str = "Revision ";
|
||||
info.push_back(rev_str + std::to_string((long long)game.GetRevision()));
|
||||
}
|
||||
|
||||
std::string name(game.GetName(lang));
|
||||
if (name.empty())
|
||||
name = game.GetName();
|
||||
std::string name(game.GetName(lang));
|
||||
if (name.empty())
|
||||
name = game.GetName();
|
||||
|
||||
int disc_number = game.GetDiscNumber() + 1;
|
||||
int disc_number = game.GetDiscNumber() + 1;
|
||||
|
||||
std::string lower_name = name;
|
||||
std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower);
|
||||
if (disc_number > 1 &&
|
||||
lower_name.find(std::string(wxString::Format("disc %i", disc_number))) == std::string::npos &&
|
||||
lower_name.find(std::string(wxString::Format("disc%i", disc_number))) == std::string::npos)
|
||||
{
|
||||
std::string disc_text = "Disc ";
|
||||
info.push_back(disc_text + std::to_string(disc_number));
|
||||
}
|
||||
if (info.empty())
|
||||
return name;
|
||||
std::ostringstream ss;
|
||||
std::copy(info.begin(), info.end() -1, std::ostream_iterator<std::string>(ss, ", "));
|
||||
ss << info.back();
|
||||
return name + " (" + ss.str() + ")";
|
||||
std::string lower_name = name;
|
||||
std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower);
|
||||
if (disc_number > 1 &&
|
||||
lower_name.find(std::string(wxString::Format("disc %i", disc_number))) == std::string::npos &&
|
||||
lower_name.find(std::string(wxString::Format("disc%i", disc_number))) == std::string::npos)
|
||||
{
|
||||
std::string disc_text = "Disc ";
|
||||
info.push_back(disc_text + std::to_string(disc_number));
|
||||
}
|
||||
if (info.empty())
|
||||
return name;
|
||||
std::ostringstream ss;
|
||||
std::copy(info.begin(), info.end() - 1, std::ostream_iterator<std::string>(ss, ", "));
|
||||
ss << info.back();
|
||||
return name + " (" + ss.str() + ")";
|
||||
}
|
||||
|
||||
void NetPlayDialog::FillWithGameNames(wxListBox* game_lbox, const CGameListCtrl& game_list)
|
||||
{
|
||||
for (u32 i = 0; auto game = game_list.GetISO(i); ++i)
|
||||
game_lbox->Append(StrToWxStr(BuildGameName(*game)));
|
||||
for (u32 i = 0; auto game = game_list.GetISO(i); ++i)
|
||||
game_lbox->Append(StrToWxStr(BuildGameName(*game)));
|
||||
}
|
||||
|
||||
NetPlayDialog::NetPlayDialog(wxWindow* const parent, const CGameListCtrl* const game_list,
|
||||
const std::string& game, const bool is_hosting)
|
||||
: wxFrame(parent, wxID_ANY, _("Dolphin NetPlay"))
|
||||
, m_selected_game(game)
|
||||
, m_start_btn(nullptr)
|
||||
, m_host_label(nullptr)
|
||||
, m_host_type_choice(nullptr)
|
||||
, m_host_copy_btn(nullptr)
|
||||
, m_host_copy_btn_is_retry(false)
|
||||
, m_is_hosting(is_hosting)
|
||||
, m_game_list(game_list)
|
||||
const std::string& game, const bool is_hosting)
|
||||
: wxFrame(parent, wxID_ANY, _("Dolphin NetPlay")), m_selected_game(game), m_start_btn(nullptr),
|
||||
m_host_label(nullptr), m_host_type_choice(nullptr), m_host_copy_btn(nullptr),
|
||||
m_host_copy_btn_is_retry(false), m_is_hosting(is_hosting), m_game_list(game_list)
|
||||
{
|
||||
Bind(wxEVT_THREAD, &NetPlayDialog::OnThread, this);
|
||||
Bind(wxEVT_THREAD, &NetPlayDialog::OnThread, this);
|
||||
|
||||
wxPanel* const panel = new wxPanel(this);
|
||||
wxPanel* const panel = new wxPanel(this);
|
||||
|
||||
// top crap
|
||||
m_game_btn = new wxButton(panel, wxID_ANY,
|
||||
StrToWxStr(m_selected_game).Prepend(_(" Game : ")),
|
||||
wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
|
||||
// top crap
|
||||
m_game_btn = new wxButton(panel, wxID_ANY, StrToWxStr(m_selected_game).Prepend(_(" Game : ")),
|
||||
wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
|
||||
|
||||
if (m_is_hosting)
|
||||
m_game_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnChangeGame, this);
|
||||
else
|
||||
m_game_btn->Disable();
|
||||
if (m_is_hosting)
|
||||
m_game_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnChangeGame, this);
|
||||
else
|
||||
m_game_btn->Disable();
|
||||
|
||||
// middle crap
|
||||
// middle crap
|
||||
|
||||
// chat
|
||||
m_chat_text = new wxTextCtrl(panel, wxID_ANY, wxEmptyString
|
||||
, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_MULTILINE);
|
||||
// chat
|
||||
m_chat_text = new wxTextCtrl(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_READONLY | wxTE_MULTILINE);
|
||||
|
||||
m_chat_msg_text = new wxTextCtrl(panel, wxID_ANY, wxEmptyString
|
||||
, wxDefaultPosition, wxSize(-1, 25), wxTE_PROCESS_ENTER);
|
||||
m_chat_msg_text->Bind(wxEVT_TEXT_ENTER, &NetPlayDialog::OnChat, this);
|
||||
m_chat_msg_text->SetMaxLength(2000);
|
||||
m_chat_msg_text = new wxTextCtrl(panel, wxID_ANY, wxEmptyString, wxDefaultPosition,
|
||||
wxSize(-1, 25), wxTE_PROCESS_ENTER);
|
||||
m_chat_msg_text->Bind(wxEVT_TEXT_ENTER, &NetPlayDialog::OnChat, this);
|
||||
m_chat_msg_text->SetMaxLength(2000);
|
||||
|
||||
wxButton* const chat_msg_btn = new wxButton(panel, wxID_ANY, _("Send"), wxDefaultPosition, wxSize(-1, 26));
|
||||
chat_msg_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnChat, this);
|
||||
wxButton* const chat_msg_btn =
|
||||
new wxButton(panel, wxID_ANY, _("Send"), wxDefaultPosition, wxSize(-1, 26));
|
||||
chat_msg_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnChat, this);
|
||||
|
||||
wxBoxSizer* const chat_msg_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
chat_msg_szr->Add(m_chat_msg_text, 1);
|
||||
chat_msg_szr->Add(chat_msg_btn, 0);
|
||||
wxBoxSizer* const chat_msg_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
chat_msg_szr->Add(m_chat_msg_text, 1);
|
||||
chat_msg_szr->Add(chat_msg_btn, 0);
|
||||
|
||||
wxStaticBoxSizer* const chat_szr = new wxStaticBoxSizer(wxVERTICAL, panel, _("Chat"));
|
||||
chat_szr->Add(m_chat_text, 1, wxEXPAND);
|
||||
chat_szr->Add(chat_msg_szr, 0, wxEXPAND | wxTOP, 5);
|
||||
wxStaticBoxSizer* const chat_szr = new wxStaticBoxSizer(wxVERTICAL, panel, _("Chat"));
|
||||
chat_szr->Add(m_chat_text, 1, wxEXPAND);
|
||||
chat_szr->Add(chat_msg_szr, 0, wxEXPAND | wxTOP, 5);
|
||||
|
||||
m_player_lbox = new wxListBox(panel, wxID_ANY, wxDefaultPosition, wxSize(256, -1));
|
||||
m_player_lbox = new wxListBox(panel, wxID_ANY, wxDefaultPosition, wxSize(256, -1));
|
||||
|
||||
wxStaticBoxSizer* const player_szr = new wxStaticBoxSizer(wxVERTICAL, panel, _("Players"));
|
||||
wxStaticBoxSizer* const player_szr = new wxStaticBoxSizer(wxVERTICAL, panel, _("Players"));
|
||||
|
||||
// player list
|
||||
if (m_is_hosting && g_TraversalClient)
|
||||
{
|
||||
wxBoxSizer* const host_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_host_type_choice = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(76, -1));
|
||||
m_host_type_choice->Bind(wxEVT_CHOICE, &NetPlayDialog::OnChoice, this);
|
||||
m_host_type_choice->Append(_("Room ID:"));
|
||||
host_szr->Add(m_host_type_choice);
|
||||
// player list
|
||||
if (m_is_hosting && g_TraversalClient)
|
||||
{
|
||||
wxBoxSizer* const host_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_host_type_choice = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(76, -1));
|
||||
m_host_type_choice->Bind(wxEVT_CHOICE, &NetPlayDialog::OnChoice, this);
|
||||
m_host_type_choice->Append(_("Room ID:"));
|
||||
host_szr->Add(m_host_type_choice);
|
||||
|
||||
m_host_label = new wxStaticText(panel, wxID_ANY, "555.555.555.555:55555", wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE | wxALIGN_LEFT);
|
||||
// Update() should fix this immediately.
|
||||
m_host_label->SetLabel("");
|
||||
host_szr->Add(m_host_label, 1, wxLEFT | wxCENTER, 5);
|
||||
m_host_label = new wxStaticText(panel, wxID_ANY, "555.555.555.555:55555", wxDefaultPosition,
|
||||
wxDefaultSize, wxST_NO_AUTORESIZE | wxALIGN_LEFT);
|
||||
// Update() should fix this immediately.
|
||||
m_host_label->SetLabel("");
|
||||
host_szr->Add(m_host_label, 1, wxLEFT | wxCENTER, 5);
|
||||
|
||||
m_host_copy_btn = new wxButton(panel, wxID_ANY, _("Copy"));
|
||||
m_host_copy_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnCopyIP, this);
|
||||
m_host_copy_btn->Disable();
|
||||
host_szr->Add(m_host_copy_btn, 0, wxLEFT | wxCENTER, 5);
|
||||
player_szr->Add(host_szr, 0, wxEXPAND | wxBOTTOM, 5);
|
||||
m_host_type_choice->Select(0);
|
||||
m_host_copy_btn = new wxButton(panel, wxID_ANY, _("Copy"));
|
||||
m_host_copy_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnCopyIP, this);
|
||||
m_host_copy_btn->Disable();
|
||||
host_szr->Add(m_host_copy_btn, 0, wxLEFT | wxCENTER, 5);
|
||||
player_szr->Add(host_szr, 0, wxEXPAND | wxBOTTOM, 5);
|
||||
m_host_type_choice->Select(0);
|
||||
|
||||
UpdateHostLabel();
|
||||
}
|
||||
UpdateHostLabel();
|
||||
}
|
||||
|
||||
player_szr->Add(m_player_lbox, 1, wxEXPAND);
|
||||
player_szr->Add(m_player_lbox, 1, wxEXPAND);
|
||||
|
||||
if (m_is_hosting)
|
||||
{
|
||||
m_player_lbox->Bind(wxEVT_LISTBOX, &NetPlayDialog::OnPlayerSelect, this);
|
||||
m_kick_btn = new wxButton(panel, wxID_ANY, _("Kick Player"));
|
||||
m_kick_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnKick, this);
|
||||
player_szr->Add(m_kick_btn, 0, wxEXPAND | wxTOP, 5);
|
||||
m_kick_btn->Disable();
|
||||
if (m_is_hosting)
|
||||
{
|
||||
m_player_lbox->Bind(wxEVT_LISTBOX, &NetPlayDialog::OnPlayerSelect, this);
|
||||
m_kick_btn = new wxButton(panel, wxID_ANY, _("Kick Player"));
|
||||
m_kick_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnKick, this);
|
||||
player_szr->Add(m_kick_btn, 0, wxEXPAND | wxTOP, 5);
|
||||
m_kick_btn->Disable();
|
||||
|
||||
m_player_config_btn = new wxButton(panel, wxID_ANY, _("Assign Controller Ports"));
|
||||
m_player_config_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnAssignPads, this);
|
||||
player_szr->Add(m_player_config_btn, 0, wxEXPAND | wxTOP, 5);
|
||||
}
|
||||
m_player_config_btn = new wxButton(panel, wxID_ANY, _("Assign Controller Ports"));
|
||||
m_player_config_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnAssignPads, this);
|
||||
player_szr->Add(m_player_config_btn, 0, wxEXPAND | wxTOP, 5);
|
||||
}
|
||||
|
||||
wxBoxSizer* const mid_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
mid_szr->Add(chat_szr, 1, wxEXPAND | wxRIGHT, 5);
|
||||
mid_szr->Add(player_szr, 0, wxEXPAND);
|
||||
wxBoxSizer* const mid_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
mid_szr->Add(chat_szr, 1, wxEXPAND | wxRIGHT, 5);
|
||||
mid_szr->Add(player_szr, 0, wxEXPAND);
|
||||
|
||||
// bottom crap
|
||||
wxButton* const quit_btn = new wxButton(panel, wxID_ANY, _("Quit Netplay"));
|
||||
quit_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnQuit, this);
|
||||
// bottom crap
|
||||
wxButton* const quit_btn = new wxButton(panel, wxID_ANY, _("Quit Netplay"));
|
||||
quit_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnQuit, this);
|
||||
|
||||
wxBoxSizer* const bottom_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
if (is_hosting)
|
||||
{
|
||||
m_start_btn = new wxButton(panel, wxID_ANY, _("Start"));
|
||||
m_start_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnStart, this);
|
||||
bottom_szr->Add(m_start_btn);
|
||||
wxBoxSizer* const bottom_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
if (is_hosting)
|
||||
{
|
||||
m_start_btn = new wxButton(panel, wxID_ANY, _("Start"));
|
||||
m_start_btn->Bind(wxEVT_BUTTON, &NetPlayDialog::OnStart, this);
|
||||
bottom_szr->Add(m_start_btn);
|
||||
|
||||
bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5);
|
||||
wxSpinCtrl* const padbuf_spin = new wxSpinCtrl(panel, wxID_ANY, std::to_string(INITIAL_PAD_BUFFER_SIZE)
|
||||
, wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, INITIAL_PAD_BUFFER_SIZE);
|
||||
padbuf_spin->Bind(wxEVT_SPINCTRL, &NetPlayDialog::OnAdjustBuffer, this);
|
||||
bottom_szr->AddSpacer(3);
|
||||
bottom_szr->Add(padbuf_spin, 0, wxCENTER);
|
||||
bottom_szr->AddSpacer(5);
|
||||
m_memcard_write = new wxCheckBox(panel, wxID_ANY, _("Write to memcards/SD"));
|
||||
bottom_szr->Add(m_memcard_write, 0, wxCENTER);
|
||||
}
|
||||
bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5);
|
||||
wxSpinCtrl* const padbuf_spin =
|
||||
new wxSpinCtrl(panel, wxID_ANY, std::to_string(INITIAL_PAD_BUFFER_SIZE), wxDefaultPosition,
|
||||
wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, INITIAL_PAD_BUFFER_SIZE);
|
||||
padbuf_spin->Bind(wxEVT_SPINCTRL, &NetPlayDialog::OnAdjustBuffer, this);
|
||||
bottom_szr->AddSpacer(3);
|
||||
bottom_szr->Add(padbuf_spin, 0, wxCENTER);
|
||||
bottom_szr->AddSpacer(5);
|
||||
m_memcard_write = new wxCheckBox(panel, wxID_ANY, _("Write to memcards/SD"));
|
||||
bottom_szr->Add(m_memcard_write, 0, wxCENTER);
|
||||
}
|
||||
|
||||
bottom_szr->AddSpacer(5);
|
||||
m_record_chkbox = new wxCheckBox(panel, wxID_ANY, _("Record inputs"));
|
||||
bottom_szr->Add(m_record_chkbox, 0, wxCENTER);
|
||||
bottom_szr->AddSpacer(5);
|
||||
m_record_chkbox = new wxCheckBox(panel, wxID_ANY, _("Record inputs"));
|
||||
bottom_szr->Add(m_record_chkbox, 0, wxCENTER);
|
||||
|
||||
bottom_szr->AddStretchSpacer(1);
|
||||
bottom_szr->Add(quit_btn);
|
||||
bottom_szr->AddStretchSpacer(1);
|
||||
bottom_szr->Add(quit_btn);
|
||||
|
||||
// main sizer
|
||||
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
|
||||
main_szr->Add(m_game_btn, 0, wxEXPAND | wxALL, 5);
|
||||
main_szr->Add(mid_szr, 1, wxEXPAND | wxLEFT | wxRIGHT, 5);
|
||||
main_szr->Add(bottom_szr, 0, wxEXPAND | wxALL, 5);
|
||||
// main sizer
|
||||
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
|
||||
main_szr->Add(m_game_btn, 0, wxEXPAND | wxALL, 5);
|
||||
main_szr->Add(mid_szr, 1, wxEXPAND | wxLEFT | wxRIGHT, 5);
|
||||
main_szr->Add(bottom_szr, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
panel->SetSizerAndFit(main_szr);
|
||||
panel->SetSizerAndFit(main_szr);
|
||||
|
||||
main_szr->SetSizeHints(this);
|
||||
SetSize(768, 768 - 128);
|
||||
main_szr->SetSizeHints(this);
|
||||
SetSize(768, 768 - 128);
|
||||
|
||||
Center();
|
||||
Center();
|
||||
}
|
||||
|
||||
NetPlayDialog::~NetPlayDialog()
|
||||
{
|
||||
if (netplay_client)
|
||||
{
|
||||
delete netplay_client;
|
||||
netplay_client = nullptr;
|
||||
}
|
||||
if (netplay_server)
|
||||
{
|
||||
delete netplay_server;
|
||||
netplay_server = nullptr;
|
||||
}
|
||||
npd = nullptr;
|
||||
if (netplay_client)
|
||||
{
|
||||
delete netplay_client;
|
||||
netplay_client = nullptr;
|
||||
}
|
||||
if (netplay_server)
|
||||
{
|
||||
delete netplay_server;
|
||||
netplay_server = nullptr;
|
||||
}
|
||||
npd = nullptr;
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnChat(wxCommandEvent&)
|
||||
{
|
||||
wxString text = m_chat_msg_text->GetValue();
|
||||
wxString text = m_chat_msg_text->GetValue();
|
||||
|
||||
if (!text.empty())
|
||||
{
|
||||
netplay_client->SendChatMessage(WxStrToStr(text));
|
||||
m_chat_text->AppendText(text.Prepend(" >> ").Append('\n'));
|
||||
m_chat_msg_text->Clear();
|
||||
}
|
||||
if (!text.empty())
|
||||
{
|
||||
netplay_client->SendChatMessage(WxStrToStr(text));
|
||||
m_chat_text->AppendText(text.Prepend(" >> ").Append('\n'));
|
||||
m_chat_msg_text->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlayDialog::GetNetSettings(NetSettings &settings)
|
||||
void NetPlayDialog::GetNetSettings(NetSettings& settings)
|
||||
{
|
||||
SConfig &instance = SConfig::GetInstance();
|
||||
settings.m_CPUthread = instance.bCPUThread;
|
||||
settings.m_CPUcore = instance.iCPUCore;
|
||||
settings.m_SelectedLanguage = instance.SelectedLanguage;
|
||||
settings.m_OverrideGCLanguage = instance.bOverrideGCLanguage;
|
||||
settings.m_ProgressiveScan = instance.bProgressive;
|
||||
settings.m_PAL60 = instance.bPAL60;
|
||||
settings.m_DSPHLE = instance.bDSPHLE;
|
||||
settings.m_DSPEnableJIT = instance.m_DSPEnableJIT;
|
||||
settings.m_WriteToMemcard = m_memcard_write->GetValue();
|
||||
settings.m_OCEnable = instance.m_OCEnable;
|
||||
settings.m_OCFactor = instance.m_OCFactor;
|
||||
settings.m_EXIDevice[0] = instance.m_EXIDevice[0];
|
||||
settings.m_EXIDevice[1] = instance.m_EXIDevice[1];
|
||||
SConfig& instance = SConfig::GetInstance();
|
||||
settings.m_CPUthread = instance.bCPUThread;
|
||||
settings.m_CPUcore = instance.iCPUCore;
|
||||
settings.m_SelectedLanguage = instance.SelectedLanguage;
|
||||
settings.m_OverrideGCLanguage = instance.bOverrideGCLanguage;
|
||||
settings.m_ProgressiveScan = instance.bProgressive;
|
||||
settings.m_PAL60 = instance.bPAL60;
|
||||
settings.m_DSPHLE = instance.bDSPHLE;
|
||||
settings.m_DSPEnableJIT = instance.m_DSPEnableJIT;
|
||||
settings.m_WriteToMemcard = m_memcard_write->GetValue();
|
||||
settings.m_OCEnable = instance.m_OCEnable;
|
||||
settings.m_OCFactor = instance.m_OCFactor;
|
||||
settings.m_EXIDevice[0] = instance.m_EXIDevice[0];
|
||||
settings.m_EXIDevice[1] = instance.m_EXIDevice[1];
|
||||
}
|
||||
|
||||
std::string NetPlayDialog::FindGame()
|
||||
{
|
||||
// find path for selected game, sloppy..
|
||||
for (u32 i = 0; auto game = m_game_list->GetISO(i); ++i)
|
||||
if (m_selected_game == BuildGameName(*game))
|
||||
return game->GetFileName();
|
||||
// find path for selected game, sloppy..
|
||||
for (u32 i = 0; auto game = m_game_list->GetISO(i); ++i)
|
||||
if (m_selected_game == BuildGameName(*game))
|
||||
return game->GetFileName();
|
||||
|
||||
WxUtils::ShowErrorDialog(_("Game not found!"));
|
||||
return "";
|
||||
WxUtils::ShowErrorDialog(_("Game not found!"));
|
||||
return "";
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnStart(wxCommandEvent&)
|
||||
{
|
||||
NetSettings settings;
|
||||
GetNetSettings(settings);
|
||||
netplay_server->SetNetSettings(settings);
|
||||
netplay_server->StartGame();
|
||||
NetSettings settings;
|
||||
GetNetSettings(settings);
|
||||
netplay_server->SetNetSettings(settings);
|
||||
netplay_server->StartGame();
|
||||
}
|
||||
|
||||
void NetPlayDialog::BootGame(const std::string& filename)
|
||||
{
|
||||
main_frame->BootGame(filename);
|
||||
main_frame->BootGame(filename);
|
||||
}
|
||||
|
||||
void NetPlayDialog::StopGame()
|
||||
{
|
||||
main_frame->DoStop();
|
||||
main_frame->DoStop();
|
||||
}
|
||||
|
||||
// NetPlayUI methods called from ---NETPLAY--- thread
|
||||
void NetPlayDialog::Update()
|
||||
{
|
||||
wxThreadEvent evt(wxEVT_THREAD, 1);
|
||||
GetEventHandler()->AddPendingEvent(evt);
|
||||
wxThreadEvent evt(wxEVT_THREAD, 1);
|
||||
GetEventHandler()->AddPendingEvent(evt);
|
||||
}
|
||||
|
||||
void NetPlayDialog::AppendChat(const std::string& msg)
|
||||
{
|
||||
chat_msgs.Push(msg);
|
||||
// silly
|
||||
Update();
|
||||
chat_msgs.Push(msg);
|
||||
// silly
|
||||
Update();
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnMsgChangeGame(const std::string& filename)
|
||||
{
|
||||
wxThreadEvent* evt = new wxThreadEvent(wxEVT_THREAD, NP_GUI_EVT_CHANGE_GAME);
|
||||
evt->SetString(StrToWxStr(filename));
|
||||
GetEventHandler()->QueueEvent(evt);
|
||||
wxThreadEvent* evt = new wxThreadEvent(wxEVT_THREAD, NP_GUI_EVT_CHANGE_GAME);
|
||||
evt->SetString(StrToWxStr(filename));
|
||||
GetEventHandler()->QueueEvent(evt);
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnMsgStartGame()
|
||||
{
|
||||
wxThreadEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME);
|
||||
GetEventHandler()->AddPendingEvent(evt);
|
||||
if (m_is_hosting)
|
||||
{
|
||||
m_start_btn->Disable();
|
||||
m_memcard_write->Disable();
|
||||
m_game_btn->Disable();
|
||||
m_player_config_btn->Disable();
|
||||
}
|
||||
wxThreadEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME);
|
||||
GetEventHandler()->AddPendingEvent(evt);
|
||||
if (m_is_hosting)
|
||||
{
|
||||
m_start_btn->Disable();
|
||||
m_memcard_write->Disable();
|
||||
m_game_btn->Disable();
|
||||
m_player_config_btn->Disable();
|
||||
}
|
||||
|
||||
m_record_chkbox->Disable();
|
||||
m_record_chkbox->Disable();
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnMsgStopGame()
|
||||
{
|
||||
wxThreadEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME);
|
||||
GetEventHandler()->AddPendingEvent(evt);
|
||||
if (m_is_hosting)
|
||||
{
|
||||
m_start_btn->Enable();
|
||||
m_memcard_write->Enable();
|
||||
m_game_btn->Enable();
|
||||
m_player_config_btn->Enable();
|
||||
}
|
||||
m_record_chkbox->Enable();
|
||||
wxThreadEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME);
|
||||
GetEventHandler()->AddPendingEvent(evt);
|
||||
if (m_is_hosting)
|
||||
{
|
||||
m_start_btn->Enable();
|
||||
m_memcard_write->Enable();
|
||||
m_game_btn->Enable();
|
||||
m_player_config_btn->Enable();
|
||||
}
|
||||
m_record_chkbox->Enable();
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnAdjustBuffer(wxCommandEvent& event)
|
||||
{
|
||||
const int val = ((wxSpinCtrl*)event.GetEventObject())->GetValue();
|
||||
netplay_server->AdjustPadBufferSize(val);
|
||||
const int val = ((wxSpinCtrl*)event.GetEventObject())->GetValue();
|
||||
netplay_server->AdjustPadBufferSize(val);
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << "< Pad Buffer: " << val << " >";
|
||||
netplay_client->SendChatMessage(ss.str());
|
||||
m_chat_text->AppendText(StrToWxStr(ss.str()).Append('\n'));
|
||||
std::ostringstream ss;
|
||||
ss << "< Pad Buffer: " << val << " >";
|
||||
netplay_client->SendChatMessage(ss.str());
|
||||
m_chat_text->AppendText(StrToWxStr(ss.str()).Append('\n'));
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnQuit(wxCommandEvent&)
|
||||
{
|
||||
Destroy();
|
||||
Destroy();
|
||||
}
|
||||
|
||||
// update gui
|
||||
void NetPlayDialog::OnThread(wxThreadEvent& event)
|
||||
{
|
||||
if (m_is_hosting && m_host_label && g_TraversalClient)
|
||||
{
|
||||
UpdateHostLabel();
|
||||
}
|
||||
if (m_is_hosting && m_host_label && g_TraversalClient)
|
||||
{
|
||||
UpdateHostLabel();
|
||||
}
|
||||
|
||||
// player list
|
||||
m_playerids.clear();
|
||||
std::string tmps;
|
||||
netplay_client->GetPlayerList(tmps, m_playerids);
|
||||
// player list
|
||||
m_playerids.clear();
|
||||
std::string tmps;
|
||||
netplay_client->GetPlayerList(tmps, m_playerids);
|
||||
|
||||
wxString selection;
|
||||
if (m_player_lbox->GetSelection() != wxNOT_FOUND)
|
||||
selection = m_player_lbox->GetString(m_player_lbox->GetSelection());
|
||||
wxString selection;
|
||||
if (m_player_lbox->GetSelection() != wxNOT_FOUND)
|
||||
selection = m_player_lbox->GetString(m_player_lbox->GetSelection());
|
||||
|
||||
m_player_lbox->Clear();
|
||||
std::istringstream ss(tmps);
|
||||
while (std::getline(ss, tmps))
|
||||
m_player_lbox->Append(StrToWxStr(tmps));
|
||||
m_player_lbox->Clear();
|
||||
std::istringstream ss(tmps);
|
||||
while (std::getline(ss, tmps))
|
||||
m_player_lbox->Append(StrToWxStr(tmps));
|
||||
|
||||
// remove ping from selection string, in case it has changed
|
||||
selection.erase(selection.rfind('|') + 1);
|
||||
// remove ping from selection string, in case it has changed
|
||||
selection.erase(selection.rfind('|') + 1);
|
||||
|
||||
if (!selection.empty())
|
||||
{
|
||||
for (unsigned int i = 0; i < m_player_lbox->GetCount(); ++i)
|
||||
{
|
||||
if (selection == m_player_lbox->GetString(i).substr(0, selection.length()))
|
||||
{
|
||||
m_player_lbox->SetSelection(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!selection.empty())
|
||||
{
|
||||
for (unsigned int i = 0; i < m_player_lbox->GetCount(); ++i)
|
||||
{
|
||||
if (selection == m_player_lbox->GetString(i).substr(0, selection.length()))
|
||||
{
|
||||
m_player_lbox->SetSelection(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// flash window in taskbar when someone joins if window isn't active
|
||||
static u8 numPlayers = 1;
|
||||
if (netplay_server != nullptr && numPlayers < m_playerids.size() && !HasFocus())
|
||||
{
|
||||
RequestUserAttention();
|
||||
}
|
||||
numPlayers = m_playerids.size();
|
||||
// flash window in taskbar when someone joins if window isn't active
|
||||
static u8 numPlayers = 1;
|
||||
if (netplay_server != nullptr && numPlayers < m_playerids.size() && !HasFocus())
|
||||
{
|
||||
RequestUserAttention();
|
||||
}
|
||||
numPlayers = m_playerids.size();
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case NP_GUI_EVT_CHANGE_GAME:
|
||||
// update selected game :/
|
||||
{
|
||||
m_selected_game = WxStrToStr(event.GetString());
|
||||
switch (event.GetId())
|
||||
{
|
||||
case NP_GUI_EVT_CHANGE_GAME:
|
||||
// update selected game :/
|
||||
{
|
||||
m_selected_game = WxStrToStr(event.GetString());
|
||||
|
||||
wxString button_label = event.GetString();
|
||||
m_game_btn->SetLabel(button_label.Prepend(_(" Game : ")));
|
||||
}
|
||||
break;
|
||||
case NP_GUI_EVT_START_GAME:
|
||||
// client start game :/
|
||||
{
|
||||
netplay_client->StartGame(FindGame());
|
||||
}
|
||||
break;
|
||||
case NP_GUI_EVT_STOP_GAME:
|
||||
// client stop game
|
||||
{
|
||||
netplay_client->StopGame();
|
||||
}
|
||||
break;
|
||||
}
|
||||
wxString button_label = event.GetString();
|
||||
m_game_btn->SetLabel(button_label.Prepend(_(" Game : ")));
|
||||
}
|
||||
break;
|
||||
case NP_GUI_EVT_START_GAME:
|
||||
// client start game :/
|
||||
{
|
||||
netplay_client->StartGame(FindGame());
|
||||
}
|
||||
break;
|
||||
case NP_GUI_EVT_STOP_GAME:
|
||||
// client stop game
|
||||
{
|
||||
netplay_client->StopGame();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// chat messages
|
||||
while (chat_msgs.Size())
|
||||
{
|
||||
std::string s;
|
||||
chat_msgs.Pop(s);
|
||||
//PanicAlert("message: %s", s.c_str());
|
||||
m_chat_text->AppendText(StrToWxStr(s).Append('\n'));
|
||||
}
|
||||
// chat messages
|
||||
while (chat_msgs.Size())
|
||||
{
|
||||
std::string s;
|
||||
chat_msgs.Pop(s);
|
||||
// PanicAlert("message: %s", s.c_str());
|
||||
m_chat_text->AppendText(StrToWxStr(s).Append('\n'));
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnChangeGame(wxCommandEvent&)
|
||||
{
|
||||
ChangeGameDialog cgd(this, m_game_list);
|
||||
cgd.ShowModal();
|
||||
ChangeGameDialog cgd(this, m_game_list);
|
||||
cgd.ShowModal();
|
||||
|
||||
wxString game_name = cgd.GetChosenGameName();
|
||||
if (game_name.empty())
|
||||
return;
|
||||
wxString game_name = cgd.GetChosenGameName();
|
||||
if (game_name.empty())
|
||||
return;
|
||||
|
||||
m_selected_game = WxStrToStr(game_name);
|
||||
netplay_server->ChangeGame(m_selected_game);
|
||||
m_game_btn->SetLabel(game_name.Prepend(_(" Game : ")));
|
||||
m_selected_game = WxStrToStr(game_name);
|
||||
netplay_server->ChangeGame(m_selected_game);
|
||||
m_game_btn->SetLabel(game_name.Prepend(_(" Game : ")));
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnAssignPads(wxCommandEvent&)
|
||||
{
|
||||
PadMapDialog pmd(this, netplay_server, netplay_client);
|
||||
pmd.ShowModal();
|
||||
PadMapDialog pmd(this, netplay_server, netplay_client);
|
||||
pmd.ShowModal();
|
||||
|
||||
netplay_server->SetPadMapping(pmd.GetModifiedPadMappings());
|
||||
netplay_server->SetPadMapping(pmd.GetModifiedPadMappings());
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnKick(wxCommandEvent&)
|
||||
{
|
||||
wxString selection = m_player_lbox->GetStringSelection();
|
||||
unsigned long player = 0;
|
||||
selection.substr(selection.rfind('[') + 1, selection.rfind(']')).ToULong(&player);
|
||||
wxString selection = m_player_lbox->GetStringSelection();
|
||||
unsigned long player = 0;
|
||||
selection.substr(selection.rfind('[') + 1, selection.rfind(']')).ToULong(&player);
|
||||
|
||||
netplay_server->KickPlayer((u8)player);
|
||||
netplay_server->KickPlayer((u8)player);
|
||||
|
||||
m_player_lbox->SetSelection(wxNOT_FOUND);
|
||||
wxCommandEvent event;
|
||||
OnPlayerSelect(event);
|
||||
m_player_lbox->SetSelection(wxNOT_FOUND);
|
||||
wxCommandEvent event;
|
||||
OnPlayerSelect(event);
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnPlayerSelect(wxCommandEvent&)
|
||||
{
|
||||
m_kick_btn->Enable(m_player_lbox->GetSelection() > 0);
|
||||
m_kick_btn->Enable(m_player_lbox->GetSelection() > 0);
|
||||
}
|
||||
|
||||
bool NetPlayDialog::IsRecording()
|
||||
{
|
||||
return m_record_chkbox->GetValue();
|
||||
return m_record_chkbox->GetValue();
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnCopyIP(wxCommandEvent&)
|
||||
{
|
||||
if (m_host_copy_btn_is_retry)
|
||||
{
|
||||
g_TraversalClient->ReconnectToServer();
|
||||
Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wxTheClipboard->Open())
|
||||
{
|
||||
wxTheClipboard->SetData(new wxTextDataObject(m_host_label->GetLabel()));
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
if (m_host_copy_btn_is_retry)
|
||||
{
|
||||
g_TraversalClient->ReconnectToServer();
|
||||
Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wxTheClipboard->Open())
|
||||
{
|
||||
wxTheClipboard->SetData(new wxTextDataObject(m_host_label->GetLabel()));
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnChoice(wxCommandEvent& event)
|
||||
{
|
||||
UpdateHostLabel();
|
||||
UpdateHostLabel();
|
||||
}
|
||||
|
||||
void NetPlayDialog::UpdateHostLabel()
|
||||
{
|
||||
wxString label = _(" (internal IP)");
|
||||
auto DeLabel = [=](wxString str) {
|
||||
if (str == _("Localhost"))
|
||||
return std::string("!local!");
|
||||
return WxStrToStr(str.Left(str.Len() - label.Len()));
|
||||
};
|
||||
auto EnLabel = [=](std::string str) -> wxString {
|
||||
if (str == "!local!")
|
||||
return _("Localhost");
|
||||
return StrToWxStr(str) + label;
|
||||
};
|
||||
int sel = m_host_type_choice->GetSelection();
|
||||
if (sel == 0)
|
||||
{
|
||||
// the traversal ID
|
||||
switch (g_TraversalClient->m_State)
|
||||
{
|
||||
case TraversalClient::Connecting:
|
||||
m_host_label->SetForegroundColour(*wxLIGHT_GREY);
|
||||
m_host_label->SetLabel("...");
|
||||
m_host_copy_btn->SetLabel(_("Copy"));
|
||||
m_host_copy_btn->Disable();
|
||||
break;
|
||||
case TraversalClient::Connected:
|
||||
m_host_label->SetForegroundColour(*wxBLACK);
|
||||
m_host_label->SetLabel(wxString(g_TraversalClient->m_HostId.data(), g_TraversalClient->m_HostId.size()));
|
||||
m_host_copy_btn->SetLabel(_("Copy"));
|
||||
m_host_copy_btn->Enable();
|
||||
m_host_copy_btn_is_retry = false;
|
||||
break;
|
||||
case TraversalClient::Failure:
|
||||
m_host_label->SetForegroundColour(*wxBLACK);
|
||||
m_host_label->SetLabel(FailureReasonStringForHostLabel(g_TraversalClient->m_FailureReason));
|
||||
m_host_copy_btn->SetLabel(_("Retry"));
|
||||
m_host_copy_btn->Enable();
|
||||
m_host_copy_btn_is_retry = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (sel != wxNOT_FOUND) // wxNOT_FOUND shouldn't generally happen
|
||||
{
|
||||
m_host_label->SetForegroundColour(*wxBLACK);
|
||||
m_host_label->SetLabel(netplay_server->GetInterfaceHost(DeLabel(m_host_type_choice->GetString(sel))));
|
||||
m_host_copy_btn->SetLabel(_("Copy"));
|
||||
m_host_copy_btn->Enable();
|
||||
m_host_copy_btn_is_retry = false;
|
||||
}
|
||||
wxString label = _(" (internal IP)");
|
||||
auto DeLabel = [=](wxString str) {
|
||||
if (str == _("Localhost"))
|
||||
return std::string("!local!");
|
||||
return WxStrToStr(str.Left(str.Len() - label.Len()));
|
||||
};
|
||||
auto EnLabel = [=](std::string str) -> wxString {
|
||||
if (str == "!local!")
|
||||
return _("Localhost");
|
||||
return StrToWxStr(str) + label;
|
||||
};
|
||||
int sel = m_host_type_choice->GetSelection();
|
||||
if (sel == 0)
|
||||
{
|
||||
// the traversal ID
|
||||
switch (g_TraversalClient->m_State)
|
||||
{
|
||||
case TraversalClient::Connecting:
|
||||
m_host_label->SetForegroundColour(*wxLIGHT_GREY);
|
||||
m_host_label->SetLabel("...");
|
||||
m_host_copy_btn->SetLabel(_("Copy"));
|
||||
m_host_copy_btn->Disable();
|
||||
break;
|
||||
case TraversalClient::Connected:
|
||||
m_host_label->SetForegroundColour(*wxBLACK);
|
||||
m_host_label->SetLabel(
|
||||
wxString(g_TraversalClient->m_HostId.data(), g_TraversalClient->m_HostId.size()));
|
||||
m_host_copy_btn->SetLabel(_("Copy"));
|
||||
m_host_copy_btn->Enable();
|
||||
m_host_copy_btn_is_retry = false;
|
||||
break;
|
||||
case TraversalClient::Failure:
|
||||
m_host_label->SetForegroundColour(*wxBLACK);
|
||||
m_host_label->SetLabel(FailureReasonStringForHostLabel(g_TraversalClient->m_FailureReason));
|
||||
m_host_copy_btn->SetLabel(_("Retry"));
|
||||
m_host_copy_btn->Enable();
|
||||
m_host_copy_btn_is_retry = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (sel != wxNOT_FOUND) // wxNOT_FOUND shouldn't generally happen
|
||||
{
|
||||
m_host_label->SetForegroundColour(*wxBLACK);
|
||||
m_host_label->SetLabel(
|
||||
netplay_server->GetInterfaceHost(DeLabel(m_host_type_choice->GetString(sel))));
|
||||
m_host_copy_btn->SetLabel(_("Copy"));
|
||||
m_host_copy_btn->Enable();
|
||||
m_host_copy_btn_is_retry = false;
|
||||
}
|
||||
|
||||
auto set = netplay_server->GetInterfaceSet();
|
||||
for (const std::string& iface : set)
|
||||
{
|
||||
wxString wxIface = EnLabel(iface);
|
||||
if (m_host_type_choice->FindString(wxIface) == wxNOT_FOUND)
|
||||
m_host_type_choice->Append(wxIface);
|
||||
}
|
||||
for (unsigned i = 1, count = m_host_type_choice->GetCount(); i != count; i++)
|
||||
{
|
||||
if (set.find(DeLabel(m_host_type_choice->GetString(i))) == set.end())
|
||||
{
|
||||
m_host_type_choice->Delete(i);
|
||||
i--;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
auto set = netplay_server->GetInterfaceSet();
|
||||
for (const std::string& iface : set)
|
||||
{
|
||||
wxString wxIface = EnLabel(iface);
|
||||
if (m_host_type_choice->FindString(wxIface) == wxNOT_FOUND)
|
||||
m_host_type_choice->Append(wxIface);
|
||||
}
|
||||
for (unsigned i = 1, count = m_host_type_choice->GetCount(); i != count; i++)
|
||||
{
|
||||
if (set.find(DeLabel(m_host_type_choice->GetString(i))) == set.end())
|
||||
{
|
||||
m_host_type_choice->Delete(i);
|
||||
i--;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,83 +24,83 @@ class wxTextCtrl;
|
||||
|
||||
enum
|
||||
{
|
||||
NP_GUI_EVT_CHANGE_GAME = 45,
|
||||
NP_GUI_EVT_START_GAME,
|
||||
NP_GUI_EVT_STOP_GAME,
|
||||
NP_GUI_EVT_CHANGE_GAME = 45,
|
||||
NP_GUI_EVT_START_GAME,
|
||||
NP_GUI_EVT_STOP_GAME,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
INITIAL_PAD_BUFFER_SIZE = 5
|
||||
INITIAL_PAD_BUFFER_SIZE = 5
|
||||
};
|
||||
|
||||
class NetPlayDialog : public wxFrame, public NetPlayUI
|
||||
{
|
||||
public:
|
||||
NetPlayDialog(wxWindow* parent, const CGameListCtrl* const game_list
|
||||
, const std::string& game, const bool is_hosting = false);
|
||||
~NetPlayDialog();
|
||||
NetPlayDialog(wxWindow* parent, const CGameListCtrl* const game_list, const std::string& game,
|
||||
const bool is_hosting = false);
|
||||
~NetPlayDialog();
|
||||
|
||||
Common::FifoQueue<std::string> chat_msgs;
|
||||
Common::FifoQueue<std::string> chat_msgs;
|
||||
|
||||
void OnStart(wxCommandEvent& event);
|
||||
void OnStart(wxCommandEvent& event);
|
||||
|
||||
// implementation of NetPlayUI methods
|
||||
void BootGame(const std::string& filename) override;
|
||||
void StopGame() override;
|
||||
// implementation of NetPlayUI methods
|
||||
void BootGame(const std::string& filename) override;
|
||||
void StopGame() override;
|
||||
|
||||
void Update() override;
|
||||
void AppendChat(const std::string& msg) override;
|
||||
void Update() override;
|
||||
void AppendChat(const std::string& msg) override;
|
||||
|
||||
void OnMsgChangeGame(const std::string& filename) override;
|
||||
void OnMsgStartGame() override;
|
||||
void OnMsgStopGame() override;
|
||||
void OnMsgChangeGame(const std::string& filename) override;
|
||||
void OnMsgStartGame() override;
|
||||
void OnMsgStopGame() override;
|
||||
|
||||
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);
|
||||
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;
|
||||
bool IsRecording() override;
|
||||
|
||||
private:
|
||||
void OnChat(wxCommandEvent& event);
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnThread(wxThreadEvent& event);
|
||||
void OnChangeGame(wxCommandEvent& event);
|
||||
void OnAdjustBuffer(wxCommandEvent& event);
|
||||
void OnAssignPads(wxCommandEvent& event);
|
||||
void OnKick(wxCommandEvent& event);
|
||||
void OnPlayerSelect(wxCommandEvent& event);
|
||||
void GetNetSettings(NetSettings& settings);
|
||||
std::string FindGame();
|
||||
void OnChat(wxCommandEvent& event);
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnThread(wxThreadEvent& event);
|
||||
void OnChangeGame(wxCommandEvent& event);
|
||||
void OnAdjustBuffer(wxCommandEvent& event);
|
||||
void OnAssignPads(wxCommandEvent& event);
|
||||
void OnKick(wxCommandEvent& event);
|
||||
void OnPlayerSelect(wxCommandEvent& event);
|
||||
void GetNetSettings(NetSettings& settings);
|
||||
std::string FindGame();
|
||||
|
||||
void OnCopyIP(wxCommandEvent&);
|
||||
void OnChoice(wxCommandEvent& event);
|
||||
void UpdateHostLabel();
|
||||
void OnCopyIP(wxCommandEvent&);
|
||||
void OnChoice(wxCommandEvent& event);
|
||||
void UpdateHostLabel();
|
||||
|
||||
wxListBox* m_player_lbox;
|
||||
wxTextCtrl* m_chat_text;
|
||||
wxTextCtrl* m_chat_msg_text;
|
||||
wxCheckBox* m_memcard_write;
|
||||
wxCheckBox* m_record_chkbox;
|
||||
wxListBox* m_player_lbox;
|
||||
wxTextCtrl* m_chat_text;
|
||||
wxTextCtrl* m_chat_msg_text;
|
||||
wxCheckBox* m_memcard_write;
|
||||
wxCheckBox* m_record_chkbox;
|
||||
|
||||
std::string m_selected_game;
|
||||
wxButton* m_player_config_btn;
|
||||
wxButton* m_game_btn;
|
||||
wxButton* m_start_btn;
|
||||
wxButton* m_kick_btn;
|
||||
wxStaticText* m_host_label;
|
||||
wxChoice* m_host_type_choice;
|
||||
wxButton* m_host_copy_btn;
|
||||
bool m_host_copy_btn_is_retry;
|
||||
bool m_is_hosting;
|
||||
std::string m_selected_game;
|
||||
wxButton* m_player_config_btn;
|
||||
wxButton* m_game_btn;
|
||||
wxButton* m_start_btn;
|
||||
wxButton* m_kick_btn;
|
||||
wxStaticText* m_host_label;
|
||||
wxChoice* m_host_type_choice;
|
||||
wxButton* m_host_copy_btn;
|
||||
bool m_host_copy_btn_is_retry;
|
||||
bool m_is_hosting;
|
||||
|
||||
std::vector<int> m_playerids;
|
||||
std::vector<int> m_playerids;
|
||||
|
||||
const CGameListCtrl* const m_game_list;
|
||||
const CGameListCtrl* const m_game_list;
|
||||
|
||||
static NetPlayDialog* npd;
|
||||
static NetPlayServer* netplay_server;
|
||||
static NetPlayClient* netplay_client;
|
||||
static NetPlayDialog* npd;
|
||||
static NetPlayServer* netplay_server;
|
||||
static NetPlayClient* netplay_client;
|
||||
};
|
||||
|
@ -14,67 +14,66 @@
|
||||
// Removed Wiimote UI elements due to Wiimotes being flat out broken in netplay.
|
||||
|
||||
PadMapDialog::PadMapDialog(wxWindow* parent, NetPlayServer* server, NetPlayClient* client)
|
||||
: wxDialog(parent, wxID_ANY, _("Controller Ports"))
|
||||
, m_pad_mapping(server->GetPadMapping())
|
||||
, m_player_list(client->GetPlayers())
|
||||
: wxDialog(parent, wxID_ANY, _("Controller Ports")), m_pad_mapping(server->GetPadMapping()),
|
||||
m_player_list(client->GetPlayers())
|
||||
{
|
||||
wxBoxSizer* const h_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
h_szr->AddSpacer(10);
|
||||
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);
|
||||
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(_("GC Port ")) + (wxChar)('1' + i))),
|
||||
1, wxALIGN_CENTER_HORIZONTAL);
|
||||
for (unsigned int i = 0; i < 4; ++i)
|
||||
{
|
||||
wxBoxSizer* const v_szr = new wxBoxSizer(wxVERTICAL);
|
||||
v_szr->Add(new wxStaticText(this, wxID_ANY, (wxString(_("GC Port ")) + (wxChar)('1' + 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_pad_mapping[i] == -1)
|
||||
{
|
||||
m_map_cbox[i]->Select(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int j = 0; j < m_player_list.size(); j++)
|
||||
{
|
||||
if (m_pad_mapping[i] == m_player_list[j]->pid)
|
||||
m_map_cbox[i]->Select(j + 1);
|
||||
}
|
||||
}
|
||||
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_pad_mapping[i] == -1)
|
||||
{
|
||||
m_map_cbox[i]->Select(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int j = 0; j < m_player_list.size(); j++)
|
||||
{
|
||||
if (m_pad_mapping[i] == m_player_list[j]->pid)
|
||||
m_map_cbox[i]->Select(j + 1);
|
||||
}
|
||||
}
|
||||
|
||||
v_szr->Add(m_map_cbox[i], 1);
|
||||
v_szr->Add(m_map_cbox[i], 1);
|
||||
|
||||
h_szr->Add(v_szr, 1, wxTOP | wxEXPAND, 20);
|
||||
h_szr->AddSpacer(10);
|
||||
}
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
PadMappingArray PadMapDialog::GetModifiedPadMappings() const
|
||||
{
|
||||
return m_pad_mapping;
|
||||
return m_pad_mapping;
|
||||
}
|
||||
|
||||
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_pad_mapping[i] = m_player_list[player_idx - 1]->pid;
|
||||
else
|
||||
m_pad_mapping[i] = -1;
|
||||
}
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
{
|
||||
int player_idx = m_map_cbox[i]->GetSelection();
|
||||
if (player_idx > 0)
|
||||
m_pad_mapping[i] = m_player_list[player_idx - 1]->pid;
|
||||
else
|
||||
m_pad_mapping[i] = -1;
|
||||
}
|
||||
}
|
||||
|
@ -17,14 +17,14 @@ class wxChoice;
|
||||
class PadMapDialog final : public wxDialog
|
||||
{
|
||||
public:
|
||||
PadMapDialog(wxWindow* parent, NetPlayServer* server, NetPlayClient* client);
|
||||
PadMapDialog(wxWindow* parent, NetPlayServer* server, NetPlayClient* client);
|
||||
|
||||
PadMappingArray GetModifiedPadMappings() const;
|
||||
PadMappingArray GetModifiedPadMappings() const;
|
||||
|
||||
private:
|
||||
void OnAdjust(wxCommandEvent& event);
|
||||
void OnAdjust(wxCommandEvent& event);
|
||||
|
||||
wxChoice* m_map_cbox[4];
|
||||
PadMappingArray m_pad_mapping;
|
||||
std::vector<const Player*> m_player_list;
|
||||
wxChoice* m_map_cbox[4];
|
||||
PadMappingArray m_pad_mapping;
|
||||
std::vector<const Player*> m_player_list;
|
||||
};
|
||||
|
Reference in New Issue
Block a user