plugins/include/menus.inc
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/plugins/include/menus.inc	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,785 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 - * =============================================================================
     1.9 - *
    1.10 - * This file is part of the SourceMod/SourcePawn SDK.
    1.11 - *
    1.12 - * This program is free software; you can redistribute it and/or modify it under
    1.13 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 - * Free Software Foundation.
    1.15 - * 
    1.16 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 - * details.
    1.20 - *
    1.21 - * You should have received a copy of the GNU General Public License along with
    1.22 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 - *
    1.24 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 - * or <http://www.sourcemod.net/license.php>.
    1.32 - *
    1.33 - * Version: $Id$
    1.34 - */
    1.35 - 
    1.36 -#if defined _menus_included
    1.37 - #endinput
    1.38 -#endif
    1.39 -#define _menus_included
    1.40 -
    1.41 -/**
    1.42 - * Low-level drawing style of the menu.
    1.43 - */
    1.44 -enum MenuStyle
    1.45 -{
    1.46 -	MenuStyle_Default = 0,		/**< The "default" menu style for the mod */
    1.47 -	MenuStyle_Valve = 1,		/**< The Valve provided menu style (Used on HL2DM) */
    1.48 -	MenuStyle_Radio = 2,		/**< The simpler menu style commonly used on CS:S */
    1.49 -};
    1.50 -
    1.51 -/**
    1.52 - * Different actions for the menu "pump" callback
    1.53 - */
    1.54 -enum MenuAction
    1.55 -{
    1.56 -	MenuAction_Start = (1<<0),		/**< A menu has been started (nothing passed) */
    1.57 -	MenuAction_Display = (1<<1),	/**< A menu is about to be displayed (param1=client, param2=MenuPanel Handle) */
    1.58 -	MenuAction_Select = (1<<2),		/**< An item was selected (param1=client, param2=item) */
    1.59 -	MenuAction_Cancel = (1<<3),		/**< The menu was cancelled (param1=client, param2=reason) */
    1.60 -	MenuAction_End = (1<<4),		/**< A menu display has fully ended (param1=reason, param2=cancel reason) */
    1.61 -	MenuAction_VoteEnd = (1<<5),	/**< (VOTE ONLY): A vote sequence has succeeded (param1=chosen item) 
    1.62 -										 This is not called if SetVoteResultCallback has been used on the menu. */
    1.63 -	MenuAction_VoteStart = (1<<6), 	/**< (VOTE ONLY): A vote sequence has started (nothing passed) */
    1.64 -	MenuAction_VoteCancel = (1<<7),	/**< (VOTE ONLY): A vote sequence has been cancelled (param1=reason) */
    1.65 -	MenuAction_DrawItem = (1<<8),	/**< An item is being drawn; return the new style (param1=client, param2=item) */
    1.66 -	MenuAction_DisplayItem = (1<<9),/**< Item text is being drawn to the display (param1=client, param2=item)
    1.67 -										  To change the text, use RedrawMenuItem().
    1.68 -										  If you do so, return its return value.  Otherwise, return 0.
    1.69 -										  */
    1.70 -};
    1.71 -
    1.72 -/** Default menu actions */
    1.73 -#define MENU_ACTIONS_DEFAULT	MenuAction_Select|MenuAction_Cancel|MenuAction_End
    1.74 -/** All menu actions */
    1.75 -#define MENU_ACTIONS_ALL		MenuAction:0xFFFFFFFF
    1.76 -
    1.77 -#define MENU_NO_PAGINATION		0		/**< Menu should not be paginated (10 items max) */
    1.78 -#define MENU_TIME_FOREVER		0		/**< Menu should be displayed as long as possible */
    1.79 -
    1.80 -#define ITEMDRAW_DEFAULT		(0)		/**< Item should be drawn normally */
    1.81 -#define ITEMDRAW_DISABLED		(1<<0)	/**< Item is drawn but not selectable */
    1.82 -#define ITEMDRAW_RAWLINE		(1<<1)	/**< Item should be a raw line, without a slot */
    1.83 -#define ITEMDRAW_NOTEXT			(1<<2)	/**< No text should be drawn */
    1.84 -#define ITEMDRAW_SPACER			(1<<3)	/**< Item should be drawn as a spacer, if possible */
    1.85 -#define ITEMDRAW_IGNORE	((1<<1)|(1<<2))	/**< Item should be completely ignored (rawline + notext) */
    1.86 -#define ITEMDRAW_CONTROL		(1<<4)	/**< Item is control text (back/next/exit) */
    1.87 -
    1.88 -#define MENUFLAG_BUTTON_EXIT		(1<<0)	/**< Menu has an "exit" button (default if paginated) */
    1.89 -#define MENUFLAG_BUTTON_EXITBACK	(1<<1)	/**< Menu has an "exit back" button */
    1.90 -#define MENUFLAG_NO_SOUND			(1<<2)	/**< Menu will not have any select sounds */
    1.91 -
    1.92 -#define VOTEINFO_CLIENT_INDEX		0		/**< Client index */
    1.93 -#define VOTEINFO_CLIENT_ITEM		1		/**< Item the client selected, or -1 for none */
    1.94 -#define VOTEINFO_ITEM_INDEX			0		/**< Item index */
    1.95 -#define VOTEINFO_ITEM_VOTES			1		/**< Number of votes for the item */
    1.96 -
    1.97 -/**
    1.98 - * Reasons a menu can be cancelled (MenuAction_Cancel).
    1.99 - */
   1.100 -enum
   1.101 -{
   1.102 -	MenuCancel_Disconnected = -1,	/**< Client dropped from the server */
   1.103 -	MenuCancel_Interrupted = -2,	/**< Client was interrupted with another menu */
   1.104 -	MenuCancel_Exit = -3,			/**< Client exited via "exit" */
   1.105 -	MenuCancel_NoDisplay = -4,		/**< Menu could not be displayed to the client */
   1.106 -	MenuCancel_Timeout = -5,		/**< Menu timed out */
   1.107 -	MenuCancel_ExitBack = -6,		/**< Client selected "exit back" on a paginated menu */
   1.108 -};
   1.109 -
   1.110 -/**
   1.111 - * Reasons a vote can be cancelled (MenuAction_VoteCancel).
   1.112 - */
   1.113 -enum
   1.114 -{
   1.115 -	VoteCancel_Generic = -1,		/**< Vote was generically cancelled. */
   1.116 -	VoteCancel_NoVotes = -2,		/**< Vote did not receive any votes. */
   1.117 -};
   1.118 -
   1.119 -/**
   1.120 - * Reasons a menu ended (MenuAction_End).
   1.121 - */
   1.122 -enum
   1.123 -{
   1.124 -	MenuEnd_Selected = 0,			/**< Menu item was selected */
   1.125 -	MenuEnd_VotingDone = -1,		/**< Voting finished */
   1.126 -	MenuEnd_VotingCancelled = -2,	/**< Voting was cancelled */
   1.127 -	MenuEnd_Cancelled = -3,			/**< Menu was cancelled (reason in param2) */
   1.128 -	MenuEnd_Exit = -4,				/**< Menu was cleanly exited via "exit" */
   1.129 -	MenuEnd_ExitBack = -5,			/**< Menu was cleanly exited via "back" */
   1.130 -};
   1.131 -
   1.132 -/**
   1.133 - * Describes a menu's source
   1.134 - */
   1.135 -enum MenuSource
   1.136 -{
   1.137 -	MenuSource_None = 0,			/**< No menu is being displayed */	
   1.138 -	MenuSource_External = 1,		/**< External menu */
   1.139 -	MenuSource_Normal = 2,			/**< A basic menu is being displayed */
   1.140 -	MenuSource_RawPanel = 3,		/**< A display is active, but it is not tied to a menu */
   1.141 -};
   1.142 -
   1.143 -/**
   1.144 - * Called when a menu action is completed.
   1.145 - *
   1.146 - * @param menu				The menu being acted upon.
   1.147 - * @param action			The action of the menu.
   1.148 - * @param param1			First action parameter (usually the client).
   1.149 - * @param param2			Second action parameter (usually the item).
   1.150 - * @noreturn
   1.151 - */
   1.152 -functag MenuHandler public(Handle:menu, MenuAction:action, param1, param2);
   1.153 -
   1.154 -/**
   1.155 - * Creates a new, empty menu using the default style.
   1.156 - * 
   1.157 - * @param handler			Function which will receive menu actions.
   1.158 - * @param actions			Optionally set which actions to receive.  Select, 
   1.159 - *							Cancel, and End will always be received regardless
   1.160 - *							of whether they are set or not.  They are also
   1.161 - *							the only default actions.
   1.162 - * @return					A new menu Handle.
   1.163 - */
   1.164 -native Handle:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT);
   1.165 -
   1.166 -/**
   1.167 - * Displays a menu to a client.
   1.168 - *
   1.169 - * @param menu				Menu Handle.
   1.170 - * @param client			Client index.
   1.171 - * @param time				Maximum time to leave menu on the screen.
   1.172 - * @return					True on success, false on failure.
   1.173 - * @error					Invalid Handle or client not in game.
   1.174 - */
   1.175 -native bool:DisplayMenu(Handle:menu, client, time);
   1.176 -
   1.177 -/**
   1.178 - * Displays a menu to a client, starting from the given item.
   1.179 - *
   1.180 - * @param menu				Menu Handle.
   1.181 - * @param client			Client index.
   1.182 - * @param first_item		First item to begin drawing from.
   1.183 - * @param time				Maximum time to leave menu on the screen.
   1.184 - * @return					True on success, false on failure.
   1.185 - * @error					Invalid Handle or client not in game.
   1.186 - */
   1.187 -native bool:DisplayMenuAtItem(Handle:menu, client, first_item, time);
   1.188 -
   1.189 -/**
   1.190 - * Appends a new item to the end of a menu.
   1.191 - *
   1.192 - * @param menu				Menu Handle.
   1.193 - * @param info				Item information string.
   1.194 - * @param display			Default item display string.
   1.195 - * @param style				Drawing style flags.  Anything other than DEFAULT or 
   1.196 - *							DISABLED will be completely ignored when paginating.
   1.197 - * @return					True on success, false on failure.
   1.198 - * @error					Invalid Handle or item limit reached.
   1.199 - */
   1.200 -native AddMenuItem(Handle:menu, 
   1.201 -					const String:info[], 
   1.202 -					const String:display[], 
   1.203 -					style=ITEMDRAW_DEFAULT);
   1.204 -
   1.205 -/**
   1.206 - * Inserts an item into the menu before a certain position; the new item will
   1.207 - * be at the given position and all next items pushed forward.
   1.208 - *
   1.209 - * @param menu				Menu Handle.
   1.210 - * @param position			Position, starting from 0.
   1.211 - * @param info				Item information string.
   1.212 - * @param display			Default item display string.
   1.213 - * @param style				Drawing style flags.  Anything other than DEFAULT or 
   1.214 - *							DISABLED will be completely ignored when paginating.
   1.215 - * @return					True on success, false on failure.
   1.216 - * @error					Invalid Handle or menu position.
   1.217 - */
   1.218 -native bool:InsertMenuItem(Handle:menu,
   1.219 -						position, 
   1.220 -						const String:info[], 
   1.221 -						const String:display[], 
   1.222 -						style=ITEMDRAW_DEFAULT);
   1.223 -
   1.224 -/**
   1.225 - * Removes an item from the menu.
   1.226 - *
   1.227 - * @param menu				Menu Handle.
   1.228 - * @param position			Position, starting from 0.
   1.229 - * @return					True on success, false on failure.
   1.230 - * @error					Invalid Handle or menu position.
   1.231 - */
   1.232 -native bool:RemoveMenuItem(Handle:menu, position);
   1.233 -
   1.234 -/**
   1.235 - * Removes all items from a menu.
   1.236 - *
   1.237 - * @param menu				Menu Handle.
   1.238 - * @noreturn
   1.239 - * @error					Invalid Handle or menu position.
   1.240 - */
   1.241 -native RemoveAllMenuItems(Handle:menu);
   1.242 -
   1.243 -/**
   1.244 - * Retrieves information about a menu item.
   1.245 - *
   1.246 - * @param menu				Menu Handle.
   1.247 - * @param position			Position, starting from 0.
   1.248 - * @param infoBuf			Info buffer.
   1.249 - * @param infoBufLen		Maximum length of the info buffer.
   1.250 - * @param style				By-reference variable to store drawing flags.
   1.251 - * @param dispBuf			Display buffer.
   1.252 - * @param dispBufLen		Maximum length of the display buffer.
   1.253 - * @return					True on success, false if position is invalid.
   1.254 - * @error					Invalid Handle.
   1.255 - */
   1.256 -native bool:GetMenuItem(Handle:menu, 
   1.257 -						position, 
   1.258 -						String:infoBuf[], 
   1.259 -						infoBufLen, 
   1.260 -						&style=0, 
   1.261 -						String:dispBuf[]="",
   1.262 -						dispBufLen=0);
   1.263 -						
   1.264 -/**
   1.265 - * Returns the first item on the page of a currently selected menu.
   1.266 - *
   1.267 - * This is only valid inside a MenuAction_Select callback.
   1.268 - *
   1.269 - * @return					First item number on the page the client was viewing 
   1.270 - *							before selecting the item in the callback.  This can 
   1.271 - *							be used to re-display the menu from the original 
   1.272 - *							position.
   1.273 - * @error					Not called from inside a MenuAction_Select callback.
   1.274 - */
   1.275 -native GetMenuSelectionPosition();
   1.276 -
   1.277 -/**
   1.278 - * Returns the number of items in a menu.
   1.279 - *
   1.280 - * @param menu				Menu Handle.
   1.281 - * @return					Number of items in the menu.
   1.282 - * @error					Invalid Handle.
   1.283 - */
   1.284 -native GetMenuItemCount(Handle:menu);
   1.285 -
   1.286 -/**
   1.287 - * Sets whether the menu should be paginated or not.
   1.288 - *
   1.289 - * If itemsPerPage is MENU_NO_PAGINATION, and the exit button flag is set, 
   1.290 - * then the exit button flag is removed.  It can be re-applied if desired.
   1.291 - *
   1.292 - * @param menu				Handle to the menu.
   1.293 - * @param itemsPerPage		Number of items per page, or MENU_NO_PAGINATION.
   1.294 - * @return					True on success, false if pagination is too high or 
   1.295 - *							low.
   1.296 - * @error					Invalid Handle.
   1.297 - */
   1.298 -native bool:SetMenuPagination(Handle:menu, itemsPerPage);
   1.299 -
   1.300 -/**
   1.301 - * Returns a menu's pagination setting.
   1.302 - *
   1.303 - * @param menu				Handle to the menu.
   1.304 - * @return					Pagination setting.
   1.305 - * @error					Invalid Handle.
   1.306 - */
   1.307 -native GetMenuPagination(Handle:menu);
   1.308 -
   1.309 -/**
   1.310 - * Returns a menu's MenuStyle Handle.  The Handle
   1.311 - * is global and cannot be freed.
   1.312 - *
   1.313 - * @param menu				Handle to the menu.
   1.314 - * @return 					Handle to the menu's draw style.
   1.315 - * @error					Invalid Handle.
   1.316 - */
   1.317 -native Handle:GetMenuStyle(Handle:menu);
   1.318 -
   1.319 -/**
   1.320 - * Sets the menu's default title/instruction message.
   1.321 - *
   1.322 - * @param menu				Menu Handle.
   1.323 - * @param fmt				Message string format
   1.324 - * @param ...				Message string arguments.
   1.325 - * @noreturn
   1.326 - * @error					Invalid Handle.
   1.327 - */
   1.328 -native SetMenuTitle(Handle:menu, const String:fmt[], any:...);
   1.329 -
   1.330 -/**
   1.331 - * Returns the text of a menu's title.
   1.332 - *
   1.333 - * @param menu				Menu Handle.
   1.334 - * @param buffer			Buffer to store title.
   1.335 - * @param maxlength			Maximum length of the buffer.
   1.336 - * @return					Number of bytes written.
   1.337 - * @error					Invalid Handle/
   1.338 - */
   1.339 -native GetMenuTitle(Handle:menu, String:buffer[], maxlength);
   1.340 -
   1.341 -/**
   1.342 - * Creates a raw MenuPanel based off the menu's style.
   1.343 - * The Handle must be freed with CloseHandle().
   1.344 - *
   1.345 - * @return					A new MenuPanel Handle.
   1.346 - * @error					Invalid Handle.
   1.347 - */
   1.348 -native Handle:CreatePanelFromMenu(Handle:menu);
   1.349 -
   1.350 -/**
   1.351 - * Returns whether or not the menu has an exit button.
   1.352 - * By default, menus have an exit button.
   1.353 - *
   1.354 - * @param menu				Menu Handle.
   1.355 - * @return 					True if the menu has an exit button; false otherwise.
   1.356 - * @error					Invalid Handle.
   1.357 - */
   1.358 -native bool:GetMenuExitButton(Handle:menu);
   1.359 -
   1.360 -/**
   1.361 - * Sets whether or not the menu has an exit button.  By default, paginated menus 
   1.362 - * have an exit button.
   1.363 - *
   1.364 - * If a menu's pagination is changed to MENU_NO_PAGINATION, and the pagination 
   1.365 - * was previously a different value, then the Exit button status is changed to 
   1.366 - * false.  It must be explicitly re-enabled afterwards.
   1.367 - *
   1.368 - * If a non-paginated menu has an exit button, then at most 9 items will be 
   1.369 - * displayed.
   1.370 - *
   1.371 - * @param menu				Menu Handle.
   1.372 - * @param button			True to enable the button, false to remove it.
   1.373 - * @return 					True if allowed; false on failure.
   1.374 - * @error					Invalid Handle.
   1.375 - */
   1.376 -native bool:SetMenuExitButton(Handle:menu, bool:button);
   1.377 -
   1.378 -/**
   1.379 - * Returns whether or not the menu has an "exit back" button.  By default, 
   1.380 - * menus do not have an exit back button.  
   1.381 - *
   1.382 - * Exit Back buttons appear as "Back" on page 1 of paginated menus and have 
   1.383 - * functionality defined by the user in MenuEnd_ExitBack.
   1.384 - *
   1.385 - * @param menu				Menu Handle.
   1.386 - * @return 					True if the menu has an exit back button; false otherwise.
   1.387 - * @error					Invalid Handle.
   1.388 - */
   1.389 -native bool:GetMenuExitBackButton(Handle:menu);
   1.390 -
   1.391 -/**
   1.392 - * Sets whether or not the menu has an "exit back" button. By default, menus 
   1.393 - * do not have an exit back button.
   1.394 - *
   1.395 - * Exit Back buttons appear as "Back" on page 1 of paginated menus and have 
   1.396 - * functionality defined by the user in MenuEnd_ExitBack.
   1.397 - *
   1.398 - * @param menu				Menu Handle.
   1.399 - * @param button			True to enable the button, false to remove it.
   1.400 - * @error					Invalid Handle.
   1.401 - */
   1.402 -native SetMenuExitBackButton(Handle:menu, bool:button);
   1.403 -
   1.404 -
   1.405 -/**
   1.406 - * Cancels a menu from displaying on all clients.  While the
   1.407 - * cancellation is in progress, this menu cannot be re-displayed
   1.408 - * to any clients.
   1.409 - *
   1.410 - * The menu may still exist on the client's screen after this command.
   1.411 - * This simply verifies that the menu is not being used anywhere.
   1.412 - *
   1.413 - * If any vote is in progress on a menu, it will be cancelled.
   1.414 - *
   1.415 - * @param menu				Menu Handle.
   1.416 - * @noreturn
   1.417 - * @error					Invalid Handle.
   1.418 - */
   1.419 -native CancelMenu(Handle:menu);
   1.420 -
   1.421 -/**
   1.422 - * Retrieves a menu's option flags.
   1.423 - *
   1.424 - * @param menu				Menu Handle.
   1.425 - * @return					A bitstring of MENUFLAG bits.
   1.426 - * @error					Invalid Handle.
   1.427 - */
   1.428 -native GetMenuOptionFlags(Handle:menu);
   1.429 -
   1.430 -/**
   1.431 - * Sets a menu's option flags.
   1.432 - *
   1.433 - * If a certain bit is not supported, it will be stripped before being set.
   1.434 - * See SetMenuExitButton() for information on Exit buttons.
   1.435 - * See SetMenuExitBackButton() for information on Exit Back buttons.
   1.436 - *
   1.437 - * @param menu				Menu Handle.
   1.438 - * @param flags				A new bitstring of MENUFLAG bits.
   1.439 - * @noreturn
   1.440 - * @error					Invalid Handle.
   1.441 - */
   1.442 -native SetMenuOptionFlags(Handle:menu, flags);
   1.443 -
   1.444 -/**
   1.445 - * Returns whether a vote is in progress.
   1.446 - *
   1.447 - * @param menu				Deprecated; no longer used.
   1.448 - * @return					True if a vote is in progress, false otherwise.
   1.449 - */
   1.450 -native bool:IsVoteInProgress(Handle:menu=INVALID_HANDLE);
   1.451 -
   1.452 -/**
   1.453 - * Cancels the vote in progress.
   1.454 - *
   1.455 - * @noreturn
   1.456 - * @error					If no vote is in progress.
   1.457 - */
   1.458 -native CancelVote();
   1.459 -
   1.460 -/**
   1.461 - * Broadcasts a menu to a list of clients.  The most selected item will be 
   1.462 - * returned through MenuAction_End.  On a tie, a random item will be returned 
   1.463 - * from a list of the tied items.
   1.464 - *
   1.465 - * Note that MenuAction_VoteEnd and MenuAction_VoteStart are both
   1.466 - * default callbacks and do not need to be enabled.
   1.467 - *
   1.468 - * @param menu				Menu Handle.
   1.469 - * @param clients			Array of clients to broadcast to.
   1.470 - * @param numClients		Number of clients in the array.
   1.471 - * @param time				Maximum time to leave menu on the screen.
   1.472 - * @return					True on success, false if this menu already has a vote session
   1.473 - *							in progress.
   1.474 - * @error					Invalid Handle, or a vote is already in progress.
   1.475 - */
   1.476 -native bool:VoteMenu(Handle:menu, clients[], numClients, time);
   1.477 -
   1.478 -/**
   1.479 - * Sends a vote menu to all clients.  See VoteMenu() for more information.
   1.480 - *
   1.481 - * @param menu				Menu Handle.
   1.482 - * @param time				Maximum time to leave menu on the screen.
   1.483 - * @return					True on success, false if this menu already has a vote session
   1.484 - *							in progress.
   1.485 - * @error					Invalid Handle.
   1.486 - */
   1.487 -stock VoteMenuToAll(Handle:menu, time)
   1.488 -{
   1.489 -	new num = GetMaxClients();
   1.490 -	new total;
   1.491 -	decl players[num];
   1.492 -	
   1.493 -	for (new i=1; i<=num; i++)
   1.494 -	{
   1.495 -		if (!IsClientInGame(i))
   1.496 -		{
   1.497 -			continue;
   1.498 -		}
   1.499 -		players[total++] = i;
   1.500 -	}
   1.501 -	
   1.502 -	return VoteMenu(menu, players, total, time);
   1.503 -}
   1.504 -/**
   1.505 - * Callback for when a vote has ended and results are available.
   1.506 - *
   1.507 - * @param menu				The menu being voted on.
   1.508 - * @param num_votes			Number of votes tallied in total.
   1.509 - * @param num_clients		Number of clients who could vote.
   1.510 - * @param client_info		Array of clients.  Use VOTEINFO_CLIENT_ defines.
   1.511 - * @param num_items			Number of unique items that were selected.
   1.512 - * @param item_info			Array of items, sorted by count.  Use VOTEINFO_ITEM
   1.513 - *							defines.
   1.514 - * @noreturn
   1.515 - */
   1.516 -functag VoteHandler public(Handle:menu,
   1.517 -						   num_votes, 
   1.518 -						   num_clients,
   1.519 -						   const client_info[][2], 
   1.520 -						   num_items,
   1.521 -						   const item_info[][2]);	   
   1.522 -
   1.523 -/**
   1.524 - * Sets an advanced vote handling callback.  If this callback is set,
   1.525 - * MenuAction_VoteEnd will not be called.
   1.526 - *
   1.527 - * @param menu				Menu Handle.
   1.528 - * @param callback			Callback function.
   1.529 - * @noreturn
   1.530 - * @error					Invalid Handle or callback.
   1.531 - */
   1.532 -native SetVoteResultCallback(Handle:menu, VoteHandler:callback);
   1.533 -
   1.534 -/**
   1.535 - * Returns the number of seconds you should "wait" before displaying
   1.536 - * a publicly invocable menu.  This number is the time remaining until
   1.537 - * (last_vote + sm_vote_delay).
   1.538 - *
   1.539 - * @return					Number of seconds to wait, or 0 for none.
   1.540 - */
   1.541 -native CheckVoteDelay();
   1.542 -
   1.543 -/**
   1.544 - * Returns a style's global Handle.
   1.545 - *
   1.546 - * @param style			Menu Style.
   1.547 - * @return				A Handle, or INVALID_HANDLE if not found or unusable.
   1.548 - */
   1.549 -native Handle:GetMenuStyleHandle(MenuStyle:style);
   1.550 -
   1.551 -/**
   1.552 - * Creates a MenuPanel from a MenuStyle.  Panels are used for drawing raw 
   1.553 - * menus without any extra helper functions.  The Handle must be closed
   1.554 - * with CloseHandle().
   1.555 - *
   1.556 - * @param hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   1.557 - * @return				A new MenuPanel Handle.
   1.558 - * @error				Invalid Handle other than INVALID_HANDLE.
   1.559 - */
   1.560 -native Handle:CreatePanel(Handle:hStyle=INVALID_HANDLE);
   1.561 -
   1.562 -/** 
   1.563 - * Creates a Menu from a MenuStyle.  The Handle must be closed with 
   1.564 - * CloseHandle().
   1.565 - *
   1.566 - * @parma hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   1.567 - * @param handler		Function which will receive menu actions.
   1.568 - * @param actions		Optionally set which actions to receive.  Select, 
   1.569 - *						Cancel, and End will always be received regardless
   1.570 - *						of whether they are set or not.  They are also
   1.571 - *						the only default actions.
   1.572 - * @return				A new menu Handle.
   1.573 - * @error				Invalid Handle other than INVALID_HANDLE.
   1.574 - */
   1.575 -native Handle:CreateMenuEx(Handle:hStyle=INVALID_HANDLE, MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT);
   1.576 -
   1.577 -/**
   1.578 - * Returns whether a client is viewing a menu.  If the menu source 
   1.579 - * is MenuSource_Normal, a menu Handle will also be returned.
   1.580 - *
   1.581 - * @param client		Client index.
   1.582 - * @param hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   1.583 - * @return				A MenuSource value.
   1.584 - * @error				Invalid Handle other than INVALID_HANDLE.
   1.585 - */
   1.586 -native MenuSource:GetClientMenu(client, Handle:hStyle=INVALID_HANDLE);
   1.587 -
   1.588 -/** 
   1.589 - * Cancels a menu on a client.  This will only affect non-external menus.
   1.590 - *
   1.591 - * @param hstyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   1.592 - * @param client		Client index.
   1.593 - * @param autoIgnore	If true, no menus can be re-drawn on the client during
   1.594 - *						the cancellation process.
   1.595 - * @return				True if a menu was cancelled, false otherwise.
   1.596 - */
   1.597 -native bool:CancelClientMenu(client, bool:autoIgnore=false, Handle:hStyle=INVALID_HANDLE);
   1.598 -
   1.599 -/**
   1.600 - * Returns a style's maximum items per page.
   1.601 - *
   1.602 - * @param hStyle		MenuStyle Handle, or INVALID_HANDLE to use the default style.
   1.603 - * @return				Maximum items per page.
   1.604 - * @error				Invalid Handle other than INVALID_HANDLE.
   1.605 - */
   1.606 -native GetMaxPageItems(Handle:hStyle=INVALID_HANDLE);
   1.607 -
   1.608 -/**
   1.609 - * Returns a MenuPanel's parent style.
   1.610 - *
   1.611 - * @param panel			A MenuPanel Handle.
   1.612 - * @return				The MenuStyle Handle that created the panel.
   1.613 - * @error				Invalid Handle.
   1.614 - */
   1.615 -native Handle:GetPanelStyle(Handle:panel);
   1.616 -
   1.617 -/**
   1.618 - * Sets the panel's title.
   1.619 - *
   1.620 - * @param panel			A MenuPanel Handle.
   1.621 - * @param title			Text to set as the title.
   1.622 - * @param onlyIfEmpty	If true, the title will only be set if no title is set.
   1.623 - * @noreturn
   1.624 - * @error				Invalid Handle.
   1.625 - */
   1.626 -native Handle:SetPanelTitle(Handle:panel, const String:text[], bool:onlyIfEmpty=false);
   1.627 -
   1.628 -/**
   1.629 - * Draws an item on a panel.  If the item takes up a slot, the position
   1.630 - * is returned.
   1.631 - *
   1.632 - * @param panel			A MenuPanel Handle.
   1.633 - * @param text			Display text to use.  If not a raw line, 
   1.634 - *						the style may automatically add color markup.
   1.635 - *						No numbering or newlines are needed.
   1.636 - * @param style			ITEMDRAW style flags.
   1.637 - * @return				A slot position, or 0 if item was a rawline or could not be drawn.
   1.638 - * @error				Invalid Handle.
   1.639 - */
   1.640 -native DrawPanelItem(Handle:panel, const String:text[], style=ITEMDRAW_DEFAULT);
   1.641 -
   1.642 -/**
   1.643 - * Draws a raw line of text on a panel, without any markup other than a newline.
   1.644 - *
   1.645 - * @param panel			A MenuPanel Handle, or INVALID_HANDLE if inside a 
   1.646 - *						MenuAction_DisplayItem callback.
   1.647 - * @param text			Display text to use.
   1.648 - * @return				True on success, false if raw lines are not supported.
   1.649 - * @error				Invalid Handle.
   1.650 - */
   1.651 -native DrawPanelText(Handle:panel, const String:text[]);
   1.652 -
   1.653 -/**
   1.654 - * Returns whether or not the given drawing flags are supported by
   1.655 - * the menu style.
   1.656 - *
   1.657 - * @param panel			A MenuPanel Handle.
   1.658 - * @param style			ITEMDRAW style flags.
   1.659 - * @return				True if item is drawable, false otherwise.
   1.660 - * @error				Invalid Handle.
   1.661 - */
   1.662 -native CanPanelDrawFlags(Handle:panel, style);
   1.663 -
   1.664 -/**
   1.665 - * Sets the selectable key map of a panel.  This is not supported by
   1.666 - * all styles (only by Radio, as of this writing).  
   1.667 - *
   1.668 - * @param keys			An integer where each bit N allows key
   1.669 - *						N+1 to be selected.  If no keys are selectable,
   1.670 - *						then key 0 (bit 9) is automatically set.
   1.671 - * @return 				True if supported, false otherwise.
   1.672 - */
   1.673 -native bool:SetPanelKeys(Handle:panel, keys);
   1.674 -
   1.675 -/**
   1.676 - * Sends a panel to a client.  Unlike full menus, the handler
   1.677 - * function will only receive the following actions, both of 
   1.678 - * which will have INVALID_HANDLE for a menu, and the client
   1.679 - * as param1.
   1.680 - *
   1.681 - * MenuAction_Select (param2 will be the key pressed)
   1.682 - * MenuAction_Cancel (param2 will be the reason)
   1.683 - *
   1.684 - * Also, if the menu fails to display, no callbacks will be called.
   1.685 - *
   1.686 - * @param panel			A MenuPanel Handle.
   1.687 - * @param client		A client to draw to.
   1.688 - * @param handler		The MenuHandler function to catch actions with.
   1.689 - * @param time			Time to hold the menu for.
   1.690 - * @return				True on success, false on failure.
   1.691 - * @error				Invalid Handle.
   1.692 - */
   1.693 -native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time);
   1.694 -
   1.695 -/**
   1.696 - * @brief Returns the amount of text the menu can still hold.  If this is 
   1.697 - * limit is reached or overflowed, the text is silently truncated.  
   1.698 - *
   1.699 - * Radio menus: Currently 511 characters (512 bytes).
   1.700 - * Valve menus: Currently -1 (no meaning).
   1.701 - *
   1.702 - * @param panel			A MenuPanel Handle.
   1.703 - * @return				Number of characters that the menu can still hold, 
   1.704 - *						or -1 if there is no known limit.
   1.705 - * @error				Invalid Handle.
   1.706 - */
   1.707 -native GetPanelTextRemaining(Handle:panel);
   1.708 -
   1.709 -/**
   1.710 - * @brief Returns the current key position.
   1.711 - *
   1.712 - * @param panel			A MenuPanel Handle.
   1.713 - * @return				Current key position starting at 1.
   1.714 - * @error				Invalid Handle.
   1.715 - */
   1.716 -native GetPanelCurrentKey(Handle:panel);
   1.717 -
   1.718 -/**
   1.719 - * @brief Sets the next key position.  This cannot be used
   1.720 - * to traverse backwards.
   1.721 - *
   1.722 - * @param panel			A MenuPanel Handle.
   1.723 - * @param key			Key that is greater or equal to
   1.724 - *						GetPanelCurrentKey().
   1.725 - * @return				True on success, false otherwise.
   1.726 - * @error				Invalid Handle.
   1.727 - */
   1.728 -native bool:SetPanelCurrentKey(Handle:panel, key);
   1.729 -
   1.730 -/**
   1.731 - * @brief Redraws menu text from inside a MenuAction_DisplayItem callback.
   1.732 - * 
   1.733 - * @param text			Menu text to draw.
   1.734 - * @return				Item position; must be returned via the callback.
   1.735 - */
   1.736 -native RedrawMenuItem(const String:text[]);
   1.737 -
   1.738 -/**
   1.739 - * This function is provided for legacy code only.  Some older plugins may use 
   1.740 - * network messages instead of the panel API.  This function wraps the panel 
   1.741 - * API for eased portability into the SourceMod menu system.  
   1.742 - *
   1.743 - * This function is only usable with the Radio Menu style.  You do not need to 
   1.744 - * split up your menu into multiple packets; SourceMod will break the string 
   1.745 - * up internally.
   1.746 - *
   1.747 - * @param client		Client index.
   1.748 - * @param str			Full menu string as would be passed over the network. 
   1.749 - * @param time			Time to hold the menu for.
   1.750 - * @param keys			Selectable key bitstring.
   1.751 - * @param handler		Optional handler function, with the same rules as
   1.752 - *						SendPanelToClient().
   1.753 - * @return				True on success, false on failure.
   1.754 - * @error				Invalid client index, or radio menus not supported.
   1.755 - */
   1.756 -native bool:InternalShowMenu(client, const String:str[], time, keys=-1, MenuHandler:handler=MenuHandler:-1);
   1.757 -
   1.758 -/**
   1.759 - * Retrieves voting information from MenuAction_VoteEnd.
   1.760 - *
   1.761 - * @param param2		Second parameter of MenuAction_VoteEnd.
   1.762 - * @param winningVotes	Number of votes received by the winning option.
   1.763 - * @param totalVotes	Number of total votes received.
   1.764 - * @noreturn
   1.765 - */
   1.766 -stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes)
   1.767 -{
   1.768 -	winningVotes = param2 & 0xFFFF;
   1.769 -	totalVotes = param2 >> 16;
   1.770 -}
   1.771 -
   1.772 -/**
   1.773 - * Quick stock to determine whether voting is allowed.  This doesn't let you 
   1.774 - * fine-tune a reason for not voting, so it's not recommended for lazily 
   1.775 - * telling clients that voting isn't allowed.
   1.776 - * 
   1.777 - * @return				True if voting is allowed, false if voting is in progress
   1.778 - *						or the cooldown is active.
   1.779 - */
   1.780 -stock bool:IsNewVoteAllowed()
   1.781 -{
   1.782 -	if (IsVoteInProgress() || CheckVoteDelay() != 0)
   1.783 -	{
   1.784 -		return false;
   1.785 -	}
   1.786 -	
   1.787 -	return true;
   1.788 -}