New Multiwait-Menu, team-mode not working yet

origin
patty21 21 years ago
parent 81bdc09dfb
commit 1dba997dbe

@ -1,4 +1,4 @@
/* $Id: multiwait.c,v 1.47 2004/09/25 11:48:36 patty21 Exp $
/* $Id: multiwait.c,v 1.48 2004/09/26 20:34:57 patty21 Exp $
multiwait.c - this manages only the network screen where
everyone have to select it's players and where even the basic chat is inside
*/
@ -21,8 +21,8 @@ static int mw_num_players_y; // number of players in the y
static int mw_num_players;
_point mw_pos[MAX_PLAYERS];
#define MW_PLAYERSCR_X 250
#define MW_PLAYERSCR_Y 64
#define MW_PLAYERSCR_X 310
#define MW_PLAYERSCR_Y 50
#define MW_TITLE_Y 50
/* Calcs the position of all items on the screen */
@ -35,7 +35,7 @@ int mw_calc_screen() {
if (PS_IS_used (players[i].state)) plnum++;
}
if (plnum!=mw_num_players) {
if (plnum!=mw_num_players || bman.updatestatusbar) {
mw_num_players=plnum;
if (bman.gametype==GT_team) {
mw_num_players_x=2;
@ -46,24 +46,25 @@ int mw_calc_screen() {
{
if (mw_num_players*2>MAX_PLAYERS) {
mw_num_players_x=2;
mw_num_players_y=floorf(mw_num_players/2)+mw_num_players%2;
}
else
{
mw_num_players_x=1;
mw_num_players_y=mw_num_players;
}
mw_num_players_y=ceil(mw_num_players/mw_num_players_x);
for(i=0;i<mw_num_players;i++) {
mw_pos[i].x=gfx.res.x/2/mw_num_players_x+(i%mw_num_players_x)*gfx.res.x/4-MW_PLAYERSCR_X/2;
mw_pos[i].x=gfx.res.x/2/mw_num_players_x+(i%mw_num_players_x)*gfx.res.x/2-MW_PLAYERSCR_X/2;
mw_pos[i].y=floorf(i/mw_num_players_x)*MW_PLAYERSCR_Y;
d_printf("mw_Position: x=%d, y=%d\n ",mw_pos[i].x,mw_pos[i].y);
}
cy=(mw_num_players_y+1)*MW_PLAYERSCR_Y;
cy=(mw_num_players_y)*MW_PLAYERSCR_Y+15;
}
draw_logo ();
d_printf ("mw_num_players_x : %d, mw_num_players_y : %d mw_players:%d\n", mw_num_players_x, mw_num_players_y,mw_num_players);
draw_logo ();
chat_show (8, cy, gfx.res.x - 16, gfx.res.y - (8 + cy));
chat.active = 1;
bman.updatestatusbar=0;
return 1;
}
return 0;
@ -122,12 +123,13 @@ void mw_check_players () {
/*
* draw only the given player
*/
void mw_draw_player (_player *player, int pos) {
void mw_draw_player (int p_nr, int pos) {
_player *player;
_point p;
char text[255];
SDL_Rect src;
SDL_Rect dest;
player=&players[p_nr];
p.x = mw_pos[pos].x;
p.y = mw_pos[pos].y;
@ -135,24 +137,43 @@ void mw_draw_player (_player *player, int pos) {
/*
* player is used
*/
if (player->gfx_nr >= 0 && player->gfx_nr < MAX_PLAYERS) {
if (player->gfx_nr >= 0 && player->gfx_nr < gfx.player_gfx_count) {
/* player is used and selected a gfx */
dest.x = p.x;
dest.y = p.y + (MW_PLAYERSCR_Y - GFX_IMGSIZE) / 2;
src.w = dest.w = gfx.players[player->gfx_nr].menu_image->w;
src.h = dest.h = gfx.players[player->gfx_nr].menu_image->h;
src.x = 0;
src.y = 0;
if (p_nr==bman.p_nr) {
/* player 1 */
dest.y = p.y;
src.w = dest.w = gfx.players[player->gfx_nr].menu_image->w;
src.h = dest.h = gfx.players[player->gfx_nr].menu_image->h;
gfx_blit (gfx.players[player->gfx_nr].menu_image, &src, gfx.screen, &dest, 10001);
} else if (p_nr==bman.p2_nr) {
/* player 2 */
dest.x=p.x+MW_PLAYERSCR_X-64;
dest.y = p.y;
src.w = dest.w = gfx.players[player->gfx_nr].menu_image->w;
src.h = dest.h = gfx.players[player->gfx_nr].menu_image->h;
gfx_blit (gfx.players[player->gfx_nr].menu_image, &src, gfx.screen, &dest, 10001);
} else {
/* net-player */
dest.x=p.x+35;
dest.y = p.y + 15;
src.w = dest.w = gfx.players[player->gfx_nr].small_image->w;
src.h = dest.h = gfx.players[player->gfx_nr].small_image->h;
gfx_blit (gfx.players[player->gfx_nr].small_image, &src, gfx.screen, &dest, 10001);
}
}
font_gfxdraw (p.x + GFX_IMGSIZE, p.y, player->name, 2, COLOR_yellow, 10002);
font_gfxdraw (p.x + GFX_IMGSIZE, p.y, player->name, 1, COLOR_yellow, 10002);
sprintf (text,"Victorys:%2d(%d)", player->wins, player->points);
font_gfxdraw (p.x + GFX_IMGSIZE, p.y + font[2].size.y - 4, text, 0, COLOR_white, 10002);
if (debug && PS_IS_used (player->state)) {
sprintf (text, "%s:%s [%d]", player->net.addr.host, player->net.addr.port, player->state);
if (player->net.flags & NETF_firewall)
sprintf (text,"%s Firewall", text);
sprintf (text,"%s FW", text);
font_gfxdraw (p.x + GFX_IMGSIZE, p.y + font[0].size.y + font[2].size.y - 4, text, 0, COLOR_white, 10002);
}
}
@ -188,18 +209,20 @@ void mw_clear_playerscreen () {
void mw_draw_all_player () {
int i,j,h;
int n[MAX_PLAYERS];
mw_clear_playerscreen ();
for(i=0;i<MAX_PLAYERS;i++) n[i]=i;
for(i=0;i<MAX_PLAYERS;i++)
for(j=i;j<MAX_PLAYERS;j++)
if (players[i].wins>players[j].wins) {
h=n[i];n[i]=n[j];n[j]=h;
}
for(i=0;i<MAX_PLAYERS;i++)
for(j=i;j<MAX_PLAYERS;j++)
if (players[i].wins>players[j].wins) {
h=n[i];n[i]=n[j];n[j]=h;
}
j=0;
for (i = 0; i < MAX_PLAYERS; i++) { /* we do not sort the players */
if (PS_IS_used (players[i].state)) {
mw_draw_player (&players[i], n[i]);
if (PS_IS_used (players[n[i]].state)) {
mw_draw_player (n[i], j);
j++;
}
}
gfx_blitdraw();
};

Loading…
Cancel
Save