From 70cfc9395d190aebed780ae371249c4cd12a833f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 9 Aug 2007 23:45:33 +0000 Subject: [PATCH] MenuAction_Cancel now passes a vote cancellation reason --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401302 --- core/MenuVoting.cpp | 6 +++--- core/smn_menus.cpp | 6 +++--- plugins/include/menus.inc | 16 ++++++++++++---- public/IMenuManager.h | 15 +++++++++++---- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/core/MenuVoting.cpp b/core/MenuVoting.cpp index f63da673..bda53385 100644 --- a/core/MenuVoting.cpp +++ b/core/MenuVoting.cpp @@ -258,7 +258,7 @@ void VoteMenuHandler::EndVoting() IBaseMenu *menu = m_pCurMenu; IMenuHandler *handler = m_pHandler; InternalReset(); - handler->OnMenuVoteCancel(menu); + handler->OnMenuVoteCancel(menu, VoteCancel_Generic); handler->OnMenuEnd(menu, MenuEnd_VotingCancelled); return; } @@ -287,8 +287,8 @@ void VoteMenuHandler::EndVoting() IBaseMenu *menu = m_pCurMenu; IMenuHandler *handler = m_pHandler; InternalReset(); - handler->OnMenuVoteCancel(menu); - handler->OnMenuEnd(menu, MenuEnd_NoVotes); + handler->OnMenuVoteCancel(menu, VoteCancel_NoVotes); + handler->OnMenuEnd(menu, MenuEnd_VotingCancelled); return; } diff --git a/core/smn_menus.cpp b/core/smn_menus.cpp index 7ec21eff..65df9672 100644 --- a/core/smn_menus.cpp +++ b/core/smn_menus.cpp @@ -96,7 +96,7 @@ public: void OnMenuDestroy(IBaseMenu *menu); void OnMenuVoteStart(IBaseMenu *menu); void OnMenuVoteResults(IBaseMenu *menu, const menu_vote_result_t *results); - void OnMenuVoteCancel(IBaseMenu *menu); + void OnMenuVoteCancel(IBaseMenu *menu, VoteCancelReason reason); void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style); unsigned int OnMenuDisplayItem(IBaseMenu *menu, int client, IMenuPanel *panel, unsigned int item, const ItemDrawInfo &dr); bool OnSetHandlerOption(const char *option, const void *data); @@ -337,9 +337,9 @@ void CMenuHandler::OnMenuVoteStart(IBaseMenu *menu) DoAction(menu, MenuAction_VoteStart, 0, 0); } -void CMenuHandler::OnMenuVoteCancel(IBaseMenu *menu) +void CMenuHandler::OnMenuVoteCancel(IBaseMenu *menu, VoteCancelReason reason) { - DoAction(menu, MenuAction_VoteCancel, 0, 0); + DoAction(menu, MenuAction_VoteCancel, reason, 0); } void CMenuHandler::OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style) diff --git a/plugins/include/menus.inc b/plugins/include/menus.inc index bbfdd9d0..6ed60ec0 100644 --- a/plugins/include/menus.inc +++ b/plugins/include/menus.inc @@ -41,7 +41,7 @@ enum MenuAction MenuAction_VoteEnd = (1<<5), /**< (VOTE ONLY): A vote sequence has succeeded (param1=chosen item) This is not called if SetVoteResultCallback has been used on the menu. */ MenuAction_VoteStart = (1<<6), /**< (VOTE ONLY): A vote sequence has started (nothing passed) */ - MenuAction_VoteCancel = (1<<7), /**< (VOTE ONLY): A vote sequence has been cancelled (nothing passed) */ + MenuAction_VoteCancel = (1<<7), /**< (VOTE ONLY): A vote sequence has been cancelled (param1=reason) */ MenuAction_DrawItem = (1<<8), /**< An item is being drawn; return the new style (param1=client, param2=item) */ MenuAction_DisplayItem = (1<<9) /**< Item text is being drawn to the display (param1=client, param2=item) To change the text, use RedrawMenuItem(). @@ -75,7 +75,7 @@ enum MenuAction #define VOTEINFO_ITEM_VOTES 1 /**< Number of votes for the item */ /** - * Reasons a menu can be cancelled. + * Reasons a menu can be cancelled (MenuAction_Cancel). */ enum { @@ -88,7 +88,16 @@ enum }; /** - * Reasons a menu ended. + * Reasons a vote can be cancelled (MenuAction_VoteCancel). + */ +enum +{ + VoteCancel_Generic = -1, /**< Vote was generically cancelled. */ + VoteCancel_NoVotes = -2, /**< Vote did not receive any votes. */ +}; + +/** + * Reasons a menu ended (MenuAction_End). */ enum { @@ -98,7 +107,6 @@ enum MenuEnd_Cancelled = -3, /**< Menu was cancelled (reason in param2) */ MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */ MenuEnd_ExitBack = -5, /**< Menu was cleanly exited via "back" */ - MenuEnd_NoVotes = -6, /**< A menu received no votes */ }; /** diff --git a/public/IMenuManager.h b/public/IMenuManager.h index ee21489c..78a4b360 100644 --- a/public/IMenuManager.h +++ b/public/IMenuManager.h @@ -37,7 +37,7 @@ #include #define SMINTERFACE_MENUMANAGER_NAME "IMenuManager" -#define SMINTERFACE_MENUMANAGER_VERSION 10 +#define SMINTERFACE_MENUMANAGER_VERSION 11 /** * @file IMenuManager.h @@ -162,9 +162,16 @@ namespace SourceMod MenuEnd_Cancelled = -3, /**< Menu was uncleanly cancelled */ MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */ MenuEnd_ExitBack = -5, /**< Menu was cleanly exited via "back" */ - MenuEnd_NoVotes = -6, /**< No votes received */ }; + /** + * @brief Reasons a vote can be cancelled. + */ + enum VoteCancelReason + { + VoteCancel_Generic = -1, /**< Vote was generically cancelled. */ + VoteCancel_NoVotes = -2, /**< Vote did not receive any votes. */ + }; #define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */ #define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */ @@ -701,7 +708,7 @@ namespace SourceMod * * @param menu Menu pointer. */ - virtual void OnMenuVoteCancel(IBaseMenu *menu) + virtual void OnMenuVoteCancel(IBaseMenu *menu, VoteCancelReason reason) { } @@ -734,7 +741,7 @@ namespace SourceMod } virtual bool IsVersionCompatible(unsigned int version) { - if (version < 9 || version > GetInterfaceVersion()) + if (version < 11 || version > GetInterfaceVersion()) { return false; }