Mercurial > molko
comparison src/libmlk-rpg/rpg/message.h @ 320:8f9937403749
misc: improve loading of data
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 01 Oct 2021 20:30:00 +0200 |
parents | libmlk-rpg/rpg/message.h@d01e83210ca2 |
children | 19782ea1cf4a |
comparison
equal
deleted
inserted
replaced
319:b843eef4cc35 | 320:8f9937403749 |
---|---|
1 /* | |
2 * message.h -- message dialog | |
3 * | |
4 * Copyright (c) 2020-2021 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_RPG_MESSAGE_H | |
20 #define MOLKO_RPG_MESSAGE_H | |
21 | |
22 #include <core/core.h> | |
23 #include <core/texture.h> | |
24 | |
25 struct action; | |
26 struct font; | |
27 struct theme; | |
28 | |
29 union event; | |
30 | |
31 #define MESSAGE_DELAY_DEFAULT (150) | |
32 #define MESSAGE_TIMEOUT_DEFAULT (5000) | |
33 #define MESSAGE_LINES_MAX (3) | |
34 | |
35 enum message_flags { | |
36 MESSAGE_FLAGS_AUTOMATIC = (1 << 0), | |
37 MESSAGE_FLAGS_QUESTION = (1 << 1), | |
38 MESSAGE_FLAGS_FADEIN = (1 << 2), | |
39 MESSAGE_FLAGS_FADEOUT = (1 << 3) | |
40 }; | |
41 | |
42 enum message_state { | |
43 MESSAGE_STATE_NONE, | |
44 MESSAGE_STATE_OPENING, | |
45 MESSAGE_STATE_SHOWING, | |
46 MESSAGE_STATE_HIDING | |
47 }; | |
48 | |
49 struct message { | |
50 int x; | |
51 int y; | |
52 unsigned int w; | |
53 unsigned int h; | |
54 unsigned int spacing; | |
55 unsigned int delay; | |
56 unsigned int timeout; | |
57 const char *text[MESSAGE_LINES_MAX]; | |
58 unsigned int index; | |
59 enum message_flags flags; | |
60 enum message_state state; | |
61 const struct theme *theme; | |
62 unsigned int elapsed; | |
63 double scale; | |
64 }; | |
65 | |
66 CORE_BEGIN_DECLS | |
67 | |
68 void | |
69 message_start(struct message *msg); | |
70 | |
71 void | |
72 message_query(const struct message *msg, unsigned int *w, unsigned int *h); | |
73 | |
74 void | |
75 message_handle(struct message *msg, const union event *ev); | |
76 | |
77 int | |
78 message_update(struct message *msg, unsigned int ticks); | |
79 | |
80 void | |
81 message_draw(const struct message *msg); | |
82 | |
83 void | |
84 message_hide(struct message *msg); | |
85 | |
86 void | |
87 message_action(struct message *msg, struct action *act); | |
88 | |
89 CORE_END_DECLS | |
90 | |
91 #endif /* !MOLKO_RPG_MESSAGE_H */ |