|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: playermenu.c,v 1.2 2004/05/20 16:55:30 stpohle Exp $
|
|
|
|
/* $Id: playermenu.c,v 1.3 2004/09/12 20:54:25 stpohle Exp $
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
@ -149,7 +149,7 @@ void playermenu () {
|
|
|
|
_menuitem *list_PlayerList;
|
|
|
|
_menuitem *list_PlayerList;
|
|
|
|
_charlist playerlist[MAX_PLAYERS + 1];
|
|
|
|
_charlist playerlist[MAX_PLAYERS + 1];
|
|
|
|
_charlist *playerlist_sel = &playerlist[0];
|
|
|
|
_charlist *playerlist_sel = &playerlist[0];
|
|
|
|
int i, menuselect = 0, done = 0, eventstate, pl_nr;
|
|
|
|
int i, done = 0, eventstate, pl_nr;
|
|
|
|
SDL_Event event;
|
|
|
|
SDL_Event event;
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
@ -200,6 +200,7 @@ void playermenu () {
|
|
|
|
if (bman.sock != -1)
|
|
|
|
if (bman.sock != -1)
|
|
|
|
network_loop ();
|
|
|
|
network_loop ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menu_draw (menu);
|
|
|
|
done = menu_event_loop (menu, &event, eventstate);
|
|
|
|
done = menu_event_loop (menu, &event, eventstate);
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* check if one of the buttons was pressed
|
|
|
|
* check if one of the buttons was pressed
|
|
|
@ -241,7 +242,7 @@ void playermenu () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
s_calctimesync ();
|
|
|
|
s_calctimesync ();
|
|
|
|
} while ((done == 0 || menu->focus->id != 1) && done != -1 && menuselect != -1 && menuselect != 1);
|
|
|
|
} while ((done == 0 || menu->focus->id != 1) && done != -1);
|
|
|
|
|
|
|
|
|
|
|
|
if (menu->focus->id == 1 && done == 1) {
|
|
|
|
if (menu->focus->id == 1 && done == 1) {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -258,7 +259,7 @@ void playermenu () {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* draw a small menu where the player has to select his gfx
|
|
|
|
* draw a small menu where the player has to select his gfx
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void playermenu_selgfx (int pl_nr) {
|
|
|
|
int playermenu_selgfx (int pl_nr) {
|
|
|
|
_menu *menu;
|
|
|
|
_menu *menu;
|
|
|
|
int selgfx, eventstate;
|
|
|
|
int selgfx, eventstate;
|
|
|
|
SDL_Event event;
|
|
|
|
SDL_Event event;
|
|
|
@ -266,7 +267,7 @@ void playermenu_selgfx (int pl_nr) {
|
|
|
|
int done = 0;
|
|
|
|
int done = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (pl_nr < 0 || pl_nr >= MAX_PLAYERS)
|
|
|
|
if (pl_nr < 0 || pl_nr >= MAX_PLAYERS)
|
|
|
|
return;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
selgfx = players[pl_nr].gfx_nr;
|
|
|
|
selgfx = players[pl_nr].gfx_nr;
|
|
|
|
if (selgfx < 0)
|
|
|
|
if (selgfx < 0)
|
|
|
@ -298,7 +299,7 @@ void playermenu_selgfx (int pl_nr) {
|
|
|
|
bman.state = GS_quit;
|
|
|
|
bman.state = GS_quit;
|
|
|
|
done = 1;
|
|
|
|
done = 1;
|
|
|
|
menu_delete (menu);
|
|
|
|
menu_delete (menu);
|
|
|
|
return;
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case (SDL_KEYDOWN):
|
|
|
|
case (SDL_KEYDOWN):
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -332,7 +333,7 @@ void playermenu_selgfx (int pl_nr) {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
else if (event.key.keysym.sym == SDLK_ESCAPE) {
|
|
|
|
else if (event.key.keysym.sym == SDLK_ESCAPE) {
|
|
|
|
selgfx = -1;
|
|
|
|
selgfx = -1;
|
|
|
|
done = 1;
|
|
|
|
done = 2;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -356,4 +357,249 @@ void playermenu_selgfx (int pl_nr) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
menu_delete (menu);
|
|
|
|
menu_delete (menu);
|
|
|
|
player_set_gfx (&players[pl_nr], selgfx);
|
|
|
|
player_set_gfx (&players[pl_nr], selgfx);
|
|
|
|
|
|
|
|
if (done == 2)
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* teammenu: Teamplay menuselection
|
|
|
|
|
|
|
|
* Show and edit all teams and the players.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct __teammenu {
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
|
|
|
_charlist names[MAX_PLAYERS];
|
|
|
|
|
|
|
|
_charlist *select;
|
|
|
|
|
|
|
|
_menuitem *item;
|
|
|
|
|
|
|
|
_menuitem *label;
|
|
|
|
|
|
|
|
} teamp, freep;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_menuitem *teamlist;
|
|
|
|
|
|
|
|
_charlist teamnames[MAX_TEAMS];
|
|
|
|
|
|
|
|
_charlist *teamsel;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void teammenu_update (_menu *menu, struct __teammenu *tm);
|
|
|
|
|
|
|
|
static int inline teammenu_get_selteam (_menu *menu, struct __teammenu *tm);
|
|
|
|
|
|
|
|
static void teammenu_set_selteam (_menu *menu, struct __teammenu *tm, int teamnr);
|
|
|
|
|
|
|
|
static void teammenu_player2team (_menu *menu, struct __teammenu *tm);
|
|
|
|
|
|
|
|
static void teammenu_team2player (_menu *menu, struct __teammenu *tm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void teammenu () {
|
|
|
|
|
|
|
|
_menu *menu;
|
|
|
|
|
|
|
|
struct __teammenu tm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int done, eventstate, menu_id = 0, last_id = 0, last_selteam = -1;
|
|
|
|
|
|
|
|
SDL_Event event;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
single_create_ai (7); // for debug only
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menu = menu_new ("Team Details", 400, 350);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menu_create_text (menu, "help1", 10, 70, (250/font[0].size.x), 5, COLOR_gray, "Move the players from one team into the other by selecting them with ENTER.");
|
|
|
|
|
|
|
|
menu_create_button (menu, "Close", -1, 325, 150, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* reset all teamlist data and create element */
|
|
|
|
|
|
|
|
tm.teamsel = NULL;
|
|
|
|
|
|
|
|
tm.teamnames[0].text[0] = 0;
|
|
|
|
|
|
|
|
tm.teamnames[0].next = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tm.teamlist = menu_create_list (menu, "Teamlist", 250, 70, 150, 80, tm.teamnames, &tm.teamsel, ++menu_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* reset all player data and create element*/
|
|
|
|
|
|
|
|
tm.teamp.names[0].text[0] = 0;
|
|
|
|
|
|
|
|
tm.teamp.names[0].next = NULL;
|
|
|
|
|
|
|
|
tm.teamp.select = &tm.teamp.names[0];;
|
|
|
|
|
|
|
|
tm.freep.names[0].text[0] = 0;
|
|
|
|
|
|
|
|
tm.freep.names[0].next = NULL;
|
|
|
|
|
|
|
|
tm.freep.select = &tm.freep.names[0];;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tm.freep.label = menu_create_label (menu, "Free Players", 40, 160, 0, COLOR_yellow);
|
|
|
|
|
|
|
|
tm.freep.item = menu_create_list (menu, "freeplayer", 30, 180, 150, 120, tm.freep.names, &tm.freep.select, ++menu_id);
|
|
|
|
|
|
|
|
tm.teamp.label = menu_create_label (menu, teams[0].name, 250, 160, 0, COLOR_yellow);
|
|
|
|
|
|
|
|
tm.teamp.item = menu_create_list (menu, "teamplayer", 240, 180, 150, 120, tm.teamp.names, &tm.teamp.select, ++menu_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* prepare everything for the menu_loop */
|
|
|
|
|
|
|
|
menu_focus_id (menu, 1);
|
|
|
|
|
|
|
|
menu->looprunning = 1;
|
|
|
|
|
|
|
|
menu_draw (menu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
teammenu_set_selteam (menu, &tm, 0);
|
|
|
|
|
|
|
|
teammenu_update (menu, &tm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* the menu loop */
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
gfx_blitdraw ();
|
|
|
|
|
|
|
|
eventstate = SDL_PollEvent (&event);
|
|
|
|
|
|
|
|
if (bman.sock != -1)
|
|
|
|
|
|
|
|
network_loop ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menu_draw (menu);
|
|
|
|
|
|
|
|
done = menu_event_loop (menu, &event, eventstate);
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* check if one of the buttons was pressed
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (last_id != menu->focus->id || last_selteam != teammenu_get_selteam(menu, &tm)) {
|
|
|
|
|
|
|
|
teammenu_update (menu, &tm);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (done == 1 && menu->focus->id == tm.freep.item->id) { // freeplayer selected
|
|
|
|
|
|
|
|
teammenu_player2team (menu, &tm);
|
|
|
|
|
|
|
|
teammenu_update (menu, &tm);
|
|
|
|
|
|
|
|
done = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (done == 1 && menu->focus->id == tm.teamp.item->id) { // teamplayer selected
|
|
|
|
|
|
|
|
teammenu_team2player (menu, &tm);
|
|
|
|
|
|
|
|
teammenu_update (menu, &tm);
|
|
|
|
|
|
|
|
done = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (done == 1 && menu->focus->id == tm.teamlist->id) {
|
|
|
|
|
|
|
|
menu_focus_id (menu, tm.freep.item->id);
|
|
|
|
|
|
|
|
teammenu_update (menu, &tm);
|
|
|
|
|
|
|
|
done = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s_calctimesync ();
|
|
|
|
|
|
|
|
last_id = menu->focus->id;
|
|
|
|
|
|
|
|
} while ((done == 0 || menu->focus->id != 0) && done != -1);
|
|
|
|
|
|
|
|
menu_delete (menu);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* add the current selected playxer to the free players
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void teammenu_team2player (_menu *menu, struct __teammenu *tm) {
|
|
|
|
|
|
|
|
int sel_team = teammenu_get_selteam (menu,tm);
|
|
|
|
|
|
|
|
int sel_teampl = tm->teamp.select - tm->teamp.names;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sel_team < 0 || sel_team >= MAX_TEAMS || sel_teampl < 0 || sel_teampl >= MAX_PLAYERS)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (teams[sel_team].players[sel_teampl] == NULL)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
teams[sel_team].players[sel_teampl]->team_nr = -1;
|
|
|
|
|
|
|
|
team_update ();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* add the current selected player to the current team
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void teammenu_player2team (_menu *menu, struct __teammenu *tm) {
|
|
|
|
|
|
|
|
int sel_player = tm->freep.select - tm->freep.names;
|
|
|
|
|
|
|
|
int sel_team = teammenu_get_selteam (menu,tm);
|
|
|
|
|
|
|
|
int pl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// d_printf ("teammenu_player2team: sel_player=%d, sel_team=%d\n", sel_player, sel_team);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sel_team < 0 || sel_team >= MAX_TEAMS || sel_player < 0 || sel_player >= MAX_PLAYERS)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* get the player */
|
|
|
|
|
|
|
|
pl = 0;
|
|
|
|
|
|
|
|
while (pl < MAX_PLAYERS && (sel_player > 0 || players[pl].team_nr != -1)) {
|
|
|
|
|
|
|
|
if (players[pl].team_nr == -1) sel_player--;
|
|
|
|
|
|
|
|
pl++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// d_printf ("teammenu_player2team: sel_player=%d, sel_team=%d, pl=\n", sel_player, sel_team, pl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pl < MAX_PLAYERS && sel_player == 0 && players[pl].team_nr == -1)
|
|
|
|
|
|
|
|
players[pl].team_nr = sel_team;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
team_update ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* update all elements on the screen
|
|
|
|
|
|
|
|
* clean the player lists for the team and free players
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void teammenu_update (_menu *menu, struct __teammenu *tm) {
|
|
|
|
|
|
|
|
int pl, cnt_team, cnt_free;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// d_printf ("teammenu_update\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* teamnames
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
tm->teamnames[0].text[0] = 0;
|
|
|
|
|
|
|
|
tm->teamnames[0].next = NULL;
|
|
|
|
|
|
|
|
for (pl = 0; pl < MAX_TEAMS; pl++) {
|
|
|
|
|
|
|
|
if (pl > 0)
|
|
|
|
|
|
|
|
tm->teamnames[pl-1].next = &tm->teamnames[pl];
|
|
|
|
|
|
|
|
tm->teamnames[pl].next = NULL;
|
|
|
|
|
|
|
|
strncpy (tm->teamnames[pl].text, teams[pl].name, LEN_CHARENTRY);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strncpy (tm->teamp.label->label, tm->teamsel->text, MENU_TITLELEN);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* playernames
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
tm->freep.names[0].next = NULL;
|
|
|
|
|
|
|
|
tm->freep.names[0].text[0] = 0;
|
|
|
|
|
|
|
|
tm->teamp.names[0].next = NULL;
|
|
|
|
|
|
|
|
tm->teamp.names[0].text[0] = 0;
|
|
|
|
|
|
|
|
for (pl = 0, cnt_team = 0, cnt_free = 0; pl < MAX_PLAYERS; pl++) {
|
|
|
|
|
|
|
|
if (PS_IS_used (players[pl].state) && (players[pl].team_nr == -1 || players[pl].team_nr == teammenu_get_selteam (menu, tm))) {
|
|
|
|
|
|
|
|
_charlist *cl;
|
|
|
|
|
|
|
|
int *cnt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* select the right list with the right counter */
|
|
|
|
|
|
|
|
if (players[pl].team_nr == -1) {
|
|
|
|
|
|
|
|
cl = tm->freep.names;
|
|
|
|
|
|
|
|
cnt = &cnt_free;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
cl = tm->teamp.names;
|
|
|
|
|
|
|
|
cnt = &cnt_team;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* set the data */
|
|
|
|
|
|
|
|
if (*cnt > 0)
|
|
|
|
|
|
|
|
cl[(*cnt)-1].next = &cl[*cnt];
|
|
|
|
|
|
|
|
strncpy (cl[*cnt].text, players[pl].name, LEN_CHARENTRY);
|
|
|
|
|
|
|
|
cl[*cnt].next = NULL;
|
|
|
|
|
|
|
|
(*cnt)++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* send update */
|
|
|
|
|
|
|
|
tm->freep.item->changed = 1;
|
|
|
|
|
|
|
|
tm->freep.label->changed = 1;
|
|
|
|
|
|
|
|
menu_draw_menuitem (tm->freep.item);
|
|
|
|
|
|
|
|
menu_draw_menuitem (tm->freep.label);
|
|
|
|
|
|
|
|
tm->teamp.item->changed = 1;
|
|
|
|
|
|
|
|
tm->teamp.label->changed = 1;
|
|
|
|
|
|
|
|
menu_draw_menuitem (tm->teamp.item);
|
|
|
|
|
|
|
|
menu_draw_menuitem (tm->teamp.label);
|
|
|
|
|
|
|
|
tm->teamlist->changed = 1;
|
|
|
|
|
|
|
|
menu_draw_menuitem (tm->teamlist);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* get the current teamnumber
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline int teammenu_get_selteam (_menu *menu, struct __teammenu *tm) {
|
|
|
|
|
|
|
|
return (tm->teamsel - tm->teamnames);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* set the current teamnumber
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void teammenu_set_selteam (_menu *menu, struct __teammenu *tm, int teamnr) {
|
|
|
|
|
|
|
|
if (teamnr < 0 ) teamnr = 0;
|
|
|
|
|
|
|
|
else if (teamnr >= MAX_TEAMS) teamnr = MAX_TEAMS-1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tm->teamsel = &tm->teamnames[teamnr];
|
|
|
|
|
|
|
|
tm->teamlist->changed = 1;
|
|
|
|
|
|
|
|
menu_draw_menuitem (tm->teamlist);
|
|
|
|
};
|
|
|
|
};
|
|
|
|