author | koda |
Wed, 29 Sep 2010 23:50:46 +0200 | |
changeset 3916 | e7d665a4ef42 |
parent 3878 | 348f4104461d |
child 3917 | 4c243b1eac97 |
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> |
|
3783 | 27 |
#import "AudioToolbox/AudioToolbox.h" |
3547 | 28 |
|
29 |
void createTeamNamed (NSString *nameWithoutExt) { |
|
30 |
NSString *teamsDirectory = TEAMS_DIRECTORY(); |
|
3697 | 31 |
|
3547 | 32 |
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
3697 | 33 |
[[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
34 |
withIntermediateDirectories:NO |
|
35 |
attributes:nil |
|
3547 | 36 |
error:NULL]; |
37 |
} |
|
3697 | 38 |
|
3547 | 39 |
NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: MAX_HOGS]; |
3697 | 40 |
|
3547 | 41 |
for (int i = 0; i < MAX_HOGS; i++) { |
42 |
NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i]; |
|
43 |
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:0],@"level", |
|
44 |
hogName,@"hogname", @"NoHat",@"hat", nil]; |
|
45 |
[hogName release]; |
|
46 |
[hedgehogs addObject:hog]; |
|
47 |
[hog release]; |
|
48 |
} |
|
3697 | 49 |
|
3660 | 50 |
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"hash", |
3547 | 51 |
@"Statue",@"grave", @"Plane",@"fort", @"Default",@"voicepack", |
52 |
@"hedgewars",@"flag", hedgehogs,@"hedgehogs", nil]; |
|
53 |
[hedgehogs release]; |
|
3697 | 54 |
|
3547 | 55 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
56 |
||
57 |
[theTeam writeToFile:teamFile atomically:YES]; |
|
58 |
[teamFile release]; |
|
59 |
[theTeam release]; |
|
60 |
} |
|
61 |
||
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
|
62 |
void createWeaponNamed (NSString *nameWithoutExt, int type) { |
3547 | 63 |
NSString *weaponsDirectory = WEAPONS_DIRECTORY(); |
64 |
||
65 |
if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { |
|
3697 | 66 |
[[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory |
67 |
withIntermediateDirectories:NO |
|
68 |
attributes:nil |
|
3547 | 69 |
error:NULL]; |
70 |
} |
|
3697 | 71 |
|
3778 | 72 |
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
|
73 |
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
|
74 |
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
|
75 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
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 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
3823
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
77 |
@"939192942219912103223511100120100000021111010101",@"ammostore_initialqt", |
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
78 |
@"040504054160065554655446477657666666615551010111",@"ammostore_probability", |
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
|
79 |
@"000000000000020550000004000700400000000020000000",@"ammostore_delay", |
3823
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
80 |
@"131111031211111112311411111111111111121111110111",@"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
|
81 |
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
|
82 |
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
|
83 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
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 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
3823
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
85 |
@"999999999999999999299999999999999929999999990999",@"ammostore_initialqt", |
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
86 |
@"111111011111111111111111111111111111111111110111",@"ammostore_probability", |
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
|
87 |
@"000000000000000000000000000000000000000000000000",@"ammostore_delay", |
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
|
88 |
@"131111031211111112311411111111111111121111010111",@"ammostore_crate", nil]; |
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: |
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
|
92 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
3878
348f4104461d
fix a small glitch in textfield cells and remove cheese from pro
koda
parents:
3829
diff
changeset
|
93 |
@"909000900000000000000900000000000000000000000000",@"ammostore_initialqt", |
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
|
94 |
@"000000000000000000000000000000000000000000000000",@"ammostore_probability", |
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
|
95 |
@"000000000000020550000004000700400000000020000000",@"ammostore_delay", |
3823
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
96 |
@"111111111111111111111111111111111111111110010111",@"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
|
97 |
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
|
98 |
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
|
99 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
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
|
100 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
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
|
101 |
@"000000990000000000000000000000000000000000000000",@"ammostore_initialqt", |
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
|
102 |
@"444441004424440221011212122242200000000200040001",@"ammostore_probability", |
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 |
@"000000000000000000000000000000000000000000000000",@"ammostore_delay", |
3823
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
104 |
@"111111111111111111111111111111111111111110110111",@"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
|
105 |
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
|
106 |
case 4: //basketball |
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
|
107 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
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
|
108 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
3823
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
109 |
@"939192942219912103223511100120100000021111010100",@"ammostore_initialqt", |
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 |
@"000000000000000000000000000000000000000000000000",@"ammostore_probability", |
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 |
@"000000000000000550000004000700400000000020000000",@"ammostore_delay", |
3823
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
112 |
@"111111111111111111111111111111111111111111110111",@"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
|
113 |
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
|
114 |
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
|
115 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
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
|
116 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
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 |
@"000000990009000000030000000000000000000000000000",@"ammostore_initialqt", |
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 |
@"000000000000000000000000000000000000000000000000",@"ammostore_probability", |
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 |
@"000000000000020550000004000700400000000020000000",@"ammostore_delay", |
3823
cca9bfb88a24
also remove sinegun from the ifrontend for whatever reason
koda
parents:
3783
diff
changeset
|
120 |
@"111111111111111111111111111111111111111111110111",@"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
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
} |
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
|
126 |
|
3547 | 127 |
NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; |
3697 | 128 |
|
3547 | 129 |
[theWeapon writeToFile:weaponFile atomically:YES]; |
130 |
[weaponFile release]; |
|
131 |
[theWeapon release]; |
|
132 |
} |
|
133 |
||
134 |
void createSchemeNamed (NSString *nameWithoutExt) { |
|
135 |
NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
|
3697 | 136 |
|
3547 | 137 |
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
3697 | 138 |
[[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
139 |
withIntermediateDirectories:NO |
|
140 |
attributes:nil |
|
3547 | 141 |
error:NULL]; |
142 |
} |
|
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
|
143 |
|
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 |
NSMutableArray *basicArray = [[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
|
145 |
[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
|
146 |
[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
|
147 |
[NSNumber numberWithInt:100], //initialhealth |
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
|
148 |
[NSNumber numberWithInt:15], //suddendeathtimeout |
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
|
149 |
[NSNumber numberWithInt:5], //cratedrops |
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 |
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
|
151 |
[NSNumber numberWithInt:4], //mines |
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 |
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
|
164 |
[NSNumber numberWithBool:YES], //addmines |
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 |
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
|
175 |
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
|
176 |
|
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
|
177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
[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
|
182 |
[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
|
183 |
|
3547 | 184 |
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
|
185 |
|
3547 | 186 |
[theScheme writeToFile:schemeFile atomically:YES]; |
187 |
[schemeFile release]; |
|
188 |
[theScheme release]; |
|
189 |
} |
|
190 |
||
191 |
BOOL rotationManager (UIInterfaceOrientation interfaceOrientation) { |
|
3551 | 192 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || |
3697 | 193 |
(interfaceOrientation == UIInterfaceOrientationLandscapeLeft); |
3547 | 194 |
} |
195 |
||
196 |
NSInteger randomPort () { |
|
197 |
srandom(time(NULL)); |
|
198 |
return (random() % 64511) + 1024; |
|
199 |
} |
|
200 |
||
201 |
void popError (const char *title, const char *message) { |
|
202 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:title] |
|
203 |
message:[NSString stringWithUTF8String:message] |
|
204 |
delegate:nil |
|
205 |
cancelButtonTitle:@"Ok" |
|
206 |
otherButtonTitles:nil]; |
|
207 |
[alert show]; |
|
208 |
[alert release]; |
|
209 |
} |
|
210 |
||
211 |
// by http://landonf.bikemonkey.org/code/iphone/Determining_Available_Memory.20081203.html |
|
212 |
void print_free_memory () { |
|
213 |
mach_port_t host_port; |
|
214 |
mach_msg_type_number_t host_size; |
|
215 |
vm_size_t pagesize; |
|
3697 | 216 |
|
3547 | 217 |
host_port = mach_host_self(); |
218 |
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); |
|
3697 | 219 |
host_page_size(host_port, &pagesize); |
220 |
||
3547 | 221 |
vm_statistics_data_t vm_stat; |
3697 | 222 |
|
3547 | 223 |
if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) |
224 |
DLog(@"Failed to fetch vm statistics"); |
|
3697 | 225 |
|
226 |
/* Stats in bytes */ |
|
3547 | 227 |
natural_t mem_used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pagesize; |
228 |
natural_t mem_free = vm_stat.free_count * pagesize; |
|
229 |
natural_t mem_total = mem_used + mem_free; |
|
230 |
DLog(@"used: %u free: %u total: %u", mem_used, mem_free, mem_total); |
|
231 |
} |
|
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3660
diff
changeset
|
232 |
|
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
233 |
BOOL isPhone () { |
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3660
diff
changeset
|
234 |
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone); |
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3660
diff
changeset
|
235 |
} |
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
236 |
|
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
237 |
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
|
238 |
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
|
239 |
// set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space |
3697 | 240 |
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
|
241 |
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
|
242 |
// 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
|
243 |
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
|
244 |
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
|
245 |
free(name); |
3697 | 246 |
|
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
247 |
return modelId; |
3697 | 248 |
} |
3783 | 249 |
|
250 |
void playSound (NSString *snd) { |
|
251 |
//Get the filename of the sound file: |
|
252 |
NSString *path = [NSString stringWithFormat:@"%@/%@.wav",[[NSBundle mainBundle] resourcePath],snd]; |
|
253 |
||
254 |
//declare a system sound id |
|
255 |
SystemSoundID soundID; |
|
256 |
||
257 |
//Get a URL for the sound file |
|
258 |
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO]; |
|
259 |
||
260 |
//Use audio sevices to create the sound |
|
261 |
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID); |
|
262 |
||
263 |
//Use audio services to play the sound |
|
264 |
AudioServicesPlaySystemSound(soundID); |
|
265 |
} |