Add support for decimal point of displayed mine timer
authorWuzzy <Wuzzy2@mail.ru>
Sun, 07 Apr 2019 22:43:45 +0200
changeset 14760 21abb4e4ca9f
parent 14759 b39da9cf7616
child 14761 15bcd82ab86c
Add support for decimal point of displayed mine timer
hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Sun Apr 07 20:53:29 2019 +0200
+++ b/hedgewars/uGears.pas	Sun Apr 07 22:43:45 2019 +0200
@@ -51,7 +51,7 @@
 function  IsClockRunning() : boolean;
 
 implementation
-uses uStore, uSound, uTeams, uRandom, uIO, uLandGraphics,
+uses sysutils, uStore, uSound, uTeams, uRandom, uIO, uLandGraphics,
     {$IFDEF USE_TOUCH_INTERFACE}uTouch,{$ENDIF}
     uLocale, uAmmos, uStats, uVisualGears, uScript, uVariables,
     uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions,
@@ -222,7 +222,7 @@
 
 procedure ProcessGears;
 var t: PGear;
-    i, AliveCount: LongInt;
+    i, j, AliveCount: LongInt;
     s: ansistring;
     prevtime: LongWord;
     stirFallers: boolean;
@@ -276,23 +276,26 @@
             begin
             if curHandledGear^.RenderTimer then
                 begin
+                // Mine timer
                 if (curHandledGear^.Kind in [gtMine, gtSMine, gtAirMine]) then
-                    begin
                     if curHandledGear^.Tex = nil then
                         if (curHandledGear^.Karma = 1) and (not (GameType in [gmtDemo, gmtRecord])) then
+                            // Secret mine timer
                             curHandledGear^.Tex:= RenderStringTex(ansistring(trmsg[sidUnknownGearValue]), $ff808080, fntSmall)
                         else
                             begin
-                            i:= curHandledGear^.Timer;
-                            if (i > 0) and (i < 1000)  then
-                                i:= 1
+                            // Display mine timer with up to 1 decimal point of precision (rounded down)
+                            i:= curHandledGear^.Timer div 1000;
+                            j:= (curHandledGear^.Timer mod 1000) div 100;
+                            if j = 0 then
+                                curHandledGear^.Tex:= RenderStringTex(ansistring(inttostr(i)), $ff808080, fntSmall)
                             else
-                                i:= curHandledGear^.Timer div 1000;
-                            curHandledGear^.Tex:= RenderStringTex(ansistring(inttostr(i)), $ff808080, fntSmall);
-                            end;
-                    end
+                                curHandledGear^.Tex:= RenderStringTex(ansistring(inttostr(i) + FormatSettings.DecimalSeparator + inttostr(j)), $ff808080, fntSmall);
+                            end
+                // Timer of other gears
                 else if ((curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0)) then
                     begin
+                    // Display time in seconds as whole number, rounded up
                     FreeAndNilTexture(curHandledGear^.Tex);
                     curHandledGear^.Tex:= RenderStringTex(ansistring(inttostr(curHandledGear^.Timer div 1000)), cWhiteColor, fntSmall);
                     end;