diff 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
line wrap: on
line diff
--- a/src/core/message.h	Thu Jan 23 13:48:49 2020 +0100
+++ b/src/core/message.h	Thu Jan 23 20:44:01 2020 +0100
@@ -29,21 +29,24 @@
 struct texture;
 struct font;
 
+union event;
+
 /**
  * \brief Message flags.
  */
 enum message_flags {
-	MESSAGE_AUTOMATIC = (1 << 0)    /*!< Message will automatically close */
+	MESSAGE_AUTOMATIC       = (1 << 0),     /*!< Will automatically change state by itself. */
+	MESSAGE_QUESTION        = (1 << 1)      /*!< The message is a question. */
 };
 
 /**
  * \brief Message state.
  */
 enum message_state {
-	MESSAGE_NONE,                   /*!< Message hasn't start yet or is finished */
-	MESSAGE_OPENING,                /*!< Message animation is opening */
-	MESSAGE_SHOWING,                /*!< Message is displaying */
-	MESSAGE_HIDING                  /*!< Message animation for hiding */
+	MESSAGE_NONE,           /*!< Message hasn't start yet or is finished */
+	MESSAGE_OPENING,        /*!< Message animation is opening */
+	MESSAGE_SHOWING,        /*!< Message is displaying */
+	MESSAGE_HIDING          /*!< Message animation for hiding */
 };
 
 /**
@@ -57,15 +60,18 @@
 	struct texture *frame;          /*!< (RW) Frame to use */
 	struct texture *avatar;         /*!< (RW) Optional avatar */
 	struct font *font;              /*!< (RW) Font to use */
-	unsigned long color;            /*!< (RW) Font color to use */
+	unsigned long colors[2];        /*!< (RW) Normal/selected colors */
+	unsigned int index;             /*!< (RW) Line selected */
 	enum message_flags flags;       /*!< (RW) Message flags */
 	enum message_state state;       /*!< (RO) Current state */
 
-	/* PRIVATE */
-	struct texture *ttext[6];       /*!< (RW) Textures for every lines */
-	struct texture *stext[6];       /*!< (RW) Textures for every lines */
-	unsigned int elapsed;           /*!< (RW) Elapsed time while displaying */
-	unsigned int alpha;             /*!< (RO) Alpha progression */
+	/*! \cond PRIVATE */
+
+	struct texture *textures[12];
+	unsigned int elapsed;
+	int height[2];
+
+	/*! \endcond */
 };
 
 /**
@@ -79,6 +85,20 @@
 message_start(struct message *msg);
 
 /**
+ * Handle input events.
+ *
+ * This function will alter state of the message and change its selection in
+ * case of question.
+ *
+ * \pre msg != NULL
+ * \pre ev != NULL
+ * \param msg the message
+ * \param ev the event which occured
+ */
+void
+message_handle(struct message *msg, const union event *ev);
+
+/**
  * Update the message state and elapsed time..
  *
  * \pre msg != NULL