Modal message box updates.
This commit is contained in:
parent
368e9dc592
commit
a2a1ec0613
|
@ -14,7 +14,7 @@
|
||||||
"group" : "okCancel",
|
"group" : "okCancel",
|
||||||
"type" : "WT_BUTTON",
|
"type" : "WT_BUTTON",
|
||||||
"text" : "OK",
|
"text" : "OK",
|
||||||
"x" : 490,
|
"x" : 530,
|
||||||
"y" : 680,
|
"y" : 680,
|
||||||
"w" : 150,
|
"w" : 150,
|
||||||
"h": 34
|
"h": 34
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
"group" : "okCancel",
|
"group" : "okCancel",
|
||||||
"type" : "WT_BUTTON",
|
"type" : "WT_BUTTON",
|
||||||
"text" : "Cancel",
|
"text" : "Cancel",
|
||||||
"x" : 790,
|
"x" : 730,
|
||||||
"y" : 680,
|
"y" : 680,
|
||||||
"w" : 150,
|
"w" : 150,
|
||||||
"h": 34
|
"h": 34
|
||||||
|
|
|
@ -64,7 +64,6 @@ extern void resetWaypoints(void);
|
||||||
extern void doPlayerSelect(void);
|
extern void doPlayerSelect(void);
|
||||||
extern void destroyQuadtree(void);
|
extern void destroyQuadtree(void);
|
||||||
extern void initQuadtree(Quadtree *root);
|
extern void initQuadtree(Quadtree *root);
|
||||||
extern void completeMission(void);
|
|
||||||
extern void initEffects(void);
|
extern void initEffects(void);
|
||||||
extern void doScript(void);
|
extern void doScript(void);
|
||||||
extern void destroyScript(void);
|
extern void destroyScript(void);
|
||||||
|
|
|
@ -45,10 +45,9 @@ static void startMission(void);
|
||||||
static void returnFromOptions(void);
|
static void returnFromOptions(void);
|
||||||
static void doStarSystemView(void);
|
static void doStarSystemView(void);
|
||||||
static void updatePandoranAdvance(void);
|
static void updatePandoranAdvance(void);
|
||||||
static void drawFallenView(void);
|
|
||||||
static void fallenOK(void);
|
static void fallenOK(void);
|
||||||
|
|
||||||
static StarSystem *selectedStarSystem, *fallenStarSystem;
|
static StarSystem *selectedStarSystem;
|
||||||
static Mission *selectedMission = {0};
|
static Mission *selectedMission = {0};
|
||||||
static SDL_Texture *background;
|
static SDL_Texture *background;
|
||||||
static SDL_Texture *starSystemTexture;
|
static SDL_Texture *starSystemTexture;
|
||||||
|
@ -121,7 +120,9 @@ void initGalacticMap(void)
|
||||||
|
|
||||||
static void updatePandoranAdvance(void)
|
static void updatePandoranAdvance(void)
|
||||||
{
|
{
|
||||||
StarSystem *starSystem;
|
StarSystem *starSystem, *fallenStarSystem;
|
||||||
|
|
||||||
|
fallenStarSystem = NULL;
|
||||||
|
|
||||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||||
{
|
{
|
||||||
|
@ -129,11 +130,14 @@ static void updatePandoranAdvance(void)
|
||||||
{
|
{
|
||||||
starSystem->side = SIDE_PANDORAN;
|
starSystem->side = SIDE_PANDORAN;
|
||||||
|
|
||||||
show = SHOW_FALLEN_MESSAGE;
|
|
||||||
|
|
||||||
fallenStarSystem = starSystem;
|
fallenStarSystem = starSystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fallenStarSystem)
|
||||||
|
{
|
||||||
|
showOKDialog(&fallenOK, "%s has fallen to the Pandorans", fallenStarSystem->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void logic(void)
|
static void logic(void)
|
||||||
|
@ -339,10 +343,6 @@ static void draw(void)
|
||||||
case SHOW_OPTIONS:
|
case SHOW_OPTIONS:
|
||||||
drawOptions();
|
drawOptions();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_FALLEN_MESSAGE:
|
|
||||||
drawFallenView();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,29 +569,8 @@ static void drawStarSystemDetail(void)
|
||||||
static void fallenOK(void)
|
static void fallenOK(void)
|
||||||
{
|
{
|
||||||
show = SHOW_GALAXY;
|
show = SHOW_GALAXY;
|
||||||
}
|
|
||||||
|
|
||||||
static void drawFallenView(void)
|
|
||||||
{
|
|
||||||
SDL_Rect r;
|
|
||||||
|
|
||||||
r.w = 800;
|
app.modalDialog.type = MD_NONE;
|
||||||
r.h = 150;
|
|
||||||
r.x = (SCREEN_WIDTH / 2) - (r.w / 2);
|
|
||||||
r.y = (SCREEN_HEIGHT / 2) - (r.h / 2);
|
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 225);
|
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 200);
|
|
||||||
SDL_RenderDrawRect(app.renderer, &r);
|
|
||||||
|
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
|
||||||
|
|
||||||
drawText(SCREEN_WIDTH / 2, r.y + 25, 24, TA_CENTER, colors.white, "%s has fallen to the Pandorans", fallenStarSystem->name);
|
|
||||||
|
|
||||||
drawWidgets("fallen");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleKeyboard(void)
|
static void handleKeyboard(void)
|
||||||
|
|
|
@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define SHOW_MENU 2
|
#define SHOW_MENU 2
|
||||||
#define SHOW_OPTIONS 3
|
#define SHOW_OPTIONS 3
|
||||||
#define SHOW_STATS 4
|
#define SHOW_STATS 4
|
||||||
#define SHOW_FALLEN_MESSAGE 5
|
|
||||||
|
|
||||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||||
extern void initBattle(void);
|
extern void initBattle(void);
|
||||||
|
@ -59,6 +58,7 @@ extern void initStatsDisplay(void);
|
||||||
extern void updateStarSystemMissions(void);
|
extern void updateStarSystemMissions(void);
|
||||||
extern StarSystem *getStarSystem(char *name);
|
extern StarSystem *getStarSystem(char *name);
|
||||||
extern void setMouse(int x, int y);
|
extern void setMouse(int x, int y);
|
||||||
|
extern void showOKDialog(void (*callback)(void), const char *format, ...);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
|
@ -50,9 +50,6 @@ int main(int argc, char *argv[])
|
||||||
lastFrameTime = SDL_GetTicks() + 1000;
|
lastFrameTime = SDL_GetTicks() + 1000;
|
||||||
expireTextTimer = SDL_GetTicks() + (1000 * 10);
|
expireTextTimer = SDL_GetTicks() + (1000 * 10);
|
||||||
|
|
||||||
app.modalDialog.type = MD_OK;
|
|
||||||
STRNCPY(app.modalDialog.message, "This is a longer message. This is a longer message. This is a longer message. This is a longer message. This is a longer message. This is a longer message. This is a longer message. This is a longer message. This is a longer message. ", MAX_DESCRIPTION_LENGTH);
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
td += (SDL_GetTicks() - then);
|
td += (SDL_GetTicks() - then);
|
||||||
|
|
|
@ -73,7 +73,6 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int type;
|
int type;
|
||||||
int result;
|
|
||||||
char message[MAX_DESCRIPTION_LENGTH];
|
char message[MAX_DESCRIPTION_LENGTH];
|
||||||
} ModalDialog;
|
} ModalDialog;
|
||||||
|
|
||||||
|
@ -342,6 +341,7 @@ struct Widget {
|
||||||
int currentOption;
|
int currentOption;
|
||||||
int visible;
|
int visible;
|
||||||
int enabled;
|
int enabled;
|
||||||
|
int isModal;
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
void (*action)(void);
|
void (*action)(void);
|
||||||
|
|
|
@ -23,12 +23,56 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
static Widget *ok;
|
static Widget *ok;
|
||||||
static Widget *okCancelOK;
|
static Widget *okCancelOK;
|
||||||
static Widget *okCancelCancel;
|
static Widget *okCancelCancel;
|
||||||
|
static char textBuffer[MAX_DESCRIPTION_LENGTH];
|
||||||
|
|
||||||
void initModalDialog(void)
|
void initModalDialog(void)
|
||||||
{
|
{
|
||||||
ok = getWidget("ok", "ok");
|
ok = getWidget("ok", "ok");
|
||||||
|
ok->action = NULL;
|
||||||
|
ok->isModal = 1;
|
||||||
|
|
||||||
okCancelOK = getWidget("ok", "okCancel");
|
okCancelOK = getWidget("ok", "okCancel");
|
||||||
|
okCancelOK->action = NULL;
|
||||||
|
okCancelOK->isModal = 1;
|
||||||
|
|
||||||
okCancelCancel = getWidget("cancel", "okCancel");
|
okCancelCancel = getWidget("cancel", "okCancel");
|
||||||
|
okCancelCancel->action = NULL;
|
||||||
|
okCancelCancel->isModal = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void showOKDialog(void (*callback)(void), const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
memset(&textBuffer, '\0', sizeof(textBuffer));
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
vsprintf(textBuffer, format, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
STRNCPY(app.modalDialog.message, textBuffer, MAX_DESCRIPTION_LENGTH);
|
||||||
|
|
||||||
|
app.modalDialog.type = MD_OK;
|
||||||
|
|
||||||
|
ok->action = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void), const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
memset(&textBuffer, '\0', sizeof(textBuffer));
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
vsprintf(textBuffer, format, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
STRNCPY(app.modalDialog.message, textBuffer, MAX_DESCRIPTION_LENGTH);
|
||||||
|
|
||||||
|
app.modalDialog.type = MD_OK_CANCEL;
|
||||||
|
|
||||||
|
okCancelOK->action = okCallback;
|
||||||
|
okCancelCancel->action = cancelCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doModalDialog(void)
|
void doModalDialog(void)
|
||||||
|
|
|
@ -95,7 +95,7 @@ void drawWidgets(const char *group)
|
||||||
|
|
||||||
for (w = head.next; w != NULL ; w = w->next)
|
for (w = head.next; w != NULL ; w = w->next)
|
||||||
{
|
{
|
||||||
if (w->visible && strcmp(w->group, group) == 0)
|
if ((app.modalDialog.type == MD_NONE || (app.modalDialog.type != MD_NONE && w->isModal)) && w->visible && strcmp(w->group, group) == 0)
|
||||||
{
|
{
|
||||||
if (!mouseOver)
|
if (!mouseOver)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue