author | unc0rr |
Sat, 12 Jun 2021 20:15:42 +0200 | |
changeset 15812 | efe4e3290870 |
parent 14956 | 4accf3e18dbc |
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 |
||
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
64 |
void HWNamegen::teamRandomEverything(HWTeam & team) |
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 |
||
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
78 |
team.setGrave(getRandomGrave()); |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
79 |
team.setFort(getRandomFort()); |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
80 |
team.setFlag(getRandomFlag()); |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
81 |
team.setVoicepack(getRandomVoice()); |
6024 | 82 |
|
83 |
QStringList dicts; |
|
84 |
QStringList dict; |
|
85 |
||
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
86 |
// Randomness mode: |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
87 |
// 0: Themed hats (from types.ini) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
88 |
// 1: Equal hats for all |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
89 |
// 2: Random hat for each hedgehog |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
90 |
int r = rand() % 10; |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
91 |
int randomMode; |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
92 |
if (r <= 4) // 0-4 (50%) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
93 |
randomMode = 0; |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
94 |
else if (r <= 8) // 5-8 (40%) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
95 |
randomMode = 1; |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
96 |
else // 9 (10%) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
97 |
randomMode = 2; |
6024 | 98 |
|
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
99 |
// Generate random hats |
6024 | 100 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
101 |
{ |
|
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
102 |
HWHog hh = team.hedgehog(i); |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
103 |
|
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
104 |
if (randomMode == 0) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
105 |
{ |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
106 |
hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
107 |
} |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
108 |
else if (randomMode == 1) |
6024 | 109 |
{ |
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
110 |
if (i == 0) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
111 |
{ |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
112 |
hh.Hat = getRandomHat(); |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
113 |
} |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
114 |
else |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
115 |
{ |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
116 |
hh.Hat = team.hedgehog(i-1).Hat; |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
117 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
118 |
} |
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
119 |
else if (randomMode == 2) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
120 |
{ |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
121 |
hh.Hat = getRandomHat(); |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
122 |
} |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
123 |
|
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
124 |
team.setHedgehog(i,hh); |
12501
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
125 |
|
6024 | 126 |
// there is a chance that this hog has the same hat as the previous one |
127 |
// let's reuse the hat-specific dict in this case |
|
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
128 |
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
|
129 |
{ |
6024 | 130 |
dicts = dictsForHat(team.hedgehog(i).Hat); |
131 |
dict = dictContents(dicts[rand()%(dicts.size())]); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
132 |
} |
1907 | 133 |
|
6024 | 134 |
// give each hedgehog a random name |
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
135 |
HWNamegen::teamRandomHogName(team,i,dict); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2192
diff
changeset
|
136 |
} |
1907 | 137 |
|
12630
11f5fe0407e5
Use generic team names for non-themed random teams; add a bunch of more random team names
Wuzzy <almikes@aol.com>
parents:
12505
diff
changeset
|
138 |
// If using themed hats, use themed team name. |
11f5fe0407e5
Use generic team names for non-themed random teams; add a bunch of more random team names
Wuzzy <almikes@aol.com>
parents:
12505
diff
changeset
|
139 |
// Otherwise, only use “generic” team names from the first team |
11f5fe0407e5
Use generic team names for non-themed random teams; add a bunch of more random team names
Wuzzy <almikes@aol.com>
parents:
12505
diff
changeset
|
140 |
// in types.txt. |
11f5fe0407e5
Use generic team names for non-themed random teams; add a bunch of more random team names
Wuzzy <almikes@aol.com>
parents:
12505
diff
changeset
|
141 |
if (randomMode == 0) |
11f5fe0407e5
Use generic team names for non-themed random teams; add a bunch of more random team names
Wuzzy <almikes@aol.com>
parents:
12505
diff
changeset
|
142 |
team.setName(getRandomTeamName(kind)); |
11f5fe0407e5
Use generic team names for non-themed random teams; add a bunch of more random team names
Wuzzy <almikes@aol.com>
parents:
12505
diff
changeset
|
143 |
else |
11f5fe0407e5
Use generic team names for non-themed random teams; add a bunch of more random team names
Wuzzy <almikes@aol.com>
parents:
12505
diff
changeset
|
144 |
team.setName(getRandomTeamName(0)); |
11f5fe0407e5
Use generic team names for non-themed random teams; add a bunch of more random team names
Wuzzy <almikes@aol.com>
parents:
12505
diff
changeset
|
145 |
|
1907 | 146 |
} |
147 |
||
12502
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
148 |
// Set random hats for entire team |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
149 |
void HWNamegen::teamRandomHats(HWTeam & team, bool withDLC) |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
150 |
{ |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
151 |
// 50% chance that all hogs are set to the same hat. |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
152 |
// 50% chance that each hog gets a random head individually. |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
153 |
|
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
154 |
bool sameHogs = (rand()%2) == 0; |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
155 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
156 |
{ |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
157 |
HWHog hh = team.hedgehog(i); |
13931 | 158 |
if (sameHogs && i > 0) |
12502
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
159 |
hh.Hat = team.hedgehog(i-1).Hat; |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
160 |
else |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
161 |
hh.Hat = getRandomHat(withDLC); |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
162 |
team.setHedgehog(i, hh); |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
163 |
} |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
164 |
} |
f4b0e164a0d5
Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents:
12501
diff
changeset
|
165 |
|
12501
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
166 |
void HWNamegen::teamRandomHat(HWTeam & team, const int HedgehogNumber, bool withDLC) |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
167 |
{ |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
168 |
HWHog hh = team.hedgehog(HedgehogNumber); |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
169 |
|
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
170 |
hh.Hat = getRandomHat(withDLC); |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
171 |
|
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
172 |
team.setHedgehog(HedgehogNumber, hh); |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
173 |
} |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
174 |
|
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
175 |
void HWNamegen::teamRandomHat(HWTeam & team, const int HedgehogNumber, const QStringList & dict) |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
176 |
{ |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
177 |
HWHog hh = team.hedgehog(HedgehogNumber); |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
178 |
|
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
179 |
hh.Name = dict[rand()%(dict.size())]; |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
180 |
|
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
181 |
team.setHedgehog(HedgehogNumber, hh); |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
182 |
} |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
183 |
|
12505
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
184 |
void HWNamegen::teamRandomHogNames(HWTeam & team) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
185 |
{ |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
186 |
QStringList dicts, dict; |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
187 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
188 |
{ |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
189 |
// there is a chance that this hog has the same hat as the previous one |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
190 |
// let's reuse the hat-specific dict in this case |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
191 |
if ((i == 0) || (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat)) |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
192 |
{ |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
193 |
dicts = dictsForHat(team.hedgehog(i).Hat); |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
194 |
dict = dictContents(dicts[rand()%(dicts.size())]); |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
195 |
} |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
196 |
|
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
197 |
// give each hedgehog a random name |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
198 |
HWNamegen::teamRandomHogName(team,i,dict); |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
199 |
} |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
200 |
} |
82c75a317d48
Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents:
12502
diff
changeset
|
201 |
|
12244 | 202 |
void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber) |
6024 | 203 |
{ |
204 |
QStringList dicts = dictsForHat(team.hedgehog(HedgehogNumber).Hat); |
|
1907 | 205 |
|
6024 | 206 |
QStringList dict = dictContents(dicts[rand()%(dicts.size())]); |
207 |
||
12244 | 208 |
teamRandomHogName(team, HedgehogNumber, dict); |
6024 | 209 |
} |
210 |
||
12244 | 211 |
void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber, const QStringList & dict) |
1907 | 212 |
{ |
6024 | 213 |
QStringList namesDict = dict; |
1907 | 214 |
|
6024 | 215 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
216 |
{ |
|
217 |
namesDict.removeOne(team.hedgehog(i).Name); |
|
218 |
} |
|
219 |
||
220 |
// if our dict doesn't have any new names we'll have to use duplicates |
|
221 |
if (namesDict.size() < 1) |
|
222 |
namesDict = dict; |
|
1907 | 223 |
|
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
|
224 |
HWHog hh = team.hedgehog(HedgehogNumber); |
6024 | 225 |
|
226 |
hh.Name = namesDict[rand()%(namesDict.size())]; |
|
227 |
||
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
|
228 |
team.setHedgehog(HedgehogNumber, hh); |
1907 | 229 |
} |
230 |
||
14956
4accf3e18dbc
Add withDLC for getLocalizedDefaultVoice
Wuzzy <Wuzzy2@mail.ru>
parents:
14955
diff
changeset
|
231 |
void HWNamegen::teamLocalizedDefaultVoice(HWTeam & team, bool withDLC) |
14955
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
232 |
{ |
14956
4accf3e18dbc
Add withDLC for getLocalizedDefaultVoice
Wuzzy <Wuzzy2@mail.ru>
parents:
14955
diff
changeset
|
233 |
team.setVoicepack(getLocalizedDefaultVoice(withDLC)); |
14955
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
234 |
} |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
235 |
|
6024 | 236 |
QStringList HWNamegen::dictContents(const QString filename) |
1907 | 237 |
{ |
6024 | 238 |
QStringList list; |
1907 | 239 |
|
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
|
240 |
// 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
|
241 |
QFile file(QString("physfs://Names/%1.txt").arg(filename)); |
6024 | 242 |
|
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
243 |
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
|
244 |
{ |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
245 |
QTextStream in(&file); |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
246 |
QString line; |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
247 |
do |
6024 | 248 |
{ |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
249 |
line = in.readLine(); |
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
250 |
|
6024 | 251 |
if(!line.isEmpty()) |
252 |
list.append(line); |
|
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
253 |
} 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
|
254 |
} |
1907 | 255 |
|
6024 | 256 |
if (list.size() == 0) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
257 |
list.append(filename); |
1907 | 258 |
|
6024 | 259 |
return list; |
1907 | 260 |
} |
261 |
||
262 |
||
6024 | 263 |
QStringList HWNamegen::dictsForHat(const QString hatname) |
1907 | 264 |
{ |
6024 | 265 |
QStringList list; |
1907 | 266 |
|
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
267 |
// 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
|
268 |
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
|
269 |
QFileInfo check_file(path); |
6024 | 270 |
|
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
271 |
// 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
|
272 |
|
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
273 |
// 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
|
274 |
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
|
275 |
{ |
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
276 |
QFile file(path); |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
277 |
|
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
278 |
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
6024 | 279 |
{ |
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
280 |
QTextStream in(&file); |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
281 |
QString line; |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
282 |
do |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
283 |
{ |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
284 |
line = in.readLine(); |
8110
9f5fe3fc9d16
Use alternative way of checking for file end. Also refactor this code a bit.
unc0rr
parents:
8049
diff
changeset
|
285 |
|
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
286 |
if(!line.isEmpty()) |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
287 |
list.append(line); |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
288 |
} while (!line.isNull()); |
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
289 |
} |
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
|
290 |
} |
1907 | 291 |
|
12499
d97050a7c074
Stop PhysFS from complaining when a random name .cfg file is missing
Wuzzy <almikes@aol.com>
parents:
12295
diff
changeset
|
292 |
// Use Data/Names/generic.cfg by default |
6024 | 293 |
if (list.size() == 0) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
294 |
list.append(QString("generic")); |
1907 | 295 |
|
6024 | 296 |
return list; |
1907 | 297 |
} |
298 |
||
6024 | 299 |
// loades types from ini files. returns true on success. |
300 |
bool HWNamegen::loadTypes() |
|
301 |
{ |
|
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
|
302 |
typesAvailable = false; |
6024 | 303 |
|
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
|
304 |
// find .ini to load the names from |
8049 | 305 |
QFile * file = new QFile(QString("physfs://Names/types.ini")); |
6024 | 306 |
|
1907 | 307 |
|
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
|
308 |
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
|
309 |
{ |
1907 | 310 |
|
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
|
311 |
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
|
312 |
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
|
313 |
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
|
314 |
|
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
|
315 |
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
|
316 |
while (!in.atEnd()) |
6024 | 317 |
{ |
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
|
318 |
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
|
319 |
if (line == QString("#####")) |
6024 | 320 |
{ |
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
|
321 |
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
|
322 |
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
|
323 |
{ |
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
|
324 |
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
|
325 |
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
|
326 |
} |
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
|
327 |
} |
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
|
328 |
else if ((line == QString("*****")) || (line == QString("*END*"))) |
6024 | 329 |
{ |
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
|
330 |
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
|
331 |
return true; // bye bye |
6024 | 332 |
} |
333 |
else |
|
334 |
{ |
|
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
|
335 |
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
|
336 |
{ |
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
|
337 |
// 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
|
338 |
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
|
339 |
} |
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
|
340 |
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
|
341 |
{ |
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
|
342 |
// 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
|
343 |
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
|
344 |
} |
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
|
345 |
} |
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
|
346 |
} |
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
|
347 |
|
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
|
348 |
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
|
349 |
} |
6024 | 350 |
|
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
|
351 |
// 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
|
352 |
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
|
353 |
|
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 |
return typesAvailable; |
1907 | 355 |
} |
356 |
||
12247
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
357 |
/* Generates a random team name. |
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
358 |
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
|
359 |
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
|
360 |
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
|
361 |
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
|
362 |
{ |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
363 |
// 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
|
364 |
if (!typesAvailable) |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
365 |
if (!loadTypes()) |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
366 |
return QString(); // abort if loading failed |
1907 | 367 |
|
12245
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
368 |
// 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
|
369 |
if (TypesHatnames.size() <= 0) |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
370 |
return QString(); |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
371 |
|
12247
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
372 |
if(kind < 0) |
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
373 |
kind = (rand()%(TypesHatnames.size())); |
a6e0977be914
Fix non-matching team name when generating random teams
Wuzzy <almikes@aol.com>
parents:
12245
diff
changeset
|
374 |
|
12245
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
375 |
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
|
376 |
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
|
377 |
else |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
378 |
return QString(); |
5206f9a803d1
Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents:
12244
diff
changeset
|
379 |
} |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
380 |
|
12501
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
381 |
QString HWNamegen::getRandomHat(bool withDLC) |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
382 |
{ |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
383 |
QStringList Hats; |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
384 |
|
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
385 |
// list all available hats |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
386 |
Hats.append(DataManager::instance().entryList( |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
387 |
"Graphics/Hats", |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
388 |
QDir::Files, |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
389 |
QStringList("*.png"), |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
390 |
withDLC |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
391 |
).replaceInStrings(QRegExp("\\.png$"), "") |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
392 |
); |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
393 |
|
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
394 |
if(Hats.size()==0) |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
395 |
{ |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
396 |
// TODO do some serious error handling |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
397 |
return "Error"; |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
398 |
} |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
399 |
|
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
400 |
// pick a random hat |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
401 |
return Hats[rand()%(Hats.size())]; |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
402 |
} |
92c597704e57
Use completely random hats when clicking on "Random hats" button in team editor
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
403 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
404 |
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
|
405 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
406 |
QStringList Graves; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
407 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
408 |
//list all available Graves |
6930 | 409 |
Graves.append(DataManager::instance().entryList( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
410 |
"Graphics/Graves", |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
411 |
QDir::Files, |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
412 |
QStringList("*.png"), |
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
413 |
withDLC |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
414 |
).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
|
415 |
); |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
416 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
417 |
if(Graves.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
418 |
{ |
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
|
419 |
// TODO do some serious error handling |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
420 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
421 |
} |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
422 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
423 |
//pick a random grave |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
424 |
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
|
425 |
} |
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
426 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
427 |
QString HWNamegen::getRandomFlag(bool withDLC) |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
428 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
429 |
QStringList Flags; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
430 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
431 |
//list all available flags |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
432 |
Flags.append(DataManager::instance().entryList( |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
433 |
"Graphics/Flags", |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
434 |
QDir::Files, |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
435 |
QStringList("*.png"), |
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
436 |
withDLC |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
437 |
).replaceInStrings(QRegExp("\\.png$"), "") |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
438 |
); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
439 |
//remove internal flags |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
440 |
Flags.removeAll("cpu"); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
441 |
Flags.removeAll("cpu_plain"); |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
442 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
443 |
if(Flags.size()==0) |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
444 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
445 |
// TODO do some serious error handling |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
446 |
return "Error"; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
447 |
} |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
448 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
449 |
//pick a random flag |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
450 |
return Flags[rand()%(Flags.size())]; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
451 |
} |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
452 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
453 |
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
|
454 |
{ |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
455 |
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
|
456 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
457 |
//list all available Forts |
6930 | 458 |
Forts.append(DataManager::instance().entryList( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
459 |
"Forts", |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
460 |
QDir::Files, |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
461 |
QStringList("*L.png"), |
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
462 |
withDLC |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6212
diff
changeset
|
463 |
).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
|
464 |
); |
5114
a05081bc2769
Improved random name generation (now a random fort and random grave is choosen
Jonathan@Jonathan-PC.fritz.box
parents:
4976
diff
changeset
|
465 |
|
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
466 |
if(Forts.size()==0) |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
467 |
{ |
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
|
468 |
// TODO do some serious error handling |
5115
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
469 |
return "Error"; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
470 |
} |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
471 |
|
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
472 |
//pick a random fort |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
473 |
return Forts[rand()%(Forts.size())]; |
276410cc1178
fix indentation and missing newline at end of file
sheepluva
parents:
5114
diff
changeset
|
474 |
} |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
475 |
|
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
476 |
QString HWNamegen::getRandomVoice(bool withDLC) |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
477 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
478 |
QStringList Voices; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
479 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
480 |
//list all available voices |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
481 |
Voices.append(DataManager::instance().entryList( |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
482 |
"Sounds/voices", |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
483 |
QDir::Dirs | QDir::NoDotAndDotDot, |
12295
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
484 |
QStringList("*"), |
ac57d564efce
Add DLC filtering in DataManager.cpp and namegen.cpp
Wuzzy <almikes@aol.com>
parents:
12248
diff
changeset
|
485 |
withDLC)); |
11888
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
486 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
487 |
if(Voices.size()==0) |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
488 |
{ |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
489 |
// TODO do some serious error handling |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
490 |
return "Error"; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
491 |
} |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
492 |
|
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
493 |
//pick a random voice |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
494 |
return Voices[rand()%(Voices.size())]; |
618d99523933
Set random flags and voice in random teams
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
495 |
} |
14955
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
496 |
|
14956
4accf3e18dbc
Add withDLC for getLocalizedDefaultVoice
Wuzzy <Wuzzy2@mail.ru>
parents:
14955
diff
changeset
|
497 |
QString HWNamegen::getLocalizedDefaultVoice(bool withDLC) |
14955
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
498 |
{ |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
499 |
QStringList entries = DataManager::instance().entryList( |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
500 |
"Sounds/voices", |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
501 |
QDir::Dirs | QDir::NoDotAndDotDot, |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
502 |
QStringList("*"), |
14956
4accf3e18dbc
Add withDLC for getLocalizedDefaultVoice
Wuzzy <Wuzzy2@mail.ru>
parents:
14955
diff
changeset
|
503 |
withDLC); |
14955
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
504 |
|
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
505 |
QString loc = QLocale().name(); |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
506 |
if(entries.contains("Default_" + loc)) |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
507 |
{ |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
508 |
return QString("Default_" + loc); |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
509 |
} |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
510 |
else if(entries.contains("Default_" + loc.left(2))) |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
511 |
{ |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
512 |
return QString("Default_" + loc.left(2)); |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
513 |
} |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
514 |
else |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
515 |
{ |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
516 |
return QString("Default"); |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
517 |
} |
0ec0ed2d9045
Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents:
13931
diff
changeset
|
518 |
} |