- Limit list of teams in game with 200 px
authorunc0rr
Mon, 08 Jan 2007 18:21:40 +0000
changeset 311 b8905423f19f
parent 310 b95fd124cb09
child 312 c36d0b34ac3d
- Limit list of teams in game with 200 px - 'New team@ button in teams selecting widget - New game options, not yet used
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/pages.cpp
QTfrontend/teamselect.cpp
QTfrontend/teamselect.h
--- a/QTfrontend/gamecfgwidget.cpp	Sun Jan 07 22:54:08 2007 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Mon Jan 08 18:21:40 2007 +0000
@@ -18,7 +18,10 @@
 
 #include <QResizeEvent>
 #include <QGroupBox>
-#include <QHBoxLayout>
+#include <QCheckBox>
+#include <QGridLayout>
+#include <QSpinBox>
+#include <QLabel>
 #include "gamecfgwidget.h"
 
 GameCFGWidget::GameCFGWidget(QWidget* parent) :
@@ -42,10 +45,26 @@
 	GBoxOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
 	mainLayout.addWidget(GBoxOptions);
 
-	QVBoxLayout *GBoxOptionsLayout = new QVBoxLayout(GBoxOptions);
+	QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions);
 	CB_mode_Forts = new QCheckBox(GBoxOptions);
 	CB_mode_Forts->setText(QCheckBox::tr("Forts mode"));
-	GBoxOptionsLayout->addWidget(CB_mode_Forts);
+	GBoxOptionsLayout->addWidget(CB_mode_Forts, 0, 0, 1, 2);
+
+	L_TurnTime = new QLabel(QLabel::tr("Turn time"), GBoxOptions);
+	L_InitHealth = new QLabel(QLabel::tr("Initial health"), GBoxOptions);
+	GBoxOptionsLayout->addWidget(L_TurnTime, 1, 0);
+	GBoxOptionsLayout->addWidget(L_InitHealth, 2, 0);
+
+	SB_TurnTime = new QSpinBox(GBoxOptions);
+	SB_TurnTime->setRange(15, 90);
+	SB_TurnTime->setValue(45);
+	SB_TurnTime->setSingleStep(15);
+	SB_InitHealth = new QSpinBox(GBoxOptions);
+	SB_InitHealth->setRange(50, 200);
+	SB_TurnTime->setValue(100);
+	SB_InitHealth->setSingleStep(25);
+	GBoxOptionsLayout->addWidget(SB_TurnTime, 1, 1);
+	GBoxOptionsLayout->addWidget(SB_InitHealth, 2, 1);
 
 	mainLayout.addWidget(new QWidget, 100);
 }
--- a/QTfrontend/gamecfgwidget.h	Sun Jan 07 22:54:08 2007 +0000
+++ b/QTfrontend/gamecfgwidget.h	Mon Jan 08 18:21:40 2007 +0000
@@ -20,11 +20,14 @@
 #define GAMECONFIGWIDGET_H
 
 #include <QWidget>
-#include <QCheckBox>
-#include <QVBoxLayout>
 
 #include "mapContainer.h"
 
+class QCheckBox;
+class QVBoxLayout;
+class QSpinBox;
+class QLabel;
+
 class GameCFGWidget : public QWidget
 {
 	Q_OBJECT
@@ -42,6 +45,10 @@
 	QCheckBox * CB_mode_Forts;
 	QVBoxLayout mainLayout;
 	HWMapContainer* pMapContainer;
+	QSpinBox * SB_TurnTime;
+	QSpinBox * SB_InitHealth;
+	QLabel * L_TurnTime;
+	QLabel * L_InitHealth;
 };
 
 #endif // GAMECONFIGWIDGET_H
--- a/QTfrontend/hwform.cpp	Sun Jan 07 22:54:08 2007 +0000
+++ b/QTfrontend/hwform.cpp	Mon Jan 08 18:21:40 2007 +0000
@@ -85,6 +85,8 @@
 
 	connect(ui.pageGameStats->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoBack()));
 
+	connect(ui.pageMultiplayer->teamsSelect, SIGNAL(NewTeam()), this, SLOT(NewTeam()));
+
 	GoToPage(ID_PAGE_MAIN);
 }
 
@@ -124,14 +126,6 @@
 
 void HWForm::GoToMultiplayer()
 {
-	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);
 	GoToPage(ID_PAGE_MULTIPLAYER);
 }
 
@@ -157,15 +151,31 @@
 	GoToPage(ID_PAGE_NETCHAT);
 }
 
+void HWForm::OnPageShown(quint8 id)
+{
+	if (id == ID_PAGE_MULTIPLAYER) {
+		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);
+	}
+}
+
 void HWForm::GoToPage(quint8 id)
 {
 	PagesStack.push(ui.Pages->currentIndex());
+	OnPageShown(id);
 	ui.Pages->setCurrentIndex(id);
 }
 
 void HWForm::GoBack()
 {
 	quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop();
+	OnPageShown(id);
 	ui.Pages->setCurrentIndex(id);
 }
 
--- a/QTfrontend/hwform.h	Sun Jan 07 22:54:08 2007 +0000
+++ b/QTfrontend/hwform.h	Mon Jan 08 18:21:40 2007 +0000
@@ -93,6 +93,7 @@
 
 	void CreateGame(GameCFGWidget * gamecfg);
 	void AddStatText(const QString & msg);
+	void OnPageShown(quint8 id);
 };
 
 #endif
--- a/QTfrontend/pages.cpp	Sun Jan 07 22:54:08 2007 +0000
+++ b/QTfrontend/pages.cpp	Mon Jan 08 18:21:40 2007 +0000
@@ -21,6 +21,7 @@
 #include <QPushButton>
 #include <QGroupBox>
 #include <QComboBox>
+#include <QCheckBox>
 #include <QLabel>
 #include <QToolBox>
 #include <QLineEdit>
--- a/QTfrontend/teamselect.cpp	Sun Jan 07 22:54:08 2007 +0000
+++ b/QTfrontend/teamselect.cpp	Mon Jan 08 18:21:40 2007 +0000
@@ -81,11 +81,13 @@
   }
 }
 
-void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color)
+void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color, int maxHeight)
 {
   VertScrArea* area=new VertScrArea(color);
   area->setWidget(pfteams);
   mainLayout.addWidget(area, 30);
+  if (maxHeight > 0)
+  	area->setMaximumHeight(maxHeight);
 }
 
 TeamSelWidget::TeamSelWidget(QWidget* parent) :
@@ -97,8 +99,12 @@
 //  addScrArea(framePlaying, QColor("DarkTurquoise"));
 //  addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
   QPalette p;
-  addScrArea(framePlaying, p.color(QPalette::Window).light(105));
-  addScrArea(frameDontPlaying, p.color(QPalette::Window).dark(105));
+  addScrArea(framePlaying, p.color(QPalette::Window).light(105), 200);
+  addScrArea(frameDontPlaying, p.color(QPalette::Window).dark(105), 0);
+  newTeam = new QPushButton(this);
+  newTeam->setText(QPushButton::tr("New team"));
+  connect(newTeam, SIGNAL(clicked()), this, SLOT(newTeamClicked()));
+  mainLayout.addWidget(newTeam);
 }
 
 void TeamSelWidget::resetPlayingTeams(const QList<HWTeam>& teamslist)
@@ -135,3 +141,8 @@
   if(!tsw) throw;
   return tsw->getTeamParams();
 }
+
+void TeamSelWidget::newTeamClicked()
+{
+	emit NewTeam();
+}
--- a/QTfrontend/teamselect.h	Sun Jan 07 22:54:08 2007 +0000
+++ b/QTfrontend/teamselect.h	Mon Jan 08 18:21:40 2007 +0000
@@ -21,7 +21,6 @@
 
 #include <QGroupBox>
 #include <QVBoxLayout>
-class QFrame;
 
 #include <list>
 #include <map>
@@ -30,6 +29,8 @@
 
 class TeamSelWidget;
 class FrameTeams;
+class QFrame;
+class QPushButton;
 
 using namespace std;
 
@@ -46,15 +47,20 @@
   HWTeamTempParams getTeamParams(HWTeam team) const;
   list<HWTeam> getPlayingTeams() const;
 
+  signals:
+    void NewTeam();
+
 private slots:
   void changeTeamStatus(HWTeam team);
+  void newTeamClicked();
 
  private:
-  void addScrArea(FrameTeams* pfteams, QColor color);
+  void addScrArea(FrameTeams* pfteams, QColor color, int maxHeight);
   FrameTeams* frameDontPlaying;
   FrameTeams* framePlaying;
 
   QVBoxLayout mainLayout;
+  QPushButton * newTeam;
 
   list<HWTeam> curPlayingTeams;
   list<HWTeam> curDontPlayingTeams;