# HG changeset patch # User Xeli # Date 1335715726 -7200 # Node ID d5ac09894a1bbae8e2711f6652d1d472ebb19043 # Parent 822f8269e13f7d3487d627fa45d18485e6af29ab hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons diff -r 822f8269e13f -r d5ac09894a1b hedgewars/uTeams.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; diff -r 822f8269e13f -r d5ac09894a1b hedgewars/uTouch.pas --- 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; diff -r 822f8269e13f -r d5ac09894a1b hedgewars/uWorld.pas --- 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