merge
authorkoda
Sat, 18 Feb 2012 19:33:48 +0100 (2012-02-18)
changeset 6715 54faf3034720
parent 6713 3a02e9c25ac5 (current diff)
parent 6714 f2f93017132c (diff)
child 6716 c9e873cf2b08
merge
--- a/hedgewars/uRender.pas	Sat Feb 18 19:33:04 2012 +0100
+++ b/hedgewars/uRender.pas	Sat Feb 18 19:33:48 2012 +0100
@@ -470,8 +470,11 @@
             if RealTicks > (startTime + MOVE_ANIM_TIME) then
                 begin
                 startTime:= 0;
+                animate:= false;
                 frame.x:= target.x;
                 frame.y:= target.y;
+                active.x:= active.x + (target.x - source.x);
+                active.y:= active.y + (target.y - source.y);
                 end
             else
                 begin
--- a/hedgewars/uTouch.pas	Sat Feb 18 19:33:04 2012 +0100
+++ b/hedgewars/uTouch.pas	Sat Feb 18 19:33:48 2012 +0100
@@ -22,7 +22,7 @@
 
 interface
 
-uses sysutils, uConsole, uVariables, SDLh, uFloat, uConsts, uIO, GLUnit, uTypes;
+uses sysutils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, uIO, GLUnit, uTypes;
 
 
 procedure initModule;
@@ -40,6 +40,7 @@
 procedure deleteFinger(id: TSDL_FingerId);
 procedure onTouchClick(finger: TTouch_Data);
 procedure onTouchDoubleClick(finger: TTouch_Data);
+procedure onTouchLongClick(finger: TTouch_Data);
 
 function findFinger(id: TSDL_FingerId): PTouch_Data;
 procedure aim(finger: TTouch_Data);
@@ -56,7 +57,8 @@
 implementation
 
 const
-    clicktime = 200;
+    clickTime = 200;
+    longClickTime = 400;
     nilFingerId = High(TSDL_FingerId);
 
 var
@@ -132,20 +134,6 @@
      exit;
      end;
 
-if isOnRect(backjump.active, finger^) then
-     begin
-     enterKey:= true;
-     moveCursor:= false;
-     finger^.pressedWidget:= @backjump;
-     exit;
-     end;
-if isOnRect(forwardjump.active, finger^) then
-     begin
-     backspaceKey:= true;
-     moveCursor:= false;
-     finger^.pressedWidget:= @forwardjump;
-     exit;
-     end;
 if isOnRect(pauseButton.active, finger^) then
      begin
      isPaused:= not isPaused;
@@ -153,7 +141,7 @@
      finger^.pressedWidget:= @pauseButton;
      exit;
      end;
-
+     
 dec(buttonsDown);//no buttonsDown, undo the inc() above
 if buttonsDown = 0 then
     begin
@@ -220,9 +208,11 @@
 y := y;
 finger:= updateFinger(x,y,0,0,pointerId);
 //Check for onTouchClick event
-if ((RealTicks - finger^.timeSinceDown) < clickTime) AND not(fingerHasMoved(finger^)) then
-    onTouchClick(finger^);
-WriteToConsole(Format('%d', [buttonsDown]));
+if not(fingerHasMoved(finger^)) then
+    if (RealTicks - finger^.timeSinceDown) < clickTime then
+        onTouchClick(finger^)
+    else
+        onTouchLongClick(finger^);
 
 if aimingCrosshair then
     begin
@@ -251,12 +241,6 @@
 
     if widget = @fireButton then
         spaceKey:= false;
-
-    if widget = @backjump then
-        enterKey:= false;
-
-    if widget = @forwardjump then
-        backspaceKey:= false;
     end;
  
 deleteFinger(pointerId);
@@ -268,14 +252,25 @@
 finger := finger;//avoid compiler hint
 end;
 
+procedure onTouchLongClick(finger: TTouch_Data);
+begin
+if isOnRect(jumpWidget.active, finger) then
+    begin
+    ParseCommand('ljump', (CurrentTeam <> nil) and not(CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel=0));
+    if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
+        ParseCommand('gencmd R', true);
+    exit;
+    end;
+end;
+
 procedure onTouchClick(finger: TTouch_Data);
 begin
-if (RealTicks - timeSinceClick < 300) and (sqrt(sqr(finger.X-xTouchClick) + sqr(finger.Y-yTouchClick)) < 30) then
-    begin
-    onTouchDoubleClick(finger);
-    timeSinceClick:= 0;//we make an assumption there won't be an 'click' in the first 300 ticks(milliseconds) 
-    exit; 
-    end;
+//if (RealTicks - timeSinceClick < 300) and (sqrt(sqr(finger.X-xTouchClick) + sqr(finger.Y-yTouchClick)) < 30) then
+//    begin
+//    onTouchDoubleClick(finger);
+//    timeSinceClick:= 0;//we make an assumption there won't be an 'click' in the first 300 ticks(milliseconds) 
+//    exit; 
+//    end;
 
 xTouchClick:= finger.x;
 yTouchClick:= finger.y;
@@ -295,11 +290,19 @@
     end;
 
 
-if isOnCurrentHog(finger) then
+if isOnCurrentHog(finger) or isOnRect(AMWidget.active, finger) then
     begin
     bShowAmmoMenu := true;
     exit;
     end;
+
+if isOnRect(jumpWidget.active, finger) then
+    begin
+    ParseCommand('hjump', (CurrentTeam <> nil) and not(CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel=0));
+    if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
+        ParseCommand('gencmd R', true);
+    exit;
+    end;
 end;
 
 function addFinger(x,y: Longword; id: TSDL_FingerId): PTouch_Data;
--- a/hedgewars/uTypes.pas	Sat Feb 18 19:33:04 2012 +0100
+++ b/hedgewars/uTypes.pas	Sat Feb 18 19:33:48 2012 +0100
@@ -59,7 +59,7 @@
             sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR,
 {$IFDEF USE_TOUCH_INTERFACE}
             sprFireButton, sprArrowUp, sprArrowDown, sprArrowLeft, sprArrowRight,
-            sprBackjump, sprForwardjump, sprPauseButton,
+            sprJumpWidget, sprAMWidget, sprPauseButton,
 {$ENDIF}
             sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun,
             sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer,
--- a/hedgewars/uVariables.pas	Sat Feb 18 19:33:04 2012 +0100
+++ b/hedgewars/uVariables.pas	Sat Feb 18 19:33:48 2012 +0100
@@ -198,9 +198,9 @@
 {$IFDEF USE_TOUCH_INTERFACE}
     buttonScale: GLFloat;
 
-    arrowUp, arrowDown, arrowLeft, arrowRight: TOnScreenWidget;
-    firebutton, backjump, forwardjump: TOnScreenWidget;
-	pauseButton: TOnScreenWidget;
+    arrowUp, arrowDown, arrowLeft, arrowRight : TOnScreenWidget;
+    firebutton, jumpWidget, AMWidget          : TOnScreenWidget;
+    pauseButton                               : TOnScreenWidget;
 {$ENDIF}
 const
     cHHFileName = 'Hedgehog';
@@ -395,10 +395,10 @@
             Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowLeft
             (FileName: 'arrowRight'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;
             Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowRight
+            (FileName: 'forwardjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;
+            Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprAMWidget
             (FileName: 'backjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;
-            Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprBackjump
-            (FileName: 'forwardjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;
-            Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprForwardJump
+            Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprJumpWidget
             (FileName: 'pause'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;
             Width: 120; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprPauseButton
 {$ENDIF}
--- a/hedgewars/uWorld.pas	Sat Feb 18 19:33:04 2012 +0100
+++ b/hedgewars/uWorld.pas	Sat Feb 18 19:33:48 2012 +0100
@@ -213,37 +213,33 @@
 //positioning of the buttons
 buttonScale:= 1.5/cDefaultZoomLevel;
 
-with firebutton do
+
+with JumpWidget do
     begin
     show:= true;
-    sprite:= sprFireButton;
+    sprite:= sprJumpWidget;
     frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale);
     frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale);
-    frame.x:= (cScreenWidth shr 1) - frame.w;
-    frame.y:= cScreenHeight - frame.h;
-    active:= frame;
+    frame.x:= (cScreenWidth shr 1) - Round(frame.w * 1.2);
+    frame.y:= cScreenHeight - frame.h * 2;
+    active.x:= frame.x;
+    active.y:= frame.y;
+    active.w:= frame.w;
+    active.h:= frame.h;
     end;
 
-with backjump do
+with AMWidget do
     begin
     show:= true;
-    sprite:= sprbackjump;
+    sprite:= sprAMWidget;
     frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale);
     frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale);
     frame.x:= (cScreenWidth shr 1) - frame.w * 2;
     frame.y:= cScreenHeight - Round(frame.h * 1.2);
-    active:= frame;
-    end;
-
-with forwardjump do
-    begin
-    show:= true;
-    sprite:= sprforwardjump;
-    frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale);
-    frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale);
-    frame.x:= (cScreenWidth shr 1) - Round(frame.w * 1.2);
-    frame.y:= cScreenHeight - frame.h * 2;
-    active:= frame;
+    active.x:= frame.x;
+    active.y:= frame.y;
+    active.w:= frame.w;
+    active.h:= frame.h;
     end;
 
 with arrowLeft do
@@ -254,7 +250,10 @@
     frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale);
     frame.x:= -(cScreenWidth shr 1) + Round(frame.w * 0.25);
     frame.y:= cScreenHeight - Round(frame.h * 1.5);
-    active:= frame;
+    active.x:= frame.x;
+    active.y:= frame.y;
+    active.w:= frame.w;
+    active.h:= frame.h;
     end;
 
 with arrowRight do
@@ -265,7 +264,24 @@
     frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale);
     frame.x:= -(cScreenWidth shr 1) + Round(frame.w * 1.5);
     frame.y:= cScreenHeight - Round(frame.h * 1.5);
-    active:= frame;
+    active.x:= frame.x;
+    active.y:= frame.y;
+    active.w:= frame.w;
+    active.h:= frame.h;
+    end;
+
+with firebutton do
+    begin
+    show:= true;
+    sprite:= sprFireButton;
+    frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale);
+    frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale);
+    frame.x:= arrowRight.frame.x + arrowRight.frame.w;
+    frame.y:= arrowRight.frame.y + (arrowRight.frame.w shr 1) - (frame.w shr 1);
+    active.x:= frame.x;
+    active.y:= frame.y;
+    active.w:= frame.w;
+    active.h:= frame.h;
     end;
 
 with arrowUp do
@@ -275,8 +291,11 @@
     frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale);
     frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale);
     frame.x:= (cScreenWidth shr 1) - frame.w * 2;
-    frame.y:= backjump.frame.y - Round(frame.h * 2.25);
-    active:= frame;
+    frame.y:= jumpWidget.frame.y - Round(frame.h * 2.25);
+    active.x:= frame.x;
+    active.y:= frame.y;
+    active.w:= frame.w;
+    active.h:= frame.h;
     with moveAnim do
          begin
          target.x:= frame.x;
@@ -293,8 +312,11 @@
     frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale);
     frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale);
     frame.x:= (cScreenWidth shr 1) - frame.w * 2;
-    frame.y:= backjump.frame.y - Round(frame.h * 2.25);
-    active:= frame;
+    frame.y:= jumpWidget.frame.y - Round(frame.h * 2.25);
+    active.x:= frame.x;
+    active.y:= frame.y;
+    active.w:= frame.w;
+    active.h:= frame.h;
     with moveAnim do
         begin
         target.x:= frame.x;
@@ -312,7 +334,10 @@
     frame.h:= Round(spritesData[sprPauseButton].Texture^.h * buttonScale);
     frame.x:= cScreenWidth div 2 - frame.w;
     frame.y:= 0;
-    active:= frame;
+    active.x:= frame.x;
+    active.y:= frame.y;
+    active.w:= frame.w;
+    active.h:= frame.h;
     end;
 
 {$ENDIF}
@@ -1188,8 +1213,8 @@
 DrawScreenWidget(@arrowDown);
 
 DrawScreenWidget(@fireButton);
-DrawScreenWidget(@backjump);
-DrawScreenWidget(@forwardjump);
+DrawScreenWidget(@jumpWidget);
+DrawScreenWidget(@AMWidget);
 DrawScreenWidget(@pauseButton);
 {$ENDIF}