20
20
You should have received a copy of the GNU General Public License
21
21
along with this program; if not, write to the Free Software
22
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
24
***************************************************************************
30
30
#include "ePlayer.h"
33
static tOutput* PrepareTeamText(tOutput* text, eTeam* team, const ePlayerNetID* player, const char* textTemplate)
37
text->SetTemplateParameter(1 , team->Name() );
38
text->SetTemplateParameter(2 , team->NumPlayers() );
39
if (team->PlayerMayJoin(player))
40
text->SetTemplateParameter(3, "0x00ff00");
42
text->SetTemplateParameter(3, "0xff0000");
46
text->SetTemplateParameter(1 , tOutput("$team_empty") );
47
text->SetTemplateParameter(2 , 0 );
48
text->SetTemplateParameter(3 , "0x00ff00" );
50
*text << textTemplate << "0xffffff";
33
54
// sets the spectator mode of a local player
34
55
static void SetSpectator( ePlayerNetID * player, bool spectate )
53
74
class gMenuItemPlayerTeam: public uMenuItem
59
gMenuItemPlayerTeam(uMenu *M,ePlayerNetID* p, eTeam* t, bool canJoin )
79
gMenuItemPlayerTeam(uMenu *M,ePlayerNetID* p, eTeam* t)
60
80
: uMenuItem( M, tOutput("$team_menu_join_help") ),
67
86
virtual void Render(REAL x,REAL y,REAL alpha=1,bool selected=0)
69
tOutput text( "$team_menu_join", team->Name() );
70
DisplayTextSpecial( x, y, text, selected, alpha * ( canJoin_ ? 1 : ( selected ? .8 : .5 ) ) );
88
tOutput text/*( "$team_menu_join", team->Name() )*/;
89
PrepareTeamText(&text, team, player, "$team_menu_join");
90
DisplayTextSpecial( x, y, text, selected, alpha );
73
93
virtual void Enter()
76
96
player->SetTeamWish( team );
101
class gMenuItemSpacer: public uMenuItem
104
gMenuItemSpacer(uMenu *M)
105
: uMenuItem( M, tOutput() )
109
virtual void Render(REAL x,REAL y,REAL alpha=1,bool selected=0)
113
virtual bool IsSelectable()
119
class gMenuItemStatus: public uMenuItem
121
ePlayerNetID *player;
124
gMenuItemStatus(uMenu *M, ePlayerNetID *playerID, bool displayCurrentTeam)
125
: uMenuItem( M, tOutput() ), player(playerID), currentTeam(displayCurrentTeam)
129
virtual void Render(REAL x,REAL y,REAL alpha=1,bool selected=0)
133
PrepareTeamText(&text, player->CurrentTeam(), player, "$team_menu_info_current_team");
135
PrepareTeamText(&text, player->NextTeam(), player, "$team_menu_info_next_team");
136
DisplayTextSpecial( x, y, text, false, alpha );
139
virtual bool IsSelectable()
81
145
class gMenuItemNewTeam: public uMenuItem
147
ePlayerNetID* player;
85
149
gMenuItemNewTeam( uMenu *M,ePlayerNetID* p )
86
150
: uMenuItem( M, tOutput("$team_menu_create_help") ),
104
168
class gMenuItemSpectate: public uMenuItem
106
ePlayerNetID* player;
170
ePlayerNetID* player;
108
172
gMenuItemSpectate( uMenu *M,ePlayerNetID* p )
109
173
: uMenuItem( M, tOutput("$team_menu_spectate_help") ),
142
206
virtual void Enter()
147
211
title.SetTemplateParameter( 1, player->GetName() );
148
212
title << "$team_menu_player_title";
149
213
uMenu playerMenu( title );
150
tArray<uMenuItem*> items;
214
tArray<uMenuItem*> items;
216
if ( player->NextTeam()!=NULL )
218
items[0] = tNEW(gMenuItemPlayerTeam) (&playerMenu, player, NULL);
152
221
if ( !player->IsSpectating() )
154
223
items[ items.Len() ] = tNEW( gMenuItemSpectate ) ( &playerMenu, player );
157
for ( i = eTeam::teams.Len()-1; i>=0; --i )
226
// first pass add teams who probably can't be joined
227
for (i = 0; i<eTeam::teams.Len(); i++ )
159
229
eTeam *team = eTeam::teams(i);
160
if ( team != player->NextTeam() )
230
if ( team != player->NextTeam() && team->PlayerMayJoin( player ) )
162
items[ items.Len() ] = tNEW( gMenuItemPlayerTeam ) ( &playerMenu, player, team, team->PlayerMayJoin( player ) );
232
items[ items.Len() ] = tNEW( gMenuItemPlayerTeam ) ( &playerMenu, player, team );
236
// second pass add teams who probably can be joined
237
// Note: these will appear above the unjoinable ones.
238
for (i = 0; i<eTeam::teams.Len(); i++ )
240
eTeam *team = eTeam::teams(i);
241
if ( team != player->NextTeam() && team->PlayerMayJoin( player ))
242
items[ items.Len() ] = tNEW( gMenuItemPlayerTeam ) ( &playerMenu, player, team );
166
245
if ( player->IsSpectating() ||
171
250
items[ items.Len() ] = tNEW( gMenuItemNewTeam ) ( &playerMenu, player );
253
items[items.Len()] = tNEW ( gMenuItemSpacer ) ( &playerMenu );
254
items[items.Len()] = tNEW ( gMenuItemStatus ) ( &playerMenu, player, false);
255
items[items.Len()] = tNEW ( gMenuItemStatus ) ( &playerMenu, player, true);
174
257
playerMenu.Enter();