- vote menus now get cancelled properly (and get a new callback with it)
- added api for seeing if a menu is in a VoteDisplay - fixed another item count bug - removed some cruft from the vote handler header --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40890
This commit is contained in:
+20
-1
@@ -95,6 +95,19 @@ void VoteMenuHandler::DecrementPlayerCount()
|
||||
|
||||
void VoteMenuHandler::EndVoting()
|
||||
{
|
||||
if (m_bCancelled)
|
||||
{
|
||||
/* If we were cancelled, don't bother tabulating anything.
|
||||
* Reset just in case someone tries to redraw, which means
|
||||
* we need to save our states.
|
||||
*/
|
||||
IBaseMenu *menu = m_pCurMenu;
|
||||
InternalReset();
|
||||
m_pHandler->OnMenuVoteCancel(menu);
|
||||
m_pHandler->OnMenuEnd(menu);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int chosen = 0;
|
||||
unsigned int highest = 0;
|
||||
unsigned int dup_count = 0;
|
||||
@@ -104,7 +117,7 @@ void VoteMenuHandler::EndVoting()
|
||||
{
|
||||
/* Pick a random item and then jump far, far away. */
|
||||
srand((unsigned int)(time(NULL)));
|
||||
chosen = (unsigned int)rand() % static_cast<unsigned int>(m_Votes.size());
|
||||
chosen = (unsigned int)rand() % m_Items;
|
||||
goto picked_item;
|
||||
}
|
||||
|
||||
@@ -207,6 +220,12 @@ void VoteMenuHandler::InternalReset()
|
||||
m_bStarted = false;
|
||||
m_pCurMenu = NULL;
|
||||
m_NumVotes = 0;
|
||||
m_bCancelled = false;
|
||||
}
|
||||
|
||||
void VoteMenuHandler::CancelVoting()
|
||||
{
|
||||
m_bCancelled = true;
|
||||
}
|
||||
|
||||
/*******************************
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ public: //IVoteMenuHandler
|
||||
bool IsVoteInProgress();
|
||||
void InitializeVoting(IBaseMenu *menu);
|
||||
void StartVoting();
|
||||
void CancelVoting();
|
||||
public:
|
||||
void Reset(IMenuHandler *mh);
|
||||
private:
|
||||
@@ -51,9 +52,9 @@ private:
|
||||
unsigned int m_Clients;
|
||||
unsigned int m_Items;
|
||||
CVector<unsigned int> m_Votes;
|
||||
CVector<unsigned int> m_Dups;
|
||||
IBaseMenu *m_pCurMenu;
|
||||
bool m_bStarted;
|
||||
bool m_bCancelled;
|
||||
unsigned int m_NumVotes;
|
||||
};
|
||||
|
||||
|
||||
@@ -673,3 +673,7 @@ bool CBaseMenu::BroadcastVote(int clients[],
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBaseMenu::IsVoteInProgress()
|
||||
{
|
||||
return (m_pVoteHandler && m_pVoteHandler->IsVoteInProgress());
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ public:
|
||||
unsigned int numClients,
|
||||
unsigned int maxTime,
|
||||
unsigned int flags=0);
|
||||
bool IsVoteInProgress();
|
||||
public:
|
||||
virtual void VoteDisplay(int client, unsigned int maxTime) =0;
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user