TeamBox Class Reference

#include <team_box.h>

Inheritance diagram for TeamBox:

Inheritance graph
[legend]
Collaboration diagram for TeamBox:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TeamBox (std::string player_name, const Rectanglei &rect)
void SetTeam (Team &_team, bool read_team_values=false)
void ClearTeam ()
TeamGetTeam () const
void ValidOptions () const
bool IsLocal () const
void Update (const Point2i &mousePosition, const Point2i &lastMousePosition, Surface &surf)
WidgetClic (const Point2i &mousePosition, uint button)

Private Attributes

bool is_local
Teamassociated_team
PictureWidgetteam_logo
Labelteam_name
TextBoxplayer_name
SpinButtonnb_characters

Detailed Description

Definition at line 33 of file team_box.h.


Constructor & Destructor Documentation

TeamBox::TeamBox ( std::string  player_name,
const Rectanglei rect 
)

Definition at line 28 of file team_box.cpp.

00028                                                                : 
00029   HBox(rect, false)
00030 {
00031   associated_team=NULL;
00032 
00033   SetMargin(2);
00034 
00035   team_logo = new PictureWidget( Rectanglei(0,0,48,48) );
00036   AddWidget(team_logo);
00037 
00038   Box * tmp_box = new VBox(Rectanglei(0, 0, rect.GetSizeX()-80, 80), false);
00039   tmp_box->SetMargin(2);
00040   tmp_box->SetBorder(Point2i(0,0));
00041   team_name = new Label(" ", Rectanglei(0,0,rect.GetSizeX()-80,0),
00042                         *Font::GetInstance(Font::FONT_NORMAL, Font::BOLD), dark_gray_color, false, false);
00043 
00044   Box * tmp_player_box = new HBox(Rectanglei(0,0,0,Font::GetInstance(Font::FONT_SMALL)->GetHeight()), false);
00045   tmp_player_box->SetMargin(0);
00046   tmp_player_box->SetBorder(Point2i(0,0));
00047   tmp_player_box->AddWidget(new Label(_("Head commander"), Rectanglei(0,0,(rect.GetSizeX()-80)-100,0),
00048                                       *Font::GetInstance(Font::FONT_SMALL), dark_gray_color, false, false));
00049   player_name = new TextBox(_player_name, Rectanglei(0,0,100,0),
00050                             *Font::GetInstance(Font::FONT_SMALL));
00051   tmp_player_box->AddWidget(player_name);
00052 
00053   nb_characters = new SpinButton(_("Number of characters"), Rectanglei(0,0,0,0),
00054                                  6,1,2,10,
00055                                  dark_gray_color, false);
00056 
00057   tmp_box->AddWidget(team_name);
00058   tmp_box->AddWidget(tmp_player_box);
00059   tmp_box->AddWidget(nb_characters);
00060 
00061   AddWidget(tmp_box);
00062 }

Here is the call graph for this function:


Member Function Documentation

void TeamBox::ClearTeam (  ) 

Definition at line 84 of file team_box.cpp.

00085 {
00086   associated_team=NULL;
00087 
00088   ForceRedraw();
00089 }

Here is the call graph for this function:

Widget * TeamBox::Clic ( const Point2i mousePosition,
uint  button 
) [virtual]

Reimplemented from Box.

Definition at line 114 of file team_box.cpp.

00115 {
00116   if (associated_team != NULL) {
00117 
00118     Widget* w = WidgetList::Clic(mousePosition, button);
00119 
00120     if ( !associated_team->IsLocal() && !associated_team->IsLocalAI() )
00121       return NULL; // it's not a local team, we can't configure it !!
00122     
00123     if (w == nb_characters || w == player_name) {
00124       if (network.IsConnected()) {
00125         ValidOptions();
00126       }
00127       return w;
00128     }
00129   }
00130   return NULL;
00131 }

Here is the call graph for this function:

Team * TeamBox::GetTeam (  )  const

Definition at line 91 of file team_box.cpp.

00092 {
00093   return associated_team;
00094 }

bool TeamBox::IsLocal (  )  const

Definition at line 160 of file team_box.cpp.

00161 {
00162   if (associated_team != NULL && associated_team->IsLocal()) {
00163     return true;
00164   }
00165 
00166   return false;
00167 }

Here is the call graph for this function:

void TeamBox::SetTeam ( Team _team,
bool  read_team_values = false 
)

Definition at line 64 of file team_box.cpp.

00065 {
00066   associated_team=&_team;
00067 
00068   team_logo->SetSurface(_team.flag);
00069   if (!_team.IsLocal() && !_team.IsLocalAI()) {
00070     team_name->SetText(_team.GetName() + " - " + _("Remote"));
00071   } else {
00072     team_name->SetText(_team.GetName());
00073   }
00074   team_logo->SetSurface(_team.flag);
00075 
00076   if (read_team_values) {
00077     player_name->SetText(_team.GetPlayerName());
00078     nb_characters->SetValue(_team.GetNbCharacters());
00079   }
00080 
00081   ForceRedraw();
00082 }

Here is the call graph for this function:

void TeamBox::Update ( const Point2i mousePosition,
const Point2i lastMousePosition,
Surface surf 
) [virtual]

Reimplemented from Box.

Definition at line 96 of file team_box.cpp.

00099 {
00100   Box::Update(mousePosition, lastMousePosition, surf);
00101   if (need_redrawing) {
00102     Draw(mousePosition, surf);
00103   }
00104 
00105   if (associated_team != NULL){
00106     WidgetList::Update(mousePosition, surf);
00107   } else {
00108     Redraw(*this, surf);
00109   }
00110 
00111   need_redrawing = false;
00112 }

Here is the call graph for this function:

void TeamBox::ValidOptions (  )  const

Definition at line 133 of file team_box.cpp.

00134 {
00135   // set the number of characters
00136   associated_team->SetNbCharacters(uint(nb_characters->GetValue()));
00137 
00138   // set the player name
00139   associated_team->SetPlayerName(player_name->GetText());
00140 
00141   // change only for local teams...
00142   if (associated_team->IsLocal() || associated_team->IsLocalAI()) {
00143 
00144     // player or AI ?
00145     if (player_name->GetText() == "AI-stupid")
00146       associated_team->SetLocalAI();
00147     else 
00148       associated_team->SetLocal();
00149 
00150     // send team configuration to the remote clients
00151     if (network.IsConnected()) {
00152       Action* a = new Action(Action::ACTION_UPDATE_TEAM, associated_team->GetId());
00153       a->Push(associated_team->GetPlayerName());
00154       a->Push(int(associated_team->GetNbCharacters()));
00155       ActionHandler::GetInstance()->NewAction (a);
00156     }
00157   }
00158 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Team* TeamBox::associated_team [private]

Definition at line 38 of file team_box.h.

bool TeamBox::is_local [private]

Definition at line 36 of file team_box.h.

SpinButton* TeamBox::nb_characters [private]

Definition at line 42 of file team_box.h.

TextBox* TeamBox::player_name [private]

Definition at line 41 of file team_box.h.

PictureWidget* TeamBox::team_logo [private]

Definition at line 39 of file team_box.h.

Label* TeamBox::team_name [private]

Definition at line 40 of file team_box.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:23:05 2007 for Wormux by  doxygen 1.4.7