--- a/QTfrontend/game.cpp Wed Dec 19 07:38:36 2007 +0000
+++ b/QTfrontend/game.cpp Wed Dec 19 11:10:23 2007 +0000
@@ -23,6 +23,7 @@
#include <QByteArray>
#include <QFile>
#include <QTextStream>
+#include <QApplication>
#include "game.h"
#include "hwconsts.h"
@@ -32,9 +33,10 @@
#include "KB.h"
#include "proto.h"
-HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget) :
+HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) :
TCPBase(true),
- m_pTeamSelWidget(pTeamSelWidget)
+ m_pTeamSelWidget(pTeamSelWidget),
+ ammostr(ammo)
{
this->config = config;
this->gamecfg = gamecfg;
@@ -83,7 +85,7 @@
{
HWProto::addStringListToBuffer(buf,
(*it).TeamGameConfig(gamecfg->getInitHealth()));
- HWProto::addStringToBuffer(buf, *cDefaultAmmoStore);
+ HWProto::addStringToBuffer(buf, ammostr);
}
}
RawSendIPC(buf);
--- a/QTfrontend/game.h Wed Dec 19 07:38:36 2007 +0000
+++ b/QTfrontend/game.h Wed Dec 19 11:10:23 2007 +0000
@@ -41,7 +41,7 @@
{
Q_OBJECT
public:
- HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget = 0);
+ HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0);
virtual ~HWGame();
void AddTeam(const QString & team);
void PlayDemo(const QString & demofilename);
@@ -76,6 +76,7 @@
char msgbuf[MAXMSGCHARS];
QString teams[5];
QString seed;
+ QString ammostr;
int TeamCount;
GameUIConfig * config;
GameCFGWidget * gamecfg;
--- a/QTfrontend/hwform.cpp Wed Dec 19 07:38:36 2007 +0000
+++ b/QTfrontend/hwform.cpp Wed Dec 19 11:10:23 2007 +0000
@@ -38,6 +38,7 @@
#include "game.h"
#include "team.h"
#include "teamselect.h"
+#include "selectWeapon.h"
#include "gameuiconfig.h"
#include "pages.h"
#include "hwconsts.h"
@@ -549,7 +550,7 @@
void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget)
{
- game = new HWGame(config, gamecfg, pTeamSelWidget);
+ game = new HWGame(config, gamecfg, ui.pageSelectWeapon->pWeapons->getWeaponsString(), pTeamSelWidget);
connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState)));
connect(game, SIGNAL(GameStats(char, const QString &)), this, SLOT(GameStats(char, const QString &)));
connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection);
--- a/QTfrontend/itemNum.h Wed Dec 19 07:38:36 2007 +0000
+++ b/QTfrontend/itemNum.h Wed Dec 19 11:10:23 2007 +0000
@@ -28,6 +28,8 @@
public:
void setInfinityState(bool value);
+ unsigned char getItemsNum() const;
+ void setItemsNum(const unsigned char num);
protected:
ItemNum(const QImage& im, QWidget * parent, unsigned char min=2, unsigned char max=8);
@@ -39,9 +41,6 @@
unsigned char minItems;
unsigned char maxItems;
- unsigned char getItemsNum() const;
- void setItemsNum(const unsigned char num);
-
// from QWidget
virtual void mousePressEvent ( QMouseEvent * event );
virtual void paintEvent(QPaintEvent* event);
--- a/QTfrontend/selectWeapon.cpp Wed Dec 19 07:38:36 2007 +0000
+++ b/QTfrontend/selectWeapon.cpp Wed Dec 19 11:10:23 2007 +0000
@@ -18,6 +18,7 @@
#include "selectWeapon.h"
#include "weaponItem.h"
+#include "hwconsts.h"
#include <QPushButton>
#include <QGridLayout>
@@ -31,7 +32,7 @@
return ammo.copy(0, num*32, 32, 32);
}
-SelWeaponItem::SelWeaponItem(int num, QWidget* parent) :
+SelWeaponItem::SelWeaponItem(int iconNum, int wNum, QWidget* parent) :
QWidget(parent)
{
QHBoxLayout* hbLayout = new QHBoxLayout(this);
@@ -39,12 +40,13 @@
hbLayout->setMargin(1);
QLabel* lbl = new QLabel(this);
- lbl->setPixmap(QPixmap::fromImage(getAmmoImage(num)));
+ lbl->setPixmap(QPixmap::fromImage(getAmmoImage(iconNum)));
lbl->setMaximumWidth(30);
lbl->setGeometry(0, 0, 30, 30);
hbLayout->addWidget(lbl);
- WeaponItem* item=new WeaponItem(QImage(":/res/M2Round2.jpg"), this);
+ item=new WeaponItem(QImage(":/res/hh25x25.png"), this);
+ item->setItemsNum(wNum);
item->setInfinityState(true);
hbLayout->addWidget(item);
@@ -54,6 +56,11 @@
hbLayout->setAlignment(item, Qt::AlignLeft | Qt::AlignVCenter);
}
+unsigned char SelWeaponItem::getItemsNum() const
+{
+ return item->getItemsNum();
+}
+
SelWeaponWidget::SelWeaponWidget(QWidget* parent) :
QWidget(parent)
{
@@ -62,9 +69,26 @@
pLayout->setMargin(1);
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);
+ for(int i=0, k=0; i<20; ++i) {
+ if(i==6) continue;
+ if (k%4==0) ++j;
+ weaponItems[i]=new SelWeaponItem(i, cDefaultAmmoStore->at(10+i).digitValue(), this);
+ pLayout->addWidget(weaponItems[i], j, k%4);
+ ++k;
}
}
+
+int SelWeaponWidget::operator [] (unsigned int weaponIndex) const
+{
+ std::map<int, SelWeaponItem*>::const_iterator it=weaponItems.find(weaponIndex);
+ return it==weaponItems.end() ? 9 : it->second->getItemsNum();
+}
+
+QString SelWeaponWidget::getWeaponsString() const
+{
+ QString ammo("eammstore ");
+ for(int i=0; i<20; ++i) {
+ ammo=QString("%1%2").arg(ammo).arg((*this)[i]);
+ }
+ return ammo;
+}
--- a/QTfrontend/selectWeapon.h Wed Dec 19 07:38:36 2007 +0000
+++ b/QTfrontend/selectWeapon.h Wed Dec 19 11:10:23 2007 +0000
@@ -20,24 +20,35 @@
#define _SELECT_WEAPON_INCLUDED
#include <QWidget>
+#include <map>
class QGridLayout;
+class WeaponItem;
class SelWeaponItem : public QWidget
{
Q_OBJECT
public:
- SelWeaponItem(int num, QWidget* parent=0);
+ SelWeaponItem(int iconNum, int wNum, QWidget* parent=0);
+
+ unsigned char getItemsNum() const;
+
+ private:
+ WeaponItem* item;
};
class SelWeaponWidget : public QWidget
{
Q_OBJECT
- public:
- SelWeaponWidget(QWidget* parent=0);
+
+ public:
+ SelWeaponWidget(QWidget* parent=0);
+ int operator [] (unsigned int weaponIndex) const;
+ QString getWeaponsString() const;
private:
+ std::map<int, SelWeaponItem*> weaponItems;
QGridLayout* pLayout;
};
--- a/hedgewars.kdevelop Wed Dec 19 07:38:36 2007 +0000
+++ b/hedgewars.kdevelop Wed Dec 19 11:10:23 2007 +0000
@@ -18,20 +18,20 @@
<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>/home/igor/sources/hedgewars/bin/hedgewars</mainprogram>
- <programargs></programargs>
+ <programargs/>
<terminal>false</terminal>
<autocompile>true</autocompile>
<envvars/>
- <globaldebugarguments></globaldebugarguments>
+ <globaldebugarguments/>
<globalcwd>/home/igor/sources/hedgewars/bin</globalcwd>
<useglobalprogram>false</useglobalprogram>
<autoinstall>false</autoinstall>
@@ -172,16 +172,16 @@
</general>
<build>
<buildtool>make</buildtool>
- <builddir></builddir>
+ <builddir/>
</build>
<make>
<abortonerror>true</abortonerror>
<numberofjobs>1</numberofjobs>
<prio>0</prio>
<dontact>false</dontact>
- <makebin></makebin>
- <defaulttarget></defaulttarget>
- <makeoptions></makeoptions>
+ <makebin/>
+ <defaulttarget/>
+ <makeoptions/>
<selectedenvironment>default</selectedenvironment>
<environments>
<default/>
@@ -189,9 +189,9 @@
</make>
<other>
<prio>0</prio>
- <otherbin></otherbin>
- <defaulttarget></defaulttarget>
- <otheroptions></otheroptions>
+ <otherbin/>
+ <defaulttarget/>
+ <otheroptions/>
<selectedenvironment>default</selectedenvironment>
<environments>
<default/>
@@ -200,12 +200,12 @@
</kdevcustomproject>
<kdevdebugger>
<general>
- <dbgshell></dbgshell>
+ <dbgshell/>
<programargs/>
- <gdbpath></gdbpath>
- <configGdbScript></configGdbScript>
- <runShellScript></runShellScript>
- <runGdbScript></runGdbScript>
+ <gdbpath/>
+ <configGdbScript/>
+ <runShellScript/>
+ <runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
@@ -310,7 +310,7 @@
<includeTypedefs>false</includeTypedefs>
</codecompletion>
<creategettersetter>
- <prefixGet></prefixGet>
+ <prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>