hedgehogs num modification now allowed to chief client only
authordisplacer
Wed, 24 Jan 2007 20:00:03 +0000
changeset 362 b28e0dd48269
parent 361 c3eebac100c0
child 363 c0d788307314
hedgehogs num modification now allowed to chief client only
QTfrontend/frameTeam.cpp
QTfrontend/frameTeam.h
QTfrontend/hedgehogerWidget.cpp
QTfrontend/hedgehogerWidget.h
QTfrontend/newnetclient.cpp
QTfrontend/teamselect.cpp
QTfrontend/teamselect.h
QTfrontend/teamselhelper.cpp
QTfrontend/teamselhelper.h
--- a/QTfrontend/frameTeam.cpp	Tue Jan 23 22:48:08 2007 +0000
+++ b/QTfrontend/frameTeam.cpp	Wed Jan 24 20:00:03 2007 +0000
@@ -25,7 +25,7 @@
 using namespace std;
 
 FrameTeams::FrameTeams(QWidget* parent) :
-  QWidget(parent), maxHedgehogsPerGame(18), overallHedgehogs(0), mainLayout(this)
+  QWidget(parent), maxHedgehogsPerGame(18), overallHedgehogs(0), mainLayout(this), nonInteractive(false)
 {
   mainLayout.setSpacing(1);
 
@@ -39,6 +39,16 @@
   resetColors();
 }
 
+void FrameTeams::setNonInteractive()
+{
+  nonInteractive=true;
+  for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ++it) {
+    TeamShowWidget* pts=dynamic_cast<TeamShowWidget*>(it.value());
+    if(!pts) throw;
+    pts->setNonInteractive();
+  }
+}
+
 void FrameTeams::resetColors()
 {
   currentColor=availableColors.begin();
@@ -47,6 +57,7 @@
 void FrameTeams::addTeam(HWTeam team, bool willPlay)
 {
   TeamShowWidget* pTeamShowWidget = new TeamShowWidget(team, willPlay, this);
+  if(nonInteractive) pTeamShowWidget->setNonInteractive();
 //  int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height();
   teamToWidget.insert(team, pTeamShowWidget);
   mainLayout.addWidget(pTeamShowWidget);
--- a/QTfrontend/frameTeam.h	Tue Jan 23 22:48:08 2007 +0000
+++ b/QTfrontend/frameTeam.h	Wed Jan 24 20:00:03 2007 +0000
@@ -39,6 +39,7 @@
   bool isFullTeams() const;
   void resetColors();
   void setHHNum(const HWTeam& team);
+  void setNonInteractive();
 
  public slots:
   void addTeam(HWTeam team, bool willPlay);
@@ -53,6 +54,7 @@
   QVBoxLayout mainLayout;
   typedef QMultiMap<HWTeam, QWidget*> tmapTeamToWidget;
   tmapTeamToWidget teamToWidget;
+  bool nonInteractive;
 };
 
 #endif // _FRAME_TAM_INCLUDED
--- a/QTfrontend/hedgehogerWidget.cpp	Tue Jan 23 22:48:08 2007 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp	Wed Jan 24 20:00:03 2007 +0000
@@ -24,7 +24,7 @@
 #include "frameTeam.h"
 
 CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
-  QWidget(parent)
+  QWidget(parent), nonInteractive(false)
 {
   if(parent) {
     pOurFrameTeams=dynamic_cast<FrameTeams*>(parent->parentWidget());
@@ -40,8 +40,14 @@
   pOurFrameTeams->overallHedgehogs-=numHedgehogs;
 }
 
+void CHedgehogerWidget::setNonInteractive()
+{
+  nonInteractive=true;
+}
+
 void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
 {
+  if(nonInteractive) return;
   if(event->button()==Qt::LeftButton) {
     event->accept();
     if(numHedgehogs < 8 && pOurFrameTeams->overallHedgehogs<18) {
--- a/QTfrontend/hedgehogerWidget.h	Tue Jan 23 22:48:08 2007 +0000
+++ b/QTfrontend/hedgehogerWidget.h	Wed Jan 24 20:00:03 2007 +0000
@@ -32,6 +32,7 @@
   ~CHedgehogerWidget();
   unsigned char getHedgehogsNum() const;
   void setHHNum (unsigned int num);
+  void setNonInteractive();
 
  signals:
   void hedgehogsNumChanged();
@@ -44,6 +45,7 @@
   CHedgehogerWidget();
   unsigned char numHedgehogs;
   FrameTeams* pOurFrameTeams;
+  bool nonInteractive;
 };
 
 #endif // _HEDGEHOGER_WIDGET
--- a/QTfrontend/newnetclient.cpp	Tue Jan 23 22:48:08 2007 +0000
+++ b/QTfrontend/newnetclient.cpp	Wed Jan 24 20:00:03 2007 +0000
@@ -175,6 +175,7 @@
 
   if(lst[0]=="SLAVE") {
     m_pGameCFGWidget->setEnabled(false);
+    m_pTeamSelWidget->setNonInteractive();
     return;
   }
 
@@ -237,8 +238,7 @@
   	}
   	if (lst[1] == "HHNUM") {
 	  HWTeam tmptm(lst[2], lst[3].toUInt());
-	  QMap<unsigned int, QString>::iterator it=m_networkToLocalteams.find(lst[3].toUInt());
-	  if(it!=m_networkToLocalteams.end()) {
+	  if(m_networkToLocalteams.find(lst[3].toUInt())!=m_networkToLocalteams.end()) {
 	    tmptm=HWTeam(lst[2]); // local team should be changed
 	  }
 	  tmptm.numHedgehogs=lst[4].toUInt();
--- a/QTfrontend/teamselect.cpp	Tue Jan 23 22:48:08 2007 +0000
+++ b/QTfrontend/teamselect.cpp	Wed Jan 24 20:00:03 2007 +0000
@@ -43,6 +43,11 @@
   }
 }
 
+void TeamSelWidget::setNonInteractive()
+{
+  framePlaying->setNonInteractive();
+}
+
 void TeamSelWidget::hhNumChanged(const HWTeam& team)
 {
   QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
--- a/QTfrontend/teamselect.h	Tue Jan 23 22:48:08 2007 +0000
+++ b/QTfrontend/teamselect.h	Wed Jan 24 20:00:03 2007 +0000
@@ -44,6 +44,7 @@
   void resetPlayingTeams(const QList<HWTeam>& teamslist);
   bool isPlaying(HWTeam team) const;
   QList<HWTeam> getPlayingTeams() const;
+  void setNonInteractive();
 
  public slots:
   void addTeam(HWTeam team);
--- a/QTfrontend/teamselhelper.cpp	Tue Jan 23 22:48:08 2007 +0000
+++ b/QTfrontend/teamselhelper.cpp	Wed Jan 24 20:00:03 2007 +0000
@@ -31,7 +31,8 @@
 }
 
 TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) :
-  QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), colorButt(0)
+  QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), 
+  colorButt(0)
 {
   mainLayout.setSpacing(1);
   mainLayout.setMargin(2);
@@ -43,7 +44,7 @@
   newPalette.setColor(QPalette::Button, palette().color(backgroundRole()));
 
   // team fort
-  QPushButton* butt=new QPushButton(difficultyIcon, "", this);
+  butt=new QPushButton(difficultyIcon, "", this);
   butt->setFlat(true);
   butt->setGeometry(0, 0, 30, 30);
   butt->setMaximumWidth(30);
@@ -52,7 +53,7 @@
   butt->setIconSize(butt->size());
 
   // team name
-  QPushButton* bText=new QPushButton(team.TeamName, this);
+  bText=new QPushButton(team.TeamName, this);
   bText->setPalette(newPalette);
   bText->setFlat(true);
   mainLayout.addWidget(bText);
@@ -76,6 +77,15 @@
   QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam()));
 }
 
+void TeamShowWidget::setNonInteractive()
+{
+  if(m_team.isNetTeam()) {
+    disconnect(butt, SIGNAL(clicked()));
+    disconnect(bText, SIGNAL(clicked()));
+  }
+  phhoger->setNonInteractive();
+}
+
 void TeamShowWidget::setHHNum(unsigned int num)
 {
   phhoger->setHHNum(num);
--- a/QTfrontend/teamselhelper.h	Tue Jan 23 22:48:08 2007 +0000
+++ b/QTfrontend/teamselhelper.h	Wed Jan 24 20:00:03 2007 +0000
@@ -54,6 +54,7 @@
  TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent);
  void setPlaying(bool isPlaying);
  void setHHNum(unsigned int num);
+ void setNonInteractive();
 
  private:
  TeamShowWidget();
@@ -62,6 +63,8 @@
  bool m_isPlaying;
  CHedgehogerWidget* phhoger;
  QPushButton* colorButt;
+ QPushButton* butt;
+ QPushButton* bText;
 
  private slots:
   void hhNumChanged();