~ubuntu-branches/ubuntu/wily/hedgewars/wily

« back to all changes in this revision

Viewing changes to QTfrontend/pagenetgame.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-09-23 10:16:55 UTC
  • mfrom: (1.2.11 upstream)
  • Revision ID: package-import@ubuntu.com-20110923101655-3977th2gc5n0a3pv
Tags: 0.9.16-1
* New upstream version.
 + Downloadable content! Simply click to install any content.
   New voices, hats, maps, themes, translations, music, scripts...
   Hedgewars is now more customisable than ever before! As time goes
   by we will be soliciting community content to feature on this page,
   so remember to check it from time to time. If you decide you want
   to go back to standard Hedgewars, just remove the Data directory
   from your Hedgewars config directory.
 + 3-D rendering! Diorama-like rendering of the game in a variety
   of 3D modes. Let us know which ones work best for you, we didn't
   really have the equipment to test them all.
 + Resizable game window.
 + New utilities! The Time Box will remove one of your hedgehogs
   from the game for a while, protecting from attack until it returns,
   somewhere else on the map. Land spray will allow you to build bridges,
   seal up holes, or just make life unpleasant for your enemies.
 + New single player: Bamboo Thicket, That Sinking Feeling, Newton and
   the Tree and multi-player: The Specialists, Space Invaders,
   Racer - scripts! And a ton more script hooks for scripters
 + New twists on old weapons. Drill strike, seduction and fire have
   been adjusted. Defective mines have been added, rope can attach to
   hogs/crates/barrels again, grenades now have variable bounce (use
   precise key + 1-5). Portal gun is now more usable in flight and
   all game actions are a lot faster.
 + New theme - Golf, dozens of new community hats and a new
   localised Default voice, Ukranian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include <QMessageBox>
 
24
 
 
25
#include "pagenetgame.h"
 
26
#include "gamecfgwidget.h"
 
27
#include "teamselect.h"
 
28
#include "chatwidget.h"
 
29
 
 
30
PageNetGame::PageNetGame(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : AbstractPage(parent)
 
31
{
 
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);
 
37
 
 
38
    // chatwidget
 
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);
 
44
 
 
45
    pGameCFG = new GameCFGWidget(this);
 
46
    pageLayout->addWidget(pGameCFG, 0, 0);
 
47
 
 
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);
 
52
 
 
53
    pNetTeamsWidget = new TeamSelWidget(this);
 
54
    pNetTeamsWidget->setAcceptOuter(true);
 
55
    pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1);
 
56
 
 
57
 
 
58
    QHBoxLayout * bottomLayout = new QHBoxLayout;
 
59
    pageLayout->addLayout(bottomLayout, 4, 0, 1, 2);
 
60
 
 
61
    BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true);
 
62
 
 
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);
 
69
 
 
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);
 
77
 
 
78
 
 
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);
 
88
 
 
89
    BtnMaster->setMenu(menu);
 
90
 
 
91
    BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3);
 
92
 
 
93
    bottomLayout->insertStretch(3, 100);
 
94
 
 
95
    connect(BtnUpdate, SIGNAL(clicked()), this, SLOT(onUpdateClick()));
 
96
}
 
97
 
 
98
void PageNetGame::setReadyStatus(bool isReady)
 
99
{
 
100
    if(isReady)
 
101
        BtnGo->setIcon(QIcon(":/res/lightbulb_on.png"));
 
102
    else
 
103
        BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
 
104
}
 
105
 
 
106
void PageNetGame::onUpdateClick()
 
107
{
 
108
    if (leRoomName->text().size())
 
109
        emit askForUpdateRoomName(leRoomName->text());
 
110
    else
 
111
        QMessageBox::critical(this,
 
112
                tr("Error"),
 
113
                tr("Please enter room name"),
 
114
                tr("OK"));
 
115
}
 
116
 
 
117
void PageNetGame::setMasterMode(bool isMaster)
 
118
{
 
119
    BtnMaster->setVisible(isMaster);
 
120
    BtnStart->setVisible(isMaster);
 
121
    BtnUpdate->setVisible(isMaster);
 
122
    leRoomName->setVisible(isMaster);
 
123
}