first buggy infinity state for weapons
authordisplacer
Mon, 10 Dec 2007 22:36:54 +0000
changeset 640 e69b651bb336
parent 639 69d7ff3ab6f0
child 641 597ec71895b1
first buggy infinity state for weapons
QTfrontend/hedgewars.qrc
QTfrontend/itemNum.cpp
QTfrontend/itemNum.h
QTfrontend/selectWeapon.cpp
--- a/QTfrontend/hedgewars.qrc	Mon Dec 10 22:05:50 2007 +0000
+++ b/QTfrontend/hedgewars.qrc	Mon Dec 10 22:36:54 2007 +0000
@@ -3,6 +3,7 @@
     <file alias="Ammos.png">../share/hedgewars/Data/Graphics/AmmoMenu/Ammos.png</file>
     <file>res/hh25x25.png</file>
     <file>res/M2Round2.jpg</file>
+    <file>res/infinity.png</file>
     <file>res/botlevels/0.png</file>
     <file>res/botlevels/1.png</file>
     <file>res/botlevels/2.png</file>
--- a/QTfrontend/itemNum.cpp	Mon Dec 10 22:05:50 2007 +0000
+++ b/QTfrontend/itemNum.cpp	Mon Dec 10 22:36:54 2007 +0000
@@ -22,7 +22,8 @@
 #include <QPainter>
 
 ItemNum::ItemNum(const QImage& im, QWidget * parent, unsigned char min, unsigned char max) :
-  m_im(im), QWidget(parent), nonInteractive(false), minItems(min), maxItems(max), numItems(min)
+  m_im(im), QWidget(parent), nonInteractive(false), minItems(min), maxItems(max), numItems(min),
+  infinityState(false)
 {
 }
 
@@ -35,6 +36,9 @@
   if(nonInteractive) return;
   if(event->button()==Qt::LeftButton) {
     event->accept();
+    if(infinityState && numItems==maxItems) {
+      incItems();
+    }
     if(numItems < maxItems) {
       incItems();
     }
@@ -54,9 +58,14 @@
 {
   QPainter painter(this);
 
-  for(int i=0; i<numItems; i++) {
-    QRect target(11 * i, i % 2, 25, 25);
-    painter.drawImage(target, m_im);
+  if (numItems==maxItems+1) {
+    QRect target(0, 0, 250, 32);
+    painter.drawImage(target, QImage(":/res/infinity.png"));
+  } else {
+    for(int i=0; i<numItems; i++) {
+      QRect target(11 * i, i % 2, 25, 25);
+      painter.drawImage(target, m_im);
+    }
   }
 }
 
@@ -69,3 +78,8 @@
 {
   numItems=num;
 }
+
+void ItemNum::setInfinityState(bool value)
+{
+  infinityState=value;
+}
--- a/QTfrontend/itemNum.h	Mon Dec 10 22:05:50 2007 +0000
+++ b/QTfrontend/itemNum.h	Mon Dec 10 22:36:54 2007 +0000
@@ -26,6 +26,9 @@
 {
   Q_OBJECT
 
+  public:
+    void setInfinityState(bool value);
+
   protected:
     ItemNum(const QImage& im, QWidget * parent, unsigned char min=2, unsigned char max=8);
     virtual ~ItemNum()=0;
@@ -47,6 +50,7 @@
     virtual void decItems()=0;
     
   private:
+    bool infinityState;
     QImage m_im;
 };
 
--- a/QTfrontend/selectWeapon.cpp	Mon Dec 10 22:05:50 2007 +0000
+++ b/QTfrontend/selectWeapon.cpp	Mon Dec 10 22:36:54 2007 +0000
@@ -43,6 +43,7 @@
   hbLayout->addWidget(lbl);
 
   WeaponItem* item=new WeaponItem(QImage(":/res/M2Round2.jpg"), this);
+  item->setInfinityState(true);
   hbLayout->addWidget(item);
 
   hbLayout->setStretchFactor(lbl, 1);