QTfrontend/pages.cpp
author unc0rr
Fri, 31 Oct 2008 14:49:16 +0000
changeset 1444 06f6ae457a2f
parent 1443 e79e4b48c771
child 1447 e3a05ce15f1a
permissions -rw-r--r--
Finish reorganizing local game page
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     1
/*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 923
diff changeset
     2
 * Hedgewars, a free turn based strategy game
1236
f9110fd03754 Add stubs for hats implementation
unc0rr
parents: 1225
diff changeset
     3
 * Copyright (c) 2006-2008 Andrey Korotaev <unC0Rr@gmail.com>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     4
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     8
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    12
 * GNU General Public License for more details.
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    13
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    15
 * along with this program; if not, write to the Free Software
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    17
 */
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    18
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    19
#include <QGridLayout>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    20
#include <QPushButton>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    21
#include <QGroupBox>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    22
#include <QComboBox>
311
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 310
diff changeset
    23
#include <QCheckBox>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    24
#include <QLabel>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    25
#include <QToolBox>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    26
#include <QLineEdit>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    27
#include <QListWidget>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    28
#include <QApplication>
231
c77b16e48273 bots power icons added
displacer
parents: 187
diff changeset
    29
#include <QSpinBox>
452
45fbb9df0c99 problems with widget sizes for net chat
displacer
parents: 451
diff changeset
    30
#include <QTextEdit>
636
dc93ac775bb9 - Switch between local and internet game
unc0rr
parents: 632
diff changeset
    31
#include <QRadioButton>
665
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 659
diff changeset
    32
#include <QTableView>
671
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
    33
#include <QMessageBox>
673
bd82104a28af - Save after save now works
unc0rr
parents: 672
diff changeset
    34
#include <QHeaderView>
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
    35
#include <QTabWidget>
1377
a9e768739345 - Customize QTextBrowser look
unc0rr
parents: 1334
diff changeset
    36
#include <QTextBrowser>
1399
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
    37
#include <QTableWidget>
1409
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
    38
#include <QAction>
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
    39
#include <QMenu>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    40
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    41
#include "pages.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    42
#include "sdlkeys.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    43
#include "hwconsts.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    44
#include "gamecfgwidget.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    45
#include "teamselect.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    46
#include "gamecfgwidget.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    47
#include "SquareLabel.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    48
#include "mapContainer.h"
187
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
    49
#include "about.h"
297
279e10ec31b4 'Show FPS' and 'FPS limit' options
unc0rr
parents: 290
diff changeset
    50
#include "fpsedit.h"
632
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
    51
#include "netserverslist.h"
412
2ddcc3e3e644 udp server detecting experimental version
displacer
parents: 373
diff changeset
    52
#include "netudpwidget.h"
461
105af110b0e6 chatWidget with layout
displacer
parents: 453
diff changeset
    53
#include "chatwidget.h"
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents: 555
diff changeset
    54
#include "playrecordpage.h"
612
333d095319de abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents: 603
diff changeset
    55
#include "selectWeapon.h"
1192
63b7961f68de Add iconed groupbox class
unc0rr
parents: 1168
diff changeset
    56
#include "igbox.h"
1238
914bd2a9a249 Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents: 1236
diff changeset
    57
#include "hats.h"
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    58
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    59
PageMain::PageMain(QWidget* parent) : 
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    60
  AbstractPage(parent)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    61
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    62
	QGridLayout * pageLayout = new QGridLayout(this);
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    63
	//pageLayout->setColumnStretch(0, 1);
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    64
	//pageLayout->setColumnStretch(1, 2);
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    65
	//pageLayout->setColumnStretch(2, 1);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    66
1199
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
    67
	//QPushButton* btnLogo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true);
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
    68
	//pageLayout->setAlignment(btnLogo, Qt::AlignHCenter);
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    69
	pageLayout->setRowStretch(0, 1);
1150
ae86e36dad2e - Make look better
unc0rr
parents: 1149
diff changeset
    70
	pageLayout->setRowStretch(1, 1);
ae86e36dad2e - Make look better
unc0rr
parents: 1149
diff changeset
    71
	pageLayout->setRowStretch(2, 0);
ae86e36dad2e - Make look better
unc0rr
parents: 1149
diff changeset
    72
	pageLayout->setRowStretch(3, 1);
1199
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
    73
	pageLayout->setRowStretch(4, 1);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    74
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1151
diff changeset
    75
	BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true);
1150
ae86e36dad2e - Make look better
unc0rr
parents: 1149
diff changeset
    76
	pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    77
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1151
diff changeset
    78
	BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true);
1150
ae86e36dad2e - Make look better
unc0rr
parents: 1149
diff changeset
    79
	pageLayout->setAlignment(BtnNet, Qt::AlignHCenter);
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents: 555
diff changeset
    80
1199
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
    81
	BtnSetup = addButton(":/res/Settings.png", pageLayout, 4, 3, true);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    82
1199
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
    83
	//BtnInfo = addButton(":/res/About.png", pageLayout, 3, 1, 1, 2, true);
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
    84
	BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true);
1212
9890facbe047 Fix "Hedgewars" button look
unc0rr
parents: 1199
diff changeset
    85
	BtnInfo->setStyleSheet("border: transparent;background: transparent;");
1150
ae86e36dad2e - Make look better
unc0rr
parents: 1149
diff changeset
    86
	pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter);
1199
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
    87
	//pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    88
1199
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
    89
	BtnExit = addButton(":/res/Exit.png", pageLayout, 4, 0, 1, 1, true);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    90
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    91
788
00720357601f - Get rid of PageSimpleGame, now pressing 'quick game' just starts round
unc0rr
parents: 730
diff changeset
    92
PageEditTeam::PageEditTeam(QWidget* parent) :
692
07787e748831 code size reduse
displacer
parents: 686
diff changeset
    93
  AbstractPage(parent)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    94
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    95
	QGridLayout * pageLayout = new QGridLayout(this);
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
    96
	QTabWidget * tbw = new QTabWidget(this);
1389
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
    97
	QWidget * page1 = new QWidget(this);
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
    98
	QWidget * page2 = new QWidget(this);
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
    99
	tbw->addTab(page1, tr("General"));
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   100
	tbw->addTab(page2, tr("Advanced"));
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   101
	pageLayout->addWidget(tbw, 0, 0, 1, 3);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   102
	BtnTeamDiscard = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   103
	BtnTeamSave = addButton(":/res/Save.png", pageLayout, 1, 2, true);;
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   104
	BtnTeamSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}");
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   105
	
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   106
	QHBoxLayout * page1Layout = new QHBoxLayout(page1);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   107
	page1Layout->setAlignment(Qt::AlignTop);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   108
	QGridLayout * page2Layout = new QGridLayout(page2);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   109
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   110
// ====== Page 1 ======
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   111
	QVBoxLayout * vbox1 = new QVBoxLayout();
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   112
	QVBoxLayout * vbox2 = new QVBoxLayout();
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   113
	QVBoxLayout * vbox3 = new QVBoxLayout();
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   114
	page1Layout->addLayout(vbox1);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   115
	page1Layout->addLayout(vbox2);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   116
	page1Layout->addLayout(vbox3);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   117
	
588
b2e61fc49e5d Better stub for Training mode
unc0rr
parents: 587
diff changeset
   118
	GBoxHedgehogs = new QGroupBox(this);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   119
	GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members"));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   120
	GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   121
	QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs);
1238
914bd2a9a249 Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents: 1236
diff changeset
   122
	
914bd2a9a249 Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents: 1236
diff changeset
   123
	HatsModel * hatsModel = new HatsModel(GBoxHedgehogs);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   124
	for(int i = 0; i < 8; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   125
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   126
		HHNameEdit[i] = new QLineEdit(GBoxHedgehogs);
1216
df1b19976e28 Allow team and hh name length be up to 64 letters length
unc0rr
parents: 1212
diff changeset
   127
		HHNameEdit[i]->setMaxLength(64);
1238
914bd2a9a249 Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents: 1236
diff changeset
   128
		HHNameEdit[i]->setMinimumWidth(120);
914bd2a9a249 Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents: 1236
diff changeset
   129
		GBHLayout->addWidget(HHNameEdit[i], i, 0);
914bd2a9a249 Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents: 1236
diff changeset
   130
		
914bd2a9a249 Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents: 1236
diff changeset
   131
		HHHats[i] = new QComboBox(GBoxHedgehogs);
914bd2a9a249 Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents: 1236
diff changeset
   132
		HHHats[i]->setModel(hatsModel);
1282
76533d0e76e3 Full-size hedgehog in hats selection widget
unc0rr
parents: 1252
diff changeset
   133
		HHHats[i]->setIconSize(QSize(32, 37));
76533d0e76e3 Full-size hedgehog in hats selection widget
unc0rr
parents: 1252
diff changeset
   134
		//HHHats[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
1239
4901abe4c3b0 - Finish hat selection widget
unc0rr
parents: 1238
diff changeset
   135
		//HHHats[i]->setModelColumn(1);
1240
16b85f292030 Store selected hats in team config
unc0rr
parents: 1239
diff changeset
   136
		//HHHats[i]->setMinimumWidth(132);
1238
914bd2a9a249 Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents: 1236
diff changeset
   137
		GBHLayout->addWidget(HHHats[i], i, 1);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   138
	}
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   139
	vbox1->addWidget(GBoxHedgehogs);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   140
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   141
1288
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   142
	GBoxTeam = new QGroupBox(this);
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   143
	GBoxTeam->setTitle(QGroupBox::tr("Team"));
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   144
	GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   145
	QVBoxLayout * GBTLayout = new QVBoxLayout(GBoxTeam);
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   146
	TeamNameEdit = new QLineEdit(GBoxTeam);
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   147
	TeamNameEdit->setMaxLength(64);
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   148
	GBTLayout->addWidget(TeamNameEdit);
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   149
	vbox2->addWidget(GBoxTeam);
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   150
	
1290
3cb7f6b5000e Fix frontend
unc0rr
parents: 1288
diff changeset
   151
	CBTeamLvl = new QComboBox(GBoxTeam);
1440
6439fa9af904 Replace grey hedgehogs
unc0rr
parents: 1415
diff changeset
   152
	CBTeamLvl->setIconSize(QSize(48, 48));
1287
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   153
	CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human"));
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   154
	for(int i = 5; i > 0; i--)
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   155
		CBTeamLvl->addItem(
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   156
				QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)),
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   157
				QString("%1 %2").arg(QComboBox::tr("Level")).arg(i)
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   158
				);
1288
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   159
	GBTLayout->addWidget(CBTeamLvl);
1287
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   160
	
1290
3cb7f6b5000e Fix frontend
unc0rr
parents: 1288
diff changeset
   161
	CBGrave = new QComboBox(GBoxTeam);
1288
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   162
	CBGrave->setMaxCount(65535);
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   163
	CBGrave->setIconSize(QSize(32, 32));
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   164
	GBTLayout->addWidget(CBGrave);
cea4a8f52f5a Reorganize team edit page a little (save a lot of space)
unc0rr
parents: 1287
diff changeset
   165
	
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   166
	GBoxFort = new QGroupBox(this);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   167
	GBoxFort->setTitle(QGroupBox::tr("Fort"));
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   168
	QGridLayout * GBFLayout = new QGridLayout(GBoxFort);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   169
	CBFort = new QComboBox(GBoxFort);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   170
	CBFort->setMaxCount(65535);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   171
	GBFLayout->addWidget(CBFort, 0, 0);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   172
	FortPreview = new SquareLabel(GBoxFort);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   173
	FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   174
	FortPreview->setPixmap(QPixmap());
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   175
	GBFLayout->addWidget(FortPreview, 1, 0);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   176
	vbox3->addWidget(GBoxFort);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   177
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   178
	QDir tmpdir;
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   179
	tmpdir.cd(datadir->absolutePath());
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   180
	tmpdir.cd("Forts");
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   181
	tmpdir.setFilter(QDir::Files);
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   182
1287
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   183
	connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &)));
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   184
	CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1"));
1287
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   185
	
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   186
	tmpdir.cd("../Graphics/Graves");
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   187
	QStringList list = tmpdir.entryList(QStringList("*.png"));
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   188
	for (QStringList::Iterator it = list.begin(); it != list.end(); ++it )
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   189
	{
1287
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   190
		QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it);
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   191
		QIcon icon(pix.copy(0, 0, 32, 32));
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   192
		CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1"));
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   193
	}
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   194
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   195
	vbox1->addStretch();
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   196
	vbox2->addStretch();
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   197
//	vbox3->addStretch();
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   198
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   199
// ====== Page 2 ======
588
b2e61fc49e5d Better stub for Training mode
unc0rr
parents: 587
diff changeset
   200
	GBoxBinds = new QGroupBox(this);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   201
	GBoxBinds->setTitle(QGroupBox::tr("Key binds"));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   202
	QGridLayout * GBBLayout = new QGridLayout(GBoxBinds);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   203
	BindsBox = new QToolBox(GBoxBinds);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   204
	BindsBox->setLineWidth(0);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   205
	GBBLayout->addWidget(BindsBox);
1389
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
   206
	page_A = new QWidget(this);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   207
	BindsBox->addItem(page_A, QToolBox::tr("Actions"));
1389
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
   208
	page_W = new QWidget(this);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   209
	BindsBox->addItem(page_W, QToolBox::tr("Weapons"));
1389
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
   210
	page_WP = new QWidget(this);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   211
	BindsBox->addItem(page_WP, QToolBox::tr("Weapon properties"));
1389
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
   212
	page_O = new QWidget(this);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   213
	BindsBox->addItem(page_O, QToolBox::tr("Other"));
1252
2e2719c0a397 - Reorganize headers according to Qt's style guide
unc0rr
parents: 1249
diff changeset
   214
	page2Layout->addWidget(GBoxBinds, 0, 0);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   215
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   216
	QStringList binds;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   217
	for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   218
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   219
		binds << sdlkeys[i][1];
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   220
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   221
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   222
	quint16 widind = 0, i = 0;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   223
	while (i < BINDS_NUMBER) {
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   224
		quint16 num = 0;
1389
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
   225
		QWidget * curW = BindsBox->widget(widind);
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
   226
		QGridLayout * pagelayout = new QGridLayout(curW);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   227
		do {
1389
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
   228
			LBind[i] = new QLabel(curW);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   229
			LBind[i]->setText(QApplication::translate("binds", cbinds[i].name));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   230
			LBind[i]->setAlignment(Qt::AlignRight);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   231
			pagelayout->addWidget(LBind[i], num, 0);
1389
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
   232
			CBBind[i] = new QComboBox(curW);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   233
			CBBind[i]->addItems(binds);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   234
			pagelayout->addWidget(CBBind[i], num, 1);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   235
			num++;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   236
		} while (!cbinds[i++].chwidget);
1389
6e411559cc7b Customize team select widget background
unc0rr
parents: 1377
diff changeset
   237
		pagelayout->addWidget(new QWidget(curW), num, 0, 1, 2);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   238
		widind++;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   239
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   240
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   241
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   242
void PageEditTeam::CBFort_activated(const QString & fortname)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   243
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   244
	QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png");
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   245
	FortPreview->setPixmap(pix);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   246
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   247
1287
4a0cbcbe3521 Move preview icons into comboboxes
unc0rr
parents: 1282
diff changeset
   248
PageMultiplayer::PageMultiplayer(QWidget* parent) :
692
07787e748831 code size reduse
displacer
parents: 686
diff changeset
   249
  AbstractPage(parent)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   250
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   251
	QGridLayout * pageLayout = new QGridLayout(this);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   252
1218
ada50f82ea53 Save some pixels for chat widget
unc0rr
parents: 1216
diff changeset
   253
	BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true);
187
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   254
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   255
	gameCFG = new GameCFGWidget(this);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   256
	pageLayout->addWidget(gameCFG, 0, 0, 1, 2);
696
d6f32ed6edc8 working multiplayer weapons combo
displacer
parents: 693
diff changeset
   257
1218
ada50f82ea53 Save some pixels for chat widget
unc0rr
parents: 1216
diff changeset
   258
	pageLayout->setRowStretch(1, 1);
ada50f82ea53 Save some pixels for chat widget
unc0rr
parents: 1216
diff changeset
   259
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   260
	teamsSelect = new TeamSelWidget(this);
1218
ada50f82ea53 Save some pixels for chat widget
unc0rr
parents: 1216
diff changeset
   261
	pageLayout->addWidget(teamsSelect, 0, 2, 2, 2);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   262
1218
ada50f82ea53 Save some pixels for chat widget
unc0rr
parents: 1216
diff changeset
   263
	BtnStartMPGame = addButton(tr("Start"), pageLayout, 2, 3);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   264
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   265
1249
b6670a6ea2d0 Remove 25pix margin on every page, so exit button is almost in the same place on all pages
unc0rr
parents: 1240
diff changeset
   266
PageOptions::PageOptions(QWidget* parent) :
692
07787e748831 code size reduse
displacer
parents: 686
diff changeset
   267
  AbstractPage(parent)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   268
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   269
	QGridLayout * pageLayout = new QGridLayout(this);
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   270
	pageLayout->setColumnStretch(0, 100);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   271
	pageLayout->setColumnStretch(1, 100);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   272
	pageLayout->setColumnStretch(2, 100);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   273
	pageLayout->setRowStretch(0, 0);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   274
	pageLayout->setRowStretch(1, 0);
719
bea32693bd7a - Fix layout on options page
unc0rr
parents: 718
diff changeset
   275
	pageLayout->setRowStretch(2, 0);
bea32693bd7a - Fix layout on options page
unc0rr
parents: 718
diff changeset
   276
	pageLayout->setRowStretch(3, 100);
bea32693bd7a - Fix layout on options page
unc0rr
parents: 718
diff changeset
   277
	pageLayout->setRowStretch(4, 0);
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   278
1198
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   279
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   280
	QGroupBox * gbTwoBoxes = new QGroupBox(this);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   281
	pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   282
	QHBoxLayout * gbTBLayout = new QHBoxLayout(gbTwoBoxes);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   283
	{
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   284
		teamsBox = new IconedGroupBox(this);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   285
		teamsBox->setIcon(QIcon(":/res/teamicon.png"));
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   286
		teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   287
		teamsBox->setTitle(QGroupBox::tr("Teams"));
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   288
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   289
		QGridLayout * GBTlayout = new QGridLayout(teamsBox);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   290
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   291
		BtnNewTeam = addButton(tr("New team"), GBTlayout, 1, 0);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   292
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   293
		CBTeamName = new QComboBox(teamsBox);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   294
		GBTlayout->addWidget(CBTeamName, 0, 0, 1, 2);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   295
1198
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   296
		BtnEditTeam = addButton(tr("Edit team"), GBTlayout, 1, 1);
1199
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   297
		
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   298
		labelNN = new QLabel(teamsBox);
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   299
		labelNN->setText(QLabel::tr("Net nick"));
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   300
		GBTlayout->addWidget(labelNN, 2, 0, 1, 2);
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   301
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   302
		editNetNick = new QLineEdit(teamsBox);
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   303
		editNetNick->setMaxLength(20);
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   304
		editNetNick->setText(QLineEdit::tr("unnamed"));
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   305
		GBTlayout->addWidget(editNetNick, 3, 0, 1, 2);
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   306
		
1198
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   307
		gbTBLayout->addWidget(teamsBox);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   308
	}
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   309
1198
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   310
	{
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   311
		IconedGroupBox* groupWeapons = new IconedGroupBox(this);
1199
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   312
		groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
1198
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   313
		groupWeapons->setIcon(QIcon(":/res/weaponsicon.png"));
1199
543d1268847b More work on options page
unc0rr
parents: 1198
diff changeset
   314
		//groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
1198
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   315
		groupWeapons->setTitle(QGroupBox::tr("Weapons"));
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   316
		QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   317
1198
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   318
		WeaponsButt = addButton(tr("Weapons set"), WeaponsLayout, 1, 0);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   319
		WeaponsName = new QComboBox(this);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   320
		WeaponsLayout->addWidget(WeaponsName, 0, 0, 1, 2);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   321
		WeaponEdit = addButton(tr("Edit"), WeaponsLayout, 1, 1);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   322
		gbTBLayout->addWidget(groupWeapons);
b600b0d9408c Reorganize widgets on options page
unc0rr
parents: 1194
diff changeset
   323
	}
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   324
1193
2911384169b4 Finish iconed groupbox implementation
unc0rr
parents: 1192
diff changeset
   325
	AGGroupBox = new IconedGroupBox(this);
2911384169b4 Finish iconed groupbox implementation
unc0rr
parents: 1192
diff changeset
   326
	AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png"));
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   327
	AGGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   328
	AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options"));
693
32a546d1eb3e prepare weapons combo
displacer
parents: 692
diff changeset
   329
	pageLayout->addWidget(AGGroupBox, 2, 1);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   330
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   331
	QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox);
436
3f806cadb4e3 Fix runtime warning
unc0rr
parents: 427
diff changeset
   332
	QHBoxLayout * GBAreslayout = new QHBoxLayout(0);
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   333
	QLabel * resolution = new QLabel(AGGroupBox);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   334
	resolution->setText(QLabel::tr("Resolution"));
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   335
	GBAreslayout->addWidget(resolution);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   336
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   337
	CBResolution = new QComboBox(AGGroupBox);
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   338
	GBAreslayout->addWidget(CBResolution);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   339
	GBAlayout->addLayout(GBAreslayout);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   340
436
3f806cadb4e3 Fix runtime warning
unc0rr
parents: 427
diff changeset
   341
	QHBoxLayout * GBAfpslayout = new QHBoxLayout(0);
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   342
	QLabel * maxfps = new QLabel(AGGroupBox);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   343
	maxfps->setText(QLabel::tr("FPS limit"));
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   344
	GBAfpslayout->addWidget(maxfps);
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   345
	GBAlayout->addLayout(GBAfpslayout);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   346
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   347
	CBFullscreen = new QCheckBox(AGGroupBox);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   348
	CBFullscreen->setText(QCheckBox::tr("Fullscreen"));
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   349
	GBAlayout->addWidget(CBFullscreen);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   350
1162
91bf5e3e558d Frontend Fullscreen mode added
displacer
parents: 1157
diff changeset
   351
	CBFrontendFullscreen = new QCheckBox(AGGroupBox);
91bf5e3e558d Frontend Fullscreen mode added
displacer
parents: 1157
diff changeset
   352
	CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen"));
91bf5e3e558d Frontend Fullscreen mode added
displacer
parents: 1157
diff changeset
   353
	GBAlayout->addWidget(CBFrontendFullscreen);
91bf5e3e558d Frontend Fullscreen mode added
displacer
parents: 1157
diff changeset
   354
1157
c2e02c52dcad Try to modify QGroupBox view
unc0rr
parents: 1153
diff changeset
   355
	CBEnableSound = new QCheckBox(AGGroupBox);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   356
	CBEnableSound->setText(QCheckBox::tr("Enable sound"));
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   357
	GBAlayout->addWidget(CBEnableSound);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   358
1157
c2e02c52dcad Try to modify QGroupBox view
unc0rr
parents: 1153
diff changeset
   359
	CBEnableMusic = new QCheckBox(AGGroupBox);
1129
b74ffca22762 Add a checkbox in frontend to turn music off
unc0rr
parents: 1066
diff changeset
   360
	CBEnableMusic->setText(QCheckBox::tr("Enable music"));
b74ffca22762 Add a checkbox in frontend to turn music off
unc0rr
parents: 1066
diff changeset
   361
	GBAlayout->addWidget(CBEnableMusic);
b74ffca22762 Add a checkbox in frontend to turn music off
unc0rr
parents: 1066
diff changeset
   362
297
279e10ec31b4 'Show FPS' and 'FPS limit' options
unc0rr
parents: 290
diff changeset
   363
	CBShowFPS = new QCheckBox(AGGroupBox);
279e10ec31b4 'Show FPS' and 'FPS limit' options
unc0rr
parents: 290
diff changeset
   364
	CBShowFPS->setText(QCheckBox::tr("Show FPS"));
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   365
	GBAlayout->addWidget(CBShowFPS);
297
279e10ec31b4 'Show FPS' and 'FPS limit' options
unc0rr
parents: 290
diff changeset
   366
529
812682c1ab62 Option for alternative damage tags
unc0rr
parents: 492
diff changeset
   367
	CBAltDamage = new QCheckBox(AGGroupBox);
812682c1ab62 Option for alternative damage tags
unc0rr
parents: 492
diff changeset
   368
	CBAltDamage->setText(QCheckBox::tr("Alternative damage show"));
812682c1ab62 Option for alternative damage tags
unc0rr
parents: 492
diff changeset
   369
	GBAlayout->addWidget(CBAltDamage);
812682c1ab62 Option for alternative damage tags
unc0rr
parents: 492
diff changeset
   370
297
279e10ec31b4 'Show FPS' and 'FPS limit' options
unc0rr
parents: 290
diff changeset
   371
	fpsedit = new FPSEdit(AGGroupBox);
427
b505012a3f15 New widgets layout on PageOptions
unc0rr
parents: 421
diff changeset
   372
	GBAfpslayout->addWidget(fpsedit);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   373
1157
c2e02c52dcad Try to modify QGroupBox view
unc0rr
parents: 1153
diff changeset
   374
	BtnSaveOptions = addButton(":/res/Save.png", pageLayout, 4, 2, true);
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   375
	BtnSaveOptions->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}");
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   376
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   377
	BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   378
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   379
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   380
PageNet::PageNet(QWidget* parent) : AbstractPage(parent)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   381
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   382
	QFont * font14 = new QFont("MS Shell Dlg", 14);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   383
	QGridLayout * pageLayout = new QGridLayout(this);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   384
	pageLayout->setColumnStretch(0, 1);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   385
	pageLayout->setColumnStretch(1, 1);
617
127510b442ca Better Net page
unc0rr
parents: 612
diff changeset
   386
	pageLayout->setColumnStretch(2, 1);
421
ebd79d171804 - Remake net game page
unc0rr
parents: 416
diff changeset
   387
ebd79d171804 - Remake net game page
unc0rr
parents: 416
diff changeset
   388
	BtnNetSvrStart = new QPushButton(this);
ebd79d171804 - Remake net game page
unc0rr
parents: 416
diff changeset
   389
	BtnNetSvrStart->setFont(*font14);
ebd79d171804 - Remake net game page
unc0rr
parents: 416
diff changeset
   390
	BtnNetSvrStart->setText(QPushButton::tr("Start server"));
1415
6fbfee0e113a Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents: 1409
diff changeset
   391
	BtnNetSvrStart->setVisible(haveServer);
1395
46fd70de89e2 Add "Join official server" button
unc0rr
parents: 1389
diff changeset
   392
	pageLayout->addWidget(BtnNetSvrStart, 4, 2);
46fd70de89e2 Add "Join official server" button
unc0rr
parents: 1389
diff changeset
   393
46fd70de89e2 Add "Join official server" button
unc0rr
parents: 1389
diff changeset
   394
	BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   395
632
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   396
	ConnGroupBox = new QGroupBox(this);
421
ebd79d171804 - Remake net game page
unc0rr
parents: 416
diff changeset
   397
	ConnGroupBox->setTitle(QGroupBox::tr("Net game"));
ebd79d171804 - Remake net game page
unc0rr
parents: 416
diff changeset
   398
	pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3);
632
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   399
	GBClayout = new QGridLayout(ConnGroupBox);
646
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   400
	GBClayout->setColumnStretch(0, 1);
421
ebd79d171804 - Remake net game page
unc0rr
parents: 416
diff changeset
   401
	GBClayout->setColumnStretch(1, 1);
ebd79d171804 - Remake net game page
unc0rr
parents: 416
diff changeset
   402
	GBClayout->setColumnStretch(2, 1);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   403
632
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   404
	BtnNetConnect = new QPushButton(ConnGroupBox);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   405
	BtnNetConnect->setFont(*font14);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   406
	BtnNetConnect->setText(QPushButton::tr("Connect"));
646
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   407
	GBClayout->addWidget(BtnNetConnect, 2, 2);
416
595d8663254d update button for udp servers list
displacer
parents: 412
diff changeset
   408
665
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 659
diff changeset
   409
	tvServersList = new QTableView(ConnGroupBox);
671
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   410
	tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows);
665
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 659
diff changeset
   411
	GBClayout->addWidget(tvServersList, 1, 0, 1, 3);
421
ebd79d171804 - Remake net game page
unc0rr
parents: 416
diff changeset
   412
632
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   413
	BtnUpdateSList = new QPushButton(ConnGroupBox);
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   414
	BtnUpdateSList->setFont(*font14);
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   415
	BtnUpdateSList->setText(QPushButton::tr("Update"));
646
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   416
	GBClayout->addWidget(BtnUpdateSList, 2, 0);
314
83773ccf4f09 client/server net pre-alpha
displacer
parents: 311
diff changeset
   417
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents: 647
diff changeset
   418
	BtnSpecifyServer = new QPushButton(ConnGroupBox);
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents: 647
diff changeset
   419
	BtnSpecifyServer->setFont(*font14);
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents: 647
diff changeset
   420
	BtnSpecifyServer->setText(QPushButton::tr("Specify"));
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents: 647
diff changeset
   421
	GBClayout->addWidget(BtnSpecifyServer, 2, 1);
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents: 647
diff changeset
   422
1395
46fd70de89e2 Add "Join official server" button
unc0rr
parents: 1389
diff changeset
   423
	BtnOfficialServer = new QPushButton(ConnGroupBox);
46fd70de89e2 Add "Join official server" button
unc0rr
parents: 1389
diff changeset
   424
	BtnOfficialServer->setFont(*font14);
46fd70de89e2 Add "Join official server" button
unc0rr
parents: 1389
diff changeset
   425
	BtnOfficialServer->setText(QPushButton::tr("Join official server"));
46fd70de89e2 Add "Join official server" button
unc0rr
parents: 1389
diff changeset
   426
	GBClayout->addWidget(BtnOfficialServer, 3, 0, 1, 3);
636
dc93ac775bb9 - Switch between local and internet game
unc0rr
parents: 632
diff changeset
   427
668
0d7683a66d61 - Share much code between models
unc0rr
parents: 667
diff changeset
   428
	connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect()));
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   429
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   430
646
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   431
void PageNet::updateServersList()
632
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   432
{
1310
4616e15d566f Get rid of "internet" network game mode
unc0rr
parents: 1290
diff changeset
   433
	tvServersList->setModel(new HWNetUdpModel(tvServersList));
659
5eafb20566f1 - Fix some stupid object casts
unc0rr
parents: 657
diff changeset
   434
673
bd82104a28af - Save after save now works
unc0rr
parents: 672
diff changeset
   435
	tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
bd82104a28af - Save after save now works
unc0rr
parents: 672
diff changeset
   436
665
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 659
diff changeset
   437
	static_cast<HWNetServersModel *>(tvServersList->model())->updateList();
632
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   438
665
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 659
diff changeset
   439
	connect(BtnUpdateSList, SIGNAL(clicked()), static_cast<HWNetServersModel *>(tvServersList->model()), SLOT(updateList()));
671
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   440
	connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect()));
646
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   441
}
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   442
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   443
void PageNet::slotConnect()
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   444
{
671
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   445
	HWNetServersModel * model = static_cast<HWNetServersModel *>(tvServersList->model());
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   446
	QModelIndex mi = tvServersList->currentIndex();
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   447
	if(!mi.isValid())
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   448
	{
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   449
		QMessageBox::information(this, tr("Error"), tr("Please, select server from the list above"));
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   450
		return;
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   451
	}
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   452
	QString host = model->index(mi.row(), 1).data().toString();
a8970859f50e Actually pass host and port values to NetConnect method
unc0rr
parents: 668
diff changeset
   453
	quint16 port = model->index(mi.row(), 2).data().toUInt();
672
08ed55ea1e2a - Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents: 671
diff changeset
   454
08ed55ea1e2a - Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents: 671
diff changeset
   455
	emit connectClicked(host, port);
646
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   456
}
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   457
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   458
PageNetServer::PageNetServer(QWidget* parent) : AbstractPage(parent)
646
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   459
{
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   460
	QFont * font14 = new QFont("MS Shell Dlg", 14);
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   461
	QGridLayout * pageLayout = new QGridLayout(this);
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   462
	pageLayout->setColumnStretch(0, 1);
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   463
	pageLayout->setColumnStretch(1, 1);
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   464
	pageLayout->setColumnStretch(2, 1);
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   465
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   466
	pageLayout->setRowStretch(0, 1);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   467
	pageLayout->setRowStretch(1, 0);
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   468
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   469
	BtnBack =addButton(":/res/Exit.png", pageLayout, 1, 0, true);
646
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   470
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   471
	BtnStart = new QPushButton(this);
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   472
	BtnStart->setFont(*font14);
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   473
	BtnStart->setText(QPushButton::tr("Start"));
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   474
	pageLayout->addWidget(BtnStart, 1, 2);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   475
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   476
	QWidget * wg = new QWidget(this);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   477
	pageLayout->addWidget(wg, 0, 0, 1, 3);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   478
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   479
	QGridLayout * wgLayout = new QGridLayout(wg);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   480
	wgLayout->setColumnStretch(0, 1);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   481
	wgLayout->setColumnStretch(1, 3);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   482
	wgLayout->setColumnStretch(2, 1);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   483
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   484
	wgLayout->setRowStretch(0, 0);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   485
	wgLayout->setRowStretch(1, 1);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   486
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   487
	QGroupBox * gb = new QGroupBox(wg);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   488
	wgLayout->addWidget(gb, 0, 1);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   489
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   490
	QGridLayout * gbLayout = new QGridLayout(gb);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   491
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   492
	labelSD = new QLabel(gb);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   493
	labelSD->setText(QLabel::tr("Server name:"));
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   494
	gbLayout->addWidget(labelSD, 0, 0);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   495
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   496
	leServerDescr = new QLineEdit(gb);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   497
	gbLayout->addWidget(leServerDescr, 0, 1);
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   498
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   499
	labelPort = new QLabel(gb);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   500
	labelPort->setText(QLabel::tr("Server port:"));
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   501
	gbLayout->addWidget(labelPort, 1, 0);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   502
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   503
	sbPort = new QSpinBox(gb);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   504
	sbPort->setMinimum(0);
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   505
	sbPort->setMaximum(65535);
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   506
	gbLayout->addWidget(sbPort, 1, 1);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   507
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   508
	BtnDefault = new QPushButton(gb);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   509
	BtnDefault->setText(QPushButton::tr("default"));
675
28e294a496cb Remake widgets layout on PageNetServer
unc0rr
parents: 673
diff changeset
   510
	gbLayout->addWidget(BtnDefault, 1, 2);
657
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   511
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   512
	connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort()));
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   513
}
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   514
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   515
void PageNetServer::setDefaultPort()
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   516
{
b34fc518a48a Basic concept for net server options page (subject to change)
unc0rr
parents: 653
diff changeset
   517
	sbPort->setValue(46631);
632
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   518
}
5e09ae25729f Half implement possibility for different backends of servers list
unc0rr
parents: 617
diff changeset
   519
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   520
PageNetGame::PageNetGame(QWidget* parent) : AbstractPage(parent)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   521
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   522
	QFont * font14 = new QFont("MS Shell Dlg", 14);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   523
	QGridLayout * pageLayout = new QGridLayout(this);
452
45fbb9df0c99 problems with widget sizes for net chat
displacer
parents: 451
diff changeset
   524
	pageLayout->setSizeConstraint(QLayout::SetMinimumSize);
461
105af110b0e6 chatWidget with layout
displacer
parents: 453
diff changeset
   525
	//pageLayout->setSpacing(1);
463
353c2f830888 fixes last commit problems
displacer
parents: 461
diff changeset
   526
	pageLayout->setColumnStretch(0, 50);
353c2f830888 fixes last commit problems
displacer
parents: 461
diff changeset
   527
	pageLayout->setColumnStretch(1, 50);
322
e7175ae57945 first new widgets added to net game
displacer
parents: 314
diff changeset
   528
461
105af110b0e6 chatWidget with layout
displacer
parents: 453
diff changeset
   529
	// chatwidget
105af110b0e6 chatWidget with layout
displacer
parents: 453
diff changeset
   530
	pChatWidget = new HWChatWidget(this);
1409
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   531
	pageLayout->addWidget(pChatWidget, 1, 0, 2, 1);
464
7f48321fc38a vertical size fix for chatwidget
displacer
parents: 463
diff changeset
   532
	pageLayout->setRowStretch(1, 100);
453
4b1236759402 simple net cha added
displacer
parents: 452
diff changeset
   533
329
4c3aad46baa5 Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents: 323
diff changeset
   534
	pGameCFG = new GameCFGWidget(this);
322
e7175ae57945 first new widgets added to net game
displacer
parents: 314
diff changeset
   535
	pageLayout->addWidget(pGameCFG, 0, 0);
329
4c3aad46baa5 Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents: 323
diff changeset
   536
4c3aad46baa5 Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents: 323
diff changeset
   537
	pNetTeamsWidget = new TeamSelWidget(this);
373
df912aab6b7e network team add can be denied by server
displacer
parents: 336
diff changeset
   538
	pNetTeamsWidget->setAcceptOuter(true);
461
105af110b0e6 chatWidget with layout
displacer
parents: 453
diff changeset
   539
	pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   540
646
ed610c2cd0a4 Some work on network widgets
unc0rr
parents: 638
diff changeset
   541
	BtnGo = new QPushButton(this);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   542
	BtnGo->setFont(*font14);
1404
2b6b6809c2e4 - Fix a bug in READY message handling
unc0rr
parents: 1400
diff changeset
   543
	BtnGo->setText(QPushButton::tr("Ready"));
1409
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   544
	pageLayout->addWidget(BtnGo, 3, 1);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   545
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   546
	BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   547
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   548
	BtnMaster = addButton(tr("Control"), pageLayout, 2, 1);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   549
	QMenu * menu = new QMenu(BtnMaster);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   550
	startGame = new QAction(QAction::tr("Start"), menu);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   551
	restrictJoins = new QAction(QAction::tr("Restrict Joins"), menu);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   552
	restrictJoins->setCheckable(true);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   553
	restrictTeamAdds = new QAction(QAction::tr("Restrict Team Additions"), menu);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   554
	restrictTeamAdds->setCheckable(true);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   555
	menu->addAction(startGame);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   556
	menu->addAction(restrictJoins);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   557
	menu->addAction(restrictTeamAdds);
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   558
	
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1404
diff changeset
   559
	BtnMaster->setMenu(menu);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   560
}
187
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   561
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   562
PageInfo::PageInfo(QWidget* parent) : AbstractPage(parent)
187
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   563
{
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   564
	QFont * font14 = new QFont("MS Shell Dlg", 14);
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   565
	QGridLayout * pageLayout = new QGridLayout(this);
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   566
	pageLayout->setColumnStretch(0, 1);
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   567
	pageLayout->setColumnStretch(1, 1);
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   568
	pageLayout->setColumnStretch(2, 1);
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   569
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   570
	BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
187
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   571
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   572
	about = new About(this);
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   573
	pageLayout->addWidget(about, 0, 0, 1, 3);
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents: 184
diff changeset
   574
}
306
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   575
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   576
PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent)
306
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   577
{
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   578
	QFont * font14 = new QFont("MS Shell Dlg", 14);
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   579
	QGridLayout * pageLayout = new QGridLayout(this);
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   580
	pageLayout->setColumnStretch(0, 1);
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   581
	pageLayout->setColumnStretch(1, 1);
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   582
	pageLayout->setColumnStretch(2, 1);
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   583
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   584
	BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
306
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   585
307
96b428ac11f2 More statistics
unc0rr
parents: 306
diff changeset
   586
	labelGameStats = new QLabel(this);
96b428ac11f2 More statistics
unc0rr
parents: 306
diff changeset
   587
	labelGameStats->setTextFormat(Qt::RichText);
96b428ac11f2 More statistics
unc0rr
parents: 306
diff changeset
   588
	pageLayout->addWidget(labelGameStats, 0, 0, 1, 3);
306
7b61834edcf6 - Better blowtorch
unc0rr
parents: 297
diff changeset
   589
}
586
ecb6347dfeca Prepare to new page 'Training'
unc0rr
parents: 585
diff changeset
   590
1150
ae86e36dad2e - Make look better
unc0rr
parents: 1149
diff changeset
   591
PageSinglePlayer::PageSinglePlayer(QWidget* parent) : AbstractPage(parent)
586
ecb6347dfeca Prepare to new page 'Training'
unc0rr
parents: 585
diff changeset
   592
{
ecb6347dfeca Prepare to new page 'Training'
unc0rr
parents: 585
diff changeset
   593
	QFont * font14 = new QFont("MS Shell Dlg", 14);
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   594
	QVBoxLayout * vLayout = new QVBoxLayout(this);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   595
	QHBoxLayout * topLine = new QHBoxLayout();
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   596
	QHBoxLayout * middleLine = new QHBoxLayout();
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   597
	QHBoxLayout * bottomLine = new QHBoxLayout();
1444
06f6ae457a2f Finish reorganizing local game page
unc0rr
parents: 1443
diff changeset
   598
	vLayout->addStretch();
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   599
	vLayout->addLayout(topLine);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   600
	vLayout->addLayout(middleLine);
1444
06f6ae457a2f Finish reorganizing local game page
unc0rr
parents: 1443
diff changeset
   601
	vLayout->addStretch();
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   602
	vLayout->addLayout(bottomLine);
586
ecb6347dfeca Prepare to new page 'Training'
unc0rr
parents: 585
diff changeset
   603
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   604
	BtnSimpleGamePage = addButton(":/res/SimpleGame.png", topLine, 0, true);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   605
	BtnMultiplayer = addButton(":/res/Multiplayer.png", topLine, 1, true);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   606
//	pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   607
	BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 0, true);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   608
	
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   609
	BtnBack = addButton(":/res/Exit.png", bottomLine, 0, true);
1444
06f6ae457a2f Finish reorganizing local game page
unc0rr
parents: 1443
diff changeset
   610
	bottomLine->addStretch();
06f6ae457a2f Finish reorganizing local game page
unc0rr
parents: 1443
diff changeset
   611
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   612
	BtnDemos = addButton(tr(":/res/Record.png"), bottomLine, 1, true);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   613
	BtnLoad = addButton(":/res/Save.png", bottomLine, 2, true);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   614
	BtnLoad->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}");
586
ecb6347dfeca Prepare to new page 'Training'
unc0rr
parents: 585
diff changeset
   615
}
ecb6347dfeca Prepare to new page 'Training'
unc0rr
parents: 585
diff changeset
   616
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   617
PageTraining::PageTraining(QWidget* parent) : AbstractPage(parent)
587
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   618
{
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   619
	QFont * font14 = new QFont("MS Shell Dlg", 14);
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   620
	QGridLayout * pageLayout = new QGridLayout(this);
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   621
	pageLayout->setColumnStretch(0, 1);
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   622
	pageLayout->setColumnStretch(1, 2);
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   623
	pageLayout->setColumnStretch(2, 1);
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   624
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   625
	BtnStartTrain = new QPushButton(this);
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   626
	BtnStartTrain->setFont(*font14);
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   627
	BtnStartTrain->setText(QPushButton::tr("Go!"));
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   628
	pageLayout->addWidget(BtnStartTrain, 1, 2);
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   629
1153
825931b81ad4 Iconed "Back" button everywhere
unc0rr
parents: 1152
diff changeset
   630
	BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
587
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   631
}
74db4115064a More work on Training mode
unc0rr
parents: 586
diff changeset
   632
923
b3d097097b54 Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents: 788
diff changeset
   633
PageSelectWeapon::PageSelectWeapon(QWidget* parent) :
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
   634
  AbstractPage(parent)
600
f6e5f4e122db Select weapon scheme page
unc0rr
parents: 597
diff changeset
   635
{
f6e5f4e122db Select weapon scheme page
unc0rr
parents: 597
diff changeset
   636
	QGridLayout * pageLayout = new QGridLayout(this);
923
b3d097097b54 Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents: 788
diff changeset
   637
	
1168
f3c68684ef88 Finally fix save button look
unc0rr
parents: 1162
diff changeset
   638
	pWeapons = new SelWeaponWidget(cDefaultAmmoStore->size() - 10, this);
718
f93a38d2c982 delete weapon button added
displacer
parents: 696
diff changeset
   639
	pageLayout->addWidget(pWeapons, 0, 0, 1, 4);
600
f6e5f4e122db Select weapon scheme page
unc0rr
parents: 597
diff changeset
   640
1168
f3c68684ef88 Finally fix save button look
unc0rr
parents: 1162
diff changeset
   641
	BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
730
6ac11b0aeb12 tr()s everywhere
displacer
parents: 728
diff changeset
   642
	BtnDefault = addButton(tr("Default"), pageLayout, 1, 1);
6ac11b0aeb12 tr()s everywhere
displacer
parents: 728
diff changeset
   643
	BtnDelete = addButton(tr("Delete"), pageLayout, 1, 2);
1168
f3c68684ef88 Finally fix save button look
unc0rr
parents: 1162
diff changeset
   644
	BtnSave = addButton(":/res/Save.png", pageLayout, 1, 3, true);
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1440
diff changeset
   645
	BtnSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}");	
600
f6e5f4e122db Select weapon scheme page
unc0rr
parents: 597
diff changeset
   646
}
f6e5f4e122db Select weapon scheme page
unc0rr
parents: 597
diff changeset
   647
1249
b6670a6ea2d0 Remove 25pix margin on every page, so exit button is almost in the same place on all pages
unc0rr
parents: 1240
diff changeset
   648
PageInGame::PageInGame(QWidget* parent) :
686
494b5880989a - Header cleanup in game.cpp
unc0rr
parents: 684
diff changeset
   649
  AbstractPage(parent)
494b5880989a - Header cleanup in game.cpp
unc0rr
parents: 684
diff changeset
   650
{
494b5880989a - Header cleanup in game.cpp
unc0rr
parents: 684
diff changeset
   651
	QLabel * label = new QLabel(this);
494b5880989a - Header cleanup in game.cpp
unc0rr
parents: 684
diff changeset
   652
	label->setText("In game...");
494b5880989a - Header cleanup in game.cpp
unc0rr
parents: 684
diff changeset
   653
}
1311
49beb1221c0b - Add stub page for rooms list
unc0rr
parents: 1310
diff changeset
   654
49beb1221c0b - Add stub page for rooms list
unc0rr
parents: 1310
diff changeset
   655
PageRoomsList::PageRoomsList(QWidget* parent) :
49beb1221c0b - Add stub page for rooms list
unc0rr
parents: 1310
diff changeset
   656
  AbstractPage(parent)
49beb1221c0b - Add stub page for rooms list
unc0rr
parents: 1310
diff changeset
   657
{
1312
0078e4f72d40 Create a page for rooms list
unc0rr
parents: 1311
diff changeset
   658
	QGridLayout * pageLayout = new QGridLayout(this);
1314
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   659
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   660
	roomName = new QLineEdit(this);
1334
b58afaadf7ae Send team removal message to others in room when client disconnects
unc0rr
parents: 1315
diff changeset
   661
	roomName->setMaxLength(60);
1314
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   662
	pageLayout->addWidget(roomName, 0, 0);
1399
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   663
	
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   664
	roomsList = new QTableWidget(this);
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   665
	roomsList->setColumnCount(3);
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   666
	roomsList->setSelectionBehavior(QAbstractItemView::SelectRows);
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   667
	roomsList->verticalHeader()->setVisible(false);
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   668
	roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   669
	roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   670
	
1314
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   671
	pageLayout->addWidget(roomsList, 1, 0, 3, 1);
1377
a9e768739345 - Customize QTextBrowser look
unc0rr
parents: 1334
diff changeset
   672
	serverMessage = new QTextBrowser(this);
a9e768739345 - Customize QTextBrowser look
unc0rr
parents: 1334
diff changeset
   673
	serverMessage->setOpenExternalLinks(true);
a9e768739345 - Customize QTextBrowser look
unc0rr
parents: 1334
diff changeset
   674
	pageLayout->addWidget(serverMessage, 4, 0, 1, 2);
1312
0078e4f72d40 Create a page for rooms list
unc0rr
parents: 1311
diff changeset
   675
	
1377
a9e768739345 - Customize QTextBrowser look
unc0rr
parents: 1334
diff changeset
   676
	BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true);
1312
0078e4f72d40 Create a page for rooms list
unc0rr
parents: 1311
diff changeset
   677
	BtnCreate = addButton(tr("Create"), pageLayout, 0, 1);
0078e4f72d40 Create a page for rooms list
unc0rr
parents: 1311
diff changeset
   678
	BtnJoin = addButton(tr("Join"), pageLayout, 1, 1);
0078e4f72d40 Create a page for rooms list
unc0rr
parents: 1311
diff changeset
   679
	BtnRefresh = addButton(tr("Refresh"), pageLayout, 2, 1);
1314
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   680
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   681
	connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick()));
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   682
	connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick()));
1315
c2f09811bb8c Implement rooms list refresh
unc0rr
parents: 1314
diff changeset
   683
	connect(BtnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClick()));
1314
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   684
	connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick()));
1311
49beb1221c0b - Add stub page for rooms list
unc0rr
parents: 1310
diff changeset
   685
}
1313
f4c54e9e1b8c - Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents: 1312
diff changeset
   686
1377
a9e768739345 - Customize QTextBrowser look
unc0rr
parents: 1334
diff changeset
   687
1313
f4c54e9e1b8c - Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents: 1312
diff changeset
   688
void PageRoomsList::setRoomsList(const QStringList & list)
f4c54e9e1b8c - Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents: 1312
diff changeset
   689
{
f4c54e9e1b8c - Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents: 1312
diff changeset
   690
	roomsList->clear();
1399
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   691
	roomsList->setHorizontalHeaderLabels(
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   692
			QStringList() <<
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   693
			QTableWidget::tr("Room name") <<
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   694
			QTableWidget::tr("Players number") <<
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   695
			QTableWidget::tr("Round in progress")
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   696
			);
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   697
	
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   698
	if (list.size() % 3)
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   699
		return;
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   700
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   701
	roomsList->setRowCount(list.size() / 3);
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   702
	for(int i = 0; i < list.size(); i += 3)
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   703
		for(int t = 0; t < 3; t++)
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   704
		{
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   705
			QTableWidgetItem * item = new QTableWidgetItem(list[i + t]);
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   706
			item->setFlags(Qt::ItemIsSelectable);
1400
8196ce1d9be1 Fix rooms list
unc0rr
parents: 1399
diff changeset
   707
			roomsList->setItem(i / 3, t, item);
1399
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   708
		}
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   709
	//roomsList->resizeColumnsToContents();
1313
f4c54e9e1b8c - Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents: 1312
diff changeset
   710
}
1314
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   711
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   712
void PageRoomsList::onCreateClick()
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   713
{
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   714
	if (roomName->text().size())
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   715
		emit askForCreateRoom(roomName->text());
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   716
	else
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   717
		QMessageBox::critical(this,
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   718
				tr("Error"),
1315
c2f09811bb8c Implement rooms list refresh
unc0rr
parents: 1314
diff changeset
   719
				tr("Please, enter room name"),
1314
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   720
				tr("OK"));
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   721
}
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   722
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   723
void PageRoomsList::onJoinClick()
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   724
{
1399
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
   725
	QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0);
1314
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   726
	if (!curritem)
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   727
	{
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   728
		QMessageBox::critical(this,
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   729
				tr("Error"),
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   730
				tr("Please, select room from the list"),
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   731
				tr("OK"));
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   732
		return ;
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   733
	}
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   734
	emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString());
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   735
}
e56b178d6d62 Implement room create and join
unc0rr
parents: 1313
diff changeset
   736
1315
c2f09811bb8c Implement rooms list refresh
unc0rr
parents: 1314
diff changeset
   737
void PageRoomsList::onRefreshClick()
c2f09811bb8c Implement rooms list refresh
unc0rr
parents: 1314
diff changeset
   738
{
c2f09811bb8c Implement rooms list refresh
unc0rr
parents: 1314
diff changeset
   739
	emit askForRoomList();
c2f09811bb8c Implement rooms list refresh
unc0rr
parents: 1314
diff changeset
   740
}
c2f09811bb8c Implement rooms list refresh
unc0rr
parents: 1314
diff changeset
   741