[Change] Bringing dialogue stuff inline with rest of toolkit changes.

This commit is contained in:
Allanis 2014-01-14 20:33:21 +00:00
parent 66e1be552e
commit 4503785b1a

View File

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