author | unc0rr |
Thu, 05 Oct 2006 16:33:18 +0000 | |
changeset 183 | 57c2ef19f719 |
parent 163 | f864a68e512c |
child 184 | f97a7a3dc8f6 |
permissions | -rw-r--r-- |
153 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2006 Ulyanov Igor <iulyanov@gmail.com> |
|
4 |
* |
|
183 | 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; version 2 of the License |
|
153 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
153 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
153 | 17 |
*/ |
18 |
||
80 | 19 |
#include "frameTeam.h" |
20 |
#include "teamselhelper.h" |
|
21 |
||
22 |
#include <QResizeEvent> |
|
23 |
#include <QCoreApplication> |
|
24 |
||
25 |
using namespace std; |
|
26 |
||
27 |
FrameTeams::FrameTeams(QWidget* parent) : |
|
163
f864a68e512c
hedgehogers number bug fixed - overallHedgehogs initialized to zero :)
displacer
parents:
153
diff
changeset
|
28 |
QWidget(parent), maxHedgehogsPerGame(18), overallHedgehogs(0), mainLayout(this) |
80 | 29 |
{ |
134 | 30 |
mainLayout.setSpacing(1); |
80 | 31 |
} |
32 |
||
132 | 33 |
void FrameTeams::addTeam(HWTeam team, bool willPlay) |
80 | 34 |
{ |
132 | 35 |
TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, willPlay, this); |
87 | 36 |
// int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height(); |
80 | 37 |
teamToWidget.insert(make_pair(team, pTeamShowWidget)); |
38 |
mainLayout.addWidget(pTeamShowWidget); |
|
39 |
QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size()); |
|
40 |
QCoreApplication::postEvent(parentWidget(), pevent); |
|
41 |
} |
|
42 |
||
117 | 43 |
void FrameTeams::removeTeam(HWTeam team) |
80 | 44 |
{ |
45 |
tmapTeamToWidget::iterator it=teamToWidget.find(team); |
|
46 |
mainLayout.removeWidget(it->second); |
|
47 |
delete it->second; |
|
48 |
teamToWidget.erase(team); |
|
49 |
} |
|
50 |
||
117 | 51 |
QWidget* FrameTeams::getTeamWidget(HWTeam team) |
80 | 52 |
{ |
53 |
tmapTeamToWidget::iterator it=teamToWidget.find(team); |
|
54 |
QWidget* ret = it!=teamToWidget.end() ? it->second : 0; |
|
55 |
return ret; |
|
56 |
} |
|
150 | 57 |
|
58 |
bool FrameTeams::isFullTeams() const |
|
59 |
{ |
|
60 |
return overallHedgehogs==maxHedgehogsPerGame; |
|
61 |
} |