core/smn_menus.cpp
changeset 885 7767bebc6262
parent 879 f1e33b35f3b6
child 960 fad7c45dacf5
     1.1 --- a/core/smn_menus.cpp	Wed Jun 06 06:27:47 2007 +0000
     1.2 +++ b/core/smn_menus.cpp	Wed Jun 06 06:33:57 2007 +0000
     1.3 @@ -39,6 +39,7 @@
     1.4  	MenuAction_End = (1<<4),		/**< A menu's display/selection cycle is complete (nothing passed). */
     1.5  	MenuAction_VoteEnd = (1<<5),	/**< (VOTE ONLY): A vote sequence has ended (param1=chosen item) */
     1.6  	MenuAction_VoteStart = (1<<6), 	/**< (VOTE ONLY): A vote sequence has started */
     1.7 +	MenuAction_VoteCancel = (1<<7),	/**< (VOTE ONLY): A vote sequence has been cancelled (nothing passed) */
     1.8  };
     1.9  
    1.10  class CPanelHandler : public IMenuHandler
    1.11 @@ -69,6 +70,7 @@
    1.12  	void OnMenuDestroy(IBaseMenu *menu);
    1.13  	void OnMenuVoteStart(IBaseMenu *menu);
    1.14  	void OnMenuVoteEnd(IBaseMenu *menu, unsigned int item);
    1.15 +	void OnMenuVoteCancel(IBaseMenu *menu);
    1.16  #if 0
    1.17  	void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
    1.18  	void OnMenuDisplayItem(IBaseMenu *menu, int client, unsigned int item, const char **display);
    1.19 @@ -291,6 +293,11 @@
    1.20  	DoAction(menu, MenuAction_VoteEnd, item, 0);
    1.21  }
    1.22  
    1.23 +void CMenuHandler::OnMenuVoteCancel(IBaseMenu *menu)
    1.24 +{
    1.25 +	DoAction(menu, MenuAction_VoteCancel, 0, 0);
    1.26 +}
    1.27 +
    1.28  void CMenuHandler::DoAction(IBaseMenu *menu, MenuAction action, cell_t param1, cell_t param2)
    1.29  {
    1.30  	m_pBasic->PushCell(menu->GetHandle());
    1.31 @@ -623,6 +630,20 @@
    1.32  	return 1;
    1.33  }
    1.34  
    1.35 +static cell_t IsVoteInProgress(IPluginContext *pContext, const cell_t *params)
    1.36 +{
    1.37 +	Handle_t hndl = (Handle_t)params[1];
    1.38 +	HandleError err;
    1.39 +	IBaseMenu *menu;
    1.40 +
    1.41 +	if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
    1.42 +	{
    1.43 +		return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
    1.44 +	}
    1.45 +
    1.46 +	return menu->IsVoteInProgress() ? 1 : 0;
    1.47 +}
    1.48 +
    1.49  static cell_t GetMenuStyle(IPluginContext *pContext, const cell_t *params)
    1.50  {
    1.51  	Handle_t hndl = (Handle_t)params[1];
    1.52 @@ -942,6 +963,7 @@
    1.53  	{"GetPanelCurrentKey",		GetPanelCurrentKey},
    1.54  	{"GetPanelStyle",			GetPanelStyle},
    1.55  	{"InsertMenuItem",			InsertMenuItem},
    1.56 +	{"IsVoteInProgress",		IsVoteInProgress},
    1.57  	{"RemoveAllMenuItems",		RemoveAllMenuItems},
    1.58  	{"RemoveMenuItem",			RemoveMenuItem},
    1.59  	{"SendPanelToClient",		SendPanelToClient},