author | antonc27 <antonc27@mail.ru> |
Sun, 20 Sep 2015 02:52:49 +0200 | |
branch | ios-revival |
changeset 11192 | 3dbea499390d |
parent 11191 | fa6f6e8b927c |
child 11194 | d77ffd68e1cd |
permissions | -rw-r--r-- |
4281 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
6700 | 3 |
* Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com> |
4281 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* 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:
8835
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4281 | 17 |
*/ |
18 |
||
19 |
||
20 |
#import "CreationChamber.h" |
|
8835 | 21 |
#import "weapons.h" |
6832 | 22 |
|
6103 | 23 |
@implementation CreationChamber |
24 |
||
6865 | 25 |
#pragma mark Checking status |
26 |
+(void) createFirstLaunch { |
|
27 |
DLog(@"Creating necessary files"); |
|
28 |
NSInteger index; |
|
29 |
||
30 |
// SAVES - just delete and overwrite |
|
31 |
if ([[NSFileManager defaultManager] fileExistsAtPath:SAVES_DIRECTORY()]) |
|
32 |
[[NSFileManager defaultManager] removeItemAtPath:SAVES_DIRECTORY() error:NULL]; |
|
33 |
[[NSFileManager defaultManager] createDirectoryAtPath:SAVES_DIRECTORY() |
|
34 |
withIntermediateDirectories:NO |
|
35 |
attributes:nil |
|
36 |
error:NULL]; |
|
37 |
||
38 |
// SCREENSHOTS - just create it the first time |
|
39 |
if ([[NSFileManager defaultManager] fileExistsAtPath:SCREENSHOTS_DIRECTORY()] == NO) |
|
40 |
[[NSFileManager defaultManager] createDirectoryAtPath:SCREENSHOTS_DIRECTORY() |
|
41 |
withIntermediateDirectories:NO |
|
42 |
attributes:nil |
|
43 |
error:NULL]; |
|
44 |
||
45 |
// SETTINGS - nsuserdefaults ftw |
|
46 |
[self createSettings]; |
|
47 |
||
48 |
// TEAMS - update exisiting teams with new format |
|
49 |
NSArray *teamNames = [[NSArray alloc] initWithObjects:@"Edit Me!",@"Ninjas",@"Pirates",@"Robots",nil]; |
|
50 |
index = 0; |
|
51 |
for (NSString *name in teamNames) |
|
52 |
[self createTeamNamed:name ofType:index++ controlledByAI:[name isEqualToString:@"Robots"]]; |
|
53 |
[teamNames release]; |
|
54 |
||
55 |
// SCHEMES - always overwrite and delete custom ones |
|
56 |
if ([[NSFileManager defaultManager] fileExistsAtPath:SCHEMES_DIRECTORY()] == YES) |
|
57 |
[[NSFileManager defaultManager] removeItemAtPath:SCHEMES_DIRECTORY() error:NULL]; |
|
58 |
NSArray *schemeNames = [[NSArray alloc] initWithObjects:@"Default",@"Pro Mode",@"Shoppa",@"Clean Slate", |
|
59 |
@"Minefield",@"Barrel Mayhem",@"Tunnel Hogs",@"Fort Mode",@"Timeless", |
|
11192
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
60 |
@"Thinking with Portals",@"King Mode",@"Construction Mode",nil]; |
6865 | 61 |
index = 0; |
62 |
for (NSString *name in schemeNames) |
|
63 |
[self createSchemeNamed:name ofType:index++]; |
|
64 |
[schemeNames release]; |
|
65 |
||
66 |
// WEAPONS - always overwrite as merge is not needed (missing weaps are 0ed automatically) |
|
67 |
NSArray *weaponNames = [[NSArray alloc] initWithObjects:@"Default",@"Crazy",@"Pro Mode",@"Shoppa",@"Clean Slate", |
|
11192
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
68 |
@"Minefield",@"Thinking with Portals",@"One of Everything",@"Highlander",@"Construction Mode",nil]; |
6865 | 69 |
index = 0; |
70 |
for (NSString *name in weaponNames) |
|
71 |
[self createWeaponNamed:name ofType:index++]; |
|
72 |
[weaponNames release]; |
|
73 |
} |
|
74 |
||
6103 | 75 |
#pragma mark Settings |
76 |
+(void) createSettings { |
|
5206 | 77 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
78 |
[settings setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"]; |
|
79 |
[settings setObject:[NSNumber numberWithBool:YES] forKey:@"music"]; |
|
80 |
[settings setObject:[NSNumber numberWithBool:YES] forKey:@"sound"]; |
|
5451
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5376
diff
changeset
|
81 |
[settings setObject:[NSNumber numberWithBool:YES] forKey:@"sync_ws"]; |
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5376
diff
changeset
|
82 |
|
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
83 |
// don't overwrite these two strings when present |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
84 |
if ([settings objectForKey:@"username"] == nil) |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
85 |
[settings setObject:@"" forKey:@"username"]; |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
86 |
if ([settings objectForKey:@"password"] == nil) |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
87 |
[settings setObject:@"" forKey:@"password"]; |
5206 | 88 |
|
89 |
[settings synchronize]; |
|
90 |
} |
|
4281 | 91 |
|
6103 | 92 |
#pragma mark Teams |
93 |
+(void) createTeamNamed:(NSString *)nameWithoutExt { |
|
6865 | 94 |
[self createTeamNamed:nameWithoutExt ofType:0 controlledByAI:NO]; |
6103 | 95 |
} |
96 |
||
97 |
+(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
|
6865 | 98 |
[self createTeamNamed:nameWithoutExt ofType:type controlledByAI:NO]; |
6103 | 99 |
} |
100 |
||
6104 | 101 |
+(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) shouldAITakeOver { |
4281 | 102 |
NSString *teamsDirectory = TEAMS_DIRECTORY(); |
103 |
||
104 |
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
|
105 |
[[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
|
106 |
withIntermediateDirectories:NO |
|
107 |
attributes:nil |
|
108 |
error:NULL]; |
|
109 |
} |
|
110 |
||
6104 | 111 |
NSArray *customNames; |
112 |
NSArray *customHats; |
|
113 |
NSString *flag, *grave, *voicepack, *fort; |
|
114 |
switch (type) { |
|
115 |
default: // default |
|
116 |
customNames = [[NSArray alloc] initWithObjects:@"No Name",@"Unnamed",@"Anonymous",@"Nameless",@"Incognito",@"Unidentified", |
|
117 |
@"Uknown",@"Secret",nil]; |
|
118 |
customHats = [[NSArray alloc] initWithObjects:@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",nil]; |
|
119 |
flag = @"hedgewars"; |
|
120 |
grave = @"Statue"; |
|
121 |
voicepack = @"Default"; |
|
122 |
fort = @"Plane"; |
|
123 |
break; |
|
124 |
case 1: // ninjas |
|
125 |
customNames = [[NSArray alloc] initWithObjects:@"Shinobi",@"Ukemi",@"Godai",@"Ninpo",@"Tatsujin",@"Arashi",@"Bushi",@"Itami",nil]; |
|
126 |
customHats = [[NSArray alloc] initWithObjects:@"NinjaFull",@"NinjaStraight",@"NinjaTriangle",@"NinjaFull",@"NinjaStraight", |
|
127 |
@"NinjaTriangle",@"NinjaFull",@"NinjaTriangle",nil]; |
|
128 |
flag = @"japan"; |
|
129 |
grave = @"bp2"; |
|
130 |
voicepack = @"Singer"; |
|
131 |
fort = @"Wood"; |
|
132 |
break; |
|
133 |
case 2: // pirates |
|
134 |
customNames = [[NSArray alloc] initWithObjects:@"Toothless Wayne",@"Long-nose Kidd",@"Eye-patch Jim",@"Rackham Blood",@"One-eyed Ayee", |
|
135 |
@"Dirty Ben",@"Morris",@"Cruise Seymour",nil]; |
|
136 |
customHats = [[NSArray alloc] initWithObjects:@"pirate_jack_bandana",@"pirate_jack",@"dwarf",@"pirate_jack_bandana",@"pirate_jack", |
|
137 |
@"dwarf",@"pirate_jack_bandana",@"pirate_jack",nil]; |
|
138 |
flag = @"cm_pirate"; |
|
139 |
grave = @"chest"; |
|
140 |
voicepack = @"Pirate"; |
|
141 |
fort = @"Hydrant"; |
|
142 |
break; |
|
143 |
case 3: // robots |
|
144 |
customNames = [[NSArray alloc] initWithObjects:@"HAL",@"R2-D2",@"Wall-E",@"Robocop",@"Optimus Prime",@"Terminator",@"C-3PO",@"KITT",nil]; |
|
145 |
customHats = [[NSArray alloc] initWithObjects:@"cyborg1",@"cyborg2",@"cyborg1",@"cyborg2",@"cyborg1",@"cyborg2",@"cyborg1", |
|
146 |
@"cyborg2",nil]; |
|
147 |
flag = @"cm_binary"; |
|
148 |
grave = @"Rip"; |
|
149 |
voicepack = @"Robot"; |
|
150 |
fort = @"UFO"; |
|
151 |
break; |
|
152 |
} |
|
4281 | 153 |
|
6104 | 154 |
NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity:HW_getMaxNumberOfHogs()]; |
4281 | 155 |
for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) { |
156 |
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
6104 | 157 |
[NSNumber numberWithInt:(shouldAITakeOver ? 4 : 0)],@"level", |
158 |
[customNames objectAtIndex:i],@"hogname", |
|
159 |
[customHats objectAtIndex:i],@"hat", |
|
4281 | 160 |
nil]; |
161 |
[hedgehogs addObject:hog]; |
|
162 |
[hog release]; |
|
163 |
} |
|
6104 | 164 |
[customHats release]; |
165 |
[customNames release]; |
|
4281 | 166 |
|
167 |
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
168 |
@"0",@"hash", |
|
6104 | 169 |
grave,@"grave", |
170 |
fort,@"fort", |
|
171 |
voicepack,@"voicepack", |
|
172 |
flag,@"flag", |
|
4281 | 173 |
hedgehogs,@"hedgehogs", |
174 |
nil]; |
|
175 |
[hedgehogs release]; |
|
176 |
||
177 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
|
178 |
||
179 |
[theTeam writeToFile:teamFile atomically:YES]; |
|
180 |
[teamFile release]; |
|
181 |
[theTeam release]; |
|
182 |
} |
|
183 |
||
6103 | 184 |
#pragma mark Weapons |
185 |
+(void) createWeaponNamed:(NSString *)nameWithoutExt { |
|
6865 | 186 |
[self createWeaponNamed:nameWithoutExt ofType:0]; |
6103 | 187 |
} |
188 |
||
189 |
+(void) createWeaponNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
|
4281 | 190 |
NSString *weaponsDirectory = WEAPONS_DIRECTORY(); |
191 |
||
192 |
if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { |
|
193 |
[[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory |
|
194 |
withIntermediateDirectories:NO |
|
195 |
attributes:nil |
|
196 |
error:NULL]; |
|
197 |
} |
|
198 |
||
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
199 |
NSInteger ammolineSize = HW_getNumberOfWeapons(); |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
200 |
NSString *qt, *prob, *delay, *crate; |
4281 | 201 |
switch (type) { |
4607 | 202 |
default: //default |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
203 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
5376 | 204 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
205 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
|
206 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
|
4281 | 207 |
break; |
6104 | 208 |
case 1: //crazy |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
209 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
210 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
211 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
212 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 213 |
break; |
6104 | 214 |
case 2: //pro mode |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
215 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
216 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
217 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
218 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 219 |
break; |
6104 | 220 |
case 3: //shoppa |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
221 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
222 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
223 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
224 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 225 |
break; |
6104 | 226 |
case 4: //clean slate |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
227 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
228 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
229 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
230 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 231 |
break; |
6104 | 232 |
case 5: //minefield |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
233 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_MINES_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
234 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_MINES_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
235 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_MINES_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
236 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_MINES_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4284
57a501a69e5f
update iFrontend with new schemes and weaps, fix up smaller glitches
koda
parents:
4281
diff
changeset
|
237 |
break; |
6104 | 238 |
case 6: //thinking with portals |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
239 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
240 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
241 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
242 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 243 |
break; |
11190
ee8e2494eaee
- 'One of everything' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
244 |
case 7: //one of everything |
ee8e2494eaee
- 'One of everything' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
245 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_ONEEVERY_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
ee8e2494eaee
- 'One of everything' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
246 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_ONEEVERY_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
ee8e2494eaee
- 'One of everything' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
247 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_ONEEVERY_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
ee8e2494eaee
- 'One of everything' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
248 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_ONEEVERY_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
ee8e2494eaee
- 'One of everything' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
249 |
break; |
11191
fa6f6e8b927c
- 'Highlander' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11190
diff
changeset
|
250 |
case 8: //highlander |
fa6f6e8b927c
- 'Highlander' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11190
diff
changeset
|
251 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_HIGHLANDER_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
fa6f6e8b927c
- 'Highlander' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11190
diff
changeset
|
252 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_HIGHLANDER_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
fa6f6e8b927c
- 'Highlander' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11190
diff
changeset
|
253 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_HIGHLANDER_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
fa6f6e8b927c
- 'Highlander' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11190
diff
changeset
|
254 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_HIGHLANDER_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
fa6f6e8b927c
- 'Highlander' ammo set added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11190
diff
changeset
|
255 |
break; |
11192
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
256 |
case 9: //construction mode |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
257 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_CONSTRUCTION_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
258 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_CONSTRUCTION_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
259 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_CONSTRUCTION_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
260 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_CONSTRUCTION_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
261 |
break; |
4281 | 262 |
} |
263 |
||
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
264 |
NSDictionary *theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: qt,@"ammostore_initialqt", |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
265 |
prob,@"ammostore_probability", delay,@"ammostore_delay", crate,@"ammostore_crate", nil]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
266 |
[qt release]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
267 |
[prob release]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
268 |
[delay release]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
269 |
[crate release]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
270 |
|
4281 | 271 |
NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; |
272 |
[theWeapon writeToFile:weaponFile atomically:YES]; |
|
273 |
[weaponFile release]; |
|
274 |
[theWeapon release]; |
|
275 |
} |
|
276 |
||
6103 | 277 |
#pragma mark Schemes |
278 |
+(void) createSchemeNamed:(NSString *)nameWithoutExt { |
|
6865 | 279 |
[self createSchemeNamed:nameWithoutExt ofType:0]; |
6103 | 280 |
} |
281 |
||
282 |
+(void) createSchemeNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
|
4281 | 283 |
NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
284 |
||
285 |
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
|
286 |
[[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
|
287 |
withIntermediateDirectories:NO |
|
288 |
attributes:nil |
|
289 |
error:NULL]; |
|
290 |
} |
|
291 |
||
5181 | 292 |
// load data to get the size of the arrays and their default values |
5185
7607a64e1853
remove the trailing _en from scheme data and use the macros available instead of creating a string every time
koda
parents:
5181
diff
changeset
|
293 |
NSArray *basicSettings = [[NSArray alloc] initWithContentsOfFile:BASICFLAGS_FILE()]; |
5181 | 294 |
NSMutableArray *basicArray = [[NSMutableArray alloc] initWithCapacity:[basicSettings count]]; |
295 |
for (NSDictionary *basicDict in basicSettings) |
|
296 |
[basicArray addObject:[basicDict objectForKey:@"default"]]; |
|
297 |
[basicSettings release]; |
|
4281 | 298 |
|
5185
7607a64e1853
remove the trailing _en from scheme data and use the macros available instead of creating a string every time
koda
parents:
5181
diff
changeset
|
299 |
NSArray *mods = [[NSArray alloc] initWithContentsOfFile:GAMEMODS_FILE()]; |
5181 | 300 |
NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithCapacity:[mods count]]; |
6908
896ed2afcfb8
ios: turn on more warning messages and start correcting them
koda
parents:
6865
diff
changeset
|
301 |
for (NSUInteger i = 0; i < [mods count]; i++) |
5181 | 302 |
[gamemodArray addObject:[NSNumber numberWithBool:NO]]; |
303 |
[mods release]; |
|
304 |
||
5984 | 305 |
switch (type) { |
6104 | 306 |
default: // default |
5984 | 307 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
308 |
break; |
|
6104 | 309 |
case 1: // pro mode |
5984 | 310 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:15]]; |
311 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]]; |
|
312 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
|
313 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
314 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
315 |
break; |
|
6104 | 316 |
case 2: // shoppa |
5984 | 317 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
318 |
[basicArray replaceObjectAtIndex:3 withObject:[NSNumber numberWithInt:50]]; |
|
319 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:1]]; |
|
320 |
[basicArray replaceObjectAtIndex:8 withObject:[NSNumber numberWithInt:0]]; |
|
321 |
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:25]]; |
|
322 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
|
323 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
|
324 |
[gamemodArray replaceObjectAtIndex:1 withObject:[NSNumber numberWithBool:YES]]; |
|
325 |
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]]; |
|
326 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
327 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
328 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
|
329 |
[gamemodArray replaceObjectAtIndex:19 withObject:[NSNumber numberWithBool:YES]]; |
|
330 |
break; |
|
6104 | 331 |
case 3: // clean slate |
5984 | 332 |
[gamemodArray replaceObjectAtIndex:6 withObject:[NSNumber numberWithBool:YES]]; |
333 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
334 |
[gamemodArray replaceObjectAtIndex:18 withObject:[NSNumber numberWithBool:YES]]; |
|
335 |
[gamemodArray replaceObjectAtIndex:19 withObject:[NSNumber numberWithBool:YES]]; |
|
336 |
break; |
|
6104 | 337 |
case 4: // minefield |
5984 | 338 |
[basicArray replaceObjectAtIndex:0 withObject:[NSNumber numberWithInt:50]]; |
339 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
|
340 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]]; |
|
341 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:0]]; |
|
342 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:80]]; |
|
343 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
|
344 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
345 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
346 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
|
347 |
break; |
|
6104 | 348 |
case 5: // barrel mayhem |
5984 | 349 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
350 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]]; |
|
351 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:0]]; |
|
352 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
|
353 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:40]]; |
|
354 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
355 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
356 |
break; |
|
6104 | 357 |
case 6: // tunnel hogs |
5984 | 358 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
359 |
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:3]]; |
|
360 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:10]]; |
|
361 |
[basicArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithInt:10]]; |
|
362 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:10]]; |
|
363 |
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]]; |
|
364 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
365 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
366 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
|
367 |
[gamemodArray replaceObjectAtIndex:16 withObject:[NSNumber numberWithBool:YES]]; |
|
368 |
break; |
|
6104 | 369 |
case 7: // fort mode |
5984 | 370 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
371 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
|
372 |
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]]; |
|
373 |
[gamemodArray replaceObjectAtIndex:3 withObject:[NSNumber numberWithBool:YES]]; |
|
374 |
[gamemodArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithBool:YES]]; |
|
375 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
376 |
break; |
|
6104 | 377 |
case 8: // timeless |
5984 | 378 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:100]]; |
379 |
[basicArray replaceObjectAtIndex:4 withObject:[NSNumber numberWithInt:0]]; |
|
380 |
[basicArray replaceObjectAtIndex:5 withObject:[NSNumber numberWithInt:0]]; |
|
381 |
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:30]]; |
|
382 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:5]]; |
|
383 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:3]]; |
|
384 |
[basicArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithInt:10]]; |
|
385 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
386 |
[gamemodArray replaceObjectAtIndex:20 withObject:[NSNumber numberWithBool:YES]]; |
|
387 |
break; |
|
6104 | 388 |
case 9: // thinking with portals |
5984 | 389 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:2]]; |
390 |
[basicArray replaceObjectAtIndex:8 withObject:[NSNumber numberWithInt:25]]; |
|
391 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:4]]; |
|
392 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:5]]; |
|
393 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:5]]; |
|
394 |
[gamemodArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithBool:YES]]; |
|
395 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
396 |
break; |
|
6104 | 397 |
case 10: // king mode |
5984 | 398 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
399 |
[gamemodArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithBool:YES]]; |
|
400 |
break; |
|
11192
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
401 |
case 11: // construction mode |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
402 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
403 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
404 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
405 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
406 |
[gamemodArray replaceObjectAtIndex:16 withObject:[NSNumber numberWithBool:YES]]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
407 |
[gamemodArray replaceObjectAtIndex:18 withObject:[NSNumber numberWithBool:YES]]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
408 |
[gamemodArray replaceObjectAtIndex:20 withObject:[NSNumber numberWithBool:YES]]; |
3dbea499390d
- 'Construction Mode' ammo set and game parameters added to iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11191
diff
changeset
|
409 |
break; |
5984 | 410 |
} |
5181 | 411 |
|
4281 | 412 |
NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
413 |
basicArray,@"basic", |
|
414 |
gamemodArray,@"gamemod", |
|
415 |
nil]; |
|
416 |
[gamemodArray release]; |
|
417 |
[basicArray release]; |
|
5984 | 418 |
|
4281 | 419 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; |
8441 | 420 |
|
4281 | 421 |
[theScheme writeToFile:schemeFile atomically:YES]; |
422 |
[schemeFile release]; |
|
423 |
[theScheme release]; |
|
424 |
} |
|
6103 | 425 |
|
426 |
@end |