25 #import <mach/mach.h> |
25 #import <mach/mach.h> |
26 #import <mach/mach_host.h> |
26 #import <mach/mach_host.h> |
27 #import <QuartzCore/QuartzCore.h> |
27 #import <QuartzCore/QuartzCore.h> |
28 #import "AudioToolbox/AudioToolbox.h" |
28 #import "AudioToolbox/AudioToolbox.h" |
29 #import "PascalImports.h" |
29 #import "PascalImports.h" |
30 |
|
31 void createTeamNamed (NSString *nameWithoutExt) { |
|
32 NSString *teamsDirectory = TEAMS_DIRECTORY(); |
|
33 |
|
34 if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
|
35 [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
|
36 withIntermediateDirectories:NO |
|
37 attributes:nil |
|
38 error:NULL]; |
|
39 } |
|
40 |
|
41 NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: HW_getMaxNumberOfHogs()]; |
|
42 |
|
43 for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) { |
|
44 NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i]; |
|
45 NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:0],@"level", |
|
46 hogName,@"hogname", @"NoHat",@"hat", nil]; |
|
47 [hogName release]; |
|
48 [hedgehogs addObject:hog]; |
|
49 [hog release]; |
|
50 } |
|
51 |
|
52 NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"hash", |
|
53 @"Statue",@"grave", @"Plane",@"fort", @"Default",@"voicepack", |
|
54 @"hedgewars",@"flag", hedgehogs,@"hedgehogs", nil]; |
|
55 [hedgehogs release]; |
|
56 |
|
57 NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
|
58 |
|
59 [theTeam writeToFile:teamFile atomically:YES]; |
|
60 [teamFile release]; |
|
61 [theTeam release]; |
|
62 } |
|
63 |
|
64 void createWeaponNamed (NSString *nameWithoutExt, int type) { |
|
65 NSString *weaponsDirectory = WEAPONS_DIRECTORY(); |
|
66 |
|
67 if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { |
|
68 [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory |
|
69 withIntermediateDirectories:NO |
|
70 attributes:nil |
|
71 error:NULL]; |
|
72 } |
|
73 |
|
74 NSDictionary *theWeapon = nil; |
|
75 switch (type) { |
|
76 case 0: //default |
|
77 theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
78 @"9391929422199121032235111001201000000211110101011",@"ammostore_initialqt", |
|
79 @"0405040541600655546554464776576666666155510101117",@"ammostore_probability", |
|
80 @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", |
|
81 @"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil]; |
|
82 break; |
|
83 case 1: //crazy |
|
84 theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
85 @"9999999999999999992999999999999999299999999909999",@"ammostore_initialqt", |
|
86 @"1111110111111111111111111111111111111111111101111",@"ammostore_probability", |
|
87 @"0000000000000000000000000000000000000000000000000",@"ammostore_delay", |
|
88 @"1311110312111111123114111111111111111211110101111",@"ammostore_crate", nil]; |
|
89 break; |
|
90 case 2: //pro mode |
|
91 theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
92 @"9090009000000000000009000000000000000000000000000",@"ammostore_initialqt", |
|
93 @"0000000000000000000000000000000000000000000000000",@"ammostore_probability", |
|
94 @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", |
|
95 @"1111111111111111111111111111111111111111100101111",@"ammostore_crate", nil]; |
|
96 break; |
|
97 case 3: //shoppa |
|
98 theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
99 @"0000009900000000000000000000000000000000000000000",@"ammostore_initialqt", |
|
100 @"4444410044244402210112121222422000000002000400010",@"ammostore_probability", |
|
101 @"0000000000000000000000000000000000000000000000000",@"ammostore_delay", |
|
102 @"1111111111111111111111111111111111111111101101111",@"ammostore_crate", nil]; |
|
103 break; |
|
104 case 4: //clean slate |
|
105 theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
106 @"1010009000010000011000000000000000000000000000001",@"ammostore_initialqt", |
|
107 @"0405040541600655546554464776576666666155510101117",@"ammostore_probability", |
|
108 @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", |
|
109 @"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil]; |
|
110 break; |
|
111 case 5: //minefield |
|
112 theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
113 @"0000009900090000000300000000000000000000000000000",@"ammostore_initialqt", |
|
114 @"0000000000000000000000000000000000000000000000000",@"ammostore_probability", |
|
115 @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", |
|
116 @"1111111111111111111111111111111111111111111101111",@"ammostore_crate", nil]; |
|
117 break; |
|
118 default: |
|
119 NSLog(@"Nope"); |
|
120 break; |
|
121 } |
|
122 |
|
123 NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; |
|
124 |
|
125 [theWeapon writeToFile:weaponFile atomically:YES]; |
|
126 [weaponFile release]; |
|
127 [theWeapon release]; |
|
128 } |
|
129 |
|
130 void createSchemeNamed (NSString *nameWithoutExt) { |
|
131 NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
|
132 |
|
133 if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
|
134 [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
|
135 withIntermediateDirectories:NO |
|
136 attributes:nil |
|
137 error:NULL]; |
|
138 } |
|
139 |
|
140 NSMutableArray *basicArray = [[NSMutableArray alloc] initWithObjects: |
|
141 [NSNumber numberWithInt:100], //initialhealth |
|
142 [NSNumber numberWithInt:45], //turntime |
|
143 [NSNumber numberWithInt:100], //damagemodifier |
|
144 [NSNumber numberWithInt:15], //suddendeathtimeout |
|
145 [NSNumber numberWithInt:47], //waterrise |
|
146 [NSNumber numberWithInt:5], //healthdecrease |
|
147 [NSNumber numberWithInt:5], //cratedrops |
|
148 [NSNumber numberWithInt:35], //healthprob |
|
149 [NSNumber numberWithInt:25], //healthamount |
|
150 [NSNumber numberWithInt:3], //minestime |
|
151 [NSNumber numberWithInt:4], //minesnumber |
|
152 [NSNumber numberWithInt:0], //dudmines |
|
153 [NSNumber numberWithInt:2], //explosives |
|
154 nil]; |
|
155 |
|
156 NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithObjects: |
|
157 [NSNumber numberWithBool:NO], //fortmode |
|
158 [NSNumber numberWithBool:NO], //divideteam |
|
159 [NSNumber numberWithBool:NO], //solidland |
|
160 [NSNumber numberWithBool:NO], //addborder |
|
161 [NSNumber numberWithBool:NO], //lowgravity |
|
162 [NSNumber numberWithBool:NO], //lasersight |
|
163 [NSNumber numberWithBool:NO], //invulnerable |
|
164 [NSNumber numberWithBool:NO], //resethealth |
|
165 [NSNumber numberWithBool:NO], //vampirism |
|
166 [NSNumber numberWithBool:NO], //karma |
|
167 [NSNumber numberWithBool:NO], //artillery |
|
168 [NSNumber numberWithBool:YES], //randomorder |
|
169 [NSNumber numberWithBool:NO], //king |
|
170 [NSNumber numberWithBool:NO], //placehedgehogs |
|
171 [NSNumber numberWithBool:NO], //clansharesammo |
|
172 [NSNumber numberWithBool:NO], //disablegirders |
|
173 [NSNumber numberWithBool:NO], //disablelandobjects |
|
174 [NSNumber numberWithBool:NO], //aisurvival |
|
175 [NSNumber numberWithBool:NO], //infattack |
|
176 [NSNumber numberWithBool:NO], //resetweaps |
|
177 [NSNumber numberWithBool:NO], //perhogammo |
|
178 nil]; |
|
179 |
|
180 NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
|
181 basicArray,@"basic", |
|
182 gamemodArray,@"gamemod", |
|
183 nil]; |
|
184 [gamemodArray release]; |
|
185 [basicArray release]; |
|
186 |
|
187 NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; |
|
188 |
|
189 [theScheme writeToFile:schemeFile atomically:YES]; |
|
190 [schemeFile release]; |
|
191 [theScheme release]; |
|
192 } |
|
193 |
30 |
194 BOOL inline rotationManager (UIInterfaceOrientation interfaceOrientation) { |
31 BOOL inline rotationManager (UIInterfaceOrientation interfaceOrientation) { |
195 if (IS_IPAD()) |
32 if (IS_IPAD()) |
196 return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || |
33 return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || |
197 (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); |
34 (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); |