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);
|
340
|
39 |
QIcon difficultyIcon=team.netTeam ? QIcon(QString(":/res/net.png"))
|
|
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);
|
|
71 |
mainLayout.addWidget(phhoger);
|
|
72 |
}
|
|
73 |
|
|
74 |
QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam()));
|
|
75 |
QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam()));
|
|
76 |
}
|
|
77 |
|
|
78 |
void TeamShowWidget::activateTeam()
|
|
79 |
{
|
|
80 |
emit teamStatusChanged(m_team);
|
|
81 |
}
|
|
82 |
|
341
|
83 |
/*HWTeamTempParams TeamShowWidget::getTeamParams() const
|
184
|
84 |
{
|
207
|
85 |
if(!phhoger) throw;
|
|
86 |
HWTeamTempParams params;
|
|
87 |
params.numHedgehogs=phhoger->getHedgehogsNum();
|
|
88 |
params.teamColor=colorButt->palette().color(QPalette::Button);
|
|
89 |
return params;
|
341
|
90 |
}*/
|
207
|
91 |
|
|
92 |
void TeamShowWidget::changeTeamColor()
|
|
93 |
{
|
|
94 |
FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget());
|
|
95 |
if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) {
|
|
96 |
pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin();
|
|
97 |
}
|
341
|
98 |
|
207
|
99 |
QPalette newPalette = palette();
|
|
100 |
newPalette.setColor(QPalette::Button, QColor(*pOurFrameTeams->currentColor));
|
229
|
101 |
//colorButt->setStyleSheet(QString("background-color : ")+pOurFrameTeams->currentColor->name());
|
|
102 |
colorButt->setStyle(QStyleFactory::create("plastique"));
|
|
103 |
colorButt->setPalette(newPalette);
|
207
|
104 |
}
|