working multiplayer weapons combo
authordisplacer
Wed, 09 Jan 2008 21:22:22 +0000
changeset 696 d6f32ed6edc8
parent 695 34a93d123712
child 697 44f167938201
working multiplayer weapons combo
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/pages.cpp
QTfrontend/selectWeapon.cpp
QTfrontend/selectWeapon.h
--- a/QTfrontend/gamecfgwidget.cpp	Wed Jan 09 20:26:31 2008 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Wed Jan 09 21:22:22 2008 +0000
@@ -67,7 +67,14 @@
 	GBoxOptionsLayout->addWidget(SB_TurnTime, 1, 1);
 	GBoxOptionsLayout->addWidget(SB_InitHealth, 2, 1);
 
-	mainLayout.addWidget(new QWidget, 100);
+	QGroupBox *GBoxWeapons = new QGroupBox(this);
+	GBoxWeapons->setTitle(QGroupBox::tr("Weapons"));
+	QHBoxLayout* lt=new QHBoxLayout(GBoxWeapons);
+	WeaponsName = new QComboBox(GBoxWeapons);
+	lt->addWidget(WeaponsName);
+	mainLayout.addWidget(GBoxWeapons);
+
+	mainLayout.addWidget(new QWidget(this), 100);
 
 	connect(SB_InitHealth, SIGNAL(valueChanged(int)), this, SLOT(onInitHealthChanged(int)));
 	connect(SB_TurnTime, SIGNAL(valueChanged(int)), this, SLOT(onTurnTimeChanged(int)));
--- a/QTfrontend/gamecfgwidget.h	Wed Jan 09 20:26:31 2008 +0000
+++ b/QTfrontend/gamecfgwidget.h	Wed Jan 09 21:22:22 2008 +0000
@@ -43,6 +43,8 @@
 	quint32 getTurnTime() const;
 	QStringList getFullConfig() const;
 
+	QComboBox* WeaponsName;
+
 public slots:
 	void setSeed(const QString & seed);
 	void setMap(const QString & map);
--- a/QTfrontend/hwform.cpp	Wed Jan 09 20:26:31 2008 +0000
+++ b/QTfrontend/hwform.cpp	Wed Jan 09 21:22:22 2008 +0000
@@ -126,6 +126,12 @@
 {
   ui.pageOptions->WeaponsName->clear();
   ui.pageOptions->WeaponsName->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames());
+
+  ui.pageMultiplayer->gameCFG->WeaponsName->clear();
+  ui.pageMultiplayer->gameCFG->WeaponsName->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames());
+
+  ui.pageNetGame->pGameCFG->WeaponsName->clear();
+  ui.pageNetGame->pGameCFG->WeaponsName->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames());
 }
 
 void HWForm::UpdateTeamsLists(const QStringList* editable_teams)
@@ -336,7 +342,7 @@
 
 void HWForm::SimpleGame()
 {
-	CreateGame(ui.pageSimpleGame->gameCFG, 0);
+	CreateGame(ui.pageSimpleGame->gameCFG, 0, cDefaultAmmoStore->mid(10));
 	game->StartQuick();
 }
 
@@ -351,7 +357,7 @@
 				tr("OK"));
 		return ;
 	}
-	CreateGame(0, 0);
+	CreateGame(0, 0, 0);
 	game->PlayDemo(curritem->data(Qt::UserRole).toString());
 }
 
@@ -502,7 +508,9 @@
 
 void HWForm::StartMPGame()
 {
-	CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect);
+	QString ammo=ui.pageSelectWeapon->pWeapons->getWeaponsString(ui.pageMultiplayer->gameCFG->WeaponsName->currentText());
+
+	CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect, ammo);
 
 	game->StartLocal();
 }
@@ -565,9 +573,9 @@
 	}
 }
 
-void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget)
+void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo)
 {
-	game = new HWGame(config, gamecfg, ui.pageSelectWeapon->pWeapons->getWeaponsString(), pTeamSelWidget);
+	game = new HWGame(config, gamecfg, ammo, 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);
@@ -612,14 +620,15 @@
 
 void HWForm::StartTraining()
 {
-	CreateGame(0, 0);
+	CreateGame(0, 0, 0);
 
 	game->StartTraining();
 }
 
 void HWForm::CreateNetGame()
 {
-	CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
+	QString ammo=ui.pageSelectWeapon->pWeapons->getWeaponsString(ui.pageNetGame->pGameCFG->WeaponsName->currentText());
+	CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget, ammo);
 
 	connect(game, SIGNAL(SendNet(const QByteArray &)), hwnet, SLOT(SendNet(const QByteArray &)));
 	connect(hwnet, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &)));
--- a/QTfrontend/hwform.h	Wed Jan 09 20:26:31 2008 +0000
+++ b/QTfrontend/hwform.h	Wed Jan 09 21:22:22 2008 +0000
@@ -87,7 +87,7 @@
 private:
 	void _NetConnect(const QString & hostName, quint16 port, const QString & nick);
 	void UpdateTeamsLists(const QStringList* editable_teams=0);
-	void CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget);
+	void CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo);
 	void closeEvent(QCloseEvent *event);
 	enum PageIDs {
 		ID_PAGE_SIMPLEGAME      =  0,
--- a/QTfrontend/pages.cpp	Wed Jan 09 20:26:31 2008 +0000
+++ b/QTfrontend/pages.cpp	Wed Jan 09 21:22:22 2008 +0000
@@ -273,6 +273,7 @@
 
 	gameCFG = new GameCFGWidget(this);
 	pageLayout->addWidget(gameCFG, 0, 0, 1, 2);
+
 	teamsSelect = new TeamSelWidget(this);
 	pageLayout->addWidget(teamsSelect, 0, 2, 1, 2);
 
--- a/QTfrontend/selectWeapon.cpp	Wed Jan 09 20:26:31 2008 +0000
+++ b/QTfrontend/selectWeapon.cpp	Wed Jan 09 21:22:22 2008 +0000
@@ -136,6 +136,11 @@
   return currentState;
 }
 
+QString SelWeaponWidget::getWeaponsString(const QString& name) const
+{
+  return wconf->value(name).toString();
+}
+
 void SelWeaponWidget::setWeaponsName(const QString& name)
 {
   if(name!="" && wconf->contains(name)) {
--- a/QTfrontend/selectWeapon.h	Wed Jan 09 20:26:31 2008 +0000
+++ b/QTfrontend/selectWeapon.h	Wed Jan 09 21:22:22 2008 +0000
@@ -47,7 +47,8 @@
   
  public:
   SelWeaponWidget(int numItems, QWidget* parent=0);
-  QString getWeaponsString() const;
+  QString getWeaponsString() const; // deprecated?
+  QString getWeaponsString(const QString& name) const;
   QStringList getWeaponNames() const;
 
  public slots: