project_files/HedgewarsMobile/Classes/InGameMenuViewController.m
changeset 3648 2477029463ed
parent 3647 0d0df215fb52
child 3649 bc35f8fee587
--- a/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m	Sat Jul 17 03:59:10 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m	Sat Jul 17 06:56:39 2010 +0200
@@ -40,7 +40,7 @@
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
     SDL_VideoDisplay *display = &_this->displays[0];
     sdlwindow = display->windows;
-    
+        
     [super viewDidLoad];
 }
 
@@ -56,6 +56,31 @@
 }
 
 #pragma mark -
+#pragma mark animating
+-(void) present {
+    CGRect screen = [[UIScreen mainScreen] bounds];
+    self.view.backgroundColor = [UIColor clearColor];
+    self.view.frame = CGRectMake(screen.size.height, 0, 200, 170);
+    
+    [UIView beginAnimations:@"showing popover" context:NULL];
+    [UIView setAnimationDuration:0.35];
+    self.view.frame = CGRectMake(screen.size.height-200, 0, 200, 170);
+    [UIView commitAnimations];
+}
+
+-(void) dismiss {
+    CGRect screen = [[UIScreen mainScreen] bounds];
+    [UIView beginAnimations:@"hiding popover" context:NULL];
+    [UIView setAnimationDuration:0.35];
+    self.view.frame = CGRectMake(screen.size.height, 0, 200, 170);
+    [UIView commitAnimations];
+        
+    [self.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35];
+    
+    [self removeChat];
+}
+
+#pragma mark -
 #pragma mark tableView methods
 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
     return 1;
@@ -87,16 +112,21 @@
             isPaused = !isPaused;
             break;
         case 1:
-            HW_chat();
-            SDL_iPhoneKeyboardShow(sdlwindow);
+            if (SDL_iPhoneKeyboardIsShown(sdlwindow))
+                [self removeChat];
+            else {
+                HW_chat();
+                SDL_iPhoneKeyboardShow(sdlwindow);
+            }
             break;
         case 2:
             // expand the view (and table) so that the actionsheet can be selected on the iPhone
             if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
+                CGRect screen = [[UIScreen mainScreen] bounds];
                 [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
                 [UIView beginAnimations:@"table width more" context:NULL];
                 [UIView setAnimationDuration:0.2];
-                self.view.frame = CGRectMake(0, 0, 480, 320);
+                self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width);
                 [UIView commitAnimations];
             }
             actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"")
@@ -118,6 +148,12 @@
     [aTableView deselectRowAtIndexPath:indexPath animated:YES];
 }
 
+-(void) removeChat {
+    HW_chatEnd();
+    if (SDL_iPhoneKeyboardIsShown(sdlwindow))
+        SDL_iPhoneKeyboardHide(sdlwindow);
+}
+
 #pragma mark -
 #pragma mark actionSheet methods
 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {