184
|
1 |
/*
|
|
2 |
* Hedgewars, a worms-like game
|
|
3 |
* Copyright (c) 2006 Ulyanov Igor <iulyanov@gmail.com>
|
|
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; version 2 of the License
|
|
8 |
*
|
|
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.
|
|
13 |
*
|
|
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
|
|
17 |
*/
|
|
18 |
|
|
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) :
|
|
28 |
QWidget(parent), maxHedgehogsPerGame(18), overallHedgehogs(0), mainLayout(this)
|
|
29 |
{
|
|
30 |
mainLayout.setSpacing(1);
|
|
31 |
}
|
|
32 |
|
|
33 |
void FrameTeams::addTeam(HWTeam team, bool willPlay)
|
|
34 |
{
|
|
35 |
TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, willPlay, this);
|
|
36 |
// int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height();
|
|
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 |
|
|
43 |
void FrameTeams::removeTeam(HWTeam team)
|
|
44 |
{
|
|
45 |
tmapTeamToWidget::iterator it=teamToWidget.find(team);
|
|
46 |
mainLayout.removeWidget(it->second);
|
|
47 |
delete it->second;
|
|
48 |
teamToWidget.erase(team);
|
|
49 |
}
|
|
50 |
|
|
51 |
QWidget* FrameTeams::getTeamWidget(HWTeam team)
|
|
52 |
{
|
|
53 |
tmapTeamToWidget::iterator it=teamToWidget.find(team);
|
|
54 |
QWidget* ret = it!=teamToWidget.end() ? it->second : 0;
|
|
55 |
return ret;
|
|
56 |
}
|
|
57 |
|
|
58 |
bool FrameTeams::isFullTeams() const
|
|
59 |
{
|
|
60 |
return overallHedgehogs==maxHedgehogsPerGame;
|
|
61 |
}
|