QTfrontend/hwform.cpp
author displacer
Sun, 15 Jan 2006 23:31:34 +0000
changeset 50 9ab4067dabec
parent 45 1072e7fe85c8
child 52 ae2950c5465c
permissions -rw-r--r--
TeamSelect widget alpha added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     1
/*
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     2
 * Hedgewars, a worms-like game
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     3
 * Copyright (c) 2005 Andrey Korotaev <unC0Rr@gmail.com>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     4
 *
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     5
 * Distributed under the terms of the BSD-modified licence:
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     6
 *
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     8
 * of this software and associated documentation files (the "Software"), to deal
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     9
 * with the Software without restriction, including without limitation the
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    10
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    11
 * sell copies of the Software, and to permit persons to whom the Software is
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    12
 * furnished to do so, subject to the following conditions:
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    13
 *
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    14
 * 1. Redistributions of source code must retain the above copyright notice,
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    15
 *    this list of conditions and the following disclaimer.
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    16
 * 2. Redistributions in binary form must reproduce the above copyright notice,
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    17
 *    this list of conditions and the following disclaimer in the documentation
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    18
 *    and/or other materials provided with the distribution.
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    19
 * 3. The name of the author may not be used to endorse or promote products
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    20
 *    derived from this software without specific prior written permission.
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    21
 *
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    23
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    24
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    25
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    27
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    28
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    29
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    30
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    31
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    32
 */
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    33
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    34
#include <QtGui>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    35
#include <QStringList>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    36
#include <QProcess>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    37
#include <QDir>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    38
#include <QPixmap>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    39
#include <QRegExp>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    40
#include <QIcon>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    41
#include <QFile>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    42
#include <QTextStream>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    43
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    44
#include "hwform.h"
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    45
#include "sdlkeys.h"
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    46
#include "hwconsts.h"
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    47
//#include "gamecmds.h"
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
    48
#include "teamselect.h"
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    49
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    50
HWForm::HWForm(QWidget *parent)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    51
	: QMainWindow(parent)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    52
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    53
	ui.setupUi(this);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    54
	TeamNameEdit = new QLineEdit(ui.GBoxTeam);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    55
	TeamNameEdit->setGeometry(QRect(10, 20, 141, 20));
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    56
	TeamNameEdit->setMaxLength(15);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    57
	for(int i = 0; i < 8; i++)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    58
	{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    59
		HHNameEdit[i] = new QLineEdit(ui.GBoxHedgehogs);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    60
		HHNameEdit[i]->setGeometry(QRect(10, 20 + i * 30, 141, 20));
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    61
		HHNameEdit[i]->setMaxLength(15);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    62
	}
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    63
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    64
	QStringList binds;
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    65
	for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    66
	{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    67
		binds << sdlkeys[i][1];
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    68
	}
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    69
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    70
	quint16 widind = 0, top = 0;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    71
	for(quint8 i = 0; i < BINDS_NUMBER; i++)
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    72
	{
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    73
		LBind[i] = new QLabel(ui.BindsBox->widget(widind));
41
5d7a505875cd - Fixed crash in IPC code
unc0rr
parents: 37
diff changeset
    74
		LBind[i]->setGeometry(QRect(10, top + 3, 70, 20));
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    75
		LBind[i]->setText(cbinds[i].name);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    76
		LBind[i]->setAlignment(Qt::AlignRight);
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    77
		CBBind[i] = new QComboBox(ui.BindsBox->widget(widind));
41
5d7a505875cd - Fixed crash in IPC code
unc0rr
parents: 37
diff changeset
    78
		CBBind[i]->setGeometry(QRect(90, top, 80, 20));
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    79
		CBBind[i]->addItems(binds);
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    80
		if (cbinds[i].chwidget)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    81
		{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    82
			top = 0;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    83
			widind++;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    84
		} else
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    85
		{
41
5d7a505875cd - Fixed crash in IPC code
unc0rr
parents: 37
diff changeset
    86
			top += 28;
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    87
		}
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    88
	}
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    89
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    90
	QDir tmpdir;
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    91
	tmpdir.cd(DATA_PATH);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    92
	tmpdir.cd("Forts");
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    93
	tmpdir.setFilter(QDir::Files);
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    94
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    95
	ui.CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L.png"), "\\1"));
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    96
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    97
	tmpdir.cd("../Graphics/Graves");
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    98
	QStringList list = tmpdir.entryList(QStringList("*.png"));
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    99
	for (QStringList::Iterator it = list.begin(); it != list.end(); ++it )
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   100
	{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   101
		ui.CBGrave->addItem((*it).replace(QRegExp("^(.*).png"), "\\1"));
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   102
	}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   103
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   104
	cfgdir.setPath(cfgdir.homePath());
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   105
	if (!cfgdir.exists(".hedgewars"))
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   106
	{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   107
		if (!cfgdir.mkdir(".hedgewars"))
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   108
		{
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   109
			QMessageBox::critical(this,
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   110
					tr("Error"),
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 41
diff changeset
   111
					tr("Cannot create directory %1").arg("/.hedgewars"),
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   112
					tr("Quit"));
34
fbe30de53d1d fixed "hang" on first run
unc0rr
parents: 32
diff changeset
   113
			return ;
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   114
		}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   115
	}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   116
	cfgdir.cd(".hedgewars");
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   117
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   118
	list = cfgdir.entryList(QStringList("*.cfg"));
44
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
   119
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
   120
	if(list.empty()) {
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
   121
	  HWTeam defaultTeam("DefaultTeam");
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
   122
	  defaultTeam.SetCfgDir(cfgdir.absolutePath());
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
   123
	  defaultTeam.SaveToFile();
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
   124
	  list.push_back("DefaultTeam");
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
   125
	}
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
   126
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   127
	for (QStringList::Iterator it = list.begin(); it != list.end(); ++it )
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   128
	{
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
   129
	  QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1");
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
   130
	  m_teamNames.push_back(tmpTeamStr);
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
   131
	  ui.CBTeamName->addItem(tmpTeamStr);
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   132
	}
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   133
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   134
	QFile settings(cfgdir.absolutePath() + "/options");
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   135
	if (settings.open(QIODevice::ReadOnly))
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   136
	{
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   137
		QTextStream stream(&settings);
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   138
		stream.setCodec("UTF-8");
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   139
		QString str;
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   140
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   141
		while (!stream.atEnd())
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   142
		{
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   143
			str = stream.readLine();
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   144
			if (str.startsWith(";")) continue;
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   145
			if (str.startsWith("resolution "))
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   146
			{
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   147
				ui.CBResolution->setCurrentIndex(str.mid(11).toLong());
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   148
			} else
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   149
			if (str.startsWith("fullscreen "))
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   150
			{
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   151
				ui.CBFullscreen->setChecked(str.mid(11).toLong());
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   152
			} else
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   153
			if (str.startsWith("nick "))
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   154
			{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   155
				ui.editNetNick->setText(str.mid(5));
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   156
			}
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   157
		}
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   158
		settings.close();
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   159
	}
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   160
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   161
	connect(ui.BtnSPBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   162
	connect(ui.BtnDemosBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   163
	connect(ui.BtnSetupBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   164
	connect(ui.BtnMPBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   165
	connect(ui.BtnNetBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   166
	connect(ui.BtnSinglePlayer,	SIGNAL(clicked()),	this, SLOT(GoToSinglePlayer()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   167
	connect(ui.BtnSetup,	SIGNAL(clicked()),	this, SLOT(GoToSetup()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   168
	connect(ui.BtnMultiplayer,	SIGNAL(clicked()),	this, SLOT(GoToMultiplayer()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   169
	connect(ui.BtnDemos,	SIGNAL(clicked()),	this, SLOT(GoToDemos()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   170
	connect(ui.BtnNet,	SIGNAL(clicked()),	this, SLOT(GoToNet()));
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   171
	connect(ui.BtnNetCFGBack,	SIGNAL(clicked()),	this, SLOT(GoToNetChat()));
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   172
	connect(ui.BtnNewTeam,	SIGNAL(clicked()),	this, SLOT(NewTeam()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   173
	connect(ui.BtnEditTeam,	SIGNAL(clicked()),	this, SLOT(EditTeam()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   174
	connect(ui.BtnTeamSave,	SIGNAL(clicked()),	this, SLOT(TeamSave()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   175
	connect(ui.BtnTeamDiscard,	SIGNAL(clicked()),	this, SLOT(TeamDiscard()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   176
	connect(ui.BtnSimpleGame,	SIGNAL(clicked()),	this, SLOT(SimpleGame()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   177
	connect(ui.BtnSaveOptions,	SIGNAL(clicked()),	this, SLOT(SaveOptions()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   178
	connect(ui.BtnPlayDemo,	SIGNAL(clicked()),	this, SLOT(PlayDemo()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   179
	connect(ui.BtnNetConnect,	SIGNAL(clicked()),	this, SLOT(NetConnect()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   180
	connect(ui.BtnNetChatDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect()));
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   181
	connect(ui.BtnNetChatJoin,	SIGNAL(clicked()),	this, SLOT(NetJoin()));
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   182
	connect(ui.BtnNetChatCreate,	SIGNAL(clicked()),	this, SLOT(NetCreate()));
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   183
	connect(ui.BtnNetCFGAddTeam,	SIGNAL(clicked()),	this, SLOT(NetAddTeam()));
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   184
	connect(ui.BtnNetCFGGo,	SIGNAL(clicked()),	this, SLOT(NetStartGame()));
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   185
	connect(ui.CBGrave,	SIGNAL(activated(const QString &)),	this, SLOT(CBGrave_activated(const QString &)));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   186
	connect(ui.CBFort,	SIGNAL(activated(const QString &)),	this, SLOT(CBFort_activated(const QString &)));
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   187
	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   188
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   189
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   190
void HWForm::GoToMain()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   191
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   192
	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   193
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   194
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   195
void HWForm::GoToSinglePlayer()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   196
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   197
	ui.Pages->setCurrentIndex(ID_PAGE_SINGLEPLAYER);
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
   198
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
   199
	TeamSelWidget* pts=new TeamSelWidget(m_teamNames, ui.Pages->widget(ID_PAGE_SINGLEPLAYER));
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
   200
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
   201
	pts->resize(500, 350);
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
   202
	pts->show();
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   203
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   204
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   205
void HWForm::GoToSetup()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   206
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   207
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   208
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   209
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   210
void HWForm::GoToMultiplayer()
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   211
{
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   212
	ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER);
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   213
}
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   214
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   215
void HWForm::GoToDemos()
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   216
{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   217
	QDir tmpdir;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   218
	tmpdir.cd(DATA_PATH);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   219
	tmpdir.cd("Demos");
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   220
	tmpdir.setFilter(QDir::Files);
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   221
	ui.DemosList->clear();
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   222
	ui.DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_1")).replaceInStrings(QRegExp("^(.*).hwd_1"), "\\1"));
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   223
	ui.Pages->setCurrentIndex(ID_PAGE_DEMOS);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   224
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   225
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   226
void HWForm::GoToNet()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   227
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   228
	ui.Pages->setCurrentIndex(ID_PAGE_NET);
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   229
}
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   230
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   231
void HWForm::GoToNetChat()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   232
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   233
	ui.Pages->setCurrentIndex(ID_PAGE_NETCHAT);
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   234
}
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   235
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   236
void HWForm::NewTeam()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   237
{
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   238
	tmpTeam = new HWTeam("unnamed");
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   239
	tmpTeam->SetCfgDir(cfgdir.absolutePath());
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   240
	tmpTeam->SetToPage(this);
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   241
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   242
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   243
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   244
void HWForm::EditTeam()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   245
{
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   246
	tmpTeam = new HWTeam(ui.CBTeamName->currentText());
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   247
	tmpTeam->SetCfgDir(cfgdir.absolutePath());
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   248
	tmpTeam->LoadFromFile();
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   249
	tmpTeam->SetToPage(this);
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   250
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   251
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   252
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   253
void HWForm::TeamSave()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   254
{
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   255
	tmpTeam->GetFromPage(this);
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   256
	tmpTeam->SaveToFile();
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   257
	delete tmpTeam;
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   258
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   259
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   260
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   261
void HWForm::TeamDiscard()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   262
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   263
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   264
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   265
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   266
void HWForm::SimpleGame()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   267
{
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   268
	game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
45
1072e7fe85c8 DefaultTeam is now default to play with single and network game
displacer
parents: 44
diff changeset
   269
	game->AddTeam("DefaultTeam");
1072e7fe85c8 DefaultTeam is now default to play with single and network game
displacer
parents: 44
diff changeset
   270
	game->AddTeam("DefaultTeam");
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   271
	game->StartLocal();
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   272
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   273
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   274
void HWForm::CBGrave_activated(const QString & gravename)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   275
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   276
	QPixmap pix(QString(DATA_PATH) + "/Graphics/Graves/" + gravename + ".png");
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   277
	ui.GravePreview->setPixmap(pix.copy(0, 0, 32, 32));
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   278
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   279
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   280
void HWForm::CBFort_activated(const QString & fortname)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   281
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   282
	QPixmap pix(QString(DATA_PATH) + "/Forts/" + fortname + "L.png");
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   283
	ui.FortPreview->setPixmap(pix);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   284
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   285
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   286
void HWForm::SaveOptions()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   287
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   288
	QFile settings(cfgdir.absolutePath() + "/options");
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   289
	if (!settings.open(QIODevice::WriteOnly))
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   290
	{
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   291
		QMessageBox::critical(this,
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   292
				tr("Error"),
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 41
diff changeset
   293
				tr("Cannot save options to file %1").arg(settings.fileName()),
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   294
				tr("Quit"));
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   295
		return ;
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   296
	}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   297
	QTextStream stream(&settings);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   298
	stream.setCodec("UTF-8");
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   299
	stream << "; Generated by Hedgewars, do not modify" << endl;
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   300
	stream << "resolution " << ui.CBResolution->currentIndex() << endl;
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   301
	stream << "fullscreen " << ui.CBFullscreen->isChecked() << endl;
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   302
	stream << "nick " << ui.editNetNick->text() << endl;
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   303
	settings.close();
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   304
}
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   305
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   306
void HWForm::PlayDemo()
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   307
{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   308
	QListWidgetItem * curritem = ui.DemosList->currentItem();
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   309
	if (!curritem)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   310
	{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   311
		QMessageBox::critical(this,
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   312
				tr("Error"),
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   313
				tr("Please, select demo from the list above"),
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   314
				tr("OK"));
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   315
		return ;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   316
	}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   317
	game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   318
	game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   319
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   320
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   321
void HWForm::NetConnect()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   322
{
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   323
	hwnet = new HWNet(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   324
	connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   325
	connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &)));
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   326
	connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()));
32
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   327
	connect(hwnet, SIGNAL(ChangeInTeams(const QStringList &)), this, SLOT(ChangeInNetTeams(const QStringList &)));
36
a803a00a3272 - Anti-flood and anti-lag changes
unc0rr
parents: 34
diff changeset
   328
	hwnet->Connect("172.19.5.168", 6667, ui.editNetNick->text());
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   329
}
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   330
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   331
void HWForm::NetDisconnect()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   332
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   333
	hwnet->Disconnect();
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   334
	GoToNet();
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   335
}
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   336
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   337
void HWForm::AddGame(const QString & chan)
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   338
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   339
	ui.ChannelsList->addItem(chan);
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   340
}
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   341
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   342
void HWForm::NetGameEnter()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   343
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   344
	ui.Pages->setCurrentIndex(ID_PAGE_NETCFG);
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   345
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   346
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   347
void HWForm::NetJoin()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   348
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   349
	hwnet->JoinGame("#hw");
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   350
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   351
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   352
void HWForm::NetCreate()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   353
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   354
	hwnet->JoinGame("#hw");
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   355
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   356
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   357
void HWForm::NetAddTeam()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   358
{
45
1072e7fe85c8 DefaultTeam is now default to play with single and network game
displacer
parents: 44
diff changeset
   359
	HWTeam team("DefaultTeam");
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   360
	team.SetCfgDir(cfgdir.absolutePath());
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   361
	team.LoadFromFile();
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   362
	hwnet->AddTeam(team);
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   363
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   364
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   365
void HWForm::NetStartGame()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   366
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   367
	hwnet->StartGame();
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   368
}
32
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   369
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   370
void HWForm::ChangeInNetTeams(const QStringList & teams)
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   371
{
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   372
	ui.listNetTeams->clear();
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   373
	ui.listNetTeams->addItems(teams);
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   374
}
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   375