# HG changeset patch # User Wuzzy # Date 1554657976 -7200 # Node ID ab7bf5036314873be247f93d768059ce333195e1 # Parent 533ac9774279b3e49cbe2775622812955bcb5ee8 Render mine timer if gear info is active diff -r 533ac9774279 -r ab7bf5036314 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Sun Apr 07 18:21:14 2019 +0200 +++ b/hedgewars/uGears.pas Sun Apr 07 19:26:16 2019 +0200 @@ -274,10 +274,25 @@ end; if curHandledGear^.Active then begin - if curHandledGear^.RenderTimer and (curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0) then + if curHandledGear^.RenderTimer then begin - FreeAndNilTexture(curHandledGear^.Tex); - curHandledGear^.Tex:= RenderStringTex(ansistring(inttostr(curHandledGear^.Timer div 1000)), cWhiteColor, fntSmall); + if (curHandledGear^.Kind in [gtMine, gtSMine, gtAirMine]) then + begin + if curHandledGear^.Tex = nil then + begin + i:= curHandledGear^.Timer; + if (i > 0) and (i < 1000) then + i:= 1 + else + i:= curHandledGear^.Timer div 1000; + curHandledGear^.Tex:= RenderStringTex(ansistring(inttostr(i)), $ff808080, fntSmall); + end; + end + else if ((curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0)) then + begin + FreeAndNilTexture(curHandledGear^.Tex); + curHandledGear^.Tex:= RenderStringTex(ansistring(inttostr(curHandledGear^.Timer div 1000)), cWhiteColor, fntSmall); + end; end; curHandledGear^.doStep(curHandledGear); end diff -r 533ac9774279 -r ab7bf5036314 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Sun Apr 07 18:21:14 2019 +0200 +++ b/hedgewars/uGearsHandlersMess.pas Sun Apr 07 19:26:16 2019 +0200 @@ -1951,6 +1951,7 @@ dmg: LongWord; begin if Gear^.Health = 0 then dxdy:= hwAbs(Gear^.dX)+hwAbs(Gear^.dY); + Gear^.RenderTimer:= ((Gear^.State and gstFrozen) = 0) and ((Gear^.State and gstAttacking) = 0) and (Gear^.Health <> 0); if (Gear^.State and gstMoving) <> 0 then begin DeleteCI(Gear); @@ -2049,6 +2050,7 @@ sparkle: PVisualGear; begin targ:= nil; + Gear^.RenderTimer:= ((Gear^.State and gstFrozen) = 0) and ((Gear^.State and gstAttacking) = 0); if (Gear^.State and gstFrozen) <> 0 then begin if Gear^.Damage > 0 then @@ -2288,6 +2290,7 @@ CalcRotationDirAngle(Gear); end; + Gear^.RenderTimer:= ((Gear^.State and gstFrozen) = 0) and ((Gear^.State and gstAttacking) = 0); if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then begin if ((Gear^.State and gstAttacking) = 0) and ((Gear^.State and gstFrozen) = 0) then diff -r 533ac9774279 -r ab7bf5036314 hedgewars/uGearsList.pas --- a/hedgewars/uGearsList.pas Sun Apr 07 18:21:14 2019 +0200 +++ b/hedgewars/uGearsList.pas Sun Apr 07 19:26:16 2019 +0200 @@ -433,7 +433,8 @@ gear^.Timer:= getrandom(51)*100 else gear^.Timer:= cMinesTime - end + end; + gear^.RenderTimer:= true; end; gtAirMine: begin gear^.AdvBounce:= 1; @@ -449,6 +450,7 @@ gear^.Power:= cMaxWindSpeed.QWordValue div 2; // hwFloat converted. 1/2 g default. defines the "seek" speed when a gear is in range. gear^.Pos:= cMaxWindSpeed.QWordValue * 3 div 2; // air friction. slows it down when not hitting stuff gear^.Tag:= 0; + gear^.RenderTimer:= true; if gear^.Timer = 0 then begin if cMinesTime < 0 then @@ -468,6 +470,7 @@ gear^.AdvBounce:= 1; gear^.Sticky:= true; if gear^.Timer = 0 then gear^.Timer:= 500; + gear^.RenderTimer:= true; end; gtKnife: begin gear^.ImpactSound:= sndKnifeImpact; diff -r 533ac9774279 -r ab7bf5036314 hedgewars/uGearsRender.pas --- a/hedgewars/uGearsRender.pas Sun Apr 07 18:21:14 2019 +0200 +++ b/hedgewars/uGearsRender.pas Sun Apr 07 19:26:16 2019 +0200 @@ -1645,7 +1645,7 @@ procedure RenderGearTimer(Gear: PGear; x, y: LongInt); begin -if Gear^.RenderTimer and (Gear^.Tex <> nil) then +if Gear^.RenderTimer and (Gear^.Tex <> nil) and (isShowGearInfo or (not (Gear^.Kind in [gtMine, gtSMine, gtAirMine]))) then DrawTextureCentered(x + 8, y + 8, Gear^.Tex); end; diff -r 533ac9774279 -r ab7bf5036314 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Sun Apr 07 18:21:14 2019 +0200 +++ b/hedgewars/uScript.pas Sun Apr 07 19:26:16 2019 +0200 @@ -1907,7 +1907,12 @@ if CheckLuaParamCount(L, 2, 'SetTimer', 'gearUid, timer') then begin gear:= GearByUID(Trunc(lua_tonumber(L, 1))); - if gear <> nil then gear^.Timer:= Trunc(lua_tonumber(L, 2)) + if gear <> nil then + begin + gear^.Timer:= Trunc(lua_tonumber(L, 2)); + if gear^.RenderTimer and (gear^.Tex <> nil) then + FreeAndNilTexture(gear^.Tex); + end; end; lc_settimer:= 0 end;