Use visible team count instead of total team count to determine rendered team bar height
authorWuzzy <Wuzzy2@mail.ru>
Mon, 12 Mar 2018 22:53:28 +0100
changeset 13179 061d55939e47
parent 13178 4d1cf0d76eb7
child 13188 fde354aaf978
Use visible team count instead of total team count to determine rendered team bar height
hedgewars/uTeams.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uTeams.pas	Mon Mar 12 19:39:00 2018 +0100
+++ b/hedgewars/uTeams.pas	Mon Mar 12 22:53:28 2018 +0100
@@ -398,6 +398,7 @@
 
 TeamsArray[TeamsCount]:= team;
 inc(TeamsCount);
+inc(VisibleTeamsCount);
 
 team^.Binds:= DefaultBinds;
 
--- a/hedgewars/uVariables.pas	Mon Mar 12 19:39:00 2018 +0100
+++ b/hedgewars/uVariables.pas	Mon Mar 12 22:53:28 2018 +0100
@@ -2497,7 +2497,8 @@
     PreviousTeam: PTeam;
     CurrentHedgehog: PHedgehog;
     TeamsArray: array[0..Pred(cMaxTeams)] of PTeam;
-    TeamsCount: Longword;
+    TeamsCount: Longword; // number of teams on game start
+    VisibleTeamsCount: Longword; // number of teams visible in team bar
     ClansArray, SpawnClansArray: TClansArray;
     ClansCount: Longword;
     LocalClan: LongInt;  // last non-bot, non-extdriven clan
--- a/hedgewars/uWorld.pas	Mon Mar 12 19:39:00 2018 +0100
+++ b/hedgewars/uWorld.pas	Mon Mar 12 22:53:28 2018 +0100
@@ -1027,20 +1027,21 @@
 
 
 procedure RenderTeamsHealth;
-var t, i,  h, smallScreenOffset, TeamHealthBarWidth : LongInt;
+var t, i, h, v, smallScreenOffset, TeamHealthBarWidth : LongInt;
     r: TSDL_Rect;
     highlight: boolean;
     hasVisibleHog: boolean;
     htex: PTexture;
 begin
-if TeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
+if VisibleTeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
     begin
     SetScale(1.5);
     smallScreenOffset:= cScreenHeight div 6;
-    if TeamsCount * 100 > Longword(cScreenHeight) then
+    if VisibleTeamsCount * 100 > Longword(cScreenHeight) then
         Tint($FF,$FF,$FF,$80);
     end
 else smallScreenOffset:= 0;
+v:= 0; // for updating VisibleTeamsCount
 for t:= 0 to Pred(TeamsCount) do
     with TeamsArray[t]^ do
       begin
@@ -1050,6 +1051,8 @@
               hasVisibleHog:= true;
       if (TeamHealth > 0) and hasVisibleHog then
         begin
+        // count visible teams
+        inc(v);
         highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
 
         if highlight then
@@ -1104,7 +1107,7 @@
         // this approach should be faster than drawing all borders one by one tinted or not
         if highlight then
             begin
-            if TeamsCount * 100 > Longword(cScreenHeight) then
+            if VisibleTeamsCount * 100 > Longword(cScreenHeight) then
                 Tint($FF,$FF,$FF,$80)
             else untint;
 
@@ -1153,9 +1156,10 @@
 if smallScreenOffset <> 0 then
     begin
     SetScale(cDefaultZoomLevel);
-    if TeamsCount * 20 > Longword(cScreenHeight) div 5 then
+    if VisibleTeamsCount * 20 > Longword(cScreenHeight) div 5 then
         untint;
     end;
+VisibleTeamsCount:= v;
 end;