keyboard setting menu created and tested, for both player can now the keys been set.

origin
stpohle 22 years ago
parent a34ab4b442
commit c618b51876

@ -9,8 +9,8 @@ enum _bcplayerkeys {
BCPK_down,
BCPK_left,
BCPK_right,
BCPK_special,
BCPK_drop,
BCPK_special,
BCPK_max
};
@ -36,8 +36,9 @@ struct {
extern BCGameKeys keyb_gamekeys;
extern void keyb_config ();
extern void keyb_configreset ();
extern void keyb_config_reset ();
extern void keyb_config_createkeymenu (int key, int x, int y, int menu_nr);
extern void keyb_config_readkey (int key);
extern void keyb_init ();
extern void keyb_loop (SDL_Event *event);

@ -1,4 +1,4 @@
/* $Id: configuration.c,v 1.54 2004/04/03 15:47:13 stpohle Exp $
/* $Id: configuration.c,v 1.55 2004/04/05 14:10:50 stpohle Exp $
* configuration */
#include <SDL.h>
@ -31,7 +31,7 @@ config_init (int argc, char **argv)
stonelist_del ();
chat.visible = 0;
chat.startline = 0;
keyb_configreset ();
keyb_config_reset ();
keybinput_new (&chat.input, KEYBI_text, 255);
for (i = 0; i < CHAT_MAX_LINES; i++)

@ -1,4 +1,4 @@
/* $Id: help.c,v 1.9 2004/04/03 14:48:43 stpohle Exp $
/* $Id: help.c,v 1.10 2004/04/05 14:10:50 stpohle Exp $
* Display complex help text and information screen about the game
*/
@ -211,11 +211,11 @@ void help () {
menu_create_text ("help", 5, y, 53, 10, COLOR_brown,
"Left/Right - Select and Deselect a Player\n"
"F1 - Mini Help Screen\n"
"F2 - Map and Game Settings\n"
"F3 - Create a AI Player\n"
"Shift-F3 - Delete a AI Player\n"
"F2 - Player Screen\n"
"F3 - Map and Game Settings\n"
"F4 - Start the Game if at last 2 Players\n"
" are selected. (only Server)\n"
"F5 - Chatmode (Exit whit ESC)\n"
"ESC - Exit Game\n");
}
else if (page == HP_credit0) {

@ -1,13 +1,18 @@
/* $Id: keyb.c,v 1.2 2004/04/03 15:47:13 stpohle Exp $
/* $Id: keyb.c,v 1.3 2004/04/05 14:10:50 stpohle Exp $
* keyb.c
*/
#include "bomberclone.h"
#include "network.h"
#include "ogcache-client.h"
#include "keyb.h"
#include "menu.h"
BCGameKeys keyb_gamekeys;
/*
* Translation table for the keycodes
*/
const struct _key_codes key_codetab [] = {
{ SDLK_RSHIFT, "RSHIFT" },
{ SDLK_LSHIFT, "LSHIFT" },
@ -37,7 +42,7 @@ const struct _key_codes key_codetab [] = {
/*
* set the default keyboard settings
*/
void keyb_configreset () {
void keyb_config_reset () {
/* player 1 */
keyb_gamekeys.keycode[BCPK_up] = SDLK_UP;
keyb_gamekeys.keycode[BCPK_down] = SDLK_DOWN;
@ -90,7 +95,7 @@ void keyb_code2text (int keycode, char *keytext) {
if (key_codetab[i].code == keycode)
strcpy (keytext, key_codetab[i].text);
else if ((keycode >= 'a' && keycode <= 'z')
|| (keycode >= 'Z' && keycode <= 'Z')
|| (keycode >= 'A' && keycode <= 'Z')
|| (keycode >= '0' && keycode <= '9'))
sprintf (keytext, "%c", keycode);
else
@ -129,7 +134,7 @@ void keyb_config_createkeymenu (int key, int x, int y, int menu_nr) {
case (BCPK_special):
strcpy (keyname, "Special");
break;
case (BCK_chat):
/* case (BCK_chat):
strcpy (keyname, "Chat");
break;
case (BCK_fullscreen):
@ -146,27 +151,115 @@ void keyb_config_createkeymenu (int key, int x, int y, int menu_nr) {
break;
case (BCK_pause):
strcpy (keyname, "Pause/Start");
break;
break; */
}
menu_create_label ("UP", x, y + 2, 0, COLOR_brown);
menu_create_label (keyname, x, y + 2, 0, COLOR_brown);
keyb_code2text (keyb_gamekeys.keycode[key], keytext);
menu_create_button (keytext, x + 50, y, 100, menu_nr);
menu_create_button (keytext, x + 50, y, 100, menu_nr + key);
}
/*
* select a new key for the function,
*/
void keyb_config_readkey (int key) {
int newkey;
SDL_Event event;
Uint8 *keys;
int keypressed = 0,
done = 0,
eventstate = 0,
reorder = 0;
newkey = 0;
if (key < 0 || key >= BCK_max)
return;
menu_displaytext ("Keyboard Config", "Please press the new key\nfor this function.");
keys = SDL_GetKeyState (NULL);
if (keys[SDLK_RETURN] || keys[SDLK_ESCAPE])
keypressed = 1;
timestamp = SDL_GetTicks (); // needed for time sync.
while (!reorder && !done && bman.state != GS_quit) {
/* do the network loop if we have to */
if (bman.sock > 0) {
network_loop ();
if (bman.notifygamemaster)
reorder = ogc_loop ();
else
reorder = 0;
}
eventstate = SDL_PollEvent (&event);
if (eventstate >= 1) {
switch (event.type) {
case (SDL_QUIT):
bman.state = GS_quit;
done = 1;
break;
case (SDL_KEYDOWN): /* focus next element */
newkey = event.key.keysym.sym;
done = 1;
break;
}
}
s_calctimesync ();
}
if (newkey != 0 && newkey != SDLK_ESCAPE)
keyb_gamekeys.keycode[key] = newkey;
};
/*
* keyboard configuration screen
*/
void keyb_config () {
int menuselect = 1;
do {
menu_new ("Keyboard Config", 420, 400);
menu_create_label ("Player 1", 100, 50, 2, COLOR_brown);
keyb_config_createkeymenu (BCPK_up, 25, 90, 1);
keyb_config_createkeymenu (BCPK_down, 25, 120, 2);
keyb_config_createkeymenu (BCPK_left, 25, 150, 3);
keyb_config_createkeymenu (BCPK_right, 25, 180, 4);
menu_loop ();
menu_create_label ("Player 1", 10, 50, 2, COLOR_brown);
keyb_config_createkeymenu (BCPK_up, 25, 90, 10);
keyb_config_createkeymenu (BCPK_down, 25, 120, 10);
keyb_config_createkeymenu (BCPK_left, 25, 150, 10);
keyb_config_createkeymenu (BCPK_right, 25, 180, 10);
keyb_config_createkeymenu (BCPK_drop, 25, 210, 10);
keyb_config_createkeymenu (BCPK_special, 25, 240, 10);
menu_create_label ("Player 2", 200, 50, 2, COLOR_brown);
keyb_config_createkeymenu (BCPK_max + BCPK_up, 225, 90, 10);
keyb_config_createkeymenu (BCPK_max + BCPK_down, 225, 120, 10);
keyb_config_createkeymenu (BCPK_max + BCPK_left, 225, 150, 10);
keyb_config_createkeymenu (BCPK_max + BCPK_right, 225, 180, 10);
keyb_config_createkeymenu (BCPK_max + BCPK_drop, 225, 210, 10);
keyb_config_createkeymenu (BCPK_max + BCPK_special, 225, 240, 10);
/*menu_create_label ("Other Keys", -1, 270, 2, COLOR_brown);
keyb_config_createkeymenu (BCK_help, 25, 300, 10);
keyb_config_createkeymenu (BCK_chat, 25, 330, 10);
keyb_config_createkeymenu (BCK_fullscreen, 25, 360, 10);
keyb_config_createkeymenu (BCK_mapmenu, 225, 300, 10);
keyb_config_createkeymenu (BCK_playermenu, 225, 330, 10);
keyb_config_createkeymenu (BCK_pause, 225, 360, 10); */
menu_create_button ("Default", 50, 280, 150, 2);
menu_create_button ("OK", 250, 280, 150, 1);
menu_focus_id (menuselect);
menuselect = menu_loop ();
menu_delete ();
if (menuselect ==2)
keyb_config_reset ();
if (menuselect >= 10 && menuselect < 10+BCK_max)
keyb_config_readkey (menuselect - 10);
} while (menuselect != 1 && menuselect != -1);
};

Loading…
Cancel
Save