Prompt for flush keyboardbuffer at startup

origin rel-0-9-8
patty21 23 years ago
parent 2b7afe5f34
commit 33569c58c5

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.17 2003/05/08 14:35:48 stpohle Exp $ */
/* $Id: bomberclone.h,v 1.18 2003/05/10 00:36:03 patty21 Exp $ */
/* bomberclone.h */
#ifndef _BOMBERCLONE_H_
@ -214,6 +214,7 @@ extern void menu_get_text (char *title, char *text, int len);
extern void menu_displaymessage (char *title, char *text);
extern void menu_displaytext (char *title, char *text, Uint8 r, Uint8 g, Uint8 b);
extern char *menu_dir_select (char *title, char *path, signed char dirflags);
void menu_clearkeybuff();
// configuration
extern void configuration ();

@ -17,7 +17,7 @@ void
gamesrv_getserver ()
{
int i,
keypressed = 0,
keypressed = 1,
done = 0,
ds = 0,
gserv = bman.notifygamemaster,

@ -41,7 +41,8 @@ main (int argc, char **argv)
gfx_init ();
if (bman.askplayername)
menu_get_text ("Please You Playername", bman.playername, LEN_PLAYERNAME);
}
else menu_clearkeybuff();
}
ReadPrgArgs (argc, argv);
sprintf(text,"Welcome to BomberClone");

@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.19 2003/05/08 20:36:13 patty21 Exp $ */
/* $Id: menu.c,v 1.20 2003/05/10 00:36:03 patty21 Exp $ */
/* menu's for the game */
#include <SDL.h>
@ -110,18 +110,18 @@ menu_loop (char *menutitle, _menu menu[], int lastselect)
lastentry;
SDL_Event event;
Uint8 *keys;
int keypressed = 1;
int keypressed = 0,
int bx,
bx,
by;
draw_logo ();
draw_logo ();
draw_menu (menutitle, menu, &bx, &by);
for (lastentry = 0; menu[lastentry].index != -1; lastentry++);
draw_select (menuselect, menu, bx, by);
SDL_Flip (gfx.screen);
while (menuselect != -1 && done == 0) {
keys=SDL_GetKeyState (NULL);
if (keys[SDLK_RETURN] || keys[SDLK_ESCAPE] ) keypressed=1;
while (menuselect != -1 && done == 0) {
/* do the network loop if we have to */
if (bman.gametype == GT_multi && bman.sock != -1)
@ -133,12 +133,13 @@ menu_loop (char *menutitle, _menu menu[], int lastselect)
menuselect = -1;
bman.state = GS_quit;
done = 1;
}
break;
}
/* keyboard handling */
keys = SDL_GetKeyState (NULL);
if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) {
if (keys[SDLK_ESCAPE] && (!keypressed)) {
/* we want to quit */
keypressed = 1;
menuselect = -1;
@ -167,14 +168,19 @@ menu_loop (char *menutitle, _menu menu[], int lastselect)
ds = 1;
}
if (keys[SDLK_RETURN] && (!keypressed)) {
if (keys[SDLK_RETURN] && (!keypressed) && (event.type=SDL_KEYDOWN)) {
done=1;
keypressed = 1;
}
// d_printf("return pressed - done=1\n");
}
if (event.type == SDL_KEYUP)
keypressed = 0;
{ // d_printf("keyup\n");
keypressed = 0;}
else if (event.type == SDL_KEYDOWN)
keypressed = 1;
{
// d_printf("keydown\n");
keypressed = 1;}
if (ds) {
draw_select (menuselect, menu, bx, by);
@ -365,6 +371,29 @@ menu_displaymessage (char *title, char *text)
}
};
void menu_clearkeybuff () {
SDL_Event event;
Uint8 *keys;
int i;
SDL_PollEvent (&event);
keys=SDL_GetKeyState (NULL);
if (!(keys[SDLK_RETURN])) return;
for(i=0;i<20;i++) {
s_delay(25);
SDL_PollEvent (&event);
keys=SDL_GetKeyState (NULL);
if (!(keys[SDLK_RETURN])) return;
}
menu_displaytext (""," Press Return ", 64, 0, 0);
while (keys[SDLK_RETURN]) {
s_delay(25);
SDL_PollEvent (&event);
keys=SDL_GetKeyState (NULL);
}
}
/***
*** Menu Selection of a file ior a directory
***/

Loading…
Cancel
Save