From 386dc279fd1beae58472bf4f31cea4e4403e6cce Mon Sep 17 00:00:00 2001 From: hiker Date: Mon, 10 Dec 2018 18:26:18 +1100 Subject: [PATCH] Make all unused boxes in the voting GUI invisible. --- src/network/protocols/client_lobby.cpp | 1 + src/states_screens/online/vote_overview.cpp | 19 +++++++++++++------ src/states_screens/online/vote_overview.hpp | 4 ++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index cc6001ee1..f6d1ff653 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -678,6 +678,7 @@ void ClientLobby::updatePlayerList(Event* event) m_total_players = total_players; NetworkingLobby::getInstance()->updatePlayers(players); + VoteOverview::getInstance()->updateNumPlayers(players.size()); } // updatePlayerList //----------------------------------------------------------------------------- diff --git a/src/states_screens/online/vote_overview.cpp b/src/states_screens/online/vote_overview.cpp index 2926e1670..a39acec86 100644 --- a/src/states_screens/online/vote_overview.cpp +++ b/src/states_screens/online/vote_overview.cpp @@ -41,8 +41,9 @@ using namespace irr::video; // ----------------------------------------------------------------------------- VoteOverview::VoteOverview() : Screen("online/vote_overview.stkgui") { - m_quit_server = false; - m_timer = NULL; + m_quit_server = false; + m_timer = NULL; + m_max_num_votes = 0; } // VoteOverview // ----------------------------------------------------------------------------- @@ -98,11 +99,10 @@ void VoteOverview::init() std::string s = StringUtils::insertValues("rect-box%d", i); Widget *box = getWidget(s.c_str()); box->setSelected(PLAYER_ID_GAME_MASTER, false); - box->setVisible(true); - // TODO: Doesn't work, player count appears to be 0 - // box->setVisible(i < lp->getGameSetup()->getPlayerCount()); + box->setVisible(i < m_max_num_votes); - // Make sure all track images are invisible + // Make sure all track images are invisible initially (till we + // receive a vote), otherwise a "?" is shown s = StringUtils::insertValues("track-%d", i); IconButtonWidget *track_widget = getWidget(s.c_str()); track_widget->setVisible(false); @@ -117,6 +117,13 @@ void VoteOverview::tearDown() m_quit_server = false; } // tearDown +// ----------------------------------------------------------------------------- +void VoteOverview::updateNumPlayers(int n) +{ + m_max_num_votes = n; + +} //updateNumPlayers + // ----------------------------------------------------------------------------- /** Selects in which part of the grid the new host is being shown and stores * this information in the m_index_to_hostid mapping. If the host_id is diff --git a/src/states_screens/online/vote_overview.hpp b/src/states_screens/online/vote_overview.hpp index 6f44920e8..6568a6503 100644 --- a/src/states_screens/online/vote_overview.hpp +++ b/src/states_screens/online/vote_overview.hpp @@ -52,6 +52,9 @@ private: /** Index of the winning vote. */ int m_winning_index; + /** Maximum number of votes, as sent by the server. */ + unsigned int m_max_num_votes; + bool m_quit_server; /* A timer used to randomly select tracks. */ @@ -88,6 +91,7 @@ public: void showVote(int host_id); void showVoteResult(); void setResult(const PeerVote &winner_vote); + void updateNumPlayers(int n); // ------------------------------------------------------------------------ void setQuitServer() { m_quit_server = true; }