From 4503785b1ada73aabe3dc25b3b887e72f8487a8f Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Tue, 14 Jan 2014 20:33:21 +0000
Subject: [PATCH] [Change] Bringing dialogue stuff inline with rest of toolkit
 changes.

---
 src/dialogue.c | 42 ++++++++++++++++--------------------------
 1 file changed, 16 insertions(+), 26 deletions(-)

diff --git a/src/dialogue.c b/src/dialogue.c
index d9eebde..8661ee2 100644
--- a/src/dialogue.c
+++ b/src/dialogue.c
@@ -29,19 +29,17 @@ extern void main_loop(void); /* From lephisto.c */
 
 /* Dialogues. */
 static glFont* dialogue_getSize(char* msg, int* w, int* h);
-static void dialogue_alertClose(char* str);
-static void dialogue_msgClose(char* str);
-static void dialogue_YesNoClose(char* str);
-static void dialogue_inputClose(char* str);
-static void dialogue_inputCancel(char* str);
+static void dialogue_alertClose(unsigned int wid, char* str);
+static void dialogue_msgClose(unsigned int wid, char* str);
+static void dialogue_YesNoClose(unsigned int wid, char* str);
+static void dialogue_inputClose(unsigned int wid, char* str);
+static void dialogue_inputCancel(unsigned int wid, char* str);
 
 /* Secondary loop hack. */
 static int loop_done;   /**< Used to indicate the secondary loop is finished. */
 static int toolkit_loop(void);
 
 /**
- * @fn void dialogue_alert(const char* fmt, ...)
- *
  * @brief Display an alert popup with only an ok button and a message.
  *    @param fmt Printf stype message to display.
  */
@@ -51,8 +49,6 @@ void dialogue_alert(const char* fmt, ...) {
   unsigned int wdw;
   int h;
 
-  if(window_exists("Warning")) return;
-  
   if(fmt == NULL) return;
   else { /* Get the message. */
     va_start(ap, fmt);
@@ -70,15 +66,12 @@ void dialogue_alert(const char* fmt, ...) {
 }
 
 /**
- * @fn static void dialogue_alertClose(char* str)
- *
  * @brief Closes the alert dialogue.
  *    @param str Unused.
  */
-static void dialogue_alertClose(char* str) {
+static void dialogue_alertClose(unsigned int wid, char* str) {
   (void)str;
-  if(window_exists("Warning"))
-    window_destroy(window_get("Warning"));
+  window_destroy(wid);
 }
 
 /**
@@ -104,10 +97,7 @@ static glFont* dialogue_getSize(char* msg, int* w, int* h) {
   return font;
 }
 
-static unsigned int msg_wid = 0; /**< Stores the message window id. */
 /**
- * @fn void dialogue_msg(char* caption, const char* fmt, ...)
- *
  * @brief Open a dialogue window with an OK button and a message.
  *    @param caption Window title.
  *    @param fmt Printf syle message to display.
@@ -118,7 +108,7 @@ void dialogue_msg(char* caption, const char* fmt, ...) {
   int w, h;
   glFont* font;
 
-  if(msg_wid) return;
+  unsigned int msg_wid;
 
   if(fmt == NULL) return;
   else {
@@ -140,10 +130,9 @@ void dialogue_msg(char* caption, const char* fmt, ...) {
   toolkit_loop();
 }
 
-static void dialogue_msgClose(char* str) {
+static void dialogue_msgClose(unsigned int wid, char* str) {
   (void)str;
-  window_destroy(msg_wid);
-  msg_wid = 0;
+  window_destroy(wid);
   loop_done = 1;
 }
 
@@ -188,13 +177,13 @@ int dialogue_YesNo(char* caption, const char* fmt, ...) {
   return yesno_result;
 }
 
-static void dialogue_YesNoClose(char* str) {
+static void dialogue_YesNoClose(unsigned int wid, char* str) {
   /* Store the result. */
   if(strcmp(str, "btnYes")==0) yesno_result = 1;
   else if(strcmp(str, "btnNo")==0) yesno_result = 0;
 
   /* Destroy the window. */
-  window_destroy(yesno_wid);
+  window_destroy(wid);
   yesno_wid = 0;
   
   loop_done = 1;
@@ -265,16 +254,17 @@ char* dialogue_input(char* title, int min, int max, const char* fmt, ...) {
   return input;
 }
 
-static void dialogue_inputClose(char* str) {
+static void dialogue_inputClose(unsigned int wid, char* str) {
   (void)str;
+  (void)wid;
 
   /* Break the loop. */
   loop_done = 1;
 }
 
-static void dialogue_inputCancel(char* str) {
+static void dialogue_inputCancel(unsigned int wid, char* str) {
   input_cancelled = 1;
-  dialogue_inputClose(str);
+  dialogue_inputClose(wid, str);
 }
 
 /*