weaponItem added
authordisplacer
Fri, 30 Nov 2007 18:31:41 +0000
changeset 624 e7673b036db5
parent 623 ca1c1bd15915
child 625 373353eaa742
weaponItem added
QTfrontend/CMakeLists.txt
QTfrontend/hedgehogerWidget.cpp
QTfrontend/hedgewars.qrc
QTfrontend/itemNum.cpp
QTfrontend/itemNum.h
QTfrontend/res/M2Round2.jpg
QTfrontend/selectWeapon.cpp
QTfrontend/selectWeapon.h
QTfrontend/weaponItem.cpp
QTfrontend/weaponItem.h
hedgewars.kdevelop
--- 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
--- 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()
--- 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 @@
 <!DOCTYPE RCC><RCC version="1.0">
 <qresource>
     <file>res/hh25x25.png</file>
+    <file>res/M2Round2.jpg</file>
     <file>res/botlevels/0.png</file>
     <file>res/botlevels/1.png</file>
     <file>res/botlevels/2.png</file>
--- 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 <QMouseEvent>
 #include <QPainter>
 
-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;
+}
--- 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 );
Binary file QTfrontend/res/M2Round2.jpg has changed
--- 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 <QPushButton>
+#include <QGridLayout>
+
+#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);
 }
--- 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 <QWidget>
 
+class QGridLayout;
+
 class SelWeaponWidget : public QWidget
 {
   Q_OBJECT
   public:
     SelWeaponWidget(QWidget* parent=0);
+
+ private:
+  QGridLayout* pLayout;
 };
 
 #endif // _SELECT_WEAPON_INCLUDED
--- /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;
+}
+
--- /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 <iulyanov@gmail.com>
+ *
+ * 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
--- 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 @@
     <projectname>hedgewars</projectname>
     <projectdirectory>.</projectdirectory>
     <absoluteprojectpath>false</absoluteprojectpath>
-    <description/>
+    <description></description>
     <versioncontrol>kdevsubversion</versioncontrol>
-    <defaultencoding/>
+    <defaultencoding></defaultencoding>
   </general>
   <kdevcustomproject>
     <run>
       <directoryradio>executable</directoryradio>
       <customdirectory>/</customdirectory>
-      <mainprogram>/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GNA/bin/hedgewars</mainprogram>
-      <programargs/>
+      <mainprogram>/home/igor/sources/hedgewars/bin/hedgewars</mainprogram>
+      <programargs></programargs>
       <terminal>false</terminal>
       <autocompile>true</autocompile>
       <envvars/>
-      <globaldebugarguments/>
-      <globalcwd>/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GNA</globalcwd>
+      <globaldebugarguments></globaldebugarguments>
+      <globalcwd>/home/igor/sources/hedgewars/bin</globalcwd>
       <useglobalprogram>false</useglobalprogram>
       <autoinstall>false</autoinstall>
       <autokdesu>false</autokdesu>
@@ -172,16 +172,16 @@
     </general>
     <build>
       <buildtool>make</buildtool>
-      <builddir/>
+      <builddir></builddir>
     </build>
     <make>
-      <abortonerror>false</abortonerror>
+      <abortonerror>true</abortonerror>
       <numberofjobs>1</numberofjobs>
       <prio>0</prio>
       <dontact>false</dontact>
-      <makebin/>
-      <defaulttarget/>
-      <makeoptions/>
+      <makebin></makebin>
+      <defaulttarget></defaulttarget>
+      <makeoptions></makeoptions>
       <selectedenvironment>default</selectedenvironment>
       <environments>
         <default/>
@@ -189,9 +189,9 @@
     </make>
     <other>
       <prio>0</prio>
-      <otherbin/>
-      <defaulttarget/>
-      <otheroptions/>
+      <otherbin></otherbin>
+      <defaulttarget></defaulttarget>
+      <otheroptions></otheroptions>
       <selectedenvironment>default</selectedenvironment>
       <environments>
         <default/>
@@ -200,12 +200,12 @@
   </kdevcustomproject>
   <kdevdebugger>
     <general>
-      <dbgshell/>
+      <dbgshell></dbgshell>
       <programargs/>
-      <gdbpath/>
-      <configGdbScript/>
-      <runShellScript/>
-      <runGdbScript/>
+      <gdbpath></gdbpath>
+      <configGdbScript></configGdbScript>
+      <runShellScript></runShellScript>
+      <runGdbScript></runGdbScript>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>false</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
@@ -272,13 +272,13 @@
   </kdevfilecreate>
   <kdevcppsupport>
     <qt>
-      <used>false</used>
+      <used>true</used>
       <version>4</version>
-      <includestyle>3</includestyle>
+      <includestyle>4</includestyle>
       <root>/usr/qt/3</root>
       <designerintegration>EmbeddedKDevDesigner</designerintegration>
-      <qmake>/usr/local/bin/qmake-qt4</qmake>
-      <designer>/usr/local/bin/designer-qt4</designer>
+      <qmake>/usr/bin/qmake</qmake>
+      <designer>/usr/bin/designer</designer>
       <designerpluginpaths/>
     </qt>
     <references/>
@@ -310,7 +310,7 @@
       <includeTypedefs>false</includeTypedefs>
     </codecompletion>
     <creategettersetter>
-      <prefixGet/>
+      <prefixGet></prefixGet>
       <prefixSet>set</prefixSet>
       <prefixVariable>m_,_</prefixVariable>
       <parameterName>theValue</parameterName>
@@ -329,7 +329,7 @@
       <hidenonlocation>false</hidenonlocation>
     </groups>
     <tree>
-      <hidepatterns>*.o,*.lo,CVS</hidepatterns>
+      <hidepatterns></hidepatterns>
       <hidenonprojectfiles>true</hidenonprojectfiles>
       <showvcsfields>false</showvcsfields>
     </tree>