diff --git a/src/multiwait.c b/src/multiwait.c index c654e59..6f40666 100644 --- a/src/multiwait.c +++ b/src/multiwait.c @@ -1,4 +1,4 @@ -/* $Id: multiwait.c,v 1.48 2004/09/26 20:34:57 patty21 Exp $ +/* $Id: multiwait.c,v 1.49 2004/09/27 19:20:20 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 */ @@ -12,6 +12,7 @@ #include "single.h" #include "keyb.h" + extern int UpdateRects_nr; extern int blitdb_nr; @@ -19,31 +20,59 @@ static int mw_num_readyplayers; // number of players who are ready static int mw_num_players_x; // number of players in the x static int mw_num_players_y; // number of players in the y static int mw_num_players; -_point mw_pos[MAX_PLAYERS]; - +_point mw_pos[MAX_PLAYERS+1]; + + // uncomment to sort by points +// #define SORT_BY_POINTS 1 #define MW_PLAYERSCR_X 310 #define MW_PLAYERSCR_Y 50 #define MW_TITLE_Y 50 + +/* returns number of active players in a team */ +int mw_team_is_used (int t_nr) { + int i,j=0; + for(i=0;istate))) { j++;} + d_printf("Team: %s : %d players\n",teams[t_nr].name,j); + return j; +} + + + + + /* Calcs the position of all items on the screen */ int mw_calc_screen() { - int i,cy, - plnum=0; + int i,j,k=0,n=0,cy; - for (i = 0; i < MAX_PLAYERS; i++) { - if (PS_IS_used (players[i].state)) plnum++; - } - - if (plnum!=mw_num_players || bman.updatestatusbar) { - mw_num_players=plnum; + if (bman.updatestatusbar) { if (bman.gametype==GT_team) { + /* team mode */ + for(i=0;ik) k=j; + if (j>0) n++; + } mw_num_players_x=2; - mw_num_players_y=2; // needs to be fixed (calculated separately) - cy=gfx.res.y/2; + mw_num_players_y=floorf(n/2)+n%2; + mw_num_players=n; + for(i=0;iMAX_PLAYERS) { mw_num_players_x=2; mw_num_players_y=floorf(mw_num_players/2)+mw_num_players%2; @@ -76,7 +105,6 @@ int mw_calc_screen() { void mw_init () { - int i; draw_logo (); menu_displaytext ("Please Wait", "Loading GFX Data"); @@ -87,7 +115,6 @@ mw_init () gfx_blitdraw (); mw_num_players=-1; - mw_calc_screen(); }; @@ -188,21 +215,6 @@ void mw_draw_player (int p_nr, int pos) { }; - -/* - * clear the player screen - */ -void mw_clear_playerscreen () { - SDL_Rect src, dest; - - src.x = dest.x = 0; - src.y = dest.y = MW_TITLE_Y; - src.w = dest.w = gfx.res.x; - src.h = dest.h = mw_num_players_y * MW_PLAYERSCR_Y; - gfx_blit (gfx.logo, &src, gfx.screen, &dest, 1); -}; - - /* * draw all player informations */ @@ -212,11 +224,15 @@ void mw_draw_all_player () { for(i=0;iplayers[j].wins) { - h=n[i];n[i]=n[j];n[j]=h; +#ifdef SORT_BY_POINTS + if (players[i].points>players[j].points) { +#else + if (players[i].wins>players[j].wins) { +#endif + 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 */ + for (i = 0; i < MAX_PLAYERS; i++) { if (PS_IS_used (players[n[i]].state)) { mw_draw_player (n[i], j); j++; @@ -226,6 +242,109 @@ void mw_draw_all_player () { }; +/* + * draw only the given team + */ +void mw_draw_team (int t_nr, int pos) { + _player *player; + _team *team; + _point p; + int i,j=0; + char text[255]; + SDL_Rect src; + SDL_Rect dest; + team=&teams[t_nr]; + p.x = mw_pos[pos].x; + p.y = mw_pos[pos].y; + + /* Find if there is any active player in that team */ + + + if (mw_team_is_used(t_nr)>0) { + /* + * team is used + */ + font_gfxdraw (p.x + GFX_IMGSIZE, p.y, team->name, 1, COLOR_yellow, 10002); + sprintf (text,"Victorys:%2d(%d)", team->wins, team->points); + font_gfxdraw (p.x + GFX_IMGSIZE, p.y + font[2].size.y - 4, text, 0, COLOR_white, 10002); + j=1; + for(i=0;iplayers[i]!=NULL) && (PS_IS_used(team->players[i]->state))) { + player=team->players[i]; + if (player->gfx_nr >= 0 && player->gfx_nr < gfx.player_gfx_count) { + /* player is used and selected a gfx */ + dest.x = p.x; + src.x = 0; + src.y = 0; + dest.x=p.x+35+20; + dest.y = p.y + 30+j*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+20, p.y + 30+j*15, team->players[i]->name, 0, COLOR_white, 10002); + j++; + } + } + } + + else { + /* + * team is emty + */ + font_gfxdraw (p.x + GFX_IMGSIZE, p.y, "No TEAM" , 0, COLOR_gray, 10002); + } + +}; + +/* +Draw players which are not assigned to any team +*/ + +void mw_draw_unassigned_players () { + int i, + n=0; + char text[255]; + sprintf(text,"Unassigned Players: "); + for (i=0;iteams[j].points) { +#else + if (teams[i].wins>teams[j].wins) { +#endif + h=n[i];n[i]=n[j];n[j]=h; + } + j=0; + for (i = 0; i < MAX_TEAMS; i++) { + if (mw_team_is_used(n[i])) { + mw_draw_team (n[i], j); + j++; + } + } + mw_draw_unassigned_players(); + gfx_blitdraw(); +}; + + + /* * check if one key is pressed */ @@ -242,7 +361,7 @@ void mw_keys_loop () { SDL_WM_ToggleFullScreen(gfx.screen); gfx.fullscreen = !gfx.fullscreen; bman.updatestatusbar = 1; // force an update - mw_num_players=-1; + bman.updatestatusbar = 1; } if (keyb_gamekeys.state[BCK_esc] && !keyb_gamekeys.old[BCK_esc]) { @@ -255,7 +374,7 @@ void mw_keys_loop () { /* player 1 want to select a new gfx */ playermenu_selgfx (bman.p_nr); net_change_playerid (bman.p_nr, 1); - mw_num_players=-1; + bman.updatestatusbar = 1; keyb_loop (NULL); // to reload the current keys } @@ -263,21 +382,21 @@ void mw_keys_loop () { /* player 2 want to select a new gfx */ playermenu_selgfx (bman.p2_nr); net_change_playerid (bman.p2_nr, 1); - mw_num_players=-1; + bman.updatestatusbar = 1; keyb_loop (NULL); // to reload the current keys } if (keyb_gamekeys.state[BCK_mapmenu] && !keyb_gamekeys.old[BCK_mapmenu] && GT_MP_PTPM) { /* mapmenu */ mapmenu (); - mw_num_players=-1; + bman.updatestatusbar = 1; keyb_loop (NULL); // to reload the current keys } if (keyb_gamekeys.state[BCK_playermenu] && !keyb_gamekeys.old[BCK_playermenu]) { /* playermenu */ playermenu (); - mw_num_players=-1; + bman.updatestatusbar = 1; keyb_loop (NULL); // to reload the current keys } }; @@ -290,7 +409,7 @@ void wait_for_players () { mw_init (); mw_calc_screen(); - mw_draw_all_player (); + if (bman.gametype==GT_team) mw_draw_all_teams(); else mw_draw_all_player (); do { if (SDL_PollEvent (&event) != 0) @@ -309,7 +428,9 @@ void wait_for_players () { /* * the drawing stuff */ - if (mw_calc_screen()) {mw_draw_all_player ();} + if (mw_calc_screen()) { + if (bman.gametype==GT_team) mw_draw_all_teams(); else mw_draw_all_player (); + } gfx_blitdraw (); /*