--- a/QTfrontend/frameTeam.cpp Mon Aug 28 19:02:57 2006 +0000
+++ b/QTfrontend/frameTeam.cpp Sun Sep 03 12:56:13 2006 +0000
@@ -11,9 +11,9 @@
{
}
-void FrameTeams::addTeam(HWTeam team)
+void FrameTeams::addTeam(HWTeam team, bool willPlay)
{
- TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, this);
+ TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, willPlay, this);
// int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height();
teamToWidget.insert(make_pair(team, pTeamShowWidget));
mainLayout.addWidget(pTeamShowWidget);
--- a/QTfrontend/frameTeam.h Mon Aug 28 19:02:57 2006 +0000
+++ b/QTfrontend/frameTeam.h Sun Sep 03 12:56:13 2006 +0000
@@ -15,7 +15,7 @@
QWidget* getTeamWidget(HWTeam team);
public slots:
- void addTeam(HWTeam team);
+ void addTeam(HWTeam team, bool willPlay);
void removeTeam(HWTeam team);
private:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp Sun Sep 03 12:56:13 2006 +0000
@@ -0,0 +1,37 @@
+#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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/hedgehogerWidget.h Sun Sep 03 12:56:13 2006 +0000
@@ -0,0 +1,21 @@
+#ifndef _HEDGEHOGER_WIDGET
+#define _HEDGEHOGER_WIDGET
+
+#include <QWidget>
+
+class CHedgehogerWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ CHedgehogerWidget(QWidget * parent = 0);
+
+ protected:
+ virtual void paintEvent(QPaintEvent* event);
+ virtual void mousePressEvent ( QMouseEvent * event );
+
+ private:
+ unsigned char numHedgedogs;
+};
+
+#endif // _HEDGEHOGER_WIDGET
--- a/QTfrontend/hedgewars.pro Mon Aug 28 19:02:57 2006 +0000
+++ b/QTfrontend/hedgewars.pro Sun Sep 03 12:56:13 2006 +0000
@@ -25,7 +25,8 @@
gamecfgwidget.h \
predefteams.h \
pages.h \
- SquareLabel.h
+ SquareLabel.h \
+ hedgehogerWidget.h
SOURCES += game.cpp \
main.cpp \
@@ -40,7 +41,8 @@
ui_hwform.cpp \
gamecfgwidget.cpp \
pages.cpp \
- SquareLabel.cpp
+ SquareLabel.cpp \
+ hedgehogerWidget.cpp
TRANSLATIONS += translations/hedgewars_ru.ts
--- a/QTfrontend/teamselect.cpp Mon Aug 28 19:02:57 2006 +0000
+++ b/QTfrontend/teamselect.cpp Sun Sep 03 12:56:13 2006 +0000
@@ -11,7 +11,7 @@
void TeamSelWidget::addTeam(HWTeam team)
{
- frameDontPlaying->addTeam(team);
+ frameDontPlaying->addTeam(team, false);
curDontPlayingTeams.push_back(team);
QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
this, SLOT(changeTeamStatus(HWTeam)));
@@ -27,7 +27,9 @@
list<HWTeam>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team);
list<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
- if(itDontPlay==curDontPlayingTeams.end()) {
+ bool willBePlaying=itDontPlay!=curDontPlayingTeams.end();
+
+ if(!willBePlaying) {
// playing team => dont playing
curDontPlayingTeams.push_back(*itPlay);
curPlayingTeams.erase(itPlay);
@@ -39,7 +41,7 @@
FrameTeams* pRemoveTeams;
FrameTeams* pAddTeams;
- if(itDontPlay==curDontPlayingTeams.end()) {
+ if(!willBePlaying) {
pRemoveTeams=framePlaying;
pAddTeams=frameDontPlaying;
} else {
@@ -47,7 +49,7 @@
pAddTeams=framePlaying;
}
- pAddTeams->addTeam(team);
+ pAddTeams->addTeam(team, willBePlaying);
pRemoveTeams->removeTeam(team);
QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
this, SLOT(changeTeamStatus(HWTeam)));
--- a/QTfrontend/teamselhelper.cpp Mon Aug 28 19:02:57 2006 +0000
+++ b/QTfrontend/teamselhelper.cpp Sun Sep 03 12:56:13 2006 +0000
@@ -1,16 +1,19 @@
#include "teamselhelper.h"
+#include "hwconsts.h"
#include <QPixmap>
#include <QPushButton>
-#include "hwconsts.h"
+#include <QPainter>
+
+#include "hedgehogerWidget.h"
void TeamLabel::teamButtonClicked()
{
emit teamActivated(text());
}
-TeamShowWidget::TeamShowWidget(HWTeam team, QWidget * parent) :
- QWidget(parent), mainLayout(this), m_team(team)
+TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) :
+ QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying)
{
this->setMaximumHeight(40);
QPixmap* px=new QPixmap(QPixmap(datadir->absolutePath() + "/Forts/" + m_team.Fort + "L.png").scaled(40, 40));
@@ -29,6 +32,11 @@
bText->setFlat(true);
mainLayout.addWidget(bText);
+ if(m_isPlaying) {
+ CHedgehogerWidget* phhoger=new CHedgehogerWidget(this);
+ mainLayout.addWidget(phhoger);
+ }
+
QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam()));
QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam()));
}
--- a/QTfrontend/teamselhelper.h Mon Aug 28 19:02:57 2006 +0000
+++ b/QTfrontend/teamselhelper.h Sun Sep 03 12:56:13 2006 +0000
@@ -30,11 +30,13 @@
void activateTeam();
public:
- TeamShowWidget(HWTeam team, QWidget * parent = 0);
+ TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent = 0);
+ void setPlaying(bool isPlaying);
private:
QHBoxLayout mainLayout;
HWTeam m_team;
+ bool m_isPlaying;
signals:
void teamStatusChanged(HWTeam team);