# HG changeset patch # User displacer # Date 1161977879 0 # Node ID 28707778913279f8df7515c70bae6ff7e33d0bd5 # Parent 32fa6282efe2833c78c424983464f786b931e0ba coosing colors added diff -r 32fa6282efe2 -r 287077789132 QTfrontend/frameTeam.cpp --- 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) diff -r 32fa6282efe2 -r 287077789132 QTfrontend/frameTeam.h --- 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 +#include +#include #include "teamselect.h" #include @@ -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 availableColors; + QList::Iterator currentColor; + QVBoxLayout mainLayout; typedef map tmapTeamToWidget; tmapTeamToWidget teamToWidget; diff -r 32fa6282efe2 -r 287077789132 QTfrontend/hedgehogerWidget.cpp --- 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; } diff -r 32fa6282efe2 -r 287077789132 QTfrontend/hedgehogerWidget.h --- 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); diff -r 32fa6282efe2 -r 287077789132 QTfrontend/hwform.cpp --- 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 teamslist=ui.pageMultiplayer->teamsSelect->getPlayingTeams(); for (list::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(); } diff -r 32fa6282efe2 -r 287077789132 QTfrontend/team.h --- 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 #include #include "binds.h" @@ -47,4 +48,11 @@ bool operator<(const HWTeam& t1) const; }; +class HWTeamTempParams +{ + public: + unsigned char numHedgehogs; + QColor teamColor; +}; + #endif diff -r 32fa6282efe2 -r 287077789132 QTfrontend/teamselect.cpp --- 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 #include #include -#include #include #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(framePlaying->getTeamWidget(team)); - if(!tsw) return 0; - return tsw->getHedgehogsNum(); + if(!tsw) throw; + return tsw->getTeamParams(); } diff -r 32fa6282efe2 -r 287077789132 QTfrontend/teamselect.h --- 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 getPlayingTeams() const; private slots: diff -r 32fa6282efe2 -r 287077789132 QTfrontend/teamselhelper.cpp --- 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 -#include #include +#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(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); +} diff -r 32fa6282efe2 -r 287077789132 QTfrontend/teamselhelper.h --- 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 #include #include +#include #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);