author | smxx |
Wed, 10 Feb 2010 15:42:00 +0000 | |
changeset 2793 | 6bcf173ba9be |
parent 2743 | 39d097ac2276 |
child 2799 | 558b29bf00c5 |
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 |
||
2743 | 14 |
@synthesize versionLabel, settingsViewController, mainView; |
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 { |
2743 | 61 |
self.mainView.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 |
|
2743 | 65 |
-(void) viewDidAppear:(BOOL)animated { |
66 |
self.mainView.userInteractionEnabled = YES; |
|
67 |
[super viewDidAppear:animated]; |
|
2694
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; |
|
2743 | 95 |
self.settingsViewController.parentView = self.mainView; |
2740 | 96 |
[controller release]; |
97 |
} |
|
2743 | 98 |
self.settingsViewController.view.frame = CGRectMake(0, -320, 480, 320); |
2740 | 99 |
|
100 |
[UIView beginAnimations:@"View Switch" context:NULL]; |
|
101 |
[UIView setAnimationDuration:3]; |
|
102 |
[UIView setAnimationDuration:UIViewAnimationCurveEaseOut]; |
|
103 |
self.settingsViewController.view.frame = CGRectMake(0, 0, 480, 320); |
|
2743 | 104 |
self.mainView.frame = CGRectMake(0, 320, 480, 320); |
2740 | 105 |
|
106 |
[self.view addSubview:settingsViewController.view]; |
|
107 |
[UIView commitAnimations]; |
|
108 |
} |
|
109 |
||
110 |
} |
|
111 |
||
2685 | 112 |
@end |