author | koda |
Wed, 03 Feb 2010 03:01:44 +0000 | |
changeset 2740 | 03df0573a9fd |
parent 2738 | bfccb2ec4334 |
child 2743 | 39d097ac2276 |
permissions | -rw-r--r-- |
2685 | 1 |
// |
2 |
// MainMenuViewController.m |
|
3 |
// hwengine |
|
4 |
// |
|
5 |
// Created by Vittorio on 08/01/10. |
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved. |
|
7 |
// |
|
8 |
||
9 |
#import "MainMenuViewController.h" |
|
10 |
#import "SDL_uikitappdelegate.h" |
|
11 |
||
12 |
@implementation MainMenuViewController |
|
13 |
||
2740 | 14 |
@synthesize versionLabel, settingsViewController; |
2685 | 15 |
|
16 |
/* |
|
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 { |
|
19 |
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { |
|
20 |
// Custom initialization |
|
21 |
} |
|
22 |
return self; |
|
23 |
} |
|
24 |
*/ |
|
25 |
||
2740 | 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 |
||
2685 | 41 |
|
42 |
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. |
|
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
43 |
-(void) viewDidLoad { |
2740 | 44 |
self.versionLabel.text = @"0.9.13-dev"; |
45 |
[super viewDidLoad]; |
|
2685 | 46 |
} |
2723 | 47 |
|
2685 | 48 |
- (void)viewDidUnload { |
49 |
// Release any retained subviews of the main view. |
|
50 |
self.versionLabel = nil; |
|
51 |
} |
|
52 |
||
53 |
- (void)dealloc { |
|
54 |
[versionLabel release]; |
|
2740 | 55 |
[settingsViewController release]; |
56 |
[super dealloc]; |
|
2685 | 57 |
} |
58 |
||
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
59 |
// disable the buttons when to prevent launching twice the game |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
60 |
-(void) viewWillDisappear:(BOOL)animated { |
2740 | 61 |
self.view.userInteractionEnabled = NO; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
62 |
[super viewWillDisappear:animated]; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
63 |
} |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
64 |
|
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
65 |
-(void) viewWillAppear:(BOOL)animated { |
2740 | 66 |
self.view.userInteractionEnabled = YES; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
67 |
[super viewWillAppear:animated]; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
68 |
} |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
69 |
|
2740 | 70 |
#pragma mark - |
71 |
#pragma mark Action buttons |
|
2685 | 72 |
-(IBAction) startPlaying { |
73 |
[[SDLUIKitDelegate sharedAppDelegate] startSDLgame]; |
|
74 |
} |
|
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
75 |
|
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
76 |
-(IBAction) notYetImplemented { |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
77 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented" |
2740 | 78 |
message:@"Sorry, this feature is not yet implemented" |
79 |
delegate:nil |
|
80 |
cancelButtonTitle:@"Well, don't worry" |
|
81 |
otherButtonTitles:nil]; |
|
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
82 |
[alert show]; |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
83 |
[alert release]; |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
84 |
} |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
85 |
|
2740 | 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 |
||
2685 | 111 |
@end |