Angband
cmd-core.h
Go to the documentation of this file.
1 
20 #ifndef INCLUDED_CMD_CORE_H
21 #define INCLUDED_CMD_CORE_H
22 
23 #include "object.h"
24 #include "z-type.h"
25 
29 typedef enum cmd_code {
30  CMD_NULL = 0, /* A "do nothing" command so that there's something
31  UIs can use as a "no command yet" sentinel. */
32  /*
33  * Splash screen commands
34  */
37 
38  /*
39  * Birth commands
40  */
53 
54  /*
55  * The main game commands
56  */
64 
73  CMD_CAST, /* Casting a spell /or/ praying. */
97 
98  /* Store commands */
103 
104  /* Hors categorie Commands */
106 
109 } cmd_code;
110 
111 typedef enum cmd_context {
117 } cmd_context;
118 
119 enum {
121  DIR_NW = 7,
122  DIR_N = 8,
123  DIR_NE = 9,
124  DIR_W = 4,
126  DIR_NONE = 5,
127  DIR_E = 6,
128  DIR_SW = 1,
129  DIR_S = 2,
130  DIR_SE = 3,
131 };
132 
142  const char *string;
143 
144  int choice;
145  struct object *obj;
146  int number;
148 
149  struct loc point;
150 };
151 
156  arg_NONE = 0,
164 };
165 
169 struct cmd_arg {
172  char name[20]; /* Better than dynamic allocation */
173 };
174 
175 
179 #define CMD_MAX_ARGS 4
180 
181 
182 
190 struct command {
191  /* What context this is happening in */
193 
194  /* A valid command code. */
196 
197  /* Number of times to attempt to repeat command. */
198  int nrepeats;
199 
200  /* Arguments */
202 };
203 
204 
209  CMD_OK = 0,
213 };
214 
215 
220 typedef void (*cmd_handler_fn)(struct command *cmd);
221 
222 
228 /* Return the verb that goes alongside the given command. */
229 const char *cmd_verb(cmd_code cmd);
230 
231 
240 struct command *cmdq_peek(void);
241 
245 extern errr (*cmd_get_hook)(cmd_context c);
246 
250 bool cmdq_pop(cmd_context c);
251 
255 errr cmdq_push_copy(struct command *cmd);
258 
259 
263 void cmdq_execute(cmd_context ctx);
264 
273 void cmd_cancel_repeat(void);
274 
278 void cmd_set_repeat(int nrepeats);
279 
284 void cmd_disable_repeat(void);
285 
290 int cmd_get_nrepeats(void);
291 
292 
293 
302 void cmd_set_arg_choice(struct command *cmd, const char *arg, int choice);
303 void cmd_set_arg_string(struct command *cmd, const char *arg, const char *str);
304 void cmd_set_arg_direction(struct command *cmd, const char *arg, int dir);
305 void cmd_set_arg_target(struct command *cmd, const char *arg, int target);
306 void cmd_set_arg_point(struct command *cmd, const char *arg, int x, int y);
307 void cmd_set_arg_item(struct command *cmd, const char *arg, struct object *obj);
308 void cmd_set_arg_number(struct command *cmd, const char *arg, int amt);
309 
310 
314 int cmd_get_arg_choice(struct command *cmd, const char *arg, int *choice);
315 int cmd_get_arg_string(struct command *cmd, const char *arg, const char **str);
316 int cmd_get_arg_direction(struct command *cmd, const char *arg, int *dir);
317 int cmd_get_arg_target(struct command *cmd, const char *arg, int *target);
318 int cmd_get_arg_point(struct command *cmd, const char *arg, int *x, int *y);
319 int cmd_get_arg_item(struct command *cmd, const char *arg, struct object **obj);
320 int cmd_get_arg_number(struct command *cmd, const char *arg, int *amt);
321 
325 int cmd_get_direction(struct command *cmd, const char *arg, int *dir,
326  bool allow_5);
327 int cmd_get_target(struct command *cmd, const char *arg, int *target);
328 int cmd_get_item(struct command *cmd, const char *arg, struct object **obj,
329  const char *prompt, const char *reject, item_tester filter,
330  int mode);
331 int cmd_get_quantity(struct command *cmd, const char *arg, int *amt, int max);
332 int cmd_get_string(struct command *cmd, const char *arg, const char **str,
333  const char *initial, const char *title, const char *prompt);
334 int cmd_get_spell(struct command *cmd, const char *arg, int *spell,
335  const char *verb, item_tester book_filter, const char *error,
336  bool (*spell_filter)(int spell));
337 
338 #endif