author | Wuzzy <almikes@aol.com> |
Thu, 13 Apr 2017 15:18:07 +0200 | |
changeset 12249 | 45c83c88ac4b |
parent 11893 | 618d99523933 |
child 12250 | 5206f9a803d1 |
permissions | -rw-r--r-- |
1907 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2009 Martin Minarik <ttsmj@pokec.sk> |
|
11046 | 4 |
* Copyright (c) 2004-2015 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1907 | 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" |
6930 | 26 |
#include "DataManager.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 |
|
12249 | 36 |
void HWNamegen::teamRandomFlag(HWTeam & team) |
37 |
{ |
|
38 |
team.setFlag(getRandomFlag()); |
|
39 |
} |
|
1907 | 40 |
|
12249 | 41 |
void HWNamegen::teamRandomVoice(HWTeam & team) |
42 |
{ |
|
43 |
team.setVoicepack(getRandomVoice()); |
|
44 |
} |
|
45 |
||
46 |
void HWNamegen::teamRandomGrave(HWTeam & team) |
|
47 |
{ |
|
48 |
team.setGrave(getRandomGrave()); |
|
49 |
} |
|
50 |
||
51 |
void HWNamegen::teamRandomFort(HWTeam & team) |
|
52 |
{ |
|
53 |
team.setFort(getRandomFort()); |
|
54 |
} |
|
55 |
||
56 |
void HWNamegen::teamRandomEverything(HWTeam & team, const bool changeteamname) |
|
1907 | 57 |
{ |
6024 | 58 |
// load types if not already loaded |
59 |
if (!typesAvailable) |
|
60 |
if (!loadTypes()) |
|
61 |
return; // abort if loading failed |
|
62 |
||
63 |
// abort if there are no hat types |
|
64 |
if (TypesHatnames.size() <= 0) |
|
65 |
return; |
|
1907 | 66 |
|
6024 | 67 |
// the hat will influence which names the hogs get |
68 |
int kind = (rand()%(TypesHatnames.size())); |
|
69 |
||
70 |
// pick team name based on hat |
|
71 |
if (changeteamname) |
|
72 |
{ |
|
73 |
if (TypesTeamnames[kind].size() > 0) |
|
74 |
team.setName(TypesTeamnames[kind][rand()%(TypesTeamnames[kind].size())]); |
|
1907 | 75 |
|
6024 | 76 |
team.setGrave(getRandomGrave()); |
77 |
team.setFort(getRandomFort()); |
|
11893
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
78 |
team.setFlag(getRandomFlag()); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
79 |
team.setVoicepack(getRandomVoice()); |
6024 | 80 |
} |
81 |
||
82 |
QStringList dicts; |
|
83 |
QStringList dict; |
|
84 |
||
85 |
if ((TypesHatnames[kind].size()) <= 0) |
|
86 |
{ |
|
87 |
dicts = dictsForHat(team.hedgehog(0).Hat); |
|
88 |
dict = dictContents(dicts[rand()%(dicts.size())]); |
|
89 |
} |
|
90 |
||
91 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
|
92 |
{ |
|
93 |
if ((TypesHatnames[kind].size()) > 0) |
|
94 |
{ |
|
95 |
HWHog hh = team.hedgehog(i); |
|
96 |
hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
|
97 |
team.setHedgehog(i,hh); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
98 |
} |
1907 | 99 |
|
6024 | 100 |
// there is a chance that this hog has the same hat as the previous one |
101 |
// let's reuse the hat-specific dict in this case |
|
6824
617a861b7750
i didn't even know it was possible (spotted by adam4813)
koda
parents:
6700
diff
changeset
|
102 |
if ((i == 0) || (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
|
103 |
{ |
6024 | 104 |
dicts = dictsForHat(team.hedgehog(i).Hat); |
105 |
dict = dictContents(dicts[rand()%(dicts.size())]); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
106 |
} |
1907 | 107 |
|
6024 | 108 |
// give each hedgehog a random name |
12249 | 109 |
HWNamegen::teamRandomHogName(team,i,dict); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
110 |
} |
1907 | 111 |
|
112 |
} |
|
113 |
||
12249 | 114 |
void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber) |
6024 | 115 |
{ |
116 |
QStringList dicts = dictsForHat(team.hedgehog(HedgehogNumber).Hat); |
|
1907 | 117 |
|
6024 | 118 |
QStringList dict = dictContents(dicts[rand()%(dicts.size())]); |
119 |
||
12249 | 120 |
teamRandomHogName(team, HedgehogNumber, dict); |
6024 | 121 |
} |
122 |
||
12249 | 123 |
void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber, const QStringList & dict) |
1907 | 124 |
{ |
6024 | 125 |
QStringList namesDict = dict; |
1907 | 126 |
|
6024 | 127 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
128 |
{ |
|
129 |
namesDict.removeOne(team.hedgehog(i).Name); |
|
130 |
} |
|
131 |
||
132 |
// if our dict doesn't have any new names we'll have to use duplicates |
|
133 |
if (namesDict.size() < 1) |
|
134 |
namesDict = dict; |
|
1907 | 135 |
|
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
|
136 |
HWHog hh = team.hedgehog(HedgehogNumber); |
6024 | 137 |
|
138 |
hh.Name = namesDict[rand()%(namesDict.size())]; |
|
139 |
||
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
|
140 |
team.setHedgehog(HedgehogNumber, hh); |
1907 | 141 |
} |
142 |
||
6024 | 143 |
QStringList HWNamegen::dictContents(const QString filename) |
1907 | 144 |
{ |
6024 | 145 |
QStringList list; |
1907 | 146 |
|
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
|
147 |
// find .txt to load the names from |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
148 |
QFile file(QString("physfs://Names/%1.txt").arg(filename)); |
6024 | 149 |
|
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
150 |
if (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
|
151 |
{ |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
152 |
QTextStream in(&file); |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
153 |
QString line; |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
154 |
do |
6024 | 155 |
{ |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
156 |
line = in.readLine(); |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
157 |
|
6024 | 158 |
if(!line.isEmpty()) |
159 |
list.append(line); |
|
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
160 |
} while (!line.isNull()); |
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 |
} |
1907 | 162 |
|
6024 | 163 |
if (list.size() == 0) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
164 |
list.append(filename); |
1907 | 165 |
|
6024 | 166 |
return list; |
1907 | 167 |
} |
168 |
||
169 |
||
6024 | 170 |
QStringList HWNamegen::dictsForHat(const QString hatname) |
1907 | 171 |
{ |
6024 | 172 |
QStringList list; |
1907 | 173 |
|
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
|
174 |
// find .cfg to load the dicts from |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
175 |
QFile file(QString("physfs://Names/%1.cfg").arg(hatname)); |
6024 | 176 |
|
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
177 |
if (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
|
178 |
{ |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
179 |
QTextStream in(&file); |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
180 |
QString line; |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
181 |
do |
6024 | 182 |
{ |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
183 |
line = in.readLine(); |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
184 |
|
6024 | 185 |
if(!line.isEmpty()) |
186 |
list.append(line); |
|
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
187 |
} while (!line.isNull()); |
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
|
188 |
} |
1907 | 189 |
|
6024 | 190 |
if (list.size() == 0) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
191 |
list.append(QString("generic")); |
1907 | 192 |
|
6024 | 193 |
return list; |
1907 | 194 |
} |
195 |
||
6024 | 196 |
// loades types from ini files. returns true on success. |
197 |
bool HWNamegen::loadTypes() |
|
198 |
{ |
|
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
|
199 |
typesAvailable = false; |
6024 | 200 |
|
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
|
201 |
// find .ini to load the names from |
8049 | 202 |
QFile * file = new QFile(QString("physfs://Names/types.ini")); |
6024 | 203 |
|
1907 | 204 |
|
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
|
205 |
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
|
206 |
{ |
1907 | 207 |
|
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
|
208 |
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
|
209 |
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
|
210 |
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
|
211 |
|
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 |
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
|
213 |
while (!in.atEnd()) |
6024 | 214 |
{ |
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
|
215 |
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
|
216 |
if (line == QString("#####")) |
6024 | 217 |
{ |
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
|
218 |
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
|
219 |
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
|
220 |
{ |
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 |
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
|
222 |
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
|
223 |
} |
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
|
224 |
} |
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
|
225 |
else if ((line == QString("*****")) || (line == QString("*END*"))) |
6024 | 226 |
{ |
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
|
227 |
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
|
228 |
return true; // bye bye |
6024 | 229 |
} |
230 |
else |
|
231 |
{ |
|
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
|
232 |
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
|
233 |
{ |
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 |
// 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
|
235 |
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
|
236 |
} |
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
|
237 |
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
|
238 |
{ |
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
|
239 |
// 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
|
240 |
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
|
241 |
} |
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
|
242 |
} |
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
|
243 |
} |
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
|
244 |
|
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
|
245 |
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
|
246 |
} |
6024 | 247 |
|
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
|
248 |
// 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
|
249 |
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
|
250 |
|
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 |
return typesAvailable; |
1907 | 252 |
} |
253 |
||
254 |
||
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
255 |
|
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
|
256 |
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
|
257 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
258 |
QStringList Graves; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
259 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
260 |
//list all available Graves |
6930 | 261 |
Graves.append(DataManager::instance().entryList( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
262 |
"Graphics/Graves", |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
263 |
QDir::Files, |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
264 |
QStringList("*.png") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
265 |
).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
|
266 |
); |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
267 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
268 |
if(Graves.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
269 |
{ |
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
|
270 |
// TODO do some serious error handling |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
271 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
272 |
} |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
273 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
274 |
//pick a random grave |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
275 |
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
|
276 |
} |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
277 |
|
11893
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
278 |
QString HWNamegen::getRandomFlag() |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
279 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
280 |
QStringList Flags; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
281 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
282 |
//list all available flags |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
283 |
Flags.append(DataManager::instance().entryList( |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
284 |
"Graphics/Flags", |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
285 |
QDir::Files, |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
286 |
QStringList("*.png") |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
287 |
).replaceInStrings(QRegExp("\\.png$"), "") |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
288 |
); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
289 |
//remove internal flags |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
290 |
Flags.removeAll("cpu"); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
291 |
Flags.removeAll("cpu_plain"); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
292 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
293 |
if(Flags.size()==0) |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
294 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
295 |
// TODO do some serious error handling |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
296 |
return "Error"; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
297 |
} |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
298 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
299 |
//pick a random flag |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
300 |
return Flags[rand()%(Flags.size())]; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
301 |
} |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
302 |
|
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
|
303 |
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
|
304 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
305 |
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
|
306 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
307 |
//list all available Forts |
6930 | 308 |
Forts.append(DataManager::instance().entryList( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
309 |
"Forts", |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
310 |
QDir::Files, |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
311 |
QStringList("*L.png") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
312 |
).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
|
313 |
); |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
314 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
315 |
if(Forts.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
316 |
{ |
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
|
317 |
// TODO do some serious error handling |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
318 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
319 |
} |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
320 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
321 |
//pick a random fort |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
322 |
return Forts[rand()%(Forts.size())]; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
323 |
} |
11893
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
324 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
325 |
QString HWNamegen::getRandomVoice() |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
326 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
327 |
QStringList Voices; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
328 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
329 |
//list all available voices |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
330 |
Voices.append(DataManager::instance().entryList( |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
331 |
"Sounds/voices", |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
332 |
QDir::Dirs | QDir::NoDotAndDotDot, |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
333 |
QStringList("*"))); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
334 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
335 |
if(Voices.size()==0) |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
336 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
337 |
// TODO do some serious error handling |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
338 |
return "Error"; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
339 |
} |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
340 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
341 |
//pick a random voice |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
342 |
return Voices[rand()%(Voices.size())]; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
343 |
} |