hedgewars/uWorld.pas
changeset 13174 061d55939e47
parent 13156 26f0c3669b4e
child 13370 e202d58236b1
child 13779 c384117f90eb
equal deleted inserted replaced
13173:4d1cf0d76eb7 13174:061d55939e47
  1025     end;
  1025     end;
  1026 end;
  1026 end;
  1027 
  1027 
  1028 
  1028 
  1029 procedure RenderTeamsHealth;
  1029 procedure RenderTeamsHealth;
  1030 var t, i,  h, smallScreenOffset, TeamHealthBarWidth : LongInt;
  1030 var t, i, h, v, smallScreenOffset, TeamHealthBarWidth : LongInt;
  1031     r: TSDL_Rect;
  1031     r: TSDL_Rect;
  1032     highlight: boolean;
  1032     highlight: boolean;
  1033     hasVisibleHog: boolean;
  1033     hasVisibleHog: boolean;
  1034     htex: PTexture;
  1034     htex: PTexture;
  1035 begin
  1035 begin
  1036 if TeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
  1036 if VisibleTeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
  1037     begin
  1037     begin
  1038     SetScale(1.5);
  1038     SetScale(1.5);
  1039     smallScreenOffset:= cScreenHeight div 6;
  1039     smallScreenOffset:= cScreenHeight div 6;
  1040     if TeamsCount * 100 > Longword(cScreenHeight) then
  1040     if VisibleTeamsCount * 100 > Longword(cScreenHeight) then
  1041         Tint($FF,$FF,$FF,$80);
  1041         Tint($FF,$FF,$FF,$80);
  1042     end
  1042     end
  1043 else smallScreenOffset:= 0;
  1043 else smallScreenOffset:= 0;
       
  1044 v:= 0; // for updating VisibleTeamsCount
  1044 for t:= 0 to Pred(TeamsCount) do
  1045 for t:= 0 to Pred(TeamsCount) do
  1045     with TeamsArray[t]^ do
  1046     with TeamsArray[t]^ do
  1046       begin
  1047       begin
  1047       hasVisibleHog:= false;
  1048       hasVisibleHog:= false;
  1048       for i:= 0 to cMaxHHIndex do
  1049       for i:= 0 to cMaxHHIndex do
  1049           if (Hedgehogs[i].Gear <> nil) then
  1050           if (Hedgehogs[i].Gear <> nil) then
  1050               hasVisibleHog:= true;
  1051               hasVisibleHog:= true;
  1051       if (TeamHealth > 0) and hasVisibleHog then
  1052       if (TeamHealth > 0) and hasVisibleHog then
  1052         begin
  1053         begin
       
  1054         // count visible teams
       
  1055         inc(v);
  1053         highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
  1056         highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
  1054 
  1057 
  1055         if highlight then
  1058         if highlight then
  1056             begin
  1059             begin
  1057             Tint(Clan^.Color shl 8 or $FF);
  1060             Tint(Clan^.Color shl 8 or $FF);
  1102 
  1105 
  1103         // if highlighted, draw flag and other contents again to keep their colors
  1106         // if highlighted, draw flag and other contents again to keep their colors
  1104         // this approach should be faster than drawing all borders one by one tinted or not
  1107         // this approach should be faster than drawing all borders one by one tinted or not
  1105         if highlight then
  1108         if highlight then
  1106             begin
  1109             begin
  1107             if TeamsCount * 100 > Longword(cScreenHeight) then
  1110             if VisibleTeamsCount * 100 > Longword(cScreenHeight) then
  1108                 Tint($FF,$FF,$FF,$80)
  1111                 Tint($FF,$FF,$FF,$80)
  1109             else untint;
  1112             else untint;
  1110 
  1113 
  1111             // draw name
  1114             // draw name
  1112             r.x:= 2;
  1115             r.x:= 2;
  1151         end;
  1154         end;
  1152       end;
  1155       end;
  1153 if smallScreenOffset <> 0 then
  1156 if smallScreenOffset <> 0 then
  1154     begin
  1157     begin
  1155     SetScale(cDefaultZoomLevel);
  1158     SetScale(cDefaultZoomLevel);
  1156     if TeamsCount * 20 > Longword(cScreenHeight) div 5 then
  1159     if VisibleTeamsCount * 20 > Longword(cScreenHeight) div 5 then
  1157         untint;
  1160         untint;
  1158     end;
  1161     end;
       
  1162 VisibleTeamsCount:= v;
  1159 end;
  1163 end;
  1160 
  1164 
  1161 
  1165 
  1162 var preShiftWorldDx: LongInt;
  1166 var preShiftWorldDx: LongInt;
  1163 
  1167