- Multiplayer game start button
authorunc0rr
Sun, 03 Sep 2006 13:54:45 +0000
changeset 133 c79cb5e5b24a
parent 132 2d0f404cdf05
child 134 3d87d8e58020
- Multiplayer game start button - Alpha-transparent hedgehog for TeamSelWidget
QTfrontend/CMakeLists.txt
QTfrontend/hedgehogerWidget.cpp
QTfrontend/hedgewars.qrc
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/res/hh25x25.png
QTfrontend/teamselhelper.cpp
--- a/QTfrontend/CMakeLists.txt	Sun Sep 03 12:56:13 2006 +0000
+++ b/QTfrontend/CMakeLists.txt	Sun Sep 03 13:54:45 2006 +0000
@@ -25,7 +25,8 @@
 	ui_hwform.cpp
 	gamecfgwidget.cpp
 	pages.cpp
-	SquareLabel.cpp)
+	SquareLabel.cpp
+	hedgehogerWidget.cpp)
 
 if (WIN32)
 	set(hwfr_src ${hwfr_src} res/hedgewars.rc)
@@ -44,7 +45,8 @@
 	gamecfgwidget.h
 	predefteams.h
 	pages.h
-	SquareLabel.h)
+	SquareLabel.h
+	hedgehogerWidget.h)
 
 
 set(hwfr_rez
--- a/QTfrontend/hedgehogerWidget.cpp	Sun Sep 03 12:56:13 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp	Sun Sep 03 13:54:45 2006 +0000
@@ -1,37 +1,36 @@
-#include "hedgehogerWidget.h"
-
-#include <QMouseEvent>
-#include <QPainter>
-
-CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
-  QWidget(parent), numHedgedogs(3)
-{
-}
-
-void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
-{
-  if(event->button()==Qt::LeftButton) {
-    event->accept();
-    numHedgedogs++;
-  } else if (event->button()==Qt::RightButton) {
-    event->accept();
-    if(numHedgedogs!=0) numHedgedogs--;
-  } else {
-    event->ignore();
-    return;
-  }
-  repaint();
-}
-
-void CHedgehogerWidget::paintEvent(QPaintEvent* event)
-{
-  QRectF source(0.0, 0.0, 32.0, 32.0);
-  QImage image("../share/hedgewars/Data/Graphics/Hedgehog.png");
-
-  QPainter painter(this);
-
-  for(int i=0; i<numHedgedogs; i++) {
-    QRectF target(0.0+12.5*i, 0.0, 25.0, 25.0);
-    painter.drawImage(target, image, source);
-  }
-}
+#include "hedgehogerWidget.h"
+
+#include <QMouseEvent>
+#include <QPainter>
+
+CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
+  QWidget(parent), numHedgedogs(3)
+{
+}
+
+void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
+{
+  if(event->button()==Qt::LeftButton) {
+    event->accept();
+    if(numHedgedogs < 8) numHedgedogs++;
+  } else if (event->button()==Qt::RightButton) {
+    event->accept();
+    if(numHedgedogs > 3) numHedgedogs--;
+  } else {
+    event->ignore();
+    return;
+  }
+  repaint();
+}
+
+void CHedgehogerWidget::paintEvent(QPaintEvent* event)
+{
+  QImage image(":/res/hh25x25.png");
+
+  QPainter painter(this);
+
+  for(int i=0; i<numHedgedogs; i++) {
+    QRect target(11 * i, i % 2, 25, 25);
+    painter.drawImage(target, image);
+  }
+}
--- a/QTfrontend/hedgewars.qrc	Sun Sep 03 12:56:13 2006 +0000
+++ b/QTfrontend/hedgewars.qrc	Sun Sep 03 13:54:45 2006 +0000
@@ -1,5 +1,6 @@
 <!DOCTYPE RCC><RCC version="1.0">
 <qresource>
     <file>translations/hedgewars_ru.qm</file>
+    <file>res/hh25x25.png</file>
 </qresource>
 </RCC>
--- a/QTfrontend/hwform.cpp	Sun Sep 03 12:56:13 2006 +0000
+++ b/QTfrontend/hwform.cpp	Sun Sep 03 13:54:45 2006 +0000
@@ -86,6 +86,7 @@
 	connect(ui.pageEditTeam->BtnTeamDiscard,	SIGNAL(clicked()),	this, SLOT(TeamDiscard()));
 
 	connect(ui.pageMultiplayer->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
+	connect(ui.pageMultiplayer->BtnStartMPGame,	SIGNAL(clicked()),	this, SLOT(StartMPGame()));
 
 	connect(ui.pagePlayDemo->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
 	connect(ui.pagePlayDemo->BtnPlayDemo,	SIGNAL(clicked()),	this, SLOT(PlayDemo()));
@@ -254,3 +255,10 @@
 	ui.pageNetGame->listNetTeams->addItems(teams);
 }
 
+void HWForm::StartMPGame()
+{
+	game = new HWGame(config, ui.pageLocalGame->gameCFG);
+	game->AddTeam("DefaultTeam");
+	game->AddTeam("DefaultTeam");
+	game->StartLocal();
+}
--- a/QTfrontend/hwform.h	Sun Sep 03 12:56:13 2006 +0000
+++ b/QTfrontend/hwform.h	Sun Sep 03 13:54:45 2006 +0000
@@ -76,6 +76,7 @@
 	void NetGameEnter();
 	void NetStartGame();
 	void ChangeInNetTeams(const QStringList & teams);
+	void StartMPGame();
 
 private:
 	HWGame * game;
--- a/QTfrontend/pages.cpp	Sun Sep 03 12:56:13 2006 +0000
+++ b/QTfrontend/pages.cpp	Sun Sep 03 13:54:45 2006 +0000
@@ -253,14 +253,21 @@
 {
 	QFont * font14 = new QFont("MS Shell Dlg", 14);
 	QGridLayout * pageLayout = new QGridLayout(this);
+
 	BtnBack = new QPushButton(this);
 	BtnBack->setFont(*font14);
 	BtnBack->setText(QPushButton::tr("Back"));
 	pageLayout->addWidget(BtnBack, 1, 0);
+
 	gameCFG = new GameCFGWidget(this);
 	pageLayout->addWidget(gameCFG, 0, 0, 1, 2);
 	teamsSelect = new TeamSelWidget(this);
 	pageLayout->addWidget(teamsSelect, 0, 2, 1, 2);
+
+	BtnStartMPGame = new QPushButton(this);
+	BtnStartMPGame->setFont(*font14);
+	BtnStartMPGame->setText(QPushButton::tr("Start"));
+	pageLayout->addWidget(BtnStartMPGame, 1, 3);
 }
 
 PagePlayDemo::PagePlayDemo(QWidget* parent) : QWidget(parent)
--- a/QTfrontend/pages.h	Sun Sep 03 12:56:13 2006 +0000
+++ b/QTfrontend/pages.h	Sun Sep 03 13:54:45 2006 +0000
@@ -122,6 +122,7 @@
 	QPushButton *BtnBack;
 	GameCFGWidget *gameCFG;
 	TeamSelWidget *teamsSelect;
+	QPushButton *BtnStartMPGame;
 };
 
 class PagePlayDemo : public QWidget
Binary file QTfrontend/res/hh25x25.png has changed
--- a/QTfrontend/teamselhelper.cpp	Sun Sep 03 12:56:13 2006 +0000
+++ b/QTfrontend/teamselhelper.cpp	Sun Sep 03 13:54:45 2006 +0000
@@ -15,7 +15,7 @@
 TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) :
   QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying)
 {
-  this->setMaximumHeight(40);
+  this->setMaximumHeight(45);
   QPixmap* px=new QPixmap(QPixmap(datadir->absolutePath() + "/Forts/" + m_team.Fort + "L.png").scaled(40, 40));
 
   QPushButton* butt=new QPushButton(*px, "", this);