target using the utility button, this fixes bee
authorXeli
Sun, 29 Apr 2012 16:09:42 +0200
changeset 6957 ab8034208fcd
parent 6956 7d9e2669c2f5
child 6958 8230a516ba93
target using the utility button, this fixes bee
hedgewars/uTouch.pas
hedgewars/uTypes.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uTouch.pas	Sun Apr 29 14:10:59 2012 +0200
+++ b/hedgewars/uTouch.pas	Sun Apr 29 16:09:42 2012 +0200
@@ -80,7 +80,7 @@
     targetAngle: LongInt;
 
     buttonsDown: Longword;
-    targetting: boolean; //true when targetting an airstrike or the like
+    targetting, targetted: boolean; //true when targetting an airstrike or the like
 
 procedure onTouchDown(x,y: Longword; pointerId: TSDL_FingerId);
 var 
@@ -101,9 +101,7 @@
 
 if isOnWidget(fireButton, finger^) then
     begin
-    if not((CurrentHedgehog <> nil) and 
-       (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0)) then
-        ParseTeamCommand('+attack');
+    ParseTeamCommand('+attack');
     moveCursor:= false;
     finger^.pressedWidget:= @fireButton;
     exit;
@@ -149,11 +147,14 @@
 
 if isOnWidget(utilityWidget, finger^) then
     begin
+    finger^.pressedWidget:= @utilityWidget;
+    moveCursor:= false;
     if(CurrentHedgehog <> nil) then
         begin
         if Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable <> 0 then
             ParseTeamCommand('/timer ' + inttostr((GetCurAmmoEntry(CurrentHedgeHog^)^.Timer div 1000) mod 5 + 1));
         end;
+    exit;
     end; 
 dec(buttonsDown);//no buttonsDown, undo the inc() above
 if buttonsDown = 0 then
@@ -161,7 +162,7 @@
     moveCursor:= true;
     case pointerCount of
         1:
-            targetting:= (CurrentHedgehog <> nil) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0);
+            targetting:= not(targetted) and (CurrentHedgehog <> nil) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0);
         2:
             begin
             moveCursor:= false;
@@ -259,15 +260,19 @@
         ParseTeamCommand('-down');
 
     if widget = @fireButton then
+        ParseTeamCommand('-attack');
+    
+    if widget = @utilityWidget then
         if (CurrentHedgehog <> nil) and 
            (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0)then
-            ParseTeamCommand('put')
-        else
-            ParseTeamCommand('-attack');
+            begin
+            ParseTeamCommand('put');
+            targetted:= true;
+            end;
     end;
         
 if targetting then
-    AddCaption('Press the attack button to mark the target', cWhiteColor, capgrpAmmoInfo);
+    AddCaption('Press the target button to mark the target', cWhiteColor, capgrpAmmoInfo);
  
 deleteFinger(pointerId);
 {$ENDIF}
--- a/hedgewars/uTypes.pas	Sun Apr 29 14:10:59 2012 +0200
+++ b/hedgewars/uTypes.pas	Sun Apr 29 16:09:42 2012 +0200
@@ -59,7 +59,7 @@
             sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR,
 {$IFDEF USE_TOUCH_INTERFACE}
             sprFireButton, sprArrowUp, sprArrowDown, sprArrowLeft, sprArrowRight,
-            sprJumpWidget, sprAMWidget, sprPauseButton, sprTimerButton,
+            sprJumpWidget, sprAMWidget, sprPauseButton, sprTimerButton, sprTargetButton,
 {$ENDIF}
             sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun,
             sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer,
--- a/hedgewars/uVariables.pas	Sun Apr 29 14:10:59 2012 +0200
+++ b/hedgewars/uVariables.pas	Sun Apr 29 16:09:42 2012 +0200
@@ -406,6 +406,8 @@
             Width: 120; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprPauseButton
             (FileName: 'pause'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;//TODO correct image
             Width: 120; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprTimerButton
+            (FileName: 'forwardjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;//TODO correct image
+            Width: 120; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprTargetButton
 {$ENDIF}
             (FileName:      'Flake'; Path:ptCurrTheme; AltPath: ptNone; Texture: nil; Surface: nil;
             Width:  64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprFlake
--- a/hedgewars/uWorld.pas	Sun Apr 29 14:10:59 2012 +0200
+++ b/hedgewars/uWorld.pas	Sun Apr 29 16:09:42 2012 +0200
@@ -729,12 +729,16 @@
                         end;
                 if (Ammo^[Slot, Pos].Propz and ammoprop_Timerable) <> 0 then
                     begin
-                    if not utilityWidget.show then
-                        animateWidget(@utilityWidget, true, true); 
+                    utilityWidget.sprite:= sprTimerButton;
+                    animateWidget(@utilityWidget, true, true);
+                    end 
+                else if (Ammo^[Slot, Pos].Propz and ammoprop_NeedTarget) <> 0 then
+                    begin
+                    utilityWidget.sprite:= sprTargetButton;
+                    animateWidget(@utilityWidget, true, true);
                     end
-                else
-                    if utilityWidget.show then
-                        animateWidget(@utilityWidget, true, false); 
+                else if utilityWidget.show then
+                    animateWidget(@utilityWidget, true, false); 
 {$ENDIF}
 
                 exit