more icons at weapon select
authordisplacer
Thu, 06 Dec 2007 20:02:01 +0000
changeset 629 fb03a39a10ff
parent 628 1d592e3ae7ae
child 630 38338573e09a
more icons at weapon select
QTfrontend/hedgewars.qrc
QTfrontend/selectWeapon.cpp
QTfrontend/selectWeapon.h
--- a/QTfrontend/hedgewars.qrc	Sun Dec 02 18:54:10 2007 +0000
+++ b/QTfrontend/hedgewars.qrc	Thu Dec 06 20:02:01 2007 +0000
@@ -1,5 +1,6 @@
 <!DOCTYPE RCC><RCC version="1.0">
 <qresource>
+    <file alias="Ammos.png">../share/hedgewars/Data/Graphics/AmmoMenu/Ammos.png</file>
     <file>res/hh25x25.png</file>
     <file>res/M2Round2.jpg</file>
     <file>res/botlevels/0.png</file>
--- a/QTfrontend/selectWeapon.cpp	Sun Dec 02 18:54:10 2007 +0000
+++ b/QTfrontend/selectWeapon.cpp	Thu Dec 06 20:02:01 2007 +0000
@@ -17,17 +17,41 @@
  */
  
 #include "selectWeapon.h"
+#include "weaponItem.h"
 
 #include <QPushButton>
 #include <QGridLayout>
+#include <QHBoxLayout>
+#include <QLabel>
 
-#include "weaponItem.h"
+QImage getAmmoImage(int num)
+{
+  static QImage ammo(":Ammos.png");
+  return ammo.copy(0, num*32, 32, 32);
+}
+
+SelWeaponItem::SelWeaponItem(int num, QWidget* parent) :
+  QWidget(parent)
+{
+  QHBoxLayout* hbLayout = new QHBoxLayout(this);
+  
+  QLabel* lbl = new QLabel("1");
+  lbl->setPixmap(QPixmap::fromImage(getAmmoImage(num)));
+  
+  hbLayout->addWidget(lbl);
+  WeaponItem* item=new WeaponItem(QImage(":/res/M2Round2.jpg"), this);
+  hbLayout->addWidget(item);
+}
 
 SelWeaponWidget::SelWeaponWidget(QWidget* parent) :
 QWidget(parent)
 {
   pLayout=new QGridLayout(this);
-  
-  WeaponItem* item=new WeaponItem(QImage(":/res/M2Round2.jpg"), this);
-  pLayout->addWidget(item);
+
+  int j=-1;
+  for(int i=0; i<19; ++i) {
+    if (i%4==0) ++j;
+    SelWeaponItem* swi = new SelWeaponItem(i, this);
+    pLayout->addWidget(swi, j, i%4);
+  }
 }
--- a/QTfrontend/selectWeapon.h	Sun Dec 02 18:54:10 2007 +0000
+++ b/QTfrontend/selectWeapon.h	Thu Dec 06 20:02:01 2007 +0000
@@ -23,6 +23,14 @@
 
 class QGridLayout;
 
+class SelWeaponItem : public QWidget
+{
+  Q_OBJECT
+
+public:
+  SelWeaponItem(int num, QWidget* parent=0);
+};
+
 class SelWeaponWidget : public QWidget
 {
   Q_OBJECT