colors changing config fully working (still need disabling in slaves)
authordisplacer
Sat, 03 Feb 2007 21:40:50 +0000
changeset 382 e7220e48ead1
parent 381 6096d74c37da
child 383 09a8795105a4
colors changing config fully working (still need disabling in slaves)
QTfrontend/frameTeam.cpp
QTfrontend/frameTeam.h
QTfrontend/netserver.cpp
QTfrontend/newnetclient.cpp
QTfrontend/teamselect.cpp
QTfrontend/teamselect.h
--- a/QTfrontend/frameTeam.cpp	Sat Feb 03 12:42:38 2007 +0000
+++ b/QTfrontend/frameTeam.cpp	Sat Feb 03 21:40:50 2007 +0000
@@ -54,6 +54,14 @@
   currentColor=availableColors.begin();
 }
 
+QColor FrameTeams::getNextColor() const
+{
+  QList<QColor>::ConstIterator nextColor=currentColor;
+  ++nextColor;
+  if (nextColor==availableColors.end()) nextColor=availableColors.begin();
+  return *nextColor;
+}
+
 void FrameTeams::addTeam(HWTeam team, bool willPlay)
 {
   TeamShowWidget* pTeamShowWidget = new TeamShowWidget(team, willPlay, this);
--- a/QTfrontend/frameTeam.h	Sat Feb 03 12:42:38 2007 +0000
+++ b/QTfrontend/frameTeam.h	Sat Feb 03 21:40:50 2007 +0000
@@ -41,6 +41,7 @@
   void setHHNum(const HWTeam& team);
   void setTeamColor(const HWTeam& team);
   void setNonInteractive();
+  QColor getNextColor() const;
 
  signals:
   void teamColorChanged(const HWTeam&);
--- a/QTfrontend/netserver.cpp	Sat Feb 03 12:42:38 2007 +0000
+++ b/QTfrontend/netserver.cpp	Sat Feb 03 21:40:50 2007 +0000
@@ -239,13 +239,22 @@
   }
 
   if(lst[0]=="ADDTEAM:") {
-    if(lst.size()<10) return;
+    if(lst.size()<11) return;
     lst.pop_front();
+    
     // add team ID
     static unsigned int netTeamID=1;
     lst.insert(1, QString::number(netTeamID++));
 
+    // creating color config for new team
+    QString colorCfg=QString("CONFIG_PARAM%1TEAM_COLOR%1%2%1%3%1%4").arg(delimeter).arg(lst[0])\
+      .arg(netTeamID)\
+      .arg(lst.takeAt(2));
+    qDebug() << "color config:" << colorCfg;
+
+    m_gameCfg[colorCfg.split(delimeter)[1]]=colorCfg.split(delimeter).mid(2);
     m_teamsCfg.push_back(lst);
+
     m_hwserver->sendOthers(this, QString("ADDTEAM:")+delimeter+lst.join(QString(delimeter)));
     RawSendNet(QString("TEAM_ACCEPTED%1%2%1%3").arg(delimeter).arg(lst[0]).arg(lst[1]));
     return;
--- a/QTfrontend/newnetclient.cpp	Sat Feb 03 12:42:38 2007 +0000
+++ b/QTfrontend/newnetclient.cpp	Sat Feb 03 21:40:50 2007 +0000
@@ -61,7 +61,9 @@
 void HWNewNet::AddTeam(const HWTeam & team)
 {
   RawSendNet(QString("ADDTEAM:") + delimeter +
-	     team.TeamName + delimeter + team.HHName[0] + delimeter + team.HHName[1] + delimeter +
+	     team.TeamName + delimeter +
+	     team.teamColor.name() + delimeter +
+	     team.HHName[0] + delimeter + team.HHName[1] + delimeter +
 	     team.HHName[2] + delimeter + team.HHName[3] + delimeter + team.HHName[4] + delimeter +
 	     team.HHName[5] + delimeter + team.HHName[6] + delimeter + team.HHName[7]);
 }
--- a/QTfrontend/teamselect.cpp	Sat Feb 03 12:42:38 2007 +0000
+++ b/QTfrontend/teamselect.cpp	Sat Feb 03 21:40:50 2007 +0000
@@ -224,6 +224,7 @@
 
 void TeamSelWidget::pre_changeTeamStatus(HWTeam team)
 {
+  team.teamColor=framePlaying->getNextColor();
   emit acceptRequested(team);
 }
 
--- a/QTfrontend/teamselect.h	Sat Feb 03 12:42:38 2007 +0000
+++ b/QTfrontend/teamselect.h	Sat Feb 03 21:40:50 2007 +0000
@@ -21,6 +21,7 @@
 
 #include <QGroupBox>
 #include <QVBoxLayout>
+#include <QColor>
 
 #include <list>
 #include <map>