plugins/include/menus.inc
author David Anderson <dvander@alliedmods.net>
Mon Oct 15 04:27:56 2007 +0000 (2007-10-15)
changeset 1573 979f2ccfee5a
parent 1484 8e3b343cbfaa
child 1594 10ed42f305e1
permissions -rw-r--r--
- LibraryExists() now works on extensions
- geoip and cstrike now work as libraries
     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  * Displays a menu to a client, starting from the given item.
   176  *
   177  * @param menu				Menu Handle.
   178  * @param client			Client index.
   179  * @param first_item		First item to begin drawing from.
   180  * @param time				Maximum time to leave menu on the screen.
   181  * @return					True on success, false on failure.
   182  * @error					Invalid Handle or client not in game.
   183  */
   184 native bool:DisplayMenuAtItem(Handle:menu, client, first_item, time);
   185 
   186 /**
   187  * Appends a new item to the end of a menu.
   188  *
   189  * @param menu				Menu Handle.
   190  * @param info				Item information string.
   191  * @param display			Default item display string.
   192  * @param style				Drawing style flags.  Anything other than DEFAULT or 
   193  *							DISABLED will be completely ignored when paginating.
   194  * @return					True on success, false on failure.
   195  * @error					Invalid Handle or item limit reached.
   196  */
   197 native AddMenuItem(Handle:menu, 
   198 					const String:info[], 
   199 					const String:display[], 
   200 					style=ITEMDRAW_DEFAULT);
   201 
   202 /**
   203  * Inserts an item into the menu before a certain position; the new item will
   204  * be at the given position and all next items pushed forward.
   205  *
   206  * @param menu				Menu Handle.
   207  * @param position			Position, starting from 0.
   208  * @param info				Item information string.
   209  * @param display			Default item display string.
   210  * @param style				Drawing style flags.  Anything other than DEFAULT or 
   211  *							DISABLED will be completely ignored when paginating.
   212  * @return					True on success, false on failure.
   213  * @error					Invalid Handle or menu position.
   214  */
   215 native bool:InsertMenuItem(Handle:menu,
   216 						position, 
   217 						const String:info[], 
   218 						const String:display[], 
   219 						style=ITEMDRAW_DEFAULT);
   220 
   221 /**
   222  * Removes an item from the menu.
   223  *
   224  * @param menu				Menu Handle.
   225  * @param position			Position, starting from 0.
   226  * @return					True on success, false on failure.
   227  * @error					Invalid Handle or menu position.
   228  */
   229 native bool:RemoveMenuItem(Handle:menu, position);
   230 
   231 /**
   232  * Removes all items from a menu.
   233  *
   234  * @param menu				Menu Handle.
   235  * @noreturn
   236  * @error					Invalid Handle or menu position.
   237  */
   238 native RemoveAllMenuItems(Handle:menu);
   239 
   240 /**
   241  * Retrieves information about a menu item.
   242  *
   243  * @param menu				Menu Handle.
   244  * @param position			Position, starting from 0.
   245  * @param infoBuf			Info buffer.
   246  * @param infoBufLen		Maximum length of the info buffer.
   247  * @param style				By-reference variable to store drawing flags.
   248  * @param dispBuf			Display buffer.
   249  * @param dispBufLen		Maximum length of the display buffer.
   250  * @return					True on success, false if position is invalid.
   251  * @error					Invalid Handle.
   252  */
   253 native bool:GetMenuItem(Handle:menu, 
   254 						position, 
   255 						String:infoBuf[], 
   256 						infoBufLen, 
   257 						&style=0, 
   258 						String:dispBuf[]="",
   259 						dispBufLen=0);
   260 						
   261 /**
   262  * Returns the first item on the page of a currently selected menu.
   263  *
   264  * This is only valid inside a MenuAction_Select callback.
   265  *
   266  * @return					First item number on the page the client was viewing 
   267  *							before selecting the item in the callback.  This can 
   268  *							be used to re-display the menu from the original 
   269  *							position.
   270  * @error					Not called from inside a MenuAction_Select callback.
   271  */
   272 native GetMenuSelectionPosition();
   273 
   274 /**
   275  * Returns the number of items in a menu.
   276  *
   277  * @param menu				Menu Handle.
   278  * @return					Number of items in the menu.
   279  * @error					Invalid Handle.
   280  */
   281 native GetMenuItemCount(Handle:menu);
   282 
   283 /**
   284  * Sets whether the menu should be paginated or not.
   285  *
   286  * @param menu				Handle to the menu.
   287  * @param itemsPerPage		Number of items per page, or MENU_NO_PAGINATION.
   288  * @return					True on success, false if pagination is too high or low.
   289  * @error					Invalid Handle.
   290  */
   291 native bool:SetMenuPagination(Handle:menu, itemsPerPage);
   292 
   293 /**
   294  * Returns a menu's pagination setting.
   295  *
   296  * @param menu				Handle to the menu.
   297  * @return					Pagination setting.
   298  * @error					Invalid Handle.
   299  */
   300 native GetMenuPagination(Handle:menu);
   301 
   302 /**
   303  * Returns a menu's MenuStyle Handle.  The Handle
   304  * is global and cannot be freed.
   305  *
   306  * @param menu				Handle to the menu.
   307  * @return 					Handle to the menu's draw style.
   308  * @error					Invalid Handle.
   309  */
   310 native Handle:GetMenuStyle(Handle:menu);
   311 
   312 /**
   313  * Sets the menu's default title/instruction message.
   314  *
   315  * @param menu				Menu Handle.
   316  * @param fmt				Message string format
   317  * @param ...				Message string arguments.
   318  * @noreturn
   319  * @error					Invalid Handle.
   320  */
   321 native SetMenuTitle(Handle:menu, const String:fmt[], any:...);
   322 
   323 /**
   324  * Returns the text of a menu's title.
   325  *
   326  * @param menu				Menu Handle.
   327  * @param buffer			Buffer to store title.
   328  * @param maxlength			Maximum length of the buffer.
   329  * @return					Number of bytes written.
   330  * @error					Invalid Handle/
   331  */
   332 native GetMenuTitle(Handle:menu, String:buffer[], maxlength);
   333 
   334 /**
   335  * Creates a raw MenuPanel based off the menu's style.
   336  * The Handle must be freed with CloseHandle().
   337  *
   338  * @return					A new MenuPanel Handle.
   339  * @error					Invalid Handle.
   340  */
   341 native Handle:CreatePanelFromMenu(Handle:menu);
   342 
   343 /**
   344  * Returns whether or not the menu has an exit button.
   345  * By default, menus have an exit button.
   346  *
   347  * @param menu				Menu Handle.
   348  * @return 					True if the menu has an exit button; false otherwise.
   349  * @error					Invalid Handle.
   350  */
   351 native bool:GetMenuExitButton(Handle:menu);
   352 
   353 /**
   354  * Sets whether or not the menu has an exit button.
   355  * By default, menus have an exit button.
   356  *
   357  * @param menu				Menu Handle.
   358  * @param button			True to enable the button, false to remove it.
   359  * @return 					True if allowed; false on failure.
   360  * @error					Invalid Handle.
   361  */
   362 native bool:SetMenuExitButton(Handle:menu, bool:button);
   363 
   364 /**
   365  * Returns whether or not the menu has an "exit back" button.
   366  * By default, menus do not have an exit back button.
   367  * Exit Back buttons appear as "Back" on page 1 of paginated menus and
   368  * have functionality defined by the user in MenuEnd_ExitBack.
   369  *
   370  * @param menu				Menu Handle.
   371  * @return 					True if the menu has an exit back button; false otherwise.
   372  * @error					Invalid Handle.
   373  */
   374 native bool:GetMenuExitBackButton(Handle:menu);
   375 
   376 /**
   377  * Sets whether or not the menu has an "exit back" button.
   378  * By default, menus do not have an exit back button.
   379  * Exit Back buttons appear as "Back" on page 1 of paginated menus and
   380  * have functionality defined by the user in MenuEnd_ExitBack.
   381  *
   382  * @param menu				Menu Handle.
   383  * @param button			True to enable the button, false to remove it.
   384  * @error					Invalid Handle.
   385  */
   386 native SetMenuExitBackButton(Handle:menu, bool:button);
   387 
   388 
   389 /**
   390  * Cancels a menu from displaying on all clients.  While the
   391  * cancellation is in progress, this menu cannot be re-displayed
   392  * to any clients.
   393  *
   394  * The menu may still exist on the client's screen after this command.
   395  * This simply verifies that the menu is not being used anywhere.
   396  *
   397  * If any vote is in progress on a menu, it will be cancelled.
   398  *
   399  * @param menu				Menu Handle.
   400  * @noreturn
   401  * @error					Invalid Handle.
   402  */
   403 native CancelMenu(Handle:menu);
   404 
   405 /**
   406  * Retrieves a menu's option flags.
   407  *
   408  * @param menu				Menu Handle.
   409  * @return					A bitstring of MENUFLAG bits.
   410  * @error					Invalid Handle.
   411  */
   412 native GetMenuOptionFlags(Handle:menu);
   413 
   414 /**
   415  * Sets a menu's option flags.
   416  *
   417  * If a certain bit is not supported, it will be stripped before
   418  * being set.
   419  *
   420  * @param menu				Menu Handle.
   421  * @param flags				A new bitstring of MENUFLAG bits.
   422  * @noreturn
   423  * @error					Invalid Handle.
   424  */
   425 native SetMenuOptionFlags(Handle:menu, flags);
   426 
   427 /**
   428  * Returns whether a vote is in progress.
   429  *
   430  * @param menu				Deprecated; no longer used.
   431  * @return					True if a vote is in progress, false otherwise.
   432  */
   433 native bool:IsVoteInProgress(Handle:menu=INVALID_HANDLE);
   434 
   435 /**
   436  * Cancels the vote in progress.
   437  *
   438  * @noreturn
   439  * @error					If no vote is in progress.
   440  */
   441 native CancelVote();
   442 
   443 /**
   444  * Broadcasts a menu to a list of clients.  The most selected item will be 
   445  * returned through MenuAction_End.  On a tie, a random item will be returned 
   446  * from a list of the tied items.
   447  *
   448  * Note that MenuAction_VoteEnd and MenuAction_VoteStart are both
   449  * default callbacks and do not need to be enabled.
   450  *
   451  * @param menu				Menu Handle.
   452  * @param clients			Array of clients to broadcast to.
   453  * @param numClients		Number of clients in the array.
   454  * @param time				Maximum time to leave menu on the screen.
   455  * @return					True on success, false if this menu already has a vote session
   456  *							in progress.
   457  * @error					Invalid Handle, or a vote is already in progress.
   458  */
   459 native bool:VoteMenu(Handle:menu, clients[], numClients, time);
   460 
   461 /**
   462  * Sends a vote menu to all clients.  See VoteMenu() for more information.
   463  *
   464  * @param menu				Menu Handle.
   465  * @param time				Maximum time to leave menu on the screen.
   466  * @return					True on success, false if this menu already has a vote session
   467  *							in progress.
   468  * @error					Invalid Handle.
   469  */
   470 stock VoteMenuToAll(Handle:menu, time)
   471 {
   472 	new num = GetMaxClients();
   473 	new total;
   474 	decl players[num];
   475 	
   476 	for (new i=1; i<=num; i++)
   477 	{
   478 		if (!IsClientInGame(i))
   479 		{
   480 			continue;
   481 		}
   482 		players[total++] = i;
   483 	}
   484 	
   485 	return VoteMenu(menu, players, total, time);
   486 }
   487 /**
   488  * Callback for when a vote has ended and results are available.
   489  *
   490  * @param menu				The menu being voted on.
   491  * @param num_votes			Number of votes tallied in total.
   492  * @param num_clients		Number of clients who could vote.
   493  * @param client_info		Array of clients.  Use VOTEINFO_CLIENT_ defines.
   494  * @param num_items			Number of unique items that were selected.
   495  * @param item_info			Array of items, sorted by count.  Use VOTEINFO_ITEM
   496  *							defines.
   497  * @noreturn
   498  */
   499 functag VoteHandler public(Handle:menu,
   500 						   num_votes, 
   501 						   num_clients,
   502 						   const client_info[][2], 
   503 						   num_items,
   504 						   const item_info[][2]);	   
   505 
   506 /**
   507  * Sets an advanced vote handling callback.  If this callback is set,
   508  * MenuAction_VoteEnd will not be called.
   509  *
   510  * @param menu				Menu Handle.
   511  * @param callback			Callback function.
   512  * @noreturn
   513  * @error					Invalid Handle or callback.
   514  */
   515 native SetVoteResultCallback(Handle:menu, VoteHandler:callback);
   516 
   517 /**
   518  * Returns the number of seconds you should "wait" before displaying
   519  * a publicly invocable menu.  This number is the time remaining until
   520  * (last_vote + sm_vote_delay).
   521  *
   522  * @return					Number of seconds to wait, or 0 for none.
   523  */
   524 native CheckVoteDelay();
   525 
   526 /**
   527  * Returns a style's global Handle.
   528  *
   529  * @param style			Menu Style.
   530  * @return				A Handle, or INVALID_HANDLE if not found or unusable.
   531  */
   532 native Handle:GetMenuStyleHandle(MenuStyle:style);
   533 
   534 /**
   535  * Creates a MenuPanel from a MenuStyle.  Panels are used for drawing raw 
   536  * menus without any extra helper functions.  The Handle must be closed
   537  * with CloseHandle().
   538  *
   539  * @param hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   540  * @return				A new MenuPanel Handle.
   541  * @error				Invalid Handle other than INVALID_HANDLE.
   542  */
   543 native Handle:CreatePanel(Handle:hStyle=INVALID_HANDLE);
   544 
   545 /** 
   546  * Creates a Menu from a MenuStyle.  The Handle must be closed with 
   547  * CloseHandle().
   548  *
   549  * @parma hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   550  * @param handler		Function which will receive menu actions.
   551  * @param actions		Optionally set which actions to receive.  Select, 
   552  *						Cancel, and End will always be received regardless
   553  *						of whether they are set or not.  They are also
   554  *						the only default actions.
   555  * @return				A new menu Handle.
   556  * @error				Invalid Handle other than INVALID_HANDLE.
   557  */
   558 native Handle:CreateMenuEx(Handle:hStyle=INVALID_HANDLE, MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT);
   559 
   560 /**
   561  * Returns whether a client is viewing a menu.  If the menu source 
   562  * is MenuSource_Normal, a menu Handle will also be returned.
   563  *
   564  * @param client		Client index.
   565  * @param hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   566  * @return				A MenuSource value.
   567  * @error				Invalid Handle other than INVALID_HANDLE.
   568  */
   569 native MenuSource:GetClientMenu(client, Handle:hStyle=INVALID_HANDLE);
   570 
   571 /** 
   572  * Cancels a menu on a client.  This will only affect non-external menus.
   573  *
   574  * @param hstyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   575  * @param client		Client index.
   576  * @param autoIgnore	If true, no menus can be re-drawn on the client during
   577  *						the cancellation process.
   578  * @return				True if a menu was cancelled, false otherwise.
   579  */
   580 native bool:CancelClientMenu(client, bool:autoIgnore=false, Handle:hStyle=INVALID_HANDLE);
   581 
   582 /**
   583  * Returns a style's maximum items per page.
   584  *
   585  * @param hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   586  * @return				Maximum items per page.
   587  * @error				Invalid Handle other than INVALID_HANDLE.
   588  */
   589 native GetMaxPageItems(Handle:hStyle=INVALID_HANDLE);
   590 
   591 /**
   592  * Returns a MenuPanel's parent style.
   593  *
   594  * @param panel			A MenuPanel Handle.
   595  * @return				The MenuStyle Handle that created the panel.
   596  * @error				Invalid Handle.
   597  */
   598 native Handle:GetPanelStyle(Handle:panel);
   599 
   600 /**
   601  * Sets the panel's title.
   602  *
   603  * @param panel			A MenuPanel Handle.
   604  * @param title			Text to set as the title.
   605  * @param onlyIfEmpty	If true, the title will only be set if no title is set.
   606  * @noreturn
   607  * @error				Invalid Handle.
   608  */
   609 native Handle:SetPanelTitle(Handle:panel, const String:text[], bool:onlyIfEmpty=false);
   610 
   611 /**
   612  * Draws an item on a panel.  If the item takes up a slot, the position
   613  * is returned.
   614  *
   615  * @param panel			A MenuPanel Handle.
   616  * @param text			Display text to use.  If not a raw line, 
   617  *						the style may automatically add color markup.
   618  *						No numbering or newlines are needed.
   619  * @param style			ITEMDRAW style flags.
   620  * @return				A slot position, or 0 if item was a rawline or could not be drawn.
   621  * @error				Invalid Handle.
   622  */
   623 native DrawPanelItem(Handle:panel, const String:text[], style=ITEMDRAW_DEFAULT);
   624 
   625 /**
   626  * Draws a raw line of text on a panel, without any markup other than a newline.
   627  *
   628  * @param panel			A MenuPanel Handle, or INVALID_HANDLE if inside a 
   629  *						MenuAction_DisplayItem callback.
   630  * @param text			Display text to use.
   631  * @return				True on success, false if raw lines are not supported.
   632  * @error				Invalid Handle.
   633  */
   634 native DrawPanelText(Handle:panel, const String:text[]);
   635 
   636 /**
   637  * Returns whether or not the given drawing flags are supported by
   638  * the menu style.
   639  *
   640  * @param panel			A MenuPanel Handle.
   641  * @param style			ITEMDRAW style flags.
   642  * @return				True if item is drawable, false otherwise.
   643  * @error				Invalid Handle.
   644  */
   645 native CanPanelDrawFlags(Handle:panel, style);
   646 
   647 /**
   648  * Sets the selectable key map of a panel.  This is not supported by
   649  * all styles (only by Radio, as of this writing).  
   650  *
   651  * @param keys			An integer where each bit N allows key
   652  *						N+1 to be selected.  If no keys are selectable,
   653  *						then key 0 (bit 9) is automatically set.
   654  * @return 				True if supported, false otherwise.
   655  */
   656 native bool:SetPanelKeys(Handle:panel, keys);
   657 
   658 /**
   659  * Sends a panel to a client.  Unlike full menus, the handler
   660  * function will only receive the following actions, both of 
   661  * which will have INVALID_HANDLE for a menu, and the client
   662  * as param1.
   663  *
   664  * MenuAction_Select (param2 will be the key pressed)
   665  * MenuAction_Cancel (param2 will be the reason)
   666  *
   667  * Also, if the menu fails to display, no callbacks will be called.
   668  *
   669  * @param panel			A MenuPanel Handle.
   670  * @param client		A client to draw to.
   671  * @param handler		The MenuHandler function to catch actions with.
   672  * @param time			Time to hold the menu for.
   673  * @return				True on success, false on failure.
   674  * @error				Invalid Handle.
   675  */
   676 native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time);
   677 
   678 /**
   679  * @brief Returns the amount of text the menu can still hold.  If this is 
   680  * limit is reached or overflowed, the text is silently truncated.  
   681  *
   682  * Radio menus: Currently 511 characters (512 bytes).
   683  * Valve menus: Currently -1 (no meaning).
   684  *
   685  * @param panel			A MenuPanel Handle.
   686  * @return				Number of characters that the menu can still hold, 
   687  *						or -1 if there is no known limit.
   688  * @error				Invalid Handle.
   689  */
   690 native GetPanelTextRemaining(Handle:panel);
   691 
   692 /**
   693  * @brief Returns the current key position.
   694  *
   695  * @param panel			A MenuPanel Handle.
   696  * @return				Current key position starting at 1.
   697  * @error				Invalid Handle.
   698  */
   699 native GetPanelCurrentKey(Handle:panel);
   700 
   701 /**
   702  * @brief Sets the next key position.  This cannot be used
   703  * to traverse backwards.
   704  *
   705  * @param panel			A MenuPanel Handle.
   706  * @param key			Key that is greater or equal to
   707  *						GetPanelCurrentKey().
   708  * @return				True on success, false otherwise.
   709  * @error				Invalid Handle.
   710  */
   711 native bool:SetPanelCurrentKey(Handle:panel, key);
   712 
   713 /**
   714  * @brief Redraws menu text from inside a MenuAction_DisplayItem callback.
   715  * 
   716  * @param text			Menu text to draw.
   717  * @return				Item position; must be returned via the callback.
   718  */
   719 native RedrawMenuItem(const String:text[]);
   720 
   721 /**
   722  * Retrieves voting information from MenuAction_VoteEnd.
   723  *
   724  * @param param2		Second parameter of MenuAction_VoteEnd.
   725  * @param winningVotes	Number of votes received by the winning option.
   726  * @param totalVotes	Number of total votes received.
   727  * @noreturn
   728  */
   729 stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes)
   730 {
   731 	winningVotes = param2 & 0xFFFF;
   732 	totalVotes = param2 >> 16;
   733 }