exposed new voting features to plugins (MenuAction_VoteCancel, IsVoteInProgress)
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40891
This commit is contained in:
parent
6f4784e3d1
commit
13493fd7d5
@ -39,6 +39,7 @@ enum MenuAction
|
|||||||
MenuAction_End = (1<<4), /**< A menu's display/selection cycle is complete (nothing passed). */
|
MenuAction_End = (1<<4), /**< A menu's display/selection cycle is complete (nothing passed). */
|
||||||
MenuAction_VoteEnd = (1<<5), /**< (VOTE ONLY): A vote sequence has ended (param1=chosen item) */
|
MenuAction_VoteEnd = (1<<5), /**< (VOTE ONLY): A vote sequence has ended (param1=chosen item) */
|
||||||
MenuAction_VoteStart = (1<<6), /**< (VOTE ONLY): A vote sequence has started */
|
MenuAction_VoteStart = (1<<6), /**< (VOTE ONLY): A vote sequence has started */
|
||||||
|
MenuAction_VoteCancel = (1<<7), /**< (VOTE ONLY): A vote sequence has been cancelled (nothing passed) */
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPanelHandler : public IMenuHandler
|
class CPanelHandler : public IMenuHandler
|
||||||
@ -69,6 +70,7 @@ public:
|
|||||||
void OnMenuDestroy(IBaseMenu *menu);
|
void OnMenuDestroy(IBaseMenu *menu);
|
||||||
void OnMenuVoteStart(IBaseMenu *menu);
|
void OnMenuVoteStart(IBaseMenu *menu);
|
||||||
void OnMenuVoteEnd(IBaseMenu *menu, unsigned int item);
|
void OnMenuVoteEnd(IBaseMenu *menu, unsigned int item);
|
||||||
|
void OnMenuVoteCancel(IBaseMenu *menu);
|
||||||
#if 0
|
#if 0
|
||||||
void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
|
void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
|
||||||
void OnMenuDisplayItem(IBaseMenu *menu, int client, unsigned int item, const char **display);
|
void OnMenuDisplayItem(IBaseMenu *menu, int client, unsigned int item, const char **display);
|
||||||
@ -291,6 +293,11 @@ void CMenuHandler::OnMenuVoteEnd(IBaseMenu *menu, unsigned int item)
|
|||||||
DoAction(menu, MenuAction_VoteEnd, item, 0);
|
DoAction(menu, MenuAction_VoteEnd, item, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMenuHandler::OnMenuVoteCancel(IBaseMenu *menu)
|
||||||
|
{
|
||||||
|
DoAction(menu, MenuAction_VoteCancel, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void CMenuHandler::DoAction(IBaseMenu *menu, MenuAction action, cell_t param1, cell_t param2)
|
void CMenuHandler::DoAction(IBaseMenu *menu, MenuAction action, cell_t param1, cell_t param2)
|
||||||
{
|
{
|
||||||
m_pBasic->PushCell(menu->GetHandle());
|
m_pBasic->PushCell(menu->GetHandle());
|
||||||
@ -623,6 +630,20 @@ static cell_t CancelMenu(IPluginContext *pContext, const cell_t *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t IsVoteInProgress(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
Handle_t hndl = (Handle_t)params[1];
|
||||||
|
HandleError err;
|
||||||
|
IBaseMenu *menu;
|
||||||
|
|
||||||
|
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
return menu->IsVoteInProgress() ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t GetMenuStyle(IPluginContext *pContext, const cell_t *params)
|
static cell_t GetMenuStyle(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
Handle_t hndl = (Handle_t)params[1];
|
Handle_t hndl = (Handle_t)params[1];
|
||||||
@ -942,6 +963,7 @@ REGISTER_NATIVES(menuNatives)
|
|||||||
{"GetPanelCurrentKey", GetPanelCurrentKey},
|
{"GetPanelCurrentKey", GetPanelCurrentKey},
|
||||||
{"GetPanelStyle", GetPanelStyle},
|
{"GetPanelStyle", GetPanelStyle},
|
||||||
{"InsertMenuItem", InsertMenuItem},
|
{"InsertMenuItem", InsertMenuItem},
|
||||||
|
{"IsVoteInProgress", IsVoteInProgress},
|
||||||
{"RemoveAllMenuItems", RemoveAllMenuItems},
|
{"RemoveAllMenuItems", RemoveAllMenuItems},
|
||||||
{"RemoveMenuItem", RemoveMenuItem},
|
{"RemoveMenuItem", RemoveMenuItem},
|
||||||
{"SendPanelToClient", SendPanelToClient},
|
{"SendPanelToClient", SendPanelToClient},
|
||||||
|
@ -37,9 +37,10 @@ enum MenuAction
|
|||||||
MenuAction_Display = (1<<1), /**< A menu is about to be displayed (param1=client, param2=MenuPanel Handle) */
|
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_Select = (1<<2), /**< An item was selected (param1=client, param2=item) */
|
||||||
MenuAction_Cancel = (1<<3), /**< The menu was cancelled (param1=client, param2=reason) */
|
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's display/selection cycle is complete (nothing passed) */
|
||||||
MenuAction_VoteEnd = (1<<5), /**< (VOTE ONLY): A vote sequence has ended (param1=chosen item) */
|
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 */
|
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) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default menu actions */
|
/** Default menu actions */
|
||||||
@ -268,12 +269,22 @@ native bool:SetMenuExitButton(Handle:menu, bool:button);
|
|||||||
* The menu may still exist on the client's screen after this command.
|
* The menu may still exist on the client's screen after this command.
|
||||||
* This simply verifies that the menu is not being used anywhere.
|
* This simply verifies that the menu is not being used anywhere.
|
||||||
*
|
*
|
||||||
|
* If any vote is in progress on a menu, it will be cancelled.
|
||||||
|
*
|
||||||
* @param menu Menu Handle.
|
* @param menu Menu Handle.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native CancelMenu(Handle:menu);
|
native CancelMenu(Handle:menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether a vote is in progress on the given menu.
|
||||||
|
*
|
||||||
|
* @param menu Menu Handle.
|
||||||
|
* @return True if a vote is in progress, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool:IsVoteInProgress(Handle:menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts a menu to a list of clients. The most selected item will be
|
* Broadcasts a menu to a list of clients. The most selected item will be
|
||||||
* returned through MenuAction_End. On a tie, a random item will be returned
|
* returned through MenuAction_End. On a tie, a random item will be returned
|
||||||
|
Loading…
Reference in New Issue
Block a user