Mercurial > molko
comparison src/core/action.h @ 59:52792b863ff7
misc: separate core from game
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 21 Jan 2020 12:42:33 +0100 |
parents | src/action.h@9f6267843815 |
children | 5da49274e5fb |
comparison
equal
deleted
inserted
replaced
58:d7d88ac30611 | 59:52792b863ff7 |
---|---|
1 /* | |
2 * action.h -- action states | |
3 * | |
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #ifndef ACTION_H | |
20 #define ACTION_H | |
21 | |
22 /** | |
23 * \file action.h | |
24 * \brief Action states. | |
25 */ | |
26 | |
27 #include <stdbool.h> | |
28 | |
29 union event; | |
30 | |
31 /** | |
32 * \brief Action flags. | |
33 */ | |
34 enum action_flags { | |
35 ACTION_NONE, /*!< No flags */ | |
36 ACTION_AUTO_LEAVE = (1 << 0) /*!< Action is removed on state change */ | |
37 }; | |
38 | |
39 /** | |
40 * \brief Action structure. | |
41 */ | |
42 struct action { | |
43 /** | |
44 * (RW) | |
45 * | |
46 * Optional flags. | |
47 */ | |
48 enum action_flags flags; | |
49 | |
50 /** | |
51 * (RW) | |
52 * | |
53 * Arbitrary user data. | |
54 */ | |
55 void *data; | |
56 | |
57 /** | |
58 * (RW) | |
59 * | |
60 * Handle event. | |
61 */ | |
62 void (*handle)(struct action *, const union event *event); | |
63 | |
64 /** | |
65 * (RW) | |
66 * | |
67 * Update the action. | |
68 * | |
69 * If returns true, the action is removed. | |
70 */ | |
71 bool (*update)(struct action *, unsigned int); | |
72 | |
73 /** | |
74 * (RW) | |
75 * | |
76 * Draw the aciton. | |
77 */ | |
78 void (*draw)(struct action *); | |
79 | |
80 /** | |
81 * (RW) | |
82 * | |
83 * Close the action before removal. | |
84 */ | |
85 void (*finish)(struct action *); | |
86 }; | |
87 | |
88 #endif /* !ACTION_H*/ |