QTfrontend/hwform.cpp
author unc0rr
Wed, 26 Jul 2006 12:25:48 +0000
changeset 87 ff213e443336
parent 86 664b536a1c27
child 97 e7c1df9cce2c
permissions -rw-r--r--
Convert all pages to classes
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
 *
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"
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    45
#include "game.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    46
#include "team.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    47
#include "netclient.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    48
#include "teamselect.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    49
#include "gameuiconfig.h"
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    50
#include "pages.h"
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    51
#include "hwconsts.h"
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    52
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    53
HWForm::HWForm(QWidget *parent)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    54
	: QMainWindow(parent)
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    55
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    56
	ui.setupUi(this);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
    57
85
44d9045b26ff New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents: 84
diff changeset
    58
	config = new GameUIConfig(this);
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
    59
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
    60
	QStringList teamslist = config->GetTeamsList();
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    61
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
    62
	if(teamslist.empty()) {
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
    63
		HWTeam defaultTeam("DefaultTeam", config);
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
    64
		defaultTeam.SaveToFile();
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
    65
		teamslist.push_back("DefaultTeam");
44
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
    66
	}
1ef9546971ff added default team on loading
displacer
parents: 43
diff changeset
    67
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
    68
	for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it )
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
    69
	{
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents: 45
diff changeset
    70
	  QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1");
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    71
	  ui.pageMultiplayer->teamsSelect->addTeam(tmpTeamStr);
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    72
	  ui.pageOptions->CBTeamName->addItem(tmpTeamStr);
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
    73
	}
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
    74
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    75
	connect(ui.pageMain->BtnSinglePlayer,	SIGNAL(clicked()),	this, SLOT(GoToSinglePlayer()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    76
	connect(ui.pageMain->BtnSetup,	SIGNAL(clicked()),	this, SLOT(GoToSetup()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    77
	connect(ui.pageMain->BtnMultiplayer,	SIGNAL(clicked()),	this, SLOT(GoToMultiplayer()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    78
	connect(ui.pageMain->BtnDemos,	SIGNAL(clicked()),	this, SLOT(GoToDemos()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    79
	connect(ui.pageMain->BtnNet,	SIGNAL(clicked()),	this, SLOT(GoToNet()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    80
	connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(close()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    81
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    82
	connect(ui.pageLocalGame->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    83
	connect(ui.pageLocalGame->BtnSimpleGame,	SIGNAL(clicked()),	this, SLOT(SimpleGame()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    84
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    85
	connect(ui.pageEditTeam->BtnTeamSave,	SIGNAL(clicked()),	this, SLOT(TeamSave()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    86
	connect(ui.pageEditTeam->BtnTeamDiscard,	SIGNAL(clicked()),	this, SLOT(TeamDiscard()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    88
	connect(ui.pageMultiplayer->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
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.pagePlayDemo->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    91
	connect(ui.pagePlayDemo->BtnPlayDemo,	SIGNAL(clicked()),	this, SLOT(PlayDemo()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    92
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    93
	connect(ui.pageOptions->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    94
	connect(ui.pageOptions->BtnNewTeam,	SIGNAL(clicked()),	this, SLOT(NewTeam()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    95
	connect(ui.pageOptions->BtnEditTeam,	SIGNAL(clicked()),	this, SLOT(EditTeam()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    96
	connect(ui.pageOptions->BtnSaveOptions,	SIGNAL(clicked()),	config, SLOT(SaveOptions()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    97
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    98
	connect(ui.pageNet->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    99
	connect(ui.pageNet->BtnNetConnect,	SIGNAL(clicked()),	this, SLOT(NetConnect()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   100
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   101
	connect(ui.pageNetGame->BtnBack,	SIGNAL(clicked()),	this, SLOT(GoToNetChat()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   102
	connect(ui.pageNetGame->BtnAddTeam,	SIGNAL(clicked()),	this, SLOT(NetAddTeam()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   103
	connect(ui.pageNetGame->BtnGo,	SIGNAL(clicked()),	this, SLOT(NetStartGame()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   104
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   105
	connect(ui.pageNetChat->BtnDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   106
	connect(ui.pageNetChat->BtnJoin,	SIGNAL(clicked()),	this, SLOT(NetJoin()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   107
	connect(ui.pageNetChat->BtnCreate,	SIGNAL(clicked()),	this, SLOT(NetCreate()));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   108
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   109
	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   110
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   111
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   112
void HWForm::GoToMain()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   113
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   114
	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   115
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   116
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   117
void HWForm::GoToSinglePlayer()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   118
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   119
	ui.Pages->setCurrentIndex(ID_PAGE_SINGLEPLAYER);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   120
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   121
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   122
void HWForm::GoToSetup()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   123
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   124
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   125
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   126
25
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   127
void HWForm::GoToMultiplayer()
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   128
{
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   129
	ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER);
27aa8030322b - Get rid of old frontend
unc0rr
parents: 21
diff changeset
   130
}
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   131
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   132
void HWForm::GoToDemos()
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   133
{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   134
	QDir tmpdir;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   135
	tmpdir.cd(DATA_PATH);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   136
	tmpdir.cd("Demos");
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   137
	tmpdir.setFilter(QDir::Files);
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   138
	ui.pagePlayDemo->DemosList->clear();
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   139
	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
   140
	ui.Pages->setCurrentIndex(ID_PAGE_DEMOS);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   141
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   142
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   143
void HWForm::GoToNet()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   144
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   145
	ui.Pages->setCurrentIndex(ID_PAGE_NET);
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   146
}
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   147
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   148
void HWForm::GoToNetChat()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   149
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   150
	ui.Pages->setCurrentIndex(ID_PAGE_NETCHAT);
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   151
}
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   152
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   153
void HWForm::NewTeam()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   154
{
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
   155
	tmpTeam = new HWTeam("unnamed", config);
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
   156
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   157
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   158
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   159
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   160
void HWForm::EditTeam()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   161
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   162
	tmpTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText(), config);
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   163
	tmpTeam->LoadFromFile();
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   164
	tmpTeam->SetToPage(this);
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   165
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   166
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   167
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   168
void HWForm::TeamSave()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   169
{
21
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   170
	tmpTeam->GetFromPage(this);
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   171
	tmpTeam->SaveToFile();
dff476dcaaa3 - Many improvements to frontend
unc0rr
parents: 20
diff changeset
   172
	delete tmpTeam;
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   173
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   174
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   175
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   176
void HWForm::TeamDiscard()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   177
{
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   178
	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   179
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   180
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   181
void HWForm::SimpleGame()
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   182
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   183
	game = new HWGame(config, ui.pageLocalGame->gameCFG);
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
   184
	game->StartQuick();
20
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   185
}
ccd2c45f043d frontend rewrite for QT4
unc0rr
parents:
diff changeset
   186
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   187
void HWForm::PlayDemo()
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   188
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   189
	QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem();
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   190
	if (!curritem)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   191
	{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   192
		QMessageBox::critical(this,
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   193
				tr("Error"),
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   194
				tr("Please, select demo from the list above"),
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   195
				tr("OK"));
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   196
		return ;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   197
	}
85
44d9045b26ff New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents: 84
diff changeset
   198
	game = new HWGame(config, 0);
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   199
	game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   200
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   201
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   202
void HWForm::NetConnect()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   203
{
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 60
diff changeset
   204
	hwnet = new HWNet(config);
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   205
	connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat()));
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   206
	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
   207
	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
   208
	connect(hwnet, SIGNAL(ChangeInTeams(const QStringList &)), this, SLOT(ChangeInNetTeams(const QStringList &)));
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   209
	hwnet->Connect("172.19.5.168", 6667, ui.pageOptions->editNetNick->text());
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   210
}
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   211
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   212
void HWForm::NetDisconnect()
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   213
{
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   214
	hwnet->Disconnect();
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   215
	GoToNet();
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   216
}
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   217
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   218
void HWForm::AddGame(const QString & chan)
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   219
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   220
	ui.pageNetChat->ChannelsList->addItem(chan);
28
59f7db859b8a - clear demos list before adding items
unc0rr
parents: 26
diff changeset
   221
}
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   222
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   223
void HWForm::NetGameEnter()
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
	ui.Pages->setCurrentIndex(ID_PAGE_NETCFG);
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   226
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   227
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   228
void HWForm::NetJoin()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   229
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   230
	hwnet->JoinGame("#hw");
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
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   233
void HWForm::NetCreate()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   234
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   235
	hwnet->JoinGame("#hw");
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   236
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   237
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   238
void HWForm::NetAddTeam()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   239
{
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 85
diff changeset
   240
	HWTeam team("DefaultTeam", config);
31
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   241
	team.LoadFromFile();
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   242
	hwnet->AddTeam(team);
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   243
}
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   244
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   245
void HWForm::NetStartGame()
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   246
{
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   247
	hwnet->StartGame();
99888245a4e8 Now net game is near available, but exception occurs...
unc0rr
parents: 28
diff changeset
   248
}
32
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   249
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   250
void HWForm::ChangeInNetTeams(const QStringList & teams)
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   251
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   252
	ui.pageNetGame->listNetTeams->clear();
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   253
	ui.pageNetGame->listNetTeams->addItems(teams);
32
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   254
}
78bff13b11c0 With this patch the game doesn't crash when gaming by net
unc0rr
parents: 31
diff changeset
   255