MenuAction_Cancel now passes a vote cancellation reason

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401302
This commit is contained in:
David Anderson 2007-08-09 23:45:33 +00:00
parent ddf6726f14
commit 70cfc9395d
4 changed files with 29 additions and 14 deletions

View File

@ -258,7 +258,7 @@ void VoteMenuHandler::EndVoting()
IBaseMenu *menu = m_pCurMenu; IBaseMenu *menu = m_pCurMenu;
IMenuHandler *handler = m_pHandler; IMenuHandler *handler = m_pHandler;
InternalReset(); InternalReset();
handler->OnMenuVoteCancel(menu); handler->OnMenuVoteCancel(menu, VoteCancel_Generic);
handler->OnMenuEnd(menu, MenuEnd_VotingCancelled); handler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
return; return;
} }
@ -287,8 +287,8 @@ void VoteMenuHandler::EndVoting()
IBaseMenu *menu = m_pCurMenu; IBaseMenu *menu = m_pCurMenu;
IMenuHandler *handler = m_pHandler; IMenuHandler *handler = m_pHandler;
InternalReset(); InternalReset();
handler->OnMenuVoteCancel(menu); handler->OnMenuVoteCancel(menu, VoteCancel_NoVotes);
handler->OnMenuEnd(menu, MenuEnd_NoVotes); handler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
return; return;
} }

View File

@ -96,7 +96,7 @@ public:
void OnMenuDestroy(IBaseMenu *menu); void OnMenuDestroy(IBaseMenu *menu);
void OnMenuVoteStart(IBaseMenu *menu); void OnMenuVoteStart(IBaseMenu *menu);
void OnMenuVoteResults(IBaseMenu *menu, const menu_vote_result_t *results); 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); 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); unsigned int OnMenuDisplayItem(IBaseMenu *menu, int client, IMenuPanel *panel, unsigned int item, const ItemDrawInfo &dr);
bool OnSetHandlerOption(const char *option, const void *data); bool OnSetHandlerOption(const char *option, const void *data);
@ -337,9 +337,9 @@ void CMenuHandler::OnMenuVoteStart(IBaseMenu *menu)
DoAction(menu, MenuAction_VoteStart, 0, 0); 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) void CMenuHandler::OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style)

View File

@ -41,7 +41,7 @@ enum MenuAction
MenuAction_VoteEnd = (1<<5), /**< (VOTE ONLY): A vote sequence has succeeded (param1=chosen item) 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. */ 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_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_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) MenuAction_DisplayItem = (1<<9) /**< Item text is being drawn to the display (param1=client, param2=item)
To change the text, use RedrawMenuItem(). To change the text, use RedrawMenuItem().
@ -75,7 +75,7 @@ enum MenuAction
#define VOTEINFO_ITEM_VOTES 1 /**< Number of votes for the item */ #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 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 enum
{ {
@ -98,7 +107,6 @@ enum
MenuEnd_Cancelled = -3, /**< Menu was cancelled (reason in param2) */ MenuEnd_Cancelled = -3, /**< Menu was cancelled (reason in param2) */
MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */ MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */
MenuEnd_ExitBack = -5, /**< Menu was cleanly exited via "back" */ MenuEnd_ExitBack = -5, /**< Menu was cleanly exited via "back" */
MenuEnd_NoVotes = -6, /**< A menu received no votes */
}; };
/** /**

View File

@ -37,7 +37,7 @@
#include <IHandleSys.h> #include <IHandleSys.h>
#define SMINTERFACE_MENUMANAGER_NAME "IMenuManager" #define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
#define SMINTERFACE_MENUMANAGER_VERSION 10 #define SMINTERFACE_MENUMANAGER_VERSION 11
/** /**
* @file IMenuManager.h * @file IMenuManager.h
@ -162,9 +162,16 @@ namespace SourceMod
MenuEnd_Cancelled = -3, /**< Menu was uncleanly cancelled */ MenuEnd_Cancelled = -3, /**< Menu was uncleanly cancelled */
MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */ MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */
MenuEnd_ExitBack = -5, /**< Menu was cleanly exited via "back" */ 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_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */
#define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */ #define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */
@ -701,7 +708,7 @@ namespace SourceMod
* *
* @param menu Menu pointer. * @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) virtual bool IsVersionCompatible(unsigned int version)
{ {
if (version < 9 || version > GetInterfaceVersion()) if (version < 11 || version > GetInterfaceVersion())
{ {
return false; return false;
} }