Mercurial > molko
comparison src/core/message.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/message.h@b815621df3e3 |
children | 7266c750b649 |
comparison
equal
deleted
inserted
replaced
58:d7d88ac30611 | 59:52792b863ff7 |
---|---|
1 /* | |
2 * message.h -- message dialog | |
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 MOLKO_MESSAGE_H | |
20 #define MOLKO_MESSAGE_H | |
21 | |
22 /** | |
23 * \file message.h | |
24 * \brief Message dialog. | |
25 */ | |
26 | |
27 #include <stdbool.h> | |
28 | |
29 struct sprite; | |
30 struct font; | |
31 | |
32 /** | |
33 * \brief Message flags. | |
34 */ | |
35 enum message_flags { | |
36 MESSAGE_AUTOMATIC = (1 << 0) /*!< Message will automatically close */ | |
37 }; | |
38 | |
39 /** | |
40 * \brief Message state. | |
41 */ | |
42 enum message_state { | |
43 MESSAGE_OPENING, /*!< Message animation is opening */ | |
44 MESSAGE_SHOWING, /*!< Message is displaying */ | |
45 MESSAGE_HIDING /*!< Message animation for hiding */ | |
46 }; | |
47 | |
48 /** | |
49 * \brief Message object. | |
50 */ | |
51 struct message { | |
52 const char *text[3]; /*!< (RW) lines of text to show */ | |
53 struct sprite *theme; /*!< (RW) sprite to use for the frame */ | |
54 struct texture *avatar; /*!< (RW) optional avatar */ | |
55 struct font *font; /*!< (RW) font to use */ | |
56 enum message_flags flags; /*!< (RW) message flags */ | |
57 enum message_state state; /*!< (RO) current state */ | |
58 unsigned int elapsed; /*!< (RW) elapsed time while displaying */ | |
59 }; | |
60 | |
61 /** | |
62 * Start opening the message. This function will reset the message state and | |
63 * elapsed time. | |
64 * | |
65 * \pre msg != NULL | |
66 * \param msg the message | |
67 */ | |
68 void | |
69 message_start(struct message *msg); | |
70 | |
71 /** | |
72 * Update the message state and elapsed time.. | |
73 * | |
74 * \pre msg != NULL | |
75 * \param msg the message | |
76 * \param ticks the elapsed delay since last frame | |
77 */ | |
78 void | |
79 message_update(struct message *msg, unsigned int ticks); | |
80 | |
81 /** | |
82 * Draw the message into the screen. | |
83 * | |
84 * \pre msg != NULL | |
85 * \param msg the message | |
86 */ | |
87 void | |
88 message_draw(struct message *msg); | |
89 | |
90 /** | |
91 * Start hiding the message. | |
92 * | |
93 * \pre msg != NULL | |
94 * \param msg the message | |
95 * \note You should still continue to draw the message as the animation is not | |
96 * finished! | |
97 */ | |
98 void | |
99 message_hide(struct message *msg); | |
100 | |
101 /** | |
102 * Tells if the message is complete. | |
103 * | |
104 * \pre msg != NULL | |
105 * \param msg the message | |
106 */ | |
107 bool | |
108 message_is_complete(struct message *msg); | |
109 | |
110 #endif /* !MOLKO_MESSAGE_H */ |