Basic concept for net server options page (subject to change)
authorunc0rr
Thu, 13 Dec 2007 23:07:16 +0000
changeset 657 b34fc518a48a
parent 656 6d6d9d7b1054
child 658 a7e625f5d9d0
Basic concept for net server options page (subject to change)
QTfrontend/gameuiconfig.cpp
QTfrontend/hwform.cpp
QTfrontend/input_ip.cpp
QTfrontend/pages.cpp
QTfrontend/pages.h
--- a/QTfrontend/gameuiconfig.cpp	Thu Dec 13 22:46:36 2007 +0000
+++ b/QTfrontend/gameuiconfig.cpp	Thu Dec 13 23:07:16 2007 +0000
@@ -44,6 +44,9 @@
 	netHost = new QString(value("net/ip", "").toString());
 	netPort = value("net/port", 46631).toUInt();
 
+	Form->ui.pageNetServer->leServerDescr->setText(value("net/servername", "hedgewars server").toString());
+	Form->ui.pageNetServer->sbPort->setValue(value("net/serverport", 46631).toUInt());
+
 	Form->ui.pageOptions->CBShowFPS->setChecked(value("fps/show", false).toBool());
 	Form->ui.pageOptions->fpsedit->setValue(value("fps/interval", 27).toUInt());
 
@@ -76,6 +79,8 @@
 	setValue("net/nick", Form->ui.pageOptions->editNetNick->text());
 	setValue("net/ip", *netHost);
 	setValue("net/port", netPort);
+	setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text());
+	setValue("net/serverport", Form->ui.pageNetServer->sbPort->value());
 
 	setValue("fps/show", isShowFPSEnabled());
 	setValue("fps/interval", Form->ui.pageOptions->fpsedit->value());
--- a/QTfrontend/hwform.cpp	Thu Dec 13 22:46:36 2007 +0000
+++ b/QTfrontend/hwform.cpp	Thu Dec 13 23:07:16 2007 +0000
@@ -426,6 +426,7 @@
 
 void HWForm::NetStartServer()
 {
+  config->SaveOptions();
   pnetserver = new HWNetServer;
   pnetserver->StartServer();
   _NetConnect("localhost", pnetserver->getRunningPort(), ui.pageOptions->editNetNick->text());
--- a/QTfrontend/input_ip.cpp	Thu Dec 13 22:46:36 2007 +0000
+++ b/QTfrontend/input_ip.cpp	Thu Dec 13 23:07:16 2007 +0000
@@ -29,11 +29,11 @@
 	QGridLayout * layout = new QGridLayout(this);
 
 	QLabel * lbHost = new QLabel(this);
-	lbHost->setText(tr("Host:"));
+	lbHost->setText(QLabel::tr("Host:"));
 	layout->addWidget(lbHost, 0, 0);
 
 	QLabel * lbPort = new QLabel(this);
-	lbPort->setText(tr("Port:"));
+	lbPort->setText(QLabel::tr("Port:"));
 	layout->addWidget(lbPort, 1, 0);
 
 	leHost = new QLineEdit(this);
@@ -45,16 +45,16 @@
 	layout->addWidget(sbPort, 1, 1, 1, 2);
 
 	pbDefault = new QPushButton(this);
-	pbDefault->setText(tr("default"));
+	pbDefault->setText(QPushButton::tr("default"));
 	layout->addWidget(pbDefault, 1, 3);
 
 	pbOK = new QPushButton(this);
-	pbOK->setText(tr("OK"));
+	pbOK->setText(QPushButton::tr("OK"));
 	pbOK->setDefault(true);
 	layout->addWidget(pbOK, 3, 1);
 
 	pbCancel = new QPushButton(this);
-	pbCancel->setText(tr("Cancel"));
+	pbCancel->setText(QPushButton::tr("Cancel"));
 	layout->addWidget(pbCancel, 3, 2);
 
 	connect(pbOK, SIGNAL(clicked()), this, SLOT(accept()));
--- a/QTfrontend/pages.cpp	Thu Dec 13 22:46:36 2007 +0000
+++ b/QTfrontend/pages.cpp	Thu Dec 13 23:07:16 2007 +0000
@@ -514,15 +514,47 @@
 	pageLayout->setColumnStretch(1, 1);
 	pageLayout->setColumnStretch(2, 1);
 
+	pageLayout->setRowStretch(0, 0);
+	pageLayout->setRowStretch(1, 0);
+	pageLayout->setRowStretch(2, 1);
+	pageLayout->setRowStretch(3, 0);
+
 	BtnBack = new QPushButton(this);
 	BtnBack->setFont(*font14);
 	BtnBack->setText(QPushButton::tr("Back"));
-	pageLayout->addWidget(BtnBack, 2, 0);
+	pageLayout->addWidget(BtnBack, 3, 0);
 
 	BtnStart = new QPushButton(this);
 	BtnStart->setFont(*font14);
 	BtnStart->setText(QPushButton::tr("Start"));
-	pageLayout->addWidget(BtnStart, 2, 2);
+	pageLayout->addWidget(BtnStart, 3, 2);
+
+	labelSD = new QLabel(this);
+	labelSD->setText(QLabel::tr("Server name:"));
+	pageLayout->addWidget(labelSD, 0, 0);
+
+	leServerDescr = new QLineEdit(this);
+	pageLayout->addWidget(leServerDescr, 0, 1);
+
+	labelPort = new QLabel(this);
+	labelPort->setText(QLabel::tr("Server port:"));
+	pageLayout->addWidget(labelPort, 1, 0);
+
+	sbPort = new QSpinBox(this);
+	sbPort->setMinimum(0);
+	sbPort->setMaximum(65535);
+	pageLayout->addWidget(sbPort, 1, 1);
+
+	BtnDefault = new QPushButton(this);
+	BtnDefault->setText(QPushButton::tr("default"));
+	pageLayout->addWidget(BtnDefault, 1, 2);
+
+	connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort()));
+}
+
+void PageNetServer::setDefaultPort()
+{
+	sbPort->setValue(46631);
 }
 
 PageNetGame::PageNetGame(QWidget* parent) : QWidget(parent)
--- a/QTfrontend/pages.h	Thu Dec 13 22:46:36 2007 +0000
+++ b/QTfrontend/pages.h	Thu Dec 13 23:07:16 2007 +0000
@@ -191,6 +191,14 @@
 
 	QPushButton *BtnBack;
 	QPushButton *BtnStart;
+	QPushButton *BtnDefault;
+	QLabel *labelSD;
+	QLineEdit *leServerDescr;
+	QLabel *labelPort;
+	QSpinBox *sbPort;
+
+private slots:
+	void setDefaultPort();
 };
 
 class PageNetGame : public QWidget