Parent Directory | Revision Log
Revision 44 - (view) (download)
1 : | ian | 17 | /* AMX Mod X constants |
2 : | * | ||
3 : | * by the AMX Mod X Development Team | ||
4 : | * originally developed by OLO | ||
5 : | * | ||
6 : | * This file is provided as is (no warranties). | ||
7 : | */ | ||
8 : | |||
9 : | #if defined _newmenus_included | ||
10 : | #endinput | ||
11 : | #endif | ||
12 : | #define _newmenus_included | ||
13 : | |||
14 : | #define MEXIT_ALL 1 /* Menu will have an exit option (default)*/ | ||
15 : | #define MEXIT_NEVER -1 /* Menu will not have an exit option */ | ||
16 : | |||
17 : | #define MPROP_PERPAGE 1 /* Number of items per page (param1 = number, 0=no paginating, 7=default) */ | ||
18 : | #define MPROP_BACKNAME 2 /* Name of the back button (param1 = string) */ | ||
19 : | #define MPROP_NEXTNAME 3 /* Name of the next button (param1 = string) */ | ||
20 : | #define MPROP_EXITNAME 4 /* Name of the exit button (param1 = string) */ | ||
21 : | #define MPROP_TITLE 5 /* Menu title text (param1 = string) */ | ||
22 : | #define MPROP_EXIT 6 /* Exit functionality (param1 = number, see MEXIT constants) */ | ||
23 : | #define MPROP_NOCOLORS 8 /* Sets whether colors are not auto (param1 = number, 0=default) */ | ||
24 : | #define MPROP_NUMBER_COLOR 10 /* Color indicator to use for numbers (param1 = string, "\r"=default) */ | ||
25 : | |||
26 : | #define MEXIT_NORMAL 0 /* DEPRECATED, do not use (has no effect) */ | ||
27 : | #define MENUPAD_NONE 0 /* DEPRECATED, do not use (has no effect) */ | ||
28 : | #define MENUPAD_PAGE 1 /* DEPRECATED, do not use (has no effect) */ | ||
29 : | #define MPROP_ORDER 7 /* DEPRECATED, do not use (has no effect) */ | ||
30 : | #define MPROP_PADMENU 9 /* DEPRECATED, do not use (has no effect) */ | ||
31 : | |||
32 : | /** | ||
33 : | * @brief Creates a new menu object. | ||
34 : | * | ||
35 : | * The handler function should be prototyped as: | ||
36 : | * | ||
37 : | * public <function>(menu, id, item) | ||
38 : | * menu - Menu resource identifier. | ||
39 : | * id - Client the menu is being acted upon. | ||
40 : | * item - Item the client selected. If less than 0, the menu was | ||
41 : | * cancelled and the item is a status code. menu_display | ||
42 : | * should never be called immediately if the item is a status | ||
43 : | * code, for re-entrancy reasons. | ||
44 : | * | ||
45 : | * The handler function should always return PLUGIN_HANDLED to block | ||
46 : | * any old menu handlers from potentially feeding on the menu, unless | ||
47 : | * that is the desired functionality. | ||
48 : | * | ||
49 : | * @param title Title the menu should use. | ||
50 : | * @param handler Name of the handler function. The function will be invoked | ||
51 : | * once and only once to every menu_display() call. | ||
52 : | * @param ml Unused (should be 0). | ||
53 : | * @return Menu resource identifier which must be destroyed via | ||
54 : | * menu_destroy(). All menus are destroyed when the plugin | ||
55 : | * unloads. | ||
56 : | * @error Function name not found. | ||
57 : | */ | ||
58 : | native menu_create(const title[], const handler[], ml=0); | ||
59 : | |||
60 : | /** | ||
61 : | * Creates a menu item callback handler. | ||
62 : | * | ||
63 : | * The handler function should be prototyped as: | ||
64 : | * | ||
65 : | * public <function>(id, menu, item) | ||
66 : | * id - Client index being displayed to. | ||
67 : | * menu - Menu resource identifier. | ||
68 : | * item - Item being drawn. | ||
69 : | * <return> - ITEM_IGNORE to use the default functionality. ITEM_ENABLED to | ||
70 : | * explicitly enable or ITEM_DISABLED to explicitly disable. | ||
71 : | * | ||
72 : | * @param function Function name. | ||
73 : | * @return Menu callback ID. | ||
74 : | */ | ||
75 : | native menu_makecallback(const function[]); | ||
76 : | |||
77 : | /** | ||
78 : | * Adds an menu to a menu. | ||
79 : | * | ||
80 : | * @param menu Menu resource identifier. | ||
81 : | * @param name Item text to display. | ||
82 : | * @param info Item info string for internal information. | ||
83 : | * @param paccess Access required by the player viewing the menu. | ||
84 : | * @param callback If set to a valid ID from menu_makecallback(), the | ||
85 : | * callback will be invoked before drawing the item. | ||
86 : | * @noreturn | ||
87 : | * @error Invalid menu resource. | ||
88 : | */ | ||
89 : | native menu_additem(menu, const name[], const info[]="", paccess=0, callback=-1); | ||
90 : | |||
91 : | /** | ||
92 : | * Returns the number of pages in a menu. | ||
93 : | * | ||
94 : | * @param menu Menu resource identifier. | ||
95 : | * @return Number of pages in the menu. | ||
96 : | * @error Invalid menu resource. | ||
97 : | */ | ||
98 : | native menu_pages(menu); | ||
99 : | |||
100 : | /** | ||
101 : | * Returns the number of items in a menu. | ||
102 : | * | ||
103 : | * @param menu Menu resource identifier. | ||
104 : | * @return Number of items in the menu. | ||
105 : | * @error Invalid menu resource. | ||
106 : | */ | ||
107 : | native menu_items(menu); | ||
108 : | |||
109 : | /** | ||
110 : | * Displays a menu to one client. This should never be called from a handler | ||
111 : | * when the item is less than 0 (i.e. calling this from a cancelled menu will | ||
112 : | * result in an error). | ||
113 : | * | ||
114 : | * @param id Client index. | ||
115 : | * @param menu Menu resource identifier. | ||
116 : | * @param page Page to start from (starting from 0). | ||
117 : | * @noreturn | ||
118 : | * @error Invalid menu resource or client index. | ||
119 : | */ | ||
120 : | native menu_display(id, menu, page=0); | ||
121 : | |||
122 : | /** | ||
123 : | * Given a page on a menu and a keypress on that page, returns the item id selected. | ||
124 : | * If the item is less than 0, a special option was chosen (such as MENU_EXIT). | ||
125 : | * | ||
126 : | * @param menu Menu resource identifier. | ||
127 : | * @param page Page on the menu. | ||
128 : | * @param key Key pressed (from 1 to 10). | ||
129 : | * @return Item identifier, or <0 for a special selection code. | ||
130 : | * @error Invalid menu resource. | ||
131 : | */ | ||
132 : | native menu_find_id(menu, page, key); | ||
133 : | |||
134 : | /** | ||
135 : | * Retrieves info about a menu item. | ||
136 : | * | ||
137 : | * @param menu Menu resource identifier. | ||
138 : | * @param item Item identifier. | ||
139 : | * @param access Variable to store access value. | ||
140 : | * @param info Buffer to store item info. | ||
141 : | * @param infolen Item info buffer length. | ||
142 : | * @param name Buffer to store item display text. | ||
143 : | * @param namelen Item name buffer length. | ||
144 : | * @param callback Callback ID. | ||
145 : | * @return 1 on success, 0 on failure. | ||
146 : | * @error Invalid menu resource. | ||
147 : | */ | ||
148 : | native menu_item_getinfo(menu, item, &access, info[], infolen, name[]="", namelen=0, &callback); | ||
149 : | |||
150 : | /** | ||
151 : | * Sets an item's display text. | ||
152 : | * | ||
153 : | * @param menu Menu resource identifier. | ||
154 : | * @param item Item identifier. | ||
155 : | * @param name New item display text. | ||
156 : | * @return 1 on success, 0 on failure. | ||
157 : | * @error Invalid menu resource. | ||
158 : | */ | ||
159 : | native menu_item_setname(menu, item, const name[]); | ||
160 : | |||
161 : | /** | ||
162 : | * Sets an item's info string. | ||
163 : | * | ||
164 : | * @param menu Menu resource identifier. | ||
165 : | * @param item Item identifier. | ||
166 : | * @param info New item info string. | ||
167 : | * @return 1 on success, 0 on failure. | ||
168 : | * @error Invalid menu resource. | ||
169 : | */ | ||
170 : | native menu_item_setcmd(menu, item, const info[]); | ||
171 : | |||
172 : | /** | ||
173 : | * Sets an item's callback. | ||
174 : | * | ||
175 : | * @param menu Menu resource identifier. | ||
176 : | * @param item Item identifier. | ||
177 : | * @param callback New callback from menu_makecallback(), or -1 to clear. | ||
178 : | * @return 1 on success, 0 on failure. | ||
179 : | * @error Invalid menu resource. | ||
180 : | */ | ||
181 : | native menu_item_setcall(menu, item, callback=-1); | ||
182 : | |||
183 : | /** | ||
184 : | * Destroys a menu. Player menus will be cancelled (although may still linger | ||
185 : | * on the HUD), and future attempts to access the menu resource will result in | ||
186 : | * an error. | ||
187 : | * | ||
188 : | * This must be called if you create menus dynamically, otherwise you will | ||
189 : | * leak memory. For normal dynamic menus, you will destroy the menu in the | ||
190 : | * handler function (remembering to handle the case of a menu being cancelled, | ||
191 : | * it must still be destroyed). | ||
192 : | * | ||
193 : | * @param menu Menu resource identifier. | ||
194 : | * @noreturn | ||
195 : | * @error Invalid menu resource. | ||
196 : | */ | ||
197 : | native menu_destroy(menu); | ||
198 : | |||
199 : | /** | ||
200 : | * Returns information about a menu (if any) the client is currently viewing. | ||
201 : | * | ||
202 : | * If newmenu is valid, then the menu will refer to the menuid associated with | ||
203 : | * the title. If newmenu is not valid, and the menu is valid, then the player | ||
204 : | * is viewing a menu displayed with show_menu(). | ||
205 : | * | ||
206 : | * Both may be invalid if the player is not viewing a menu. | ||
207 : | * | ||
208 : | * @param id Client index. | ||
209 : | * @param menu Variable to store old menu id. If none, then <1 will be | ||
210 : | * stored. | ||
211 : | * @param newmenu Variable to store new menu id. If none, then -1 will be | ||
212 : | * stored. | ||
213 : | * @param menupage Variable to store current page of the new menu, if any. | ||
214 : | * @return 1 if the player is viewing a menu, 0 otherwise. | ||
215 : | * @error Invalid client. | ||
216 : | */ | ||
217 : | native player_menu_info(id, &menu, &newmenu, &menupage=0); | ||
218 : | |||
219 : | /** | ||
220 : | * Adds a blank line to a menu. | ||
221 : | * | ||
222 : | * @param menu Menu resource identifier. | ||
223 : | * @param slot 1 (default) if the line should shift the numbering down. | ||
224 : | * 0 if the line should be a visual shift only. | ||
225 : | * @noreturn | ||
226 : | * @error Invalid menu resource. | ||
227 : | */ | ||
228 : | native menu_addblank(menu, slot=1); | ||
229 : | |||
230 : | /** | ||
231 : | ian | 44 | * Adds a text line to a menu. Only available in amxmodx 1.8.1 and above. |
232 : | * | ||
233 : | * @param menu Menu resource identifier. | ||
234 : | * @param text Text to add. | ||
235 : | * @param slot 1 (default) if the line should shift the numbering down. | ||
236 : | * 0 if the line should be a visual shift only. | ||
237 : | * @noreturn | ||
238 : | * @error Invalid menu resource. | ||
239 : | */ | ||
240 : | native menu_addtext(menu, const text[], slot=1); | ||
241 : | |||
242 : | /** | ||
243 : | ian | 17 | * Sets a menu property. |
244 : | * | ||
245 : | * @param menu Menu resource identifier. | ||
246 : | * @param prop MPROP_ constant. | ||
247 : | * @param ... Property parameters. | ||
248 : | * @return 1 on success, 0 on failure. | ||
249 : | * @error Invalid menu resource or property. | ||
250 : | */ | ||
251 : | native menu_setprop(menu, prop, ...); | ||
252 : | |||
253 : | /** | ||
254 : | * Cancels a player's menu, effectively forcing the player to select MENU_EXIT. | ||
255 : | * The menu will still exist on their screen but any results are invalidated, | ||
256 : | * and the callback is invoked. | ||
257 : | * | ||
258 : | * @param player Client index. | ||
259 : | * @noreturn | ||
260 : | * @error Invalid client index. | ||
261 : | */ | ||
262 : | native menu_cancel(player); |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |