some further chat polishing
authorkoda
Sat, 17 Jul 2010 06:56:39 +0200
changeset 3648 2477029463ed
parent 3647 0d0df215fb52
child 3649 bc35f8fee587
some further chat polishing
hedgewars/PascalExports.pas
project_files/HedgewarsMobile/Classes/InGameMenuViewController.h
project_files/HedgewarsMobile/Classes/InGameMenuViewController.m
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Classes/PascalImports.h
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- a/hedgewars/PascalExports.pas	Sat Jul 17 03:59:10 2010 +0200
+++ b/hedgewars/PascalExports.pas	Sat Jul 17 06:56:39 2010 +0200
@@ -13,7 +13,7 @@
 unit PascalExports;
 
 interface
-uses uKeys, GLunit, uWorld, uMisc, uGears, uConsole, uTeams, uConsts, hwengine;
+uses uKeys, GLunit, uWorld, uMisc, uConsole, uTeams, uConsts, uChat, hwengine;
 
 {$INCLUDE "config.inc"}
 
@@ -118,6 +118,12 @@
     chatAction:= true;
 end;
 
+procedure HW_chatEnd; cdecl; export;
+begin
+    KeyPressChat(27); // esc - cleans buffer
+    KeyPressChat(13); // enter - removes chat
+end;
+
 procedure HW_tab; cdecl; export;
 begin
     switchAction:= true;
--- a/project_files/HedgewarsMobile/Classes/InGameMenuViewController.h	Sat Jul 17 03:59:10 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/InGameMenuViewController.h	Sat Jul 17 06:56:39 2010 +0200
@@ -14,6 +14,11 @@
     BOOL isPaused;
     SDL_Window *sdlwindow;
 }
+
 @property (nonatomic,retain) NSArray *menuList;
 
+-(void) present;
+-(void) dismiss;
+-(void) removeChat;
+
 @end
--- 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 {
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Jul 17 03:59:10 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Jul 17 06:56:39 2010 +0200
@@ -11,9 +11,9 @@
 #import "PascalImports.h"
 #import "CGPointUtils.h"
 #import "SDL_mouse.h"
-#import "SDL_config_iphoneos.h"
 #import "InGameMenuViewController.h"
 #import "CommodityFunctions.h"
+#import "SDL_config_iphoneos.h"
 
 #define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7]
 #define HIDING_TIME_NEVER   [NSDate dateWithTimeIntervalSinceNow:10000]
@@ -35,7 +35,7 @@
     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
     CGRect rect = [[UIScreen mainScreen] bounds];
     CGRect usefulRect = CGRectMake(0, 0, rect.size.width, rect.size.height);
-    UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:12345];
+    UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG];
     
     [UIView beginAnimations:@"rotation" context:NULL];
     [UIView setAnimationDuration:0.8f];
@@ -276,17 +276,11 @@
                          permittedArrowDirections:UIPopoverArrowDirectionUp
                                          animated:YES];
     } else {
-        if (popupMenu == nil) {
+        if (popupMenu == nil)
             popupMenu = [[InGameMenuViewController alloc] initWithStyle:UITableViewStyleGrouped];
-            popupMenu.view.backgroundColor = [UIColor clearColor];
-            popupMenu.view.frame = CGRectMake(480, 0, 200, 170);
-        }
+        
         [self.view addSubview:popupMenu.view];
-        
-        [UIView beginAnimations:@"showing popover" context:NULL];
-        [UIView setAnimationDuration:0.35];
-        popupMenu.view.frame = CGRectMake(280, 0, 200, 170);
-        [UIView commitAnimations];
+        [popupMenu present];
     }
     popupMenu.tableView.scrollEnabled = NO;
 }
@@ -297,14 +291,10 @@
         isPopoverVisible = NO;
         
         if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+            [(InGameMenuViewController *)popoverController.contentViewController removeChat];
             [popoverController dismissPopoverAnimated:YES];
         } else {
-            [UIView beginAnimations:@"hiding popover" context:NULL];
-            [UIView setAnimationDuration:0.35];
-            popupMenu.view.frame = CGRectMake(480, 0, 200, 170);
-            [UIView commitAnimations];
-        
-            [popupMenu.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35];
+            [popupMenu dismiss];
         }
         [self buttonReleased:nil];
     }
@@ -325,10 +315,6 @@
     if (isPopoverVisible)
         [self dismissPopover];
     
-    // remove keyboard from the view
-    if (SDL_iPhoneKeyboardIsShown(sdlwindow))
-        SDL_iPhoneKeyboardHide(sdlwindow);
-    
     // reset default dimming
     doDim();
     
--- a/project_files/HedgewarsMobile/Classes/PascalImports.h	Sat Jul 17 03:59:10 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/PascalImports.h	Sat Jul 17 06:56:39 2010 +0200
@@ -44,6 +44,7 @@
     void HW_backjump(void);
     
     void HW_chat(void);
+    void HW_chatEnd(void);
     void HW_tab(void);
     void HW_pause(void);
     
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Sat Jul 17 03:59:10 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Sat Jul 17 06:56:39 2010 +0200
@@ -1280,9 +1280,9 @@
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = (
 					/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/OpenAL.framework/Headers,
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include\"/**",
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src\"/**",
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src/\"/**",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net/\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include/\"",
 				);
 				IPHONEOS_DEPLOYMENT_TARGET = 3.0;
 				ONLY_ACTIVE_ARCH = NO;
@@ -1397,9 +1397,9 @@
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = (
 					/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/OpenAL.framework/Headers,
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include\"/**",
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src\"/**",
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src/\"/**",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net/\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include/\"",
 				);
 				IPHONEOS_DEPLOYMENT_TARGET = 3.0;
 				ONLY_ACTIVE_ARCH = NO;
@@ -1597,9 +1597,9 @@
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = (
 					/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/OpenAL.framework/Headers,
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include\"/**",
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src\"/**",
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src/\"/**",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net/\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include/\"",
 				);
 				IPHONEOS_DEPLOYMENT_TARGET = 3.0;
 				ONLY_ACTIVE_ARCH = NO;
@@ -1637,9 +1637,9 @@
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = (
 					/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/OpenAL.framework/Headers,
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include\"/**",
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src\"/**",
-					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src/\"/**",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net/\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include/\"",
 				);
 				IPHONEOS_DEPLOYMENT_TARGET = 3.0;
 				ONLY_ACTIVE_ARCH = NO;