Mercurial > molko
comparison src/core/message.h @ 64:da9b7462ab92
core: implement question, closes #2464 @2h
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 23 Jan 2020 20:44:01 +0100 |
parents | d07acc6ee4d9 |
children | 7187c0d9b9c0 |
comparison
equal
deleted
inserted
replaced
63:ec0872aaee07 | 64:da9b7462ab92 |
---|---|
27 #include <stdbool.h> | 27 #include <stdbool.h> |
28 | 28 |
29 struct texture; | 29 struct texture; |
30 struct font; | 30 struct font; |
31 | 31 |
32 union event; | |
33 | |
32 /** | 34 /** |
33 * \brief Message flags. | 35 * \brief Message flags. |
34 */ | 36 */ |
35 enum message_flags { | 37 enum message_flags { |
36 MESSAGE_AUTOMATIC = (1 << 0) /*!< Message will automatically close */ | 38 MESSAGE_AUTOMATIC = (1 << 0), /*!< Will automatically change state by itself. */ |
39 MESSAGE_QUESTION = (1 << 1) /*!< The message is a question. */ | |
37 }; | 40 }; |
38 | 41 |
39 /** | 42 /** |
40 * \brief Message state. | 43 * \brief Message state. |
41 */ | 44 */ |
42 enum message_state { | 45 enum message_state { |
43 MESSAGE_NONE, /*!< Message hasn't start yet or is finished */ | 46 MESSAGE_NONE, /*!< Message hasn't start yet or is finished */ |
44 MESSAGE_OPENING, /*!< Message animation is opening */ | 47 MESSAGE_OPENING, /*!< Message animation is opening */ |
45 MESSAGE_SHOWING, /*!< Message is displaying */ | 48 MESSAGE_SHOWING, /*!< Message is displaying */ |
46 MESSAGE_HIDING /*!< Message animation for hiding */ | 49 MESSAGE_HIDING /*!< Message animation for hiding */ |
47 }; | 50 }; |
48 | 51 |
49 /** | 52 /** |
50 * \brief Message object. | 53 * \brief Message object. |
51 * | 54 * |
55 struct message { | 58 struct message { |
56 const char *text[6]; /*!< (RW) Lines of text to show */ | 59 const char *text[6]; /*!< (RW) Lines of text to show */ |
57 struct texture *frame; /*!< (RW) Frame to use */ | 60 struct texture *frame; /*!< (RW) Frame to use */ |
58 struct texture *avatar; /*!< (RW) Optional avatar */ | 61 struct texture *avatar; /*!< (RW) Optional avatar */ |
59 struct font *font; /*!< (RW) Font to use */ | 62 struct font *font; /*!< (RW) Font to use */ |
60 unsigned long color; /*!< (RW) Font color to use */ | 63 unsigned long colors[2]; /*!< (RW) Normal/selected colors */ |
64 unsigned int index; /*!< (RW) Line selected */ | |
61 enum message_flags flags; /*!< (RW) Message flags */ | 65 enum message_flags flags; /*!< (RW) Message flags */ |
62 enum message_state state; /*!< (RO) Current state */ | 66 enum message_state state; /*!< (RO) Current state */ |
63 | 67 |
64 /* PRIVATE */ | 68 /*! \cond PRIVATE */ |
65 struct texture *ttext[6]; /*!< (RW) Textures for every lines */ | 69 |
66 struct texture *stext[6]; /*!< (RW) Textures for every lines */ | 70 struct texture *textures[12]; |
67 unsigned int elapsed; /*!< (RW) Elapsed time while displaying */ | 71 unsigned int elapsed; |
68 unsigned int alpha; /*!< (RO) Alpha progression */ | 72 int height[2]; |
73 | |
74 /*! \endcond */ | |
69 }; | 75 }; |
70 | 76 |
71 /** | 77 /** |
72 * Start opening the message. This function will reset the message state and | 78 * Start opening the message. This function will reset the message state and |
73 * elapsed time. | 79 * elapsed time. |
75 * \pre msg != NULL | 81 * \pre msg != NULL |
76 * \param msg the message | 82 * \param msg the message |
77 */ | 83 */ |
78 void | 84 void |
79 message_start(struct message *msg); | 85 message_start(struct message *msg); |
86 | |
87 /** | |
88 * Handle input events. | |
89 * | |
90 * This function will alter state of the message and change its selection in | |
91 * case of question. | |
92 * | |
93 * \pre msg != NULL | |
94 * \pre ev != NULL | |
95 * \param msg the message | |
96 * \param ev the event which occured | |
97 */ | |
98 void | |
99 message_handle(struct message *msg, const union event *ev); | |
80 | 100 |
81 /** | 101 /** |
82 * Update the message state and elapsed time.. | 102 * Update the message state and elapsed time.. |
83 * | 103 * |
84 * \pre msg != NULL | 104 * \pre msg != NULL |