Skip to content
Permalink
Browse files

Show a message in netplay chat when a player joins or leaves

  • Loading branch information...
bdr99 committed Jul 31, 2019
1 parent dea2b9c commit fdfa14d9cc412d6ed8db841136ef62b6b3facb3e
@@ -305,6 +305,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
m_players[player.pid] = player;
}

m_dialog->OnPlayerConnect(player.name);

m_dialog->Update();
}
break;
@@ -316,6 +318,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)

INFO_LOG(NETPLAY, "Player %s (%d) left", m_players.find(pid)->second.name.c_str(), pid);

m_dialog->OnPlayerDisconnect(m_players.find(pid)->second.name);

{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
m_players.erase(m_players.find(pid));
@@ -46,6 +46,8 @@ class NetPlayUI
virtual void OnMsgStartGame() = 0;
virtual void OnMsgStopGame() = 0;
virtual void OnMsgPowerButton() = 0;
virtual void OnPlayerConnect(const std::string& player) = 0;
virtual void OnPlayerDisconnect(const std::string& player) = 0;
virtual void OnPadBufferChanged(u32 buffer) = 0;
virtual void OnHostInputAuthorityChanged(bool enabled) = 0;
virtual void OnDesync(u32 frame, const std::string& player) = 0;
@@ -887,6 +887,16 @@ void NetPlayDialog::OnMsgPowerButton()
QueueOnObject(this, [] { UICommon::TriggerSTMPowerEvent(); });
}

void NetPlayDialog::OnPlayerConnect(const std::string& player)
{
DisplayMessage(tr("%1 has joined").arg(QString::fromStdString(player)), "darkcyan");
}

void NetPlayDialog::OnPlayerDisconnect(const std::string& player)
{
DisplayMessage(tr("%1 has left").arg(QString::fromStdString(player)), "darkcyan");
}

void NetPlayDialog::OnPadBufferChanged(u32 buffer)
{
QueueOnObject(this, [this, buffer] {
@@ -49,6 +49,8 @@ class NetPlayDialog : public QDialog, public NetPlay::NetPlayUI
void OnMsgStartGame() override;
void OnMsgStopGame() override;
void OnMsgPowerButton() override;
void OnPlayerConnect(const std::string& player) override;
void OnPlayerDisconnect(const std::string& player) override;
void OnPadBufferChanged(u32 buffer) override;
void OnHostInputAuthorityChanged(bool enabled) override;
void OnDesync(u32 frame, const std::string& player) override;

0 comments on commit fdfa14d

Please sign in to comment.
You can’t perform that action at this time.