]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/mutators/events.qh
Merge branch 'master' into TimePath/scrollpanel
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / mutators / events.qh
1 #pragma once
2
3 #include <common/mutators/base.qh>
4
5 // globals
6
7 string cmd_name;
8 int cmd_argc;
9 string cmd_string;
10
11 /**
12  * Called when a menu command is parsed
13  * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
14  * NOTE: return true if you handled the command, return false to continue handling
15  * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
16  * // example:
17  * MUTATOR_HOOKFUNCTION(foo, Menu_ConsoleCommand) {
18  *     if (MUTATOR_RETURNVALUE) return false; // command was already handled
19  *     if (cmd_name == "echocvar" && cmd_argc >= 2) {
20  *         print(cvar_string(argv(1)), "\n");
21  *         return true;
22  *     }
23  *     if (cmd_name == "echostring" && cmd_argc >= 2) {
24  *         print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
25  *         return true;
26  *     }
27  *     return false;
28  * }
29  */
30 #define EV_Menu_ConsoleCommand(i, o) \
31         /** command name */ i(string, cmd_name) \
32         /** also, argv() can be used */ i(int, cmd_argc) \
33         /** whole command, use only if you really have to */ i(string, cmd_string) \
34         /**/
35 MUTATOR_HOOKABLE(Menu_ConsoleCommand, EV_Menu_ConsoleCommand);
36
37 #define EV_ConfigureDialogs(i, o) \
38         /** main window entity */ i(entity, MUTATOR_ARGV_0_entity) \
39         /**/
40 MUTATOR_HOOKABLE(ConfigureDialogs, EV_ConfigureDialogs);