video menu and option menu got mixed up after the video menu was selected

origin r0-11-0
stpohle 22 years ago
parent 3196ca7110
commit 67f576a28b

@ -1,9 +1,9 @@
$Id: ChangeLog,v 1.50 2004/01/06 20:49:57 stpohle Exp $ $Id: ChangeLog,v 1.51 2004/01/06 23:07:21 stpohle Exp $
Version 0.11.0 Version 0.11.0
============== ==============
2004-01-06 2004-01-06
- Added Programm flags to the game. For more information - Added Programm options to the game. For more information
run BomberClone with -help. run BomberClone with -help.
- Compiler Flag added for disabling debuging. Compiler - Compiler Flag added for disabling debuging. Compiler

@ -19,13 +19,13 @@ config_init (int argc, char **argv)
srand (((int) time (NULL))); // initialize randomgenerator srand (((int) time (NULL))); // initialize randomgenerator
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
players[i].gfx = NULL; /* we will select them in the wait_for_players loop */ players[i].gfx = NULL; /* we will select them in the wait_for_players loop */
players[i].gfx_nr = -1; /* and even now in the singleplayer menu */ players[i].gfx_nr = -1; /* and even now in the singleplayer menu */
} }
menu.oldscreen = NULL; menu.oldscreen = NULL;
stonelist_del (); stonelist_del ();
chat.visible = 0; chat.visible = 0;
chat.startline = 0; chat.startline = 0;
keybinput_new (&chat.input, KEYBI_text, 255); keybinput_new (&chat.input, KEYBI_text, 255);
@ -35,7 +35,7 @@ config_init (int argc, char **argv)
bman.maxplayer = MAX_PLAYERS; bman.maxplayer = MAX_PLAYERS;
bman.net_ai_family = PF_INET; bman.net_ai_family = PF_INET;
bman.sock = -1; bman.sock = -1;
bman.gamename[0] = 0; bman.gamename[0] = 0;
sprintf (bman.port, "%d", DEFAULT_UDPPORT); sprintf (bman.port, "%d", DEFAULT_UDPPORT);
sprintf (bman.ogcserver, DEFAULT_GAMECACHE); sprintf (bman.ogcserver, DEFAULT_GAMECACHE);
@ -47,58 +47,60 @@ config_init (int argc, char **argv)
debug = 0; debug = 0;
gfx.res.x = 640; gfx.res.x = 640;
gfx.res.y = 480; gfx.res.y = 480;
gfx.bpp = 16; gfx.bpp = 16;
map.tileset[0] = 0; map.tileset[0] = 0;
map.random_tileset = 1; map.random_tileset = 1;
map.size.x = 25; map.size.x = 25;
map.size.y = 17; map.size.y = 17;
sprintf (bman.datapath, PACKAGE_DATA_DIR); sprintf (bman.datapath, PACKAGE_DATA_DIR);
map.map[0] = 0; map.map[0] = 0;
map.map_selection = 2; map.map_selection = 2;
map.type = -1; map.type = -1;
bman.firewall = 0; bman.firewall = 0;
bman.init_timeout = GAME_TIMEOUT; bman.init_timeout = GAME_TIMEOUT;
bman.ai_players = 1; bman.ai_players = 1;
snd.inited = 0; snd.inited = 0;
snd.audio_rate = 22050; snd.audio_rate = 22050;
snd.audio_format = AUDIO_S16; snd.audio_format = AUDIO_S16;
snd.audio_channels = 2; snd.audio_channels = 2;
snd.playmusic = 1; snd.playmusic = 1;
snd.playsound = 1; snd.playsound = 1;
map.bombs = GAME_SPECIAL_ITEMBOMB; map.bombs = GAME_SPECIAL_ITEMBOMB;
map.fire = GAME_SPECIAL_ITEMFIRE; map.fire = GAME_SPECIAL_ITEMFIRE;
map.shoes = GAME_SPECIAL_ITEMSHOE; map.shoes = GAME_SPECIAL_ITEMSHOE;
map.mixed = GAME_SPECIAL_ITEMMIXED; map.mixed = GAME_SPECIAL_ITEMMIXED;
map.death = GAME_SPECIAL_ITEMDEATH; map.death = GAME_SPECIAL_ITEMDEATH;
map.sp_trigger = GAME_SPECIAL_ITEMSTRIGGER; map.sp_trigger = GAME_SPECIAL_ITEMSTRIGGER;
map.sp_row = GAME_SPECIAL_ITEMSROW; map.sp_row = GAME_SPECIAL_ITEMSROW;
map.sp_push = GAME_SPECIAL_ITEMSPUSH; map.sp_push = GAME_SPECIAL_ITEMSPUSH;
d_printf ("\n\n ***** Bomberclone Version %s \n\n", VERSION);
d_printf ("\n\n ***** Bomberclone Version %s \n\n",VERSION); if (config_read ()) { /* error on reading the config file */
if (config_read()) { /* error on reading the config file */ ReadPrgArgs (argc, argv);
ReadPrgArgs (argc, argv); gfx_init ();
gfx_init (); draw_logo ();
draw_logo (); bman.playername[LEN_PLAYERNAME - 1] = 0;
bman.playername[LEN_PLAYERNAME-1] = 0; bman.playername[0] = 0;
bman.playername[0] = 0; config_menu ();
config_menu (); }
} else { else {
ReadPrgArgs (argc, argv); ReadPrgArgs (argc, argv);
gfx_init (); gfx_init ();
draw_logo (); draw_logo ();
if (bman.askplayername) if (bman.askplayername)
config_menu (); config_menu ();
} }
snd_init (); snd_init ();
gfx_blitdraw (); gfx_blitdraw ();
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
}; };
/* read the configuration file /* read the configuration file
* return -1 if something went wrong and 0 if no problem */ * return -1 if something went wrong and 0 if no problem */
int config_read () { int
config_read ()
{
FILE *config; FILE *config;
char buf[1024]; char buf[1024];
char *findit, char *findit,
@ -185,7 +187,7 @@ int config_read () {
LEN_PATHFILENAME); LEN_PATHFILENAME);
} }
value[511] = 0; value[511] = 0;
strcpy(map.map,value); strcpy (map.map, value);
} }
if (!strcmp (keyword, "firewall")) { if (!strcmp (keyword, "firewall")) {
bman.firewall = atoi (value); bman.firewall = atoi (value);
@ -241,21 +243,21 @@ int config_read () {
if (!strcmp (keyword, "gametimeout")) { if (!strcmp (keyword, "gametimeout")) {
bman.init_timeout = atoi (value); bman.init_timeout = atoi (value);
} }
if(!strcmp (keyword, "sndrate")) { if (!strcmp (keyword, "sndrate")) {
snd.audio_rate = atoi (value); snd.audio_rate = atoi (value);
} }
if (!strcmp (keyword, "sndchannels")) { if (!strcmp (keyword, "sndchannels")) {
snd.audio_channels = atoi (value); snd.audio_channels = atoi (value);
} }
if (!strcmp (keyword, "sndformat")) { if (!strcmp (keyword, "sndformat")) {
snd.audio_format = atoi (value); snd.audio_format = atoi (value);
} }
if (!strcmp (keyword, "sndplaymusic")) { if (!strcmp (keyword, "sndplaymusic")) {
snd.playmusic = atoi (value); snd.playmusic = atoi (value);
} }
if (!strcmp (keyword, "sndplaysound")) { if (!strcmp (keyword, "sndplaysound")) {
snd.playsound = atoi (value); snd.playsound = atoi (value);
} }
} }
fclose (config); fclose (config);
return 0; return 0;
@ -281,7 +283,7 @@ config_write ()
fprintf (config, "mapname=%s\n", map.map); fprintf (config, "mapname=%s\n", map.map);
fprintf (config, "firewall=%d\n", bman.firewall); fprintf (config, "firewall=%d\n", bman.firewall);
fprintf (config, "udpport=%s\n", bman.port); fprintf (config, "udpport=%s\n", bman.port);
fprintf (config, "ai_players=%d\n", bman.ai_players); fprintf (config, "ai_players=%d\n", bman.ai_players);
fprintf (config, "fieldsizex=%d\n", map.size.x); fprintf (config, "fieldsizex=%d\n", map.size.x);
fprintf (config, "fieldsizey=%d\n", map.size.y); fprintf (config, "fieldsizey=%d\n", map.size.y);
fprintf (config, "notify=%d\n", bman.notifygamemaster); fprintf (config, "notify=%d\n", bman.notifygamemaster);
@ -294,14 +296,14 @@ config_write ()
fprintf (config, "debug=%d\n", debug); fprintf (config, "debug=%d\n", debug);
fprintf (config, "askplayername=%d\n", bman.askplayername); fprintf (config, "askplayername=%d\n", bman.askplayername);
fprintf (config, "playername=%s\n", bman.playername); fprintf (config, "playername=%s\n", bman.playername);
fprintf (config, "bitsperpixel=%d\n", gfx.bpp); fprintf (config, "bitsperpixel=%d\n", gfx.bpp);
fprintf (config, "randomtileset=%d\n", map.random_tileset); fprintf (config, "randomtileset=%d\n", map.random_tileset);
fprintf (config, "mapselection=%d\n", map.map_selection); fprintf (config, "mapselection=%d\n", map.map_selection);
fprintf (config, "sndrate=%d\n", snd.audio_rate); fprintf (config, "sndrate=%d\n", snd.audio_rate);
fprintf (config, "sndchannels=%d\n", snd.audio_channels); fprintf (config, "sndchannels=%d\n", snd.audio_channels);
fprintf (config, "sndformat=%d\n", snd.audio_format); fprintf (config, "sndformat=%d\n", snd.audio_format);
fprintf (config, "sndplaymusic=%d\n", snd.playmusic); fprintf (config, "sndplaymusic=%d\n", snd.playmusic);
fprintf (config, "sndplaysound=%d\n", snd.playsound); fprintf (config, "sndplaysound=%d\n", snd.playsound);
fclose (config); fclose (config);
return 0; return 0;
} }
@ -311,68 +313,72 @@ config_write ()
void void
config_video () config_video ()
{ {
int done = 0, menuselect, x, y; int done = 0,
menuselect,
x,
y;
_charlist screenres[] = { _charlist screenres[] = {
{"640x480", NULL}, {"640x480", NULL},
{"800x600", NULL}, {"800x600", NULL},
{"1024x768", NULL}, {"1024x768", NULL},
{"1280x1024", NULL} {"1280x1024", NULL}
}; };
_charlist screenbpp[] = { _charlist screenbpp[] = {
{"16", NULL}, {"16", NULL},
{"24", NULL}, {"24", NULL},
{"32", NULL} {"32", NULL}
}; };
_charlist *selres = NULL; _charlist *selres = NULL;
_charlist *selbpp = NULL; _charlist *selbpp = NULL;
char text[100]; char text[100];
/* set all pointers in this array */ /* set all pointers in this array */
charlist_fillarraypointer (screenres, 4); charlist_fillarraypointer (screenres, 4);
charlist_fillarraypointer (screenbpp, 3); charlist_fillarraypointer (screenbpp, 3);
/* select the current settings */ /* select the current settings */
sprintf (text, "%dx%d", gfx.res.x, gfx.res.y); sprintf (text, "%dx%d", gfx.res.x, gfx.res.y);
selres = charlist_findtext (screenres, text); selres = charlist_findtext (screenres, text);
sprintf (text, "%d", gfx.bpp); sprintf (text, "%d", gfx.bpp);
selbpp = charlist_findtext (screenbpp, text); selbpp = charlist_findtext (screenbpp, text);
while (!done && bman.state != GS_quit) { while (!done && bman.state != GS_quit) {
menu_new ("Video Setup", 325, 300); menu_new ("Video Setup", 325, 300);
menu_create_label ("Resolution", 25, 70, 0); menu_create_label ("Resolution", 25, 70, 0);
menu_create_list ("res", 155, 55, 150, 70, screenres, &selres, 1); menu_create_list ("res", 155, 55, 150, 70, screenres, &selres, 1);
menu_create_label ("Colors", 65, 160, 0); menu_create_label ("Colors", 65, 160, 0);
menu_create_list ("bpp", 195, 145, 50, 55, screenbpp, &selbpp, 2); menu_create_list ("bpp", 195, 145, 50, 55, screenbpp, &selbpp, 2);
menu_create_bool ("Fullscreen", -1, 210, 150, &gfx.fullscreen, 3); menu_create_bool ("Fullscreen", -1, 210, 150, &gfx.fullscreen, 3);
menu_create_button ("OK", -1, 250, 100, 0); menu_create_button ("OK", -1, 250, 100, 0);
menuselect = menu_loop (); menuselect = menu_loop ();
menu_delete (); menu_delete ();
switch (menuselect) { switch (menuselect) {
case (0): case (0):
done = 1; done = 1;
gfx_shutdown (); gfx_shutdown ();
gfx_init (); gfx_init ();
break; break;
case (1): // new resolution case (1): // new resolution
gfx_shutdown (); gfx_shutdown ();
sscanf (selres->text, "%dx%d", &x, &y); sscanf (selres->text, "%dx%d", &x, &y);
gfx.res.x = x; gfx.res.y = y; gfx.res.x = x;
gfx_init (); gfx.res.y = y;
break; gfx_init ();
case (2): // new color depth break;
gfx_shutdown (); case (2): // new color depth
sscanf (selbpp->text, "%d", &x); gfx_shutdown ();
gfx.bpp = x; sscanf (selbpp->text, "%d", &x);
gfx_init (); gfx.bpp = x;
break; gfx_init ();
default: break;
done = 1; default:
break; done = 1;
} break;
}; }
draw_logo (); };
SDL_Flip (gfx.screen); draw_logo ();
SDL_Flip (gfx.screen);
}; };
@ -383,43 +389,43 @@ config_video ()
void void
config_menu () config_menu ()
{ {
int menuselect = 0; int menuselect = 0;
menu_new ("Configuration", 400, 300); while (menuselect != -1 && bman.state != GS_quit) {
menu_create_label ("General Option", -1, 50, 1); menu_new ("Configuration", 400, 300);
menu_create_entry ("Name", -1, 85, 200, bman.playername, LEN_PLAYERNAME, MENU_entrytext, 1); menu_create_label ("General Option", -1, 50, 1);
menu_create_button ("Video Setup", -1, 120, 200, 2); menu_create_entry ("Name", -1, 85, 200, bman.playername, LEN_PLAYERNAME, MENU_entrytext, 1);
menu_create_label ("Sound", 25 , 154, 0); menu_create_button ("Video Setup", -1, 120, 200, 2);
menu_create_bool ("ON", 100, 150, 50, &snd.playsound, 3); menu_create_label ("Sound", 25, 154, 0);
menu_create_label ("Music", 250 , 154, 0); menu_create_bool ("ON", 100, 150, 50, &snd.playsound, 3);
menu_create_bool ("ON", 325, 150, 50, &snd.playmusic, 4); menu_create_label ("Music", 250, 154, 0);
menu_create_label ("Extended Option", -1, 200, 1); menu_create_bool ("ON", 325, 150, 50, &snd.playmusic, 4);
menu_create_bool ("Debug", 25, 230, 150, &debug, 5); menu_create_label ("Extended Option", -1, 200, 1);
menu_create_bool ("Ask Playername", 250, 230, 150, &bman.askplayername, 6); menu_create_bool ("Debug", 25, 230, 150, &debug, 5);
menu_create_button ("Ok", -1, 270, 150, 0); menu_create_bool ("Ask Playername", 250, 230, 150, &bman.askplayername, 6);
while (menuselect != -1 && bman.state != GS_quit) { menu_create_button ("Ok", -1, 270, 150, 0);
if (bman.playername[0] == '\0') if (bman.playername[0] == '\0')
menu_focus_id (1); menu_focus_id (1);
else else
menu_focus_id (0); menu_focus_id (0);
menu_reload (); menu_reload ();
menuselect = menu_loop (); menuselect = menu_loop ();
switch (menuselect) { menu_delete ();
case (0): // Back to the Main Menu switch (menuselect) {
if (bman.playername[0] == '\0') case (0): // Back to the Main Menu
menuselect = 0; if (bman.playername[0] == '\0')
else menuselect = 0;
menuselect = -1; else
break; menuselect = -1;
case (2): // Screen Options break;
config_video (); case (2): // Screen Options
break; config_video ();
} break;
} }
menu_delete (); }
config_write (); config_write ();
}; };
@ -434,27 +440,27 @@ ReadPrgArgs (int argc, char **argv)
strncpy (bman.port, argv[++i], LEN_PORT); strncpy (bman.port, argv[++i], LEN_PORT);
if (!strcmp (argv[i], "-ogcport")) if (!strcmp (argv[i], "-ogcport"))
strncpy (bman.ogc_port, argv[++i], LEN_PORT); strncpy (bman.ogc_port, argv[++i], LEN_PORT);
if (!strcmp (argv[i], "-firewall")) if (!strcmp (argv[i], "-firewall"))
bman.firewall = 1; bman.firewall = 1;
if (!strcmp (argv[i], "-name")) if (!strcmp (argv[i], "-name"))
strncpy (bman.playername, argv[++i], LEN_PLAYERNAME); strncpy (bman.playername, argv[++i], LEN_PLAYERNAME);
if (!strcmp (argv[i], "-help")) { if (!strcmp (argv[i], "-help")) {
printf ("BomberClone Version " VERSION "\n"); printf ("BomberClone Version " VERSION "\n");
printf (" WebPage : http://www.bomberclone.de\n"); printf (" WebPage : http://www.bomberclone.de\n");
printf (" Bug Report to :\n"); printf (" Bug Report to :\n");
printf (" http://sourceforge.net/tracker/?group_id=79449&atid=556629\n"); printf (" http://sourceforge.net/tracker/?group_id=79449&atid=556629\n");
printf (" Other Comments: steffen@bomberclone.de\n"); printf (" Other Comments: steffen@bomberclone.de\n");
printf ("\nProgramm options:\n"); printf ("\nProgramm options:\n");
printf (" -name PLAYERNAME - set the Playername\n"); printf (" -name PLAYERNAME - set the Playername\n");
printf (" -port PORT - set the local BomberClone port (Def.: 11000)\n"); printf (" -port PORT - set the local BomberClone port (Def.: 11000)\n");
printf (" -ogcport PORT - set the local OGC Port (Def.: 11100)\n"); printf (" -ogcport PORT - set the local OGC Port (Def.: 11100)\n");
printf (" -ogc 0/1 - Enable/Disable OGC\n"); printf (" -ogc 0/1 - Enable/Disable OGC\n");
printf (" -firewall - Client is behind a firewall\n"); printf (" -firewall - Client is behind a firewall\n");
printf (" Only set this if you get some problems\n"); printf (" Only set this if you get some problems\n");
printf (" with network games.\n"); printf (" with network games.\n");
exit (0); exit (0);
} }
if (!strcmp (argv[i], "-ogc")) if (!strcmp (argv[i], "-ogc"))
bman.notifygamemaster = atoi (argv[++i]); bman.notifygamemaster = atoi (argv[++i]);
} }
}; };

Loading…
Cancel
Save