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 "teamselhelper.h"
|
|
20 |
#include "hwconsts.h"
|
|
21 |
|
|
22 |
#include <QPixmap>
|
|
23 |
#include <QPainter>
|
|
24 |
|
207
|
25 |
#include "frameTeam.h"
|
|
26 |
|
184
|
27 |
void TeamLabel::teamButtonClicked()
|
|
28 |
{
|
|
29 |
emit teamActivated(text());
|
|
30 |
}
|
|
31 |
|
|
32 |
TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) :
|
207
|
33 |
QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), colorButt(0)
|
184
|
34 |
{
|
|
35 |
mainLayout.setSpacing(1);
|
|
36 |
mainLayout.setMargin(2);
|
|
37 |
this->setMaximumHeight(35);
|
|
38 |
QPixmap* px=new QPixmap(QPixmap(datadir->absolutePath() + "/Forts/" + m_team.Fort + "L.png").scaled(40, 40));
|
|
39 |
|
|
40 |
QPalette newPalette = palette();
|
|
41 |
newPalette.setColor(QPalette::Button, palette().color(backgroundRole()));
|
|
42 |
|
207
|
43 |
// team fort
|
184
|
44 |
QPushButton* butt=new QPushButton(*px, "", this);
|
|
45 |
butt->setFlat(true);
|
|
46 |
butt->setGeometry(0, 0, 30, 30);
|
|
47 |
butt->setMaximumWidth(30);
|
|
48 |
butt->setPalette(newPalette);
|
|
49 |
mainLayout.addWidget(butt);
|
|
50 |
butt->setIconSize(butt->size());
|
|
51 |
|
207
|
52 |
// team name
|
184
|
53 |
QPushButton* bText=new QPushButton(team.TeamName, this);
|
|
54 |
bText->setPalette(newPalette);
|
|
55 |
bText->setFlat(true);
|
|
56 |
mainLayout.addWidget(bText);
|
|
57 |
|
|
58 |
if(m_isPlaying) {
|
207
|
59 |
// team color
|
|
60 |
colorButt=new QPushButton(this);
|
|
61 |
colorButt->setMaximumWidth(30);
|
|
62 |
colorButt->setGeometry(0, 0, 30, 30);
|
|
63 |
changeTeamColor();
|
|
64 |
connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor()));
|
|
65 |
mainLayout.addWidget(colorButt);
|
|
66 |
|
|
67 |
// hedgehogs num
|
184
|
68 |
phhoger=new CHedgehogerWidget(this);
|
|
69 |
mainLayout.addWidget(phhoger);
|
|
70 |
}
|
|
71 |
|
|
72 |
QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam()));
|
|
73 |
QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam()));
|
|
74 |
}
|
|
75 |
|
|
76 |
void TeamShowWidget::activateTeam()
|
|
77 |
{
|
|
78 |
emit teamStatusChanged(m_team);
|
|
79 |
}
|
|
80 |
|
207
|
81 |
HWTeamTempParams TeamShowWidget::getTeamParams() const
|
184
|
82 |
{
|
207
|
83 |
if(!phhoger) throw;
|
|
84 |
HWTeamTempParams params;
|
|
85 |
params.numHedgehogs=phhoger->getHedgehogsNum();
|
|
86 |
params.teamColor=colorButt->palette().color(QPalette::Button);
|
|
87 |
return params;
|
184
|
88 |
}
|
207
|
89 |
|
|
90 |
void TeamShowWidget::changeTeamColor()
|
|
91 |
{
|
|
92 |
FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget());
|
|
93 |
if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) {
|
|
94 |
pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin();
|
|
95 |
}
|
|
96 |
|
|
97 |
QPalette newPalette = palette();
|
|
98 |
newPalette.setColor(QPalette::Button, QColor(*pOurFrameTeams->currentColor));
|
|
99 |
colorButt->setPalette(newPalette);
|
|
100 |
}
|