author | koda |
Mon, 31 May 2010 19:33:42 +0000 | |
changeset 3487 | b1d00f1950c8 |
parent 3479 | 972ae3ec178a |
child 3490 | 016b3172b645 |
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]; |
|
3479 | 26 |
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: [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 |
|
3479 | 45 |
void createSchemeNamed (NSString *nameWithoutExt) { |
46 |
NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
|
47 |
||
48 |
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
|
49 |
[[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
|
50 |
withIntermediateDirectories:NO |
|
51 |
attributes:nil |
|
52 |
error:NULL]; |
|
53 |
} |
|
54 |
||
55 |
NSArray *theScheme = [[NSArray alloc] initWithObjects: |
|
56 |
[NSNumber numberWithBool:NO], //fortmode |
|
57 |
[NSNumber numberWithBool:NO], //divideteam |
|
58 |
[NSNumber numberWithBool:NO], //solidland |
|
59 |
[NSNumber numberWithBool:NO], //addborder |
|
60 |
[NSNumber numberWithBool:NO], //lowgravity |
|
61 |
[NSNumber numberWithBool:NO], //lasersight |
|
62 |
[NSNumber numberWithBool:NO], //invulnerable |
|
63 |
[NSNumber numberWithBool:NO], //addmines |
|
64 |
[NSNumber numberWithBool:NO], //vampirism |
|
65 |
[NSNumber numberWithBool:NO], //karma |
|
66 |
[NSNumber numberWithBool:NO], //artillery |
|
67 |
[NSNumber numberWithBool:YES], //randomorder |
|
68 |
[NSNumber numberWithBool:NO], //king |
|
69 |
[NSNumber numberWithBool:NO], //placehedgehogs |
|
70 |
[NSNumber numberWithBool:NO], //clansharesammo |
|
71 |
[NSNumber numberWithBool:NO], //disablegirders |
|
72 |
[NSNumber numberWithBool:NO], //disablelandobjects |
|
73 |
[NSNumber numberWithInt:100], //damagemodifier |
|
74 |
[NSNumber numberWithInt:45], //turntime |
|
75 |
[NSNumber numberWithInt:100], //initialhealth |
|
76 |
[NSNumber numberWithInt:15], //suddendeathtimeout |
|
77 |
[NSNumber numberWithInt:5], //cratedrops |
|
78 |
[NSNumber numberWithInt:3], //minestime |
|
79 |
[NSNumber numberWithInt:4], //mines |
|
80 |
[NSNumber numberWithInt:0], //dudmines |
|
81 |
[NSNumber numberWithInt:2], //explosives |
|
82 |
nil]; |
|
83 |
||
84 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; |
|
85 |
||
86 |
[theScheme writeToFile:schemeFile atomically:YES]; |
|
87 |
[schemeFile release]; |
|
88 |
[theScheme release]; |
|
89 |
} |
|
90 |
||
3335 | 91 |
BOOL rotationManager (UIInterfaceOrientation interfaceOrientation) { |
92 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
|
3405 | 93 |
return YES; |
3335 | 94 |
else |
95 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
|
96 |
||
97 |
} |
|
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3352
diff
changeset
|
98 |
|
3373 | 99 |
NSInteger randomPort () { |
100 |
srandom(time(NULL)); |
|
101 |
return (random() % 64511) + 1024; |
|
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3352
diff
changeset
|
102 |
} |
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3352
diff
changeset
|
103 |
|
3373 | 104 |
void popError (const char *title, const char *message) { |
105 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:title] |
|
106 |
message:[NSString stringWithUTF8String:message] |
|
107 |
delegate:nil |
|
108 |
cancelButtonTitle:@"Ok" |
|
109 |
otherButtonTitles:nil]; |
|
110 |
[alert show]; |
|
111 |
[alert release]; |
|
112 |
} |
|
113 |
||
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3352
diff
changeset
|
114 |
|
3373 | 115 |