Improve netplay setup dialog UX

* Focus "Hash Code" / "IP address" text box by default in "Connect"
* Focus game list in "Host" tab
* RETURN keypress now host/join depending on selected tab
* Remember last hosted game
* Remove PanicAlertT:
	* Simply log message to netplay window
	* Remove them when they are useless
* Show some netplay message in OSD
	* Chat messages
	* Pad buffer changes
	* Desync alerts
* Stop the game consistently when another player disconnects / crashes
* Prettify chat textbox
* Log netplay ping to OSD

Join scenario:
* Copy netplay code
* Open netplay
* Paste code
* Press enter

Host scenario:
* Open netplay
* Go to host tab
* Press enter
This commit is contained in:
Aestek
2016-02-02 16:35:27 +01:00
parent aa34e5e20e
commit 6a0fc4c438
13 changed files with 428 additions and 178 deletions

View File

@ -31,6 +31,10 @@ enum
NP_GUI_EVT_DISPLAY_MD5_DIALOG,
NP_GUI_EVT_MD5_PROGRESS,
NP_GUI_EVT_MD5_RESULT,
NP_GUI_EVT_PAD_BUFFER_CHANGE,
NP_GUI_EVT_DESYNC,
NP_GUI_EVT_CONNECTION_LOST,
NP_GUI_EVT_TRAVERSAL_CONNECTION_ERROR,
};
enum
@ -38,6 +42,18 @@ enum
INITIAL_PAD_BUFFER_SIZE = 5
};
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,
};
// IDs are UI-dependent here
enum class MD5Target
{
@ -72,6 +88,10 @@ public:
void OnMsgChangeGame(const std::string& filename) override;
void OnMsgStartGame() override;
void OnMsgStopGame() override;
void OnPadBufferChanged(u32 buffer) override;
void OnDesync(u32 frame, const std::string& player) override;
void OnConnectionLost() override;
void OnTraversalError(int error) override;
static NetPlayDialog*& GetInstance() { return npd; }
static NetPlayClient*& GetNetPlayClient() { return netplay_client; }
@ -92,7 +112,8 @@ private:
void OnPlayerSelect(wxCommandEvent& event);
void GetNetSettings(NetSettings& settings);
std::string FindCurrentGame();
std::string FindGame(const std::string& game) override;
std::string FindGame(const std::string& game);
void AddChatMessage(ChatMessageType type, const std::string& msg);
void OnCopyIP(wxCommandEvent&);
void OnChoice(wxCommandEvent& event);
@ -116,6 +137,9 @@ private:
MD5Dialog* m_MD5_dialog = nullptr;
bool m_host_copy_btn_is_retry;
bool m_is_hosting;
u32 m_pad_buffer;
u32 m_desync_frame;
std::string m_desync_player;
std::vector<int> m_playerids;