added request amb404

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40966
This commit is contained in:
David Anderson 2007-06-16 21:56:12 +00:00
parent fe0d41198b
commit 8437e8ee04
4 changed files with 41 additions and 6 deletions

View File

@ -126,6 +126,7 @@ void VoteMenuHandler::EndVoting()
*/ */
unsigned int dup_array[256]; unsigned int dup_array[256];
unsigned int total = m_Votes[0];
for (size_t i=1; i<m_Items; i++) for (size_t i=1; i<m_Items; i++)
{ {
if (m_Votes[i] > m_Votes[highest]) if (m_Votes[i] > m_Votes[highest])
@ -141,6 +142,7 @@ void VoteMenuHandler::EndVoting()
*/ */
dup_array[dup_count++] = i; dup_array[dup_count++] = i;
} }
total += m_Votes[i];
} }
/* Check if we need to pick from the duplicate list */ /* Check if we need to pick from the duplicate list */
@ -160,7 +162,7 @@ void VoteMenuHandler::EndVoting()
} }
picked_item: picked_item:
m_pHandler->OnMenuVoteEnd(m_pCurMenu, chosen); m_pHandler->OnMenuVoteEnd(m_pCurMenu, chosen, m_Votes[highest], total);
m_pHandler->OnMenuEnd(m_pCurMenu); m_pHandler->OnMenuEnd(m_pCurMenu);
InternalReset(); InternalReset();
} }

View File

@ -69,7 +69,10 @@ public:
void OnMenuEnd(IBaseMenu *menu); void OnMenuEnd(IBaseMenu *menu);
void OnMenuDestroy(IBaseMenu *menu); void OnMenuDestroy(IBaseMenu *menu);
void OnMenuVoteStart(IBaseMenu *menu); void OnMenuVoteStart(IBaseMenu *menu);
void OnMenuVoteEnd(IBaseMenu *menu, unsigned int item); void OnMenuVoteEnd(IBaseMenu *menu,
unsigned int item,
unsigned int winningVotes,
unsigned int totalVotes);
void OnMenuVoteCancel(IBaseMenu *menu); void OnMenuVoteCancel(IBaseMenu *menu);
#if 0 #if 0
void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style); void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
@ -288,9 +291,12 @@ void CMenuHandler::OnMenuVoteStart(IBaseMenu *menu)
DoAction(menu, MenuAction_VoteStart, 0, 0); DoAction(menu, MenuAction_VoteStart, 0, 0);
} }
void CMenuHandler::OnMenuVoteEnd(IBaseMenu *menu, unsigned int item) void CMenuHandler::OnMenuVoteEnd(IBaseMenu *menu,
unsigned int item,
unsigned int winningVotes,
unsigned int totalVotes)
{ {
DoAction(menu, MenuAction_VoteEnd, item, 0); DoAction(menu, MenuAction_VoteEnd, item, (totalVotes << 16) | (totalVotes & 0xFFFF));
} }
void CMenuHandler::OnMenuVoteCancel(IBaseMenu *menu) void CMenuHandler::OnMenuVoteCancel(IBaseMenu *menu)

View File

@ -501,3 +501,17 @@ native GetPanelCurrentKey(Handle:panel);
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool:SetPanelCurrentKey(Handle:panel, key); native bool:SetPanelCurrentKey(Handle:panel, key);
/**
* Retrieves voting information from MenuAction_VoteEnd.
*
* @param param2 Second parameter of MenuAction_VoteEnd.
* @param winningVotes Number of votes received by the winning option.
* @param totalVotes Number of total votes received.
* @noreturn
*/
stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes)
{
winningVotes = param2 & 0xFFFF;
totalVotes = param2 >> 16;
}

View File

@ -23,7 +23,7 @@
#include <IHandleSys.h> #include <IHandleSys.h>
#define SMINTERFACE_MENUMANAGER_NAME "IMenuManager" #define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
#define SMINTERFACE_MENUMANAGER_VERSION 3 #define SMINTERFACE_MENUMANAGER_VERSION 4
/** /**
* @file IMenuManager.h * @file IMenuManager.h
@ -647,8 +647,13 @@ namespace SourceMod
* *
* @param menu Menu pointer. * @param menu Menu pointer.
* @param item Item position that was chosen by a majority. * @param item Item position that was chosen by a majority.
* @param winningVotes Number of votes from the winning item.
* @param totalVotes Number of votes total.
*/ */
virtual void OnMenuVoteEnd(IBaseMenu *menu, unsigned int item) virtual void OnMenuVoteEnd(IBaseMenu *menu,
unsigned int item,
unsigned int winningVotes,
unsigned int totalVotes)
{ {
} }
@ -715,6 +720,14 @@ namespace SourceMod
{ {
return SMINTERFACE_MENUMANAGER_VERSION; return SMINTERFACE_MENUMANAGER_VERSION;
} }
virtual bool IsVersionCompatible(unsigned int version)
{
if (version < 4 || version > GetInterfaceVersion())
{
return false;
}
return true;
}
public: public:
/** /**
* @brief Finds a style by name. * @brief Finds a style by name.