QTfrontend/pagenetgame.cpp
changeset 5078 3527f0e7bb21
child 5126 50803f3403a5
equal deleted inserted replaced
5076:b3bb27f4ba6b 5078:3527f0e7bb21
       
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    17  */
       
    18 
       
    19 #include <QGridLayout>
       
    20 #include <QPushButton>
       
    21 #include <QAction>
       
    22 #include <QMenu>
       
    23 
       
    24 #include "pages.h"
       
    25 #include "gamecfgwidget.h"
       
    26 #include "teamselect.h"
       
    27 #include "chatwidget.h"
       
    28 
       
    29 PageNetGame::PageNetGame(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : AbstractPage(parent)
       
    30 {
       
    31     QGridLayout * pageLayout = new QGridLayout(this);
       
    32     pageLayout->setSizeConstraint(QLayout::SetMinimumSize);
       
    33     //pageLayout->setSpacing(1);
       
    34     pageLayout->setColumnStretch(0, 50);
       
    35     pageLayout->setColumnStretch(1, 50);
       
    36 
       
    37     // chatwidget
       
    38     pChatWidget = new HWChatWidget(this, gameSettings, sdli, true);
       
    39     pChatWidget->setShowReady(true); // show status bulbs by default
       
    40     pChatWidget->setShowFollow(false); // don't show follow in nicks' context menus
       
    41     pageLayout->addWidget(pChatWidget, 2, 0, 1, 2);
       
    42     pageLayout->setRowStretch(1, 100);
       
    43 
       
    44     pGameCFG = new GameCFGWidget(this);
       
    45     pageLayout->addWidget(pGameCFG, 0, 0);
       
    46 
       
    47     QPushButton * btnSetup = new QPushButton(this);
       
    48     btnSetup->setText(QPushButton::tr("Setup"));
       
    49     connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked()));
       
    50     pageLayout->addWidget(btnSetup, 1, 0);
       
    51 
       
    52     pNetTeamsWidget = new TeamSelWidget(this);
       
    53     pNetTeamsWidget->setAcceptOuter(true);
       
    54     pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1);
       
    55 
       
    56 
       
    57     QHBoxLayout * bottomLayout = new QHBoxLayout;
       
    58     pageLayout->addLayout(bottomLayout, 4, 0, 1, 2);
       
    59 
       
    60     BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true);
       
    61 
       
    62     BtnGo = new QPushButton(this);
       
    63     BtnGo->setToolTip(QPushButton::tr("Ready"));
       
    64     BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
       
    65     BtnGo->setIconSize(QSize(25, 34));
       
    66     BtnGo->setMinimumWidth(50);
       
    67     BtnGo->setMinimumHeight(50);
       
    68     bottomLayout->addWidget(BtnGo, 4);
       
    69 
       
    70 
       
    71     BtnMaster = addButton(tr("Control"), bottomLayout, 2);
       
    72     QMenu * menu = new QMenu(BtnMaster);
       
    73     restrictJoins = new QAction(QAction::tr("Restrict Joins"), menu);
       
    74     restrictJoins->setCheckable(true);
       
    75     restrictTeamAdds = new QAction(QAction::tr("Restrict Team Additions"), menu);
       
    76     restrictTeamAdds->setCheckable(true);
       
    77     //menu->addAction(startGame);
       
    78     menu->addAction(restrictJoins);
       
    79     menu->addAction(restrictTeamAdds);
       
    80 
       
    81     BtnMaster->setMenu(menu);
       
    82 
       
    83     BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3);
       
    84 
       
    85     bottomLayout->insertStretch(1, 100);
       
    86 }
       
    87 
       
    88 void PageNetGame::setReadyStatus(bool isReady)
       
    89 {
       
    90     if(isReady)
       
    91         BtnGo->setIcon(QIcon(":/res/lightbulb_on.png"));
       
    92     else
       
    93         BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
       
    94 }
       
    95 
       
    96 void PageNetGame::setMasterMode(bool isMaster)
       
    97 {
       
    98     BtnMaster->setVisible(isMaster);
       
    99     BtnStart->setVisible(isMaster);
       
   100 }