15 * along with this program; if not, write to the Free Software |
15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 */ |
17 */ |
18 |
18 |
19 #include "selectWeapon.h" |
19 #include "selectWeapon.h" |
|
20 #include "weaponItem.h" |
20 |
21 |
21 #include <QPushButton> |
22 #include <QPushButton> |
22 #include <QGridLayout> |
23 #include <QGridLayout> |
|
24 #include <QHBoxLayout> |
|
25 #include <QLabel> |
23 |
26 |
24 #include "weaponItem.h" |
27 QImage getAmmoImage(int num) |
|
28 { |
|
29 static QImage ammo(":Ammos.png"); |
|
30 return ammo.copy(0, num*32, 32, 32); |
|
31 } |
|
32 |
|
33 SelWeaponItem::SelWeaponItem(int num, QWidget* parent) : |
|
34 QWidget(parent) |
|
35 { |
|
36 QHBoxLayout* hbLayout = new QHBoxLayout(this); |
|
37 |
|
38 QLabel* lbl = new QLabel("1"); |
|
39 lbl->setPixmap(QPixmap::fromImage(getAmmoImage(num))); |
|
40 |
|
41 hbLayout->addWidget(lbl); |
|
42 WeaponItem* item=new WeaponItem(QImage(":/res/M2Round2.jpg"), this); |
|
43 hbLayout->addWidget(item); |
|
44 } |
25 |
45 |
26 SelWeaponWidget::SelWeaponWidget(QWidget* parent) : |
46 SelWeaponWidget::SelWeaponWidget(QWidget* parent) : |
27 QWidget(parent) |
47 QWidget(parent) |
28 { |
48 { |
29 pLayout=new QGridLayout(this); |
49 pLayout=new QGridLayout(this); |
30 |
50 |
31 WeaponItem* item=new WeaponItem(QImage(":/res/M2Round2.jpg"), this); |
51 int j=-1; |
32 pLayout->addWidget(item); |
52 for(int i=0; i<19; ++i) { |
|
53 if (i%4==0) ++j; |
|
54 SelWeaponItem* swi = new SelWeaponItem(i, this); |
|
55 pLayout->addWidget(swi, j, i%4); |
|
56 } |
33 } |
57 } |