switching hogs now works
authorkoda
Sun, 18 Jul 2010 03:55:56 +0200
changeset 3651 7058ca178f3b
parent 3650 ec90e573f47a
child 3652 df76ccda0648
switching hogs now works
hedgewars/PascalExports.pas
hedgewars/uKeys.pas
project_files/HedgewarsMobile/Classes/OverlayViewController.h
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Classes/PascalImports.h
--- a/hedgewars/PascalExports.pas	Sun Jul 18 03:26:15 2010 +0200
+++ b/hedgewars/PascalExports.pas	Sun Jul 18 03:55:56 2010 +0200
@@ -13,7 +13,7 @@
 unit PascalExports;
 
 interface
-uses uKeys, GLunit, uWorld, uMisc, uConsole, uTeams, uConsts, uChat, hwengine;
+uses uKeys, GLunit, uWorld, uMisc, uConsole, uTeams, uConsts, uChat, uGears, hwengine;
 
 {$INCLUDE "config.inc"}
 
@@ -119,6 +119,11 @@
     backspaceKey:= true;
 end;
 
+procedure HW_tab; cdecl; export;
+begin
+    tabKey:= true;
+end;
+
 procedure HW_chat; cdecl; export;
 begin
     chatAction:= true;
@@ -130,40 +135,11 @@
     KeyPressChat(13); // enter - removes chat
 end;
 
-procedure HW_tab; cdecl; export;
-begin
-    switchAction:= true;
-end;
-
 procedure HW_pause; cdecl; export;
 begin
     pauseAction:= true;
 end;
 
-procedure HW_cursorUp(coefficient:LongInt); cdecl; export;
-begin
-    coeff:= coefficient;
-    cursorUp:= true;
-end;
-
-procedure HW_cursorDown(coefficient:LongInt); cdecl; export;
-begin
-    coeff:= coefficient;
-    cursorDown:= true;
-end;
-
-procedure HW_cursorLeft(coefficient:LongInt); cdecl; export;
-begin
-    coeff:= coefficient;
-    cursorLeft:= true;
-end;
-
-procedure HW_cursorRight(coefficient:LongInt); cdecl; export;
-begin
-    coeff:= coefficient;
-    cursorRight:= true;
-end;
-
 procedure HW_terminate(closeFrontend: boolean); cdecl; export;
 begin
     isTerminated:= true;
@@ -220,6 +196,14 @@
     exit( (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0)
 end;
 
+function HW_isWeaponSwitch: boolean cdecl; export;
+begin
+    if CurAmmoGear <> nil then
+        exit(CurAmmoGear^.AmmoType = amSwitch) 
+    else
+        exit(false)
+end;
+
 procedure HW_setGrenadeTime(time: LongInt); cdecl; export;
 begin
     ParseCommand('/timer ' + inttostr(time), true);
--- a/hedgewars/uKeys.pas	Sun Jul 18 03:26:15 2010 +0200
+++ b/hedgewars/uKeys.pas	Sun Jul 18 03:55:56 2010 +0200
@@ -79,12 +79,7 @@
     
     chatAction: boolean;
     pauseAction: boolean;
-    switchAction: boolean;
     
-    cursorUp: boolean;
-    cursorDown: boolean;
-    cursorLeft: boolean;
-    cursorRight: boolean;
 {$IFDEF IPHONEOS}    
 procedure setiPhoneBinds;
 {$ENDIF}
@@ -346,10 +341,6 @@
 DefaultBinds[27]:= '+precise';
 DefaultBinds[44]:= 'chat';
 DefaultBinds[55]:= 'pause';
-DefaultBinds[66]:= '+cur_u';
-DefaultBinds[67]:= '+cur_d';
-DefaultBinds[68]:= '+cur_l';
-DefaultBinds[69]:= '+cur_r';
 {$ELSE}
 DefaultBinds[KeyNameToCode('up')]:= '+up';
 DefaultBinds[KeyNameToCode('down')]:= '+down';
@@ -391,12 +382,6 @@
 
     tkbdn[44]:= ord(chatAction);
     tkbdn[55]:= ord(pauseAction);
-    //tkbdn[100]:= ord(switchAction);
-    
-    tkbdn[66]:= ord(cursorUp);
-    tkbdn[67]:= ord(cursorDown);
-    tkbdn[68]:= ord(cursorLeft);
-    tkbdn[69]:= ord(cursorRight);
     
     // set to false the keys that only need one stoke
     leftClick:= false;
@@ -409,7 +394,6 @@
     
     chatAction:= false;
     pauseAction:= false;
-    //switchAction:= false;
 end;
 {$ENDIF}
 
@@ -534,14 +518,6 @@
     // other key emulation
     chatAction:= false;
     pauseAction:= false;
-    switchAction:= false;
-
-    // cursor emulation
-    cursorUp:= false;
-    cursorDown:= false;
-    cursorLeft:= false;
-    cursorRight:= false;
-    
 {$ENDIF}
 end;
 
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Sun Jul 18 03:26:15 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Sun Jul 18 03:55:56 2010 +0200
@@ -22,6 +22,7 @@
     
     // ths touch section
     CGFloat initialDistanceForPinching;
+    CGPoint startingPoint;
     BOOL isSegmentVisible;
     
     // the sdl window underneath
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sun Jul 18 03:26:15 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sun Jul 18 03:55:56 2010 +0200
@@ -326,8 +326,9 @@
     doDim();
     
     switch ([allTouches count]) {
-        case 1:            
+        case 1:       
             removeConfirmationInput();
+            startingPoint = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view];
             if (2 == [[[allTouches allObjects] objectAtIndex:0] tapCount])
                 HW_zoomReset();
             break;
@@ -460,6 +461,8 @@
             } else {
                 DLog(@"x: %f y: %f -> X:%d Y:%d", currentPosition.x, currentPosition.y, HWX(currentPosition.x), HWY(currentPosition.y));
                 HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y));
+                if (HW_isWeaponSwitch())
+                    HW_tab();
             }
             break;
         case 2:
--- a/project_files/HedgewarsMobile/Classes/PascalImports.h	Sun Jul 18 03:26:15 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/PascalImports.h	Sun Jul 18 03:55:56 2010 +0200
@@ -50,11 +50,6 @@
     void HW_tab(void);
     void HW_pause(void);
     
-    void HW_cursorUp(int);
-    void HW_cursorDown(int);
-    void HW_cursorLeft(int);
-    void HW_cursorRight(int);
-    
     void HW_terminate(BOOL andCloseFrontend);
     
     void HW_setLandscape(BOOL rotate);
@@ -64,6 +59,7 @@
     BOOL HW_isAmmoOpen(void);
     BOOL HW_isWeaponRequiringClick(void);
     BOOL HW_isWeaponTimerable(void);
+    BOOL HW_isWeaponSwitch(void);
     
     void HW_setGrenadeTime(int time);