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];
|
|
26 |
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys:@"100",@"health", @"0",@"level",
|
|
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];
|
|
39 |
NSLog(@"%@",teamFile);
|
|
40 |
[theTeam writeToFile:teamFile atomically:YES];
|
|
41 |
[teamFile release];
|
|
42 |
[theTeam release];
|
|
43 |
}
|
3330
|
44 |
|
|
45 |
UIImage *mergeTwoImages (UIImage *firstImage, UIImage *secondImage) {
|
|
46 |
UIGraphicsBeginImageContext(firstImage.size);
|
|
47 |
[firstImage drawAtPoint:CGPointMake(0,0)];
|
|
48 |
[secondImage drawAtPoint:CGPointMake(0,-4)];
|
|
49 |
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
|
|
50 |
UIGraphicsEndImageContext();
|
|
51 |
return resultImage; // autoreleased
|
|
52 |
}
|
3335
|
53 |
|
|
54 |
BOOL rotationManager (UIInterfaceOrientation interfaceOrientation) {
|
|
55 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
|
|
56 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
|
57 |
else
|
|
58 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
|
59 |
|
|
60 |
}
|