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