coosing colors added
authordisplacer
Fri, 27 Oct 2006 19:37:59 +0000
changeset 207 287077789132
parent 206 32fa6282efe2
child 208 a049157d673a
coosing colors added
QTfrontend/frameTeam.cpp
QTfrontend/frameTeam.h
QTfrontend/hedgehogerWidget.cpp
QTfrontend/hedgehogerWidget.h
QTfrontend/hwform.cpp
QTfrontend/team.h
QTfrontend/teamselect.cpp
QTfrontend/teamselect.h
QTfrontend/teamselhelper.cpp
QTfrontend/teamselhelper.h
--- a/QTfrontend/frameTeam.cpp	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/frameTeam.cpp	Fri Oct 27 19:37:59 2006 +0000
@@ -28,6 +28,20 @@
   QWidget(parent), maxHedgehogsPerGame(18), overallHedgehogs(0), mainLayout(this)
 {
   mainLayout.setSpacing(1);
+
+  availableColors.push_back(QColor(0, 0, 255));
+  availableColors.push_back(QColor(0, 255, 0));
+  availableColors.push_back(QColor(0, 255, 255));
+  availableColors.push_back(QColor(255, 0, 0));
+  availableColors.push_back(QColor(255, 0, 255));
+  availableColors.push_back(QColor(255, 255, 0));
+
+  resetColors();
+}
+
+void FrameTeams::resetColors()
+{
+  currentColor=availableColors.begin();
 }
 
 void FrameTeams::addTeam(HWTeam team, bool willPlay)
--- a/QTfrontend/frameTeam.h	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/frameTeam.h	Fri Oct 27 19:37:59 2006 +0000
@@ -20,6 +20,8 @@
 #define _FRAME_TEAM_INCLUDED
 
 #include <QWidget>
+#include <QList>
+#include <QColor>
 
 #include "teamselect.h"
 #include <map>
@@ -29,11 +31,13 @@
   Q_OBJECT
 
  friend class CHedgehogerWidget;
+ friend class TeamShowWidget;
 
  public:
   FrameTeams(QWidget* parent=0);
   QWidget* getTeamWidget(HWTeam team);
   bool isFullTeams() const;
+  void resetColors();
 
  public slots:
   void addTeam(HWTeam team, bool willPlay);
@@ -42,6 +46,9 @@
  private:
   const int maxHedgehogsPerGame;
   int overallHedgehogs;
+  QList<QColor> availableColors;
+  QList<QColor>::Iterator currentColor;
+    
   QVBoxLayout mainLayout;
   typedef map<HWTeam, QWidget*> tmapTeamToWidget;
   tmapTeamToWidget teamToWidget;
--- a/QTfrontend/hedgehogerWidget.cpp	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp	Fri Oct 27 19:37:59 2006 +0000
@@ -73,7 +73,7 @@
   }
 }
 
-unsigned char CHedgehogerWidget::getHedgehogsNum()
+unsigned char CHedgehogerWidget::getHedgehogsNum() const
 {
   return numHedgehogs;
 }
--- a/QTfrontend/hedgehogerWidget.h	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.h	Fri Oct 27 19:37:59 2006 +0000
@@ -30,7 +30,7 @@
  public:
   CHedgehogerWidget(QWidget * parent);
   ~CHedgehogerWidget();
-  unsigned char getHedgehogsNum();
+  unsigned char getHedgehogsNum() const;
 
  protected:
   virtual void paintEvent(QPaintEvent* event);
--- a/QTfrontend/hwform.cpp	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/hwform.cpp	Fri Oct 27 19:37:59 2006 +0000
@@ -253,7 +253,8 @@
 	game = new HWGame(config, ui.pageMultiplayer->gameCFG);
 	list<HWTeam> teamslist=ui.pageMultiplayer->teamsSelect->getPlayingTeams();
 	for (list<HWTeam>::const_iterator it = teamslist.begin(); it != teamslist.end(); ++it ) {
-	  game->AddTeam(it->TeamName, ui.pageMultiplayer->teamsSelect->numHedgedogs(it->TeamName));
+	  HWTeamTempParams params=ui.pageMultiplayer->teamsSelect->getTeamParams(it->TeamName);
+	  game->AddTeam(it->TeamName, params.numHedgehogs);
 	}
 	game->StartLocal();
 }
--- a/QTfrontend/team.h	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/team.h	Fri Oct 27 19:37:59 2006 +0000
@@ -19,6 +19,7 @@
 #ifndef TEAM_H
 #define TEAM_H
 
+#include <QColor>
 #include <QString>
 #include "binds.h"
 
@@ -47,4 +48,11 @@
 		bool operator<(const HWTeam& t1) const;
 };
 
+class HWTeamTempParams
+{
+ public:
+  unsigned char numHedgehogs;
+  QColor teamColor;
+};
+
 #endif
--- a/QTfrontend/teamselect.cpp	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/teamselect.cpp	Fri Oct 27 19:37:59 2006 +0000
@@ -20,7 +20,6 @@
 #include <QPixmap>
 #include <QPushButton>
 #include <QFrame>
-#include <QDebug>
 
 #include <vertScrollArea.h>
 #include "teamselect.h"
@@ -104,6 +103,7 @@
   for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) {
     framePlaying->removeTeam(*it);
   }
+  framePlaying->resetColors();
   curPlayingTeams.clear();
   for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) {
     frameDontPlaying->removeTeam(*it);
@@ -125,9 +125,9 @@
   return curPlayingTeams;
 }
 
-unsigned char TeamSelWidget::numHedgedogs(HWTeam team) const
+HWTeamTempParams TeamSelWidget::getTeamParams(HWTeam team) const
 {
   const TeamShowWidget* tsw=dynamic_cast<TeamShowWidget*>(framePlaying->getTeamWidget(team));
-  if(!tsw) return 0;
-  return tsw->getHedgehogsNum();
+  if(!tsw) throw;
+  return tsw->getTeamParams();
 }
--- a/QTfrontend/teamselect.h	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/teamselect.h	Fri Oct 27 19:37:59 2006 +0000
@@ -43,7 +43,7 @@
   //void removeTeam(HWTeam team);
   void resetPlayingTeams(const QStringList& teamslist);
   bool isPlaying(HWTeam team) const;
-  unsigned char numHedgedogs(HWTeam team) const;
+  HWTeamTempParams getTeamParams(HWTeam team) const;
   list<HWTeam> getPlayingTeams() const;
 
 private slots:
--- a/QTfrontend/teamselhelper.cpp	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/teamselhelper.cpp	Fri Oct 27 19:37:59 2006 +0000
@@ -20,16 +20,17 @@
 #include "hwconsts.h"
 
 #include <QPixmap>
-#include <QPushButton>
 #include <QPainter>
 
+#include "frameTeam.h"
+
 void TeamLabel::teamButtonClicked()
 {
   emit teamActivated(text());
 }
 
 TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) :
-  QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0)
+  QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), colorButt(0)
 {
   mainLayout.setSpacing(1);
   mainLayout.setMargin(2);
@@ -39,6 +40,7 @@
   QPalette newPalette = palette();
   newPalette.setColor(QPalette::Button, palette().color(backgroundRole()));
 
+  // team fort
   QPushButton* butt=new QPushButton(*px, "", this);
   butt->setFlat(true);
   butt->setGeometry(0, 0, 30, 30);
@@ -47,12 +49,22 @@
   mainLayout.addWidget(butt);
   butt->setIconSize(butt->size());
 
+  // team name
   QPushButton* bText=new QPushButton(team.TeamName, this);
   bText->setPalette(newPalette);
   bText->setFlat(true);
   mainLayout.addWidget(bText);
 
   if(m_isPlaying) {
+    // team color
+    colorButt=new QPushButton(this);
+    colorButt->setMaximumWidth(30);
+    colorButt->setGeometry(0, 0, 30, 30);
+    changeTeamColor();
+    connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor()));
+    mainLayout.addWidget(colorButt);
+
+    // hedgehogs num
     phhoger=new CHedgehogerWidget(this);
     mainLayout.addWidget(phhoger);
   }
@@ -66,7 +78,23 @@
   emit teamStatusChanged(m_team);
 }
 
-unsigned char TeamShowWidget::getHedgehogsNum() const
+HWTeamTempParams TeamShowWidget::getTeamParams() const
 {
-  return phhoger ? phhoger->getHedgehogsNum() : 0;
+  if(!phhoger) throw;
+  HWTeamTempParams params;
+  params.numHedgehogs=phhoger->getHedgehogsNum();
+  params.teamColor=colorButt->palette().color(QPalette::Button);
+  return params;
 }
+
+void TeamShowWidget::changeTeamColor()
+{
+  FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget());
+  if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) {
+    pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin();
+  }
+  
+  QPalette newPalette = palette();
+  newPalette.setColor(QPalette::Button, QColor(*pOurFrameTeams->currentColor));
+  colorButt->setPalette(newPalette);
+}
--- a/QTfrontend/teamselhelper.h	Fri Oct 27 14:30:36 2006 +0000
+++ b/QTfrontend/teamselhelper.h	Fri Oct 27 19:37:59 2006 +0000
@@ -22,6 +22,7 @@
 #include <QLabel>
 #include <QWidget>
 #include <QString>
+#include <QPushButton>
 
 #include "teamselect.h"
 #include "hedgehogerWidget.h"
@@ -47,11 +48,12 @@
 
  private slots:
  void activateTeam();
+ void changeTeamColor();
 
  public:
  TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent);
  void setPlaying(bool isPlaying);
- unsigned char getHedgehogsNum() const;
+ HWTeamTempParams getTeamParams() const;
  
  private:
  TeamShowWidget();
@@ -59,6 +61,7 @@
  HWTeam m_team;
  bool m_isPlaying;
  CHedgehogerWidget* phhoger;
+ QPushButton* colorButt;
 
  signals:
  void teamStatusChanged(HWTeam team);