author | Wuzzy <almikes@aol.com> |
Sat, 23 Sep 2017 07:38:41 +0200 | |
changeset 12499 | d97050a7c074 |
parent 12295 | ac57d564efce |
child 12501 | 92c597704e57 |
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> |
|
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
21 |
#include <QFileInfo> |
1907 | 22 |
#include <QTextStream> |
23 |
#include <QStringList> |
|
24 |
#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
|
25 |
|
1907 | 26 |
#include "hwform.h" |
6930 | 27 |
#include "DataManager.h" |
1907 | 28 |
|
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
|
29 |
#include "namegen.h" |
1907 | 30 |
|
6024 | 31 |
HWNamegen::HWNamegen() {} |
1907 | 32 |
|
6024 | 33 |
QList<QStringList> HWNamegen::TypesTeamnames; |
34 |
QList<QStringList> HWNamegen::TypesHatnames; |
|
35 |
bool HWNamegen::typesAvailable = false; |
|
1907 | 36 |
|
12245
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
37 |
void HWNamegen::teamRandomTeamName(HWTeam & team) |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
38 |
{ |
12247
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
39 |
QString newName = getRandomTeamName(-1); |
12245
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
40 |
if(!newName.isNull()) |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
41 |
team.setName(newName); |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
42 |
} |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
43 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
44 |
void HWNamegen::teamRandomFlag(HWTeam & team, bool withDLC) |
12244 | 45 |
{ |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
46 |
team.setFlag(getRandomFlag(withDLC)); |
12244 | 47 |
} |
1907 | 48 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
49 |
void HWNamegen::teamRandomVoice(HWTeam & team, bool withDLC) |
12244 | 50 |
{ |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
51 |
team.setVoicepack(getRandomVoice(withDLC)); |
12244 | 52 |
} |
53 |
||
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
54 |
void HWNamegen::teamRandomGrave(HWTeam & team, bool withDLC) |
12244 | 55 |
{ |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
56 |
team.setGrave(getRandomGrave(withDLC)); |
12244 | 57 |
} |
58 |
||
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
59 |
void HWNamegen::teamRandomFort(HWTeam & team, bool withDLC) |
12244 | 60 |
{ |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
61 |
team.setFort(getRandomFort(withDLC)); |
12244 | 62 |
} |
63 |
||
12248
07f67ee424dc
Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents:
12247
diff
changeset
|
64 |
void HWNamegen::teamRandomEverything(HWTeam & team, const RandomTeamMode mode) |
1907 | 65 |
{ |
6024 | 66 |
// load types if not already loaded |
67 |
if (!typesAvailable) |
|
68 |
if (!loadTypes()) |
|
69 |
return; // abort if loading failed |
|
70 |
||
71 |
// abort if there are no hat types |
|
72 |
if (TypesHatnames.size() <= 0) |
|
73 |
return; |
|
1907 | 74 |
|
6024 | 75 |
// the hat will influence which names the hogs get |
76 |
int kind = (rand()%(TypesHatnames.size())); |
|
77 |
||
78 |
// pick team name based on hat |
|
12248
07f67ee424dc
Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents:
12247
diff
changeset
|
79 |
if (mode == HWNamegen::rtmEverything) |
6024 | 80 |
{ |
12247
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
81 |
team.setName(getRandomTeamName(kind)); |
6024 | 82 |
team.setGrave(getRandomGrave()); |
83 |
team.setFort(getRandomFort()); |
|
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
84 |
team.setFlag(getRandomFlag()); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
85 |
team.setVoicepack(getRandomVoice()); |
6024 | 86 |
} |
87 |
||
88 |
QStringList dicts; |
|
89 |
QStringList dict; |
|
90 |
||
91 |
if ((TypesHatnames[kind].size()) <= 0) |
|
92 |
{ |
|
93 |
dicts = dictsForHat(team.hedgehog(0).Hat); |
|
94 |
dict = dictContents(dicts[rand()%(dicts.size())]); |
|
95 |
} |
|
96 |
||
97 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
|
98 |
{ |
|
12248
07f67ee424dc
Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents:
12247
diff
changeset
|
99 |
if (((TypesHatnames[kind].size()) > 0) && (mode == HWNamegen::rtmEverything || mode == HWNamegen::rtmHats)) |
6024 | 100 |
{ |
101 |
HWHog hh = team.hedgehog(i); |
|
102 |
hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
|
103 |
team.setHedgehog(i,hh); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
104 |
} |
6024 | 105 |
// there is a chance that this hog has the same hat as the previous one |
106 |
// 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
|
107 |
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
|
108 |
{ |
6024 | 109 |
dicts = dictsForHat(team.hedgehog(i).Hat); |
110 |
dict = dictContents(dicts[rand()%(dicts.size())]); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
111 |
} |
1907 | 112 |
|
6024 | 113 |
// give each hedgehog a random name |
12248
07f67ee424dc
Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents:
12247
diff
changeset
|
114 |
if (mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything) |
07f67ee424dc
Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents:
12247
diff
changeset
|
115 |
HWNamegen::teamRandomHogName(team,i,dict); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
116 |
} |
1907 | 117 |
|
118 |
} |
|
119 |
||
12244 | 120 |
void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber) |
6024 | 121 |
{ |
122 |
QStringList dicts = dictsForHat(team.hedgehog(HedgehogNumber).Hat); |
|
1907 | 123 |
|
6024 | 124 |
QStringList dict = dictContents(dicts[rand()%(dicts.size())]); |
125 |
||
12244 | 126 |
teamRandomHogName(team, HedgehogNumber, dict); |
6024 | 127 |
} |
128 |
||
12244 | 129 |
void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber, const QStringList & dict) |
1907 | 130 |
{ |
6024 | 131 |
QStringList namesDict = dict; |
1907 | 132 |
|
6024 | 133 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
134 |
{ |
|
135 |
namesDict.removeOne(team.hedgehog(i).Name); |
|
136 |
} |
|
137 |
||
138 |
// if our dict doesn't have any new names we'll have to use duplicates |
|
139 |
if (namesDict.size() < 1) |
|
140 |
namesDict = dict; |
|
1907 | 141 |
|
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
|
142 |
HWHog hh = team.hedgehog(HedgehogNumber); |
6024 | 143 |
|
144 |
hh.Name = namesDict[rand()%(namesDict.size())]; |
|
145 |
||
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
|
146 |
team.setHedgehog(HedgehogNumber, hh); |
1907 | 147 |
} |
148 |
||
6024 | 149 |
QStringList HWNamegen::dictContents(const QString filename) |
1907 | 150 |
{ |
6024 | 151 |
QStringList list; |
1907 | 152 |
|
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
|
153 |
// 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
|
154 |
QFile file(QString("physfs://Names/%1.txt").arg(filename)); |
6024 | 155 |
|
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
156 |
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
|
157 |
{ |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
158 |
QTextStream in(&file); |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
159 |
QString line; |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
160 |
do |
6024 | 161 |
{ |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
162 |
line = in.readLine(); |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
163 |
|
6024 | 164 |
if(!line.isEmpty()) |
165 |
list.append(line); |
|
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
166 |
} 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
|
167 |
} |
1907 | 168 |
|
6024 | 169 |
if (list.size() == 0) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
170 |
list.append(filename); |
1907 | 171 |
|
6024 | 172 |
return list; |
1907 | 173 |
} |
174 |
||
175 |
||
6024 | 176 |
QStringList HWNamegen::dictsForHat(const QString hatname) |
1907 | 177 |
{ |
6024 | 178 |
QStringList list; |
1907 | 179 |
|
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
180 |
// Find and check .cfg to load the dicts from |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
181 |
QString path = QString("physfs://Names/%1.cfg").arg(hatname); |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
182 |
QFileInfo check_file(path); |
6024 | 183 |
|
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
184 |
// Note: The .cfg file is optional; a fallback mechanism is in place (see below) |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
185 |
|
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
186 |
// Check if file exists to prevent PhysFS from complaining in console so much |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
187 |
if (check_file.exists() && check_file.isFile()) |
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 |
{ |
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
189 |
QFile file(path); |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
190 |
|
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
191 |
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
6024 | 192 |
{ |
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
193 |
QTextStream in(&file); |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
194 |
QString line; |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
195 |
do |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
196 |
{ |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
197 |
line = in.readLine(); |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
198 |
|
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
199 |
if(!line.isEmpty()) |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
200 |
list.append(line); |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
201 |
} while (!line.isNull()); |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
202 |
} |
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
|
203 |
} |
1907 | 204 |
|
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
205 |
// Use Data/Names/generic.cfg by default |
6024 | 206 |
if (list.size() == 0) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
207 |
list.append(QString("generic")); |
1907 | 208 |
|
6024 | 209 |
return list; |
1907 | 210 |
} |
211 |
||
6024 | 212 |
// loades types from ini files. returns true on success. |
213 |
bool HWNamegen::loadTypes() |
|
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 |
typesAvailable = false; |
6024 | 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 |
// find .ini to load the names from |
8049 | 218 |
QFile * file = new QFile(QString("physfs://Names/types.ini")); |
6024 | 219 |
|
1907 | 220 |
|
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
|
221 |
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
|
222 |
{ |
1907 | 223 |
|
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
|
224 |
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
|
225 |
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
|
226 |
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
|
227 |
|
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 |
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
|
229 |
while (!in.atEnd()) |
6024 | 230 |
{ |
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
|
231 |
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
|
232 |
if (line == QString("#####")) |
6024 | 233 |
{ |
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
|
234 |
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
|
235 |
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
|
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 |
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
|
238 |
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
|
239 |
} |
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
|
240 |
} |
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
|
241 |
else if ((line == QString("*****")) || (line == QString("*END*"))) |
6024 | 242 |
{ |
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
|
243 |
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
|
244 |
return true; // bye bye |
6024 | 245 |
} |
246 |
else |
|
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 |
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
|
249 |
{ |
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 |
// 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
|
251 |
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
|
252 |
} |
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
|
253 |
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
|
254 |
{ |
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 |
// 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
|
256 |
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
|
257 |
} |
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
|
258 |
} |
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
|
259 |
} |
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
|
260 |
|
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
|
261 |
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
|
262 |
} |
6024 | 263 |
|
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
|
264 |
// 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
|
265 |
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
|
266 |
|
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
|
267 |
return typesAvailable; |
1907 | 268 |
} |
269 |
||
12247
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
270 |
/* Generates a random team name. |
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
271 |
kind: Use to select a team name out of a group (types.ini). |
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
272 |
Use a negative value if you don't care. |
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
273 |
This function may return a null QString on error(this should never happen). */ |
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
274 |
QString HWNamegen::getRandomTeamName(int kind) |
12245
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
275 |
{ |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
276 |
// load types if not already loaded |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
277 |
if (!typesAvailable) |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
278 |
if (!loadTypes()) |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
279 |
return QString(); // abort if loading failed |
1907 | 280 |
|
12245
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
281 |
// abort if there are no hat types |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
282 |
if (TypesHatnames.size() <= 0) |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
283 |
return QString(); |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
284 |
|
12247
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
285 |
if(kind < 0) |
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
286 |
kind = (rand()%(TypesHatnames.size())); |
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
287 |
|
12245
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
288 |
if (TypesTeamnames[kind].size() > 0) |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
289 |
return TypesTeamnames[kind][rand()%(TypesTeamnames[kind].size())]; |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
290 |
else |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
291 |
return QString(); |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
292 |
} |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
293 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
294 |
QString HWNamegen::getRandomGrave(bool withDLC) |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
295 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
296 |
QStringList Graves; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
297 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
298 |
//list all available Graves |
6930 | 299 |
Graves.append(DataManager::instance().entryList( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
300 |
"Graphics/Graves", |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
301 |
QDir::Files, |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
302 |
QStringList("*.png"), |
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
303 |
withDLC |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
304 |
).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
|
305 |
); |
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 |
if(Graves.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
308 |
{ |
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
|
309 |
// TODO do some serious error handling |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
310 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
311 |
} |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
312 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
313 |
//pick a random grave |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
314 |
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
|
315 |
} |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
316 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
317 |
QString HWNamegen::getRandomFlag(bool withDLC) |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
318 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
319 |
QStringList Flags; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
320 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
321 |
//list all available flags |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
322 |
Flags.append(DataManager::instance().entryList( |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
323 |
"Graphics/Flags", |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
324 |
QDir::Files, |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
325 |
QStringList("*.png"), |
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
326 |
withDLC |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
327 |
).replaceInStrings(QRegExp("\\.png$"), "") |
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 |
//remove internal flags |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
330 |
Flags.removeAll("cpu"); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
331 |
Flags.removeAll("cpu_plain"); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
332 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
333 |
if(Flags.size()==0) |
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 |
// TODO do some serious error handling |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
336 |
return "Error"; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
337 |
} |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
338 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
339 |
//pick a random flag |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
340 |
return Flags[rand()%(Flags.size())]; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
341 |
} |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
342 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
343 |
QString HWNamegen::getRandomFort(bool withDLC) |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
344 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
345 |
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
|
346 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
347 |
//list all available Forts |
6930 | 348 |
Forts.append(DataManager::instance().entryList( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
349 |
"Forts", |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
350 |
QDir::Files, |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
351 |
QStringList("*L.png"), |
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
352 |
withDLC |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
353 |
).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
|
354 |
); |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
355 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
356 |
if(Forts.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
357 |
{ |
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
|
358 |
// TODO do some serious error handling |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
359 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
360 |
} |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
361 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
362 |
//pick a random fort |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
363 |
return Forts[rand()%(Forts.size())]; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
364 |
} |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
365 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
366 |
QString HWNamegen::getRandomVoice(bool withDLC) |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
367 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
368 |
QStringList Voices; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
369 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
370 |
//list all available voices |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
371 |
Voices.append(DataManager::instance().entryList( |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
372 |
"Sounds/voices", |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
373 |
QDir::Dirs | QDir::NoDotAndDotDot, |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
374 |
QStringList("*"), |
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
375 |
withDLC)); |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
376 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
377 |
if(Voices.size()==0) |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
378 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
379 |
// TODO do some serious error handling |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
380 |
return "Error"; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
381 |
} |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
382 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
383 |
//pick a random voice |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
384 |
return Voices[rand()%(Voices.size())]; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
385 |
} |