# HG changeset patch # User displacer # Date 1198062623 0 # Node ID 7a20c50988ec1d3d8c2db6b57c00db7fe5f00d08 # Parent 8ef26c8e8aa77f2eaf1416941356a159db39e096 working weapons select diff -r 8ef26c8e8aa7 -r 7a20c50988ec QTfrontend/game.cpp --- 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 #include #include +#include #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); diff -r 8ef26c8e8aa7 -r 7a20c50988ec QTfrontend/game.h --- 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; diff -r 8ef26c8e8aa7 -r 7a20c50988ec QTfrontend/hwform.cpp --- 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); diff -r 8ef26c8e8aa7 -r 7a20c50988ec QTfrontend/itemNum.h --- 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); diff -r 8ef26c8e8aa7 -r 7a20c50988ec QTfrontend/selectWeapon.cpp --- 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 #include @@ -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::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; +} diff -r 8ef26c8e8aa7 -r 7a20c50988ec QTfrontend/selectWeapon.h --- 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 +#include 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 weaponItems; QGridLayout* pLayout; }; diff -r 8ef26c8e8aa7 -r 7a20c50988ec hedgewars.kdevelop --- 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 @@ hedgewars . false - + kdevsubversion - + executable / /home/igor/sources/hedgewars/bin/hedgewars - + false true - + /home/igor/sources/hedgewars/bin false false @@ -172,16 +172,16 @@ make - + true 1 0 false - - - + + + default @@ -189,9 +189,9 @@ 0 - - - + + + default @@ -200,12 +200,12 @@ - + - - - - + + + + true false false @@ -310,7 +310,7 @@ false - + set m_,_ theValue