author | koda |
Sat, 01 May 2010 19:40:45 +0000 | |
changeset 3389 | 9b97b9240c22 |
parent 3385 | 361bd29293f4 |
child 3405 | 8fdb08497bf1 |
permissions | -rw-r--r-- |
3325 | 1 |
// |
2 |
// CommodityFunctions.m |
|
3 |
// HedgewarsMobile |
|
4 |
// |
|
5 |
// Created by Vittorio on 08/04/10. |
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved. |
|
7 |
// |
|
8 |
||
9 |
#import "CommodityFunctions.h" |
|
3335 | 10 |
#import "SDL_uikitappdelegate.h" |
3325 | 11 |
|
12 |
void createTeamNamed (NSString *nameWithoutExt) { |
|
13 |
NSString *teamsDirectory = TEAMS_DIRECTORY(); |
|
14 |
||
15 |
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
|
16 |
[[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
|
17 |
withIntermediateDirectories:NO |
|
18 |
attributes:nil |
|
19 |
error:NULL]; |
|
20 |
} |
|
21 |
||
22 |
NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: MAX_HOGS]; |
|
23 |
||
24 |
for (int i = 0; i < MAX_HOGS; i++) { |
|
25 |
NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i]; |
|
3339 | 26 |
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys:@"100",@"health", [NSNumber numberWithInt:0],@"level", |
3325 | 27 |
hogName,@"hogname", @"NoHat",@"hat", nil]; |
28 |
[hogName release]; |
|
29 |
[hedgehogs addObject:hog]; |
|
30 |
[hog release]; |
|
31 |
} |
|
32 |
||
33 |
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"hash", nameWithoutExt,@"teamname", |
|
34 |
@"Statue",@"grave", @"Plane",@"fort", @"Default",@"voicepack", |
|
35 |
@"hedgewars",@"flag", hedgehogs,@"hedgehogs", nil]; |
|
36 |
[hedgehogs release]; |
|
37 |
||
38 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
|
3352 | 39 |
|
3325 | 40 |
[theTeam writeToFile:teamFile atomically:YES]; |
41 |
[teamFile release]; |
|
42 |
[theTeam release]; |
|
43 |
} |
|
3330 | 44 |
|
3335 | 45 |
BOOL rotationManager (UIInterfaceOrientation interfaceOrientation) { |
46 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
|
3385 | 47 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); |
3335 | 48 |
else |
49 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
|
50 |
||
51 |
} |
|
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3352
diff
changeset
|
52 |
|
3373 | 53 |
NSInteger randomPort () { |
54 |
srandom(time(NULL)); |
|
55 |
return (random() % 64511) + 1024; |
|
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3352
diff
changeset
|
56 |
} |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3352
diff
changeset
|
57 |
|
3373 | 58 |
void popError (const char *title, const char *message) { |
59 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:title] |
|
60 |
message:[NSString stringWithUTF8String:message] |
|
61 |
delegate:nil |
|
62 |
cancelButtonTitle:@"Ok" |
|
63 |
otherButtonTitles:nil]; |
|
64 |
[alert show]; |
|
65 |
[alert release]; |
|
66 |
} |
|
67 |
||
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3352
diff
changeset
|
68 |
|
3373 | 69 |