experimental changes to topmenu api -- drawing/displaying is now properly abstracted
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.
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.
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.
71 TopMenuAction_SelectOption = 2,
74 * A menu option is being drawn and its flags can be overridden.
76 * INPUT : TopMenu Handle, object ID, client index.
77 * OUTPUT: The first byte of the 'buffer' string should be set
78 * to the desired flags. By default, it will contain
81 TopMenuAction_DrawOption = 3,
85 * Top menu object types.
87 enum TopMenuObjectType
89 TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */
90 TopMenuObject_Item = 1 /**< Item on a sub-menu */
94 * Top menu starting positions for display.
98 TopMenuPosition_Start = 0, /**< Start/root of the menu */
99 TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */
100 TopMenuPosition_LastCategory = 3, /**< Last position in their last category */
104 * Top menu object tag for type checking.
108 INVALID_TOPMENUOBJECT = 0,
112 * TopMenu callback prototype.
114 * @param topmenu Handle to the TopMenu.
115 * @param action TopMenuAction being performed.
116 * @param object_id The object ID (if used).
117 * @param param Extra parameter (if used).
118 * @param buffer Output buffer (if used).
119 * @param maxlength Output buffer (if used).
122 functag TopMenuHandler public(Handle:topmenu,
123 TopMenuAction:action,
124 TopMenuObject:object_id,
132 * @param handler Handler to use for drawing the root title.
133 * @return A new TopMenu Handle, or INVALID_HANDLE on failure.
135 native Handle:CreateTopMenu(TopMenuHandler:handler);
138 * Re-sorts the items in a TopMenu via a configuration file.
140 * The format of the configuration file should be a Valve Key-Values
141 * formatted file that SourceMod can parse. There should be one root
142 * section, and one sub-section for each category. Each sub-section's
143 * name should match the category name.
145 * Each sub-section may only contain key/value pairs in the form of:
147 * value: Name of the item as passed to AddToTopMenu().
149 * The TopMenu will draw items in the order declared in the configuration
150 * file. If items do not appear in the configuration file, they are sorted
151 * per-player based on how the handler function renders for that player.
152 * These items appear after the configuration sorted items.
154 * @param topmenu TopMenu Handle.
155 * @param file File path.
156 * @param error Error buffer.
157 * @param maxlength Maximum size of the error buffer.
158 * Error buffer will be filled with a
159 * zero-terminated string if false is
161 * @return True on success, false on failure.
162 * @error Invalid TopMenu Handle.
164 native bool:LoadTopMenuConfig(Handle:topmenu, const String:file[], String:error[], maxlength);
167 * Adds an object to a TopMenu.
169 * @param topmenu TopMenu Handle.
170 * @param name Object name (MUST be unique).
171 * @param type Object type.
172 * @param handler Handler for object.
173 * @param cmdname Command name (for access overrides).
174 * @param flags Default access flags.
175 * @param parent Parent object ID, or INVALID_TOPMENUOBJECT for none.
176 * Items must have a category parent.
177 * Categories must not have a parent.
178 * @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on
180 * @error Invalid TopMenu Handle.
182 native TopMenuObject:AddToTopMenu(Handle:topmenu,
184 TopMenuObjectType:type,
185 TopMenuHandler:handler,
186 TopMenuObject:parent,
187 const String:cmdname[]="",
191 * Removes an object from a TopMenu.
193 * Plugins' objects are automatically removed all TopMenus when the given
194 * plugin unloads or pauses. In the case of unpausing, all items are restored.
196 * @param topmenu TopMenu Handle.
197 * @param object TopMenuObject ID.
199 * @error Invalid TopMenu Handle.
201 native RemoveFromTopMenu(Handle:topmenu, TopMenuObject:object);
204 * Displays a TopMenu to a client.
206 * @param topmenu TopMenu Handle.
207 * @param client Client index.
208 * @param position Position to display from.
209 * @return True on success, false on failure.
210 * @error Invalid TopMenu Handle or client not in game.
212 native bool:DisplayTopMenu(Handle:topmenu, client, TopMenuPosition:position);
215 * Finds a category's object ID in a TopMenu.
217 * @param topmenu TopMenu Handle.
218 * @param name Object's unique name.
219 * @return TopMenuObject ID on success, or
220 * INVALID_TOPMENUOBJECT on failure.
221 * @error Invalid TopMenu Handle.
223 native TopMenuObject:FindTopMenuCategory(Handle:topmenu, const String:name[]);
226 * Do not edit below this line!
228 public Extension:__ext_cstrike =
231 file = "topmenus.ext",
232 #if defined AUTOLOAD_EXTENSIONS
237 #if defined REQUIRE_EXTENSIONS