8 |
8 |
9 #import "MainMenuViewController.h" |
9 #import "MainMenuViewController.h" |
10 #import "SDL_uikitappdelegate.h" |
10 #import "SDL_uikitappdelegate.h" |
11 #import "PascalImports.h" |
11 #import "PascalImports.h" |
12 #import "SplitViewRootController.h" |
12 #import "SplitViewRootController.h" |
13 |
|
14 // in case we don't want SDL_mixer... |
|
15 //#import "SoundEffect.h" |
|
16 //SoundEffect *erasingSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"Erase" ofType:@"caf"]]; |
|
17 //SoundEffect *selectSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"Select" ofType:@"caf"]]; |
|
18 |
13 |
19 |
14 |
20 @implementation MainMenuViewController |
15 @implementation MainMenuViewController |
21 @synthesize cover; |
16 @synthesize cover; |
22 |
17 |
41 |
36 |
42 -(void) viewDidLoad { |
37 -(void) viewDidLoad { |
43 // initialize some files the first time we load the game |
38 // initialize some files the first time we load the game |
44 [NSThread detachNewThreadSelector:@selector(checkFirstRun) toTarget:self withObject:nil]; |
39 [NSThread detachNewThreadSelector:@selector(checkFirstRun) toTarget:self withObject:nil]; |
45 // listen to request to remove the modalviewcontroller |
40 // listen to request to remove the modalviewcontroller |
46 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissModalViewController) name: @"dismissModalView" object:nil]; |
41 [[NSNotificationCenter defaultCenter] addObserver:self |
|
42 selector:@selector(dismissModalViewController) |
|
43 name: @"dismissModalView" |
|
44 object:nil]; |
47 |
45 |
48 [super viewDidLoad]; |
46 [super viewDidLoad]; |
49 } |
47 } |
50 |
48 |
51 // this is called to verify whether it's the first time the app is launched |
49 // this is called to verify whether it's the first time the app is launched |
57 if (!([[NSFileManager defaultManager] fileExistsAtPath:filePath])) { |
55 if (!([[NSFileManager defaultManager] fileExistsAtPath:filePath])) { |
58 // file not present, means that also other files are absent |
56 // file not present, means that also other files are absent |
59 NSLog(@"First time run, creating settings files"); |
57 NSLog(@"First time run, creating settings files"); |
60 |
58 |
61 // show a popup with an indicator to make the user wait |
59 // show a popup with an indicator to make the user wait |
62 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"One-time Preferences Configuration",@"") |
60 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Please wait",@"") |
63 message:nil |
61 message:nil |
64 delegate:nil |
62 delegate:nil |
65 cancelButtonTitle:nil |
63 cancelButtonTitle:nil |
66 otherButtonTitles:nil]; |
64 otherButtonTitles:nil]; |
67 [alert show]; |
65 [alert show]; |
68 [alert release]; |
66 [alert release]; |
69 |
67 |
70 UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
68 UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] |
|
69 initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
71 indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50); |
70 indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50); |
72 [indicator startAnimating]; |
71 [indicator startAnimating]; |
73 [alert addSubview:indicator]; |
72 [alert addSubview:indicator]; |
74 [indicator release]; |
73 [indicator release]; |
75 |
74 |
|
75 // create Default Team.plist |
|
76 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
|
77 NSString *teamsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"Teams/"]; |
|
78 [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
|
79 withIntermediateDirectories:NO |
|
80 attributes:nil |
|
81 error:NULL]; |
|
82 |
|
83 NSMutableArray *hedgehogs = [[NSMutableArray alloc] init]; |
|
84 |
|
85 for (int i = 0; i < 8; i++) { |
|
86 NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i]; |
|
87 NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys:@"100",@"health",@"0",@"level", |
|
88 hogName,@"hogname",@"NoHat",@"hat",nil]; |
|
89 [hogName release]; |
|
90 [hedgehogs addObject:hog]; |
|
91 [hog release]; |
|
92 } |
|
93 |
|
94 NSDictionary *defaultTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"4421353",@"color",@"0",@"hash", |
|
95 @"Default Team",@"teamname",@"Statue",@"grave",@"Plane",@"fort", |
|
96 @"Default",@"voicepack",@"hedgewars",@"flag",hedgehogs,@"hedgehogs",nil]; |
|
97 [hedgehogs release]; |
|
98 NSString *defaultTeamFile = [teamsDirectory stringByAppendingString:@"Default Team.plist"]; |
|
99 [defaultTeam writeToFile:defaultTeamFile atomically:YES]; |
|
100 [defaultTeam release]; |
|
101 |
76 // create settings.plist |
102 // create settings.plist |
77 NSMutableDictionary *saveDict = [[NSMutableDictionary alloc] init]; |
103 NSMutableDictionary *saveDict = [[NSMutableDictionary alloc] init]; |
78 |
104 |
79 [saveDict setObject:@"" forKey:@"username"]; |
105 [saveDict setObject:@"" forKey:@"username"]; |
80 [saveDict setObject:@"" forKey:@"password"]; |
106 [saveDict setObject:@"" forKey:@"password"]; |