QTfrontend/hwform.cpp
author unc0rr
Thu, 05 Oct 2006 16:33:18 +0000
changeset 183 57c2ef19f719
parent 157 8e3e11bb0a5f
child 184 f97a7a3dc8f6
permissions -rw-r--r--
Relicense to GPL
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
85
44d9045b26ff New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents: 84
diff changeset
     3
 * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     4
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
     8
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
    12
 * GNU General Public License for more details.
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    13
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
    14
 * You should have received a copy of the GNU General Public License
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
    15
 * along with this program; if not, write to the Free Software
57c2ef19f719 Relicense to GPL
unc0rr
parents: 157
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    17
 */
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    18
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    19
#include <QtGui>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    20
#include <QStringList>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    21
#include <QProcess>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    22
#include <QDir>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    23
#include <QPixmap>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    24
#include <QRegExp>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    25
#include <QIcon>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    26
#include <QFile>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    27
#include <QTextStream>
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    28
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    29
#include "hwform.h"
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    30
#include "game.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    31
#include "team.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    32
#include "netclient.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    33
#include "teamselect.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    34
#include "gameuiconfig.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    35
#include "pages.h"
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    36
#include "hwconsts.h"
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    37
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    38
HWForm::HWForm(QWidget *parent)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    39
	: QMainWindow(parent)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    40
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    41
	ui.setupUi(this);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    42
85
44d9045b26ff New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents: 84
diff changeset
    43
	config = new GameUIConfig(this);
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
    44
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
    45
	QStringList teamslist = config->GetTeamsList();
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    46
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
    47
	if(teamslist.empty()) {
116
00d3d6d2e699 GameUIConfig* member removed
displacer
parents: 111
diff changeset
    48
		HWTeam defaultTeam("DefaultTeam");
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
    49
		defaultTeam.SaveToFile();
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
    50
		teamslist.push_back("DefaultTeam");
44
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
    51
	}
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
    52
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
    53
	for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it )
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
    54
	{
140
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 137
diff changeset
    55
	  ui.pageMultiplayer->teamsSelect->addTeam(*it);
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 137
diff changeset
    56
	  ui.pageOptions->CBTeamName->addItem(*it);
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
    57
	}
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    58
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    59
	connect(ui.pageMain->BtnSinglePlayer,	SIGNAL(clicked()),	this, SLOT(GoToSinglePlayer()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    60
	connect(ui.pageMain->BtnSetup,	SIGNAL(clicked()),	this, SLOT(GoToSetup()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    61
	connect(ui.pageMain->BtnMultiplayer,	SIGNAL(clicked()),	this, SLOT(GoToMultiplayer()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    62
	connect(ui.pageMain->BtnDemos,	SIGNAL(clicked()),	this, SLOT(GoToDemos()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    63
	connect(ui.pageMain->BtnNet,	SIGNAL(clicked()),	this, SLOT(GoToNet()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    64
	connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(close()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    65
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    66
	connect(ui.pageLocalGame->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    67
	connect(ui.pageLocalGame->BtnSimpleGame,	SIGNAL(clicked()),	this, SLOT(SimpleGame()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    68
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    69
	connect(ui.pageEditTeam->BtnTeamSave,	SIGNAL(clicked()),	this, SLOT(TeamSave()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    70
	connect(ui.pageEditTeam->BtnTeamDiscard,	SIGNAL(clicked()),	this, SLOT(TeamDiscard()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    71
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    72
	connect(ui.pageMultiplayer->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
133
c79cb5e5b24a - Multiplayer game start button
unc0rr
parents: 116
diff changeset
    73
	connect(ui.pageMultiplayer->BtnStartMPGame,	SIGNAL(clicked()),	this, SLOT(StartMPGame()));
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    74
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    75
	connect(ui.pagePlayDemo->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    76
	connect(ui.pagePlayDemo->BtnPlayDemo,	SIGNAL(clicked()),	this, SLOT(PlayDemo()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    77
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    78
	connect(ui.pageOptions->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    79
	connect(ui.pageOptions->BtnNewTeam,	SIGNAL(clicked()),	this, SLOT(NewTeam()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    80
	connect(ui.pageOptions->BtnEditTeam,	SIGNAL(clicked()),	this, SLOT(EditTeam()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    81
	connect(ui.pageOptions->BtnSaveOptions,	SIGNAL(clicked()),	config, SLOT(SaveOptions()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    82
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    83
	connect(ui.pageNet->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    84
	connect(ui.pageNet->BtnNetConnect,	SIGNAL(clicked()),	this, SLOT(NetConnect()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    85
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    86
	connect(ui.pageNetGame->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToNetChat()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    87
	connect(ui.pageNetGame->BtnAddTeam,	SIGNAL(clicked()),	this, SLOT(NetAddTeam()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    88
	connect(ui.pageNetGame->BtnGo,	SIGNAL(clicked()),	this, SLOT(NetStartGame()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    89
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    90
	connect(ui.pageNetChat->BtnDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    91
	connect(ui.pageNetChat->BtnJoin,	SIGNAL(clicked()),	this, SLOT(NetJoin()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    92
	connect(ui.pageNetChat->BtnCreate,	SIGNAL(clicked()),	this, SLOT(NetCreate()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    93
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    94
	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    95
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    96
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    97
void HWForm::GoToMain()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    98
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    99
	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   100
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   101
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   102
void HWForm::GoToSinglePlayer()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   103
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   104
	ui.Pages->setCurrentIndex(ID_PAGE_SINGLEPLAYER);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   105
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   106
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   107
void HWForm::GoToSetup()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   108
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   109
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   110
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   111
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   112
void HWForm::GoToMultiplayer()
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   113
{
151
9eb5a4cee35e reset playing teams
displacer
parents: 144
diff changeset
   114
	ui.pageMultiplayer->teamsSelect->resetPlayingTeams(config->GetTeamsList());
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   115
	ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER);
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   116
}
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   117
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   118
void HWForm::GoToDemos()
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   119
{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   120
	QDir tmpdir;
157
8e3e11bb0a5f Fix demos usability
unc0rr
parents: 152
diff changeset
   121
	tmpdir.cd(cfgdir->absolutePath());
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   122
	tmpdir.cd("Demos");
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   123
	tmpdir.setFilter(QDir::Files);
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   124
	ui.pagePlayDemo->DemosList->clear();
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   125
	ui.pagePlayDemo->DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_1")).replaceInStrings(QRegExp("^(.*).hwd_1"), "\\1"));
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   126
	ui.Pages->setCurrentIndex(ID_PAGE_DEMOS);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   127
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   128
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   129
void HWForm::GoToNet()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   130
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   131
	ui.Pages->setCurrentIndex(ID_PAGE_NET);
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   132
}
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   133
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   134
void HWForm::GoToNetChat()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   135
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   136
	ui.Pages->setCurrentIndex(ID_PAGE_NETCHAT);
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   137
}
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   138
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   139
void HWForm::NewTeam()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   140
{
116
00d3d6d2e699 GameUIConfig* member removed
displacer
parents: 111
diff changeset
   141
	tmpTeam = new HWTeam("unnamed");
144
e6084b0c9316 - Fix 'new team' regression
unc0rr
parents: 140
diff changeset
   142
	tmpTeam->SetToPage(this);
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   143
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   144
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   145
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   146
void HWForm::EditTeam()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   147
{
116
00d3d6d2e699 GameUIConfig* member removed
displacer
parents: 111
diff changeset
   148
	tmpTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText());
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   149
	tmpTeam->LoadFromFile();
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   150
	tmpTeam->SetToPage(this);
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   151
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   152
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   153
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   154
void HWForm::TeamSave()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   155
{
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   156
	tmpTeam->GetFromPage(this);
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   157
	tmpTeam->SaveToFile();
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   158
	delete tmpTeam;
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   159
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   160
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   161
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   162
void HWForm::TeamDiscard()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   163
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   164
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   165
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   166
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   167
void HWForm::SimpleGame()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   168
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   169
	game = new HWGame(config, ui.pageLocalGame->gameCFG);
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
   170
	game->StartQuick();
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   171
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   172
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   173
void HWForm::PlayDemo()
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   174
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   175
	QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem();
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   176
	if (!curritem)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   177
	{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   178
		QMessageBox::critical(this,
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   179
				tr("Error"),
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   180
				tr("Please, select demo from the list above"),
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   181
				tr("OK"));
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   182
		return ;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   183
	}
85
44d9045b26ff New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents: 84
diff changeset
   184
	game = new HWGame(config, 0);
157
8e3e11bb0a5f Fix demos usability
unc0rr
parents: 152
diff changeset
   185
	game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_1");
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   186
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   187
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   188
void HWForm::NetConnect()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   189
{
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
   190
	hwnet = new HWNet(config);
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   191
	connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   192
	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
   193
	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
   194
	connect(hwnet, SIGNAL(ChangeInTeams(const QStringList &)), this, SLOT(ChangeInNetTeams(const QStringList &)));
111
30ca06092a64 - 'net nickname' and 'server address' options are on PageNet
unc0rr
parents: 97
diff changeset
   195
	hwnet->Connect(ui.pageNet->editIP->text(), 6667, ui.pageNet->editNetNick->text());
30ca06092a64 - 'net nickname' and 'server address' options are on PageNet
unc0rr
parents: 97
diff changeset
   196
	config->SaveOptions();
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   197
}
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   198
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   199
void HWForm::NetDisconnect()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   200
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   201
	hwnet->Disconnect();
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   202
	GoToNet();
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   203
}
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   204
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   205
void HWForm::AddGame(const QString & chan)
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   206
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   207
	ui.pageNetChat->ChannelsList->addItem(chan);
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   208
}
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   209
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   210
void HWForm::NetGameEnter()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   211
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   212
	ui.Pages->setCurrentIndex(ID_PAGE_NETCFG);
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   213
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   214
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   215
void HWForm::NetJoin()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   216
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   217
	hwnet->JoinGame("#hw");
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   218
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   219
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   220
void HWForm::NetCreate()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   221
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   222
	hwnet->JoinGame("#hw");
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   223
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   224
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   225
void HWForm::NetAddTeam()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   226
{
116
00d3d6d2e699 GameUIConfig* member removed
displacer
parents: 111
diff changeset
   227
	HWTeam team("DefaultTeam");
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   228
	team.LoadFromFile();
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   229
	hwnet->AddTeam(team);
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   230
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   231
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   232
void HWForm::NetStartGame()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   233
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   234
	hwnet->StartGame();
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   235
}
32
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   236
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   237
void HWForm::ChangeInNetTeams(const QStringList & teams)
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   238
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   239
	ui.pageNetGame->listNetTeams->clear();
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   240
	ui.pageNetGame->listNetTeams->addItems(teams);
32
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   241
}
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   242
133
c79cb5e5b24a - Multiplayer game start button
unc0rr
parents: 116
diff changeset
   243
void HWForm::StartMPGame()
c79cb5e5b24a - Multiplayer game start button
unc0rr
parents: 116
diff changeset
   244
{
137
bcab861a3262 Get game modes from right GameCFGWidget
unc0rr
parents: 133
diff changeset
   245
	game = new HWGame(config, ui.pageMultiplayer->gameCFG);
152
c558957ef644 teams moving order fixed
displacer
parents: 151
diff changeset
   246
	list<HWTeam> teamslist=ui.pageMultiplayer->teamsSelect->getPlayingTeams();
c558957ef644 teams moving order fixed
displacer
parents: 151
diff changeset
   247
	for (list<HWTeam>::const_iterator it = teamslist.begin(); it != teamslist.end(); ++it ) {
c558957ef644 teams moving order fixed
displacer
parents: 151
diff changeset
   248
	  game->AddTeam(it->TeamName, ui.pageMultiplayer->teamsSelect->numHedgedogs(it->TeamName));
140
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 137
diff changeset
   249
	}
133
c79cb5e5b24a - Multiplayer game start button
unc0rr
parents: 116
diff changeset
   250
	game->StartLocal();
c79cb5e5b24a - Multiplayer game start button
unc0rr
parents: 116
diff changeset
   251
}