QTfrontend/gamecfgwidget.cpp
author displacer
Thu, 11 Jan 2007 22:04:08 +0000
changeset 317 e95340dbfc1d
parent 312 c36d0b34ac3d
child 318 46a43b02bbb3
permissions -rw-r--r--
start all clients
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     1
/*
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     2
 * Hedgewars, a worms-like game
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     3
 * Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
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 <QResizeEvent>
218
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    20
#include <QGroupBox>
311
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    21
#include <QCheckBox>
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    22
#include <QGridLayout>
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    23
#include <QSpinBox>
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    24
#include <QLabel>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    25
#include "gamecfgwidget.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    26
218
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    27
GameCFGWidget::GameCFGWidget(QWidget* parent) :
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    28
  QWidget(parent), mainLayout(this)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    29
{
240
c7f0a4f7a54a Better-looking multiplayer page
unc0rr
parents: 218
diff changeset
    30
	mainLayout.setMargin(0);
218
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    31
	QGroupBox *GBoxMap = new QGroupBox(this);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    32
	GBoxMap->setTitle(QGroupBox::tr("Landscape"));
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    33
	GBoxMap->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    34
	mainLayout.addWidget(GBoxMap);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    35
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    36
	QHBoxLayout *GBoxMapLayout = new QHBoxLayout(GBoxMap);
240
c7f0a4f7a54a Better-looking multiplayer page
unc0rr
parents: 218
diff changeset
    37
	GBoxMapLayout->setMargin(0);
218
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    38
	pMapContainer = new HWMapContainer(GBoxMap);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    39
	GBoxMapLayout->addWidget(new QWidget);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    40
	GBoxMapLayout->addWidget(pMapContainer);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    41
	GBoxMapLayout->addWidget(new QWidget);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    42
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    43
	QGroupBox *GBoxOptions = new QGroupBox(this);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    44
	GBoxOptions->setTitle(QGroupBox::tr("Game scheme"));
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    45
	GBoxOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    46
	mainLayout.addWidget(GBoxOptions);
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    47
311
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    48
	QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions);
218
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    49
	CB_mode_Forts = new QCheckBox(GBoxOptions);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    50
	CB_mode_Forts->setText(QCheckBox::tr("Forts mode"));
311
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    51
	GBoxOptionsLayout->addWidget(CB_mode_Forts, 0, 0, 1, 2);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    52
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    53
	L_TurnTime = new QLabel(QLabel::tr("Turn time"), GBoxOptions);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    54
	L_InitHealth = new QLabel(QLabel::tr("Initial health"), GBoxOptions);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    55
	GBoxOptionsLayout->addWidget(L_TurnTime, 1, 0);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    56
	GBoxOptionsLayout->addWidget(L_InitHealth, 2, 0);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    57
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    58
	SB_TurnTime = new QSpinBox(GBoxOptions);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    59
	SB_TurnTime->setRange(15, 90);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    60
	SB_TurnTime->setValue(45);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    61
	SB_TurnTime->setSingleStep(15);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    62
	SB_InitHealth = new QSpinBox(GBoxOptions);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    63
	SB_InitHealth->setRange(50, 200);
312
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
    64
	SB_InitHealth->setValue(100);
311
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    65
	SB_InitHealth->setSingleStep(25);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    66
	GBoxOptionsLayout->addWidget(SB_TurnTime, 1, 1);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 249
diff changeset
    67
	GBoxOptionsLayout->addWidget(SB_InitHealth, 2, 1);
218
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    68
6e64db60222c Better-looking game config widget
unc0rr
parents: 184
diff changeset
    69
	mainLayout.addWidget(new QWidget, 100);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    70
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    71
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    72
quint32 GameCFGWidget::getGameFlags()
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    73
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    74
	quint32 result = 0;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    75
	if (CB_mode_Forts->isChecked())
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    76
		result |= 1;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    77
	return result;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    78
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    79
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    80
QString GameCFGWidget::getCurrentSeed() const
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    81
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    82
  return pMapContainer->getCurrentSeed();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    83
}
249
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    84
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    85
QString GameCFGWidget::getCurrentMap() const
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    86
{
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    87
  return pMapContainer->getCurrentMap();
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    88
}
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    89
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    90
QString GameCFGWidget::getCurrentTheme() const
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    91
{
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    92
  return pMapContainer->getCurrentTheme();
ff85fa029541 map choose from files added
displacer
parents: 240
diff changeset
    93
}
312
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
    94
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
    95
quint32 GameCFGWidget::getInitHealth() const
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
    96
{
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
    97
	return SB_InitHealth->value();
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
    98
}
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
    99
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
   100
quint32 GameCFGWidget::getTurnTime() const
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
   101
{
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
   102
	return SB_TurnTime->value();
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 311
diff changeset
   103
}