MenuAction_Cancel now passes a vote cancellation reason
authorDavid Anderson <dvander@alliedmods.net>
Thu Aug 09 23:45:33 2007 +0000 (2007-08-09)
changeset 12960197a1212cb8
parent 1295 957df1c7b80a
child 1297 423d171fafac
MenuAction_Cancel now passes a vote cancellation reason
core/MenuVoting.cpp
core/smn_menus.cpp
plugins/include/menus.inc
public/IMenuManager.h
     1.1 --- a/core/MenuVoting.cpp	Thu Aug 09 23:34:53 2007 +0000
     1.2 +++ b/core/MenuVoting.cpp	Thu Aug 09 23:45:33 2007 +0000
     1.3 @@ -258,7 +258,7 @@
     1.4  		IBaseMenu *menu = m_pCurMenu;
     1.5  		IMenuHandler *handler = m_pHandler;
     1.6  		InternalReset();
     1.7 -		handler->OnMenuVoteCancel(menu);
     1.8 +		handler->OnMenuVoteCancel(menu, VoteCancel_Generic);
     1.9  		handler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
    1.10  		return;
    1.11  	}
    1.12 @@ -287,8 +287,8 @@
    1.13  		IBaseMenu *menu = m_pCurMenu;
    1.14  		IMenuHandler *handler = m_pHandler;
    1.15  		InternalReset();
    1.16 -		handler->OnMenuVoteCancel(menu);
    1.17 -		handler->OnMenuEnd(menu, MenuEnd_NoVotes);
    1.18 +		handler->OnMenuVoteCancel(menu, VoteCancel_NoVotes);
    1.19 +		handler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
    1.20  		return;
    1.21  	}
    1.22  
     2.1 --- a/core/smn_menus.cpp	Thu Aug 09 23:34:53 2007 +0000
     2.2 +++ b/core/smn_menus.cpp	Thu Aug 09 23:45:33 2007 +0000
     2.3 @@ -96,7 +96,7 @@
     2.4  	void OnMenuDestroy(IBaseMenu *menu);
     2.5  	void OnMenuVoteStart(IBaseMenu *menu);
     2.6  	void OnMenuVoteResults(IBaseMenu *menu, const menu_vote_result_t *results);
     2.7 -	void OnMenuVoteCancel(IBaseMenu *menu);
     2.8 +	void OnMenuVoteCancel(IBaseMenu *menu, VoteCancelReason reason);
     2.9  	void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
    2.10  	unsigned int OnMenuDisplayItem(IBaseMenu *menu, int client, IMenuPanel *panel, unsigned int item, const ItemDrawInfo &dr);
    2.11  	bool OnSetHandlerOption(const char *option, const void *data);
    2.12 @@ -337,9 +337,9 @@
    2.13  	DoAction(menu, MenuAction_VoteStart, 0, 0);
    2.14  }
    2.15  
    2.16 -void CMenuHandler::OnMenuVoteCancel(IBaseMenu *menu)
    2.17 +void CMenuHandler::OnMenuVoteCancel(IBaseMenu *menu, VoteCancelReason reason)
    2.18  {
    2.19 -	DoAction(menu, MenuAction_VoteCancel, 0, 0);
    2.20 +	DoAction(menu, MenuAction_VoteCancel, reason, 0);
    2.21  }
    2.22  
    2.23  void CMenuHandler::OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style)
     3.1 --- a/plugins/include/menus.inc	Thu Aug 09 23:34:53 2007 +0000
     3.2 +++ b/plugins/include/menus.inc	Thu Aug 09 23:45:33 2007 +0000
     3.3 @@ -41,7 +41,7 @@
     3.4  	MenuAction_VoteEnd = (1<<5),	/**< (VOTE ONLY): A vote sequence has succeeded (param1=chosen item) 
     3.5  										 This is not called if SetVoteResultCallback has been used on the menu. */
     3.6  	MenuAction_VoteStart = (1<<6), 	/**< (VOTE ONLY): A vote sequence has started (nothing passed) */
     3.7 -	MenuAction_VoteCancel = (1<<7),	/**< (VOTE ONLY): A vote sequence has been cancelled (nothing passed) */
     3.8 +	MenuAction_VoteCancel = (1<<7),	/**< (VOTE ONLY): A vote sequence has been cancelled (param1=reason) */
     3.9  	MenuAction_DrawItem = (1<<8),	/**< An item is being drawn; return the new style (param1=client, param2=item) */
    3.10  	MenuAction_DisplayItem = (1<<9) /**< Item text is being drawn to the display (param1=client, param2=item)
    3.11  										  To change the text, use RedrawMenuItem().
    3.12 @@ -75,7 +75,7 @@
    3.13  #define VOTEINFO_ITEM_VOTES			1		/**< Number of votes for the item */
    3.14  
    3.15  /**
    3.16 - * Reasons a menu can be cancelled.
    3.17 + * Reasons a menu can be cancelled (MenuAction_Cancel).
    3.18   */
    3.19  enum
    3.20  {
    3.21 @@ -88,7 +88,16 @@
    3.22  };
    3.23  
    3.24  /**
    3.25 - * Reasons a menu ended.
    3.26 + * Reasons a vote can be cancelled (MenuAction_VoteCancel).
    3.27 + */
    3.28 +enum
    3.29 +{
    3.30 +	VoteCancel_Generic = -1,		/**< Vote was generically cancelled. */
    3.31 +	VoteCancel_NoVotes = -2,		/**< Vote did not receive any votes. */
    3.32 +};
    3.33 +
    3.34 +/**
    3.35 + * Reasons a menu ended (MenuAction_End).
    3.36   */
    3.37  enum
    3.38  {
    3.39 @@ -98,7 +107,6 @@
    3.40  	MenuEnd_Cancelled = -3,			/**< Menu was cancelled (reason in param2) */
    3.41  	MenuEnd_Exit = -4,				/**< Menu was cleanly exited via "exit" */
    3.42  	MenuEnd_ExitBack = -5,			/**< Menu was cleanly exited via "back" */
    3.43 -	MenuEnd_NoVotes = -6,			/**< A menu received no votes */
    3.44  };
    3.45  
    3.46  /**
     4.1 --- a/public/IMenuManager.h	Thu Aug 09 23:34:53 2007 +0000
     4.2 +++ b/public/IMenuManager.h	Thu Aug 09 23:45:33 2007 +0000
     4.3 @@ -37,7 +37,7 @@
     4.4  #include <IHandleSys.h>
     4.5  
     4.6  #define SMINTERFACE_MENUMANAGER_NAME		"IMenuManager"
     4.7 -#define SMINTERFACE_MENUMANAGER_VERSION		10
     4.8 +#define SMINTERFACE_MENUMANAGER_VERSION		11
     4.9  
    4.10  /**
    4.11   * @file IMenuManager.h
    4.12 @@ -162,9 +162,16 @@
    4.13  		MenuEnd_Cancelled = -3,				/**< Menu was uncleanly cancelled */
    4.14  		MenuEnd_Exit = -4,					/**< Menu was cleanly exited via "exit" */
    4.15  		MenuEnd_ExitBack = -5,				/**< Menu was cleanly exited via "back" */
    4.16 -		MenuEnd_NoVotes = -6,				/**< No votes received */
    4.17  	};
    4.18  
    4.19 +	/**
    4.20 +	 * @brief Reasons a vote can be cancelled.
    4.21 +	 */
    4.22 +	enum VoteCancelReason
    4.23 +	{
    4.24 +		VoteCancel_Generic = -1,		/**< Vote was generically cancelled. */
    4.25 +		VoteCancel_NoVotes = -2,		/**< Vote did not receive any votes. */
    4.26 +	};
    4.27  
    4.28  	#define MENU_NO_PAGINATION			0		/**< Menu should not be paginated (10 items max) */
    4.29  	#define MENU_TIME_FOREVER			0		/**< Menu should be displayed as long as possible */
    4.30 @@ -701,7 +708,7 @@
    4.31  		 *
    4.32  		 * @param menu			Menu pointer.
    4.33  		 */
    4.34 -		virtual void OnMenuVoteCancel(IBaseMenu *menu)
    4.35 +		virtual void OnMenuVoteCancel(IBaseMenu *menu, VoteCancelReason reason)
    4.36  		{
    4.37  		}
    4.38  
    4.39 @@ -734,7 +741,7 @@
    4.40  		}
    4.41  		virtual bool IsVersionCompatible(unsigned int version)
    4.42  		{
    4.43 -			if (version < 9 || version > GetInterfaceVersion())
    4.44 +			if (version < 11 || version > GetInterfaceVersion())
    4.45  			{
    4.46  				return false;
    4.47  			}