# HG changeset patch # User David Anderson # Date 1182030972 0 # Node ID fad7c45dacf53b990d11a6eed0464e5b52be6492 # Parent f0231833e6ec5e658ebcc6bedda308dedf2c6b9d added request amb404 diff -r f0231833e6ec -r fad7c45dacf5 core/MenuManager.cpp --- a/core/MenuManager.cpp Sat Jun 16 21:42:05 2007 +0000 +++ b/core/MenuManager.cpp Sat Jun 16 21:56:12 2007 +0000 @@ -126,6 +126,7 @@ */ unsigned int dup_array[256]; + unsigned int total = m_Votes[0]; for (size_t i=1; i m_Votes[highest]) @@ -141,6 +142,7 @@ */ dup_array[dup_count++] = i; } + total += m_Votes[i]; } /* Check if we need to pick from the duplicate list */ @@ -160,7 +162,7 @@ } picked_item: - m_pHandler->OnMenuVoteEnd(m_pCurMenu, chosen); + m_pHandler->OnMenuVoteEnd(m_pCurMenu, chosen, m_Votes[highest], total); m_pHandler->OnMenuEnd(m_pCurMenu); InternalReset(); } diff -r f0231833e6ec -r fad7c45dacf5 core/smn_menus.cpp --- a/core/smn_menus.cpp Sat Jun 16 21:42:05 2007 +0000 +++ b/core/smn_menus.cpp Sat Jun 16 21:56:12 2007 +0000 @@ -69,7 +69,10 @@ void OnMenuEnd(IBaseMenu *menu); void OnMenuDestroy(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); #if 0 void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style); @@ -288,9 +291,12 @@ 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) diff -r f0231833e6ec -r fad7c45dacf5 plugins/include/menus.inc --- a/plugins/include/menus.inc Sat Jun 16 21:42:05 2007 +0000 +++ b/plugins/include/menus.inc Sat Jun 16 21:56:12 2007 +0000 @@ -501,3 +501,17 @@ * @error Invalid Handle. */ 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; +} diff -r f0231833e6ec -r fad7c45dacf5 public/IMenuManager.h --- a/public/IMenuManager.h Sat Jun 16 21:42:05 2007 +0000 +++ b/public/IMenuManager.h Sat Jun 16 21:56:12 2007 +0000 @@ -23,7 +23,7 @@ #include #define SMINTERFACE_MENUMANAGER_NAME "IMenuManager" -#define SMINTERFACE_MENUMANAGER_VERSION 3 +#define SMINTERFACE_MENUMANAGER_VERSION 4 /** * @file IMenuManager.h @@ -647,8 +647,13 @@ * * @param menu Menu pointer. * @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 @@ { return SMINTERFACE_MENUMANAGER_VERSION; } + virtual bool IsVersionCompatible(unsigned int version) + { + if (version < 4 || version > GetInterfaceVersion()) + { + return false; + } + return true; + } public: /** * @brief Finds a style by name.