author | nemo |
Sun, 12 Jun 2011 22:34:38 -0400 | |
changeset 5239 | f34f391a223b |
parent 5238 | 46ddaf14509d |
child 5252 | ded882439548 |
permissions | -rw-r--r-- |
1907 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2009 Martin Minarik <ttsmj@pokec.sk> |
|
4976 | 4 |
* Copyright (c) 2009-2011 Andrey Korotaev <unC0Rr@gmail.com> |
1907 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; version 2 of the License |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
18 |
*/ |
|
19 |
||
20 |
#include <QFile> |
|
21 |
#include <QTextStream> |
|
22 |
#include <QApplication> |
|
23 |
#include <QStringList> |
|
24 |
#include <QLineEdit> |
|
25 |
#include "namegen.h" |
|
26 |
#include "hwform.h" |
|
27 |
#include "hwconsts.h" |
|
28 |
||
29 |
||
30 |
HWNamegen::HWNamegen() : |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
31 |
TypesAvliable(false) |
1907 | 32 |
{ |
33 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
34 |
TypesLoad(); |
1907 | 35 |
} |
36 |
||
37 |
HWNamegen::~HWNamegen() |
|
38 |
{ |
|
39 |
} |
|
40 |
||
41 |
||
42 |
||
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
43 |
void HWNamegen::TeamRandomName(HWTeam*& team, const int HedgehogNumber) |
1907 | 44 |
{ |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
45 |
RandomNameByHat(team, HedgehogNumber); |
1907 | 46 |
} |
47 |
||
48 |
void HWNamegen::TeamRandomNames(HWTeam*& team, const bool changeteamname) |
|
49 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
50 |
if ((TypesHatnames.size() > 0) && TypesAvliable){ |
1907 | 51 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
52 |
int kind = (rand()%(TypesHatnames.size())); |
1907 | 53 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
54 |
if (changeteamname){ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
55 |
if (TypesTeamnames[kind].size() > 0){ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
56 |
team->TeamName = TypesTeamnames[kind][rand()%(TypesTeamnames[kind].size())]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
57 |
} |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
58 |
team->Grave = GetRandomGrave(); |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
59 |
team->Fort = GetRandomFort(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
60 |
team->Voicepack = "Default"; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
61 |
} |
1907 | 62 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
63 |
//give each hedgehog a random name: |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
64 |
//TODO: load the dictionary only once! (right now it's loaded once for each hedgehog) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
65 |
for(int i = 0; i < 8; i++) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
66 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
67 |
if ((TypesHatnames[kind].size()) > 0){ |
3344 | 68 |
team->Hedgehogs[i].Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
69 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
70 |
RandomNameByHat(team,i); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
71 |
} |
1907 | 72 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
73 |
} |
1907 | 74 |
|
75 |
} |
|
76 |
||
77 |
||
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
78 |
void HWNamegen::RandomNameByHat(HWTeam*& team, const int HedgehogNumber) |
1907 | 79 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
80 |
QStringList Dictionaries; |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
81 |
HatCfgLoad(team->Hedgehogs[HedgehogNumber].Hat,Dictionaries); |
1907 | 82 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
83 |
QStringList Dictionary; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
84 |
DictLoad(Dictionaries[rand()%(Dictionaries.size())],Dictionary); |
1907 | 85 |
|
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
86 |
team->Hedgehogs[HedgehogNumber].Name = Dictionary[rand()%(Dictionary.size())]; |
1907 | 87 |
} |
88 |
||
89 |
void HWNamegen::DictLoad(const QString filename, QStringList &list) |
|
90 |
{ |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
91 |
list.clear(); |
1907 | 92 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
93 |
QFile file; |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
94 |
file.setFileName(QString("%1/Data/Names/%2.txt").arg(cfgdir->absolutePath()).arg(filename)); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
95 |
if (!file.exists()) file.setFileName(QString("%1/Names/%2.txt").arg(datadir->absolutePath()).arg(filename)); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
96 |
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
97 |
{ |
1907 | 98 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
99 |
QTextStream in(&file); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
100 |
while (!in.atEnd()) { |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
101 |
QString line = in.readLine(); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
102 |
if(line != QString("")) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
103 |
{list.append(line);} |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
104 |
} |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
105 |
} |
1907 | 106 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
107 |
if (list.size()==0) |
1907 | 108 |
list.append(filename); |
109 |
||
110 |
} |
|
111 |
||
112 |
||
113 |
void HWNamegen::HatCfgLoad(const QString hatname, QStringList &list) |
|
114 |
{ |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
115 |
list.clear(); |
1907 | 116 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
117 |
QFile file; |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
118 |
file.setFileName(QString("%1/Data/Names/%2.cfg").arg(cfgdir->absolutePath()).arg(hatname)); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
119 |
if (!file.exists()) file.setFileName(QString("%1/Names/%2.cfg").arg(datadir->absolutePath()).arg(hatname)); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
120 |
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
121 |
{ |
1907 | 122 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
123 |
QTextStream in(&file); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
124 |
while (!in.atEnd()) { |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
125 |
QString line = in.readLine(); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
126 |
if(line != QString("")) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
127 |
{list.append(line);} |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
128 |
} |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
129 |
} |
1907 | 130 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
131 |
if (list.size()==0) |
1907 | 132 |
list.append(QString("generic")); |
133 |
||
134 |
} |
|
135 |
||
136 |
||
137 |
void HWNamegen::TypesLoad() |
|
138 |
{ |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
139 |
QFile file; |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
140 |
file.setFileName(QString("%1/Data/Names/types.ini").arg(cfgdir->absolutePath())); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
141 |
if (!file.exists()) file.setFileName(QString("%1/Names/types.ini").arg(datadir->absolutePath())); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
142 |
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
143 |
{TypesAvliable = FALSE; return;} |
1907 | 144 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
145 |
int counter = 0; //counter starts with 0 (teamnames mode) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
146 |
TypesTeamnames.append(QStringList()); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
147 |
TypesHatnames.append(QStringList()); |
1907 | 148 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
149 |
QTextStream in(&file); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
150 |
while (!in.atEnd()) { |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
151 |
QString line = in.readLine(); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
152 |
if (line == QString("#####")){ |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
153 |
counter++; //toggle mode (teamnames || hats) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
154 |
if ((counter%2) == 0){ |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
155 |
TypesTeamnames.append(QStringList()); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
156 |
TypesHatnames.append(QStringList()); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
157 |
} |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
158 |
} else if ((line == QString("*****")) || (line == QString("*END*"))){ |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
159 |
TypesAvliable = TRUE; return; // bye bye |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
160 |
} else { |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
161 |
if ((counter%2) == 0){ // even => teamnames mode |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
162 |
TypesTeamnames[(counter/2)].append(line); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
163 |
} else { // odd => hats mode |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
164 |
TypesHatnames[((counter-1)/2)].append(line); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
165 |
} |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
166 |
} |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
167 |
// Types.append(line); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
168 |
} |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
169 |
TypesAvliable = TRUE; |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
170 |
return; |
1907 | 171 |
} |
172 |
||
173 |
||
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
174 |
|
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
175 |
QString HWNamegen::GetRandomGrave() |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
176 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
177 |
QStringList Graves; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
178 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
179 |
//list all available Graves |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
180 |
QDir tmpdir; |
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
181 |
tmpdir.cd(cfgdir->absolutePath()); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
182 |
tmpdir.cd("Data/Graphics/Graves"); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
183 |
tmpdir.setFilter(QDir::Files); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
184 |
Graves.append(tmpdir.entryList(QStringList("*.png")).replaceInStrings(QRegExp("^(.*)\\.png"), "\\1")); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
185 |
|
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
186 |
tmpdir.cd(datadir->absolutePath()); |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
187 |
tmpdir.cd("Graphics/Graves"); |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
188 |
tmpdir.setFilter(QDir::Files); |
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
189 |
QStringList tmpList = tmpdir.entryList(QStringList("*.png")).replaceInStrings(QRegExp("^(.*)\\.png"), "\\1"); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
190 |
for (QStringList::Iterator it = tmpList.begin(); it != tmpList.end(); ++it) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5115
diff
changeset
|
191 |
if (!Graves.contains(*it,Qt::CaseInsensitive)) Graves.append(*it); |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
192 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
193 |
if(Graves.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
194 |
{ |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
195 |
//do some serious error handling |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
196 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
197 |
} |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
198 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
199 |
//pick a random grave |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
200 |
return Graves[rand()%(Graves.size())]; |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
201 |
} |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
202 |
|
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
203 |
QString HWNamegen::GetRandomFort() |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
204 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
205 |
QStringList Forts; |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
206 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
207 |
//list all available Forts |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
208 |
QDir tmpdir; |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
209 |
tmpdir.cd(datadir->absolutePath()); |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
210 |
tmpdir.cd("Forts"); |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
211 |
tmpdir.setFilter(QDir::Files); |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
212 |
Forts.append(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
213 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
214 |
if(Forts.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
215 |
{ |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
216 |
//do some serious error handling |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
217 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
218 |
} |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
219 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
220 |
//pick a random fort |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
221 |
return Forts[rand()%(Forts.size())]; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
222 |
} |