QTfrontend/hedgehogerWidget.cpp
changeset 147 52a3c431db8a
parent 140 50ccde437ea1
child 150 d9e8a336195c
--- a/QTfrontend/hedgehogerWidget.cpp	Fri Sep 15 13:47:01 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp	Fri Sep 15 15:45:30 2006 +0000
@@ -3,19 +3,33 @@
 #include <QMouseEvent>
 #include <QPainter>
 
+int overallHedgehogs=0;
+
 CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
   QWidget(parent), numHedgehogs(4)
 {
+  overallHedgehogs+=numHedgehogs;
+}
+
+CHedgehogerWidget::~CHedgehogerWidget()
+{
+  overallHedgehogs-=numHedgehogs;
 }
 
 void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
 {
   if(event->button()==Qt::LeftButton) {
     event->accept();
-    if(numHedgehogs < 8) numHedgehogs++;
+    if(numHedgehogs < 8 && overallHedgehogs<18) {
+      numHedgehogs++;
+      overallHedgehogs++;
+    }
   } else if (event->button()==Qt::RightButton) {
     event->accept();
-    if(numHedgehogs > 3) numHedgehogs--;
+    if(numHedgehogs > 3) {
+      numHedgehogs--;
+      overallHedgehogs--;
+    }
   } else {
     event->ignore();
     return;