author | koda |
Sat, 18 Feb 2012 19:29:16 +0100 | |
changeset 6711 | 76e96101a84f |
parent 6700 | e04da46ee43c |
child 6824 | 617a861b7750 |
permissions | -rw-r--r-- |
1907 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2009 Martin Minarik <ttsmj@pokec.sk> |
|
6700 | 4 |
* Copyright (c) 2009-2012 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 <QStringList> |
|
23 |
#include <QLineEdit> |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
24 |
|
1907 | 25 |
#include "hwform.h" |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
26 |
#include "HWDataManager.h" |
1907 | 27 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
28 |
#include "namegen.h" |
1907 | 29 |
|
6024 | 30 |
HWNamegen::HWNamegen() {} |
1907 | 31 |
|
6024 | 32 |
QList<QStringList> HWNamegen::TypesTeamnames; |
33 |
QList<QStringList> HWNamegen::TypesHatnames; |
|
34 |
bool HWNamegen::typesAvailable = false; |
|
1907 | 35 |
|
36 |
||
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5252
diff
changeset
|
37 |
void HWNamegen::teamRandomNames(HWTeam & team, const bool changeteamname) |
1907 | 38 |
{ |
6024 | 39 |
// load types if not already loaded |
40 |
if (!typesAvailable) |
|
41 |
if (!loadTypes()) |
|
42 |
return; // abort if loading failed |
|
43 |
||
44 |
// abort if there are no hat types |
|
45 |
if (TypesHatnames.size() <= 0) |
|
46 |
return; |
|
1907 | 47 |
|
6024 | 48 |
// the hat will influence which names the hogs get |
49 |
int kind = (rand()%(TypesHatnames.size())); |
|
50 |
||
51 |
// pick team name based on hat |
|
52 |
if (changeteamname) |
|
53 |
{ |
|
54 |
if (TypesTeamnames[kind].size() > 0) |
|
55 |
team.setName(TypesTeamnames[kind][rand()%(TypesTeamnames[kind].size())]); |
|
1907 | 56 |
|
6024 | 57 |
team.setGrave(getRandomGrave()); |
58 |
team.setFort(getRandomFort()); |
|
59 |
team.setVoicepack("Default"); |
|
60 |
} |
|
61 |
||
62 |
QStringList dicts; |
|
63 |
QStringList dict; |
|
64 |
||
65 |
if ((TypesHatnames[kind].size()) <= 0) |
|
66 |
{ |
|
67 |
dicts = dictsForHat(team.hedgehog(0).Hat); |
|
68 |
dict = dictContents(dicts[rand()%(dicts.size())]); |
|
69 |
} |
|
70 |
||
71 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
|
72 |
{ |
|
73 |
if ((TypesHatnames[kind].size()) > 0) |
|
74 |
{ |
|
75 |
HWHog hh = team.hedgehog(i); |
|
76 |
hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
|
77 |
team.setHedgehog(i,hh); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
78 |
} |
1907 | 79 |
|
6024 | 80 |
// there is a chance that this hog has the same hat as the previous one |
81 |
// let's reuse the hat-specific dict in this case |
|
82 |
if ((i == 0) or (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat)) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
83 |
{ |
6024 | 84 |
dicts = dictsForHat(team.hedgehog(i).Hat); |
85 |
dict = dictContents(dicts[rand()%(dicts.size())]); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
86 |
} |
1907 | 87 |
|
6024 | 88 |
// give each hedgehog a random name |
89 |
HWNamegen::teamRandomName(team,i,dict); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
90 |
} |
1907 | 91 |
|
92 |
} |
|
93 |
||
6024 | 94 |
void HWNamegen::teamRandomName(HWTeam & team, const int HedgehogNumber) |
95 |
{ |
|
96 |
QStringList dicts = dictsForHat(team.hedgehog(HedgehogNumber).Hat); |
|
1907 | 97 |
|
6024 | 98 |
QStringList dict = dictContents(dicts[rand()%(dicts.size())]); |
99 |
||
100 |
teamRandomName(team, HedgehogNumber, dict); |
|
101 |
} |
|
102 |
||
103 |
void HWNamegen::teamRandomName(HWTeam & team, const int HedgehogNumber, const QStringList & dict) |
|
1907 | 104 |
{ |
6024 | 105 |
QStringList namesDict = dict; |
1907 | 106 |
|
6024 | 107 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
108 |
{ |
|
109 |
namesDict.removeOne(team.hedgehog(i).Name); |
|
110 |
} |
|
111 |
||
112 |
// if our dict doesn't have any new names we'll have to use duplicates |
|
113 |
if (namesDict.size() < 1) |
|
114 |
namesDict = dict; |
|
1907 | 115 |
|
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5252
diff
changeset
|
116 |
HWHog hh = team.hedgehog(HedgehogNumber); |
6024 | 117 |
|
118 |
hh.Name = namesDict[rand()%(namesDict.size())]; |
|
119 |
||
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5252
diff
changeset
|
120 |
team.setHedgehog(HedgehogNumber, hh); |
1907 | 121 |
} |
122 |
||
6024 | 123 |
QStringList HWNamegen::dictContents(const QString filename) |
1907 | 124 |
{ |
6024 | 125 |
QStringList list; |
1907 | 126 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
127 |
// find .txt to load the names from |
6167 | 128 |
QFile * file = new QFile(HWDataManager::instance().findFileForRead(QString( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
129 |
"Names/%1.txt").arg(filename))); |
6024 | 130 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
131 |
if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) |
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
|
132 |
{ |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
133 |
QTextStream in(file); |
6024 | 134 |
while (!in.atEnd()) |
135 |
{ |
|
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
|
136 |
QString line = in.readLine(); |
6024 | 137 |
if(!line.isEmpty()) |
138 |
list.append(line); |
|
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 |
} |
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 |
} |
1907 | 141 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
142 |
// this QFile isn't needed any further |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
143 |
delete file; |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
144 |
|
6024 | 145 |
if (list.size() == 0) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
146 |
list.append(filename); |
1907 | 147 |
|
6024 | 148 |
return list; |
1907 | 149 |
} |
150 |
||
151 |
||
6024 | 152 |
QStringList HWNamegen::dictsForHat(const QString hatname) |
1907 | 153 |
{ |
6024 | 154 |
QStringList list; |
1907 | 155 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
156 |
// find .cfg to load the dicts from |
6167 | 157 |
QFile * file = new QFile(HWDataManager::instance().findFileForRead(QString( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
158 |
"Names/%1.cfg").arg(hatname))); |
6024 | 159 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
160 |
if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) |
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
|
161 |
{ |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
162 |
QTextStream in(file); |
6024 | 163 |
while (!in.atEnd()) |
164 |
{ |
|
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
|
165 |
QString line = in.readLine(); |
6024 | 166 |
if(!line.isEmpty()) |
167 |
list.append(line); |
|
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
|
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 |
} |
1907 | 170 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
171 |
// this QFile isn't needed any further |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
172 |
delete file; |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
173 |
|
6024 | 174 |
if (list.size() == 0) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
175 |
list.append(QString("generic")); |
1907 | 176 |
|
6024 | 177 |
return list; |
1907 | 178 |
} |
179 |
||
6024 | 180 |
// loades types from ini files. returns true on success. |
181 |
bool HWNamegen::loadTypes() |
|
182 |
{ |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
183 |
typesAvailable = false; |
6024 | 184 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
185 |
// find .ini to load the names from |
6167 | 186 |
QFile * file = new QFile( |
187 |
HWDataManager::instance().findFileForRead(QString("Names/types.ini"))); |
|
6024 | 188 |
|
1907 | 189 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
190 |
if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
191 |
{ |
1907 | 192 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
193 |
int counter = 0; //counter starts with 0 (teamnames mode) |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
194 |
TypesTeamnames.append(QStringList()); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
195 |
TypesHatnames.append(QStringList()); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
196 |
|
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
197 |
QTextStream in(file); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
198 |
while (!in.atEnd()) |
6024 | 199 |
{ |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
200 |
QString line = in.readLine(); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
201 |
if (line == QString("#####")) |
6024 | 202 |
{ |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
203 |
counter++; //toggle mode (teamnames || hats) |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
204 |
if ((counter%2) == 0) |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
205 |
{ |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
206 |
TypesTeamnames.append(QStringList()); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
207 |
TypesHatnames.append(QStringList()); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
208 |
} |
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
|
209 |
} |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
210 |
else if ((line == QString("*****")) || (line == QString("*END*"))) |
6024 | 211 |
{ |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
212 |
typesAvailable = true; |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
213 |
return true; // bye bye |
6024 | 214 |
} |
215 |
else |
|
216 |
{ |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
217 |
if ((counter%2) == 0) |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
218 |
{ |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
219 |
// even => teamnames mode |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
220 |
TypesTeamnames[(counter/2)].append(line); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
221 |
} |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
222 |
else |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
223 |
{ |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
224 |
// odd => hats mode |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
225 |
TypesHatnames[((counter-1)/2)].append(line); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
226 |
} |
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
|
227 |
} |
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
|
228 |
} |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
229 |
|
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
230 |
typesAvailable = true; |
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
|
231 |
} |
6024 | 232 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
233 |
// this QFile isn't needed any further |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
234 |
delete file; |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
235 |
|
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
236 |
return typesAvailable; |
1907 | 237 |
} |
238 |
||
239 |
||
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
240 |
|
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5252
diff
changeset
|
241 |
QString HWNamegen::getRandomGrave() |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
242 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
243 |
QStringList Graves; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
244 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
245 |
//list all available Graves |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
246 |
Graves.append(HWDataManager::instance().entryList( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
247 |
"Graphics/Graves", |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
248 |
QDir::Files, |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
249 |
QStringList("*.png") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
250 |
).replaceInStrings(QRegExp("\\.png$"), "") |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
251 |
); |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
252 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
253 |
if(Graves.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
254 |
{ |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
255 |
// TODO do some serious error handling |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
256 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
257 |
} |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
258 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
259 |
//pick a random grave |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
260 |
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
|
261 |
} |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
262 |
|
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5252
diff
changeset
|
263 |
QString HWNamegen::getRandomFort() |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
264 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
265 |
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
|
266 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
267 |
//list all available Forts |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
268 |
Forts.append(HWDataManager::instance().entryList( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
269 |
"Forts", |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
270 |
QDir::Files, |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
271 |
QStringList("*L.png") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
272 |
).replaceInStrings(QRegExp("L\\.png$"), "") |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
273 |
); |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
274 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
275 |
if(Forts.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
276 |
{ |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6060
diff
changeset
|
277 |
// TODO do some serious error handling |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
278 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
279 |
} |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
280 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
281 |
//pick a random fort |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
282 |
return Forts[rand()%(Forts.size())]; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
283 |
} |