annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 /*
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 * message.h -- message dialog
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
3 *
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr>
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 *
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 * Permission to use, copy, modify, and/or distribute this software for any
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 * purpose with or without fee is hereby granted, provided that the above
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 * copyright notice and this permission notice appear in all copies.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 *
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
18
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
19 #ifndef MOLKO_MESSAGE_H
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
20 #define MOLKO_MESSAGE_H
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
21
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
22 /**
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
23 * \file message.h
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
24 * \brief Message dialog.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
25 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
26
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
27 #include <stdbool.h>
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
28
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
29 struct sprite;
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
30 struct font;
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
31
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
32 /**
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
33 * \brief Message flags.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
34 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 enum message_flags {
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
36 MESSAGE_AUTOMATIC = (1 << 0) /*!< Message will automatically close */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
37 };
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
38
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 /**
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 * \brief Message state.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
42 enum message_state {
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
43 MESSAGE_OPENING, /*!< Message animation is opening */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
44 MESSAGE_SHOWING, /*!< Message is displaying */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
45 MESSAGE_HIDING /*!< Message animation for hiding */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
46 };
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
47
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
48 /**
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
49 * \brief Message object.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
50 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 struct message {
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
52 const char *text[3]; /*!< (RW) lines of text to show */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
53 struct sprite *theme; /*!< (RW) sprite to use for the frame */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
54 struct texture *avatar; /*!< (RW) optional avatar */
46
b815621df3e3 core: remove all fixed width integers, closes #2460
David Demelier <markand@malikania.fr>
parents: 24
diff changeset
55 struct font *font; /*!< (RW) font to use */
24
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
56 enum message_flags flags; /*!< (RW) message flags */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
57 enum message_state state; /*!< (RO) current state */
46
b815621df3e3 core: remove all fixed width integers, closes #2460
David Demelier <markand@malikania.fr>
parents: 24
diff changeset
58 unsigned int elapsed; /*!< (RW) elapsed time while displaying */
24
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 };
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
60
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
61 /**
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
62 * Start opening the message. This function will reset the message state and
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
63 * elapsed time.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
64 *
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
65 * \pre msg != NULL
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
66 * \param msg the message
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
68 void
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
69 message_start(struct message *msg);
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
70
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
71 /**
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
72 * Update the message state and elapsed time..
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
73 *
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
74 * \pre msg != NULL
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
75 * \param msg the message
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
76 * \param ticks the elapsed delay since last frame
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
77 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
78 void
46
b815621df3e3 core: remove all fixed width integers, closes #2460
David Demelier <markand@malikania.fr>
parents: 24
diff changeset
79 message_update(struct message *msg, unsigned int ticks);
24
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
80
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
81 /**
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
82 * Draw the message into the screen.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
83 *
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
84 * \pre msg != NULL
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
85 * \param msg the message
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
86 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
87 void
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
88 message_draw(struct message *msg);
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
89
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
90 /**
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
91 * Start hiding the message.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
92 *
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
93 * \pre msg != NULL
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
94 * \param msg the message
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
95 * \note You should still continue to draw the message as the animation is not
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
96 * finished!
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
97 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
98 void
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
99 message_hide(struct message *msg);
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
100
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
101 /**
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
102 * Tells if the message is complete.
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
103 *
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
104 * \pre msg != NULL
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
105 * \param msg the message
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
106 */
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
107 bool
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
108 message_is_complete(struct message *msg);
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
109
4a06503641eb core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff changeset
110 #endif /* !MOLKO_MESSAGE_H */