30 #include "teamselhelper.h" |
30 #include "teamselhelper.h" |
31 #include "frameTeam.h" |
31 #include "frameTeam.h" |
32 |
32 |
33 void TeamSelWidget::addTeam(HWTeam team) |
33 void TeamSelWidget::addTeam(HWTeam team) |
34 { |
34 { |
35 if(team.isNetTeam()) { |
35 if(team.isNetTeam()) |
36 framePlaying->addTeam(team, true); |
36 { |
37 curPlayingTeams.push_back(team); |
37 framePlaying->addTeam(team, true); |
38 connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
38 curPlayingTeams.push_back(team); |
39 this, SLOT(netTeamStatusChanged(const HWTeam&))); |
39 connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
40 connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), |
40 this, SLOT(netTeamStatusChanged(const HWTeam&))); |
|
41 connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), |
41 this, SLOT(hhNumChanged(const HWTeam&))); |
42 this, SLOT(hhNumChanged(const HWTeam&))); |
42 dynamic_cast<TeamShowWidget*>(framePlaying->getTeamWidget(team))->hhNumChanged(); |
43 dynamic_cast<TeamShowWidget*>(framePlaying->getTeamWidget(team))->hhNumChanged(); |
43 connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), |
44 connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), |
44 this, SLOT(proxyTeamColorChanged(const HWTeam&))); |
45 this, SLOT(proxyTeamColorChanged(const HWTeam&))); |
45 } else { |
46 } |
46 frameDontPlaying->addTeam(team, false); |
47 else |
47 m_curNotPlayingTeams.push_back(team); |
48 { |
48 if(m_acceptOuter) { |
49 frameDontPlaying->addTeam(team, false); |
49 connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
50 m_curNotPlayingTeams.push_back(team); |
50 this, SLOT(pre_changeTeamStatus(HWTeam))); |
51 if(m_acceptOuter) |
51 } else { |
52 { |
52 connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
53 connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
53 this, SLOT(changeTeamStatus(HWTeam))); |
54 this, SLOT(pre_changeTeamStatus(HWTeam))); |
54 } |
55 } |
55 } |
56 else |
56 emit setEnabledGameStart(curPlayingTeams.size()>1); |
57 { |
|
58 connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
|
59 this, SLOT(changeTeamStatus(HWTeam))); |
|
60 } |
|
61 } |
|
62 emit setEnabledGameStart(curPlayingTeams.size()>1); |
57 } |
63 } |
58 |
64 |
59 void TeamSelWidget::setInteractivity(bool interactive) |
65 void TeamSelWidget::setInteractivity(bool interactive) |
60 { |
66 { |
61 framePlaying->setInteractivity(interactive); |
67 framePlaying->setInteractivity(interactive); |
131 emit setEnabledGameStart(curPlayingTeams.size()>1); |
139 emit setEnabledGameStart(curPlayingTeams.size()>1); |
132 } |
140 } |
133 |
141 |
134 void TeamSelWidget::netTeamStatusChanged(const HWTeam& team) |
142 void TeamSelWidget::netTeamStatusChanged(const HWTeam& team) |
135 { |
143 { |
136 QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
144 QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
137 |
145 |
138 } |
146 } |
139 |
147 |
140 //void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) |
148 //void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) |
141 //{ |
149 //{ |
142 //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); |
150 //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); |
143 //} |
151 //} |
144 |
152 |
145 void TeamSelWidget::changeTeamStatus(HWTeam team) |
153 void TeamSelWidget::changeTeamStatus(HWTeam team) |
146 { |
154 { |
147 QList<HWTeam>::iterator itDontPlay=std::find(m_curNotPlayingTeams.begin(), m_curNotPlayingTeams.end(), team); |
155 QList<HWTeam>::iterator itDontPlay=std::find(m_curNotPlayingTeams.begin(), m_curNotPlayingTeams.end(), team); |
148 QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
156 QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
149 |
157 |
150 bool willBePlaying=itDontPlay!=m_curNotPlayingTeams.end(); |
158 bool willBePlaying=itDontPlay!=m_curNotPlayingTeams.end(); |
151 |
159 |
152 if(!willBePlaying) { |
160 if(!willBePlaying) |
153 // playing team => dont playing |
161 { |
154 m_curNotPlayingTeams.push_back(*itPlay); |
162 // playing team => dont playing |
155 emit teamNotPlaying(*itPlay); |
163 m_curNotPlayingTeams.push_back(*itPlay); |
156 curPlayingTeams.erase(itPlay); |
164 emit teamNotPlaying(*itPlay); |
157 } else { |
165 curPlayingTeams.erase(itPlay); |
158 // return if max playing teams reached |
166 } |
159 if(framePlaying->isFullTeams()) return; |
167 else |
160 // dont playing team => playing |
168 { |
161 team=*itDontPlay; // for net team info saving in framePlaying (we have only name with netID from network) |
169 // return if max playing teams reached |
162 itDontPlay->setColor(framePlaying->getNextColor()); |
170 if(framePlaying->isFullTeams()) return; |
163 curPlayingTeams.push_back(*itDontPlay); |
171 // dont playing team => playing |
164 if(!m_acceptOuter) emit teamWillPlay(*itDontPlay); |
172 team=*itDontPlay; // for net team info saving in framePlaying (we have only name with netID from network) |
165 m_curNotPlayingTeams.erase(itDontPlay); |
173 itDontPlay->setColor(framePlaying->getNextColor()); |
166 } |
174 curPlayingTeams.push_back(*itDontPlay); |
167 |
175 if(!m_acceptOuter) emit teamWillPlay(*itDontPlay); |
168 FrameTeams* pRemoveTeams; |
176 m_curNotPlayingTeams.erase(itDontPlay); |
169 FrameTeams* pAddTeams; |
177 } |
170 if(!willBePlaying) { |
178 |
171 pRemoveTeams=framePlaying; |
179 FrameTeams* pRemoveTeams; |
172 pAddTeams=frameDontPlaying; |
180 FrameTeams* pAddTeams; |
173 } else { |
181 if(!willBePlaying) |
174 pRemoveTeams=frameDontPlaying; |
182 { |
175 pAddTeams=framePlaying; |
183 pRemoveTeams=framePlaying; |
176 } |
184 pAddTeams=frameDontPlaying; |
177 |
185 } |
178 pAddTeams->addTeam(team, willBePlaying); |
186 else |
179 pRemoveTeams->removeTeam(team); |
187 { |
180 if(!team.isNetTeam() && m_acceptOuter && !willBePlaying) { |
188 pRemoveTeams=frameDontPlaying; |
181 connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
189 pAddTeams=framePlaying; |
182 this, SLOT(pre_changeTeamStatus(HWTeam))); |
190 } |
183 } else { |
191 |
184 connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
192 pAddTeams->addTeam(team, willBePlaying); |
185 this, SLOT(changeTeamStatus(HWTeam))); |
193 pRemoveTeams->removeTeam(team); |
186 } |
194 if(!team.isNetTeam() && m_acceptOuter && !willBePlaying) |
187 if(willBePlaying) { |
195 { |
188 connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), |
196 connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
189 this, SLOT(hhNumChanged(const HWTeam&))); |
197 this, SLOT(pre_changeTeamStatus(HWTeam))); |
190 dynamic_cast<TeamShowWidget*>(framePlaying->getTeamWidget(team))->hhNumChanged(); |
198 } |
191 connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), |
199 else |
192 this, SLOT(proxyTeamColorChanged(const HWTeam&))); |
200 { |
193 emit teamColorChanged(((TeamShowWidget*)framePlaying->getTeamWidget(team))->getTeam()); |
201 connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
194 } |
202 this, SLOT(changeTeamStatus(HWTeam))); |
195 |
203 } |
196 QSize szh=pAddTeams->sizeHint(); |
204 if(willBePlaying) |
197 QSize szh1=pRemoveTeams->sizeHint(); |
205 { |
198 if(szh.isValid() && szh1.isValid()) { |
206 connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), |
199 pAddTeams->resize(pAddTeams->size().width(), szh.height()); |
207 this, SLOT(hhNumChanged(const HWTeam&))); |
200 pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); |
208 dynamic_cast<TeamShowWidget*>(framePlaying->getTeamWidget(team))->hhNumChanged(); |
201 } |
209 connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), |
202 |
210 this, SLOT(proxyTeamColorChanged(const HWTeam&))); |
203 emit setEnabledGameStart(curPlayingTeams.size()>1); |
211 emit teamColorChanged(((TeamShowWidget*)framePlaying->getTeamWidget(team))->getTeam()); |
|
212 } |
|
213 |
|
214 QSize szh=pAddTeams->sizeHint(); |
|
215 QSize szh1=pRemoveTeams->sizeHint(); |
|
216 if(szh.isValid() && szh1.isValid()) |
|
217 { |
|
218 pAddTeams->resize(pAddTeams->size().width(), szh.height()); |
|
219 pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); |
|
220 } |
|
221 |
|
222 emit setEnabledGameStart(curPlayingTeams.size()>1); |
204 } |
223 } |
205 |
224 |
206 void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color, int fixedHeight) |
225 void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color, int fixedHeight) |
207 { |
226 { |
208 VertScrArea* area = new VertScrArea(color); |
227 VertScrArea* area = new VertScrArea(color); |
236 addScrArea(frameDontPlaying, p.color(QPalette::Window).dark(105), 0); |
255 addScrArea(frameDontPlaying, p.color(QPalette::Window).dark(105), 0); |
237 } |
256 } |
238 |
257 |
239 void TeamSelWidget::setAcceptOuter(bool acceptOuter) |
258 void TeamSelWidget::setAcceptOuter(bool acceptOuter) |
240 { |
259 { |
241 m_acceptOuter=acceptOuter; |
260 m_acceptOuter=acceptOuter; |
242 } |
261 } |
243 |
262 |
244 void TeamSelWidget::resetPlayingTeams(const QList<HWTeam>& teamslist) |
263 void TeamSelWidget::resetPlayingTeams(const QList<HWTeam>& teamslist) |
245 { |
264 { |
246 //for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) { |
265 //for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) { |
247 //framePlaying->removeTeam(*it); |
266 //framePlaying->removeTeam(*it); |
248 //} |
267 //} |
249 framePlaying->resetTeams(); |
268 framePlaying->resetTeams(); |
250 framePlaying->resetColors(); |
269 framePlaying->resetColors(); |
251 curPlayingTeams.clear(); |
270 curPlayingTeams.clear(); |
252 //for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) { |
271 //for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) { |
253 //frameDontPlaying->removeTeam(*it); |
272 //frameDontPlaying->removeTeam(*it); |
254 //} |
273 //} |
255 frameDontPlaying->resetTeams(); |
274 frameDontPlaying->resetTeams(); |
256 m_curNotPlayingTeams.clear(); |
275 m_curNotPlayingTeams.clear(); |
257 |
276 |
258 foreach(HWTeam team, teamslist) |
277 foreach(HWTeam team, teamslist) |
259 addTeam(team); |
278 addTeam(team); |
260 } |
279 } |
261 |
280 |
262 bool TeamSelWidget::isPlaying(HWTeam team) const |
281 bool TeamSelWidget::isPlaying(HWTeam team) const |
263 { |
282 { |
264 return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end(); |
283 return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end(); |
265 } |
284 } |
266 |
285 |
267 QList<HWTeam> TeamSelWidget::getPlayingTeams() const |
286 QList<HWTeam> TeamSelWidget::getPlayingTeams() const |
268 { |
287 { |
269 return curPlayingTeams; |
288 return curPlayingTeams; |
270 } |
289 } |
271 |
290 |
272 QList<HWTeam> TeamSelWidget::getNotPlayingTeams() const |
291 QList<HWTeam> TeamSelWidget::getNotPlayingTeams() const |
273 { |
292 { |
274 return m_curNotPlayingTeams; |
293 return m_curNotPlayingTeams; |
275 } |
294 } |
276 |
295 |
277 void TeamSelWidget::pre_changeTeamStatus(HWTeam team) |
296 void TeamSelWidget::pre_changeTeamStatus(HWTeam team) |
278 { |
297 { |
279 team.setColor(framePlaying->getNextColor()); |
298 team.setColor(framePlaying->getNextColor()); |
280 emit acceptRequested(team); |
299 emit acceptRequested(team); |
281 } |
300 } |