author | koda |
Wed, 10 Feb 2010 22:00:49 +0000 | |
changeset 2799 | 558b29bf00c5 |
parent 2743 | 39d097ac2276 |
child 2803 | 1f446fc5c8ec |
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" |
|
2799 | 11 |
#import "PascalImports.h" |
2685 | 12 |
|
13 |
@implementation MainMenuViewController |
|
14 |
||
2743 | 15 |
@synthesize versionLabel, settingsViewController, mainView; |
2685 | 16 |
|
17 |
/* |
|
18 |
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. |
|
19 |
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { |
|
20 |
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { |
|
21 |
// Custom initialization |
|
22 |
} |
|
23 |
return self; |
|
24 |
} |
|
25 |
*/ |
|
26 |
||
2740 | 27 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
28 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
|
29 |
} |
|
30 |
||
31 |
||
32 |
- (void)didReceiveMemoryWarning { |
|
33 |
// Releases the view if it doesn't have a superview. |
|
34 |
[super didReceiveMemoryWarning]; |
|
35 |
||
36 |
// Release any cached data, images, etc that aren't in use. |
|
37 |
if (nil == self.settingsViewController.view.superview) { |
|
38 |
self.settingsViewController = nil; |
|
2799 | 39 |
[settingsViewController release]; |
2740 | 40 |
} |
41 |
} |
|
42 |
||
2685 | 43 |
|
44 |
// 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
|
45 |
-(void) viewDidLoad { |
2799 | 46 |
char *ver; |
47 |
HW_versionInfo(NULL, &ver); |
|
48 |
self.versionLabel.text = [[NSString stringWithUTF8String:ver] autorelease]; |
|
2740 | 49 |
[super viewDidLoad]; |
2685 | 50 |
} |
2723 | 51 |
|
2685 | 52 |
- (void)viewDidUnload { |
53 |
// Release any retained subviews of the main view. |
|
54 |
self.versionLabel = nil; |
|
55 |
} |
|
56 |
||
57 |
- (void)dealloc { |
|
58 |
[versionLabel release]; |
|
2740 | 59 |
[settingsViewController release]; |
60 |
[super dealloc]; |
|
2685 | 61 |
} |
62 |
||
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
63 |
// 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
|
64 |
-(void) viewWillDisappear:(BOOL)animated { |
2743 | 65 |
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
|
66 |
[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
|
67 |
} |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
68 |
|
2743 | 69 |
-(void) viewDidAppear:(BOOL)animated { |
70 |
self.mainView.userInteractionEnabled = YES; |
|
71 |
[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
|
72 |
} |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
73 |
|
2740 | 74 |
#pragma mark - |
75 |
#pragma mark Action buttons |
|
2685 | 76 |
-(IBAction) startPlaying { |
77 |
[[SDLUIKitDelegate sharedAppDelegate] startSDLgame]; |
|
78 |
} |
|
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
79 |
|
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
80 |
-(IBAction) notYetImplemented { |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
81 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented" |
2740 | 82 |
message:@"Sorry, this feature is not yet implemented" |
83 |
delegate:nil |
|
84 |
cancelButtonTitle:@"Well, don't worry" |
|
85 |
otherButtonTitles:nil]; |
|
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
86 |
[alert show]; |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
87 |
[alert release]; |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
88 |
} |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
2685
diff
changeset
|
89 |
|
2740 | 90 |
-(IBAction) switchViews:(id)sender { |
91 |
||
92 |
// view not displayed or not created |
|
93 |
if (nil == self.settingsViewController.view.superview) { |
|
94 |
// view not created |
|
95 |
if (nil == self.settingsViewController) { |
|
96 |
SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" |
|
97 |
bundle:nil]; |
|
98 |
self.settingsViewController = controller; |
|
99 |
[controller release]; |
|
100 |
} |
|
2743 | 101 |
self.settingsViewController.view.frame = CGRectMake(0, -320, 480, 320); |
2799 | 102 |
self.settingsViewController.parentView = self.mainView; |
2740 | 103 |
|
104 |
[UIView beginAnimations:@"View Switch" context:NULL]; |
|
2799 | 105 |
[UIView setAnimationDuration:1]; |
106 |
//[UIView setAnimationDuration:UIViewAnimationCurveEaseOut]; |
|
2740 | 107 |
self.settingsViewController.view.frame = CGRectMake(0, 0, 480, 320); |
2743 | 108 |
self.mainView.frame = CGRectMake(0, 320, 480, 320); |
2740 | 109 |
|
110 |
[self.view addSubview:settingsViewController.view]; |
|
111 |
[UIView commitAnimations]; |
|
112 |
} |
|
113 |
||
114 |
} |
|
115 |
||
2685 | 116 |
@end |