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);
|
234
|
39 |
QIcon difficultyIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty));
|
184
|
40 |
|
|
41 |
QPalette newPalette = palette();
|
|
42 |
newPalette.setColor(QPalette::Button, palette().color(backgroundRole()));
|
|
43 |
|
207
|
44 |
// team fort
|
234
|
45 |
QPushButton* butt=new QPushButton(difficultyIcon, "", this);
|
184
|
46 |
butt->setFlat(true);
|
|
47 |
butt->setGeometry(0, 0, 30, 30);
|
|
48 |
butt->setMaximumWidth(30);
|
|
49 |
butt->setPalette(newPalette);
|
|
50 |
mainLayout.addWidget(butt);
|
|
51 |
butt->setIconSize(butt->size());
|
|
52 |
|
207
|
53 |
// team name
|
184
|
54 |
QPushButton* bText=new QPushButton(team.TeamName, this);
|
|
55 |
bText->setPalette(newPalette);
|
|
56 |
bText->setFlat(true);
|
|
57 |
mainLayout.addWidget(bText);
|
|
58 |
|
|
59 |
if(m_isPlaying) {
|
207
|
60 |
// team color
|
|
61 |
colorButt=new QPushButton(this);
|
|
62 |
colorButt->setMaximumWidth(30);
|
|
63 |
colorButt->setGeometry(0, 0, 30, 30);
|
|
64 |
changeTeamColor();
|
|
65 |
connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor()));
|
|
66 |
mainLayout.addWidget(colorButt);
|
|
67 |
|
|
68 |
// hedgehogs num
|
184
|
69 |
phhoger=new CHedgehogerWidget(this);
|
|
70 |
mainLayout.addWidget(phhoger);
|
|
71 |
}
|
|
72 |
|
|
73 |
QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam()));
|
|
74 |
QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam()));
|
|
75 |
}
|
|
76 |
|
|
77 |
void TeamShowWidget::activateTeam()
|
|
78 |
{
|
|
79 |
emit teamStatusChanged(m_team);
|
|
80 |
}
|
|
81 |
|
207
|
82 |
HWTeamTempParams TeamShowWidget::getTeamParams() const
|
184
|
83 |
{
|
207
|
84 |
if(!phhoger) throw;
|
|
85 |
HWTeamTempParams params;
|
|
86 |
params.numHedgehogs=phhoger->getHedgehogsNum();
|
|
87 |
params.teamColor=colorButt->palette().color(QPalette::Button);
|
|
88 |
return params;
|
184
|
89 |
}
|
207
|
90 |
|
|
91 |
void TeamShowWidget::changeTeamColor()
|
|
92 |
{
|
|
93 |
FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget());
|
|
94 |
if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) {
|
|
95 |
pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin();
|
|
96 |
}
|
|
97 |
|
|
98 |
QPalette newPalette = palette();
|
|
99 |
newPalette.setColor(QPalette::Button, QColor(*pOurFrameTeams->currentColor));
|
229
|
100 |
//colorButt->setStyleSheet(QString("background-color : ")+pOurFrameTeams->currentColor->name());
|
|
101 |
colorButt->setStyle(QStyleFactory::create("plastique"));
|
|
102 |
colorButt->setPalette(newPalette);
|
207
|
103 |
}
|