QTfrontend/team.cpp
author displacer
Fri, 18 Aug 2006 20:37:50 +0000
changeset 117 d21a48200772
parent 116 00d3d6d2e699
child 128 223522298250
permissions -rw-r--r--
HWTeam integration in team select widget
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
     1
/*
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
     2
 * Hedgewars, a worms-like game
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
     3
 * Copyright (c) 2005 Andrey Korotaev <unC0Rr@gmail.com>
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
     4
 *
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
     5
 * Distributed under the terms of the BSD-modified licence:
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
     6
 *
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
     7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
     8
 * of this software and associated documentation files (the "Software"), to deal
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
     9
 * with the Software without restriction, including without limitation the
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    10
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    11
 * sell copies of the Software, and to permit persons to whom the Software is
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    12
 * furnished to do so, subject to the following conditions:
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    13
 *
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    14
 * 1. Redistributions of source code must retain the above copyright notice,
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    15
 *    this list of conditions and the following disclaimer.
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    16
 * 2. Redistributions in binary form must reproduce the above copyright notice,
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    17
 *    this list of conditions and the following disclaimer in the documentation
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    18
 *    and/or other materials provided with the distribution.
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    19
 * 3. The name of the author may not be used to endorse or promote products
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    20
 *    derived from this software without specific prior written permission.
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    21
 *
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    23
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    24
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    25
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    27
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    28
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    29
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    30
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    31
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    32
 */
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    33
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    34
#include <QFile>
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    35
#include <QTextStream>
88
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    36
#include <QApplication>
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    37
#include "team.h"
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    38
#include "hwform.h"
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
    39
#include "predefteams.h"
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    40
#include "pages.h"
97
e7c1df9cce2c - make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents: 88
diff changeset
    41
#include "hwconsts.h"
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    42
116
00d3d6d2e699 GameUIConfig* member removed
displacer
parents: 97
diff changeset
    43
HWTeam::HWTeam(const QString & teamname)
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    44
{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    45
	TeamName = teamname;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    46
	for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    47
	Grave = "Simple";
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    48
	Fort = "Barrelhouse";
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    49
	for(int i = 0; i < BINDS_NUMBER; i++)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    50
	{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    51
		binds[i].action = cbinds[i].action;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    52
		binds[i].strbind = cbinds[i].strbind;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    53
	}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    54
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    55
116
00d3d6d2e699 GameUIConfig* member removed
displacer
parents: 97
diff changeset
    56
HWTeam::HWTeam(quint8 num)
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
    57
{
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
    58
	num %= PREDEFTEAMS_COUNT;
88
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    59
	TeamName = QApplication::translate("teams", pteams[num].TeamName);
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    60
	HHName[0] = QApplication::translate("teams", pteams[num].hh0name);
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    61
	HHName[1] = QApplication::translate("teams", pteams[num].hh1name);
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    62
	HHName[2] = QApplication::translate("teams", pteams[num].hh2name);
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    63
	HHName[3] = QApplication::translate("teams", pteams[num].hh3name);
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    64
	HHName[4] = QApplication::translate("teams", pteams[num].hh4name);
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    65
	HHName[5] = QApplication::translate("teams", pteams[num].hh5name);
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    66
	HHName[6] = QApplication::translate("teams", pteams[num].hh6name);
6740a1c4edc9 - Fix internationalization issues
unc0rr
parents: 87
diff changeset
    67
	HHName[7] = QApplication::translate("teams", pteams[num].hh7name);
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
    68
	Grave = pteams[num].Grave;
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
    69
	Fort = pteams[num].Fort;
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    70
	for(int i = 0; i < BINDS_NUMBER; i++)
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    71
	{
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    72
		binds[i].action = cbinds[i].action;
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    73
		binds[i].strbind = cbinds[i].strbind;
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
    74
	}
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
    75
}
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
    76
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
    77
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    78
bool HWTeam::LoadFromFile()
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    79
{
97
e7c1df9cce2c - make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents: 88
diff changeset
    80
	QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    81
	if (!cfgfile.open(QIODevice::ReadOnly)) return false;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    82
	QTextStream stream(&cfgfile);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    83
	stream.setCodec("UTF-8");
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    84
	QString str;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    85
	QString action;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    86
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    87
	while (!stream.atEnd())
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    88
	{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    89
		str = stream.readLine();
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    90
		if (str.startsWith(";")) continue;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    91
		if (str.startsWith("name team "))
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    92
		{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    93
			str.remove(0, 10);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    94
			TeamName = str;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    95
		} else
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    96
		if (str.startsWith("name hh"))
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    97
		{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    98
			str.remove(0, 7);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
    99
			long i = str.left(1).toLong();
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   100
			if ((i < 0) || (i > 7)) continue;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   101
			str.remove(0, 2);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   102
			HHName[i] = str;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   103
		} else
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   104
		if (str.startsWith("grave "))
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   105
		{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   106
			str.remove(0, 6);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   107
			Grave = str;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   108
		} else
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   109
		if (str.startsWith("fort "))
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   110
		{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   111
			str.remove(0, 5);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   112
			Fort = str;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   113
		} else
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   114
		if (str.startsWith("bind "))
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   115
		{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   116
			str.remove(0, 5);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   117
			action = str.section(' ', 1);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   118
			str = str.section(' ', 0, 0);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   119
			str.truncate(15);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   120
			for (int i = 0; i < BINDS_NUMBER; i++)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   121
				if (action == binds[i].action)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   122
				{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   123
					binds[i].strbind = str;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   124
					break;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   125
				}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   126
		}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   127
	}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   128
	cfgfile.close();
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   129
	return true;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   130
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   131
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   132
bool HWTeam::SaveToFile()
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   133
{
97
e7c1df9cce2c - make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents: 88
diff changeset
   134
	QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   135
	if (!cfgfile.open(QIODevice::WriteOnly)) return false;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   136
	QTextStream stream(&cfgfile);
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   137
	stream.setCodec("UTF-8");
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   138
	stream << "; Generated by Hedgewars, do not modify" << endl;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   139
	stream << "name team " << TeamName << endl;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   140
	for (int i = 0; i < 8; i++)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   141
		stream << "name hh" << i << " " << HHName[i] << endl;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   142
	stream << "grave " << Grave << endl;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   143
	stream << "fort " << Fort << endl;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   144
	for(int i = 0; i < BINDS_NUMBER; i++)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   145
	{
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   146
		stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   147
	}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   148
	cfgfile.close();
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   149
	return true;
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   150
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   151
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   152
void HWTeam::SetToPage(HWForm * hwform)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   153
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   154
	hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName);
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   155
	for(int i = 0; i < 8; i++)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   156
	{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   157
		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   158
	}
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   159
	hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   160
	hwform->ui.pageEditTeam->CBGrave_activated(Grave);
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   161
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   162
	hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort));
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   163
	hwform->ui.pageEditTeam->CBFort_activated(Fort);
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   164
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   165
	for(int i = 0; i < BINDS_NUMBER; i++)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   166
	{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   167
		hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findText(binds[i].strbind));
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   168
	}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   169
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   170
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   171
void HWTeam::GetFromPage(HWForm * hwform)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   172
{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   173
	TeamName  = hwform->ui.pageEditTeam->TeamNameEdit->text();
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   174
	for(int i = 0; i < 8; i++)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   175
	{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   176
		HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text();
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   177
	}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   178
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   179
	Grave = hwform->ui.pageEditTeam->CBGrave->currentText();
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   180
	Fort = hwform->ui.pageEditTeam->CBFort->currentText();
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   181
	for(int i = 0; i < 8; i++)
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   182
	{
87
ff213e443336 Convert all pages to classes
unc0rr
parents: 86
diff changeset
   183
		binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->currentText();
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   184
	}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   185
}
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   186
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   187
QByteArray HWTeam::IPCTeamInfo() const
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   188
{
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   189
	QByteArray buf;
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   190
	#define ADD(a) { \
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   191
					QByteArray strmsg = a.toUtf8(); \
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   192
					quint8 sz = strmsg.size(); \
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   193
					buf.append(QByteArray((char *)&sz, 1)); \
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   194
					buf.append(strmsg); \
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   195
					}
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   196
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   197
	ADD(QString("ename team " + TeamName));
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   198
	for (int i = 0; i < 8; i++)
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   199
		ADD(QString("ename hh%1 ").arg(i).append(HHName[i]));
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   200
	ADD(QString("egrave " + Grave));
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   201
	ADD(QString("efort " + Fort));
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   202
	for(int i = 0; i < BINDS_NUMBER; i++)
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   203
	{
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   204
		ADD(QString("ebind " + binds[i].strbind + " " + binds[i].action));
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   205
	}
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   206
	#undef ADD
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   207
	return buf;
26
e32fa14529f8 Frontend lets define more binds
unc0rr
parents: 25
diff changeset
   208
}
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 26
diff changeset
   209
117
d21a48200772 HWTeam integration in team select widget
displacer
parents: 116
diff changeset
   210
bool HWTeam::operator==(const HWTeam& t1) const {
d21a48200772 HWTeam integration in team select widget
displacer
parents: 116
diff changeset
   211
  return TeamName==t1.TeamName;
d21a48200772 HWTeam integration in team select widget
displacer
parents: 116
diff changeset
   212
}
d21a48200772 HWTeam integration in team select widget
displacer
parents: 116
diff changeset
   213
d21a48200772 HWTeam integration in team select widget
displacer
parents: 116
diff changeset
   214
bool HWTeam::operator<(const HWTeam& t1) const {
d21a48200772 HWTeam integration in team select widget
displacer
parents: 116
diff changeset
   215
  return TeamName<t1.TeamName;
d21a48200772 HWTeam integration in team select widget
displacer
parents: 116
diff changeset
   216
}