1.1 --- a/core/MenuManager.cpp Sat Jun 16 21:42:05 2007 +0000
1.2 +++ b/core/MenuManager.cpp Sat Jun 16 21:56:12 2007 +0000
1.3 @@ -126,6 +126,7 @@
1.4 */
1.5 unsigned int dup_array[256];
1.6
1.7 + unsigned int total = m_Votes[0];
1.8 for (size_t i=1; i<m_Items; i++)
1.9 {
1.10 if (m_Votes[i] > m_Votes[highest])
1.11 @@ -141,6 +142,7 @@
1.12 */
1.13 dup_array[dup_count++] = i;
1.14 }
1.15 + total += m_Votes[i];
1.16 }
1.17
1.18 /* Check if we need to pick from the duplicate list */
1.19 @@ -160,7 +162,7 @@
1.20 }
1.21
1.22 picked_item:
1.23 - m_pHandler->OnMenuVoteEnd(m_pCurMenu, chosen);
1.24 + m_pHandler->OnMenuVoteEnd(m_pCurMenu, chosen, m_Votes[highest], total);
1.25 m_pHandler->OnMenuEnd(m_pCurMenu);
1.26 InternalReset();
1.27 }
2.1 --- a/core/smn_menus.cpp Sat Jun 16 21:42:05 2007 +0000
2.2 +++ b/core/smn_menus.cpp Sat Jun 16 21:56:12 2007 +0000
2.3 @@ -69,7 +69,10 @@
2.4 void OnMenuEnd(IBaseMenu *menu);
2.5 void OnMenuDestroy(IBaseMenu *menu);
2.6 void OnMenuVoteStart(IBaseMenu *menu);
2.7 - void OnMenuVoteEnd(IBaseMenu *menu, unsigned int item);
2.8 + void OnMenuVoteEnd(IBaseMenu *menu,
2.9 + unsigned int item,
2.10 + unsigned int winningVotes,
2.11 + unsigned int totalVotes);
2.12 void OnMenuVoteCancel(IBaseMenu *menu);
2.13 #if 0
2.14 void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
2.15 @@ -288,9 +291,12 @@
2.16 DoAction(menu, MenuAction_VoteStart, 0, 0);
2.17 }
2.18
2.19 -void CMenuHandler::OnMenuVoteEnd(IBaseMenu *menu, unsigned int item)
2.20 +void CMenuHandler::OnMenuVoteEnd(IBaseMenu *menu,
2.21 + unsigned int item,
2.22 + unsigned int winningVotes,
2.23 + unsigned int totalVotes)
2.24 {
2.25 - DoAction(menu, MenuAction_VoteEnd, item, 0);
2.26 + DoAction(menu, MenuAction_VoteEnd, item, (totalVotes << 16) | (totalVotes & 0xFFFF));
2.27 }
2.28
2.29 void CMenuHandler::OnMenuVoteCancel(IBaseMenu *menu)
3.1 --- a/plugins/include/menus.inc Sat Jun 16 21:42:05 2007 +0000
3.2 +++ b/plugins/include/menus.inc Sat Jun 16 21:56:12 2007 +0000
3.3 @@ -501,3 +501,17 @@
3.4 * @error Invalid Handle.
3.5 */
3.6 native bool:SetPanelCurrentKey(Handle:panel, key);
3.7 +
3.8 +/**
3.9 + * Retrieves voting information from MenuAction_VoteEnd.
3.10 + *
3.11 + * @param param2 Second parameter of MenuAction_VoteEnd.
3.12 + * @param winningVotes Number of votes received by the winning option.
3.13 + * @param totalVotes Number of total votes received.
3.14 + * @noreturn
3.15 + */
3.16 +stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes)
3.17 +{
3.18 + winningVotes = param2 & 0xFFFF;
3.19 + totalVotes = param2 >> 16;
3.20 +}
4.1 --- a/public/IMenuManager.h Sat Jun 16 21:42:05 2007 +0000
4.2 +++ b/public/IMenuManager.h Sat Jun 16 21:56:12 2007 +0000
4.3 @@ -23,7 +23,7 @@
4.4 #include <IHandleSys.h>
4.5
4.6 #define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
4.7 -#define SMINTERFACE_MENUMANAGER_VERSION 3
4.8 +#define SMINTERFACE_MENUMANAGER_VERSION 4
4.9
4.10 /**
4.11 * @file IMenuManager.h
4.12 @@ -647,8 +647,13 @@
4.13 *
4.14 * @param menu Menu pointer.
4.15 * @param item Item position that was chosen by a majority.
4.16 + * @param winningVotes Number of votes from the winning item.
4.17 + * @param totalVotes Number of votes total.
4.18 */
4.19 - virtual void OnMenuVoteEnd(IBaseMenu *menu, unsigned int item)
4.20 + virtual void OnMenuVoteEnd(IBaseMenu *menu,
4.21 + unsigned int item,
4.22 + unsigned int winningVotes,
4.23 + unsigned int totalVotes)
4.24 {
4.25 }
4.26
4.27 @@ -715,6 +720,14 @@
4.28 {
4.29 return SMINTERFACE_MENUMANAGER_VERSION;
4.30 }
4.31 + virtual bool IsVersionCompatible(unsigned int version)
4.32 + {
4.33 + if (version < 4 || version > GetInterfaceVersion())
4.34 + {
4.35 + return false;
4.36 + }
4.37 + return true;
4.38 + }
4.39 public:
4.40 /**
4.41 * @brief Finds a style by name.