Finish asking host/port dialog implementation
authorunc0rr
Thu, 13 Dec 2007 21:49:52 +0000
changeset 654 1019b8fa8638
parent 653 4f44fc06ca45
child 655 e58a77556878
Finish asking host/port dialog implementation
QTfrontend/gameuiconfig.cpp
QTfrontend/hwconsts.cpp.in
QTfrontend/hwconsts.h
QTfrontend/hwform.cpp
QTfrontend/input_ip.h
--- a/QTfrontend/gameuiconfig.cpp	Thu Dec 13 21:31:47 2007 +0000
+++ b/QTfrontend/gameuiconfig.cpp	Thu Dec 13 21:49:52 2007 +0000
@@ -39,7 +39,10 @@
 	Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
 
 	Form->ui.pageOptions->editNetNick->setText(value("net/nick", QLineEdit::tr("unnamed")).toString());
-//	Form->ui.pageNet->editIP->setText(value("net/ip", "").toString());
+
+	delete netHost;
+	netHost = new QString(value("net/ip", "").toString());
+	netPort = value("net/port", 46631).toUInt();
 
 	Form->ui.pageOptions->CBShowFPS->setChecked(value("fps/show", false).toBool());
 	Form->ui.pageOptions->fpsedit->setValue(value("fps/interval", 27).toUInt());
@@ -71,7 +74,8 @@
 	setValue("audio/sound", isSoundEnabled());
 
 	setValue("net/nick", Form->ui.pageOptions->editNetNick->text());
-//	setValue("net/ip", Form->ui.pageNet->editIP->text());
+	setValue("net/ip", *netHost);
+	setValue("net/port", netPort);
 
 	setValue("fps/show", isShowFPSEnabled());
 	setValue("fps/interval", Form->ui.pageOptions->fpsedit->value());
--- a/QTfrontend/hwconsts.cpp.in	Thu Dec 13 21:31:47 2007 +0000
+++ b/QTfrontend/hwconsts.cpp.in	Thu Dec 13 21:49:52 2007 +0000
@@ -35,3 +35,6 @@
 QColor * color4 = new QColor( 37, 181,  61);
 QColor * color5 = new QColor(247, 237, 112);
 QColor * color6 = new QColor(192,  85, 160);
+
+QString * netHost = new QString();
+quint16 netPort = 46631;
--- a/QTfrontend/hwconsts.h	Thu Dec 13 21:31:47 2007 +0000
+++ b/QTfrontend/hwconsts.h	Thu Dec 13 21:49:52 2007 +0000
@@ -38,3 +38,6 @@
 extern QColor * color4;
 extern QColor * color5;
 extern QColor * color6;
+
+extern QString * netHost;
+extern quint16 netPort;
--- a/QTfrontend/hwform.cpp	Thu Dec 13 21:31:47 2007 +0000
+++ b/QTfrontend/hwform.cpp	Thu Dec 13 21:49:52 2007 +0000
@@ -31,6 +31,7 @@
 #include <QLineEdit>
 #include <QLabel>
 #include <QRadioButton>
+#include <QSpinBox>
 
 #include "hwform.h"
 #include "game.h"
@@ -405,15 +406,22 @@
 		ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&)));
 
 	hwnet->Connect(hostName, port, nick);
-	config->SaveOptions();
 }
 
 void HWForm::NetConnect()
 {
 	HWHostPortDialog * hpd = new HWHostPortDialog(this);
+	hpd->leHost->setText(*netHost);
+	hpd->sbPort->setValue(netPort);
 
-	hpd->exec();
-// FIXME:  _NetConnect(ui.pageNet->editIP->text(), 46631, ui.pageNet->editNetNick->text());
+	if (hpd->exec() == QDialog::Accepted)
+	{
+		config->SaveOptions();
+		delete netHost;
+		netHost = new QString(hpd->leHost->text());
+		netPort = hpd->sbPort->value();
+		_NetConnect(*netHost, netPort, ui.pageOptions->editNetNick->text());
+	}
 }
 
 void HWForm::NetStartServer()
--- a/QTfrontend/input_ip.h	Thu Dec 13 21:31:47 2007 +0000
+++ b/QTfrontend/input_ip.h	Thu Dec 13 21:49:52 2007 +0000
@@ -33,9 +33,10 @@
 public:
 	HWHostPortDialog(QWidget* parent = 0);
 
-private:
 	QLineEdit* leHost;
 	QSpinBox* sbPort;
+
+private:
 	QPushButton* pbOK;
 	QPushButton* pbCancel;
 	QPushButton * pbDefault;