12 #import "GameConfigViewController.h" |
12 #import "GameConfigViewController.h" |
13 #import "SplitViewRootController.h" |
13 #import "SplitViewRootController.h" |
14 #import "CommodityFunctions.h" |
14 #import "CommodityFunctions.h" |
15 |
15 |
16 @implementation MainMenuViewController |
16 @implementation MainMenuViewController |
17 @synthesize cover, versionLabel; |
17 @synthesize versionLabel; |
18 |
18 |
19 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
19 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
20 return rotationManager(interfaceOrientation); |
20 return rotationManager(interfaceOrientation); |
21 } |
21 } |
22 |
22 |
88 [pool release]; |
88 [pool release]; |
89 [NSThread exit]; |
89 [NSThread exit]; |
90 } |
90 } |
91 |
91 |
92 #pragma mark - |
92 #pragma mark - |
93 -(void) appear { |
|
94 [[SDLUIKitDelegate sharedAppDelegate].uiwindow addSubview:self.view]; |
|
95 [self release]; |
|
96 |
|
97 [UIView beginAnimations:@"inserting main controller" context:NULL]; |
|
98 [UIView setAnimationDuration:1]; |
|
99 self.view.alpha = 1; |
|
100 [UIView commitAnimations]; |
|
101 |
|
102 [NSTimer scheduledTimerWithTimeInterval:0.7 target:self selector:@selector(hideBehind) userInfo:nil repeats:NO]; |
|
103 } |
|
104 |
|
105 -(void) disappear { |
|
106 if (nil != cover) |
|
107 [cover release]; |
|
108 |
|
109 [UIView beginAnimations:@"removing main controller" context:NULL]; |
|
110 [UIView setAnimationDuration:1]; |
|
111 self.view.alpha = 0; |
|
112 [UIView commitAnimations]; |
|
113 [self retain]; |
|
114 //[self.view removeFromSuperview]; |
|
115 } |
|
116 |
|
117 // this is a silly way to hide the sdl contex that remained active |
|
118 -(void) hideBehind { |
|
119 if (nil == cover) { |
|
120 cover= [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; |
|
121 cover.backgroundColor = [UIColor blackColor]; |
|
122 } |
|
123 [[SDLUIKitDelegate sharedAppDelegate].uiwindow insertSubview:cover belowSubview:self.view]; |
|
124 } |
|
125 |
|
126 #pragma mark - |
|
127 -(IBAction) switchViews:(id) sender { |
93 -(IBAction) switchViews:(id) sender { |
128 UIButton *button = (UIButton *)sender; |
94 UIButton *button = (UIButton *)sender; |
129 UIAlertView *alert; |
95 UIAlertView *alert; |
130 NSString *configNibName; |
96 NSString *debugStr, *configNibName; |
131 NSString *debugStr; |
97 |
132 |
|
133 switch (button.tag) { |
98 switch (button.tag) { |
134 case 0: |
99 case 0: |
135 if (1) { // bug in UIModalTransitionStylePartialCurl? |
100 // bug in UIModalTransitionStylePartialCurl, displays the controller awkwardly if it is not allocated every time |
136 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
101 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
137 configNibName = @"GameConfigViewController-iPad"; |
102 configNibName = @"GameConfigViewController-iPad"; |
138 else |
103 else |
139 configNibName = @"GameConfigViewController-iPhone"; |
104 configNibName = @"GameConfigViewController-iPhone"; |
140 |
105 |
141 gameConfigViewController = [[GameConfigViewController alloc] initWithNibName:configNibName |
106 gameConfigViewController = [[GameConfigViewController alloc] initWithNibName:configNibName bundle:nil]; |
142 bundle:nil]; |
|
143 #ifdef __IPHONE_3_2 |
107 #ifdef __IPHONE_3_2 |
144 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
108 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
145 gameConfigViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl; |
109 gameConfigViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl; |
146 #endif |
110 #endif |
147 } |
|
148 |
|
149 [self presentModalViewController:gameConfigViewController animated:YES]; |
111 [self presentModalViewController:gameConfigViewController animated:YES]; |
150 break; |
112 break; |
151 case 2: |
113 case 2: |
152 if (nil == splitRootViewController) { |
114 if (nil == splitRootViewController) { |
153 splitRootViewController = [[SplitViewRootController alloc] initWithNibName:nil bundle:nil]; |
115 splitRootViewController = [[SplitViewRootController alloc] initWithNibName:nil bundle:nil]; |
188 [self dismissModalViewControllerAnimated:YES]; |
150 [self dismissModalViewControllerAnimated:YES]; |
189 } |
151 } |
190 |
152 |
191 |
153 |
192 -(void) viewDidUnload { |
154 -(void) viewDidUnload { |
193 self.cover = nil; |
|
194 self.versionLabel = nil; |
155 self.versionLabel = nil; |
195 gameConfigViewController = nil; |
156 gameConfigViewController = nil; |
196 splitRootViewController = nil; |
157 splitRootViewController = nil; |
197 [super viewDidUnload]; |
158 [super viewDidUnload]; |
198 } |
159 } |
199 |
160 |
200 -(void) dealloc { |
161 -(void) dealloc { |
201 [versionLabel release]; |
162 [versionLabel release]; |
202 [cover release]; |
|
203 [splitRootViewController release]; |
163 [splitRootViewController release]; |
204 [gameConfigViewController release]; |
164 [gameConfigViewController release]; |
205 [super dealloc]; |
165 [super dealloc]; |
206 } |
166 } |
207 |
167 |