GCI2012: Beautify Network Page
authordag10
Thu, 20 Dec 2012 23:54:41 +0100
changeset 8318 e2c01fbf36c0
parent 8317 ec9f94ab2737
child 8319 408371c03140
GCI2012: Beautify Network Page
QTfrontend/hedgewars.qrc
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/res/NetworkPlayDisabled.png
QTfrontend/res/css/qt.css
QTfrontend/ui/page/pagemain.cpp
QTfrontend/ui/page/pagemain.h
QTfrontend/ui/page/pagenettype.cpp
QTfrontend/ui/page/pagenettype.h
QTfrontend/ui_hwform.cpp
QTfrontend/ui_hwform.h
--- a/QTfrontend/hedgewars.qrc	Thu Dec 20 23:14:54 2012 +0100
+++ b/QTfrontend/hedgewars.qrc	Thu Dec 20 23:54:41 2012 +0100
@@ -44,6 +44,7 @@
         <file>res/HedgewarsTitle.png</file>
         <file>res/LocalPlay.png</file>
         <file>res/NetworkPlay.png</file>
+        <file>res/NetworkPlayDisabled.png</file>
         <file>res/Settings.png</file>
         <file>res/dropdown.png</file>
         <file>res/new.png</file>
--- a/QTfrontend/hwform.cpp	Thu Dec 20 23:14:54 2012 +0100
+++ b/QTfrontend/hwform.cpp	Thu Dec 20 23:54:41 2012 +0100
@@ -73,7 +73,6 @@
 #include "pagefeedback.h"
 #include "pagenetserver.h"
 #include "pagedrawmap.h"
-#include "pagenettype.h"
 #include "pagegamestats.h"
 #include "pageplayrecord.h"
 #include "pagedata.h"
@@ -203,9 +202,6 @@
     connect(ui.pageMain->BtnFeedback, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
     pageSwitchMapper->setMapping(ui.pageMain->BtnFeedback, ID_PAGE_FEEDBACK);
 
-    connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
-    pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE);
-
     connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
     pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_INFO);
 
@@ -304,8 +300,8 @@
     //    this, SLOT(GoBack())); // executed third
 
 
-    connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet()));
-    connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
+    connect(ui.pageMain->BtnNetLocal, SIGNAL(clicked()), this, SLOT(GoToNet()));
+    connect(ui.pageMain->BtnNetOfficial, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
 
     connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack()));
 
@@ -573,7 +569,6 @@
       case ID_PAGE_CONNECTING :	qDebug("%sPAGE_CONNECTING%s", qPrintable(closePrefix), qPrintable(closeSuffix));	break;      
       case ID_PAGE_SCHEME :		qDebug("%sPAGE_SCHEME%s", qPrintable(closePrefix), qPrintable(closeSuffix));		break;      
       case ID_PAGE_ADMIN :		qDebug("%sPAGE_ADMIN%s", qPrintable(closePrefix), qPrintable(closeSuffix));		break;      
-      case ID_PAGE_NETTYPE :		qDebug("%sPAGE_NETTYPE%s", qPrintable(closePrefix), qPrintable(closeSuffix));		break;      
       case ID_PAGE_CAMPAIGN :		qDebug("%sPAGE_CAMPAIGN%s", qPrintable(closePrefix), qPrintable(closeSuffix));		break;      
       case ID_PAGE_DRAWMAP :		qDebug("%sPAGE_DRAWMAP%s", qPrintable(closePrefix), qPrintable(closeSuffix));		break;      
       case ID_PAGE_DATADOWNLOAD :	qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(closePrefix), qPrintable(closeSuffix));	break;      
@@ -601,7 +596,6 @@
       case ID_PAGE_CONNECTING :	qDebug("%sPAGE_CONNECTING%s", qPrintable(openPrefix), qPrintable(openSuffix));		break;      
       case ID_PAGE_SCHEME :		qDebug("%sPAGE_SCHEME%s", qPrintable(openPrefix), qPrintable(openSuffix));		break;      
       case ID_PAGE_ADMIN :		qDebug("%sPAGE_ADMIN%s", qPrintable(openPrefix), qPrintable(openSuffix));		break;      
-      case ID_PAGE_NETTYPE :		qDebug("%sPAGE_NETTYPE%s", qPrintable(openPrefix), qPrintable(openSuffix));		break;      
       case ID_PAGE_CAMPAIGN :		qDebug("%sPAGE_CAMPAIGN%s", qPrintable(openPrefix), qPrintable(openSuffix));		break;      
       case ID_PAGE_DRAWMAP :		qDebug("%sPAGE_DRAWMAP%s", qPrintable(openPrefix), qPrintable(openSuffix));		break;      
       case ID_PAGE_DATADOWNLOAD :	qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(openPrefix), qPrintable(openSuffix));	break;      
@@ -1508,7 +1502,6 @@
         }
         else {
             while (ui.Pages->currentIndex() != ID_PAGE_NET
-                && ui.Pages->currentIndex() != ID_PAGE_NETTYPE
                 && ui.Pages->currentIndex() != ID_PAGE_MAIN) 
             {
                 GoBack();
@@ -1525,7 +1518,6 @@
     }
 
     while (ui.Pages->currentIndex() != ID_PAGE_NET
-        && ui.Pages->currentIndex() != ID_PAGE_NETTYPE
         && ui.Pages->currentIndex() != ID_PAGE_MAIN)
     {
         GoBack();
--- a/QTfrontend/hwform.h	Thu Dec 20 23:14:54 2012 +0100
+++ b/QTfrontend/hwform.h	Thu Dec 20 23:54:41 2012 +0100
@@ -172,7 +172,6 @@
             ID_PAGE_CONNECTING     ,
             ID_PAGE_SCHEME         ,
             ID_PAGE_ADMIN          ,
-            ID_PAGE_NETTYPE        ,
             ID_PAGE_CAMPAIGN       ,
             ID_PAGE_DRAWMAP        ,
             ID_PAGE_DATADOWNLOAD   ,
Binary file QTfrontend/res/NetworkPlayDisabled.png has changed
--- a/QTfrontend/res/css/qt.css	Thu Dec 20 23:14:54 2012 +0100
+++ b/QTfrontend/res/css/qt.css	Thu Dec 20 23:54:41 2012 +0100
@@ -105,7 +105,6 @@
 outline: none;
 }
 
-
 QHeaderView {
 border-radius: 0;
 border-width: 0;
--- a/QTfrontend/ui/page/pagemain.cpp	Thu Dec 20 23:14:54 2012 +0100
+++ b/QTfrontend/ui/page/pagemain.cpp	Thu Dec 20 23:54:41 2012 +0100
@@ -46,10 +46,35 @@
     BtnSinglePlayer->setWhatsThis(tr("Play a game on a single computer"));
     pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter);
 
+    //BtnNet = addButton(":/res/NetworkPlay.png", (QBoxLayout*)netLayout, 1, true);
     BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true);
     BtnNet->setToolTip(tr("Network Game"));
     BtnNet->setWhatsThis(tr("Play a game across a network"));
     pageLayout->setAlignment(BtnNet, Qt::AlignHCenter);
+    connect(BtnNet, SIGNAL(clicked()), this, SLOT(toggleNetworkChoice()));
+    
+    originalNetworkIcon = BtnNet->icon();
+    disabledNetworkIcon = QIcon(":/res/NetworkPlayDisabled.png");
+
+    //QWidget *netLayoutWidget = new QWidget();
+    QVBoxLayout *netLayout = new QVBoxLayout(BtnNet);
+    //pageLayout->addWidget(netLayoutWidget, 2, 2, 1, 2);
+    //netLayoutWidget->setStyleSheet("background: green;");
+    //netLayoutWidget->setFixedSize(314, 260);
+    netLayout->setSpacing(20);
+    netLayout->setAlignment(Qt::AlignHCenter);
+
+    BtnNetLocal = addButton("Play local network game", (QBoxLayout*)netLayout, 0, false);
+    BtnNetLocal->setToolTip(tr("Play a local network game"));
+    BtnNetLocal->setWhatsThis(tr("Play a game across a local area network"));
+    BtnNetLocal->setFixedSize(BtnNet->width() - 50, 60);
+    BtnNetLocal->setVisible(false);
+
+    BtnNetOfficial = addButton("Play official network game", (QBoxLayout*)netLayout, 0, false);
+    BtnNetOfficial->setToolTip(tr("Play a network game"));
+    BtnNetOfficial->setWhatsThis(tr("Play a game on an official server"));
+    BtnNetOfficial->setFixedSize(BtnNet->width() - 50, 60);
+    BtnNetOfficial->setVisible(false);
 
     // button order matters for overlapping (what's on top and what isn't)
     BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true);
@@ -184,3 +209,12 @@
 
     return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()];
 }
+
+void PageMain::toggleNetworkChoice()
+{
+    bool visible = BtnNetLocal->isVisible();
+    BtnNetLocal->setVisible(!visible);
+    BtnNetOfficial->setVisible(!visible);
+    if (visible)    BtnNet->setIcon(originalNetworkIcon);
+    else            BtnNet->setIcon(disabledNetworkIcon);
+}
--- a/QTfrontend/ui/page/pagemain.h	Thu Dec 20 23:14:54 2012 +0100
+++ b/QTfrontend/ui/page/pagemain.h	Thu Dec 20 23:54:41 2012 +0100
@@ -21,15 +21,19 @@
 
 #include "AbstractPage.h"
 
+class QIcon;
+
 class PageMain : public AbstractPage
 {
-        Q_OBJECT
+    Q_OBJECT
 
     public:
         PageMain(QWidget * parent = 0);
 
         QPushButton * BtnSinglePlayer;
         QPushButton * BtnNet;
+        QPushButton * BtnNetLocal;
+        QPushButton * BtnNetOfficial;
         QPushButton * BtnSetup;
         QPushButton * BtnFeedback;
         QPushButton * BtnInfo;
@@ -41,8 +45,12 @@
         QLayout * bodyLayoutDefinition();
         QLayout * footerLayoutDefinition();
         void connectSignals();
+        QIcon originalNetworkIcon, disabledNetworkIcon;
 
         QString randomTip() const;
+
+    private slots:
+        void toggleNetworkChoice();
 };
 
 #endif
--- a/QTfrontend/ui/page/pagenettype.cpp	Thu Dec 20 23:14:54 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QGridLayout>
-#include <QPushButton>
-
-#include "pagenettype.h"
-
-
-QLayout * PageNetType::bodyLayoutDefinition()
-{
-    QGridLayout * pageLayout = new QGridLayout();
-    pageLayout->setRowStretch(0, 10);
-    pageLayout->setRowStretch(3, 10);
-
-    pageLayout->setColumnStretch(1, 10);
-    pageLayout->setColumnStretch(2, 20);
-    pageLayout->setColumnStretch(3, 10);
-
-    BtnLAN = addButton(tr("LAN game"), pageLayout, 1, 2);
-    BtnLAN->setWhatsThis(tr("Join or host your own game server in a Local Area Network."));
-    BtnOfficialServer = addButton(tr("Official server"), pageLayout, 2, 2);
-    BtnOfficialServer->setWhatsThis(tr("Join hundreds of players online!"));
-
-    // hack: temporary deactivated - requires server modifications that aren't backward compatible (yet)
-    //BtnOfficialServer->setEnabled(false);
-
-    return pageLayout;
-}
-
-PageNetType::PageNetType(QWidget* parent) : AbstractPage(parent)
-{
-    initPage();
-}
--- a/QTfrontend/ui/page/pagenettype.h	Thu Dec 20 23:14:54 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef PAGE_NETTYPE_H
-#define PAGE_NETTYPE_H
-
-#include "AbstractPage.h"
-
-class PageNetType : public AbstractPage
-{
-        Q_OBJECT
-
-    public:
-        PageNetType(QWidget* parent = 0);
-
-        QPushButton * BtnLAN;
-        QPushButton * BtnOfficialServer;
-
-    protected:
-        QLayout * bodyLayoutDefinition();
-};
-
-#endif
--- a/QTfrontend/ui_hwform.cpp	Thu Dec 20 23:14:54 2012 +0100
+++ b/QTfrontend/ui_hwform.cpp	Thu Dec 20 23:54:41 2012 +0100
@@ -30,7 +30,6 @@
 #include "pagefeedback.h"
 #include "pageingame.h"
 #include "pagescheme.h"
-#include "pagenettype.h"
 #include "pageroomslist.h"
 #include "pageinfo.h"
 #include "pagenetgame.h"
@@ -132,9 +131,6 @@
     pageAdmin = new PageAdmin();
     Pages->addWidget(pageAdmin);
 
-    pageNetType = new PageNetType();
-    Pages->addWidget(pageNetType);
-
     pageCampaign = new PageCampaign();
     Pages->addWidget(pageCampaign);
 
--- a/QTfrontend/ui_hwform.h	Thu Dec 20 23:14:54 2012 +0100
+++ b/QTfrontend/ui_hwform.h	Thu Dec 20 23:54:41 2012 +0100
@@ -41,7 +41,6 @@
 class PageConnecting;
 class PageScheme;
 class PageAdmin;
-class PageNetType;
 class PageDrawMap;
 class PageVideos;
 class QStackedLayout;
@@ -76,7 +75,6 @@
         PageConnecting *pageConnecting;
         PageScheme *pageScheme;
         PageAdmin *pageAdmin;
-        PageNetType *pageNetType;
         PageCampaign *pageCampaign;
         PageDrawMap *pageDrawMap;
         PageVideos *pageVideos;