9 #import "MainMenuViewController.h" |
9 #import "MainMenuViewController.h" |
10 #import "SDL_uikitappdelegate.h" |
10 #import "SDL_uikitappdelegate.h" |
11 |
11 |
12 @implementation MainMenuViewController |
12 @implementation MainMenuViewController |
13 |
13 |
14 @synthesize passandplayButton, netplayButton, storeButton, versionLabel; |
14 @synthesize versionLabel, settingsViewController; |
15 |
15 |
16 /* |
16 /* |
17 // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. |
17 // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. |
18 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { |
18 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { |
19 if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { |
19 if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { |
21 } |
21 } |
22 return self; |
22 return self; |
23 } |
23 } |
24 */ |
24 */ |
25 |
25 |
|
26 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
27 return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
|
28 } |
|
29 |
|
30 |
|
31 - (void)didReceiveMemoryWarning { |
|
32 // Releases the view if it doesn't have a superview. |
|
33 [super didReceiveMemoryWarning]; |
|
34 |
|
35 // Release any cached data, images, etc that aren't in use. |
|
36 if (nil == self.settingsViewController.view.superview) { |
|
37 self.settingsViewController = nil; |
|
38 } |
|
39 } |
|
40 |
26 |
41 |
27 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. |
42 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. |
28 -(void) viewDidLoad { |
43 -(void) viewDidLoad { |
29 self.versionLabel.text = @"Hedgewars version 0.9.13-dev"; |
44 self.versionLabel.text = @"0.9.13-dev"; |
30 [super viewDidLoad]; |
45 [super viewDidLoad]; |
31 } |
46 } |
32 |
|
33 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
34 if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) return YES; |
|
35 else return NO; |
|
36 } |
|
37 |
|
38 /* |
|
39 - (void)didReceiveMemoryWarning { |
|
40 // Releases the view if it doesn't have a superview. |
|
41 [super didReceiveMemoryWarning]; |
|
42 |
|
43 // Release any cached data, images, etc that aren't in use. |
|
44 } |
|
45 */ |
|
46 |
47 |
47 - (void)viewDidUnload { |
48 - (void)viewDidUnload { |
48 // Release any retained subviews of the main view. |
49 // Release any retained subviews of the main view. |
49 self.passandplayButton = nil; |
|
50 self.netplayButton = nil; |
|
51 self.storeButton = nil; |
|
52 self.versionLabel = nil; |
50 self.versionLabel = nil; |
53 } |
51 } |
54 |
52 |
55 - (void)dealloc { |
53 - (void)dealloc { |
56 [passandplayButton release]; |
|
57 [netplayButton release]; |
|
58 [storeButton release]; |
|
59 [versionLabel release]; |
54 [versionLabel release]; |
60 [super dealloc]; |
55 [settingsViewController release]; |
|
56 [super dealloc]; |
61 } |
57 } |
62 |
58 |
63 // disable the buttons when to prevent launching twice the game |
59 // disable the buttons when to prevent launching twice the game |
64 -(void) viewWillDisappear:(BOOL)animated { |
60 -(void) viewWillDisappear:(BOOL)animated { |
65 passandplayButton.enabled = NO; |
61 self.view.userInteractionEnabled = NO; |
66 netplayButton.enabled = NO; |
|
67 storeButton.enabled = NO; |
|
68 [super viewWillDisappear:animated]; |
62 [super viewWillDisappear:animated]; |
69 } |
63 } |
70 |
64 |
71 -(void) viewWillAppear:(BOOL)animated { |
65 -(void) viewWillAppear:(BOOL)animated { |
72 passandplayButton.enabled = YES; |
66 self.view.userInteractionEnabled = YES; |
73 netplayButton.enabled = YES; |
|
74 storeButton.enabled = YES; |
|
75 [super viewWillAppear:animated]; |
67 [super viewWillAppear:animated]; |
76 } |
68 } |
77 |
69 |
|
70 #pragma mark - |
|
71 #pragma mark Action buttons |
78 -(IBAction) startPlaying { |
72 -(IBAction) startPlaying { |
79 [[SDLUIKitDelegate sharedAppDelegate] startSDLgame]; |
73 [[SDLUIKitDelegate sharedAppDelegate] startSDLgame]; |
80 } |
74 } |
81 |
75 |
82 -(IBAction) notYetImplemented { |
76 -(IBAction) notYetImplemented { |
83 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented" |
77 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented" |
84 message:@"Sorry, this feature is not yet implemented" |
78 message:@"Sorry, this feature is not yet implemented" |
85 delegate:nil |
79 delegate:nil |
86 cancelButtonTitle:@"Well, don't worry" |
80 cancelButtonTitle:@"Well, don't worry" |
87 otherButtonTitles:nil]; |
81 otherButtonTitles:nil]; |
88 [alert show]; |
82 [alert show]; |
89 [alert release]; |
83 [alert release]; |
90 } |
84 } |
91 |
85 |
|
86 -(IBAction) switchViews:(id)sender { |
|
87 |
|
88 // view not displayed or not created |
|
89 if (nil == self.settingsViewController.view.superview) { |
|
90 // view not created |
|
91 if (nil == self.settingsViewController) { |
|
92 SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" |
|
93 bundle:nil]; |
|
94 self.settingsViewController = controller; |
|
95 [controller release]; |
|
96 } |
|
97 self.settingsViewController.view.frame = CGRectMake(0, -480, 480, 320); |
|
98 |
|
99 [UIView beginAnimations:@"View Switch" context:NULL]; |
|
100 [UIView setAnimationDuration:3]; |
|
101 [UIView setAnimationDuration:UIViewAnimationCurveEaseOut]; |
|
102 self.settingsViewController.view.frame = CGRectMake(0, 0, 480, 320); |
|
103 |
|
104 // we have the new controller, let's switch |
|
105 [self.view addSubview:settingsViewController.view]; |
|
106 [UIView commitAnimations]; |
|
107 } |
|
108 |
|
109 } |
|
110 |
92 @end |
111 @end |