Skip to content

Commit

Permalink
Qt/NetPlayDialog: Show alerts when events happen
Browse files Browse the repository at this point in the history
Displays an alert when you receive a message or a player joins / leaves
  • Loading branch information
spycrab committed Jul 12, 2018
1 parent 196bf8d commit 9ab489a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ void NetPlayDialog::UpdateGUI()


// Update Player List // Update Player List
const auto players = client->GetPlayers(); const auto players = client->GetPlayers();
const auto player_count = static_cast<int>(players.size());
if (static_cast<int>(players.size()) != m_player_count && m_player_count != 0)
QApplication::alert(this);

m_player_count = static_cast<int>(players.size());



int selection_pid = m_players_list->currentItem() ? int selection_pid = m_players_list->currentItem() ?
m_players_list->currentItem()->data(Qt::UserRole).toInt() : m_players_list->currentItem()->data(Qt::UserRole).toInt() :
Expand All @@ -377,7 +382,7 @@ void NetPlayDialog::UpdateGUI()
m_players_list->clear(); m_players_list->clear();
m_players_list->setHorizontalHeaderLabels( m_players_list->setHorizontalHeaderLabels(
{tr("Player"), tr("Game Status"), tr("Ping"), tr("Mapping"), tr("Revision")}); {tr("Player"), tr("Game Status"), tr("Ping"), tr("Mapping"), tr("Revision")});
m_players_list->setRowCount(player_count); m_players_list->setRowCount(m_player_count);


const auto get_mapping_string = [](const NetPlay::Player* player, const auto get_mapping_string = [](const NetPlay::Player* player,
const NetPlay::PadMappingArray& array) { const NetPlay::PadMappingArray& array) {
Expand All @@ -398,7 +403,7 @@ void NetPlayDialog::UpdateGUI()
{NetPlay::PlayerGameStatus::NotFound, tr("Not Found")}, {NetPlay::PlayerGameStatus::NotFound, tr("Not Found")},
}; };


for (int i = 0; i < player_count; i++) for (int i = 0; i < m_player_count; i++)
{ {
const auto* p = players[i]; const auto* p = players[i];


Expand Down Expand Up @@ -516,6 +521,7 @@ void NetPlayDialog::DisplayMessage(const QString& msg, const std::string& color,
void NetPlayDialog::AppendChat(const std::string& msg) void NetPlayDialog::AppendChat(const std::string& msg)
{ {
DisplayMessage(QString::fromStdString(msg).toHtmlEscaped(), ""); DisplayMessage(QString::fromStdString(msg).toHtmlEscaped(), "");
QApplication::alert(this);
} }


void NetPlayDialog::OnMsgChangeGame(const std::string& title) void NetPlayDialog::OnMsgChangeGame(const std::string& title)
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinQt/NetPlay/NetPlayDialog.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ class NetPlayDialog : public QDialog, public NetPlay::NetPlayUI
bool m_is_copy_button_retry = false; bool m_is_copy_button_retry = false;
bool m_got_stop_request = true; bool m_got_stop_request = true;
int m_buffer_size = 0; int m_buffer_size = 0;
int m_player_count = 0;
}; };

0 comments on commit 9ab489a

Please sign in to comment.