Mercurial > molko
comparison src/core/message.h @ 62:d07acc6ee4d9
core: improve message
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 23 Jan 2020 13:48:31 +0100 |
parents | 7266c750b649 |
children | da9b7462ab92 |
comparison
equal
deleted
inserted
replaced
61:8d34a12484db | 62:d07acc6ee4d9 |
---|---|
24 * \brief Message dialog. | 24 * \brief Message dialog. |
25 */ | 25 */ |
26 | 26 |
27 #include <stdbool.h> | 27 #include <stdbool.h> |
28 | 28 |
29 struct sprite; | 29 struct texture; |
30 struct font; | 30 struct font; |
31 | 31 |
32 /** | 32 /** |
33 * \brief Message flags. | 33 * \brief Message flags. |
34 */ | 34 */ |
38 | 38 |
39 /** | 39 /** |
40 * \brief Message state. | 40 * \brief Message state. |
41 */ | 41 */ |
42 enum message_state { | 42 enum message_state { |
43 MESSAGE_NONE, /*!< Message hasn't start yet or is finished */ | |
43 MESSAGE_OPENING, /*!< Message animation is opening */ | 44 MESSAGE_OPENING, /*!< Message animation is opening */ |
44 MESSAGE_SHOWING, /*!< Message is displaying */ | 45 MESSAGE_SHOWING, /*!< Message is displaying */ |
45 MESSAGE_HIDING /*!< Message animation for hiding */ | 46 MESSAGE_HIDING /*!< Message animation for hiding */ |
46 }; | 47 }; |
47 | 48 |
48 /** | 49 /** |
49 * \brief Message object. | 50 * \brief Message object. |
51 * | |
52 * This structure is used to display a message into the screen. It does not own | |
53 * any user properties and therefore must exist while using it. | |
50 */ | 54 */ |
51 struct message { | 55 struct message { |
52 const char *text[3]; /*!< (RW) lines of text to show */ | 56 const char *text[6]; /*!< (RW) Lines of text to show */ |
53 struct sprite *theme; /*!< (RW) sprite to use for the frame */ | 57 struct texture *frame; /*!< (RW) Frame to use */ |
54 struct texture *avatar; /*!< (RW) optional avatar */ | 58 struct texture *avatar; /*!< (RW) Optional avatar */ |
55 struct font *font; /*!< (RW) font to use */ | 59 struct font *font; /*!< (RW) Font to use */ |
56 enum message_flags flags; /*!< (RW) message flags */ | 60 unsigned long color; /*!< (RW) Font color to use */ |
57 enum message_state state; /*!< (RO) current state */ | 61 enum message_flags flags; /*!< (RW) Message flags */ |
58 unsigned int elapsed; /*!< (RW) elapsed time while displaying */ | 62 enum message_state state; /*!< (RO) Current state */ |
63 | |
64 /* PRIVATE */ | |
65 struct texture *ttext[6]; /*!< (RW) Textures for every lines */ | |
66 struct texture *stext[6]; /*!< (RW) Textures for every lines */ | |
67 unsigned int elapsed; /*!< (RW) Elapsed time while displaying */ | |
68 unsigned int alpha; /*!< (RO) Alpha progression */ | |
59 }; | 69 }; |
60 | 70 |
61 /** | 71 /** |
62 * Start opening the message. This function will reset the message state and | 72 * Start opening the message. This function will reset the message state and |
63 * elapsed time. | 73 * elapsed time. |
97 * finished! | 107 * finished! |
98 */ | 108 */ |
99 void | 109 void |
100 message_hide(struct message *msg); | 110 message_hide(struct message *msg); |
101 | 111 |
112 /** | |
113 * Destroy owned resources. | |
114 * | |
115 * \pre msg != NULL | |
116 * \param msg the message | |
117 */ | |
118 void | |
119 message_finish(struct message *msg); | |
120 | |
102 #endif /* !MOLKO_MESSAGE_H */ | 121 #endif /* !MOLKO_MESSAGE_H */ |