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>
|
229
|
24 |
#include <QStyleFactory>
|
184
|
25 |
|
207
|
26 |
#include "frameTeam.h"
|
|
27 |
|
184
|
28 |
void TeamLabel::teamButtonClicked()
|
|
29 |
{
|
|
30 |
emit teamActivated(text());
|
|
31 |
}
|
|
32 |
|
|
33 |
TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) :
|
207
|
34 |
QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), colorButt(0)
|
184
|
35 |
{
|
|
36 |
mainLayout.setSpacing(1);
|
|
37 |
mainLayout.setMargin(2);
|
|
38 |
this->setMaximumHeight(35);
|
352
|
39 |
QIcon difficultyIcon=team.isNetTeam() ? QIcon(QString(":/res/net.png"))
|
340
|
40 |
: QIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty));
|
184
|
41 |
|
|
42 |
QPalette newPalette = palette();
|
|
43 |
newPalette.setColor(QPalette::Button, palette().color(backgroundRole()));
|
|
44 |
|
207
|
45 |
// team fort
|
234
|
46 |
QPushButton* butt=new QPushButton(difficultyIcon, "", this);
|
184
|
47 |
butt->setFlat(true);
|
|
48 |
butt->setGeometry(0, 0, 30, 30);
|
|
49 |
butt->setMaximumWidth(30);
|
|
50 |
butt->setPalette(newPalette);
|
|
51 |
mainLayout.addWidget(butt);
|
|
52 |
butt->setIconSize(butt->size());
|
|
53 |
|
207
|
54 |
// team name
|
184
|
55 |
QPushButton* bText=new QPushButton(team.TeamName, this);
|
|
56 |
bText->setPalette(newPalette);
|
|
57 |
bText->setFlat(true);
|
|
58 |
mainLayout.addWidget(bText);
|
|
59 |
|
|
60 |
if(m_isPlaying) {
|
207
|
61 |
// team color
|
|
62 |
colorButt=new QPushButton(this);
|
|
63 |
colorButt->setMaximumWidth(30);
|
|
64 |
colorButt->setGeometry(0, 0, 30, 30);
|
|
65 |
changeTeamColor();
|
|
66 |
connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor()));
|
|
67 |
mainLayout.addWidget(colorButt);
|
|
68 |
|
|
69 |
// hedgehogs num
|
184
|
70 |
phhoger=new CHedgehogerWidget(this);
|
352
|
71 |
connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged()));
|
184
|
72 |
mainLayout.addWidget(phhoger);
|
|
73 |
}
|
|
74 |
|
|
75 |
QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam()));
|
|
76 |
QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam()));
|
|
77 |
}
|
|
78 |
|
352
|
79 |
void TeamShowWidget::setHHNum(unsigned int num)
|
|
80 |
{
|
|
81 |
phhoger->setHHNum(num);
|
|
82 |
}
|
|
83 |
|
|
84 |
void TeamShowWidget::hhNumChanged()
|
|
85 |
{
|
|
86 |
m_team.numHedgehogs=phhoger->getHedgehogsNum();
|
|
87 |
emit hhNmChanged(m_team);
|
|
88 |
}
|
|
89 |
|
184
|
90 |
void TeamShowWidget::activateTeam()
|
|
91 |
{
|
|
92 |
emit teamStatusChanged(m_team);
|
|
93 |
}
|
|
94 |
|
341
|
95 |
/*HWTeamTempParams TeamShowWidget::getTeamParams() const
|
184
|
96 |
{
|
207
|
97 |
if(!phhoger) throw;
|
|
98 |
HWTeamTempParams params;
|
|
99 |
params.numHedgehogs=phhoger->getHedgehogsNum();
|
|
100 |
params.teamColor=colorButt->palette().color(QPalette::Button);
|
|
101 |
return params;
|
341
|
102 |
}*/
|
207
|
103 |
|
|
104 |
void TeamShowWidget::changeTeamColor()
|
|
105 |
{
|
|
106 |
FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget());
|
|
107 |
if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) {
|
|
108 |
pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin();
|
|
109 |
}
|
341
|
110 |
|
207
|
111 |
QPalette newPalette = palette();
|
|
112 |
newPalette.setColor(QPalette::Button, QColor(*pOurFrameTeams->currentColor));
|
229
|
113 |
//colorButt->setStyleSheet(QString("background-color : ")+pOurFrameTeams->currentColor->name());
|
|
114 |
colorButt->setStyle(QStyleFactory::create("plastique"));
|
|
115 |
colorButt->setPalette(newPalette);
|
207
|
116 |
}
|