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