Mercurial > molko
annotate libmlk-rpg/rpg/message.h @ 243:71b3b7036de7
misc: lot of cleanups,
- prefix libraries with libmlk,
- move assets from source directories closes #2520,
- prefix header guards closes #2519
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 28 Nov 2020 22:37:30 +0100 |
parents | librpg/rpg/message.h@64f24b482722 |
children | 08ab73b32832 |
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 |
243
71b3b7036de7
misc: lot of cleanups,
David Demelier <markand@malikania.fr>
parents:
215
diff
changeset
|
19 #ifndef MOLKO_RPG_MESSAGE_H |
71b3b7036de7
misc: lot of cleanups,
David Demelier <markand@malikania.fr>
parents:
215
diff
changeset
|
20 #define MOLKO_RPG_MESSAGE_H |
24
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. |
70
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
25 * \ingroup actions |
72
6203e1ac9b18
doc: improve doxygen documentation a lot
David Demelier <markand@malikania.fr>
parents:
71
diff
changeset
|
26 * \ingroup drawing |
70
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
27 * |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
28 * This module's purpose is to show a dialog box into the screen to show text |
159
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
29 * and optionally ask the user a question. It is similar to what you're used to |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
30 * see in many RPGs. |
70
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
31 * |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
32 * To use it use the following procedure: |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
33 * |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
34 * 1. Create a struct message object and set required properties, |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
35 * 2. Call \ref message_start to reset the state, |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
36 * 3. Call \ref message_handle and \ref message_update with appropriate values, |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
37 * 4. Call \ref message_draw to render the dialog. |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
38 * |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
39 * Depending on message flags or user input, step 3 may return true in this |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
40 * case you should stop using the message as it has completed rendering. |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
41 * |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
42 * \note All properties must exist until the object is no longer used. |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
43 * |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
44 * \code |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
45 * struct message msg = { |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
46 * // You can show up to 6 lines. |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
47 * .text = { |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
48 * "Hello, what's up?" |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
49 * }, |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
50 * // This indicates this message is a question. |
159
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
51 * .flags = MESSAGE_FLAGS_QUESTION |
70
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
52 * }; |
53b217afe122
doc: improve doxygen documentation
David Demelier <markand@malikania.fr>
parents:
67
diff
changeset
|
53 * \endcode |
159
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
54 * |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
55 * For performance reasons, flexibility and simplicity, the message box does |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
56 * not try to be clever about positions of lines. It will simply create an |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
57 * animation for opening the box, drawing the lines to the position according |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
58 * to the theme padding and spacing and interact with user. For convenience |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
59 * though, the \ref message_query can be used to determine dimensions required |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
60 * for a better final result. |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
61 * |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
62 * ## Example, computing the dimensions: |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
63 * |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
64 * \code |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
65 * // We create a message that we put on the center of the screen. |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
66 * struct message msg = { |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
67 * .text = { |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
68 * "Hi, have you tried turning it off and on again?" |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
69 * } |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
70 * }; |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
71 * |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
72 * message_query(&msg, &msg.w, &msg.h); |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
73 * align(ALIGN_CENTER, &msg.x, &msg.y, msg.w, msg.h, 0, 0, window.w, window.h); |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
74 * \endcode |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
75 */ |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
76 |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
77 #include <stdbool.h> |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
78 |
148
c577c15df07f
misc: split libraries, closes #2496
David Demelier <markand@malikania.fr>
parents:
147
diff
changeset
|
79 #include <core/texture.h> |
94
ed72843a7194
core: simplify font/texture interfaces
David Demelier <markand@malikania.fr>
parents:
72
diff
changeset
|
80 |
67
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
81 struct action; |
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
82 struct font; |
99
4ac71ac10c9f
core: start adding some UI elements
David Demelier <markand@malikania.fr>
parents:
94
diff
changeset
|
83 struct theme; |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
84 |
64
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
85 union event; |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
86 |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
87 /** |
140
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
88 * \brief Default animation speed in milliseconds. |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
89 */ |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
90 #define MESSAGE_DELAY_DEFAULT (150) |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
91 |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
92 /** |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
93 * \brief Default timeout in milliseconds for automatic messages. |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
94 */ |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
95 #define MESSAGE_TIMEOUT_DEFAULT (5000) |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
96 |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
97 /** |
157
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
98 * \brief Maximum number of lines allowed in the message. |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
99 */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
100 #define MESSAGE_LINES_MAX (3) |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
101 |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
102 /** |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
103 * \brief Message flags. |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
104 */ |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
105 enum message_flags { |
140
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
106 MESSAGE_FLAGS_AUTOMATIC = (1 << 0), /*!< Will automatically change state by itself. */ |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
107 MESSAGE_FLAGS_QUESTION = (1 << 1), /*!< The message is a question. */ |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
108 MESSAGE_FLAGS_FADEIN = (1 << 2), /*!< Animate opening. */ |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
109 MESSAGE_FLAGS_FADEOUT = (1 << 3) /*!< Animate closing. */ |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
110 }; |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
111 |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
112 /** |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
113 * \brief Message state. |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
114 */ |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
115 enum message_state { |
140
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
116 MESSAGE_STATE_NONE, /*!< Message hasn't start yet or is finished */ |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
117 MESSAGE_STATE_OPENING, /*!< Message animation is opening */ |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
118 MESSAGE_STATE_SHOWING, /*!< Message is displaying */ |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
119 MESSAGE_STATE_HIDING /*!< Message animation for hiding */ |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
120 }; |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
121 |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
122 /** |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
123 * \brief Message object. |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
124 */ |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
125 struct message { |
157
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
126 int x; /*!< (+) Position in x. */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
127 int y; /*!< (+) Position in y. */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
128 unsigned int w; /*!< (+) Width. */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
129 unsigned int h; /*!< (+) Height. */ |
159
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
130 unsigned int spacing; /*!< (+) Spacing between lines. */ |
157
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
131 unsigned int delay; /*!< (+) Delay for animations. */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
132 unsigned int timeout; /*!< (+) Timeout in milliseconds. */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
133 const char *text[MESSAGE_LINES_MAX]; /*!< (+) Lines of text to show. */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
134 unsigned int index; /*!< (+) Line selected */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
135 enum message_flags flags; /*!< (+) Message flags */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
136 enum message_state state; /*!< (-) Current state */ |
174
6992085d47fd
ui: major theme overhaul, closes #2509 @1h
David Demelier <markand@malikania.fr>
parents:
159
diff
changeset
|
137 const struct theme *theme; /*!< (+&?) Theme to use. */ |
157
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
138 unsigned int elapsed; /*!< (-) Time elapsed. */ |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
139 double scale; /*!< (-) Current scale [0-1]. */ |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
140 }; |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
141 |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
142 /** |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
143 * 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
|
144 * elapsed time. |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
145 * |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
146 * \pre msg != NULL |
141
4eeeccf2b732
core: add trace/vtrace functions, closes #2493
David Demelier <markand@malikania.fr>
parents:
140
diff
changeset
|
147 * \pre msg->delay > 0 if msg->flags contains MESSAGE_FLAGS_FADEIN or |
4eeeccf2b732
core: add trace/vtrace functions, closes #2493
David Demelier <markand@malikania.fr>
parents:
140
diff
changeset
|
148 * MESSAGE_FLAGS_FADEOUT |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
149 * \param msg the message |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
150 */ |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
151 void |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
152 message_start(struct message *msg); |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
153 |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
154 /** |
159
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
155 * Compute the minimal message dimensions required. |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
156 * |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
157 * \pre msg != NULL |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
158 * \param msg the message to query |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
159 * \param w the pointer to width (may be NULL) |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
160 * \param h the pointer to height (may be NULL) |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
161 */ |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
162 void |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
163 message_query(const struct message *msg, unsigned int *w, unsigned int *h); |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
164 |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
165 /** |
64
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
166 * Handle input events. |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
167 * |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
168 * This function will alter state of the message and change its selection in |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
169 * case of question. |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
170 * |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
171 * \pre msg != NULL |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
172 * \pre ev != NULL |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
173 * \param msg the message |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
174 * \param ev the event which occured |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
175 */ |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
176 void |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
177 message_handle(struct message *msg, const union event *ev); |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
178 |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
179 /** |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
180 * 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
|
181 * |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
182 * \pre msg != NULL |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
183 * \param msg the message |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
184 * \param ticks the elapsed delay since last frame |
60
7266c750b649
core: simplify message
David Demelier <markand@malikania.fr>
parents:
59
diff
changeset
|
185 * \return true if it has finished |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
186 */ |
60
7266c750b649
core: simplify message
David Demelier <markand@malikania.fr>
parents:
59
diff
changeset
|
187 bool |
46
b815621df3e3
core: remove all fixed width integers, closes #2460
David Demelier <markand@malikania.fr>
parents:
24
diff
changeset
|
188 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
|
189 |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
190 /** |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
191 * Draw the message into the screen. |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
192 * |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
193 * \pre msg != NULL |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
194 * \param msg the message |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
195 */ |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
196 void |
174
6992085d47fd
ui: major theme overhaul, closes #2509 @1h
David Demelier <markand@malikania.fr>
parents:
159
diff
changeset
|
197 message_draw(const struct message *msg); |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
198 |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
199 /** |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
200 * Start hiding the message. |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
201 * |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
202 * \pre msg != NULL |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
203 * \param msg the message |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
204 * \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
|
205 * finished! |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
206 */ |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
207 void |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
208 message_hide(struct message *msg); |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
209 |
62 | 210 /** |
67
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
211 * Convert message into an action. |
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
212 * |
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
213 * \pre msg != NULL |
215
64f24b482722
rpg: implement tilesets separately, closes #2515 @4h
David Demelier <markand@malikania.fr>
parents:
174
diff
changeset
|
214 * \pre act != NULL |
136
30b68089ae70
core: rework actions and a bit of drawables, closes #2492
David Demelier <markand@malikania.fr>
parents:
121
diff
changeset
|
215 * \param msg the message to reference |
215
64f24b482722
rpg: implement tilesets separately, closes #2515 @4h
David Demelier <markand@malikania.fr>
parents:
174
diff
changeset
|
216 * \param act the action to fill |
64f24b482722
rpg: implement tilesets separately, closes #2515 @4h
David Demelier <markand@malikania.fr>
parents:
174
diff
changeset
|
217 * \post act->data contains msg |
64f24b482722
rpg: implement tilesets separately, closes #2515 @4h
David Demelier <markand@malikania.fr>
parents:
174
diff
changeset
|
218 * \post act->handle invokes message_handle |
64f24b482722
rpg: implement tilesets separately, closes #2515 @4h
David Demelier <markand@malikania.fr>
parents:
174
diff
changeset
|
219 * \post act->update invokes message_update |
64f24b482722
rpg: implement tilesets separately, closes #2515 @4h
David Demelier <markand@malikania.fr>
parents:
174
diff
changeset
|
220 * \post act->draw invokes message_draw |
67
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
221 */ |
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
222 void |
215
64f24b482722
rpg: implement tilesets separately, closes #2515 @4h
David Demelier <markand@malikania.fr>
parents:
174
diff
changeset
|
223 message_action(struct message *msg, struct action *act); |
67
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
224 |
243
71b3b7036de7
misc: lot of cleanups,
David Demelier <markand@malikania.fr>
parents:
215
diff
changeset
|
225 #endif /* !MOLKO_RPG_MESSAGE_H */ |