QTfrontend/hedgehogerWidget.cpp
changeset 184 f97a7a3dc8f6
parent 183 57c2ef19f719
child 207 287077789132
--- a/QTfrontend/hedgehogerWidget.cpp	Thu Oct 05 16:33:18 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp	Thu Oct 05 17:02:09 2006 +0000
@@ -1,79 +1,79 @@
-/*
- * Hedgewars, a worms-like game
- * Copyright (c) 2006 Ulyanov Igor <iulyanov@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "hedgehogerWidget.h"
-
-#include <QMouseEvent>
-#include <QPainter>
-
-#include "frameTeam.h"
-
-CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
-  QWidget(parent)
-{
-  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()
-{
-  pOurFrameTeams->overallHedgehogs-=numHedgehogs;
-}
-
-void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
-{
-  if(event->button()==Qt::LeftButton) {
-    event->accept();
-    if(numHedgehogs < 8 && pOurFrameTeams->overallHedgehogs<18) {
-      numHedgehogs++;
-      pOurFrameTeams->overallHedgehogs++;
-    }
-  } else if (event->button()==Qt::RightButton) {
-    event->accept();
-    if(numHedgehogs > 3) {
-      numHedgehogs--;
-      pOurFrameTeams->overallHedgehogs--;
-    }
-  } else {
-    event->ignore();
-    return;
-  }
-  repaint();
-}
-
-void CHedgehogerWidget::paintEvent(QPaintEvent* event)
-{
-  QImage image(":/res/hh25x25.png");
-
-  QPainter painter(this);
-
-  for(int i=0; i<numHedgehogs; i++) {
-    QRect target(11 * i, i % 2, 25, 25);
-    painter.drawImage(target, image);
-  }
-}
-
-unsigned char CHedgehogerWidget::getHedgehogsNum()
-{
-  return numHedgehogs;
-}
+/*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2006 Ulyanov Igor <iulyanov@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "hedgehogerWidget.h"
+
+#include <QMouseEvent>
+#include <QPainter>
+
+#include "frameTeam.h"
+
+CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
+  QWidget(parent)
+{
+  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()
+{
+  pOurFrameTeams->overallHedgehogs-=numHedgehogs;
+}
+
+void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
+{
+  if(event->button()==Qt::LeftButton) {
+    event->accept();
+    if(numHedgehogs < 8 && pOurFrameTeams->overallHedgehogs<18) {
+      numHedgehogs++;
+      pOurFrameTeams->overallHedgehogs++;
+    }
+  } else if (event->button()==Qt::RightButton) {
+    event->accept();
+    if(numHedgehogs > 3) {
+      numHedgehogs--;
+      pOurFrameTeams->overallHedgehogs--;
+    }
+  } else {
+    event->ignore();
+    return;
+  }
+  repaint();
+}
+
+void CHedgehogerWidget::paintEvent(QPaintEvent* event)
+{
+  QImage image(":/res/hh25x25.png");
+
+  QPainter painter(this);
+
+  for(int i=0; i<numHedgehogs; i++) {
+    QRect target(11 * i, i % 2, 25, 25);
+    painter.drawImage(target, image);
+  }
+}
+
+unsigned char CHedgehogerWidget::getHedgehogsNum()
+{
+  return numHedgehogs;
+}