- Switch between local and internet game
authorunc0rr
Sun, 09 Dec 2007 13:49:33 +0000
changeset 636 dc93ac775bb9
parent 635 0fb6d55ecd66
child 637 8fa7ed5e13bd
- Switch between local and internet game - Some bugs a left
QTfrontend/hwform.cpp
QTfrontend/pages.cpp
QTfrontend/pages.h
--- a/QTfrontend/hwform.cpp	Sun Dec 09 13:21:47 2007 +0000
+++ b/QTfrontend/hwform.cpp	Sun Dec 09 13:49:33 2007 +0000
@@ -30,6 +30,7 @@
 #include <QStackedLayout>
 #include <QLineEdit>
 #include <QLabel>
+#include <QRadioButton>
 
 #include "hwform.h"
 #include "game.h"
@@ -402,7 +403,11 @@
   pnetserver = new HWNetServer;
   pnetserver->StartServer();
   _NetConnect("localhost", pnetserver->getRunningPort(), ui.pageNet->editNetNick->text());
-  pRegisterServer = new HWNetWwwServer(0, "hedgewars server", 46631);
+
+  if (ui.pageNet->rbLocalGame->isChecked())
+    pRegisterServer = new HWNetUdpServer(0, "hedgewars server", 46631);
+  else
+    pRegisterServer = new HWNetWwwServer(0, "hedgewars server", 46631);
 }
 
 void HWForm::NetDisconnect()
--- a/QTfrontend/pages.cpp	Sun Dec 09 13:21:47 2007 +0000
+++ b/QTfrontend/pages.cpp	Sun Dec 09 13:49:33 2007 +0000
@@ -28,6 +28,7 @@
 #include <QApplication>
 #include <QSpinBox>
 #include <QTextEdit>
+#include <QRadioButton>
 
 #include "pages.h"
 #include "sdlkeys.h"
@@ -429,11 +430,25 @@
 	labelNN->setText(QLabel::tr("Net nick"));
 	GBNlayout->addWidget(labelNN, 0, 0);
 
-	editNetNick	= new QLineEdit(NNGroupBox);
+	editNetNick = new QLineEdit(NNGroupBox);
 	editNetNick->setMaxLength(20);
 	editNetNick->setText(QLineEdit::tr("unnamed"));
 	GBNlayout->addWidget(editNetNick, 0, 1);
 
+	QGroupBox * NetTypeGroupBox = new QGroupBox(this);
+	NetTypeGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
+	NetTypeGroupBox->setTitle(QGroupBox::tr("Connection type"));
+	pageLayout->addWidget(NetTypeGroupBox, 0, 1);
+
+	QVBoxLayout * GBTlayout = new QVBoxLayout(NetTypeGroupBox);
+	rbLocalGame = new QRadioButton(NetTypeGroupBox);
+	rbLocalGame->setText(tr("Local game"));
+	rbLocalGame->setChecked(true);
+	GBTlayout->addWidget(rbLocalGame);
+	rbInternetGame = new QRadioButton(NetTypeGroupBox);
+	rbInternetGame->setText(tr("Internet game"));
+	GBTlayout->addWidget(rbInternetGame);
+
 	ConnGroupBox = new QGroupBox(this);
 	ConnGroupBox->setTitle(QGroupBox::tr("Net game"));
 	pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3);
@@ -469,13 +484,18 @@
 	BtnBack->setFont(*font14);
 	BtnBack->setText(QPushButton::tr("Back"));
 	pageLayout->addWidget(BtnBack, 3, 0);
+
+	connect(rbLocalGame, SIGNAL(toggled(bool)), this, SLOT(changeServersList()));
 }
 
 void PageNet::changeServersList()
 {
 	if (netServersWidget) delete netServersWidget;
 
-	netServersWidget = new HWNetWwwWidget(ConnGroupBox);
+	if (rbLocalGame->isChecked())
+		netServersWidget = new HWNetUdpWidget(ConnGroupBox);
+	else
+		netServersWidget = new HWNetWwwWidget(ConnGroupBox);
 	GBClayout->addWidget(netServersWidget, 1, 0, 2, 2);
 
 	connect(BtnUpdateSList, SIGNAL(clicked()), netServersWidget, SLOT(updateList()));
--- a/QTfrontend/pages.h	Sun Dec 09 13:21:47 2007 +0000
+++ b/QTfrontend/pages.h	Sun Dec 09 13:49:33 2007 +0000
@@ -44,6 +44,7 @@
 class HWChatWidget;
 class SelWeaponWidget;
 class HWNetServersWidget;
+class QRadioButton;
 
 class PageMain : public QWidget
 {
@@ -165,6 +166,8 @@
 	QLineEdit *editNetNick;
 	QLabel *labelIP;
 	QLineEdit * editIP;
+	QRadioButton * rbLocalGame;
+	QRadioButton * rbInternetGame;
 
 private:
 	QGroupBox * ConnGroupBox;