2008-10-04 22:59:11 +02:00
|
|
|
/**
|
2015-03-21 15:43:24 +01:00
|
|
|
* vim: set ts=4 sw=4 tw=99 noet :
|
2008-10-04 22:59:11 +02:00
|
|
|
* =============================================================================
|
2015-03-21 15:43:24 +01:00
|
|
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
2008-10-04 22:59:11 +02:00
|
|
|
* =============================================================================
|
|
|
|
*
|
|
|
|
* This file is part of the SourceMod/SourcePawn SDK.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
|
|
* Free Software Foundation.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
2008-10-04 22:59:11 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
|
|
*
|
2009-04-14 23:40:48 +02:00
|
|
|
* Version: $Id$
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2019-09-27 13:14:44 +02:00
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
#if defined _menus_included
|
|
|
|
#endinput
|
|
|
|
#endif
|
|
|
|
#define _menus_included
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Low-level drawing style of the menu.
|
|
|
|
*/
|
|
|
|
enum MenuStyle
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
MenuStyle_Default = 0, /**< The "default" menu style for the mod */
|
|
|
|
MenuStyle_Valve = 1, /**< The Valve provided menu style (Used on HL2DM) */
|
|
|
|
MenuStyle_Radio = 2 /**< The simpler menu style commonly used on CS:S */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Different actions for the menu "pump" callback
|
|
|
|
*/
|
|
|
|
enum MenuAction
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
MenuAction_Start = (1<<0), /**< A menu has been started (nothing passed) */
|
|
|
|
MenuAction_Display = (1<<1), /**< A menu is about to be displayed (param1=client, param2=MenuPanel Handle) */
|
|
|
|
MenuAction_Select = (1<<2), /**< An item was selected (param1=client, param2=item) */
|
|
|
|
MenuAction_Cancel = (1<<3), /**< The menu was cancelled (param1=client, param2=reason) */
|
|
|
|
MenuAction_End = (1<<4), /**< A menu display has fully ended.
|
|
|
|
param1 is the MenuEnd reason, and if it's MenuEnd_Cancelled, then
|
|
|
|
param2 is the MenuCancel reason from MenuAction_Cancel. */
|
|
|
|
MenuAction_VoteEnd = (1<<5), /**< (VOTE ONLY): A vote sequence has succeeded (param1=chosen item)
|
|
|
|
This is not called if SetVoteResultCallback has been used on the menu. */
|
|
|
|
MenuAction_VoteStart = (1<<6), /**< (VOTE ONLY): A vote sequence has started (nothing passed) */
|
|
|
|
MenuAction_VoteCancel = (1<<7), /**< (VOTE ONLY): A vote sequence has been cancelled (param1=reason) */
|
|
|
|
MenuAction_DrawItem = (1<<8), /**< An item is being drawn; return the new style (param1=client, param2=item) */
|
|
|
|
MenuAction_DisplayItem = (1<<9) /**< Item text is being drawn to the display (param1=client, param2=item)
|
|
|
|
To change the text, use RedrawMenuItem().
|
|
|
|
If you do so, return its return value. Otherwise, return 0. */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Default menu actions */
|
2019-09-27 13:14:44 +02:00
|
|
|
#define MENU_ACTIONS_DEFAULT MenuAction_Select|MenuAction_Cancel|MenuAction_End
|
2008-10-04 22:59:11 +02:00
|
|
|
/** All menu actions */
|
2019-09-27 13:14:44 +02:00
|
|
|
#define MENU_ACTIONS_ALL view_as<MenuAction>(0xFFFFFFFF)
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
#define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */
|
|
|
|
#define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
#define ITEMDRAW_DEFAULT (0) /**< Item should be drawn normally */
|
|
|
|
#define ITEMDRAW_DISABLED (1<<0) /**< Item is drawn but not selectable */
|
|
|
|
#define ITEMDRAW_RAWLINE (1<<1) /**< Item should be a raw line, without a slot */
|
|
|
|
#define ITEMDRAW_NOTEXT (1<<2) /**< No text should be drawn */
|
|
|
|
#define ITEMDRAW_SPACER (1<<3) /**< Item should be drawn as a spacer, if possible */
|
|
|
|
#define ITEMDRAW_IGNORE ((1<<1)|(1<<2)) /**< Item should be completely ignored (rawline + notext) */
|
|
|
|
#define ITEMDRAW_CONTROL (1<<4) /**< Item is control text (back/next/exit) */
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
#define MENUFLAG_BUTTON_EXIT (1<<0) /**< Menu has an "exit" button (default if paginated) */
|
|
|
|
#define MENUFLAG_BUTTON_EXITBACK (1<<1) /**< Menu has an "exit back" button */
|
|
|
|
#define MENUFLAG_NO_SOUND (1<<2) /**< Menu will not have any select sounds */
|
|
|
|
#define MENUFLAG_BUTTON_NOVOTE (1<<3) /**< Menu has a "No Vote" button at slot 1 */
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
#define VOTEINFO_CLIENT_INDEX 0 /**< Client index */
|
|
|
|
#define VOTEINFO_CLIENT_ITEM 1 /**< Item the client selected, or -1 for none */
|
|
|
|
#define VOTEINFO_ITEM_INDEX 0 /**< Item index */
|
|
|
|
#define VOTEINFO_ITEM_VOTES 1 /**< Number of votes for the item */
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
#define VOTEFLAG_NO_REVOTES (1<<0) /**< Players cannot change their votes */
|
2009-07-16 10:16:58 +02:00
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* Reasons a menu can be cancelled (MenuAction_Cancel).
|
|
|
|
*/
|
|
|
|
enum
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
MenuCancel_Disconnected = -1, /**< Client dropped from the server */
|
|
|
|
MenuCancel_Interrupted = -2, /**< Client was interrupted with another menu */
|
|
|
|
MenuCancel_Exit = -3, /**< Client exited via "exit" */
|
|
|
|
MenuCancel_NoDisplay = -4, /**< Menu could not be displayed to the client */
|
|
|
|
MenuCancel_Timeout = -5, /**< Menu timed out */
|
|
|
|
MenuCancel_ExitBack = -6 /**< Client selected "exit back" on a paginated menu */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reasons a vote can be cancelled (MenuAction_VoteCancel).
|
|
|
|
*/
|
|
|
|
enum
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
VoteCancel_Generic = -1, /**< Vote was generically cancelled. */
|
|
|
|
VoteCancel_NoVotes = -2 /**< Vote did not receive any votes. */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reasons a menu ended (MenuAction_End).
|
|
|
|
*/
|
|
|
|
enum
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
MenuEnd_Selected = 0, /**< Menu item was selected */
|
|
|
|
MenuEnd_VotingDone = -1, /**< Voting finished */
|
|
|
|
MenuEnd_VotingCancelled = -2, /**< Voting was cancelled */
|
|
|
|
MenuEnd_Cancelled = -3, /**< Menu was cancelled (reason in param2) */
|
|
|
|
MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */
|
|
|
|
MenuEnd_ExitBack = -5 /**< Menu was cleanly exited via "back" */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Describes a menu's source
|
|
|
|
*/
|
|
|
|
enum MenuSource
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
MenuSource_None = 0, /**< No menu is being displayed */
|
|
|
|
MenuSource_External = 1, /**< External menu */
|
|
|
|
MenuSource_Normal = 2, /**< A basic menu is being displayed */
|
|
|
|
MenuSource_RawPanel = 3 /**< A display is active, but it is not tied to a menu */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a menu action is completed.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu The menu being acted upon.
|
|
|
|
* @param action The action of the menu.
|
|
|
|
* @param param1 First action parameter (usually the client).
|
|
|
|
* @param param2 Second action parameter (usually the item).
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
typedef MenuHandler = function int (Menu menu, MenuAction action, int param1, int param2);
|
|
|
|
|
|
|
|
// Panels are used for drawing raw menus without any extra helper functions.
|
|
|
|
// Handles must be closed via delete or CloseHandle().
|
|
|
|
methodmap Panel < Handle
|
|
|
|
{
|
|
|
|
// Constructor for a new Panel.
|
2019-09-27 13:14:44 +02:00
|
|
|
//
|
|
|
|
// @param hStyle MenuStyle Handle, or null to use the default style.
|
2015-03-21 15:43:24 +01:00
|
|
|
public native Panel(Handle hStyle = null);
|
|
|
|
|
|
|
|
// Sets the panel's title.
|
|
|
|
//
|
|
|
|
// @param text Text to set as the title.
|
|
|
|
// @param onlyIfEmpty If true, the title will only be set if no title is set.
|
|
|
|
public native void SetTitle(const char[] text, bool onlyIfEmpty=false);
|
|
|
|
|
|
|
|
// Draws an item on a panel. If the item takes up a slot, the position
|
|
|
|
// is returned.
|
|
|
|
//
|
2019-09-27 13:14:44 +02:00
|
|
|
// @param text Display text to use. If not a raw line,
|
2015-03-21 15:43:24 +01:00
|
|
|
// the style may automatically add color markup.
|
|
|
|
// No numbering or newlines are needed.
|
|
|
|
// @param style ITEMDRAW style flags.
|
|
|
|
// @return A slot position, or 0 if item was a rawline or could not be drawn.
|
2016-08-23 15:34:00 +02:00
|
|
|
public native int DrawItem(const char[] text, int style=ITEMDRAW_DEFAULT);
|
2015-03-21 15:43:24 +01:00
|
|
|
|
|
|
|
// Draws a raw line of text on a panel, without any markup other than a
|
|
|
|
// newline.
|
|
|
|
//
|
|
|
|
// @param text Display text to use.
|
|
|
|
// @return True on success, false if raw lines are not supported.
|
|
|
|
public native bool DrawText(const char[] text);
|
|
|
|
|
|
|
|
// Returns whether or not the given drawing flags are supported by
|
|
|
|
// the menu style.
|
|
|
|
//
|
|
|
|
// @param style ITEMDRAW style flags.
|
|
|
|
// @return True if item is drawable, false otherwise.
|
|
|
|
public native bool CanDrawFlags(int style);
|
|
|
|
|
|
|
|
// Sets the selectable key map of a panel. This is not supported by
|
2019-09-27 13:14:44 +02:00
|
|
|
// all styles (only by Radio, as of this writing).
|
2015-03-21 15:43:24 +01:00
|
|
|
//
|
|
|
|
// @param keys An integer where each bit N allows key
|
|
|
|
// N+1 to be selected. If no keys are selectable,
|
|
|
|
// then key 0 (bit 9) is automatically set.
|
|
|
|
// @return True if supported, false otherwise.
|
|
|
|
public native bool SetKeys(int keys);
|
|
|
|
|
|
|
|
// Sends a panel to a client. Unlike full menus, the handler
|
2019-09-27 13:14:44 +02:00
|
|
|
// function will only receive the following actions, both of
|
2015-03-21 15:43:24 +01:00
|
|
|
// which will have null for a menu, and the client as param1.
|
|
|
|
//
|
|
|
|
// MenuAction_Select (param2 will be the key pressed)
|
|
|
|
// MenuAction_Cancel (param2 will be the reason)
|
|
|
|
//
|
|
|
|
// Also, if the menu fails to display, no callbacks will be called.
|
|
|
|
//
|
|
|
|
// @param client A client to draw to.
|
|
|
|
// @param handler The MenuHandler function to catch actions with.
|
|
|
|
// @param time Time to hold the menu for.
|
|
|
|
// @return True on success, false on failure.
|
|
|
|
public native bool Send(int client, MenuHandler handler, int time);
|
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
// Returns the amount of text the menu can still hold. If this is
|
|
|
|
// limit is reached or overflowed, the text is silently truncated.
|
2015-03-21 15:43:24 +01:00
|
|
|
//
|
|
|
|
// Radio menus: Currently 511 characters (512 bytes).
|
|
|
|
// Valve menus: Currently -1 (no meaning).
|
|
|
|
property int TextRemaining {
|
|
|
|
public native get();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns or sets the current key position, starting at 1. This cannot be
|
|
|
|
// used to traverse backwards.
|
|
|
|
property int CurrentKey {
|
|
|
|
public native get();
|
|
|
|
public native set(int key);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the panel's style. Style handles are global and cannot be closed.
|
|
|
|
property Handle Style {
|
|
|
|
public native get();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// A menu is a helper object for managing in-game menus.
|
|
|
|
methodmap Menu < Handle
|
|
|
|
{
|
|
|
|
// Creates a new, empty menu using the default style.
|
2019-09-27 13:14:44 +02:00
|
|
|
//
|
2015-03-21 15:43:24 +01:00
|
|
|
// @param handler Function which will receive menu actions.
|
2019-09-27 13:14:44 +02:00
|
|
|
// @param actions Optionally set which actions to receive. Select,
|
2015-03-21 15:43:24 +01:00
|
|
|
// Cancel, and End will always be received regardless
|
|
|
|
// of whether they are set or not. They are also
|
|
|
|
// the only default actions.
|
|
|
|
public native Menu(MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT);
|
|
|
|
|
|
|
|
// Displays a menu to a client.
|
|
|
|
//
|
|
|
|
// @param client Client index.
|
|
|
|
// @param time Maximum time to leave menu on the screen.
|
|
|
|
// @return True on success, false on failure.
|
|
|
|
// @error Client not in game.
|
|
|
|
public native bool Display(int client, int time);
|
|
|
|
|
|
|
|
// Displays a menu to a client, starting from the given item.
|
|
|
|
//
|
|
|
|
// @param client Client index.
|
|
|
|
// @param first_item First item to begin drawing from.
|
|
|
|
// @param time Maximum time to leave menu on the screen.
|
|
|
|
// @return True on success, false on failure.
|
|
|
|
// @error Client not in game.
|
|
|
|
///
|
|
|
|
public native bool DisplayAt(int client, int first_item, int time);
|
|
|
|
|
|
|
|
// Appends a new item to the end of a menu.
|
|
|
|
//
|
|
|
|
// @param info Item information string.
|
|
|
|
// @param display Default item display string.
|
2019-09-27 13:14:44 +02:00
|
|
|
// @param style Drawing style flags. Anything other than DEFAULT or
|
2015-03-21 15:43:24 +01:00
|
|
|
// DISABLED will be completely ignored when paginating.
|
|
|
|
// @return True on success, false on failure.
|
|
|
|
// @error Item limit reached.
|
|
|
|
public native bool AddItem(const char[] info, const char[] display, int style=ITEMDRAW_DEFAULT);
|
|
|
|
|
|
|
|
// Inserts an item into the menu before a certain position; the new item will
|
|
|
|
// be at the given position and all next items pushed forward.
|
|
|
|
//
|
|
|
|
// @param position Position, starting from 0.
|
|
|
|
// @param info Item information string.
|
|
|
|
// @param display Default item display string.
|
2019-09-27 13:14:44 +02:00
|
|
|
// @param style Drawing style flags. Anything other than DEFAULT or
|
2015-03-21 15:43:24 +01:00
|
|
|
// DISABLED will be completely ignored when paginating.
|
|
|
|
// @return True on success, false on failure.
|
|
|
|
// @error Invalid menu position.
|
|
|
|
public native bool InsertItem(int position, const char[] info,
|
|
|
|
const char[] display, int style=ITEMDRAW_DEFAULT);
|
|
|
|
|
|
|
|
// Removes an item from the menu.
|
|
|
|
//
|
|
|
|
// @param position Position, starting from 0.
|
|
|
|
// @return True on success, false on failure.
|
|
|
|
// @error Invalid menu position.
|
|
|
|
public native bool RemoveItem(int position);
|
|
|
|
|
|
|
|
// Removes all items from a menu.
|
|
|
|
public native void RemoveAllItems();
|
|
|
|
|
|
|
|
// Retrieves information about a menu item.
|
|
|
|
//
|
|
|
|
// @param position Position, starting from 0.
|
|
|
|
// @param infoBuf Info buffer.
|
|
|
|
// @param infoBufLen Maximum length of the info buffer.
|
|
|
|
// @param style By-reference variable to store drawing flags.
|
|
|
|
// @param dispBuf Display buffer.
|
|
|
|
// @param dispBufLen Maximum length of the display buffer.
|
2019-09-27 13:14:44 +02:00
|
|
|
// @param client Client index. Must be specified if menu is per-client random shuffled, -1 to ignore.
|
2015-03-21 15:43:24 +01:00
|
|
|
// @return True on success, false if position is invalid.
|
2019-09-27 13:14:44 +02:00
|
|
|
public native bool GetItem(int position, char[] infoBuf, int infoBufLen,
|
|
|
|
int &style=0, char[] dispBuf="", int dispBufLen=0, int client=0);
|
|
|
|
|
|
|
|
// Generates a per-client random mapping for the current vote options.
|
|
|
|
//
|
|
|
|
// @param start Menu item index to start randomizing from.
|
|
|
|
// @param stop Menu item index to stop randomizing at. -1 = infinite
|
|
|
|
public native void ShufflePerClient(int start=0, int stop=-1);
|
|
|
|
|
|
|
|
// Fills the client vote option mapping with user supplied values.
|
|
|
|
//
|
|
|
|
// @param client Client index.
|
|
|
|
// @param array Integer array with mapping.
|
|
|
|
// @param length Length of array.
|
|
|
|
public native void SetClientMapping(int client, int[] array, int length);
|
2015-03-21 15:43:24 +01:00
|
|
|
|
|
|
|
// Sets the menu's default title/instruction message.
|
|
|
|
//
|
|
|
|
// @param fmt Message string format
|
|
|
|
// @param ... Message string arguments.
|
|
|
|
public native void SetTitle(const char[] fmt, any ...);
|
|
|
|
|
|
|
|
// Returns the text of a menu's title.
|
|
|
|
//
|
|
|
|
// @param buffer Buffer to store title.
|
|
|
|
// @param maxlength Maximum length of the buffer.
|
|
|
|
// @return Number of bytes written.
|
|
|
|
public native void GetTitle(char[] buffer, int maxlength);
|
|
|
|
|
|
|
|
// Creates a raw MenuPanel based off the menu's style.
|
|
|
|
// The Handle must be freed with CloseHandle().
|
|
|
|
//
|
|
|
|
// @return A new MenuPanel Handle.
|
|
|
|
public native Panel ToPanel();
|
|
|
|
|
|
|
|
// Cancels a menu from displaying on all clients. While the
|
|
|
|
// cancellation is in progress, this menu cannot be re-displayed
|
|
|
|
// to any clients.
|
|
|
|
//
|
|
|
|
// The menu may still exist on the client's screen after this command.
|
|
|
|
// This simply verifies that the menu is not being used anywhere.
|
|
|
|
//
|
|
|
|
// If any vote is in progress on a menu, it will be cancelled.
|
|
|
|
public native void Cancel();
|
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
// Broadcasts a menu to a list of clients. The most selected item will be
|
|
|
|
// returned through MenuAction_End. On a tie, a random item will be returned
|
2015-03-21 15:43:24 +01:00
|
|
|
// from a list of the tied items.
|
|
|
|
//
|
|
|
|
// Note that MenuAction_VoteEnd and MenuAction_VoteStart are both
|
|
|
|
// default callbacks and do not need to be enabled.
|
|
|
|
//
|
|
|
|
// @param clients Array of clients to broadcast to.
|
|
|
|
// @param numClients Number of clients in the array.
|
|
|
|
// @param time Maximum time to leave menu on the screen.
|
|
|
|
// @param flags Optional voting flags.
|
|
|
|
// @return True on success, false if this menu already has a
|
|
|
|
// vote session in progress.
|
|
|
|
// @error A vote is already in progress.
|
|
|
|
public native bool DisplayVote(int[] clients, int numClients, int time, int flags=0);
|
|
|
|
|
|
|
|
// Sends a vote menu to all clients. See VoteMenu() for more information.
|
|
|
|
//
|
|
|
|
// @param time Maximum time to leave menu on the screen.
|
|
|
|
// @param flags Optional voting flags.
|
|
|
|
// @return True on success, false if this menu already has a
|
|
|
|
// vote session in progress.
|
|
|
|
public bool DisplayVoteToAll(int time, int flags=0) {
|
|
|
|
int total = 0;
|
|
|
|
int[] players = new int[MaxClients];
|
|
|
|
for (int i = 1; i <= MaxClients; i++) {
|
|
|
|
if (!IsClientInGame(i) || IsFakeClient(i))
|
2019-09-27 13:14:44 +02:00
|
|
|
{
|
2015-03-21 15:43:24 +01:00
|
|
|
continue;
|
2019-09-27 13:14:44 +02:00
|
|
|
}
|
2015-03-21 15:43:24 +01:00
|
|
|
players[total++] = i;
|
|
|
|
}
|
|
|
|
return this.DisplayVote(players, total, time, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get or set the menu's pagination.
|
2019-09-27 13:14:44 +02:00
|
|
|
//
|
|
|
|
// If pagination is MENU_NO_PAGINATION, and the exit button flag is set,
|
2015-03-21 15:43:24 +01:00
|
|
|
// then the exit button flag is removed. It can be re-applied if desired.
|
|
|
|
property int Pagination {
|
|
|
|
public native get();
|
|
|
|
public native set(int value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get or set the menu's option flags.
|
|
|
|
//
|
|
|
|
// If a certain bit is not supported, it will be stripped before being set.
|
|
|
|
property int OptionFlags {
|
|
|
|
public native get();
|
|
|
|
public native set(int value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns whether or not the menu has an exit button. By default, menus
|
|
|
|
// have an exit button.
|
|
|
|
property bool ExitButton {
|
|
|
|
public native get();
|
|
|
|
public native set(bool value);
|
|
|
|
}
|
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
// Controls whether or not the menu has an "exit back" button. By default,
|
|
|
|
// menus do not have an exit back button.
|
|
|
|
//
|
|
|
|
// Exit Back buttons appear as "Back" on page 1 of paginated menus and have
|
2015-03-21 15:43:24 +01:00
|
|
|
// functionality defined by the user in MenuEnd_ExitBack.
|
|
|
|
property bool ExitBackButton {
|
|
|
|
public native get();
|
|
|
|
public native set(bool value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sets whether or not the menu has a "no vote" button in slot 1.
|
|
|
|
// By default, menus do not have a no vote button.
|
|
|
|
property bool NoVoteButton {
|
|
|
|
public native set(bool value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sets an advanced vote handling callback. If this callback is set,
|
|
|
|
// MenuAction_VoteEnd will not be called.
|
|
|
|
property VoteHandler VoteResultCallback {
|
|
|
|
public native set(VoteHandler handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the number of items in a menu.
|
|
|
|
property int ItemCount {
|
|
|
|
public native get();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the menu style. The Handle is global and cannot be closed.
|
|
|
|
property Handle Style {
|
|
|
|
public native get();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the first item on the page of a currently selected menu.
|
2019-09-27 13:14:44 +02:00
|
|
|
//
|
2015-03-21 15:43:24 +01:00
|
|
|
// This is only valid inside a MenuAction_Select callback.
|
|
|
|
property int Selection {
|
|
|
|
public native get();
|
|
|
|
}
|
|
|
|
}
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new, empty menu using the default style.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
|
|
|
* @param handler Function which will receive menu actions.
|
|
|
|
* @param actions Optionally set which actions to receive. Select,
|
|
|
|
* Cancel, and End will always be received regardless
|
|
|
|
* of whether they are set or not. They are also
|
|
|
|
* the only default actions.
|
|
|
|
* @return A new menu Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native Menu CreateMenu(MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a menu to a client.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param client Client index.
|
|
|
|
* @param time Maximum time to leave menu on the screen.
|
|
|
|
* @return True on success, false on failure.
|
|
|
|
* @error Invalid Handle or client not in game.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool DisplayMenu(Handle menu, int client, int time);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a menu to a client, starting from the given item.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param client Client index.
|
|
|
|
* @param first_item First item to begin drawing from.
|
|
|
|
* @param time Maximum time to leave menu on the screen.
|
|
|
|
* @return True on success, false on failure.
|
|
|
|
* @error Invalid Handle or client not in game.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool DisplayMenuAtItem(Handle menu, int client, int first_item, int time);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a new item to the end of a menu.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param info Item information string.
|
|
|
|
* @param display Default item display string.
|
|
|
|
* @param style Drawing style flags. Anything other than DEFAULT or
|
|
|
|
* DISABLED will be completely ignored when paginating.
|
|
|
|
* @return True on success, false on failure.
|
|
|
|
* @error Invalid Handle or item limit reached.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2019-09-27 13:14:44 +02:00
|
|
|
native bool AddMenuItem(Handle menu,
|
|
|
|
const char[] info,
|
|
|
|
const char[] display,
|
2015-03-21 15:43:24 +01:00
|
|
|
int style=ITEMDRAW_DEFAULT);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Inserts an item into the menu before a certain position; the new item will
|
|
|
|
* be at the given position and all next items pushed forward.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param position Position, starting from 0.
|
|
|
|
* @param info Item information string.
|
|
|
|
* @param display Default item display string.
|
|
|
|
* @param style Drawing style flags. Anything other than DEFAULT or
|
|
|
|
* DISABLED will be completely ignored when paginating.
|
|
|
|
* @return True on success, false on failure.
|
|
|
|
* @error Invalid Handle or menu position.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool InsertMenuItem(Handle menu,
|
2019-09-27 13:14:44 +02:00
|
|
|
position,
|
|
|
|
const char[] info,
|
|
|
|
const char[] display,
|
2015-03-21 15:43:24 +01:00
|
|
|
int style=ITEMDRAW_DEFAULT);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes an item from the menu.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param position Position, starting from 0.
|
|
|
|
* @return True on success, false on failure.
|
|
|
|
* @error Invalid Handle or menu position.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool RemoveMenuItem(Handle menu, int position);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all items from a menu.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @error Invalid Handle or menu position.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native void RemoveAllMenuItems(Handle menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves information about a menu item.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param position Position, starting from 0.
|
|
|
|
* @param infoBuf Info buffer.
|
|
|
|
* @param infoBufLen Maximum length of the info buffer.
|
|
|
|
* @param style By-reference variable to store drawing flags.
|
|
|
|
* @param dispBuf Display buffer.
|
|
|
|
* @param dispBufLen Maximum length of the display buffer.
|
|
|
|
* @param client Client index. Must be specified if menu is per-client random shuffled, -1 to ignore.
|
|
|
|
* @return True on success, false if position is invalid.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2019-09-27 13:14:44 +02:00
|
|
|
native bool GetMenuItem(Handle menu,
|
|
|
|
int position,
|
|
|
|
char[] infoBuf,
|
|
|
|
int infoBufLen,
|
|
|
|
int &style=0,
|
2015-03-21 15:43:24 +01:00
|
|
|
char[] dispBuf="",
|
2019-09-27 13:14:44 +02:00
|
|
|
int dispBufLen=0,
|
|
|
|
int client=0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates a per-client random mapping for the current vote options.
|
|
|
|
*
|
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param start Menu item index to start randomizing from.
|
|
|
|
* @param stop Menu item index to stop randomizing at. -1 = infinite
|
|
|
|
*/
|
|
|
|
native void MenuShufflePerClient(Handle menu, int start=0, int stop=-1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fills the client vote option mapping with user supplied values.
|
|
|
|
*
|
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param client Client index.
|
|
|
|
* @param array Integer array with mapping.
|
|
|
|
* @param length Length of array.
|
|
|
|
*/
|
|
|
|
native void MenuSetClientMapping(Handle menu, int client, int[] array, int length);
|
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* Returns the first item on the page of a currently selected menu.
|
|
|
|
*
|
|
|
|
* This is only valid inside a MenuAction_Select callback.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return First item number on the page the client was viewing
|
|
|
|
* before selecting the item in the callback. This can
|
|
|
|
* be used to re-display the menu from the original
|
|
|
|
* position.
|
|
|
|
* @error Not called from inside a MenuAction_Select callback.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int GetMenuSelectionPosition();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of items in a menu.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @return Number of items in the menu.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int GetMenuItemCount(Handle menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether the menu should be paginated or not.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* If itemsPerPage is MENU_NO_PAGINATION, and the exit button flag is set,
|
2008-10-04 22:59:11 +02:00
|
|
|
* then the exit button flag is removed. It can be re-applied if desired.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Handle to the menu.
|
|
|
|
* @param itemsPerPage Number of items per page, or MENU_NO_PAGINATION.
|
|
|
|
* @return True on success, false if pagination is too high or
|
|
|
|
* low.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool SetMenuPagination(Handle menu, int itemsPerPage);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a menu's pagination setting.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Handle to the menu.
|
|
|
|
* @return Pagination setting.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int GetMenuPagination(Handle menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a menu's MenuStyle Handle. The Handle
|
|
|
|
* is global and cannot be freed.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Handle to the menu.
|
|
|
|
* @return Handle to the menu's draw style.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native Handle GetMenuStyle(Handle menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the menu's default title/instruction message.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param fmt Message string format
|
|
|
|
* @param ... Message string arguments.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native void SetMenuTitle(Handle menu, const char[] fmt, any ...);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the text of a menu's title.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param buffer Buffer to store title.
|
|
|
|
* @param maxlength Maximum length of the buffer.
|
|
|
|
* @return Number of bytes written.
|
|
|
|
* @error Invalid Handle/
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int GetMenuTitle(Handle menu, char[] buffer, int maxlength);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a raw MenuPanel based off the menu's style.
|
|
|
|
* The Handle must be freed with CloseHandle().
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @return A new MenuPanel Handle.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native Panel CreatePanelFromMenu(Handle menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the menu has an exit button.
|
|
|
|
* By default, menus have an exit button.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @return True if the menu has an exit button; false otherwise.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool GetMenuExitButton(Handle menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Sets whether or not the menu has an exit button. By default, paginated menus
|
2008-10-04 22:59:11 +02:00
|
|
|
* have an exit button.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* If a menu's pagination is changed to MENU_NO_PAGINATION, and the pagination
|
|
|
|
* was previously a different value, then the Exit button status is changed to
|
2008-10-04 22:59:11 +02:00
|
|
|
* false. It must be explicitly re-enabled afterwards.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* If a non-paginated menu has an exit button, then at most 9 items will be
|
2008-10-04 22:59:11 +02:00
|
|
|
* displayed.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param button True to enable the button, false to remove it.
|
|
|
|
* @return True if allowed; false on failure.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool SetMenuExitButton(Handle menu, bool button);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Returns whether or not the menu has an "exit back" button. By default,
|
|
|
|
* menus do not have an exit back button.
|
2008-10-04 22:59:11 +02:00
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* Exit Back buttons appear as "Back" on page 1 of paginated menus and have
|
2008-10-04 22:59:11 +02:00
|
|
|
* functionality defined by the user in MenuEnd_ExitBack.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @return True if the menu has an exit back button; false otherwise.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool GetMenuExitBackButton(Handle menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Sets whether or not the menu has an "exit back" button. By default, menus
|
2008-10-04 22:59:11 +02:00
|
|
|
* do not have an exit back button.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* Exit Back buttons appear as "Back" on page 1 of paginated menus and have
|
2008-10-04 22:59:11 +02:00
|
|
|
* functionality defined by the user in MenuEnd_ExitBack.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param button True to enable the button, false to remove it.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native void SetMenuExitBackButton(Handle menu, bool button);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2014-07-30 11:03:42 +02:00
|
|
|
/**
|
|
|
|
* Sets whether or not the menu has a "no vote" button in slot 1.
|
|
|
|
* By default, menus do not have a no vote button.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param button True to enable the button, false to remove it.
|
|
|
|
* @return True if allowed; false on failure.
|
|
|
|
* @error Invalid Handle.
|
2014-07-30 11:03:42 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool SetMenuNoVoteButton(Handle menu, bool button);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancels a menu from displaying on all clients. While the
|
|
|
|
* cancellation is in progress, this menu cannot be re-displayed
|
|
|
|
* to any clients.
|
|
|
|
*
|
|
|
|
* The menu may still exist on the client's screen after this command.
|
|
|
|
* This simply verifies that the menu is not being used anywhere.
|
|
|
|
*
|
|
|
|
* If any vote is in progress on a menu, it will be cancelled.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native void CancelMenu(Handle menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves a menu's option flags.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @return A bitstring of MENUFLAG bits.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int GetMenuOptionFlags(Handle menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a menu's option flags.
|
|
|
|
*
|
|
|
|
* If a certain bit is not supported, it will be stripped before being set.
|
|
|
|
* See SetMenuExitButton() for information on Exit buttons.
|
|
|
|
* See SetMenuExitBackButton() for information on Exit Back buttons.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param flags A new bitstring of MENUFLAG bits.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native void SetMenuOptionFlags(Handle menu, int flags);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether a vote is in progress.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Deprecated; no longer used.
|
|
|
|
* @return True if a vote is in progress, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool IsVoteInProgress(Handle menu=INVALID_HANDLE);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancels the vote in progress.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @error If no vote is in progress.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native void CancelVote();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Broadcasts a menu to a list of clients. The most selected item will be
|
|
|
|
* returned through MenuAction_End. On a tie, a random item will be returned
|
2008-10-04 22:59:11 +02:00
|
|
|
* from a list of the tied items.
|
|
|
|
*
|
|
|
|
* Note that MenuAction_VoteEnd and MenuAction_VoteStart are both
|
|
|
|
* default callbacks and do not need to be enabled.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param clients Array of clients to broadcast to.
|
|
|
|
* @param numClients Number of clients in the array.
|
|
|
|
* @param time Maximum time to leave menu on the screen.
|
|
|
|
* @param flags Optional voting flags.
|
|
|
|
* @return True on success, false if this menu already has a vote session
|
|
|
|
* in progress.
|
|
|
|
* @error Invalid Handle, or a vote is already in progress.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool VoteMenu(Handle menu, int[] clients, int numClients, int time, int flags=0);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends a vote menu to all clients. See VoteMenu() for more information.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param time Maximum time to leave menu on the screen.
|
|
|
|
* @param flags Optional voting flags.
|
|
|
|
* @return True on success, false if this menu already has a vote session
|
|
|
|
* in progress.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
stock bool VoteMenuToAll(Handle menu, int time, int flags=0)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2016-08-23 15:34:00 +02:00
|
|
|
int total;
|
|
|
|
int[] players = new int[MaxClients];
|
2019-09-27 13:14:44 +02:00
|
|
|
|
2016-08-23 15:34:00 +02:00
|
|
|
for (int i=1; i<=MaxClients; i++)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2014-07-30 11:03:42 +02:00
|
|
|
if (!IsClientInGame(i) || IsFakeClient(i))
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
players[total++] = i;
|
|
|
|
}
|
2019-09-27 13:14:44 +02:00
|
|
|
|
2009-07-16 10:16:58 +02:00
|
|
|
return VoteMenu(menu, players, total, time, flags);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2015-03-21 15:43:24 +01:00
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* Callback for when a vote has ended and results are available.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu The menu being voted on.
|
|
|
|
* @param num_votes Number of votes tallied in total.
|
|
|
|
* @param num_clients Number of clients who could vote.
|
|
|
|
* @param client_info Array of clients. Use VOTEINFO_CLIENT_ defines.
|
|
|
|
* @param num_items Number of unique items that were selected.
|
|
|
|
* @param item_info Array of items, sorted by count. Use VOTEINFO_ITEM
|
|
|
|
* defines.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
typeset VoteHandler
|
|
|
|
{
|
|
|
|
// old style
|
|
|
|
function void(
|
|
|
|
Menu menu,
|
|
|
|
int num_votes,
|
|
|
|
int num_clients,
|
|
|
|
const int client_info[][2],
|
|
|
|
int num_items,
|
|
|
|
const int item_info[][2]
|
|
|
|
);
|
|
|
|
|
|
|
|
// new style
|
|
|
|
function void(
|
|
|
|
Menu menu,
|
|
|
|
int num_votes,
|
|
|
|
int num_clients,
|
|
|
|
const int[][] client_info,
|
|
|
|
int num_items,
|
|
|
|
const int[][] item_info
|
|
|
|
);
|
|
|
|
};
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets an advanced vote handling callback. If this callback is set,
|
|
|
|
* MenuAction_VoteEnd will not be called.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param callback Callback function.
|
|
|
|
* @error Invalid Handle or callback.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native void SetVoteResultCallback(Handle menu, VoteHandler callback);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of seconds you should "wait" before displaying
|
|
|
|
* a publicly invocable menu. This number is the time remaining until
|
|
|
|
* (last_vote + sm_vote_delay).
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return Number of seconds to wait, or 0 for none.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int CheckVoteDelay();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-14 23:40:48 +02:00
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Returns whether a client is in the pool of clients allowed
|
|
|
|
* to participate in the current vote. This is determined by
|
2009-07-16 10:16:58 +02:00
|
|
|
* the client list passed to VoteMenu().
|
2009-04-14 23:40:48 +02:00
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @return True if client is allowed to vote, false otherwise.
|
|
|
|
* @error If no vote is in progress or client index is invalid.
|
2009-04-14 23:40:48 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool IsClientInVotePool(int client);
|
2009-04-14 23:40:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Redraws the current vote menu to a client in the voting pool.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @param revotes True to allow revotes, false otherwise.
|
|
|
|
* @return True on success, false if the client is in the vote pool
|
|
|
|
* but cannot vote again.
|
|
|
|
* @error No vote in progress, int client is not in the voting pool,
|
|
|
|
* or client index is invalid.
|
2009-04-14 23:40:48 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool RedrawClientVoteMenu(int client, bool revotes=true);
|
2009-04-14 23:40:48 +02:00
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* Returns a style's global Handle.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param style Menu Style.
|
|
|
|
* @return A Handle, or INVALID_HANDLE if not found or unusable.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native Handle GetMenuStyleHandle(MenuStyle style);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Creates a MenuPanel from a MenuStyle. Panels are used for drawing raw
|
2008-10-04 22:59:11 +02:00
|
|
|
* menus without any extra helper functions. The Handle must be closed
|
|
|
|
* with CloseHandle().
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
|
|
|
|
* @return A new MenuPanel Handle.
|
|
|
|
* @error Invalid Handle other than INVALID_HANDLE.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native Panel CreatePanel(Handle hStyle=INVALID_HANDLE);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
/**
|
|
|
|
* Creates a Menu from a MenuStyle. The Handle must be closed with
|
2008-10-04 22:59:11 +02:00
|
|
|
* CloseHandle().
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
|
|
|
|
* @param handler Function which will receive menu actions.
|
|
|
|
* @param actions Optionally set which actions to receive. Select,
|
|
|
|
* Cancel, and End will always be received regardless
|
|
|
|
* of whether they are set or not. They are also
|
|
|
|
* the only default actions.
|
|
|
|
* @return A new menu Handle.
|
|
|
|
* @error Invalid Handle other than INVALID_HANDLE.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native Menu CreateMenuEx(Handle hStyle=INVALID_HANDLE, MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether a client is viewing a menu.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
|
|
|
|
* @return A MenuSource value.
|
|
|
|
* @error Invalid Handle other than null.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native MenuSource GetClientMenu(int client, Handle hStyle=null);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
/**
|
2008-10-04 22:59:11 +02:00
|
|
|
* Cancels a menu on a client. This will only affect non-external menus.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @param autoIgnore If true, no menus can be re-drawn on the client during
|
|
|
|
* the cancellation process.
|
|
|
|
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
|
|
|
|
* @return True if a menu was cancelled, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool CancelClientMenu(int client, bool autoIgnore=false, Handle hStyle=INVALID_HANDLE);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a style's maximum items per page.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
|
|
|
|
* @return Maximum items per page.
|
|
|
|
* @error Invalid Handle other than INVALID_HANDLE.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int GetMaxPageItems(Handle hStyle=INVALID_HANDLE);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a MenuPanel's parent style.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle.
|
|
|
|
* @return The MenuStyle Handle that created the panel.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native Handle GetPanelStyle(Handle panel);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the panel's title.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle.
|
|
|
|
* @param text Text to set as the title.
|
|
|
|
* @param onlyIfEmpty If true, the title will only be set if no title is set.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native void SetPanelTitle(Handle panel, const char[] text, bool onlyIfEmpty=false);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws an item on a panel. If the item takes up a slot, the position
|
|
|
|
* is returned.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle.
|
|
|
|
* @param text Display text to use. If not a raw line,
|
|
|
|
* the style may automatically add color markup.
|
|
|
|
* No numbering or newlines are needed.
|
|
|
|
* @param style ITEMDRAW style flags.
|
|
|
|
* @return A slot position, or 0 if item was a rawline or could not be drawn.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int DrawPanelItem(Handle panel, const char[] text, int style=ITEMDRAW_DEFAULT);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws a raw line of text on a panel, without any markup other than a newline.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle, or INVALID_HANDLE if inside a
|
|
|
|
* MenuAction_DisplayItem callback.
|
|
|
|
* @param text Display text to use.
|
|
|
|
* @return True on success, false if raw lines are not supported.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool DrawPanelText(Handle panel, const char[] text);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the given drawing flags are supported by
|
|
|
|
* the menu style.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle.
|
|
|
|
* @param style ITEMDRAW style flags.
|
|
|
|
* @return True if item is drawable, false otherwise.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool CanPanelDrawFlags(Handle panel, int style);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the selectable key map of a panel. This is not supported by
|
2019-09-27 13:14:44 +02:00
|
|
|
* all styles (only by Radio, as of this writing).
|
2008-10-04 22:59:11 +02:00
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle.
|
|
|
|
* @param keys An integer where each bit N allows key
|
|
|
|
* N+1 to be selected. If no keys are selectable,
|
|
|
|
* then key 0 (bit 9) is automatically set.
|
|
|
|
* @return True if supported, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool SetPanelKeys(Handle panel, int keys);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends a panel to a client. Unlike full menus, the handler
|
2019-09-27 13:14:44 +02:00
|
|
|
* function will only receive the following actions, both of
|
2008-10-04 22:59:11 +02:00
|
|
|
* which will have INVALID_HANDLE for a menu, and the client
|
|
|
|
* as param1.
|
|
|
|
*
|
|
|
|
* MenuAction_Select (param2 will be the key pressed)
|
|
|
|
* MenuAction_Cancel (param2 will be the reason)
|
|
|
|
*
|
|
|
|
* Also, if the menu fails to display, no callbacks will be called.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle.
|
|
|
|
* @param client A client to draw to.
|
|
|
|
* @param handler The MenuHandler function to catch actions with.
|
|
|
|
* @param time Time to hold the menu for.
|
|
|
|
* @return True on success, false on failure.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool SendPanelToClient(Handle panel, int client, MenuHandler handler, int time);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* @brief Returns the amount of text the menu can still hold. If this is
|
|
|
|
* limit is reached or overflowed, the text is silently truncated.
|
2008-10-04 22:59:11 +02:00
|
|
|
*
|
|
|
|
* Radio menus: Currently 511 characters (512 bytes).
|
|
|
|
* Valve menus: Currently -1 (no meaning).
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle.
|
|
|
|
* @return Number of characters that the menu can still hold,
|
|
|
|
* or -1 if there is no known limit.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int GetPanelTextRemaining(Handle panel);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns the current key position.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle.
|
|
|
|
* @return Current key position starting at 1.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int GetPanelCurrentKey(Handle panel);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sets the next key position. This cannot be used
|
|
|
|
* to traverse backwards.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param panel A MenuPanel Handle.
|
|
|
|
* @param key Key that is greater or equal to
|
|
|
|
* GetPanelCurrentKey().
|
|
|
|
* @return True on success, false otherwise.
|
|
|
|
* @error Invalid Handle.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool SetPanelCurrentKey(Handle panel, int key);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Redraws menu text from inside a MenuAction_DisplayItem callback.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
|
|
|
* @param text Menu text to draw.
|
|
|
|
* @return Item position; must be returned via the callback.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native int RedrawMenuItem(const char[] text);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* This function is provided for legacy code only. Some older plugins may use
|
|
|
|
* network messages instead of the panel API. This function wraps the panel
|
|
|
|
* API for eased portability into the SourceMod menu system.
|
2008-10-04 22:59:11 +02:00
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* This function is only usable with the Radio Menu style. You do not need to
|
|
|
|
* split up your menu into multiple packets; SourceMod will break the string
|
2008-10-04 22:59:11 +02:00
|
|
|
* up internally.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @param str Full menu string as would be passed over the network.
|
|
|
|
* @param time Time to hold the menu for.
|
|
|
|
* @param keys Selectable key bitstring.
|
|
|
|
* @param handler Optional handler function, with the same rules as
|
|
|
|
* SendPanelToClient().
|
|
|
|
* @return True on success, false on failure.
|
|
|
|
* @error Invalid client index, or radio menus not supported.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native bool InternalShowMenu(int client, const char[] str, int time, int keys=-1, MenuHandler handler=INVALID_FUNCTION);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves voting information from MenuAction_VoteEnd.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param param2 Second parameter of MenuAction_VoteEnd.
|
|
|
|
* @param winningVotes Number of votes received by the winning option.
|
|
|
|
* @param totalVotes Number of total votes received.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
stock void GetMenuVoteInfo(int param2, int &winningVotes, int &totalVotes)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
winningVotes = param2 & 0xFFFF;
|
|
|
|
totalVotes = param2 >> 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Quick stock to determine whether voting is allowed. This doesn't let you
|
|
|
|
* fine-tune a reason for not voting, so it's not recommended for lazily
|
2008-10-04 22:59:11 +02:00
|
|
|
* telling clients that voting isn't allowed.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
|
|
|
* @return True if voting is allowed, false if voting is in progress
|
|
|
|
* or the cooldown is active.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
stock bool IsNewVoteAllowed()
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
if (IsVoteInProgress() || CheckVoteDelay() != 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-27 13:14:44 +02:00
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
return true;
|
|
|
|
}
|