hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
authorXeli
Sun, 29 Apr 2012 18:08:46 +0200
changeset 6961 d5ac09894a1b
parent 6960 822f8269e13f
child 6962 ec308eabe09b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
hedgewars/uTeams.pas
hedgewars/uTouch.pas
hedgewars/uWorld.pas
--- a/hedgewars/uTeams.pas	Sun Apr 29 20:52:10 2012 +0200
+++ b/hedgewars/uTeams.pas	Sun Apr 29 18:08:46 2012 +0200
@@ -37,7 +37,7 @@
 
 implementation
 uses uLocale, uAmmos, uChat, uMobile, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug, uScript,
-    uGearsUtils, uGearsList;
+    uGearsUtils, uGearsList, uTouch;
 
 const MaxTeamHealth: LongInt = 0;
 
@@ -300,6 +300,7 @@
     end;
 
 uMobile.NewTurnBeginning();
+uTouch.NewTurnBeginning();
 ScriptCall('onNewTurn');
 end;
 
--- a/hedgewars/uTouch.pas	Sun Apr 29 20:52:10 2012 +0200
+++ b/hedgewars/uTouch.pas	Sun Apr 29 18:08:46 2012 +0200
@@ -22,12 +22,14 @@
 
 interface
 
-uses sysutils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, uIO, GLUnit, uTypes, uCaptions, uAmmos;
+uses sysutils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, uIO, GLUnit, uTypes, uCaptions, uAmmos, uWorld;
 
 
 procedure initModule;
 
 procedure ProcessTouch;
+procedure NewTurnBeginning;
+
 procedure onTouchDown(x,y: Longword; pointerId: TSDL_FingerId);
 procedure onTouchMotion(x,y: Longword; dx,dy: LongInt; pointerId: TSDL_FingerId);
 procedure onTouchUp(x,y: Longword; pointerId: TSDL_FingerId);
@@ -409,6 +411,14 @@
 
 end;
 
+procedure NewTurnBeginning;
+begin
+targetted:= false;
+targetting:= false;
+SetUtilityWidgetState;
+end;
+
+
 procedure ProcessTouch;
 var
     deltaAngle: LongInt;
--- a/hedgewars/uWorld.pas	Sun Apr 29 20:52:10 2012 +0200
+++ b/hedgewars/uWorld.pas	Sun Apr 29 18:08:46 2012 +0200
@@ -36,6 +36,7 @@
 procedure ShakeCamera(amount: LongInt);
 procedure InitCameraBorders;
 procedure InitTouchInterface;
+procedure SetUtilityWidgetState(ammoType: TAmmoType = amNothing);
 procedure animateWidget(widget: POnScreenWidget; fade, showWidget: boolean);
 procedure MoveCamera;
 procedure onFocusStateChanged;
@@ -727,20 +728,8 @@
                         animateWidget(@arrowUp, true, false);
                         animateWidget(@arrowDown, true, false);
                         end;
-                if (Ammo^[Slot, Pos].Propz and ammoprop_Timerable) <> 0 then
-                    begin
-                    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); 
+                SetUtilityWidgetState(Ammo^[Slot, Pos].AmmoType);
 {$ENDIF}
-
                 exit
                 end;
             end
@@ -1760,6 +1749,26 @@
 else UndampenAudio();
 end;
 
+procedure SetUtilityWidgetState(ammoType: TAmmoType);
+begin
+if(ammoType = amNothing)then
+    ammoType:= CurrentHedgehog^.CurAmmoType;
+
+if(CurrentHedgehog <> nil)then
+    if (Ammoz[ammoType].Ammo.Propz and ammoprop_Timerable) <> 0 then
+        begin
+        utilityWidget.sprite:= sprTimerButton;
+        animateWidget(@utilityWidget, true, true);
+        end 
+    else if (Ammoz[ammoType].Ammo.Propz and ammoprop_NeedTarget) <> 0 then
+        begin
+        utilityWidget.sprite:= sprTargetButton;
+        animateWidget(@utilityWidget, true, true);
+        end
+    else if utilityWidget.show then
+        animateWidget(@utilityWidget, true, false); 
+end;
+
 procedure animateWidget(widget: POnScreenWidget; fade, showWidget: boolean);
 begin
 with widget^ do