Mercurial > molko
annotate src/libmlk-rpg/rpg/message.h @ 378:460c78706989
misc: update copyright years
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 02 Jan 2022 10:22:48 +0100 |
parents | 19782ea1cf4a |
children | 9334b420c975 |
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 * |
378
460c78706989
misc: update copyright years
David Demelier <markand@malikania.fr>
parents:
366
diff
changeset
|
4 * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> |
24
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 |
366
19782ea1cf4a
misc: start rebranding
David Demelier <markand@malikania.fr>
parents:
320
diff
changeset
|
19 #ifndef MLK_RPG_MESSAGE_H |
19782ea1cf4a
misc: start rebranding
David Demelier <markand@malikania.fr>
parents:
320
diff
changeset
|
20 #define MLK_RPG_MESSAGE_H |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
21 |
292
08ab73b32832
misc: add extern "C" {} blocks for C++ friends
David Demelier <markand@malikania.fr>
parents:
243
diff
changeset
|
22 #include <core/core.h> |
148
c577c15df07f
misc: split libraries, closes #2496
David Demelier <markand@malikania.fr>
parents:
147
diff
changeset
|
23 #include <core/texture.h> |
94
ed72843a7194
core: simplify font/texture interfaces
David Demelier <markand@malikania.fr>
parents:
72
diff
changeset
|
24 |
67
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
25 struct action; |
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
26 struct font; |
99
4ac71ac10c9f
core: start adding some UI elements
David Demelier <markand@malikania.fr>
parents:
94
diff
changeset
|
27 struct theme; |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
28 |
64
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
29 union event; |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
30 |
140
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
31 #define MESSAGE_DELAY_DEFAULT (150) |
453651d76f7c
core: upgrade message in terms of customization
David Demelier <markand@malikania.fr>
parents:
136
diff
changeset
|
32 #define MESSAGE_TIMEOUT_DEFAULT (5000) |
157
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
33 #define MESSAGE_LINES_MAX (3) |
fb306ed990f8
ui: make message more flexible, closes #2501
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
34 |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
35 enum message_flags { |
298
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
36 MESSAGE_FLAGS_AUTOMATIC = (1 << 0), |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
37 MESSAGE_FLAGS_QUESTION = (1 << 1), |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
38 MESSAGE_FLAGS_FADEIN = (1 << 2), |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
39 MESSAGE_FLAGS_FADEOUT = (1 << 3) |
24
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
40 }; |
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 { |
298
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
43 MESSAGE_STATE_NONE, |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
44 MESSAGE_STATE_OPENING, |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
45 MESSAGE_STATE_SHOWING, |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
46 MESSAGE_STATE_HIDING |
24
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 struct message { |
298
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
50 int x; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
51 int y; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
52 unsigned int w; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
53 unsigned int h; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
54 unsigned int spacing; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
55 unsigned int delay; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
56 unsigned int timeout; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
57 const char *text[MESSAGE_LINES_MAX]; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
58 unsigned int index; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
59 enum message_flags flags; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
60 enum message_state state; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
61 const struct theme *theme; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
62 unsigned int elapsed; |
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
63 double scale; |
24
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 |
292
08ab73b32832
misc: add extern "C" {} blocks for C++ friends
David Demelier <markand@malikania.fr>
parents:
243
diff
changeset
|
66 CORE_BEGIN_DECLS |
08ab73b32832
misc: add extern "C" {} blocks for C++ friends
David Demelier <markand@malikania.fr>
parents:
243
diff
changeset
|
67 |
24
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 |
159
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
71 void |
e05a792f6910
ui: make message less clever and provide spacing field
David Demelier <markand@malikania.fr>
parents:
157
diff
changeset
|
72 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
|
73 |
64
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
74 void |
da9b7462ab92
core: implement question, closes #2464 @2h
David Demelier <markand@malikania.fr>
parents:
62
diff
changeset
|
75 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
|
76 |
298
196264679079
misc: remove usage of bool
David Demelier <markand@malikania.fr>
parents:
292
diff
changeset
|
77 int |
46
b815621df3e3
core: remove all fixed width integers, closes #2460
David Demelier <markand@malikania.fr>
parents:
24
diff
changeset
|
78 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
|
79 |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
80 void |
174
6992085d47fd
ui: major theme overhaul, closes #2509 @1h
David Demelier <markand@malikania.fr>
parents:
159
diff
changeset
|
81 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
|
82 |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
83 void |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
84 message_hide(struct message *msg); |
4a06503641eb
core: start basic implementation of dialog, continue #2449 @2h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
85 |
67
7187c0d9b9c0
core: implement message action, closes #2467
David Demelier <markand@malikania.fr>
parents:
64
diff
changeset
|
86 void |
215
64f24b482722
rpg: implement tilesets separately, closes #2515 @4h
David Demelier <markand@malikania.fr>
parents:
174
diff
changeset
|
87 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
|
88 |
292
08ab73b32832
misc: add extern "C" {} blocks for C++ friends
David Demelier <markand@malikania.fr>
parents:
243
diff
changeset
|
89 CORE_END_DECLS |
08ab73b32832
misc: add extern "C" {} blocks for C++ friends
David Demelier <markand@malikania.fr>
parents:
243
diff
changeset
|
90 |
366
19782ea1cf4a
misc: start rebranding
David Demelier <markand@malikania.fr>
parents:
320
diff
changeset
|
91 #endif /* !MLK_RPG_MESSAGE_H */ |