Scheme options work now
authorunc0rr
Fri, 13 Mar 2009 21:39:59 +0000
changeset 1890 de5cfe3beb22
parent 1889 b8590b604fdd
child 1891 47e832a88cbd
Scheme options work now Things left: save/load schemes, pass schemes via net, make nice-looking scheme edit page, add more options
QTfrontend/ammoSchemeModel.cpp
QTfrontend/ammoSchemeModel.h
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
QTfrontend/hwform.cpp
--- a/QTfrontend/ammoSchemeModel.cpp	Fri Mar 13 18:04:44 2009 +0000
+++ b/QTfrontend/ammoSchemeModel.cpp	Fri Mar 13 21:39:59 2009 +0000
@@ -24,15 +24,15 @@
   QAbstractTableModel(parent)
 {
 	defaultScheme
-		<< "Default" // name
-		<< "false" // fortsmode
-		<< "false" // team divide
-		<< "false" // solid land
-		<< "false" // border
-		<< "45" // turn time
-		<< "101" // init health
-		<< "15" // sudden death
-		<< "5" // case probability
+		<< QVariant(tr("Default")) // name         0
+		<< QVariant(false)         // fortsmode    1
+		<< QVariant(false)         // team divide  2
+		<< QVariant(false)         // solid land   3
+		<< QVariant(false)         // border       4
+		<< QVariant(45)            // turn time    5
+		<< QVariant(100)           // init health  6
+		<< QVariant(15)            // sudden death 7
+		<< QVariant(5)             // case prob    8
 		;
 
 	schemes.append(defaultScheme);
@@ -75,7 +75,7 @@
 		|| role != Qt::EditRole)
 		return false;
 
-	schemes[index.row()][index.column()] = value.toString();
+	schemes[index.row()][index.column()] = value;
 
 	emit dataChanged(index, index);
 	return true;
@@ -85,8 +85,8 @@
 {
 	beginInsertRows(parent, row, row);
 
-	QStringList newScheme = defaultScheme;
-	newScheme[0] = tr("new");
+	QList<QVariant> newScheme = defaultScheme;
+	newScheme[0] = QVariant(tr("new"));
 	
 	schemes.insert(row, newScheme);
 
@@ -111,5 +111,5 @@
 		)
 		return QVariant();
 
-	return QVariant::fromValue(schemes[index.row()][index.column()]);
+	return schemes[index.row()][index.column()];
 }
--- a/QTfrontend/ammoSchemeModel.h	Fri Mar 13 18:04:44 2009 +0000
+++ b/QTfrontend/ammoSchemeModel.h	Fri Mar 13 21:39:59 2009 +0000
@@ -20,7 +20,7 @@
 #define _AMMO_SCHEME_MODEL_INCLUDED
 
 #include <QAbstractTableModel>
-#include <QStringList>
+#include <QList>
 
 class AmmoSchemeModel : public QAbstractTableModel
 {
@@ -42,10 +42,10 @@
 	void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
 
 protected:
-	QList<QStringList> schemes;
+	QList< QList<QVariant> > schemes;
 
 private:
-	QStringList defaultScheme;
+	QList<QVariant> defaultScheme;
 };
 
 #endif // _AMMO_SCHEME_MODEL_INCLUDED
--- a/QTfrontend/gamecfgwidget.cpp	Fri Mar 13 18:04:44 2009 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Fri Mar 13 21:39:59 2009 +0000
@@ -46,8 +46,8 @@
 
 	QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions);
 
-	tv = new QTableView(this);
-	GBoxOptionsLayout->addWidget(tv, 0, 0, 1, 2);
+	GameSchemes = new QComboBox(GBoxOptions);
+	GBoxOptionsLayout->addWidget(GameSchemes, 0, 1);
 
 	QPushButton * goToSchemePage = new QPushButton(GBoxOptions);
 	goToSchemePage->setText(tr("Edit schemes"));
@@ -67,25 +67,30 @@
 	connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int)));
 }
 
+QVariant GameCFGWidget::schemeData(int column) const
+{
+	return GameSchemes->model()->data(GameSchemes->model()->index(GameSchemes->currentIndex(), column));
+}
+
 quint32 GameCFGWidget::getGameFlags() const
 {
 	quint32 result = 0;
 
-/*	if (CB_mode_Forts->isChecked())
+	if (schemeData(1).toBool())
 		result |= 0x01;
-	if (CB_teamsDivide->isChecked())
+	if (schemeData(2).toBool())
 		result |= 0x10;
-	if (CB_solid->isChecked())
+	if (schemeData(3).toBool())
 		result |= 0x04;
-	if (CB_border->isChecked())
-		result |= 0x08;*/
+	if (schemeData(4).toBool())
+		result |= 0x08;
 
 	return result;
 }
 
 quint32 GameCFGWidget::getInitHealth() const
 {
-//	return SB_InitHealth->value();
+	return schemeData(6).toInt();
 }
 
 QStringList GameCFGWidget::getFullConfig() const
@@ -93,9 +98,9 @@
 	QStringList sl;
 	sl.append("eseed " + pMapContainer->getCurrentSeed());
 	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
-//	sl.append(QString("e$turntime %1").arg(SB_TurnTime->value() * 1000));
-//	sl.append(QString("e$sd_turns %1").arg(SB_SuddenDeath->value()));
-//	sl.append(QString("e$casefreq %1").arg(SB_CaseProb->value()));
+	sl.append(QString("e$turntime %1").arg(schemeData(5).toInt() * 1000));
+	sl.append(QString("e$sd_turns %1").arg(schemeData(7).toInt()));
+	sl.append(QString("e$casefreq %1").arg(schemeData(8).toInt()));
 	sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
 
 	QString currentMap = pMapContainer->getCurrentMap();
--- a/QTfrontend/gamecfgwidget.h	Fri Mar 13 18:04:44 2009 +0000
+++ b/QTfrontend/gamecfgwidget.h	Fri Mar 13 21:39:59 2009 +0000
@@ -40,6 +40,7 @@
 	quint32 getGameFlags() const;
 	quint32 getInitHealth() const;
 	QStringList getFullConfig() const;
+	QComboBox * GameSchemes;
 	QComboBox * WeaponsName;
 	HWMapContainer* pMapContainer;
 	QTableView * tv;
@@ -66,6 +67,8 @@
 	QString curNetAmmo;
 
 	void setNetAmmo(const QString& name, const QString& ammo);
+
+	QVariant schemeData(int column) const;
 };
 
 #endif // GAMECONFIGWIDGET_H
--- a/QTfrontend/hwform.cpp	Fri Mar 13 18:04:44 2009 +0000
+++ b/QTfrontend/hwform.cpp	Fri Mar 13 21:39:59 2009 +0000
@@ -152,7 +152,7 @@
 
 	AmmoSchemeModel * ammoSchemeModel = new AmmoSchemeModel(this);
 	ui.pageScheme->setModel(ammoSchemeModel);
-	ui.pageMultiplayer->gameCFG->tv->setModel(ammoSchemeModel);
+	ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel);
 
 	PagesStack.push(ID_PAGE_MAIN);
 	GoBack();
@@ -580,10 +580,6 @@
 	connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)),
 		ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&)));
 
-	//connect(ui.pageNetGame->pGameCFG->pMapContainer, SIGNAL(newTemplateFilter(int)), hwnet, SLOT(onTemplateFilterChanged(int)));
-
-	//connect(hwnet, SIGNAL(templateFilterChanged(int)), ui.pageNetGame->pGameCFG->pMapContainer, SLOT(setTemplateFilter(int)));
-
 // config stuff
 	connect(hwnet, SIGNAL(paramChanged(const QString &, const QStringList &)), ui.pageNetGame->pGameCFG, SLOT(setParam(const QString &, const QStringList &)));
 	connect(ui.pageNetGame->pGameCFG, SIGNAL(paramChanged(const QString &, const QStringList &)), hwnet, SLOT(onParamChanged(const QString &, const QStringList &)));