9 #import "OverlayViewController.h" |
9 #import "OverlayViewController.h" |
10 #import "SDL_uikitappdelegate.h" |
10 #import "SDL_uikitappdelegate.h" |
11 #import "PascalImports.h" |
11 #import "PascalImports.h" |
12 #import "CGPointUtils.h" |
12 #import "CGPointUtils.h" |
13 #import "SDL_mouse.h" |
13 #import "SDL_mouse.h" |
14 #import "SDL_config_iphoneos.h" |
|
15 #import "InGameMenuViewController.h" |
14 #import "InGameMenuViewController.h" |
16 #import "CommodityFunctions.h" |
15 #import "CommodityFunctions.h" |
|
16 #import "SDL_config_iphoneos.h" |
17 |
17 |
18 #define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7] |
18 #define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7] |
19 #define HIDING_TIME_NEVER [NSDate dateWithTimeIntervalSinceNow:10000] |
19 #define HIDING_TIME_NEVER [NSDate dateWithTimeIntervalSinceNow:10000] |
20 #define doDim() [dimTimer setFireDate:HIDING_TIME_DEFAULT] |
20 #define doDim() [dimTimer setFireDate:HIDING_TIME_DEFAULT] |
21 #define doNotDim() [dimTimer setFireDate:HIDING_TIME_NEVER] |
21 #define doNotDim() [dimTimer setFireDate:HIDING_TIME_NEVER] |
33 |
33 |
34 -(void) didRotate:(NSNotification *)notification { |
34 -(void) didRotate:(NSNotification *)notification { |
35 UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; |
35 UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; |
36 CGRect rect = [[UIScreen mainScreen] bounds]; |
36 CGRect rect = [[UIScreen mainScreen] bounds]; |
37 CGRect usefulRect = CGRectMake(0, 0, rect.size.width, rect.size.height); |
37 CGRect usefulRect = CGRectMake(0, 0, rect.size.width, rect.size.height); |
38 UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:12345]; |
38 UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG]; |
39 |
39 |
40 [UIView beginAnimations:@"rotation" context:NULL]; |
40 [UIView beginAnimations:@"rotation" context:NULL]; |
41 [UIView setAnimationDuration:0.8f]; |
41 [UIView setAnimationDuration:0.8f]; |
42 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; |
42 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; |
43 switch (orientation) { |
43 switch (orientation) { |
274 [popoverController presentPopoverFromRect:CGRectMake(1000, 0, 220, 32) |
274 [popoverController presentPopoverFromRect:CGRectMake(1000, 0, 220, 32) |
275 inView:self.view |
275 inView:self.view |
276 permittedArrowDirections:UIPopoverArrowDirectionUp |
276 permittedArrowDirections:UIPopoverArrowDirectionUp |
277 animated:YES]; |
277 animated:YES]; |
278 } else { |
278 } else { |
279 if (popupMenu == nil) { |
279 if (popupMenu == nil) |
280 popupMenu = [[InGameMenuViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
280 popupMenu = [[InGameMenuViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
281 popupMenu.view.backgroundColor = [UIColor clearColor]; |
281 |
282 popupMenu.view.frame = CGRectMake(480, 0, 200, 170); |
|
283 } |
|
284 [self.view addSubview:popupMenu.view]; |
282 [self.view addSubview:popupMenu.view]; |
285 |
283 [popupMenu present]; |
286 [UIView beginAnimations:@"showing popover" context:NULL]; |
|
287 [UIView setAnimationDuration:0.35]; |
|
288 popupMenu.view.frame = CGRectMake(280, 0, 200, 170); |
|
289 [UIView commitAnimations]; |
|
290 } |
284 } |
291 popupMenu.tableView.scrollEnabled = NO; |
285 popupMenu.tableView.scrollEnabled = NO; |
292 } |
286 } |
293 |
287 |
294 // on ipad just dismiss it, on iphone transtion to the right |
288 // on ipad just dismiss it, on iphone transtion to the right |
295 -(void) dismissPopover { |
289 -(void) dismissPopover { |
296 if (YES == isPopoverVisible) { |
290 if (YES == isPopoverVisible) { |
297 isPopoverVisible = NO; |
291 isPopoverVisible = NO; |
298 |
292 |
299 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { |
293 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { |
|
294 [(InGameMenuViewController *)popoverController.contentViewController removeChat]; |
300 [popoverController dismissPopoverAnimated:YES]; |
295 [popoverController dismissPopoverAnimated:YES]; |
301 } else { |
296 } else { |
302 [UIView beginAnimations:@"hiding popover" context:NULL]; |
297 [popupMenu dismiss]; |
303 [UIView setAnimationDuration:0.35]; |
|
304 popupMenu.view.frame = CGRectMake(480, 0, 200, 170); |
|
305 [UIView commitAnimations]; |
|
306 |
|
307 [popupMenu.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35]; |
|
308 } |
298 } |
309 [self buttonReleased:nil]; |
299 [self buttonReleased:nil]; |
310 } |
300 } |
311 } |
301 } |
312 |
302 |
322 UITouch *first, *second; |
312 UITouch *first, *second; |
323 |
313 |
324 // hide in-game menu |
314 // hide in-game menu |
325 if (isPopoverVisible) |
315 if (isPopoverVisible) |
326 [self dismissPopover]; |
316 [self dismissPopover]; |
327 |
|
328 // remove keyboard from the view |
|
329 if (SDL_iPhoneKeyboardIsShown(sdlwindow)) |
|
330 SDL_iPhoneKeyboardHide(sdlwindow); |
|
331 |
317 |
332 // reset default dimming |
318 // reset default dimming |
333 doDim(); |
319 doDim(); |
334 |
320 |
335 switch ([allTouches count]) { |
321 switch ([allTouches count]) { |