33 |
33 |
34 TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) : |
34 TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) : |
35 QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), |
35 QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), |
36 colorButt(0) |
36 colorButt(0) |
37 { |
37 { |
38 QPalette newPalette = palette(); |
38 QPalette newPalette = palette(); |
39 newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); |
39 newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); |
40 setPalette(newPalette); |
40 setPalette(newPalette); |
41 setAutoFillBackground(true); |
41 setAutoFillBackground(true); |
42 |
42 |
43 mainLayout.setSpacing(3); |
43 mainLayout.setSpacing(3); |
44 mainLayout.setMargin(0); |
44 mainLayout.setMargin(0); |
45 this->setMaximumHeight(38); |
45 this->setMaximumHeight(38); |
46 this->setMinimumHeight(38); |
46 this->setMinimumHeight(38); |
47 QIcon difficultyIcon=team.isNetTeam() ? |
47 QIcon difficultyIcon=team.isNetTeam() ? |
48 QIcon(QString(":/res/botlevels/net%1.png").arg(m_team.difficulty)) |
48 QIcon(QString(":/res/botlevels/net%1.png").arg(m_team.difficulty)) |
49 : QIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty)); |
49 : QIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty)); |
50 |
50 |
51 butt = new QPushButton(difficultyIcon, team.TeamName, this); |
51 butt = new QPushButton(difficultyIcon, team.TeamName, this); |
52 butt->setFlat(true); |
52 butt->setFlat(true); |
53 butt->setToolTip(team.Owner); |
53 butt->setToolTip(team.Owner); |
54 mainLayout.addWidget(butt); |
54 mainLayout.addWidget(butt); |
55 butt->setStyleSheet("QPushButton{" |
55 butt->setStyleSheet("QPushButton{" |
56 "icon-size: 48px;" |
56 "icon-size: 48px;" |
57 "text-align: left;" |
57 "text-align: left;" |
58 "background-color: #0d0544;" |
58 "background-color: #0d0544;" |
59 "color: orange;" |
59 "color: orange;" |
60 "font: bold;" |
60 "font: bold;" |
61 "border-width: 2px;" |
61 "border-width: 2px;" |
62 "margin: 6px 0px 6px 0px;" |
62 "margin: 6px 0px 6px 0px;" |
63 "}"); |
63 "}"); |
64 |
64 |
65 if(m_isPlaying) { |
65 if(m_isPlaying) { |
66 // team color |
66 // team color |
67 colorButt = new QPushButton(this); |
67 colorButt = new QPushButton(this); |
68 colorButt->setMaximumWidth(26); |
68 colorButt->setMaximumWidth(26); |
69 colorButt->setMinimumHeight(26); |
69 colorButt->setMinimumHeight(26); |
70 colorButt->setGeometry(0, 0, 26, 26); |
70 colorButt->setGeometry(0, 0, 26, 26); |
71 |
71 |
72 changeTeamColor(); |
72 changeTeamColor(); |
73 connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor())); |
73 connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor())); |
74 mainLayout.addWidget(colorButt); |
74 mainLayout.addWidget(colorButt); |
75 |
75 |
76 phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), this); |
76 phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), this); |
77 connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); |
77 connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); |
78 mainLayout.addWidget(phhoger); |
78 mainLayout.addWidget(phhoger); |
79 } else { |
79 } else { |
80 } |
80 } |
81 |
81 |
82 QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam())); |
82 QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam())); |
83 //QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam())); |
83 //QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam())); |
84 } |
84 } |
85 |
85 |
86 void TeamShowWidget::setInteractivity(bool interactive) |
86 void TeamShowWidget::setInteractivity(bool interactive) |
87 { |
87 { |
88 if(m_team.isNetTeam()) { |
88 if(m_team.isNetTeam()) { |
89 butt->setEnabled(interactive); |
89 butt->setEnabled(interactive); |
90 } |
90 } |
91 |
91 |
92 colorButt->setEnabled(interactive); |
92 colorButt->setEnabled(interactive); |
93 phhoger->setEnabled(interactive); |
93 phhoger->setEnabled(interactive); |
94 } |
94 } |
95 |
95 |
96 void TeamShowWidget::setHHNum(unsigned int num) |
96 void TeamShowWidget::setHHNum(unsigned int num) |
97 { |
97 { |
98 phhoger->setHHNum(num); |
98 phhoger->setHHNum(num); |
118 return params; |
118 return params; |
119 }*/ |
119 }*/ |
120 |
120 |
121 void TeamShowWidget::changeTeamColor(QColor color) |
121 void TeamShowWidget::changeTeamColor(QColor color) |
122 { |
122 { |
123 FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget()); |
123 FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget()); |
124 if(!color.isValid()) { |
124 if(!color.isValid()) { |
125 if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { |
125 if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { |
126 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); |
126 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); |
127 } |
127 } |
128 color=*pOurFrameTeams->currentColor; |
128 color=*pOurFrameTeams->currentColor; |
129 } else { |
129 } else { |
130 // set according color iterator |
130 // set according color iterator |
131 pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(), |
131 pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(), |
132 pOurFrameTeams->availableColors.end(), color); |
132 pOurFrameTeams->availableColors.end(), color); |
133 if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { |
133 if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { |
134 // error condition |
134 // error condition |
135 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); |
135 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); |
136 } |
136 } |
137 } |
137 } |
138 |
138 |
139 colorButt->setStyleSheet(QString("QPushButton{" |
139 colorButt->setStyleSheet(QString("QPushButton{" |
140 "background-color: %1;" |
140 "background-color: %1;" |
141 "border-width: 1px;" |
141 "border-width: 1px;" |
142 "border-radius: 2px;" |
142 "border-radius: 2px;" |
143 "}").arg(pOurFrameTeams->currentColor->name())); |
143 "}").arg(pOurFrameTeams->currentColor->name())); |
144 |
144 |
145 m_team.teamColor=color; |
145 m_team.teamColor=color; |
146 emit teamColorChanged(m_team); |
146 emit teamColorChanged(m_team); |
147 } |
147 } |
148 |
148 |
149 HWTeam TeamShowWidget::getTeam() const |
149 HWTeam TeamShowWidget::getTeam() const |
150 { |
150 { |
151 return m_team; |
151 return m_team; |