first part of the utilitywidget (grenade timer/swap hogs) code
authorXeli
Fri, 23 Mar 2012 14:14:43 +0100
changeset 6806 cdfb6c7099e5
parent 6805 097289be7200
child 6807 f4816282ba01
first part of the utilitywidget (grenade timer/swap hogs) code
hedgewars/uTouch.pas
hedgewars/uTypes.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uTouch.pas	Thu Mar 22 22:55:38 2012 +0400
+++ b/hedgewars/uTouch.pas	Fri Mar 23 14:14:43 2012 +0100
@@ -121,28 +121,32 @@
     exit;
     end;
 if isOnWidget(arrowUp, finger^) then
-     begin
-     upKey:= true;
-     moveCursor:= false;
-     finger^.pressedWidget:= @arrowUp;
-     exit;
-     end;
+    begin
+    upKey:= true;
+    moveCursor:= false;
+    finger^.pressedWidget:= @arrowUp;
+    exit;
+    end;
 if isOnWidget(arrowDown, finger^) then
-     begin
-     downKey:= true;
-     moveCursor:= false;
-     finger^.pressedWidget:= @arrowDown;
-     exit;
-     end;
+    begin
+    downKey:= true;
+    moveCursor:= false;
+    finger^.pressedWidget:= @arrowDown;
+    exit;
+    end;
 
 if isOnWidget(pauseButton, finger^) then
-     begin
-     isPaused:= not isPaused;
-     moveCursor:= false;
-     finger^.pressedWidget:= @pauseButton;
-     exit;
-     end;
-     
+    begin
+    isPaused:= not isPaused;
+    moveCursor:= false;
+    finger^.pressedWidget:= @pauseButton;
+    exit;
+    end;
+
+if isOnWidget(utilityWidget, finger^) then
+    begin
+    ParseCommand('/timer ' + inttostr((CurrentHedgeHog^.CurWeapon^.Timer div 1000 + 1) mod 5));
+    end; 
 dec(buttonsDown);//no buttonsDown, undo the inc() above
 if buttonsDown = 0 then
     begin
--- a/hedgewars/uTypes.pas	Thu Mar 22 22:55:38 2012 +0400
+++ b/hedgewars/uTypes.pas	Fri Mar 23 14:14:43 2012 +0100
@@ -59,7 +59,7 @@
             sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR,
 {$IFDEF USE_TOUCH_INTERFACE}
             sprFireButton, sprArrowUp, sprArrowDown, sprArrowLeft, sprArrowRight,
-            sprJumpWidget, sprAMWidget, sprPauseButton,
+            sprJumpWidget, sprAMWidget, sprPauseButton, sprTimerButton,
 {$ENDIF}
             sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun,
             sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer,
--- a/hedgewars/uVariables.pas	Thu Mar 22 22:55:38 2012 +0400
+++ b/hedgewars/uVariables.pas	Fri Mar 23 14:14:43 2012 +0100
@@ -200,7 +200,7 @@
 
     arrowUp, arrowDown, arrowLeft, arrowRight : TOnScreenWidget;
     firebutton, jumpWidget, AMWidget          : TOnScreenWidget;
-    pauseButton                               : TOnScreenWidget;
+    pauseButton, utilityWidget                : TOnScreenWidget;
 {$ENDIF}
 
     AMAnimType      : LongInt;
@@ -403,6 +403,8 @@
             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
+            (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
 {$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	Thu Mar 22 22:55:38 2012 +0400
+++ b/hedgewars/uWorld.pas	Fri Mar 23 14:14:43 2012 +0100
@@ -341,6 +341,26 @@
     active.h:= frame.h;
     end;
 
+with utilityWidget do
+    begin
+    show:= false;
+    sprite:= sprTimerButton;
+    frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale);
+    frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale);
+    frame.x:= arrowLeft.frame.x;
+    frame.y:= arrowLeft.frame.y - Round(frame.h * 1.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;
+        target.y:= frame.y;
+        source.x:= frame.x;
+        source.y:= frame.y;
+        end;
+    end;
 {$ENDIF}
 end;
 
@@ -668,6 +688,14 @@
                         animateWidget(@arrowUp, true, false);
                         animateWidget(@arrowDown, true, false);
                         end;
+                if (Ammo^[Slot, Pos].Propz and ammoprop_Timerable) <> 0 then
+                    begin
+                    if not utilityWidget.show then
+                        animateWidget(@utilityWidget, true, true); 
+                    end
+                else
+                    if utilityWidget.show then
+                        animateWidget(@utilityWidget, true, false); 
 {$ENDIF}
 
                 exit
@@ -1226,6 +1254,7 @@
 DrawScreenWidget(@jumpWidget);
 DrawScreenWidget(@AMWidget);
 DrawScreenWidget(@pauseButton);
+DrawScreenWidget(@utilityWidget);
 {$ENDIF}
 
 // Teams Healths