bots power icons added
authordisplacer
Sun, 12 Nov 2006 20:15:58 +0000
changeset 231 c77b16e48273
parent 230 ff76ba0671f7
child 232 e6ae904c050a
bots power icons added
QTfrontend/hwform.cpp
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/res/botlevels/1.png
QTfrontend/res/botlevels/2.png
QTfrontend/res/botlevels/4.png
QTfrontend/res/botlevels/5.png
QTfrontend/team.cpp
QTfrontend/team.h
QTfrontend/teamselect.cpp
QTfrontend/teamselect.h
QTfrontend/teamselhelper.cpp
--- a/QTfrontend/hwform.cpp	Fri Nov 10 20:41:12 2006 +0000
+++ b/QTfrontend/hwform.cpp	Sun Nov 12 20:15:58 2006 +0000
@@ -119,7 +119,14 @@
 
 void HWForm::GoToMultiplayer()
 {
-	ui.pageMultiplayer->teamsSelect->resetPlayingTeams(config->GetTeamsList());
+	QStringList tmNames=config->GetTeamsList();
+	QList<HWTeam> teamsList;
+	for(QStringList::iterator it=tmNames.begin(); it!=tmNames.end(); it++) {
+	  HWTeam team(*it);
+	  team.LoadFromFile();
+	  teamsList.push_back(team);
+	}
+	ui.pageMultiplayer->teamsSelect->resetPlayingTeams(teamsList);
 	ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER);
 }
 
--- a/QTfrontend/pages.cpp	Fri Nov 10 20:41:12 2006 +0000
+++ b/QTfrontend/pages.cpp	Sun Nov 12 20:15:58 2006 +0000
@@ -26,6 +26,7 @@
 #include <QLineEdit>
 #include <QListWidget>
 #include <QApplication>
+#include <QSpinBox>
 
 #include "pages.h"
 #include "sdlkeys.h"
@@ -122,7 +123,17 @@
 	QGridLayout * GBTLayout = new QGridLayout(GBoxTeam);
 	TeamNameEdit = new QLineEdit(GBoxTeam);
 	TeamNameEdit->setMaxLength(15);
-	GBTLayout->addWidget(TeamNameEdit);
+	GBTLayout->addWidget(TeamNameEdit, 0, 0, 1, 0);
+
+	QLabel* difficultyLabel=new QLabel(GBoxTeam);
+	difficultyLabel->setText("difficulty:");
+	difficultyBox=new QSpinBox(GBoxTeam);
+	difficultyBox->setRange(0, 5);
+	difficultyBox->setSingleStep(1);
+	difficultyBox->setValue(0);
+	GBTLayout->addWidget(difficultyLabel, 1, 0);
+	GBTLayout->addWidget(difficultyBox, 1, 1);
+	
 	pageLayout->addWidget(GBoxTeam, 0, 0);
 
 	GBoxHedgehogs = new	QGroupBox(this);
--- a/QTfrontend/pages.h	Fri Nov 10 20:41:12 2006 +0000
+++ b/QTfrontend/pages.h	Sun Nov 12 20:15:58 2006 +0000
@@ -36,6 +36,7 @@
 class QCheckBox;
 class SquareLabel;
 class About;
+class QSpinBox;
 
 class PageMain : public QWidget
 {
@@ -88,6 +89,7 @@
 	QPushButton *BtnTeamDiscard;
 	QPushButton *BtnTeamSave;
 	QLineEdit * TeamNameEdit;
+	QSpinBox* difficultyBox;
 	QLineEdit * HHNameEdit[8];
 	QComboBox * CBBind[BINDS_NUMBER];
 
Binary file QTfrontend/res/botlevels/1.png has changed
Binary file QTfrontend/res/botlevels/2.png has changed
Binary file QTfrontend/res/botlevels/4.png has changed
Binary file QTfrontend/res/botlevels/5.png has changed
--- a/QTfrontend/team.cpp	Fri Nov 10 20:41:12 2006 +0000
+++ b/QTfrontend/team.cpp	Sun Nov 12 20:15:58 2006 +0000
@@ -19,13 +19,15 @@
 #include <QFile>
 #include <QTextStream>
 #include <QApplication>
+#include <QSpinBox>
 #include "team.h"
 #include "hwform.h"
 #include "predefteams.h"
 #include "pages.h"
 #include "hwconsts.h"
 
-HWTeam::HWTeam(const QString & teamname)
+HWTeam::HWTeam(const QString & teamname) :
+  difficulty(0)
 {
 	TeamName = teamname;
 	for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
@@ -38,7 +40,8 @@
 	}
 }
 
-HWTeam::HWTeam(quint8 num)
+HWTeam::HWTeam(quint8 num) :
+  difficulty(0)
 {
 	num %= PREDEFTEAMS_COUNT;
 	TeamName = QApplication::translate("teams", pteams[num].TeamName);
@@ -108,6 +111,12 @@
 					binds[i].strbind = str;
 					break;
 				}
+		} else 
+		if (str.startsWith("difficulty "))
+		{
+		  str.remove(0, 11);
+		  difficulty=str.toUInt();
+		  if (difficulty>5) difficulty=0; // this shouldn't normally happen
 		}
 	}
 	cfgfile.close();
@@ -130,6 +139,7 @@
 	{
 		stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
 	}
+	stream << "difficulty " << difficulty << endl;
 	cfgfile.close();
 	return true;
 }
@@ -137,6 +147,7 @@
 void HWTeam::SetToPage(HWForm * hwform)
 {
 	hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName);
+	hwform->ui.pageEditTeam->difficultyBox->setValue(difficulty);
 	for(int i = 0; i < 8; i++)
 	{
 		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
@@ -156,6 +167,7 @@
 void HWTeam::GetFromPage(HWForm * hwform)
 {
 	TeamName  = hwform->ui.pageEditTeam->TeamNameEdit->text();
+	difficulty = hwform->ui.pageEditTeam->difficultyBox->value();
 	for(int i = 0; i < 8; i++)
 	{
 		HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text();
--- a/QTfrontend/team.h	Fri Nov 10 20:41:12 2006 +0000
+++ b/QTfrontend/team.h	Sun Nov 12 20:15:58 2006 +0000
@@ -36,6 +36,7 @@
 		QString HHName[8];
 		QString	Grave;
 		QString Fort;
+		unsigned int difficulty;
 		BindAction binds[BINDS_NUMBER];
 
 		bool LoadFromFile();
--- a/QTfrontend/teamselect.cpp	Fri Nov 10 20:41:12 2006 +0000
+++ b/QTfrontend/teamselect.cpp	Sun Nov 12 20:15:58 2006 +0000
@@ -97,7 +97,7 @@
   addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
 }
 
-void TeamSelWidget::resetPlayingTeams(const QStringList& teamslist)
+void TeamSelWidget::resetPlayingTeams(const QList<HWTeam>& teamslist)
 {
   list<HWTeam>::iterator it;
   for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) {
@@ -110,7 +110,7 @@
   }
   curDontPlayingTeams.clear();
 
-  for (QStringList::ConstIterator it = teamslist.begin(); it != teamslist.end(); ++it ) {
+  for (QList<HWTeam>::ConstIterator it = teamslist.begin(); it != teamslist.end(); ++it ) {
     addTeam(*it);
   }
 }
--- a/QTfrontend/teamselect.h	Fri Nov 10 20:41:12 2006 +0000
+++ b/QTfrontend/teamselect.h	Sun Nov 12 20:15:58 2006 +0000
@@ -41,7 +41,7 @@
   TeamSelWidget(QWidget* parent=0);
   void addTeam(HWTeam team);
   //void removeTeam(HWTeam team);
-  void resetPlayingTeams(const QStringList& teamslist);
+  void resetPlayingTeams(const QList<HWTeam>& teamslist);
   bool isPlaying(HWTeam team) const;
   HWTeamTempParams getTeamParams(HWTeam team) const;
   list<HWTeam> getPlayingTeams() const;
--- a/QTfrontend/teamselhelper.cpp	Fri Nov 10 20:41:12 2006 +0000
+++ b/QTfrontend/teamselhelper.cpp	Sun Nov 12 20:15:58 2006 +0000
@@ -36,13 +36,14 @@
   mainLayout.setSpacing(1);
   mainLayout.setMargin(2);
   this->setMaximumHeight(35);
-  QPixmap* px=new QPixmap(QPixmap(datadir->absolutePath() + "/Forts/" + m_team.Fort + "L.png").scaled(40, 40));
+  //QPixmap* px=new QPixmap(QPixmap(datadir->absolutePath() + "/Forts/" + m_team.Fort + "L.png").scaled(40, 40));
+  QIcon difficultyIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty));
 
   QPalette newPalette = palette();
   newPalette.setColor(QPalette::Button, palette().color(backgroundRole()));
 
   // team fort
-  QPushButton* butt=new QPushButton(*px, "", this);
+  QPushButton* butt=new QPushButton(difficultyIcon, "", this); // *px
   butt->setFlat(true);
   butt->setGeometry(0, 0, 30, 30);
   butt->setMaximumWidth(30);