Frontend:
authorsmaxx
Sat, 18 Sep 2010 12:35:58 +0200
changeset 3876 3dd031a8b395
parent 3875 7d7c16ed5056
child 3877 bd1662bc6ed1
Frontend: * Changed team color handling to use red as first color and make it easier to add more colors in the future
QTfrontend/frameTeam.cpp
QTfrontend/game.cpp
QTfrontend/hwconsts.cpp.in
QTfrontend/hwconsts.h
--- a/QTfrontend/frameTeam.cpp	Sat Sep 18 01:50:29 2010 +0200
+++ b/QTfrontend/frameTeam.cpp	Sat Sep 18 12:35:58 2010 +0200
@@ -35,12 +35,9 @@
     mainLayout.setSpacing(1);
     mainLayout.setContentsMargins(4, 4, 4, 4);
 
-    availableColors.push_back(*color1);
-    availableColors.push_back(*color2);
-    availableColors.push_back(*color3);
-    availableColors.push_back(*color4);
-    availableColors.push_back(*color5);
-    availableColors.push_back(*color6);
+    int i = 0;
+    while(colors[i])
+        availableColors.push_back(*colors[i++]);
 
     resetColors();
 }
@@ -57,7 +54,7 @@
 
 void FrameTeams::resetColors()
 {
-  currentColor=availableColors.begin();
+  currentColor=availableColors.end() - 1; // ensure next color is the first one
 }
 
 QColor FrameTeams::getNextColor() const
--- a/QTfrontend/game.cpp	Sat Sep 18 01:50:29 2010 +0200
+++ b/QTfrontend/game.cpp	Sat Sep 18 12:35:58 2010 +0200
@@ -115,7 +115,7 @@
     HWTeam * team1;
     team1 = new HWTeam;
     team1->difficulty = 0;
-    team1->teamColor = *color1;
+    team1->teamColor = *colors[0];
     team1->numHedgehogs = 4;
     namegen.TeamRandomNames(team1,TRUE);
     HWProto::addStringListToBuffer(teamscfg,
@@ -124,7 +124,7 @@
     HWTeam * team2;
     team2 = new HWTeam;
     team2->difficulty = 4;
-    team2->teamColor = *color2;
+    team2->teamColor = *colors[1];
     team2->numHedgehogs = 4;
 	do
         namegen.TeamRandomNames(team2,TRUE);
--- a/QTfrontend/hwconsts.cpp.in	Sat Sep 18 01:50:29 2010 +0200
+++ b/QTfrontend/hwconsts.cpp.in	Sat Sep 18 12:35:58 2010 +0200
@@ -70,12 +70,17 @@
 		"111111111111111111111111111111111111111111110111"))
 	;
 
-QColor * color1 = new QColor(221,   0,   0);
-QColor * color2 = new QColor( 67, 118, 233);
-QColor * color3 = new QColor( 62, 147,  33);
-QColor * color4 = new QColor(162,  61, 187);
-QColor * color5 = new QColor(255, 147,  41);
-QColor * color6 = new QColor(115, 115, 115);
+QColor *colors[] = {
+                    new QColor(221,   0,   0), // classic red
+                    new QColor( 67, 118, 233), // classic blue
+                    new QColor( 62, 147,  33), // classic green
+                    new QColor(162,  61, 187), // classic purple
+                    new QColor(255, 147,  41), // classic orange
+                    new QColor(115, 115, 115), // classic gray
+                    new QColor(187, 162,  61), // gold
+                    new QColor( 61, 162, 187), // cyan
+                    // add new colors here
+                    0};
 
 QString * netHost = new QString();
 quint16 netPort = 46631;
--- a/QTfrontend/hwconsts.h	Sat Sep 18 01:50:29 2010 +0200
+++ b/QTfrontend/hwconsts.h	Sat Sep 18 12:35:58 2010 +0200
@@ -40,12 +40,7 @@
 extern int cAmmoNumber;
 extern QList< QPair<QString, QString> > cDefaultAmmos;
 
-extern QColor * color1;
-extern QColor * color2;
-extern QColor * color3;
-extern QColor * color4;
-extern QColor * color5;
-extern QColor * color6;
+extern QColor *colors[];
 
 extern QString * netHost;
 extern quint16 netPort;