2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:43:35 -06:00
|
|
|
// Refer to the license.txt file included.
|
2009-07-05 20:10:26 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2009-07-05 20:10:26 -06:00
|
|
|
|
|
|
|
#include <string>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <vector>
|
|
|
|
#include <wx/frame.h>
|
|
|
|
|
2017-02-06 12:48:09 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/FifoQueue.h"
|
|
|
|
#include "Core/NetPlayClient.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "Core/NetPlayProto.h"
|
2015-04-10 23:24:45 -06:00
|
|
|
#include "Core/NetPlayServer.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
|
2017-02-24 10:48:26 -07:00
|
|
|
#ifdef _WIN32
|
2017-02-10 17:14:13 -07:00
|
|
|
// HACK: wxWidgets headers don't play well with some of the macros defined in Windows
|
|
|
|
// headers and perform their own magic to fix things, as long as they're included entirely
|
|
|
|
// either before or after any Windows headers.
|
|
|
|
//
|
|
|
|
// This file can cause a conflict in other DolphinWX files because NetPlay headers directly
|
|
|
|
// include ENet headers, which leak Windows header macros. To fix this, explicitly tell
|
|
|
|
// wxWidgets here that it needs to re-clean macros.
|
|
|
|
#include <wx/msw/winundef.h>
|
2017-02-24 10:48:26 -07:00
|
|
|
#endif
|
2017-02-10 17:14:13 -07:00
|
|
|
|
2014-02-22 15:36:30 -07:00
|
|
|
class CGameListCtrl;
|
2016-07-13 16:45:38 -06:00
|
|
|
class MD5Dialog;
|
2014-02-22 15:36:30 -07:00
|
|
|
class wxButton;
|
|
|
|
class wxCheckBox;
|
|
|
|
class wxChoice;
|
|
|
|
class wxListBox;
|
2016-08-02 00:23:02 -06:00
|
|
|
class wxSizer;
|
2015-04-10 23:24:45 -06:00
|
|
|
class wxStaticText;
|
2016-07-13 16:45:38 -06:00
|
|
|
class wxString;
|
2014-02-22 15:36:30 -07:00
|
|
|
class wxTextCtrl;
|
2011-02-08 08:36:15 -07:00
|
|
|
|
2010-05-02 17:01:50 -06:00
|
|
|
enum
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
NP_GUI_EVT_CHANGE_GAME = 45,
|
|
|
|
NP_GUI_EVT_START_GAME,
|
|
|
|
NP_GUI_EVT_STOP_GAME,
|
2016-07-13 16:45:38 -06:00
|
|
|
NP_GUI_EVT_DISPLAY_MD5_DIALOG,
|
|
|
|
NP_GUI_EVT_MD5_PROGRESS,
|
|
|
|
NP_GUI_EVT_MD5_RESULT,
|
2016-02-02 08:35:27 -07:00
|
|
|
NP_GUI_EVT_PAD_BUFFER_CHANGE,
|
|
|
|
NP_GUI_EVT_DESYNC,
|
|
|
|
NP_GUI_EVT_CONNECTION_LOST,
|
|
|
|
NP_GUI_EVT_TRAVERSAL_CONNECTION_ERROR,
|
2010-05-02 17:01:50 -06:00
|
|
|
};
|
|
|
|
|
2015-04-10 23:24:45 -06:00
|
|
|
enum
|
2010-05-01 13:10:35 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
INITIAL_PAD_BUFFER_SIZE = 5
|
2009-07-05 20:10:26 -06:00
|
|
|
};
|
|
|
|
|
2016-02-02 08:35:27 -07:00
|
|
|
enum class ChatMessageType
|
|
|
|
{
|
|
|
|
// Info messages logged to chat
|
|
|
|
Info,
|
|
|
|
// Error messages logged to chat
|
|
|
|
Error,
|
|
|
|
// Incoming user chat messages
|
|
|
|
UserIn,
|
|
|
|
// Outcoming user chat messages
|
|
|
|
UserOut,
|
|
|
|
};
|
|
|
|
|
2016-07-13 16:45:38 -06:00
|
|
|
// IDs are UI-dependent here
|
|
|
|
enum class MD5Target
|
|
|
|
{
|
|
|
|
CurrentGame = 1,
|
|
|
|
OtherGame = 2,
|
|
|
|
SdCard = 3
|
|
|
|
};
|
|
|
|
|
2015-04-10 23:24:45 -06:00
|
|
|
class NetPlayDialog : public wxFrame, public NetPlayUI
|
2009-07-05 20:10:26 -06:00
|
|
|
{
|
2010-05-01 13:10:35 -06:00
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
NetPlayDialog(wxWindow* parent, const CGameListCtrl* const game_list, const std::string& game,
|
|
|
|
const bool is_hosting = false);
|
|
|
|
~NetPlayDialog();
|
2009-07-05 20:10:26 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void OnStart(wxCommandEvent& event);
|
2010-05-01 13:10:35 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// implementation of NetPlayUI methods
|
|
|
|
void BootGame(const std::string& filename) override;
|
|
|
|
void StopGame() override;
|
2011-02-08 08:36:15 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void Update() override;
|
|
|
|
void AppendChat(const std::string& msg) override;
|
2011-02-08 08:36:15 -07:00
|
|
|
|
2016-07-13 16:45:38 -06:00
|
|
|
void ShowMD5Dialog(const std::string& file_identifier) override;
|
|
|
|
void SetMD5Progress(int pid, int progress) override;
|
|
|
|
void SetMD5Result(int pid, const std::string& result) override;
|
|
|
|
void AbortMD5() override;
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void OnMsgChangeGame(const std::string& filename) override;
|
|
|
|
void OnMsgStartGame() override;
|
|
|
|
void OnMsgStopGame() override;
|
2016-02-02 08:35:27 -07:00
|
|
|
void OnPadBufferChanged(u32 buffer) override;
|
|
|
|
void OnDesync(u32 frame, const std::string& player) override;
|
|
|
|
void OnConnectionLost() override;
|
|
|
|
void OnTraversalError(int error) override;
|
2011-02-08 08:36:15 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
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);
|
2011-02-26 19:27:43 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
bool IsRecording() override;
|
2013-09-03 13:50:41 -06:00
|
|
|
|
2010-05-01 13:10:35 -06:00
|
|
|
private:
|
2016-08-02 00:23:02 -06:00
|
|
|
void CreateGUI();
|
|
|
|
wxSizer* CreateTopGUI(wxWindow* parent);
|
|
|
|
wxSizer* CreateMiddleGUI(wxWindow* parent);
|
|
|
|
wxSizer* CreateChatGUI(wxWindow* parent);
|
|
|
|
wxSizer* CreatePlayerListGUI(wxWindow* parent);
|
|
|
|
wxSizer* CreateBottomGUI(wxWindow* parent);
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void OnChat(wxCommandEvent& event);
|
|
|
|
void OnQuit(wxCommandEvent& event);
|
|
|
|
void OnThread(wxThreadEvent& event);
|
|
|
|
void OnChangeGame(wxCommandEvent& event);
|
2016-07-13 16:45:38 -06:00
|
|
|
void OnMD5ComputeRequested(wxCommandEvent& event);
|
2016-06-24 02:43:46 -06:00
|
|
|
void OnAdjustBuffer(wxCommandEvent& event);
|
|
|
|
void OnAssignPads(wxCommandEvent& event);
|
|
|
|
void OnKick(wxCommandEvent& event);
|
|
|
|
void OnPlayerSelect(wxCommandEvent& event);
|
|
|
|
void GetNetSettings(NetSettings& settings);
|
2016-07-10 02:13:34 -06:00
|
|
|
std::string FindCurrentGame();
|
2016-08-04 14:19:01 -06:00
|
|
|
std::string FindGame(const std::string& game) override;
|
2016-02-02 08:35:27 -07:00
|
|
|
void AddChatMessage(ChatMessageType type, const std::string& msg);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
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;
|
2016-12-23 18:37:23 -07:00
|
|
|
wxCheckBox* m_copy_wii_save;
|
2016-06-24 02:43:46 -06:00
|
|
|
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;
|
2016-08-02 00:23:02 -06:00
|
|
|
wxChoice* m_MD5_choice = nullptr;
|
2016-07-13 16:45:38 -06:00
|
|
|
MD5Dialog* m_MD5_dialog = nullptr;
|
2016-06-24 02:43:46 -06:00
|
|
|
bool m_host_copy_btn_is_retry;
|
|
|
|
bool m_is_hosting;
|
2016-02-02 08:35:27 -07:00
|
|
|
u32 m_pad_buffer;
|
|
|
|
u32 m_desync_frame;
|
|
|
|
std::string m_desync_player;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
std::vector<int> m_playerids;
|
2017-02-06 11:02:02 -07:00
|
|
|
Common::FifoQueue<std::string> m_chat_msgs;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
const CGameListCtrl* const m_game_list;
|
|
|
|
|
|
|
|
static NetPlayDialog* npd;
|
|
|
|
static NetPlayServer* netplay_server;
|
|
|
|
static NetPlayClient* netplay_client;
|
2010-05-02 17:01:50 -06:00
|
|
|
};
|