New signals and slot for GameCFGWidget
authorunc0rr
Sun, 14 Jan 2007 11:58:08 +0000
changeset 325 17c860483407
parent 324 f4c109c82a0c
child 326 c6718bfdd642
New signals and slot for GameCFGWidget
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
QTfrontend/mapContainer.cpp
QTfrontend/mapContainer.h
--- a/QTfrontend/gamecfgwidget.cpp	Sat Jan 13 22:32:08 2007 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Sun Jan 14 11:58:08 2007 +0000
@@ -67,6 +67,14 @@
 	GBoxOptionsLayout->addWidget(SB_InitHealth, 2, 1);
 
 	mainLayout.addWidget(new QWidget, 100);
+
+	connect(SB_InitHealth, SIGNAL(valueChanged(int i)), this, SLOT(onInitHealthChanged(int)));
+	connect(SB_TurnTime, SIGNAL(valueChanged(int i)), this, SLOT(onTurnTimeChanged(int time)));
+	connect(CB_mode_Forts, SIGNAL(toggled(bool)), this, SLOT(onFortsModeChanged(bool)));
+
+	connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(onSeedChanged(const QString &)));
+	connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(onThemeChanged(const QString &)));
+	connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(onMapChanged(const QString &)));
 }
 
 quint32 GameCFGWidget::getGameFlags() const
@@ -130,17 +138,47 @@
 	pMapContainer->setTheme(theme);
 }
 
-void GameCFGWidget::setInitHealth(const quint32 health)
+void GameCFGWidget::setInitHealth(quint32 health)
 {
 	SB_InitHealth->setValue(health);
 }
 
-void GameCFGWidget::setTurnTime(const quint32 time)
+void GameCFGWidget::setTurnTime(quint32 time)
 {
 	SB_TurnTime->setValue(time);
 }
 
-void GameCFGWidget::setFortsMode(const bool value)
+void GameCFGWidget::setFortsMode(bool value)
 {
 	CB_mode_Forts->setChecked(value);
 }
+
+void GameCFGWidget::onInitHealthChanged(int health)
+{
+	emit initHealthChanged(health);
+}
+
+void GameCFGWidget::onTurnTimeChanged(int time)
+{
+	emit turnTimeChanged(time);
+}
+
+void GameCFGWidget::onFortsModeChanged(bool value)
+{
+	emit fortsModeChanged(value);
+}
+
+void GameCFGWidget::onSeedChanged(const QString & seed)
+{
+	emit seedChanged(seed);
+}
+
+void GameCFGWidget::onMapChanged(const QString & map)
+{
+	emit mapChanged(map);
+}
+
+void GameCFGWidget::onThemeChanged(const QString & theme)
+{
+	emit themeChanged(theme);
+}
--- a/QTfrontend/gamecfgwidget.h	Sat Jan 13 22:32:08 2007 +0000
+++ b/QTfrontend/gamecfgwidget.h	Sun Jan 14 11:58:08 2007 +0000
@@ -47,9 +47,17 @@
 	void setSeed(const QString & seed);
 	void setMap(const QString & map);
 	void setTheme(const QString & theme);
-	void setInitHealth(const quint32 health);
-	void setTurnTime(const quint32 time);
-	void setFortsMode(const bool value);
+	void setInitHealth(quint32 health);
+	void setTurnTime(quint32 time);
+	void setFortsMode(bool value);
+
+signals:
+	void seedChanged(const QString & seed);
+	void mapChanged(const QString & map);
+	void themeChanged(const QString & theme);
+	void initHealthChanged(quint32 health);
+	void turnTimeChanged(quint32 time);
+	void fortsModeChanged(bool value);
 
 private:
 	QCheckBox * CB_mode_Forts;
@@ -59,6 +67,15 @@
 	QSpinBox * SB_InitHealth;
 	QLabel * L_TurnTime;
 	QLabel * L_InitHealth;
+
+private slots:
+	void onSeedChanged(const QString & seed);
+	void onMapChanged(const QString & map);
+	void onThemeChanged(const QString & theme);
+	void onInitHealthChanged(int health);
+	void onTurnTimeChanged(int time);
+	void onFortsModeChanged(bool value);
+
 };
 
 #endif // GAMECONFIGWIDGET_H
--- a/QTfrontend/mapContainer.cpp	Sat Jan 13 22:32:08 2007 +0000
+++ b/QTfrontend/mapContainer.cpp	Sun Jan 14 11:58:08 2007 +0000
@@ -94,14 +94,17 @@
     input >> theme;
     mapCfgFile.close();
   }
+  emit mapChanged(chooseMap->currentText());
 }
 
 void HWMapContainer::changeImage()
 {
   pMap = new HWMap();
   connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
+  emit seedChanged(m_seed);
   pMap->getImage(m_seed.toStdString());
   theme = (Themes->size() > 0) ? Themes->at(rand() % Themes->size()) : "steel";
+  emit themeChanged(theme);
 }
 
 QString HWMapContainer::getCurrentSeed() const
--- a/QTfrontend/mapContainer.h	Sat Jan 13 22:32:08 2007 +0000
+++ b/QTfrontend/mapContainer.h	Sun Jan 14 11:58:08 2007 +0000
@@ -47,6 +47,12 @@
   void setMap(const QString & map);
   void setTheme(const QString & theme);
 
+ signals:
+  void seedChanged(const QString & seed);
+  void mapChanged(const QString & map);
+  void themeChanged(const QString & theme);
+
+
  private slots:
   void setImage(const QImage newImage);
   void mapChanged(int index);