Add notification sound when new player joins lobby

This commit is contained in:
Benau 2018-10-25 15:12:06 +08:00
parent 20ea6d4a5f
commit d731a658d8
2 changed files with 11 additions and 0 deletions

View File

@ -676,6 +676,7 @@ void ClientLobby::updatePlayerList(Event* event)
unsigned player_count = data.getUInt8();
std::vector<std::tuple<uint32_t, uint32_t, uint32_t, core::stringw,
int, KartTeam> > players;
core::stringw total_players;
for (unsigned i = 0; i < player_count; i++)
{
std::tuple<uint32_t, uint32_t, uint32_t, core::stringw, int,
@ -684,6 +685,7 @@ void ClientLobby::updatePlayerList(Event* event)
std::get<1>(pl) = data.getUInt32();
std::get<2>(pl) = data.getUInt8();
data.decodeStringW(&std::get<3>(pl));
total_players += std::get<3>(pl);
bool is_peer_waiting_for_game = data.getUInt8() == 1;
bool is_peer_server_owner = data.getUInt8() == 1;
// icon to be used, see NetworkingLobby::loadedFromFile
@ -697,6 +699,13 @@ void ClientLobby::updatePlayerList(Event* event)
std::get<5>(pl) = (KartTeam)data.getUInt8();
players.push_back(pl);
}
// Notification sound for new player
if (!m_total_players.empty() &&
total_players.size() > m_total_players.size())
SFXManager::get()->quickSound("energy_bar_full");
m_total_players = total_players;
NetworkingLobby::getInstance()->updatePlayers(players);
} // updatePlayerList

View File

@ -87,6 +87,8 @@ private:
std::map<PeerDisconnectInfo, irr::core::stringw> m_disconnected_msg;
irr::core::stringw m_total_players;
public:
ClientLobby(const TransportAddress& a, std::shared_ptr<Server> s);
virtual ~ClientLobby();