QTfrontend/hedgehogerWidget.cpp
changeset 133 c79cb5e5b24a
parent 132 2d0f404cdf05
child 134 3d87d8e58020
--- a/QTfrontend/hedgehogerWidget.cpp	Sun Sep 03 12:56:13 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp	Sun Sep 03 13:54:45 2006 +0000
@@ -1,37 +1,36 @@
-#include "hedgehogerWidget.h"
-
-#include <QMouseEvent>
-#include <QPainter>
-
-CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
-  QWidget(parent), numHedgedogs(3)
-{
-}
-
-void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
-{
-  if(event->button()==Qt::LeftButton) {
-    event->accept();
-    numHedgedogs++;
-  } else if (event->button()==Qt::RightButton) {
-    event->accept();
-    if(numHedgedogs!=0) numHedgedogs--;
-  } else {
-    event->ignore();
-    return;
-  }
-  repaint();
-}
-
-void CHedgehogerWidget::paintEvent(QPaintEvent* event)
-{
-  QRectF source(0.0, 0.0, 32.0, 32.0);
-  QImage image("../share/hedgewars/Data/Graphics/Hedgehog.png");
-
-  QPainter painter(this);
-
-  for(int i=0; i<numHedgedogs; i++) {
-    QRectF target(0.0+12.5*i, 0.0, 25.0, 25.0);
-    painter.drawImage(target, image, source);
-  }
-}
+#include "hedgehogerWidget.h"
+
+#include <QMouseEvent>
+#include <QPainter>
+
+CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
+  QWidget(parent), numHedgedogs(3)
+{
+}
+
+void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
+{
+  if(event->button()==Qt::LeftButton) {
+    event->accept();
+    if(numHedgedogs < 8) numHedgedogs++;
+  } else if (event->button()==Qt::RightButton) {
+    event->accept();
+    if(numHedgedogs > 3) numHedgedogs--;
+  } else {
+    event->ignore();
+    return;
+  }
+  repaint();
+}
+
+void CHedgehogerWidget::paintEvent(QPaintEvent* event)
+{
+  QImage image(":/res/hh25x25.png");
+
+  QPainter painter(this);
+
+  for(int i=0; i<numHedgedogs; i++) {
+    QRect target(11 * i, i % 2, 25, 25);
+    painter.drawImage(target, image);
+  }
+}