Make all unused boxes in the voting GUI invisible.

This commit is contained in:
hiker 2018-12-10 18:26:18 +11:00
parent 4b74c673fe
commit 386dc279fd
3 changed files with 18 additions and 6 deletions

View File

@ -678,6 +678,7 @@ void ClientLobby::updatePlayerList(Event* event)
m_total_players = total_players;
NetworkingLobby::getInstance()->updatePlayers(players);
VoteOverview::getInstance()->updateNumPlayers(players.size());
} // updatePlayerList
//-----------------------------------------------------------------------------

View File

@ -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<IconButtonWidget>(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

View File

@ -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; }