--- a/QTfrontend/frameTeam.cpp Sat Sep 16 15:15:30 2006 +0000
+++ b/QTfrontend/frameTeam.cpp Sat Sep 16 17:24:41 2006 +0000
@@ -7,7 +7,7 @@
using namespace std;
FrameTeams::FrameTeams(QWidget* parent) :
- QWidget(parent), mainLayout(this)
+ QWidget(parent), maxHedgehogsPerGame(18), mainLayout(this)
{
mainLayout.setSpacing(1);
}
@@ -36,3 +36,8 @@
QWidget* ret = it!=teamToWidget.end() ? it->second : 0;
return ret;
}
+
+bool FrameTeams::isFullTeams() const
+{
+ return overallHedgehogs==maxHedgehogsPerGame;
+}
--- a/QTfrontend/frameTeam.h Sat Sep 16 15:15:30 2006 +0000
+++ b/QTfrontend/frameTeam.h Sat Sep 16 17:24:41 2006 +0000
@@ -10,15 +10,20 @@
{
Q_OBJECT
+ friend class CHedgehogerWidget;
+
public:
FrameTeams(QWidget* parent=0);
QWidget* getTeamWidget(HWTeam team);
+ bool isFullTeams() const;
public slots:
void addTeam(HWTeam team, bool willPlay);
void removeTeam(HWTeam team);
private:
+ const int maxHedgehogsPerGame;
+ int overallHedgehogs;
QVBoxLayout mainLayout;
typedef map<HWTeam, QWidget*> tmapTeamToWidget;
tmapTeamToWidget teamToWidget;
--- a/QTfrontend/hedgehogerWidget.cpp Sat Sep 16 15:15:30 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp Sat Sep 16 17:24:41 2006 +0000
@@ -3,32 +3,38 @@
#include <QMouseEvent>
#include <QPainter>
-int overallHedgehogs=0;
+#include "frameTeam.h"
CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
- QWidget(parent), numHedgehogs(4)
+ QWidget(parent)
{
- overallHedgehogs+=numHedgehogs;
+ if(parent) {
+ pOurFrameTeams=dynamic_cast<FrameTeams*>(parent->parentWidget());
+ }
+ if(pOurFrameTeams->overallHedgehogs+4>pOurFrameTeams->maxHedgehogsPerGame) {
+ numHedgehogs=pOurFrameTeams->maxHedgehogsPerGame-pOurFrameTeams->overallHedgehogs;
+ } else numHedgehogs=4;
+ pOurFrameTeams->overallHedgehogs+=numHedgehogs;
}
CHedgehogerWidget::~CHedgehogerWidget()
{
- overallHedgehogs-=numHedgehogs;
+ pOurFrameTeams->overallHedgehogs-=numHedgehogs;
}
void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
{
if(event->button()==Qt::LeftButton) {
event->accept();
- if(numHedgehogs < 8 && overallHedgehogs<18) {
+ if(numHedgehogs < 8 && pOurFrameTeams->overallHedgehogs<18) {
numHedgehogs++;
- overallHedgehogs++;
+ pOurFrameTeams->overallHedgehogs++;
}
} else if (event->button()==Qt::RightButton) {
event->accept();
if(numHedgehogs > 3) {
numHedgehogs--;
- overallHedgehogs--;
+ pOurFrameTeams->overallHedgehogs--;
}
} else {
event->ignore();
--- a/QTfrontend/hedgehogerWidget.h Sat Sep 16 15:15:30 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.h Sat Sep 16 17:24:41 2006 +0000
@@ -3,12 +3,14 @@
#include <QWidget>
+class FrameTeams;
+
class CHedgehogerWidget : public QWidget
{
Q_OBJECT
public:
- CHedgehogerWidget(QWidget * parent = 0);
+ CHedgehogerWidget(QWidget * parent);
~CHedgehogerWidget();
unsigned char getHedgehogsNum();
@@ -17,7 +19,9 @@
virtual void mousePressEvent ( QMouseEvent * event );
private:
+ CHedgehogerWidget();
unsigned char numHedgehogs;
+ FrameTeams* pOurFrameTeams;
};
#endif // _HEDGEHOGER_WIDGET
--- a/QTfrontend/teamselect.cpp Sat Sep 16 15:15:30 2006 +0000
+++ b/QTfrontend/teamselect.cpp Sat Sep 16 17:24:41 2006 +0000
@@ -35,7 +35,7 @@
curPlayingTeams.erase(itPlay);
} else {
// return if max playing teams reached
- if(curPlayingTeams.size()>2) return;
+ if(framePlaying->isFullTeams()) return;
// dont playing team => playing
curPlayingTeams.push_back(*itDontPlay);
curDontPlayingTeams.erase(itDontPlay);
--- a/QTfrontend/teamselhelper.h Sat Sep 16 15:15:30 2006 +0000
+++ b/QTfrontend/teamselhelper.h Sat Sep 16 17:24:41 2006 +0000
@@ -31,11 +31,12 @@
void activateTeam();
public:
- TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent = 0);
+ TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent);
void setPlaying(bool isPlaying);
unsigned char getHedgehogsNum();
private:
+ TeamShowWidget();
QHBoxLayout mainLayout;
HWTeam m_team;
bool m_isPlaying;