bumped menu api again - added feature to get menu end reason
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401003
This commit is contained in:
parent
4a82ce501b
commit
58eedf6226
@ -104,7 +104,7 @@ void VoteMenuHandler::EndVoting()
|
||||
IBaseMenu *menu = m_pCurMenu;
|
||||
InternalReset();
|
||||
m_pHandler->OnMenuVoteCancel(menu);
|
||||
m_pHandler->OnMenuEnd(menu);
|
||||
m_pHandler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ void VoteMenuHandler::EndVoting()
|
||||
|
||||
picked_item:
|
||||
m_pHandler->OnMenuVoteEnd(m_pCurMenu, chosen, m_Votes[highest], total);
|
||||
m_pHandler->OnMenuEnd(m_pCurMenu);
|
||||
m_pHandler->OnMenuEnd(m_pCurMenu, MenuEnd_VotingDone);
|
||||
InternalReset();
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ void VoteMenuHandler::OnMenuStart(IBaseMenu *menu)
|
||||
m_Clients++;
|
||||
}
|
||||
|
||||
void VoteMenuHandler::OnMenuEnd(IBaseMenu *menu)
|
||||
void VoteMenuHandler::OnMenuEnd(IBaseMenu *menu, MenuEndReason reason)
|
||||
{
|
||||
DecrementPlayerCount();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public: //IMenuHandler
|
||||
void OnMenuDisplay(IBaseMenu *menu, int client, IMenuPanel *display);
|
||||
void OnMenuSelect(IBaseMenu *menu, int client, unsigned int item);
|
||||
void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason);
|
||||
void OnMenuEnd(IBaseMenu *menu);
|
||||
void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason);
|
||||
void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
|
||||
void OnMenuDisplayItem(IBaseMenu *menu, int client, unsigned int item, const char **display);
|
||||
public: //IVoteMenuHandler
|
||||
|
@ -84,7 +84,7 @@ void BaseMenuStyle::_CancelClientMenu(int client, bool bAutoIgnore/* =false */,
|
||||
/* Only fire end if there's a valid menu */
|
||||
if (menu)
|
||||
{
|
||||
mh->OnMenuEnd(menu);
|
||||
mh->OnMenuEnd(menu, MenuEnd_Cancelled);
|
||||
}
|
||||
|
||||
if (bAutoIgnore)
|
||||
@ -311,7 +311,15 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
||||
/* Only fire end for valid menus */
|
||||
if (menu)
|
||||
{
|
||||
mh->OnMenuEnd(menu);
|
||||
MenuEndReason end_reason =
|
||||
(cancel ?
|
||||
MenuEnd_Selected
|
||||
:
|
||||
(reason == MenuCancel_Exit ?
|
||||
MenuEnd_Exit
|
||||
:
|
||||
MenuEnd_Cancelled));
|
||||
mh->OnMenuEnd(menu, end_reason);
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,7 +400,7 @@ bool BaseMenuStyle::DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh,
|
||||
g_Logger.LogMessage("[SM_MENU] DoClientMenu(): Failed to display to client %d", client);
|
||||
#endif
|
||||
mh->OnMenuCancel(menu, client, MenuCancel_NoDisplay);
|
||||
mh->OnMenuEnd(menu);
|
||||
mh->OnMenuEnd(menu, MenuEnd_Cancelled);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -403,7 +411,7 @@ bool BaseMenuStyle::DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh,
|
||||
g_Logger.LogMessage("[SM_MENU] DoClientMenu(): Client %d is autoIgnoring", client);
|
||||
#endif
|
||||
mh->OnMenuCancel(menu, client, MenuCancel_NoDisplay);
|
||||
mh->OnMenuEnd(menu);
|
||||
mh->OnMenuEnd(menu, MenuEnd_Cancelled);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -439,7 +447,7 @@ bool BaseMenuStyle::DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh,
|
||||
player->bAutoIgnore = false;
|
||||
player->bInMenu = false;
|
||||
mh->OnMenuCancel(menu, client, MenuCancel_NoDisplay);
|
||||
mh->OnMenuEnd(menu);
|
||||
mh->OnMenuEnd(menu, MenuEnd_Cancelled);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ bool ValveMenuStyle::DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh,
|
||||
{
|
||||
mh->OnMenuStart(menu);
|
||||
mh->OnMenuCancel(menu, client, MenuCancel_NoDisplay);
|
||||
mh->OnMenuEnd(menu);
|
||||
mh->OnMenuEnd(menu, MenuEnd_Cancelled);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
void OnMenuDisplay(IBaseMenu *menu, int client, IMenuPanel *display);
|
||||
void OnMenuSelect(IBaseMenu *menu, int client, unsigned int item);
|
||||
void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason);
|
||||
void OnMenuEnd(IBaseMenu *menu);
|
||||
void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason);
|
||||
void OnMenuDestroy(IBaseMenu *menu);
|
||||
void OnMenuVoteStart(IBaseMenu *menu);
|
||||
void OnMenuVoteEnd(IBaseMenu *menu,
|
||||
@ -279,9 +279,9 @@ void CMenuHandler::OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason re
|
||||
DoAction(menu, MenuAction_Cancel, client, (cell_t)reason);
|
||||
}
|
||||
|
||||
void CMenuHandler::OnMenuEnd(IBaseMenu *menu)
|
||||
void CMenuHandler::OnMenuEnd(IBaseMenu *menu, MenuEndReason reason)
|
||||
{
|
||||
DoAction(menu, MenuAction_End, 0, 0);
|
||||
DoAction(menu, MenuAction_End, reason, 0);
|
||||
}
|
||||
|
||||
void CMenuHandler::OnMenuDestroy(IBaseMenu *menu)
|
||||
|
@ -37,7 +37,7 @@ enum MenuAction
|
||||
MenuAction_Display = (1<<1), /**< A menu is about to be displayed (param1=client, param2=MenuPanel Handle) */
|
||||
MenuAction_Select = (1<<2), /**< An item was selected (param1=client, param2=item) */
|
||||
MenuAction_Cancel = (1<<3), /**< The menu was cancelled (param1=client, param2=reason) */
|
||||
MenuAction_End = (1<<4), /**< A menu's display/selection cycle is complete (nothing passed) */
|
||||
MenuAction_End = (1<<4), /**< A menu display has fully ended (param1=reason) */
|
||||
MenuAction_VoteEnd = (1<<5), /**< (VOTE ONLY): A vote sequence has succeeded (param1=chosen item) */
|
||||
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) */
|
||||
@ -70,6 +70,18 @@ enum
|
||||
MenuCancel_NoDisplay = -4, /**< Menu could not be displayed to the client */
|
||||
};
|
||||
|
||||
/**
|
||||
* Reasons a menu ended.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
MenuEnd_Cancelled = -1, /**< Menu was cancelled, reason was passed in MenuAction_Cancel */
|
||||
MenuEnd_Exit = -2, /**< Menu was cleanly exited (but cancelled) */
|
||||
MenuEnd_Selected = -3, /**< Menu item was selected and thus the menu is finished */
|
||||
MenuEnd_VotingDone = -4, /**< Voting finished */
|
||||
MenuEnd_VotingCancelled = -5, /**< Voting was cancelled */
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes a menu's source
|
||||
*/
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <IHandleSys.h>
|
||||
|
||||
#define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
|
||||
#define SMINTERFACE_MENUMANAGER_VERSION 4
|
||||
#define SMINTERFACE_MENUMANAGER_VERSION 5
|
||||
|
||||
/**
|
||||
* @file IMenuManager.h
|
||||
@ -116,6 +116,19 @@ namespace SourceMod
|
||||
MenuCancel_NoDisplay = -4, /**< Menu could not be displayed to the client */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Reasons a menu ended.
|
||||
*/
|
||||
enum MenuEndReason
|
||||
{
|
||||
MenuEnd_Cancelled = -1, /**< Menu was cancelled, reason was passed in MenuAction_Cancel */
|
||||
MenuEnd_Exit = -2, /**< Menu was cleanly exited (but cancelled) */
|
||||
MenuEnd_Selected = -3, /**< Menu item was selected and thus the menu is finished */
|
||||
MenuEnd_VotingDone = -4, /**< Voting finished */
|
||||
MenuEnd_VotingCancelled = -5, /**< Voting was cancelled */
|
||||
};
|
||||
|
||||
|
||||
#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 */
|
||||
|
||||
@ -589,7 +602,7 @@ namespace SourceMod
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
*/
|
||||
virtual void OnMenuEnd(IBaseMenu *menu)
|
||||
virtual void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason)
|
||||
{
|
||||
}
|
||||
|
||||
@ -722,7 +735,7 @@ namespace SourceMod
|
||||
}
|
||||
virtual bool IsVersionCompatible(unsigned int version)
|
||||
{
|
||||
if (version < 4 || version > GetInterfaceVersion())
|
||||
if (version < 5 || version > GetInterfaceVersion())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user