[Fix] Minor flag bug and small menu no longer opens over dialogues.
This commit is contained in:
parent
a5d0c513e2
commit
25aa3e905f
@ -24,6 +24,8 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "dialogue.h"
|
#include "dialogue.h"
|
||||||
|
|
||||||
|
int dialogue_open; /**< Number of dialogues open. */
|
||||||
|
|
||||||
/* Extern. */
|
/* Extern. */
|
||||||
extern void main_loop(void); /* From lephisto.c */
|
extern void main_loop(void); /* From lephisto.c */
|
||||||
|
|
||||||
@ -39,6 +41,13 @@ static void dialogue_inputCancel(unsigned int wid, char* str);
|
|||||||
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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check to see if a dialogue is open.
|
||||||
|
*/
|
||||||
|
int dialogue_isOpen(void) {
|
||||||
|
return !!dialogue_open;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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.
|
||||||
@ -63,6 +72,8 @@ void dialogue_alert(const char* fmt, ...) {
|
|||||||
&gl_smallFont, &cBlack, msg);
|
&gl_smallFont, &cBlack, msg);
|
||||||
window_addButton(wdw, 135, 20, 50, 30, "btnOK", "OK",
|
window_addButton(wdw, 135, 20, 50, 30, "btnOK", "OK",
|
||||||
dialogue_alertClose);
|
dialogue_alertClose);
|
||||||
|
|
||||||
|
dialogue_open++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,6 +83,7 @@ void dialogue_alert(const char* fmt, ...) {
|
|||||||
static void dialogue_alertClose(unsigned int wid, char* str) {
|
static void dialogue_alertClose(unsigned int wid, char* str) {
|
||||||
(void)str;
|
(void)str;
|
||||||
window_destroy(wid);
|
window_destroy(wid);
|
||||||
|
dialogue_open--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,6 +155,7 @@ void dialogue_msg(char* caption, const char* fmt, ...) {
|
|||||||
window_addButton(msg_wid, (w-50)/2, 20, 50, 30, "btnOK", "OK",
|
window_addButton(msg_wid, (w-50)/2, 20, 50, 30, "btnOK", "OK",
|
||||||
dialogue_msgClose);
|
dialogue_msgClose);
|
||||||
|
|
||||||
|
dialogue_open++;
|
||||||
toolkit_loop();
|
toolkit_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +163,7 @@ static void dialogue_msgClose(unsigned int wid, char* str) {
|
|||||||
(void)str;
|
(void)str;
|
||||||
window_destroy(wid);
|
window_destroy(wid);
|
||||||
loop_done = 1;
|
loop_done = 1;
|
||||||
|
dialogue_open--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run a dialogue with a Yes and No button, return 1 if yes, 0 for no. */
|
/* Run a dialogue with a Yes and No button, return 1 if yes, 0 for no. */
|
||||||
@ -186,6 +200,7 @@ int dialogue_YesNo(char* caption, const char* fmt, ...) {
|
|||||||
dialogue_YesNoClose);
|
dialogue_YesNoClose);
|
||||||
|
|
||||||
/* Tricky secondary loop. */
|
/* Tricky secondary loop. */
|
||||||
|
dialogue_open++;
|
||||||
toolkit_loop();
|
toolkit_loop();
|
||||||
|
|
||||||
/* Return the result. */
|
/* Return the result. */
|
||||||
@ -202,6 +217,7 @@ static void dialogue_YesNoClose(unsigned int wid, char* str) {
|
|||||||
yesno_wid = 0;
|
yesno_wid = 0;
|
||||||
|
|
||||||
loop_done = 1;
|
loop_done = 1;
|
||||||
|
dialogue_open--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Toolkit input boxes, returns the input. */
|
/* Toolkit input boxes, returns the input. */
|
||||||
@ -243,6 +259,7 @@ char* dialogue_input(char* title, int min, int max, const char* fmt, ...) {
|
|||||||
"btnClose", "Done", dialogue_inputClose);
|
"btnClose", "Done", dialogue_inputClose);
|
||||||
|
|
||||||
/* Tricky secondary. */
|
/* Tricky secondary. */
|
||||||
|
dialogue_open++;
|
||||||
input = NULL;
|
input = NULL;
|
||||||
while(!input_cancelled && (!input ||
|
while(!input_cancelled && (!input ||
|
||||||
((int) strlen(input) < min))) { /* Must be longer than min. */
|
((int) strlen(input) < min))) { /* Must be longer than min. */
|
||||||
@ -265,6 +282,7 @@ char* dialogue_input(char* title, int min, int max, const char* fmt, ...) {
|
|||||||
/* Cleanup plox. */
|
/* Cleanup plox. */
|
||||||
window_destroy(input_wid);
|
window_destroy(input_wid);
|
||||||
input_wid = 0;
|
input_wid = 0;
|
||||||
|
dialogue_open--;
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
@ -8,3 +8,6 @@ void dialogue_msg(char* caption, const char* fmt, ...);
|
|||||||
int dialogue_YesNo(char* caption, const char* fmt, ...); /* Yes = 1, No = 0. */
|
int dialogue_YesNo(char* caption, const char* fmt, ...); /* Yes = 1, No = 0. */
|
||||||
char* dialogue_input(char* title, int min, int max, const char* fmt, ...);
|
char* dialogue_input(char* title, int min, int max, const char* fmt, ...);
|
||||||
|
|
||||||
|
/* Misc. */
|
||||||
|
int dialogue_isOpen(void);
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@
|
|||||||
#define BUTTON_WIDTH 90 /**< Button width, standard across menus. */
|
#define BUTTON_WIDTH 90 /**< Button width, standard across menus. */
|
||||||
#define BUTTON_HEIGHT 30 /**< Button height, standard across menus. */
|
#define BUTTON_HEIGHT 30 /**< Button height, standard across menus. */
|
||||||
|
|
||||||
#define menu_Open(f) (menu_open |= (f)) /**< Mark a menu as open. */
|
#define menu_Open(f) (menu_open |= (f)) /**< Mark a menu as open. */
|
||||||
#define menu_Close(f) (menu_open ^= (f)) /**< Mark a menu as closed. */
|
#define menu_Close(f) (menu_open &= ~(f)) /**< Mark a menu as closed. */
|
||||||
int menu_open = 0; /**< Store the opened/closed menus. */
|
int menu_open = 0; /**< Store the opened/closed menus. */
|
||||||
|
|
||||||
/* Main menu. */
|
/* Main menu. */
|
||||||
@ -189,6 +189,7 @@ void menu_small(void) {
|
|||||||
/* Check if menu should be openable. */
|
/* Check if menu should be openable. */
|
||||||
if((player == NULL) || player_isFlag(PLAYER_DESTROYED)
|
if((player == NULL) || player_isFlag(PLAYER_DESTROYED)
|
||||||
|| pilot_isFlag(player, PILOT_DEAD) ||
|
|| pilot_isFlag(player, PILOT_DEAD) ||
|
||||||
|
dialogue_isOpen() || /* Shouldn't open OVER dialogues. */
|
||||||
(menu_isOpen(MENU_MAIN) ||
|
(menu_isOpen(MENU_MAIN) ||
|
||||||
menu_isOpen(MENU_SMALL) ||
|
menu_isOpen(MENU_SMALL) ||
|
||||||
menu_isOpen(MENU_DEATH)))
|
menu_isOpen(MENU_DEATH)))
|
||||||
|
Loading…
Reference in New Issue
Block a user