author | koda |
Mon, 08 Nov 2010 23:46:34 +0100 | |
changeset 4211 | 7dcbd236ca59 |
parent 4210 | caa9b08990eb |
child 4213 | 3875481fcc86 |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
3 |
* Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 |
* |
|
18 |
* File created on 08/04/2010. |
|
19 |
*/ |
|
20 |
||
3547 | 21 |
|
22 |
#import "CommodityFunctions.h" |
|
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
23 |
#import <sys/types.h> |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
24 |
#import <sys/sysctl.h> |
3547 | 25 |
#import <mach/mach.h> |
26 |
#import <mach/mach_host.h> |
|
3983
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
27 |
#import <QuartzCore/QuartzCore.h> |
3783 | 28 |
#import "AudioToolbox/AudioToolbox.h" |
3926
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3917
diff
changeset
|
29 |
#import "PascalImports.h" |
3547 | 30 |
|
31 |
void createTeamNamed (NSString *nameWithoutExt) { |
|
32 |
NSString *teamsDirectory = TEAMS_DIRECTORY(); |
|
3697 | 33 |
|
3547 | 34 |
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
3697 | 35 |
[[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
36 |
withIntermediateDirectories:NO |
|
37 |
attributes:nil |
|
3547 | 38 |
error:NULL]; |
39 |
} |
|
3697 | 40 |
|
3926
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3917
diff
changeset
|
41 |
NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: HW_getMaxNumberOfHogs()]; |
3697 | 42 |
|
3926
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3917
diff
changeset
|
43 |
for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) { |
3547 | 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 |
} |
|
3697 | 51 |
|
3660 | 52 |
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"hash", |
3547 | 53 |
@"Statue",@"grave", @"Plane",@"fort", @"Default",@"voicepack", |
54 |
@"hedgewars",@"flag", hedgehogs,@"hedgehogs", nil]; |
|
55 |
[hedgehogs release]; |
|
3697 | 56 |
|
3547 | 57 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
58 |
||
59 |
[theTeam writeToFile:teamFile atomically:YES]; |
|
60 |
[teamFile release]; |
|
61 |
[theTeam release]; |
|
62 |
} |
|
63 |
||
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
64 |
void createWeaponNamed (NSString *nameWithoutExt, int type) { |
3547 | 65 |
NSString *weaponsDirectory = WEAPONS_DIRECTORY(); |
66 |
||
67 |
if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { |
|
3697 | 68 |
[[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory |
69 |
withIntermediateDirectories:NO |
|
70 |
attributes:nil |
|
3547 | 71 |
error:NULL]; |
72 |
} |
|
3697 | 73 |
|
3778 | 74 |
NSDictionary *theWeapon = nil; |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
75 |
switch (type) { |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
76 |
case 0: //default |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
77 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
78 |
@"9391929422199121032235111001201000000211110101011",@"ammostore_initialqt", |
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
79 |
@"0405040541600655546554464776576666666155510101117",@"ammostore_probability", |
3971 | 80 |
@"0000000000000205500000040007004000000000200000000",@"ammostore_delay", |
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
81 |
@"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil]; |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
82 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
83 |
case 1: //crazy |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
84 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
85 |
@"9999999999999999992999999999999999299999999909999",@"ammostore_initialqt", |
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
86 |
@"1111110111111111111111111111111111111111111101111",@"ammostore_probability", |
3971 | 87 |
@"0000000000000000000000000000000000000000000000000",@"ammostore_delay", |
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
88 |
@"1311110312111111123114111111111111111211110101111",@"ammostore_crate", nil]; |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
89 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
90 |
case 2: //pro mode |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
91 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
3971 | 92 |
@"9090009000000000000009000000000000000000000000000",@"ammostore_initialqt", |
93 |
@"0000000000000000000000000000000000000000000000000",@"ammostore_probability", |
|
94 |
@"0000000000000205500000040007004000000000200000000",@"ammostore_delay", |
|
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
95 |
@"1111111111111111111111111111111111111111100101111",@"ammostore_crate", nil]; |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
96 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
97 |
case 3: //shoppa |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
98 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
3971 | 99 |
@"0000009900000000000000000000000000000000000000000",@"ammostore_initialqt", |
100 |
@"4444410044244402210112121222422000000002000400010",@"ammostore_probability", |
|
101 |
@"0000000000000000000000000000000000000000000000000",@"ammostore_delay", |
|
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
102 |
@"1111111111111111111111111111111111111111101101111",@"ammostore_crate", nil]; |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
103 |
break; |
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
104 |
case 4: //clean slate |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
105 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
106 |
@"1010009000010000011000000000000000000000000000001",@"ammostore_initialqt", |
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
107 |
@"0405040541600655546554464776576666666155510101117",@"ammostore_probability", |
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
108 |
@"0000000000000205500000040007004000000000200000000",@"ammostore_delay", |
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
109 |
@"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil]; |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
110 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
111 |
case 5: //minefield |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
112 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
3971 | 113 |
@"0000009900090000000300000000000000000000000000000",@"ammostore_initialqt", |
114 |
@"0000000000000000000000000000000000000000000000000",@"ammostore_probability", |
|
115 |
@"0000000000000205500000040007004000000000200000000",@"ammostore_delay", |
|
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
116 |
@"1111111111111111111111111111111111111111111101111",@"ammostore_crate", nil]; |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
117 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
118 |
default: |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
119 |
NSLog(@"Nope"); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
120 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
121 |
} |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
122 |
|
3547 | 123 |
NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; |
3697 | 124 |
|
3547 | 125 |
[theWeapon writeToFile:weaponFile atomically:YES]; |
126 |
[weaponFile release]; |
|
127 |
[theWeapon release]; |
|
128 |
} |
|
129 |
||
130 |
void createSchemeNamed (NSString *nameWithoutExt) { |
|
131 |
NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
|
3697 | 132 |
|
3547 | 133 |
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
3697 | 134 |
[[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
135 |
withIntermediateDirectories:NO |
|
136 |
attributes:nil |
|
3547 | 137 |
error:NULL]; |
138 |
} |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
139 |
|
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
140 |
NSMutableArray *basicArray = [[NSMutableArray alloc] initWithObjects: |
4211
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
141 |
[NSNumber numberWithInt:100], //initialhealth |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
142 |
[NSNumber numberWithInt:100], //damagemodifier |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
143 |
[NSNumber numberWithInt:45], //turntime |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
144 |
[NSNumber numberWithInt:15], //suddendeathtimeout |
4211
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
145 |
[NSNumber numberWithInt:47], //waterrise |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
146 |
[NSNumber numberWithInt:5], //healthdecrease |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
147 |
[NSNumber numberWithInt:5], //cratedrops |
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
148 |
[NSNumber numberWithInt:35], //healthprob |
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
149 |
[NSNumber numberWithInt:25], //healthamount |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
150 |
[NSNumber numberWithInt:3], //minestime |
4149
51200479f9d8
update ios port with new health modes, increase sd turns, new game modes, fixed bugs that prevented the creation of AI controlled teams, revisited update modes
koda
parents:
4115
diff
changeset
|
151 |
[NSNumber numberWithInt:4], //minesnumber |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
152 |
[NSNumber numberWithInt:0], //dudmines |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
153 |
[NSNumber numberWithInt:2], //explosives |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
154 |
nil]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
155 |
|
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
156 |
NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithObjects: |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
157 |
[NSNumber numberWithBool:NO], //fortmode |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
158 |
[NSNumber numberWithBool:NO], //divideteam |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
159 |
[NSNumber numberWithBool:NO], //solidland |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
160 |
[NSNumber numberWithBool:NO], //addborder |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
161 |
[NSNumber numberWithBool:NO], //lowgravity |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
162 |
[NSNumber numberWithBool:NO], //lasersight |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
163 |
[NSNumber numberWithBool:NO], //invulnerable |
4115 | 164 |
[NSNumber numberWithBool:NO], //resethealth |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
165 |
[NSNumber numberWithBool:NO], //vampirism |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
166 |
[NSNumber numberWithBool:NO], //karma |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
167 |
[NSNumber numberWithBool:NO], //artillery |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
168 |
[NSNumber numberWithBool:YES], //randomorder |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
169 |
[NSNumber numberWithBool:NO], //king |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
170 |
[NSNumber numberWithBool:NO], //placehedgehogs |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
171 |
[NSNumber numberWithBool:NO], //clansharesammo |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
172 |
[NSNumber numberWithBool:NO], //disablegirders |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
173 |
[NSNumber numberWithBool:NO], //disablelandobjects |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
174 |
[NSNumber numberWithBool:NO], //aisurvival |
4115 | 175 |
[NSNumber numberWithBool:NO], //infattack |
176 |
[NSNumber numberWithBool:NO], //resetweaps |
|
177 |
[NSNumber numberWithBool:NO], //perhogammo |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
178 |
nil]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
179 |
|
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
180 |
NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
181 |
basicArray,@"basic", |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
182 |
gamemodArray,@"gamemod", |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
183 |
nil]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
184 |
[gamemodArray release]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
185 |
[basicArray release]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
186 |
|
3547 | 187 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
188 |
|
3547 | 189 |
[theScheme writeToFile:schemeFile atomically:YES]; |
190 |
[schemeFile release]; |
|
191 |
[theScheme release]; |
|
192 |
} |
|
193 |
||
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3930
diff
changeset
|
194 |
BOOL inline rotationManager (UIInterfaceOrientation interfaceOrientation) { |
4098
40df542b5f62
i give up and disable rotation on the iphone; also fix smaller compilation issues
koda
parents:
3996
diff
changeset
|
195 |
if (IS_IPAD()) |
40df542b5f62
i give up and disable rotation on the iphone; also fix smaller compilation issues
koda
parents:
3996
diff
changeset
|
196 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || |
40df542b5f62
i give up and disable rotation on the iphone; also fix smaller compilation issues
koda
parents:
3996
diff
changeset
|
197 |
(interfaceOrientation == UIInterfaceOrientationLandscapeLeft); |
40df542b5f62
i give up and disable rotation on the iphone; also fix smaller compilation issues
koda
parents:
3996
diff
changeset
|
198 |
else |
40df542b5f62
i give up and disable rotation on the iphone; also fix smaller compilation issues
koda
parents:
3996
diff
changeset
|
199 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
3547 | 200 |
} |
201 |
||
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3930
diff
changeset
|
202 |
NSInteger inline randomPort () { |
3547 | 203 |
srandom(time(NULL)); |
3971 | 204 |
NSInteger res = (random() % 64511) + 1024; |
205 |
return (res == DEFAULT_NETGAME_PORT) ? randomPort() : res; |
|
3547 | 206 |
} |
207 |
||
208 |
void popError (const char *title, const char *message) { |
|
209 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:title] |
|
210 |
message:[NSString stringWithUTF8String:message] |
|
211 |
delegate:nil |
|
212 |
cancelButtonTitle:@"Ok" |
|
213 |
otherButtonTitles:nil]; |
|
214 |
[alert show]; |
|
215 |
[alert release]; |
|
216 |
} |
|
217 |
||
218 |
// by http://landonf.bikemonkey.org/code/iphone/Determining_Available_Memory.20081203.html |
|
219 |
void print_free_memory () { |
|
220 |
mach_port_t host_port; |
|
221 |
mach_msg_type_number_t host_size; |
|
222 |
vm_size_t pagesize; |
|
3697 | 223 |
|
3547 | 224 |
host_port = mach_host_self(); |
225 |
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); |
|
3697 | 226 |
host_page_size(host_port, &pagesize); |
227 |
||
3547 | 228 |
vm_statistics_data_t vm_stat; |
3697 | 229 |
|
3547 | 230 |
if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) |
231 |
DLog(@"Failed to fetch vm statistics"); |
|
3697 | 232 |
|
233 |
/* Stats in bytes */ |
|
3547 | 234 |
natural_t mem_used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pagesize; |
235 |
natural_t mem_free = vm_stat.free_count * pagesize; |
|
236 |
natural_t mem_total = mem_used + mem_free; |
|
237 |
DLog(@"used: %u free: %u total: %u", mem_used, mem_free, mem_total); |
|
238 |
} |
|
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3660
diff
changeset
|
239 |
|
3930 | 240 |
BOOL inline isApplePhone () { |
3996 | 241 |
return (IS_IPAD() == NO); |
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3660
diff
changeset
|
242 |
} |
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
243 |
|
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
244 |
NSString *modelType () { |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
245 |
size_t size; |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
246 |
// set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space |
3697 | 247 |
sysctlbyname("hw.machine", NULL, &size, NULL, 0); |
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
248 |
char *name = (char *)malloc(sizeof(char) * size); |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
249 |
// get the platform name |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
250 |
sysctlbyname("hw.machine", name, &size, NULL, 0); |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
251 |
NSString *modelId = [NSString stringWithUTF8String:name]; |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
252 |
free(name); |
3697 | 253 |
|
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
254 |
return modelId; |
3697 | 255 |
} |
3783 | 256 |
|
257 |
void playSound (NSString *snd) { |
|
258 |
//Get the filename of the sound file: |
|
259 |
NSString *path = [NSString stringWithFormat:@"%@/%@.wav",[[NSBundle mainBundle] resourcePath],snd]; |
|
260 |
||
261 |
//declare a system sound id |
|
262 |
SystemSoundID soundID; |
|
263 |
||
264 |
//Get a URL for the sound file |
|
265 |
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO]; |
|
266 |
||
267 |
//Use audio sevices to create the sound |
|
268 |
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID); |
|
269 |
||
270 |
//Use audio services to play the sound |
|
271 |
AudioServicesPlaySystemSound(soundID); |
|
3917 | 272 |
} |
273 |
||
3983
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
274 |
NSArray inline *getAvailableColors (void) { |
3917 | 275 |
return [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x4376e9], // bluette |
276 |
[NSNumber numberWithUnsignedInt:0x3e9321], // greeeen |
|
277 |
[NSNumber numberWithUnsignedInt:0xa23dbb], // violett |
|
278 |
[NSNumber numberWithUnsignedInt:0xff9329], // oranngy |
|
279 |
[NSNumber numberWithUnsignedInt:0xdd0000], // reddish |
|
280 |
[NSNumber numberWithUnsignedInt:0x737373], // graaaay |
|
281 |
[NSNumber numberWithUnsignedInt:0xbba23d], // gold$$$ |
|
282 |
[NSNumber numberWithUnsignedInt:0x3da2bb], // cyannnn |
|
283 |
nil]; |
|
284 |
} |
|
3983
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
285 |
|
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
286 |
UILabel *createBlueLabel (NSString *title, CGRect frame) { |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
287 |
return createLabelWithParams(title, frame, 1.5f, UICOLOR_HW_YELLOW_BODER, UICOLOR_HW_DARKBLUE); |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
288 |
} |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
289 |
|
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
290 |
UILabel *createLabelWithParams (NSString *title, CGRect frame, CGFloat borderWidth, UIColor *borderColor, UIColor *backgroundColor) { |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
291 |
UILabel *theLabel = [[UILabel alloc] initWithFrame:frame]; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
292 |
theLabel.backgroundColor = backgroundColor; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
293 |
|
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
294 |
if (title != nil) { |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
295 |
theLabel.text = title; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
296 |
theLabel.textColor = UICOLOR_HW_YELLOW_TEXT; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
297 |
theLabel.textAlignment = UITextAlignmentCenter; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
298 |
theLabel.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]*80/100]; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
299 |
} |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
300 |
|
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
301 |
[theLabel.layer setBorderWidth:borderWidth]; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
302 |
[theLabel.layer setBorderColor:borderColor.CGColor]; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
303 |
[theLabel.layer setCornerRadius:8.0f]; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
304 |
[theLabel.layer setMasksToBounds:YES]; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
305 |
|
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
306 |
return theLabel; |
aa24192417a8
use labels instead of images, should save ram and space
koda
parents:
3982
diff
changeset
|
307 |
} |