|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: menu.c,v 1.5 2003/05/04 21:00:30 ob1kenewb Exp $ */
|
|
|
|
|
/* $Id: menu.c,v 1.6 2003/05/06 12:25:30 stpohle Exp $ */
|
|
|
|
|
/* menu's for the game */
|
|
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
@ -115,19 +115,20 @@ menu_loop (char *menutitle, _menu menu[], int lastselect)
|
|
|
|
|
by;
|
|
|
|
|
|
|
|
|
|
draw_logo ();
|
|
|
|
|
|
|
|
|
|
draw_menu (menutitle, menu, &bx, &by);
|
|
|
|
|
|
|
|
|
|
SDL_Flip (gfx.screen);
|
|
|
|
|
|
|
|
|
|
for (lastentry = 0; menu[lastentry].index != -1; lastentry++);
|
|
|
|
|
|
|
|
|
|
while ((!done || keypressed == 1) && bman.state != GS_quit) {
|
|
|
|
|
draw_select (menuselect, menu, bx, by);
|
|
|
|
|
|
|
|
|
|
SDL_Flip (gfx.screen);
|
|
|
|
|
|
|
|
|
|
if (SDL_WaitEvent (&event) != 0)
|
|
|
|
|
/* do the network loop if we have to */
|
|
|
|
|
if (bman.gametype == GT_multi && bman.sock != -1)
|
|
|
|
|
network_loop ();
|
|
|
|
|
|
|
|
|
|
if (SDL_PollEvent (&event) != 0)
|
|
|
|
|
switch (event.type) {
|
|
|
|
|
case (SDL_QUIT):
|
|
|
|
|
menuselect = -1;
|
|
|
|
@ -137,19 +138,22 @@ menu_loop (char *menutitle, _menu menu[], int lastselect)
|
|
|
|
|
|
|
|
|
|
/* keyboard handling */
|
|
|
|
|
keys = SDL_GetKeyState (NULL);
|
|
|
|
|
if (keys[SDLK_DOWN] && event.type == SDL_KEYDOWN) {
|
|
|
|
|
if (keys[SDLK_DOWN] && event.type == SDL_KEYDOWN && keypressed == 0) {
|
|
|
|
|
keypressed = 1;
|
|
|
|
|
menuselect++;
|
|
|
|
|
if (menuselect >= lastentry)
|
|
|
|
|
menuselect = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keys[SDLK_UP] && event.type == SDL_KEYDOWN) {
|
|
|
|
|
if (keys[SDLK_UP] && event.type == SDL_KEYDOWN && keypressed == 0) {
|
|
|
|
|
keypressed = 1;
|
|
|
|
|
menuselect--;
|
|
|
|
|
if (menuselect < 0)
|
|
|
|
|
menuselect = lastentry - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) {
|
|
|
|
|
keypressed = 1;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (!keys[SDLK_ESCAPE] && event.type == SDL_KEYUP)
|
|
|
|
@ -162,7 +166,8 @@ menu_loop (char *menutitle, _menu menu[], int lastselect)
|
|
|
|
|
if (!keys[SDLK_RETURN] && event.type == SDL_KEYUP)
|
|
|
|
|
keypressed = 0;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
s_delay (100);
|
|
|
|
|
};
|
|
|
|
|
return menuselect;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -207,12 +212,14 @@ menu_get_text (char *title, char *text, int len)
|
|
|
|
|
|
|
|
|
|
redraw_logo_shaded (x, y, (gfx.font.size.x - 4) * len_, gfx.font.size.y, MENU_BG_SHADE_DARK);
|
|
|
|
|
draw_text (x, y, t, 1);
|
|
|
|
|
|
|
|
|
|
draw_text (x + (gfx.font.size.x - 4) * curpos, y, "_", 1);
|
|
|
|
|
|
|
|
|
|
SDL_Flip (gfx.screen);
|
|
|
|
|
|
|
|
|
|
if (SDL_WaitEvent (&event) != 0)
|
|
|
|
|
/* do the network loop if we have to */
|
|
|
|
|
if (bman.gametype == GT_multi && bman.sock != -1)
|
|
|
|
|
network_loop ();
|
|
|
|
|
|
|
|
|
|
if (SDL_PollEvent (&event) != 0)
|
|
|
|
|
switch (event.type) {
|
|
|
|
|
case (SDL_QUIT):
|
|
|
|
|
bman.state = GS_quit;
|
|
|
|
@ -263,6 +270,7 @@ menu_get_text (char *title, char *text, int len)
|
|
|
|
|
if (event.type == SDL_KEYUP)
|
|
|
|
|
keypressed = 0;
|
|
|
|
|
|
|
|
|
|
s_delay (100);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -313,7 +321,11 @@ menu_displaymessage (char *title, char *text)
|
|
|
|
|
menu_displaytext (title, text, 64, 0, 0);
|
|
|
|
|
|
|
|
|
|
while (done == 0 || (done == 1 && keypressed == 1)) {
|
|
|
|
|
if (SDL_WaitEvent (&event) != 0)
|
|
|
|
|
/* do the network loop if we have to */
|
|
|
|
|
if (bman.gametype == GT_multi && bman.sock != -1)
|
|
|
|
|
network_loop ();
|
|
|
|
|
|
|
|
|
|
if (SDL_PollEvent (&event) != 0)
|
|
|
|
|
switch (event.type) {
|
|
|
|
|
case (SDL_QUIT):
|
|
|
|
|
done = 1;
|
|
|
|
@ -333,6 +345,8 @@ menu_displaymessage (char *title, char *text)
|
|
|
|
|
|
|
|
|
|
if (event.type == SDL_KEYUP)
|
|
|
|
|
keypressed = 0;
|
|
|
|
|
|
|
|
|
|
s_delay (100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|