~swag/armagetronad/0.2.9-sty+ct+ap-fork

« back to all changes in this revision

Viewing changes to src/tron/gTeam.cpp

  • Committer: wrtlprnft
  • Date: 2008-03-24 08:28:20 UTC
  • mfrom: (563.1.226)
  • Revision ID: wrtlprnft@users.sf.net-20080324082820-235q3jssjh059s53
Merged changes from the 0.2.8 branch.
The pighack help text got replaced by the new help menu.
To emulate the old behavior use:
REMOVE_HELP_TOPIC commands
HELP_INTRODUCTORY_BLURB <your help text>

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "ePlayer.h"
31
31
#include "eTeam.h"
32
32
 
 
33
// sets the spectator mode of a local player
 
34
static void SetSpectator( ePlayerNetID * player, bool spectate )
 
35
{
 
36
    for ( int i = MAX_PLAYERS; i>=0; --i )
 
37
    {
 
38
        if ( ePlayer::PlayerIsInGame(i))
 
39
        {
 
40
            ePlayer* localPlayer = ePlayer::PlayerConfig( i );
 
41
            ePlayerNetID* pni = localPlayer->netPlayer;
 
42
            if ( pni == player && localPlayer->spectate != spectate )
 
43
            {
 
44
                localPlayer->spectate = spectate;
 
45
                con << tOutput( spectate ? "$player_toggle_spectator_on" : "$player_toggle_spectator_off", localPlayer->name );
 
46
                ePlayerNetID::Update();
 
47
            }
 
48
        }
 
49
    }
 
50
}
 
51
 
 
52
 
33
53
class gMenuItemPlayerTeam: public uMenuItem
34
54
{
35
55
    ePlayerNetID*       player;
52
72
 
53
73
    virtual void Enter()
54
74
    {
 
75
        SetSpectator( player, false );
55
76
        player->SetTeamWish( team );
56
77
        menu->Exit();
57
78
    }
74
95
 
75
96
    virtual void Enter()
76
97
    {
 
98
        SetSpectator( player, false );
77
99
        player->CreateNewTeamWish();
78
100
        menu->Exit();
79
101
    }
80
102
};
81
103
 
 
104
class gMenuItemSpectate: public uMenuItem
 
105
{
 
106
    ePlayerNetID*       player;
 
107
public:
 
108
    gMenuItemSpectate( uMenu *M,ePlayerNetID* p )
 
109
            : uMenuItem( M, tOutput("$team_menu_spectate_help") ),
 
110
            player ( p )
 
111
    {
 
112
    }
 
113
 
 
114
    virtual void Render(REAL x,REAL y,REAL alpha=1,bool selected=0)
 
115
    {
 
116
        DisplayTextSpecial( x, y, tOutput("$team_menu_spectate"), selected, alpha );
 
117
    }
 
118
 
 
119
    virtual void Enter()
 
120
    {
 
121
        SetSpectator( player, true );
 
122
        menu->Exit();
 
123
    }
 
124
};
 
125
 
82
126
class gMenuItemPlayer: public uMenuItem
83
127
{
84
128
    ePlayerNetID* player;
105
149
        uMenu playerMenu( title );
106
150
        tArray<uMenuItem*> items;
107
151
 
108
 
        // quit from spectator mode, the player would be trown out of the team again otherwise
109
 
        for ( i = MAX_PLAYERS; i>=0; --i )
 
152
        if ( !player->IsSpectating() )
110
153
        {
111
 
            if ( ePlayer::PlayerIsInGame(i))
112
 
            {
113
 
                ePlayer* localPlayer = ePlayer::PlayerConfig( i );
114
 
                ePlayerNetID* pni = localPlayer->netPlayer;
115
 
                if ( pni == this->player && localPlayer->spectate )
116
 
                {
117
 
                    localPlayer->spectate = false;
118
 
                    con << tOutput("$player_toggle_spectator_off", localPlayer->name );
119
 
                    ePlayerNetID::Update();
120
 
                }
121
 
            }
 
154
            items[ items.Len() ] = tNEW( gMenuItemSpectate ) ( &playerMenu, player );
122
155
        }
123
156
 
124
157
        for ( i = eTeam::teams.Len()-1; i>=0; --i )
130
163
            }
131
164
        }
132
165
 
133
 
        if ( /* eTeam::NewTeamAllowed() && */
 
166
        if ( player->IsSpectating() ||
134
167
            !( player->NextTeam() && player->NextTeam()->NumHumanPlayers() == 1 &&
135
168
               player->CurrentTeam() && player->CurrentTeam()->NumHumanPlayers() == 1 )
136
169
        )
137
170
        {
138
171
            items[ items.Len() ] = tNEW( gMenuItemNewTeam ) ( &playerMenu, player );
139
 
 
140
172
        }
141
173
 
142
174
        playerMenu.Enter();