author | displacer |
Fri, 15 Sep 2006 15:45:30 +0000 | |
changeset 147 | 52a3c431db8a |
parent 140 | 50ccde437ea1 |
child 150 | d9e8a336195c |
permissions | -rw-r--r-- |
84 | 1 |
#include <QLabel> |
2 |
#include <QPixmap> |
|
3 |
#include <QPushButton> |
|
4 |
#include <QFrame> |
|
114 | 5 |
#include <QDebug> |
84 | 6 |
|
7 |
#include <vertScrollArea.h> |
|
8 |
#include "teamselect.h" |
|
9 |
#include "teamselhelper.h" |
|
10 |
#include "frameTeam.h" |
|
11 |
||
117 | 12 |
void TeamSelWidget::addTeam(HWTeam team) |
84 | 13 |
{ |
132 | 14 |
frameDontPlaying->addTeam(team, false); |
84 | 15 |
curDontPlayingTeams.push_back(team); |
117 | 16 |
QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
17 |
this, SLOT(changeTeamStatus(HWTeam))); |
|
84 | 18 |
} |
19 |
||
117 | 20 |
//void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) |
21 |
//{ |
|
84 | 22 |
//curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); |
117 | 23 |
//} |
84 | 24 |
|
117 | 25 |
void TeamSelWidget::changeTeamStatus(HWTeam team) |
84 | 26 |
{ |
117 | 27 |
list<HWTeam>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team); |
28 |
list<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
|
84 | 29 |
|
132 | 30 |
bool willBePlaying=itDontPlay!=curDontPlayingTeams.end(); |
31 |
||
32 |
if(!willBePlaying) { |
|
84 | 33 |
// playing team => dont playing |
34 |
curDontPlayingTeams.push_back(*itPlay); |
|
35 |
curPlayingTeams.erase(itPlay); |
|
36 |
} else { |
|
147 | 37 |
// return if max playing teams reached |
38 |
if(curPlayingTeams.size()>2) return; |
|
84 | 39 |
// dont playing team => playing |
40 |
curPlayingTeams.push_back(*itDontPlay); |
|
41 |
curDontPlayingTeams.erase(itDontPlay); |
|
42 |
} |
|
43 |
||
44 |
FrameTeams* pRemoveTeams; |
|
45 |
FrameTeams* pAddTeams; |
|
132 | 46 |
if(!willBePlaying) { |
84 | 47 |
pRemoveTeams=framePlaying; |
48 |
pAddTeams=frameDontPlaying; |
|
49 |
} else { |
|
50 |
pRemoveTeams=frameDontPlaying; |
|
51 |
pAddTeams=framePlaying; |
|
52 |
} |
|
53 |
||
132 | 54 |
pAddTeams->addTeam(team, willBePlaying); |
84 | 55 |
pRemoveTeams->removeTeam(team); |
117 | 56 |
QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
57 |
this, SLOT(changeTeamStatus(HWTeam))); |
|
131 | 58 |
|
59 |
QSize szh=pAddTeams->sizeHint(); |
|
60 |
QSize szh1=pRemoveTeams->sizeHint(); |
|
61 |
if(szh.isValid() && szh1.isValid()) { |
|
62 |
pAddTeams->resize(pAddTeams->size().width(), szh.height()); |
|
63 |
pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); |
|
122 | 64 |
} |
84 | 65 |
} |
66 |
||
67 |
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color) |
|
68 |
{ |
|
69 |
VertScrArea* area=new VertScrArea(color); |
|
70 |
area->setWidget(pfteams); |
|
71 |
mainLayout.addWidget(area, 30); |
|
72 |
} |
|
73 |
||
74 |
TeamSelWidget::TeamSelWidget(QWidget* parent) : |
|
75 |
QWidget(parent), mainLayout(this) |
|
76 |
{ |
|
77 |
framePlaying=new FrameTeams(); |
|
78 |
frameDontPlaying=new FrameTeams(); |
|
79 |
addScrArea(framePlaying, QColor("DarkTurquoise")); |
|
80 |
addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow")); |
|
81 |
} |
|
140
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
82 |
|
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
83 |
void TeamSelWidget::resetPlayingTeams() |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
84 |
{ |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
85 |
} |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
86 |
|
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
87 |
bool TeamSelWidget::isPlaying(HWTeam team) |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
88 |
{ |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
89 |
return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end(); |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
90 |
} |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
91 |
|
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
92 |
unsigned char TeamSelWidget::numHedgedogs(HWTeam team) |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
93 |
{ |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
94 |
TeamShowWidget* tsw=dynamic_cast<TeamShowWidget*>(framePlaying->getTeamWidget(team)); |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
95 |
if(!tsw) return 0; |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
96 |
return tsw->getHedgehogsNum(); |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
97 |
} |