# HG changeset patch # User displacer # Date 1196447501 0 # Node ID e7673b036db5e2dda8d74e55673dc9d441bda4e2 # Parent ca1c1bd15915e8bac0f737926bf6afedf2a0fda9 weaponItem added diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Fri Oct 26 18:55:27 2007 +0000 +++ b/QTfrontend/CMakeLists.txt Fri Nov 30 18:31:41 2007 +0000 @@ -68,7 +68,8 @@ playrecordpage.cpp hwconsts.cpp selectWeapon.cpp - itemNum.cpp) + itemNum.cpp + weaponItem.cpp) if (WIN32) set(hwfr_src ${hwfr_src} res/hedgewars.rc) @@ -101,7 +102,8 @@ SDLs.h playrecordpage.h selectWeapon.h - itemNum.h) + itemNum.h + weaponItem.h) set(hwfr_hdrs binds.h diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/hedgehogerWidget.cpp --- a/QTfrontend/hedgehogerWidget.cpp Fri Oct 26 18:55:27 2007 +0000 +++ b/QTfrontend/hedgehogerWidget.cpp Fri Nov 30 18:31:41 2007 +0000 @@ -34,20 +34,18 @@ void CHedgehogerWidget::incItems() { - if(numItems < 8 && pOurFrameTeams->overallHedgehogs<18) { - numItems++; - pOurFrameTeams->overallHedgehogs++; - emit hedgehogsNumChanged(); - } + if (pOurFrameTeams->overallHedgehogs<18) { + numItems++; + pOurFrameTeams->overallHedgehogs++; + emit hedgehogsNumChanged(); + } } void CHedgehogerWidget::decItems() { - if(numItems > 1) { - numItems--; - pOurFrameTeams->overallHedgehogs--; - emit hedgehogsNumChanged(); - } + numItems--; + pOurFrameTeams->overallHedgehogs--; + emit hedgehogsNumChanged(); } CHedgehogerWidget::~CHedgehogerWidget() diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/hedgewars.qrc --- a/QTfrontend/hedgewars.qrc Fri Oct 26 18:55:27 2007 +0000 +++ b/QTfrontend/hedgewars.qrc Fri Nov 30 18:31:41 2007 +0000 @@ -1,6 +1,7 @@ res/hh25x25.png + res/M2Round2.jpg res/botlevels/0.png res/botlevels/1.png res/botlevels/2.png diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/itemNum.cpp --- a/QTfrontend/itemNum.cpp Fri Oct 26 18:55:27 2007 +0000 +++ b/QTfrontend/itemNum.cpp Fri Nov 30 18:31:41 2007 +0000 @@ -21,8 +21,8 @@ #include #include -ItemNum::ItemNum(const QImage& im, QWidget * parent) : - m_im(im), QWidget(parent), nonInteractive(false) +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) { } @@ -35,10 +35,14 @@ if(nonInteractive) return; if(event->button()==Qt::LeftButton) { event->accept(); - incItems(); + if(numItems < maxItems) { + incItems(); + } } else if (event->button()==Qt::RightButton) { event->accept(); - decItems(); + if(numItems > minItems) { + decItems(); + } } else { event->ignore(); return; @@ -55,3 +59,13 @@ painter.drawImage(target, m_im); } } + +unsigned char ItemNum::getItemsNum() const +{ + return numItems; +} + +void ItemNum::setItemsNum(const unsigned char num) +{ + numItems=num; +} diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/itemNum.h --- a/QTfrontend/itemNum.h Fri Oct 26 18:55:27 2007 +0000 +++ b/QTfrontend/itemNum.h Fri Nov 30 18:31:41 2007 +0000 @@ -27,11 +27,16 @@ Q_OBJECT protected: - ItemNum(const QImage& im, QWidget * parent); + ItemNum(const QImage& im, QWidget * parent, unsigned char min=2, unsigned char max=8); virtual ~ItemNum()=0; bool nonInteractive; unsigned char numItems; + unsigned char minItems; + unsigned char maxItems; + + unsigned char getItemsNum() const; + void setItemsNum(const unsigned char num); // from QWidget virtual void mousePressEvent ( QMouseEvent * event ); diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/res/M2Round2.jpg Binary file QTfrontend/res/M2Round2.jpg has changed diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/selectWeapon.cpp --- a/QTfrontend/selectWeapon.cpp Fri Oct 26 18:55:27 2007 +0000 +++ b/QTfrontend/selectWeapon.cpp Fri Nov 30 18:31:41 2007 +0000 @@ -15,10 +15,19 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ + +#include "selectWeapon.h" -#include "selectWeapon.h" +#include +#include + +#include "weaponItem.h" SelWeaponWidget::SelWeaponWidget(QWidget* parent) : QWidget(parent) { + pLayout=new QGridLayout(this); + + WeaponItem* item=new WeaponItem(QImage(":/res/M2Round2.jpg"), this); + pLayout->addWidget(item); } diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/selectWeapon.h --- a/QTfrontend/selectWeapon.h Fri Oct 26 18:55:27 2007 +0000 +++ b/QTfrontend/selectWeapon.h Fri Nov 30 18:31:41 2007 +0000 @@ -21,11 +21,16 @@ #include +class QGridLayout; + class SelWeaponWidget : public QWidget { Q_OBJECT public: SelWeaponWidget(QWidget* parent=0); + + private: + QGridLayout* pLayout; }; #endif // _SELECT_WEAPON_INCLUDED diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/weaponItem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/weaponItem.cpp Fri Nov 30 18:31:41 2007 +0000 @@ -0,0 +1,21 @@ +#include "weaponItem.h" + +WeaponItem::WeaponItem(const QImage& im, QWidget * parent) : + ItemNum(im, parent) +{ +} + +WeaponItem::~WeaponItem() +{ +} + +void WeaponItem::incItems() +{ + ++numItems; +} + +void WeaponItem::decItems() +{ + --numItems; +} + diff -r ca1c1bd15915 -r e7673b036db5 QTfrontend/weaponItem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/weaponItem.h Fri Nov 30 18:31:41 2007 +0000 @@ -0,0 +1,43 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006, 2007 Ulyanov Igor + * + * 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 + */ + +#ifndef _WEAPON_ITEM +#define _WEAPON_ITEM + +#include "itemNum.h" + +class WeaponItem : public ItemNum +{ + Q_OBJECT + + public: + WeaponItem(const QImage& im, QWidget * parent); + virtual ~WeaponItem(); + + signals: + void hedgehogsNumChanged(); + + protected: + virtual void incItems(); + virtual void decItems(); + + private: + WeaponItem(); +}; + +#endif // _WEAPON_ITEM diff -r ca1c1bd15915 -r e7673b036db5 hedgewars.kdevelop --- a/hedgewars.kdevelop Fri Oct 26 18:55:27 2007 +0000 +++ b/hedgewars.kdevelop Fri Nov 30 18:31:41 2007 +0000 @@ -18,21 +18,21 @@ hedgewars . false - + kdevsubversion - + executable / - /usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GNA/bin/hedgewars - + /home/igor/sources/hedgewars/bin/hedgewars + false true - - /usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GNA + + /home/igor/sources/hedgewars/bin false false false @@ -172,16 +172,16 @@ make - + - false + true 1 0 false - - - + + + default @@ -189,9 +189,9 @@ 0 - - - + + + default @@ -200,12 +200,12 @@ - + - - - - + + + + true false false @@ -272,13 +272,13 @@ - false + true 4 - 3 + 4 /usr/qt/3 EmbeddedKDevDesigner - /usr/local/bin/qmake-qt4 - /usr/local/bin/designer-qt4 + /usr/bin/qmake + /usr/bin/designer @@ -310,7 +310,7 @@ false - + set m_,_ theValue @@ -329,7 +329,7 @@ false - *.o,*.lo,CVS + true false