QTfrontend/team.cpp
author displacer
Thu, 16 Aug 2007 15:16:56 +0000
changeset 572 302ad5c3836d
parent 546 0e7cc3fb05cd
child 605 2651c3fe4567
permissions -rw-r--r--
gcc 4.3 related patch - missing header added :)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     1
/*
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     2
 * Hedgewars, a worms-like game
486
7ea71cd3acd5 - Change proto version to 4
unc0rr
parents: 471
diff changeset
     3
 * Copyright (c) 2005-2007 Andrey Korotaev <unC0Rr@gmail.com>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     4
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     8
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    12
 * GNU General Public License for more details.
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    13
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    15
 * along with this program; if not, write to the Free Software
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    17
 */
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    18
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    19
#include <QFile>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    20
#include <QTextStream>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    21
#include <QApplication>
471
e1eb64ba5e9c Small cleanup, faster compilation as a result
unc0rr
parents: 468
diff changeset
    22
#include <QStringList>
e1eb64ba5e9c Small cleanup, faster compilation as a result
unc0rr
parents: 468
diff changeset
    23
#include <QLineEdit>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    24
#include "team.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    25
#include "hwform.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    26
#include "predefteams.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    27
#include "pages.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    28
#include "hwconsts.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    29
314
83773ccf4f09 client/server net pre-alpha
displacer
parents: 312
diff changeset
    30
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    31
HWTeam::HWTeam(const QString & teamname, unsigned int netID) :
339
7535ab6c3820 Run game message added, team and config info provided for net game
displacer
parents: 336
diff changeset
    32
  difficulty(0),
353
5ec611d702a0 initial hedgehogs num fixed
displacer
parents: 352
diff changeset
    33
  numHedgehogs(4),
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    34
  m_netID(netID)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    35
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    36
	TeamName = teamname;
245
4f6b53b7a567 Make teams config file name be team name
unc0rr
parents: 239
diff changeset
    37
	OldTeamName = TeamName;
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    38
	for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    39
	Grave = "Simple";
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    40
	Fort = "Barrelhouse";
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    41
	for(int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    42
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    43
		binds[i].action = cbinds[i].action;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    44
		binds[i].strbind = cbinds[i].strbind;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    45
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    46
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    47
353
5ec611d702a0 initial hedgehogs num fixed
displacer
parents: 352
diff changeset
    48
HWTeam::HWTeam(const QStringList& strLst) :
5ec611d702a0 initial hedgehogs num fixed
displacer
parents: 352
diff changeset
    49
  numHedgehogs(4)
314
83773ccf4f09 client/server net pre-alpha
displacer
parents: 312
diff changeset
    50
{
339
7535ab6c3820 Run game message added, team and config info provided for net game
displacer
parents: 336
diff changeset
    51
  // net teams are configured from QStringList
443
eec37eb7f5db fort, grave and difficulty information for net team
displacer
parents: 353
diff changeset
    52
  if(strLst.size()<13) throw HWTeamConstructException();
314
83773ccf4f09 client/server net pre-alpha
displacer
parents: 312
diff changeset
    53
  TeamName=strLst[0];
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    54
  m_netID=strLst[1].toUInt();
443
eec37eb7f5db fort, grave and difficulty information for net team
displacer
parents: 353
diff changeset
    55
  Grave=strLst[2];
eec37eb7f5db fort, grave and difficulty information for net team
displacer
parents: 353
diff changeset
    56
  Fort=strLst[3];
eec37eb7f5db fort, grave and difficulty information for net team
displacer
parents: 353
diff changeset
    57
  difficulty=strLst[4].toUInt();
eec37eb7f5db fort, grave and difficulty information for net team
displacer
parents: 353
diff changeset
    58
  for(int i = 0; i < 8; i++) HHName[i]=strLst[i+5];
314
83773ccf4f09 client/server net pre-alpha
displacer
parents: 312
diff changeset
    59
}
83773ccf4f09 client/server net pre-alpha
displacer
parents: 312
diff changeset
    60
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
    61
HWTeam::HWTeam(quint8 num) :
339
7535ab6c3820 Run game message added, team and config info provided for net game
displacer
parents: 336
diff changeset
    62
  difficulty(0),
353
5ec611d702a0 initial hedgehogs num fixed
displacer
parents: 352
diff changeset
    63
  numHedgehogs(4),
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    64
  m_netID(0)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    65
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    66
	num %= PREDEFTEAMS_COUNT;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    67
	TeamName = QApplication::translate("teams", pteams[num].TeamName);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    68
	HHName[0] = QApplication::translate("teams", pteams[num].hh0name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    69
	HHName[1] = QApplication::translate("teams", pteams[num].hh1name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    70
	HHName[2] = QApplication::translate("teams", pteams[num].hh2name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    71
	HHName[3] = QApplication::translate("teams", pteams[num].hh3name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    72
	HHName[4] = QApplication::translate("teams", pteams[num].hh4name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    73
	HHName[5] = QApplication::translate("teams", pteams[num].hh5name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    74
	HHName[6] = QApplication::translate("teams", pteams[num].hh6name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    75
	HHName[7] = QApplication::translate("teams", pteams[num].hh7name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    76
	Grave = pteams[num].Grave;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    77
	Fort = pteams[num].Fort;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    78
	for(int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    79
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    80
		binds[i].action = cbinds[i].action;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    81
		binds[i].strbind = cbinds[i].strbind;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    82
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    83
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    84
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    85
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    86
bool HWTeam::LoadFromFile()
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    87
{
353
5ec611d702a0 initial hedgehogs num fixed
displacer
parents: 352
diff changeset
    88
	numHedgehogs=4;
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    89
	QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    90
	if (!cfgfile.open(QIODevice::ReadOnly)) return false;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    91
	QTextStream stream(&cfgfile);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    92
	stream.setCodec("UTF-8");
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    93
	QString str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    94
	QString action;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    95
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    96
	while (!stream.atEnd())
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    97
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    98
		str = stream.readLine();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    99
		if (str.startsWith(";")) continue;
245
4f6b53b7a567 Make teams config file name be team name
unc0rr
parents: 239
diff changeset
   100
		/*if (str.startsWith("name team "))
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   101
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   102
			str.remove(0, 10);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   103
			TeamName = str;
245
4f6b53b7a567 Make teams config file name be team name
unc0rr
parents: 239
diff changeset
   104
		} else*/
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   105
		if (str.startsWith("name hh"))
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   106
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   107
			str.remove(0, 7);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   108
			long i = str.left(1).toLong();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   109
			if ((i < 0) || (i > 7)) continue;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   110
			str.remove(0, 2);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   111
			HHName[i] = str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   112
		} else
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   113
		if (str.startsWith("grave "))
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   114
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   115
			str.remove(0, 6);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   116
			Grave = str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   117
		} else
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   118
		if (str.startsWith("fort "))
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   119
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   120
			str.remove(0, 5);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   121
			Fort = str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   122
		} else
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   123
		if (str.startsWith("bind "))
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   124
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   125
			str.remove(0, 5);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   126
			action = str.section(' ', 1);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   127
			str = str.section(' ', 0, 0);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   128
			str.truncate(15);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   129
			for (int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   130
				if (action == binds[i].action)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   131
				{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   132
					binds[i].strbind = str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   133
					break;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   134
				}
239
f9adf3c73bed 'Proto' class to make things easier
unc0rr
parents: 231
diff changeset
   135
		} else
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   136
		if (str.startsWith("difficulty "))
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   137
		{
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   138
		  str.remove(0, 11);
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   139
		  difficulty=str.toUInt();
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   140
		  if (difficulty>5) difficulty=0; // this shouldn't normally happen
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   141
		}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   142
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   143
	cfgfile.close();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   144
	return true;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   145
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   146
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   147
bool HWTeam::SaveToFile()
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   148
{
245
4f6b53b7a567 Make teams config file name be team name
unc0rr
parents: 239
diff changeset
   149
	if (OldTeamName != TeamName)
4f6b53b7a567 Make teams config file name be team name
unc0rr
parents: 239
diff changeset
   150
	{
4f6b53b7a567 Make teams config file name be team name
unc0rr
parents: 239
diff changeset
   151
		QFile cfgfile(cfgdir->absolutePath() + "/" + OldTeamName + ".cfg");
4f6b53b7a567 Make teams config file name be team name
unc0rr
parents: 239
diff changeset
   152
		cfgfile.remove();
4f6b53b7a567 Make teams config file name be team name
unc0rr
parents: 239
diff changeset
   153
		OldTeamName = TeamName;
4f6b53b7a567 Make teams config file name be team name
unc0rr
parents: 239
diff changeset
   154
	}
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   155
	QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   156
	if (!cfgfile.open(QIODevice::WriteOnly)) return false;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   157
	QTextStream stream(&cfgfile);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   158
	stream.setCodec("UTF-8");
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   159
	stream << "; Generated by Hedgewars, do not modify" << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   160
	stream << "name team " << TeamName << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   161
	for (int i = 0; i < 8; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   162
		stream << "name hh" << i << " " << HHName[i] << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   163
	stream << "grave " << Grave << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   164
	stream << "fort " << Fort << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   165
	for(int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   166
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   167
		stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   168
	}
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   169
	stream << "difficulty " << difficulty << endl;
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   170
	cfgfile.close();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   171
	return true;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   172
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   173
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   174
void HWTeam::SetToPage(HWForm * hwform)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   175
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   176
	hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName);
336
82d654db133d Team level at new place on team config page
unc0rr
parents: 319
diff changeset
   177
	hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(difficulty);
82d654db133d Team level at new place on team config page
unc0rr
parents: 319
diff changeset
   178
	hwform->ui.pageEditTeam->CBTeamLvl_activated(difficulty);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   179
	for(int i = 0; i < 8; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   180
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   181
		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   182
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   183
	hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   184
	hwform->ui.pageEditTeam->CBGrave_activated(Grave);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   185
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   186
	hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   187
	hwform->ui.pageEditTeam->CBFort_activated(Fort);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   188
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   189
	for(int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   190
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   191
		hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findText(binds[i].strbind));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   192
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   193
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   194
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   195
void HWTeam::GetFromPage(HWForm * hwform)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   196
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   197
	TeamName  = hwform->ui.pageEditTeam->TeamNameEdit->text();
336
82d654db133d Team level at new place on team config page
unc0rr
parents: 319
diff changeset
   198
	difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex();
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   199
	for(int i = 0; i < 8; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   200
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   201
		HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   202
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   203
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   204
	Grave = hwform->ui.pageEditTeam->CBGrave->currentText();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   205
	Fort = hwform->ui.pageEditTeam->CBFort->currentText();
247
07605d2a2024 - Fix infinite loop when selecting weapon with ammo menu
unc0rr
parents: 245
diff changeset
   206
	for(int i = 0; i < BINDS_NUMBER; i++)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   207
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   208
		binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->currentText();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   209
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   210
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   211
341
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   212
QStringList HWTeam::TeamGameConfig(quint32 InitHealth) const
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   213
{
239
f9adf3c73bed 'Proto' class to make things easier
unc0rr
parents: 231
diff changeset
   214
	QStringList sl;
546
0e7cc3fb05cd Proto change: set color in addteam command
unc0rr
parents: 486
diff changeset
   215
	sl.push_back(QString("eaddteam %1").arg(teamColor.rgb() & 0xffffff));
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   216
	if (m_netID)
341
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   217
		sl.push_back("erdriven");
239
f9adf3c73bed 'Proto' class to make things easier
unc0rr
parents: 231
diff changeset
   218
	sl.push_back("ename team " + TeamName);
341
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   219
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   220
	for (int i = 0; i < numHedgehogs; i++)
239
f9adf3c73bed 'Proto' class to make things easier
unc0rr
parents: 231
diff changeset
   221
		sl.push_back(QString("ename hh%1 ").arg(i).append(HHName[i]));
341
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   222
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   223
	sl.push_back(QString("egrave " + Grave));
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   224
	sl.push_back(QString("efort " + Fort));
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   225
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   226
	if (!m_netID)
341
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   227
		for(int i = 0; i < BINDS_NUMBER; i++)
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   228
			sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action));
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   229
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   230
	for (int t = 0; t < numHedgehogs; t++)
319
7f3bd9e31f18 some changes
displacer
parents: 314
diff changeset
   231
	  sl.push_back(QString("eaddhh %1 %2")
7f3bd9e31f18 some changes
displacer
parents: 314
diff changeset
   232
		       .arg(QString::number(difficulty),
7f3bd9e31f18 some changes
displacer
parents: 314
diff changeset
   233
			    QString::number(InitHealth)));
239
f9adf3c73bed 'Proto' class to make things easier
unc0rr
parents: 231
diff changeset
   234
	return sl;
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   235
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   236
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   237
bool HWTeam::isNetTeam() const
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   238
{
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   239
  return m_netID!=0;
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   240
}
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   241
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   242
unsigned int HWTeam::getNetID() const
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   243
{
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   244
  return m_netID;
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   245
}
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   246
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   247
bool HWTeam::operator==(const HWTeam& t1) const {
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   248
  return TeamName==t1.TeamName && m_netID==t1.m_netID;
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   249
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   250
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   251
bool HWTeam::operator<(const HWTeam& t1) const {
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   252
  return m_netID<t1.m_netID || TeamName<t1.TeamName; // if names are equal - test if it is net team
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   253
}