3 * =============================================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * =============================================================================
7 * This file is part of the SourceMod/SourcePawn SDK.
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, version 3.0, as published by the
11 * Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
21 * As a special exception, AlliedModders LLC gives you permission to link the
22 * code of this program (as well as its derivative works) to "Half-Life 2," the
23 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 * by the Valve Corporation. You must obey the GNU General Public License in
25 * all respects for all other code used. Additionally, AlliedModders LLC grants
26 * this exception to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 * or <http://www.sourcemod.net/license.php>.
33 #if defined _topmenus_included
36 #define _topmenus_included
41 * Actions a top menu will take on an object.
46 * An option is being drawn for a menu (or for sorting purposes).
48 * INPUT : TopMenu Handle, object ID, client index in extra parameter.
49 * OUTPUT: Buffer for rendering, maxlength of buffer.
51 TopMenuAction_DisplayOption = 0,
54 * The title of a menu is being drawn for a given object.
56 * Note: The Object ID will be INVALID_TOPMENUOBJECT if drawing the
57 * root title. Otherwise, the Object ID is a category.
59 * INPUT : TopMenu Handle, object ID, client index in extra parameter.
60 * OUTPUT: Buffer for rendering, maxlength of buffer.
62 TopMenuAction_DisplayTitle = 1,
65 * A menu option has been selected.
67 * The Object ID will always be an item (not a category).
69 * INPUT : TopMenu Handle, object ID, client index in extra parameter.
71 TopMenuAction_SelectOption = 2,
75 * Top menu object types.
77 enum TopMenuObjectType
79 TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */
80 TopMenuObject_Item = 1 /**< Item on a sub-menu */
84 * Top menu starting positions for display.
88 TopMenuPosition_Start = 0, /**< Start/root of the menu */
89 TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */
90 TopMenuPosition_LastCategory = 3, /**< Last position in their last category */
94 * Top menu object tag for type checking.
98 INVALID_TOPMENUOBJECT = 0,
102 * TopMenu callback prototype.
104 * @param topmenu Handle to the TopMenu.
105 * @param action TopMenuAction being performed.
106 * @param object_id The object ID (if used).
107 * @param param Extra parameter (if used).
108 * @param buffer Output buffer (if used).
109 * @param maxlength Output buffer (if used).
112 functag TopMenuHandler public(Handle:topmenu,
113 TopMenuAction:action,
114 TopMenuObject:object_id,
122 * @param handler Handler to use for drawing the root title.
123 * @return A new TopMenu Handle, or INVALID_HANDLE on failure.
125 native Handle:CreateTopMenu(TopMenuHandler:handler);
128 * Re-sorts the items in a TopMenu via a configuration file.
130 * The format of the configuration file should be a Valve Key-Values
131 * formatted file that SourceMod can parse. There should be one root
132 * section, and one sub-section for each category. Each sub-section's
133 * name should match the category name.
135 * Each sub-section may only contain key/value pairs in the form of:
137 * value: Name of the item as passed to AddToTopMenu().
139 * The TopMenu will draw items in the order declared in the configuration
140 * file. If items do not appear in the configuration file, they are sorted
141 * per-player based on how the handler function renders for that player.
142 * These items appear after the configuration sorted items.
144 * @param topmenu TopMenu Handle.
145 * @param file File path.
146 * @param error Error buffer.
147 * @param maxlength Maximum size of the error buffer.
148 * Error buffer will be filled with a
149 * zero-terminated string if false is
151 * @return True on success, false on failure.
152 * @error Invalid TopMenu Handle.
154 native bool:LoadTopMenuConfig(Handle:topmenu, const String:file[], String:error[], maxlength);
157 * Adds an object to a TopMenu.
159 * @param topmenu TopMenu Handle.
160 * @param name Object name (MUST be unique).
161 * @param type Object type.
162 * @param handler Handler for object.
163 * @param cmdname Command name (for access overrides).
164 * @param flags Default access flags.
165 * @param parent Parent object ID, or INVALID_TOPMENUOBJECT for none.
166 * Items must have a category parent.
167 * Categories must not have a parent.
168 * @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on
170 * @error Invalid TopMenu Handle.
172 native TopMenuObject:AddToTopMenu(Handle:topmenu,
174 TopMenuObjectType:type,
175 TopMenuHandler:handler,
176 TopMenuObject:parent,
177 const String:cmdname[]="",
181 * Removes an object from a TopMenu.
183 * Plugins' objects are automatically removed all TopMenus when the given
184 * plugin unloads or pauses. In the case of unpausing, all items are restored.
186 * @param topmenu TopMenu Handle.
187 * @param object TopMenuObject ID.
189 * @error Invalid TopMenu Handle.
191 native RemoveFromTopMenu(Handle:topmenu, TopMenuObject:object);
194 * Displays a TopMenu to a client.
196 * @param topmenu TopMenu Handle.
197 * @param client Client index.
198 * @param position Position to display from.
199 * @return True on success, false on failure.
200 * @error Invalid TopMenu Handle or client not in game.
202 native bool:DisplayTopMenu(Handle:topmenu, client, TopMenuPosition:position);
205 * Finds a category's object ID in a TopMenu.
207 * @param topmenu TopMenu Handle.
208 * @param name Object's unique name.
209 * @return TopMenuObject ID on success, or
210 * INVALID_TOPMENUOBJECT on failure.
211 * @error Invalid TopMenu Handle.
213 native TopMenuObject:FindTopMenuCategory(Handle:topmenu, const String:name[]);
216 * Do not edit below this line!
218 public Extension:__ext_cstrike =
221 file = "topmenus.ext",
222 #if defined AUTOLOAD_EXTENSIONS
227 #if defined REQUIRE_EXTENSIONS