Advanced Strategic Command
emailsetup.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.de
3  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 
22 #include <sstream>
23 #include <pgimage.h>
24 
25 #include "../iconrepository.h"
26 #include "../gamemap.h"
27 #include "../paradialog.h"
28 #include "emailsetup.h"
29 
30 
31 
32 EmailSetupWidget::EmailSetupWidget( GameMap* gamemap, int editablePlayers, PG_Widget *parent, const PG_Rect &r, const std::string &style ) : PG_ScrollWidget( parent, r, style ) , actmap ( gamemap )
33 {
34  int counter = 0;
35  int y1 = Width() * 4 / 10;
36 
37  const int colBarXStart = 20;
38  new PG_Label( this, PG_Rect( colBarXStart + y1, 20, 200, 20 ), "Email Address" );
39 
40  for ( int i = 0; i < actmap->getPlayerCount(); ++i )
41  if ( actmap->player[i].exist() ) {
42 
43  PlayerWidgets pw;
44  pw.pos = i;
45 
46  int y = 50 + counter * spacing;
47 
48  ColoredBar* colbar = new ColoredBar( actmap->player[i].getColor(), this, PG_Rect( colBarXStart, y, Width() - 60, 30 ));
49  colbar->SetTransparency( 128 );
50 
51 
52 
53  pw.name = new PG_LineEdit( colbar, PG_Rect( 40, 5, y1 - 40, 20 ));
54  pw.name->SetText( actmap->player[i].getName());
55  pw.name->SetEditable(false );
56 
57  PG_Rect r = PG_Rect( y1 + 20, 5, colbar->Width() - y1 - 40, 20 );
58  pw.email = new PG_LineEdit( colbar, r );
59  pw.email->SetText( actmap->player[i].email );
60 
61 
62  if ( editablePlayers == -1 || editablePlayers == gamemap->actplayer ) {
63  pw.email->SetEditable(true);
64  } else {
65  pw.email->SetEditable(false);
66  }
67 
68  PG_ThemeWidget* col = new PG_ThemeWidget( colbar, PG_Rect( 5, 5, 20, 20 ));
69  col->SetSimpleBackground(true);
70  col->SetBackgroundColor ( actmap->player[i].getColor());
71  col->SetBorderSize(0);
72 
73  playerWidgets.push_back( pw );
74 
75  ++counter;
76  }
77 
78  SetTransparency(255);
79 };
80 
81 
83 {
84  for ( vector<PlayerWidgets>::iterator i = playerWidgets.begin(); i != playerWidgets.end(); ++i )
85  actmap->player[i->pos].email = i->email->GetText();
86 };
ASCString getName() const
returns the name of the player
Definition: player.cpp:274
EmailSetupWidget(GameMap *gamemap, int editablePlayers, PG_Widget *parent, const PG_Rect &r, const std::string &style="ScrollWidget")
Definition: emailsetup.cpp:32
ASCString email
Definition: player.h:211
DI_Color getColor() const
Definition: player.cpp:249
signed char actplayer
the player who is currently making his moves (may be human or AI)
Definition: gamemap.h:232
Player player[9]
Definition: gamemap.h:253
GameMap * actmap
Definition: spfst.cpp:64
int getPlayerCount() const
Definition: gamemap.h:255
bool exist() const
does the player exist at all
Definition: player.cpp:313
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182