2
* Hedgewars, a free turn based strategy game
3
* Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
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
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.
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
19
#include <QGridLayout>
20
#include <QPushButton>
23
#include <QMessageBox>
25
#include "pagenetgame.h"
26
#include "gamecfgwidget.h"
27
#include "teamselect.h"
28
#include "chatwidget.h"
30
PageNetGame::PageNetGame(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : AbstractPage(parent)
32
QGridLayout * pageLayout = new QGridLayout(this);
33
pageLayout->setSizeConstraint(QLayout::SetMinimumSize);
34
//pageLayout->setSpacing(1);
35
pageLayout->setColumnStretch(0, 50);
36
pageLayout->setColumnStretch(1, 50);
39
pChatWidget = new HWChatWidget(this, gameSettings, sdli, true);
40
pChatWidget->setShowReady(true); // show status bulbs by default
41
pChatWidget->setShowFollow(false); // don't show follow in nicks' context menus
42
pageLayout->addWidget(pChatWidget, 2, 0, 1, 2);
43
pageLayout->setRowStretch(1, 100);
45
pGameCFG = new GameCFGWidget(this);
46
pageLayout->addWidget(pGameCFG, 0, 0);
48
QPushButton * btnSetup = new QPushButton(this);
49
btnSetup->setText(QPushButton::tr("Setup"));
50
connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked()));
51
pageLayout->addWidget(btnSetup, 1, 0);
53
pNetTeamsWidget = new TeamSelWidget(this);
54
pNetTeamsWidget->setAcceptOuter(true);
55
pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1);
58
QHBoxLayout * bottomLayout = new QHBoxLayout;
59
pageLayout->addLayout(bottomLayout, 4, 0, 1, 2);
61
BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true);
63
leRoomName = new QLineEdit(this);
64
leRoomName->setMaxLength(60);
65
leRoomName->setMinimumWidth(200);
66
leRoomName->setMaximumWidth(400);
67
bottomLayout->addWidget(leRoomName, 8,0);
68
BtnUpdate = addButton(QAction::tr("Update"), bottomLayout, 1, false);
70
BtnGo = new QPushButton(this);
71
BtnGo->setToolTip(QPushButton::tr("Ready"));
72
BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
73
BtnGo->setIconSize(QSize(25, 34));
74
BtnGo->setMinimumWidth(50);
75
BtnGo->setMinimumHeight(50);
76
bottomLayout->addWidget(BtnGo, 4);
79
BtnMaster = addButton(tr("Control"), bottomLayout, 2);
80
QMenu * menu = new QMenu(BtnMaster);
81
restrictJoins = new QAction(QAction::tr("Restrict Joins"), menu);
82
restrictJoins->setCheckable(true);
83
restrictTeamAdds = new QAction(QAction::tr("Restrict Team Additions"), menu);
84
restrictTeamAdds->setCheckable(true);
85
//menu->addAction(startGame);
86
menu->addAction(restrictJoins);
87
menu->addAction(restrictTeamAdds);
89
BtnMaster->setMenu(menu);
91
BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3);
93
bottomLayout->insertStretch(3, 100);
95
connect(BtnUpdate, SIGNAL(clicked()), this, SLOT(onUpdateClick()));
98
void PageNetGame::setReadyStatus(bool isReady)
101
BtnGo->setIcon(QIcon(":/res/lightbulb_on.png"));
103
BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
106
void PageNetGame::onUpdateClick()
108
if (leRoomName->text().size())
109
emit askForUpdateRoomName(leRoomName->text());
111
QMessageBox::critical(this,
113
tr("Please enter room name"),
117
void PageNetGame::setMasterMode(bool isMaster)
119
BtnMaster->setVisible(isMaster);
120
BtnStart->setVisible(isMaster);
121
BtnUpdate->setVisible(isMaster);
122
leRoomName->setVisible(isMaster);