Make timer gray while the time is not running or while it is paused
authorWuzzy <almikes@aol.com>
Sat, 30 Apr 2016 23:46:57 +0200
changeset 11916 38fa4583e7f3
parent 11915 16ce211010cf
child 11917 d819c04d0cbe
Make timer gray while the time is not running or while it is paused
hedgewars/uGears.pas
hedgewars/uWorld.pas
--- a/hedgewars/uGears.pas	Sat Apr 30 23:30:34 2016 +0200
+++ b/hedgewars/uGears.pas	Sat Apr 30 23:46:57 2016 +0200
@@ -46,6 +46,7 @@
 procedure AddMiscGears;
 procedure AssignHHCoords;
 function  GearByUID(uid : Longword) : PGear;
+function  IsClockRunning() : boolean;
 
 implementation
 uses uStore, uSound, uTeams, uRandom, uIO, uLandGraphics,
@@ -444,36 +445,32 @@
     end;
 
 if TurnTimeLeft > 0 then
-    if CurrentHedgehog^.Gear <> nil then
-        if (((CurrentHedgehog^.Gear^.State and gstAttacking) = 0)
-            or (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_DoesntStopTimerWhileAttacking <> 0)
-            or ((GameFlags and gfInfAttack) <> 0) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_DoesntStopTimerWhileAttackingInInfAttackMode <> 0))
-            and (not(isInMultiShoot and ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_DoesntStopTimerInMultiShoot) <> 0))) then
-            //(CurrentHedgehog^.CurAmmoType in [amShotgun, amDEagle, amSniperRifle])
-                begin
-                if (cHedgehogTurnTime >= 10000)
-                and (not PlacingHogs)
-                and (CurrentHedgehog^.Gear <> nil)
-                and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then
-                    if TurnTimeLeft = 5000 then
-                        PlaySoundV(sndHurry, CurrentTeam^.voicepack)
-                    else if TurnTimeLeft = 4000 then
-                        PlaySound(sndCountdown4)
-                    else if TurnTimeLeft = 3000 then
-                        PlaySound(sndCountdown3)
-                    else if TurnTimeLeft = 2000 then
-                        PlaySound(sndCountdown2)
-                    else if TurnTimeLeft = 1000 then
-                        PlaySound(sndCountdown1);
-            if ReadyTimeLeft > 0 then
-                begin
-                if (ReadyTimeLeft = 2000) and (LastVoice.snd = sndNone) then
-                    AddVoice(sndComeonthen, CurrentTeam^.voicepack);
-                dec(ReadyTimeLeft)
-                end
-            else
-                dec(TurnTimeLeft)
-            end;
+    if IsClockRunning() then
+        //(CurrentHedgehog^.CurAmmoType in [amShotgun, amDEagle, amSniperRifle])
+        begin
+        if (cHedgehogTurnTime >= 10000)
+        and (not PlacingHogs)
+        and (CurrentHedgehog^.Gear <> nil)
+        and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then
+            if TurnTimeLeft = 5000 then
+                PlaySoundV(sndHurry, CurrentTeam^.voicepack)
+            else if TurnTimeLeft = 4000 then
+                PlaySound(sndCountdown4)
+            else if TurnTimeLeft = 3000 then
+                PlaySound(sndCountdown3)
+            else if TurnTimeLeft = 2000 then
+                PlaySound(sndCountdown2)
+            else if TurnTimeLeft = 1000 then
+                PlaySound(sndCountdown1);
+        if ReadyTimeLeft > 0 then
+            begin
+            if (ReadyTimeLeft = 2000) and (LastVoice.snd = sndNone) then
+                AddVoice(sndComeonthen, CurrentTeam^.voicepack);
+            dec(ReadyTimeLeft)
+            end
+        else
+            dec(TurnTimeLeft)
+        end;
 
 if skipFlag then
     begin
@@ -1059,6 +1056,16 @@
     end
 end;
 
+function IsClockRunning() : boolean;
+begin
+    IsClockRunning :=
+    (CurrentHedgehog^.Gear <> nil)
+    and (((CurrentHedgehog^.Gear^.State and gstAttacking) = 0)
+    or (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_DoesntStopTimerWhileAttacking <> 0)
+    or ((GameFlags and gfInfAttack) <> 0) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_DoesntStopTimerWhileAttackingInInfAttackMode <> 0))
+    and (not(isInMultiShoot and ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_DoesntStopTimerInMultiShoot) <> 0)));
+end;
+
 
 procedure chSkip(var s: shortstring);
 begin
--- a/hedgewars/uWorld.pas	Sat Apr 30 23:30:34 2016 +0200
+++ b/hedgewars/uWorld.pas	Sat Apr 30 23:46:57 2016 +0200
@@ -1442,7 +1442,9 @@
         while i > 0 do
             begin
             dec(t, 32);
-            if (ReadyTimeLeft <> 0) then
+            if isPaused or (not IsClockRunning()) then
+                spr := sprBigDigitGray
+            else if (ReadyTimeLeft <> 0) then
                 spr := sprBigDigitGreen
             else if IsGetAwayTime then
                 spr := sprBigDigitRed