Changing on the font routines

origin
stpohle 23 years ago
parent fdef75cc02
commit d73b3af7ad

@ -113,7 +113,8 @@ module.source.files=\
mapmenu.c\ mapmenu.c\
special.c\ special.c\
sound.h\ sound.h\
sound.c sound.c\
font.h
module.pixmap.name=pixmaps module.pixmap.name=pixmaps
module.pixmap.type= module.pixmap.type=

@ -10,6 +10,7 @@ bomberclone_SOURCES = \
debug.c\ debug.c\
packets.c\ packets.c\
font.c\ font.c\
font.h\
gfx.c\ gfx.c\
player.c\ player.c\
packets.h\ packets.h\

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.36 2003/06/04 19:53:52 patty21 Exp $ */ /* $Id: bomberclone.h,v 1.37 2003/06/06 23:22:03 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -39,6 +39,8 @@
#endif #endif
#include "gfx.h" #include "gfx.h"
#include "font.h"
#include "sound.h"
#include "network.h" #include "network.h"
#include "sysfunc.h" #include "sysfunc.h"

@ -192,7 +192,7 @@ chat_loop (SDL_Event * event)
/* draw the new field */ /* draw the new field */
chat_clearscreen (chat.lineschanged); chat_clearscreen (chat.lineschanged);
p1 = p2 = 0; p1 = p2 = 0;
maxchar = (chat.window.w - 4) / (gfx.font.size.x - 4); maxchar = (chat.window.w - 4) / (font[0].size.x - 4);
if (chat.lineschanged) { if (chat.lineschanged) {
y = chat.window.y + 4; y = chat.window.y + 4;
l = chat.startline; l = chat.startline;
@ -200,12 +200,12 @@ chat_loop (SDL_Event * event)
for (p1 = 0; (p1 < maxchar && chat.lines[l][p2] != 0); p1++) for (p1 = 0; (p1 < maxchar && chat.lines[l][p2] != 0); p1++)
text[p1] = chat.lines[l][p2++]; text[p1] = chat.lines[l][p2++];
text[p1] = 0; text[p1] = 0;
draw_text (chat.window.x + 4, y, text, 1); font_draw (chat.window.x + 4, y, text, 0);
if (chat.lines[l][p2] == 0) { // the end of the line if (chat.lines[l][p2] == 0) { // the end of the line
l++; l++;
p2 = 0; p2 = 0;
} }
y = y + gfx.font.size.y; y = y + font[0].size.y;
} }
if (chat.lines[l][0] != 0) { if (chat.lines[l][0] != 0) {
chat.startline++; chat.startline++;
@ -227,7 +227,6 @@ chat_loop (SDL_Event * event)
for (p1 = 0; (p1 < maxchar && chat.input.text[p2] != 0); p1++) for (p1 = 0; (p1 < maxchar && chat.input.text[p2] != 0); p1++)
text[p1] = chat.input.text[p2++]; text[p1] = chat.input.text[p2++];
text[p1] = 0; text[p1] = 0;
draw_text (chat.window.x + 4, (chat.window.y + chat.window.h) - 4 - gfx.font.size.y, text, font_draw (chat.window.x + 4, (chat.window.y + chat.window.h) - 4 - font[0].size.y, text,0);
1);
} }
}; };

@ -1,13 +1,16 @@
/* $Id: font.c,v 1.5 2003/06/06 23:22:03 stpohle Exp $ */
// Using Fonts in SDL // Using Fonts in SDL
#include <string.h> #include <string.h>
#include <SDL.h> #include <SDL.h>
#include "bomberclone.h" #include "bomberclone.h"
#include "gfx.h"
_point font_lastsize; // so we can get the last size of the drawn font
_font font[3];
void void
draw_text (int x, int y, char *text, int white) font_draw (int x, int y, char *text, int size)
{ {
int i, int i,
c; c;
@ -15,22 +18,60 @@ draw_text (int x, int y, char *text, int white)
dest; dest;
src.y = 0; src.y = 0;
dest.w = src.w = gfx.font.size.x; dest.w = src.w = font[size].size.x;
dest.h = src.h = gfx.font.size.y; dest.h = src.h = font[size].size.y;
dest.x = x; dest.x = x;
dest.y = y; dest.y = y;
for (i = 0; text[i] != 0; i++) { for (i = 0; text[i] != 0; i++) {
c = text[i]; c = text[i];
src.x = gfx.font.size.x * (c & 15); src.x = font[size].size.x * (c & 15);
src.y = gfx.font.size.y * ((c & 240) >> 4); src.y = font[size].size.y * ((c & 240) >> 4);
if (white) SDL_BlitSurface (font[size].image, &src, gfx.screen, &dest);
SDL_BlitSurface (gfx.font.image, &src, gfx.screen, &dest); dest.x += font[size].size.x;
else
SDL_BlitSurface (gfx.font1.image, &src, gfx.screen, &dest);
dest.x += gfx.font.size.x-4;
} }
font_lastsize = font[size].size;
// gfx_AddUpdateRect (x, y, dest.x - x, dest.h); // gfx_AddUpdateRect (x, y, dest.x - x, dest.h);
}; };
void font_load () {
int i;
char filename[LEN_PATHFILENAME];
/* load the font */
for (i = 0; i < 3; i++) {
sprintf (filename, "%s/gfx/font%d.bmp", bman.datapath, i);
font[i].raw = SDL_LoadBMP (filename);
if (font[i].raw == NULL) {
printf ("Could not load font.\n");
exit (1);
}
SDL_SetColorKey (font[i].raw , SDL_SRCCOLORKEY, SDL_MapRGB (font[i].raw->format, 255, 255, 255));
font[i].image = SDL_DisplayFormat (font[i].raw);
SDL_SetColorKey (font[i].image , SDL_SRCCOLORKEY, SDL_MapRGB (font[i].image->format, 0,0,0));
font[i].size.x = font[i].raw->w / 16;
font[i].size.y = font[i].raw->h / 16;
}
};
void font_setcolor (unsigned char r, unsigned char g, unsigned char b, int size) {
SDL_FillRect (font[size].image, NULL, SDL_MapRGB (font[size].image->format, r,g,b));
SDL_BlitSurface (font[size].raw, NULL, font[size].image, NULL);
};
void font_free() {
int i;
for (i = 0; i < 3; i++) {
SDL_FreeSurface (font[i].image);
SDL_FreeSurface (font[i].raw);
font[i].image = NULL;
}
};

@ -0,0 +1,21 @@
#ifndef _FONT_H_
#define _FONT_H_
#include "basic.h"
struct __font {
SDL_Surface *image;
SDL_Surface *raw;
_point size;
} typedef _font;
extern _point font_lastsize;
extern _font font[3];
extern void font_setcolor (unsigned char r, unsigned char g, unsigned char b, int size);
extern void font_draw (int x, int y, char *text, int size);
extern void font_load ();
extern void font_free ();
#endif

@ -52,19 +52,22 @@ game_draw_info ()
sprintf (scrtext, "%10s:%2d", bman.players[i].name, bman.players[i].points); sprintf (scrtext, "%10s:%2d", bman.players[i].name, bman.players[i].points);
if (!PS_IS_alife(bman.players[i].state)) { // Player is dead if (!PS_IS_alife(bman.players[i].state)) { // Player is dead
draw_text (x, j, scrtext, 0);
if ((bman.players[i].state & PSF_used) != PSF_used) if ((bman.players[i].state & PSF_used) != PSF_used)
draw_text (x, j, "-------------", 1); font_setcolor (128,128,128,0);
else
font_setcolor (0,0,128,0);
} }
else { // players is alife else { // players is alife
draw_text (x, j, scrtext, 1); font_setcolor (128,128,255, 0);
bman.players_nr++; bman.players_nr++;
} }
font_draw (x, j, scrtext, 0);
x = x + 170; x = x + 170;
if (x >= gfx.res.x - (120 + 170)) { if (x >= gfx.res.x - (120 + 170)) {
x = 0; x = 0;
j = j + 14; j = j + font[0].size.x;
} }
} }
} }
@ -74,25 +77,26 @@ game_draw_info ()
if (PS_IS_alife (bman.players[i].state)) if (PS_IS_alife (bman.players[i].state))
bman.players_nr++; bman.players_nr++;
font_setcolor (255,255,255, 0);
x = gfx.res.x - 120; x = gfx.res.x - 120;
sprintf (text, "Bombs: %2d", bman.players[bman.p_nr].bombs_n); sprintf (text, "Bombs: %2d", bman.players[bman.p_nr].bombs_n);
draw_text (x, 0, text, 1); font_draw (x, 0, text, 0);
sprintf (text, "Range: %2d", bman.players[bman.p_nr].range); sprintf (text, "Range: %2d", bman.players[bman.p_nr].range);
draw_text (x, 16, text, 1); font_draw (x, 16, text, 0);
sprintf (text, "SP: %d/%d/%d Speed: %2d", bman.players[bman.p_nr].special.type, sprintf (text, "SP: %d/%d/%d Speed: %2d", bman.players[bman.p_nr].special.type,
bman.players[bman.p_nr].special.numuse, bman.players[bman.p_nr].special.numuse,
bman.players[bman.p_nr].special.to/TIME_FACTOR, bman.players[bman.p_nr].special.to/TIME_FACTOR,
bman.players[bman.p_nr].speed); bman.players[bman.p_nr].speed);
draw_text (x - 140, 32, text, 1); font_draw (x - 140, 32, text, 0);
if (bman.state == GS_ready && GT_MP_PTPM) if (bman.state == GS_ready && GT_MP_PTPM)
draw_text (100, 32, "Press F4 to start the game", 1); font_draw (100, 32, "Press F4 to start the game", 0);
else if (bman.state == GS_ready) else if (bman.state == GS_ready)
draw_text (100, 32, "Waiting for the Server to Start", 1); font_draw (100, 32, "Waiting for the Server to Start", 0);
} }
if (debug) { /* do some debug informations on the screen */ if (debug) { /* do some debug informations on the screen */
redraw_logo (0, gfx.res.y - gfx.font.size.y, gfx.res.x, gfx.res.y); redraw_logo (0, gfx.res.y - font[0].size.y, gfx.res.x, gfx.res.y);
for (x = 0; x < bman.fieldsize.x; x++) for (x = 0; x < bman.fieldsize.x; x++)
draw_stone (x, bman.fieldsize.y - 1); draw_stone (x, bman.fieldsize.y - 1);
if (GT_MP_PTP) { if (GT_MP_PTP) {
@ -101,12 +105,12 @@ game_draw_info ()
sprintf (text, "%s%3d ", text, bman.players[i].net.pkgopt.send_set); sprintf (text, "%s%3d ", text, bman.players[i].net.pkgopt.send_set);
text[strlen (text) + 1] = 0; text[strlen (text) + 1] = 0;
text[strlen (text)] = ']'; text[strlen (text)] = ']';
draw_text (0, gfx.res.y - (gfx.font.size.y << 1), text, 1); font_draw (0, gfx.res.y - (font[0].size.y << 1), text, 0);
} }
sprintf (text, "TILESET: %s Tframe: %d Tloop: %d", gfx.tileset, timediff, timediff1); sprintf (text, "TILESET: %s Tframe: %d Tloop: %d", gfx.tileset, timediff, timediff1);
sprintf (text, "%s GFX_RECTS:%d", text, UpdateRects_nr); sprintf (text, "%s GFX_RECTS:%d", text, UpdateRects_nr);
draw_text (0, gfx.res.y - gfx.font.size.y, text, 1); font_draw (0, gfx.res.y - font[0].size.y, text, 0);
gfx_AddUpdateRect (0, gfx.res.y - (gfx.font.size.y << 1), gfx.res.x, gfx.font.size.y << 1); gfx_AddUpdateRect (0, gfx.res.y - (font[0].size.y << 1), gfx.res.x, font[0].size.y << 1);
} }

@ -1,9 +1,8 @@
/* $Id: gfx.c,v 1.19 2003/06/06 23:22:03 stpohle Exp $ */
/* gfx.c */ /* gfx.c */
#include <SDL.h> #include <SDL.h>
#include "bomberclone.h" #include "bomberclone.h"
#include "gfx.h"
#include "sound.h"
int UpdateRects_nr = 0; int UpdateRects_nr = 0;
SDL_Rect UpdateRects[MAX_UPDATERECTS]; SDL_Rect UpdateRects[MAX_UPDATERECTS];
@ -537,50 +536,26 @@ gfx_loaddata ()
SDL_Surface *tmpimage, SDL_Surface *tmpimage,
*tmpimage1; *tmpimage1;
/* load the font */ /* load the logo */
sprintf (filename, "%s/gfx/font.bmp", bman.datapath); sprintf (filename, "%s/gfx/logo.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (filename); tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
sprintf (bman.datapath, "data"); sprintf (bman.datapath, "data");
sprintf (filename, "%s/gfx/font.bmp", bman.datapath); sprintf (filename, "%s/gfx/logo.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (filename); tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
exit (1); exit (1);
} }
} }
SDL_SetColorKey (tmpimage, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage->format, 0, 0, 0));
gfx.font.image = SDL_DisplayFormat (tmpimage);
gfx.font.size.x = 16;
gfx.font.size.y = 16;
SDL_FreeSurface (tmpimage);
/* load the font */
sprintf (filename, "%s/gfx/font1.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ());
exit (1);
}
SDL_SetColorKey (tmpimage, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage->format, 0, 0, 0));
gfx.font1.image = SDL_DisplayFormat (tmpimage);
gfx.font1.size.x = 16;
gfx.font1.size.y = 16;
SDL_FreeSurface (tmpimage);
/* load the logo */
sprintf (filename, "%s/gfx/logo.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ());
exit (1);
}
tmpimage1 = scale_image (tmpimage, gfx.res.x, gfx.res.y); tmpimage1 = scale_image (tmpimage, gfx.res.x, gfx.res.y);
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, 255, 255, 0)); SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, 255, 255, 0));
gfx.logo = SDL_DisplayFormat (tmpimage1); gfx.logo = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);
font_load ();
/* load the menuselector */ /* load the menuselector */
sprintf (filename, "%s/gfx/menuselect.bmp", bman.datapath); sprintf (filename, "%s/gfx/menuselect.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (filename); tmpimage = SDL_LoadBMP (filename);
@ -589,7 +564,7 @@ gfx_loaddata ()
exit (1); exit (1);
} }
gfx.menuselect.frames = tmpimage->h / GFX_IMGSIZE; gfx.menuselect.frames = tmpimage->h / GFX_IMGSIZE;
tmpimage1 = scale_image (tmpimage, gfx.font.size.x, gfx.menuselect.frames * gfx.font.size.y); tmpimage1 = scale_image (tmpimage, font[0].size.x, gfx.menuselect.frames * font[0].size.y);
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
gfx.menuselect.image = SDL_DisplayFormat (tmpimage1); gfx.menuselect.image = SDL_DisplayFormat (tmpimage1);
@ -606,14 +581,14 @@ gfx_shutdown ()
SDL_FreeSurface (gfx.field[i].image); SDL_FreeSurface (gfx.field[i].image);
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
SDL_FreeSurface (gfx.players[i].ani.image); SDL_FreeSurface (gfx.players[i].ani.image);
SDL_FreeSurface (gfx.font.image);
SDL_FreeSurface (gfx.font1.image);
SDL_FreeSurface (gfx.logo); SDL_FreeSurface (gfx.logo);
SDL_FreeSurface (gfx.bomb.image); SDL_FreeSurface (gfx.bomb.image);
SDL_FreeSurface (gfx.fire.image); SDL_FreeSurface (gfx.fire.image);
SDL_FreeSurface (gfx.menuselect.image); SDL_FreeSurface (gfx.menuselect.image);
gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_FreeSurface (gfx.screen); SDL_FreeSurface (gfx.screen);
font_free();
}; };

@ -1,3 +1,4 @@
/* $Id: gfx.h,v 1.10 2003/06/06 23:22:03 stpohle Exp $ */
#ifndef _GFX_H_ #ifndef _GFX_H_
#define _GFX_H_ #define _GFX_H_
@ -23,12 +24,6 @@ struct __gfxplayer {
} typedef _gfxplayer; } typedef _gfxplayer;
struct __gfxfont {
SDL_Surface *image;
_point size;
} typedef _gfxfont;
struct __gfx { struct __gfx {
SDL_Surface *screen; SDL_Surface *screen;
_point res; // resolution _point res; // resolution
@ -39,9 +34,6 @@ struct __gfx {
_point offset; // where the game field starts _point offset; // where the game field starts
_gfxfont font;
_gfxfont font1;
_gfxplayer players[MAX_PLAYERS]; _gfxplayer players[MAX_PLAYERS];
short int postab[256]; // table of points where we need to go to. short int postab[256]; // table of points where we need to go to.
@ -90,8 +82,5 @@ extern void gfx_free_tileset ();
extern SDL_Surface *makegray_image (SDL_Surface *org); extern SDL_Surface *makegray_image (SDL_Surface *org);
extern SDL_Surface *gfx_copyscreen (SDL_Rect *wnd); extern SDL_Surface *gfx_copyscreen (SDL_Rect *wnd);
// declared functions in font.c
extern void draw_text (int x, int y, char *text, int white);
#endif #endif

@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.23 2003/05/11 00:13:21 stpohle Exp $ */ /* $Id: menu.c,v 1.24 2003/06/06 23:22:03 stpohle Exp $ */
/* menu's for the game */ /* menu's for the game */
#include <SDL.h> #include <SDL.h>
@ -46,6 +46,7 @@ draw_menubox (int x, int y)
redraw_logo_shaded (x1 + 2, y1 + 2, x - 2, y - 2, MENU_BG_SHADE_DARK); redraw_logo_shaded (x1 + 2, y1 + 2, x - 2, y - 2, MENU_BG_SHADE_DARK);
} }
void void
draw_menu (char *text, _menu menu[], int *x, int *y) draw_menu (char *text, _menu menu[], int *x, int *y)
{ {
@ -62,20 +63,21 @@ draw_menu (char *text, _menu menu[], int *x, int *y)
maxlen = strlen (menu[last].text); maxlen = strlen (menu[last].text);
if (strlen (text) > maxlen) if (strlen (text) > maxlen)
maxlen = strlen (text); maxlen = strlen (text);
*x = x1 = gfx.res.x / 2 - ((gfx.font.size.x + (maxlen * (gfx.font.size.x - 2))) / 2); *x = x1 = gfx.res.x / 2 - ((font[0].size.x + (maxlen * (font[0].size.x - 2))) / 2);
y1 = gfx.res.y / 2 - ((last + 2) * gfx.font.size.y / 2); y1 = gfx.res.y / 2 - ((last + 2) * font[0].size.y / 2);
x1 = x1 + gfx.font.size.x; x1 = x1 + font[0].size.x;
draw_menubox (maxlen * gfx.font.size.x, (last + 3) * gfx.font.size.y); draw_menubox (maxlen * font[0].size.x, (last + 3) * font[0].size.y);
draw_text (x1, y1, text, 1); font_setcolor (128,128,0, 2);
font_draw (x1, y1, text, 2);
*y = y1 = y1 + (gfx.font.size.y * 2); *y = y1 = y1 + (font[0].size.y * 2);
for (i = 0; i < last; i++) { for (i = 0; i < last; i++) {
draw_text (x1, y1, menu[i].text, 1); font_draw (x1, y1, menu[i].text, 0);
y1 = y1 + gfx.font.size.y; y1 = y1 + font[0].size.y;
} }
sprintf (vers, "v%s", VERSION); sprintf (vers, "v%s", VERSION);
draw_text (gfx.res.x - gfx.font.size.x * strlen (vers), gfx.res.y - gfx.font.size.y, vers, 1); font_draw (gfx.res.x - font[1].size.x * strlen (vers), gfx.res.y - font[1].size.y, vers, 1);
}; };
@ -87,16 +89,16 @@ draw_select (int select, _menu menu[], int x, int y)
int last; int last;
for (last = 0; menu[last].index != -1; last++) for (last = 0; menu[last].index != -1; last++)
redraw_logo_shaded (x, y + last * gfx.font.size.y, gfx.menuselect.image->w, redraw_logo_shaded (x, y + last * font[0].size.y, gfx.menuselect.image->w,
gfx.menuselect.image->h, MENU_BG_SHADE_DARK); gfx.menuselect.image->h, MENU_BG_SHADE_DARK);
dest.x = x; dest.x = x;
dest.y = y + select * gfx.font.size.y; dest.y = y + select * font[0].size.y;
src.x = 0; src.x = 0;
src.y = 0; src.y = 0;
src.w = gfx.font.size.x; src.w = font[0].size.x;
src.h = gfx.font.size.y; src.h = font[0].size.y;
SDL_BlitSurface (gfx.menuselect.image, &src, gfx.screen, &dest); SDL_BlitSurface (gfx.menuselect.image, &src, gfx.screen, &dest);
}; };
@ -226,24 +228,24 @@ menu_get_text (char *title, char *text, int len)
len_ = strlen (title); len_ = strlen (title);
} }
draw_logo (); draw_logo ();
y = (gfx.res.y - 2 * gfx.font.size.y) / 2; y = (gfx.res.y - 2 * font[0].size.y) / 2;
x = (gfx.res.x - (gfx.font.size.x - 4) * len_) / 2; x = (gfx.res.x - (font[0].size.x - 4) * len_) / 2;
draw_menubox ((gfx.font.size.x - 1) * len_, 4 * gfx.font.size.y); draw_menubox ((font[0].size.x - 1) * len_, 4 * font[0].size.y);
draw_text (x, y, title, 1); font_draw (x, y, title, 1);
y = y + gfx.font.size.y; y = y + font[0].size.y;
x = (gfx.res.x - (gfx.font.size.x - 4) * len) / 2; x = (gfx.res.x - (font[0].size.x - 4) * len) / 2;
if ((len - 1) * (gfx.font.size.x - 4) > gfx.res.x) if ((len - 1) * (font[0].size.x - 4) > gfx.res.x)
len_ = 40; len_ = 40;
else else
len_ = len; len_ = len;
while (!done || keypressed == 1) { while (!done || keypressed == 1) {
redraw_logo_shaded (x, y, (gfx.font.size.x - 4) * len_, gfx.font.size.y, redraw_logo_shaded (x, y, (font[0].size.x - 4) * len_, font[0].size.y,
MENU_BG_SHADE_DARK); MENU_BG_SHADE_DARK);
draw_text (x, y, t, 1); font_draw (x, y, t, 1);
draw_text (x + (gfx.font.size.x - 4) * curpos, y, "_", 1); font_draw (x + (font[0].size.x - 4) * curpos, y, "_", 1);
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
/* do the network loop if we have to */ /* do the network loop if we have to */
@ -325,10 +327,10 @@ menu_displaytext (char *title, char *text, Uint8 r, Uint8 g, Uint8 b)
len = strlen (text); len = strlen (text);
y = (gfx.res.y - 2 * gfx.block.y) / 2; y = (gfx.res.y - 2 * gfx.block.y) / 2;
x = (gfx.res.x - (gfx.font.size.x - 4) * len) / 2; x = (gfx.res.x - (font[0].size.x - 4) * len) / 2;
y1 = gfx.font.size.y * 3; y1 = font[0].size.y * 3;
x1 = ((gfx.font.size.x - 4) * len); x1 = ((font[0].size.x - 4) * len);
dest.x = x; dest.x = x;
dest.y = y - 4; dest.y = y - 4;
@ -337,8 +339,8 @@ menu_displaytext (char *title, char *text, Uint8 r, Uint8 g, Uint8 b)
SDL_FillRect (gfx.screen, &dest, SDL_MapRGB (gfx.screen->format, r, g, b)); SDL_FillRect (gfx.screen, &dest, SDL_MapRGB (gfx.screen->format, r, g, b));
y = (gfx.res.y - 2 * gfx.block.y) / 2; y = (gfx.res.y - 2 * gfx.block.y) / 2;
draw_text ((gfx.res.x - (gfx.font.size.x - 4) * strlen (title)) / 2, y, title, 1); font_draw ((gfx.res.x - (font[1].size.x - 4) * strlen (title)) / 2, y, title, 1);
draw_text ((gfx.res.x - (gfx.font.size.x - 4) * strlen (text)) / 2, y + gfx.font.size.y, text, font_draw ((gfx.res.x - (font[0].size.x - 4) * strlen (text)) / 2, y + font[0].size.y, text,
0); 0);
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
@ -442,21 +444,21 @@ menu_dir_draw (char *title, _direntry * dirstart, int start, int selected)
if (maxlen < strlen (title)) if (maxlen < strlen (title))
maxlen = strlen (title); maxlen = strlen (title);
if (maxlen * gfx.font.size.x > gfx.res.x - 32) if (maxlen * font[0].size.x > gfx.res.x - 32)
maxlen = (gfx.res.x - 40) / gfx.font.size.x; maxlen = (gfx.res.x - 40) / font[0].size.x;
wnd.h = DIRSCRMAX * gfx.font.size.y * 2; wnd.h = DIRSCRMAX * font[0].size.y * 2;
wnd.w = maxlen * gfx.font.size.x; wnd.w = maxlen * font[0].size.x;
wnd.x = (gfx.res.x - wnd.w) / 2; wnd.x = (gfx.res.x - wnd.w) / 2;
wnd.y = (gfx.res.y - wnd.h) / 2; wnd.y = (gfx.res.y - wnd.h) / 2;
draw_menubox (wnd.w, wnd.h); draw_menubox (wnd.w, wnd.h);
draw_text ((gfx.res.x - (gfx.font.size.x / 1.17) * strlen (title)) / 2, wnd.y + 4, title, 1); font_draw ((gfx.res.x - (font[0].size.x / 1.17) * strlen (title)) / 2, wnd.y + 4, title, 1);
for (de = dirstart, pos = 0; de != NULL && pos < start + DIRSCRMAX - 1; de = de->next, pos++) { for (de = dirstart, pos = 0; de != NULL && pos < start + DIRSCRMAX - 1; de = de->next, pos++) {
if (pos >= start && pos < (start + DIRSCRMAX - 1)) if (pos >= start && pos < (start + DIRSCRMAX - 1))
draw_text (wnd.x + gfx.menuselect.image->w + 2, font_draw (wnd.x + gfx.menuselect.image->w + 2,
8 + wnd.y + (1 + pos - start) * gfx.font.size.y * 2, de->name, 8 + wnd.y + (1 + pos - start) * font[0].size.y * 2, de->name,
(pos == selected)); (pos == selected));
} }

@ -83,7 +83,7 @@ mw_draw_status ()
x = (gfx.res.x - px * 320) / 2; x = (gfx.res.x - px * 320) / 2;
for (pnr = 0; pnr < px; pnr++) for (pnr = 0; pnr < px; pnr++)
draw_text (pnr * 320 + x, 24, " Wins Points", 1); font_draw (pnr * 320 + x, 24, " Wins Points", 1);
/* 2. the names with points */ /* 2. the names with points */
for (x1 = pnr = 0, y = 48; pnr < MAX_PLAYERS; pnr++) { for (x1 = pnr = 0, y = 48; pnr < MAX_PLAYERS; pnr++) {
@ -105,9 +105,9 @@ mw_draw_status ()
if (PS_IS_used (bman.players[pnr].state)) { if (PS_IS_used (bman.players[pnr].state)) {
if (bman.lastwinner == pnr) if (bman.lastwinner == pnr)
draw_text (x + x1 * 320, y, text, 1); font_draw (x + x1 * 320, y, text, 0);
else else
draw_text (x + x1 * 320, y, text, 0); font_draw (x + x1 * 320, y, text, 0);
} }
x1++; x1++;
if (x1 >= px) { if (x1 >= px) {

@ -1,13 +1,13 @@
/* $Id: network.c,v 1.29 2003/06/02 19:25:45 stpohle Exp $ */ /* $Id: network.c,v 1.30 2003/06/06 23:22:03 stpohle Exp $ */
/* /*
network routines. network routines.
*/ */
#include "bomberclone.h" #include "bomberclone.h"
#include "network.h" #include "network.h"
#include "gamesrv.h" #include "chat.h"
#include "packets.h" #include "packets.h"
#include "gfx.h" #include "gamesrv.h"
int int
network_server_port (char *server, char *host, int hostlen, char *port, int portlen) network_server_port (char *server, char *host, int hostlen, char *port, int portlen)
@ -337,7 +337,7 @@ draw_netupdatestate ()
sprintf (text, "%s - State : READY", bman.players[i].name); sprintf (text, "%s - State : READY", bman.players[i].name);
else else
sprintf (text, "%s - State : DOWNLOAD", bman.players[i].name); sprintf (text, "%s - State : DOWNLOAD", bman.players[i].name);
draw_text (70, y, text, 1); font_draw (70, y, text, 1);
text[0] = 0; text[0] = 0;
if (bman.players[i].net.net_istep == 2) if (bman.players[i].net.net_istep == 2)
@ -348,7 +348,7 @@ draw_netupdatestate ()
sprintf (text, "Getting Player Data %d of %d.", bman.players[i].net.net_status, sprintf (text, "Getting Player Data %d of %d.", bman.players[i].net.net_status,
MAX_PLAYERS); MAX_PLAYERS);
draw_text (70, y + 16, text, 1); font_draw (70, y + 32, text, 1);
} }
return; return;
} }
@ -407,9 +407,9 @@ net_new_gamedata ()
draw_logo (); draw_logo ();
if (GT_MP_PTPM) if (GT_MP_PTPM)
draw_text (100, 0, "Waiting for the Clients", 1); font_draw (100, 0, "Waiting for the Clients", 1);
else else
draw_text (100, 0, "Downloading Data", 1); font_draw (100, 0, "Downloading Data", 1);
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);

Loading…
Cancel
Save