plugins/include/menus.inc
author David Anderson <dvander@alliedmods.net>
Thu Aug 09 18:25:00 2007 +0000 (2007-08-09)
changeset 1290 1a3198e040fa
parent 1289 1b9c8a609447
child 1291 c6d26de53926
permissions -rw-r--r--
added amb766 - GetMenuTitle()
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
     8  * or modified under the Terms and Conditions of its License Agreement, which is found 
     9  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    10  * may change at any time.  To view the latest information, see:
    11  *   http://www.sourcemod.net/license.php
    12  *
    13  * Version: $Id$
    14  */
    15  
    16 #if defined _menus_included
    17  #endinput
    18 #endif
    19 #define _menus_included
    20 
    21 /**
    22  * Low-level drawing style of the menu.
    23  */
    24 enum MenuStyle
    25 {
    26 	MenuStyle_Default = 0,		/**< The "default" menu style for the mod */
    27 	MenuStyle_Valve = 1,		/**< The Valve provided menu style (Used on HL2DM) */
    28 	MenuStyle_Radio = 2,		/**< The simpler menu style commonly used on CS:S */
    29 };
    30 
    31 /**
    32  * Different actions for the menu "pump" callback
    33  */
    34 enum MenuAction
    35 {
    36 	MenuAction_Start = (1<<0),		/**< A menu has been started (nothing passed) */
    37 	MenuAction_Display = (1<<1),	/**< A menu is about to be displayed (param1=client, param2=MenuPanel Handle) */
    38 	MenuAction_Select = (1<<2),		/**< An item was selected (param1=client, param2=item) */
    39 	MenuAction_Cancel = (1<<3),		/**< The menu was cancelled (param1=client, param2=reason) */
    40 	MenuAction_End = (1<<4),		/**< A menu display has fully ended (param1=reason, param2=cancel reason) */
    41 	MenuAction_VoteEnd = (1<<5),	/**< (VOTE ONLY): A vote sequence has succeeded (param1=chosen item) 
    42 										 This is not called if SetVoteResultCallback has been used on the menu. */
    43 	MenuAction_VoteStart = (1<<6), 	/**< (VOTE ONLY): A vote sequence has started (nothing passed) */
    44 	MenuAction_VoteCancel = (1<<7),	/**< (VOTE ONLY): A vote sequence has been cancelled (nothing passed) */
    45 	MenuAction_DrawItem = (1<<8),	/**< An item is being drawn; return the new style (param1=client, param2=item) */
    46 	MenuAction_DisplayItem = (1<<9) /**< Item text is being drawn to the display (param1=client, param2=item)
    47 										  To change the text, use RedrawMenuItem().
    48 										  If you do so, return its return value.  Otherwise, return 0.
    49 										  */
    50 };
    51 
    52 /** Default menu actions */
    53 #define MENU_ACTIONS_DEFAULT	MenuAction_Select|MenuAction_Cancel|MenuAction_End
    54 /** All menu actions */
    55 #define MENU_ACTIONS_ALL		MenuAction:0xFFFFFFFF
    56 
    57 #define MENU_NO_PAGINATION		0		/**< Menu should not be paginated (10 items max) */
    58 #define MENU_TIME_FOREVER		0		/**< Menu should be displayed as long as possible */
    59 
    60 #define ITEMDRAW_DEFAULT		(0)		/**< Item should be drawn normally */
    61 #define ITEMDRAW_DISABLED		(1<<0)	/**< Item is drawn but not selectable */
    62 #define ITEMDRAW_RAWLINE		(1<<1)	/**< Item should be a raw line, without a slot */
    63 #define ITEMDRAW_NOTEXT			(1<<2)	/**< No text should be drawn */
    64 #define ITEMDRAW_SPACER			(1<<3)	/**< Item should be drawn as a spacer, if possible */
    65 #define ITEMDRAW_IGNORE	((1<<1)|(1<<2))	/**< Item should be completely ignored (rawline + notext) */
    66 #define ITEMDRAW_CONTROL		(1<<4)	/**< Item is control text (back/next/exit) */
    67 
    68 #define MENUFLAG_BUTTON_EXIT		(1<<0)	/**< Menu has an "exit" button */
    69 #define MENUFLAG_BUTTON_EXITBACK	(1<<1)	/**< Menu has an "exit back" button */
    70 #define MENUFLAG_NO_SOUND			(1<<2)	/**< Menu will not have any select sounds */
    71 
    72 #define VOTEINFO_CLIENT_INDEX		0		/**< Client index */
    73 #define VOTEINFO_CLIENT_ITEM		1		/**< Item the client selected, or -1 for none */
    74 #define VOTEINFO_ITEM_INDEX			0		/**< Item index */
    75 #define VOTEINFO_ITEM_VOTES			1		/**< Number of votes for the item */
    76 
    77 /**
    78  * Reasons a menu can be cancelled.
    79  */
    80 enum
    81 {
    82 	MenuCancel_Disconnected = -1,	/**< Client dropped from the server */
    83 	MenuCancel_Interrupted = -2,	/**< Client was interrupted with another menu */
    84 	MenuCancel_Exit = -3,			/**< Client exited via "exit" */
    85 	MenuCancel_NoDisplay = -4,		/**< Menu could not be displayed to the client */
    86 	MenuCancel_Timeout = -5,		/**< Menu timed out */
    87 	MenuCancel_ExitBack = -6,		/**< Client selected "exit back" on a paginated menu */
    88 };
    89 
    90 /**
    91  * Reasons a menu ended.
    92  */
    93 enum
    94 {
    95 	MenuEnd_Selected = 0,			/**< Menu item was selected */
    96 	MenuEnd_VotingDone = -1,		/**< Voting finished */
    97 	MenuEnd_VotingCancelled = -2,	/**< Voting was cancelled */
    98 	MenuEnd_Cancelled = -3,			/**< Menu was cancelled (reason in param2) */
    99 	MenuEnd_Exit = -4,				/**< Menu was cleanly exited via "exit" */
   100 	MenuEnd_ExitBack = -5,			/**< Menu was cleanly exited via "back" */
   101 	MenuEnd_NoVotes = -6,			/**< A menu received no votes */
   102 };
   103 
   104 /**
   105  * Describes a menu's source
   106  */
   107 enum MenuSource
   108 {
   109 	MenuSource_None = 0,			/**< No menu is being displayed */	
   110 	MenuSource_External = 1,		/**< External menu */
   111 	MenuSource_Normal = 2,			/**< A basic menu is being displayed */
   112 	MenuSource_RawPanel = 3,		/**< A display is active, but it is not tied to a menu */
   113 };
   114 
   115 /**
   116  * Called when a menu action is completed.
   117  *
   118  * @param menu				The menu being acted upon.
   119  * @param action			The action of the menu.
   120  * @param param1			First action parameter (usually the client).
   121  * @param param2			Second action parameter (usually the item).
   122  * @noreturn
   123  */
   124 functag MenuHandler public(Handle:menu, MenuAction:action, param1, param2);
   125 
   126 /**
   127  * Creates a new, empty menu using the default style.
   128  * 
   129  * @param handler			Function which will receive menu actions.
   130  * @param actions			Optionally set which actions to receive.  Select, 
   131  *							Cancel, and End will always be received regardless
   132  *							of whether they are set or not.  They are also
   133  *							the only default actions.
   134  * @return					A new menu Handle.
   135  */
   136 native Handle:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT);
   137 
   138 /**
   139  * Displays a menu to a client.
   140  *
   141  * @param menu				Menu Handle.
   142  * @param client			Client index.
   143  * @param time				Maximum time to leave menu on the screen.
   144  * @return					True on success, false on failure.
   145  * @error					Invalid Handle or client not in game.
   146  */
   147 native bool:DisplayMenu(Handle:menu, client, time);
   148 
   149 /**
   150  * Appends a new item to the end of a menu.
   151  *
   152  * @param menu				Menu Handle.
   153  * @param info				Item information string.
   154  * @param display			Default item display string.
   155  * @param style				Drawing style flags.  Anything other than DEFAULT or 
   156  *							DISABLED will be completely ignored when paginating.
   157  * @return					True on success, false on failure.
   158  * @error					Invalid Handle or item limit reached.
   159  */
   160 native AddMenuItem(Handle:menu, 
   161 					const String:info[], 
   162 					const String:display[], 
   163 					style=ITEMDRAW_DEFAULT);
   164 
   165 /**
   166  * Inserts an item into the menu before a certain position; the new item will
   167  * be at the given position and all next items pushed forward.
   168  *
   169  * @param menu				Menu Handle.
   170  * @param position			Position, starting from 0.
   171  * @param info				Item information string.
   172  * @param display			Default item display string.
   173  * @param style				Drawing style flags.  Anything other than DEFAULT or 
   174  *							DISABLED will be completely ignored when paginating.
   175  * @return					True on success, false on failure.
   176  * @error					Invalid Handle or menu position.
   177  */
   178 native bool:InsertMenuItem(Handle:menu,
   179 						position, 
   180 						const String:info[], 
   181 						const String:display[], 
   182 						style=ITEMDRAW_DEFAULT);
   183 
   184 /**
   185  * Removes an item from the menu.
   186  *
   187  * @param menu				Menu Handle.
   188  * @param position			Position, starting from 0.
   189  * @return					True on success, false on failure.
   190  * @error					Invalid Handle or menu position.
   191  */
   192 native bool:RemoveMenuItem(Handle:menu, position);
   193 
   194 /**
   195  * Removes all items from a menu.
   196  *
   197  * @param menu				Menu Handle.
   198  * @noreturn
   199  * @error					Invalid Handle or menu position.
   200  */
   201 native RemoveAllMenuItems(Handle:menu);
   202 
   203 /**
   204  * Retrieves information about a menu item.
   205  *
   206  * @param menu				Menu Handle.
   207  * @param position			Position, starting from 0.
   208  * @param infoBuf			Info buffer.
   209  * @param infoBufLen		Maximum length of the info buffer.
   210  * @param style				By-reference variable to store drawing flags.
   211  * @param dispBuf			Display buffer.
   212  * @param dispBufLen		Maximum length of the display buffer.
   213  * @return					True on success, false if position is invalid.
   214  * @error					Invalid Handle.
   215  */
   216 native bool:GetMenuItem(Handle:menu, position, String:infoBuf[], infoBufLen, &style=0, String:dispBuf[]="", dispBufLen=0);
   217 
   218 /**
   219  * Returns the number of items in a menu.
   220  *
   221  * @param menu				Menu Handle.
   222  * @return					Number of items in the menu.
   223  * @error					Invalid Handle.
   224  */
   225 native GetMenuItemCount(Handle:menu);
   226 
   227 /**
   228  * Sets whether the menu should be paginated or not.
   229  *
   230  * @param menu				Handle to the menu.
   231  * @param itemsPerPage		Number of items per page, or MENU_NO_PAGINATION.
   232  * @return					True on success, false if pagination is too high or low.
   233  * @error					Invalid Handle.
   234  */
   235 native bool:SetMenuPagination(Handle:menu, itemsPerPage);
   236 
   237 /**
   238  * Returns a menu's pagination setting.
   239  *
   240  * @param menu				Handle to the menu.
   241  * @return					Pagination setting.
   242  * @error					Invalid Handle.
   243  */
   244 native GetMenuPagination(Handle:menu);
   245 
   246 /**
   247  * Returns a menu's MenuStyle Handle.  The Handle
   248  * is global and cannot be freed.
   249  *
   250  * @param menu				Handle to the menu.
   251  * @return 					Handle to the menu's draw style.
   252  * @error					Invalid Handle.
   253  */
   254 native Handle:GetMenuStyle(Handle:menu);
   255 
   256 /**
   257  * Sets the menu's default title/instruction message.
   258  *
   259  * @param menu				Menu Handle.
   260  * @param fmt				Message string format
   261  * @param ...				Message string arguments.
   262  * @noreturn
   263  * @error					Invalid Handle.
   264  */
   265 native SetMenuTitle(Handle:menu, const String:fmt[], any:...);
   266 
   267 /**
   268  * Returns the text of a menu's title.
   269  *
   270  * @param menu				Menu Handle.
   271  * @param buffer			Buffer to store title.
   272  * @param maxlength			Maximum length of the buffer.
   273  * @return					Number of bytes written.
   274  * @error					Invalid Handle/
   275  */
   276 native GetMenuTitle(Handle:menu, String:buffer[], maxlength);
   277 
   278 /**
   279  * Creates a raw MenuPanel based off the menu's style.
   280  * The Handle must be freed with CloseHandle().
   281  *
   282  * @return					A new MenuPanel Handle.
   283  * @error					Invalid Handle.
   284  */
   285 native Handle:CreatePanelFromMenu(Handle:menu);
   286 
   287 /**
   288  * Returns whether or not the menu has an exit button.
   289  * By default, menus have an exit button.
   290  *
   291  * @param menu				Menu Handle.
   292  * @return 					True if the menu has an exit button; false otherwise.
   293  * @error					Invalid Handle.
   294  */
   295 native bool:GetMenuExitButton(Handle:menu);
   296 
   297 /**
   298  * Sets whether or not the menu has an exit button.
   299  * By default, menus have an exit button.
   300  *
   301  * @param menu				Menu Handle.
   302  * @param button			True to enable the button, false to remove it.
   303  * @return 					True if allowed; false on failure.
   304  * @error					Invalid Handle.
   305  */
   306 native bool:SetMenuExitButton(Handle:menu, bool:button);
   307 
   308 /**
   309  * Returns whether or not the menu has an "exit back" button.
   310  * By default, menus do not have an exit back button.
   311  * Exit Back buttons appear as "Back" on page 1 of paginated menus and
   312  * have functionality defined by the user in MenuEnd_ExitBack.
   313  *
   314  * @param menu				Menu Handle.
   315  * @return 					True if the menu has an exit back button; false otherwise.
   316  * @error					Invalid Handle.
   317  */
   318 native bool:GetMenuExitBackButton(Handle:menu);
   319 
   320 /**
   321  * Sets whether or not the menu has an "exit back" button.
   322  * By default, menus do not have an exit back button.
   323  * Exit Back buttons appear as "Back" on page 1 of paginated menus and
   324  * have functionality defined by the user in MenuEnd_ExitBack.
   325  *
   326  * @param menu				Menu Handle.
   327  * @param button			True to enable the button, false to remove it.
   328  * @error					Invalid Handle.
   329  */
   330 native SetMenuExitBackButton(Handle:menu, bool:button);
   331 
   332 
   333 /**
   334  * Cancels a menu from displaying on all clients.  While the
   335  * cancellation is in progress, this menu cannot be re-displayed
   336  * to any clients.
   337  *
   338  * The menu may still exist on the client's screen after this command.
   339  * This simply verifies that the menu is not being used anywhere.
   340  *
   341  * If any vote is in progress on a menu, it will be cancelled.
   342  *
   343  * @param menu				Menu Handle.
   344  * @noreturn
   345  * @error					Invalid Handle.
   346  */
   347 native CancelMenu(Handle:menu);
   348 
   349 /**
   350  * Retrieves a menu's option flags.
   351  *
   352  * @param menu				Menu Handle.
   353  * @return					A bitstring of MENUFLAG bits.
   354  * @error					Invalid Handle.
   355  */
   356 native GetMenuOptionFlags(Handle:menu);
   357 
   358 /**
   359  * Sets a menu's option flags.
   360  *
   361  * If a certain bit is not supported, it will be stripped before
   362  * being set.
   363  *
   364  * @param menu				Menu Handle.
   365  * @param flags				A new bitstring of MENUFLAG bits.
   366  * @noreturn
   367  * @error					Invalid Handle.
   368  */
   369 native SetMenuOptionFlags(Handle:menu, flags);
   370 
   371 /**
   372  * Returns whether a vote is in progress.
   373  *
   374  * @param menu				Deprecated; no longer used.
   375  * @return					True if a vote is in progress, false otherwise.
   376  */
   377 native bool:IsVoteInProgress(Handle:menu=INVALID_HANDLE);
   378 
   379 /**
   380  * Cancels the vote in progress.
   381  *
   382  * @noreturn
   383  * @error					If no vote is in progress.
   384  */
   385 native CancelVote();
   386 
   387 /**
   388  * Broadcasts a menu to a list of clients.  The most selected item will be 
   389  * returned through MenuAction_End.  On a tie, a random item will be returned 
   390  * from a list of the tied items.
   391  *
   392  * Note that MenuAction_VoteEnd and MenuAction_VoteStart are both
   393  * default callbacks and do not need to be enabled.
   394  *
   395  * @param menu				Menu Handle.
   396  * @param clients			Array of clients to broadcast to.
   397  * @param numClients		Number of clients in the array.
   398  * @param time				Maximum time to leave menu on the screen.
   399  * @return					True on success, false if this menu already has a vote session
   400  *							in progress.
   401  * @error					Invalid Handle, or a vote is already in progress.
   402  */
   403 native bool:VoteMenu(Handle:menu, clients[], numClients, time);
   404 
   405 /**
   406  * Sends a vote menu to all clients.  See VoteMenu() for more information.
   407  *
   408  * @param menu				Menu Handle.
   409  * @param time				Maximum time to leave menu on the screen.
   410  * @return					True on success, false if this menu already has a vote session
   411  *							in progress.
   412  * @error					Invalid Handle.
   413  */
   414 stock VoteMenuToAll(Handle:menu, time)
   415 {
   416 	new num = GetMaxClients();
   417 	new total;
   418 	decl players[num];
   419 	
   420 	for (new i=1; i<=num; i++)
   421 	{
   422 		if (!IsClientInGame(i))
   423 		{
   424 			continue;
   425 		}
   426 		players[total++] = i;
   427 	}
   428 	
   429 	return VoteMenu(menu, players, total, time);
   430 }
   431 /**
   432  * Callback for when a vote has ended and results are available.
   433  *
   434  * @param menu				The menu being voted on.
   435  * @param num_votes			Number of votes tallied in total.
   436  * @param num_clients		Number of clients who could vote.
   437  * @param client_info		Array of clients.  Use VOTEINFO_CLIENT_ defines.
   438  * @param num_items			Number of unique items that were selected.
   439  * @param item_info			Array of items, sorted by count.  Use VOTEINFO_ITEM
   440  *							defines.
   441  * @noreturn
   442  */
   443 functag VoteHandler public(Handle:menu,
   444 						   num_votes, 
   445 						   num_clients,
   446 						   const client_info[][2], 
   447 						   num_items,
   448 						   const item_info[][2]);	   
   449 
   450 /**
   451  * Sets an advanced vote handling callback.  If this callback is set,
   452  * MenuAction_VoteEnd will not be called.
   453  *
   454  * @param menu				Menu Handle.
   455  * @param callback			Callback function.
   456  * @noreturn
   457  * @error					Invalid Handle or callback.
   458  */
   459 native SetVoteResultCallback(Handle:menu, VoteHandler:callback);
   460 
   461 /**
   462  * Returns a style's global Handle.
   463  *
   464  * @param style			Menu Style.
   465  * @return				A Handle, or INVALID_HANDLE if not found or unusable.
   466  */
   467 native Handle:GetMenuStyleHandle(MenuStyle:style);
   468 
   469 /**
   470  * Creates a MenuPanel from a MenuStyle.  Panels are used for drawing raw 
   471  * menus without any extra helper functions.  The Handle must be closed
   472  * with CloseHandle().
   473  *
   474  * @param hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   475  * @return				A new MenuPanel Handle.
   476  * @error				Invalid Handle other than INVALID_HANDLE.
   477  */
   478 native Handle:CreatePanel(Handle:hStyle=INVALID_HANDLE);
   479 
   480 /** 
   481  * Creates a Menu from a MenuStyle.  The Handle must be closed with 
   482  * CloseHandle().
   483  *
   484  * @parma hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   485  * @param handler		Function which will receive menu actions.
   486  * @param actions		Optionally set which actions to receive.  Select, 
   487  *						Cancel, and End will always be received regardless
   488  *						of whether they are set or not.  They are also
   489  *						the only default actions.
   490  * @return				A new menu Handle.
   491  * @error				Invalid Handle other than INVALID_HANDLE.
   492  */
   493 native Handle:CreateMenuEx(Handle:hStyle=INVALID_HANDLE, MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT);
   494 
   495 /**
   496  * Returns whether a client is viewing a menu.  If the menu source 
   497  * is MenuSource_Normal, a menu Handle will also be returned.
   498  *
   499  * @param client		Client index.
   500  * @param hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   501  * @return				A MenuSource value.
   502  * @error				Invalid Handle other than INVALID_HANDLE.
   503  */
   504 native MenuSource:GetClientMenu(client, Handle:hStyle=INVALID_HANDLE);
   505 
   506 /** 
   507  * Cancels a menu on a client.  This will only affect non-external menus.
   508  *
   509  * @param hstyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   510  * @param client		Client index.
   511  * @param autoIgnore	If true, no menus can be re-drawn on the client during
   512  *						the cancellation process.
   513  * @return				True if a menu was cancelled, false otherwise.
   514  */
   515 native bool:CancelClientMenu(client, bool:autoIgnore=false, Handle:hStyle=INVALID_HANDLE);
   516 
   517 /**
   518  * Returns a style's maximum items per page.
   519  *
   520  * @param hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   521  * @return				Maximum items per page.
   522  * @error				Invalid Handle other than INVALID_HANDLE.
   523  */
   524 native GetMaxPageItems(Handle:hStyle=INVALID_HANDLE);
   525 
   526 /**
   527  * Returns a MenuPanel's parent style.
   528  *
   529  * @param panel			A MenuPanel Handle.
   530  * @return				The MenuStyle Handle that created the panel.
   531  * @error				Invalid Handle.
   532  */
   533 native Handle:GetPanelStyle(Handle:panel);
   534 
   535 /**
   536  * Sets the panel's title.
   537  *
   538  * @param panel			A MenuPanel Handle.
   539  * @param title			Text to set as the title.
   540  * @param onlyIfEmpty	If true, the title will only be set if no title is set.
   541  * @noreturn
   542  * @error				Invalid Handle.
   543  */
   544 native Handle:SetPanelTitle(Handle:panel, const String:text[], bool:onlyIfEmpty=false);
   545 
   546 /**
   547  * Draws an item on a panel.  If the item takes up a slot, the position
   548  * is returned.
   549  *
   550  * @param panel			A MenuPanel Handle.
   551  * @param text			Display text to use.  If not a raw line, 
   552  *						the style may automatically add color markup.
   553  *						No numbering or newlines are needed.
   554  * @param style			ITEMDRAW style flags.
   555  * @return				A slot position, or 0 if item was a rawline or could not be drawn.
   556  * @error				Invalid Handle.
   557  */
   558 native DrawPanelItem(Handle:panel, const String:text[], style=ITEMDRAW_DEFAULT);
   559 
   560 /**
   561  * Draws a raw line of text on a panel, without any markup other than a newline.
   562  *
   563  * @param panel			A MenuPanel Handle, or INVALID_HANDLE if inside a 
   564  *						MenuAction_DisplayItem callback.
   565  * @param text			Display text to use.
   566  * @return				True on success, false if raw lines are not supported.
   567  * @error				Invalid Handle.
   568  */
   569 native DrawPanelText(Handle:panel, const String:text[]);
   570 
   571 /**
   572  * Returns whether or not the given drawing flags are supported by
   573  * the menu style.
   574  *
   575  * @param panel			A MenuPanel Handle.
   576  * @param style			ITEMDRAW style flags.
   577  * @return				True if item is drawable, false otherwise.
   578  * @error				Invalid Handle.
   579  */
   580 native CanPanelDrawFlags(Handle:panel, style);
   581 
   582 /**
   583  * Sets the selectable key map of a panel.  This is not supported by
   584  * all styles (only by Radio, as of this writing).  
   585  *
   586  * @param keys			An integer where each bit N allows key
   587  *						N+1 to be selected.  If no keys are selectable,
   588  *						then key 0 (bit 9) is automatically set.
   589  * @return 				True if supported, false otherwise.
   590  */
   591 native bool:SetPanelKeys(Handle:panel, keys);
   592 
   593 /**
   594  * Sends a panel to a client.  Unlike full menus, the handler
   595  * function will only receive the following actions, both of 
   596  * which will have INVALID_HANDLE for a menu, and the client
   597  * as param1.
   598  *
   599  * MenuAction_Select (param2 will be the key pressed)
   600  * MenuAction_Cancel (param2 will be the reason)
   601  *
   602  * Also, if the menu fails to display, no callbacks will be called.
   603  *
   604  * @param panel			A MenuPanel Handle.
   605  * @param client		A client to draw to.
   606  * @param handler		The MenuHandler function to catch actions with.
   607  * @param time			Time to hold the menu for.
   608  * @return				True on success, false on failure.
   609  * @error				Invalid Handle.
   610  */
   611 native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time);
   612 
   613 /**
   614  * @brief Returns the current key position.
   615  *
   616  * @param panel			A MenuPanel Handle.
   617  * @return				Current key position starting at 1.
   618  * @error				Invalid Handle.
   619  */
   620 native GetPanelCurrentKey(Handle:panel);
   621 
   622 /**
   623  * @brief Sets the next key position.  This cannot be used
   624  * to traverse backwards.
   625  *
   626  * @param panel			A MenuPanel Handle.
   627  * @param key			Key that is greater or equal to
   628  *						GetPanelCurrentKey().
   629  * @return				True on success, false otherwise.
   630  * @error				Invalid Handle.
   631  */
   632 native bool:SetPanelCurrentKey(Handle:panel, key);
   633 
   634 /**
   635  * @brief Redraws menu text from inside a MenuAction_DisplayItem callback.
   636  * 
   637  * @param text			Menu text to draw.
   638  * @return				Item position; must be returned via the callback.
   639  */
   640 native RedrawMenuItem(const String:text[]);
   641 
   642 /**
   643  * Retrieves voting information from MenuAction_VoteEnd.
   644  *
   645  * @param param2		Second parameter of MenuAction_VoteEnd.
   646  * @param winningVotes	Number of votes received by the winning option.
   647  * @param totalVotes	Number of total votes received.
   648  * @noreturn
   649  */
   650 stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes)
   651 {
   652 	winningVotes = param2 & 0xFFFF;
   653 	totalVotes = param2 >> 16;
   654 }