hedgewars/uWorld.pas
branchios-develop
changeset 13413 ba39a1d396c0
parent 13412 236cc4cf2448
child 13465 08a3851aaf67
equal deleted inserted replaced
13411:6e8b807bda4b 13413:ba39a1d396c0
    30 
    30 
    31 procedure DrawWorld(Lag: LongInt);
    31 procedure DrawWorld(Lag: LongInt);
    32 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
    32 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
    33 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
    33 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
    34 procedure HideMission;
    34 procedure HideMission;
    35 procedure SetAmmoTexts(ammoType: TAmmoType; name: ansistring; caption: ansistring; description: ansistring);
    35 procedure SetAmmoTexts(ammoType: TAmmoType; name: ansistring; caption: ansistring; description: ansistring; autoLabels: boolean);
    36 procedure ShakeCamera(amount: LongInt);
    36 procedure ShakeCamera(amount: LongInt);
    37 procedure InitCameraBorders;
    37 procedure InitCameraBorders;
    38 procedure InitTouchInterface;
    38 procedure InitTouchInterface;
    39 procedure SetUtilityWidgetState(ammoType: TAmmoType);
    39 procedure SetUtilityWidgetState(ammoType: TAmmoType);
    40 procedure animateWidget(widget: POnScreenWidget; fade, showWidget: boolean);
    40 procedure animateWidget(widget: POnScreenWidget; fade, showWidget: boolean);
  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     htex: PTexture;
  1034     htex: PTexture;
  1034 begin
  1035 begin
  1035 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
  1036     begin
  1037     begin
  1037     SetScale(1.5);
  1038     SetScale(1.5);
  1038     smallScreenOffset:= cScreenHeight div 6;
  1039     smallScreenOffset:= cScreenHeight div 6;
  1039     if TeamsCount * 100 > Longword(cScreenHeight) then
  1040     if VisibleTeamsCount * 100 > Longword(cScreenHeight) then
  1040         Tint($FF,$FF,$FF,$80);
  1041         Tint($FF,$FF,$FF,$80);
  1041     end
  1042     end
  1042 else smallScreenOffset:= 0;
  1043 else smallScreenOffset:= 0;
       
  1044 v:= 0; // for updating VisibleTeamsCount
  1043 for t:= 0 to Pred(TeamsCount) do
  1045 for t:= 0 to Pred(TeamsCount) do
  1044     with TeamsArray[t]^ do
  1046     with TeamsArray[t]^ do
  1045       if TeamHealth > 0 then
  1047       begin
  1046         begin
  1048       hasVisibleHog:= false;
       
  1049       for i:= 0 to cMaxHHIndex do
       
  1050           if (Hedgehogs[i].Gear <> nil) then
       
  1051               hasVisibleHog:= true;
       
  1052       if (TeamHealth > 0) and hasVisibleHog then
       
  1053         begin
       
  1054         // count visible teams
       
  1055         inc(v);
  1047         highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
  1056         highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
  1048 
  1057 
  1049         if highlight then
  1058         if highlight then
  1050             begin
  1059             begin
  1051             Tint(Clan^.Color shl 8 or $FF);
  1060             Tint(Clan^.Color shl 8 or $FF);
  1085                 inc(h, Hedgehogs[i].HealthBarHealth);
  1094                 inc(h, Hedgehogs[i].HealthBarHealth);
  1086                 if (h < TeamHealthBarHealth) and (Hedgehogs[i].HealthBarHealth > 0) then
  1095                 if (h < TeamHealthBarHealth) and (Hedgehogs[i].HealthBarHealth > 0) then
  1087                     DrawTexture(15 + h * TeamHealthBarWidth div TeamHealthBarHealth, cScreenHeight + DrawHealthY + smallScreenOffset + 1, SpritesData[sprSlider].Texture);
  1096                     DrawTexture(15 + h * TeamHealthBarWidth div TeamHealthBarHealth, cScreenHeight + DrawHealthY + smallScreenOffset + 1, SpritesData[sprSlider].Texture);
  1088                 end;
  1097                 end;
  1089 
  1098 
  1090         // draw ai kill counter for gfAISurvival
  1099         // draw Lua value, if set
  1091         if (GameFlags and gfAISurvival) <> 0 then
  1100         if (hasLuaTeamValue) then
  1092             begin
  1101             DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY + smallScreenOffset, LuaTeamValueTex)
       
  1102         // otherwise, draw AI kill counter for gfAISurvival
       
  1103         else if (GameFlags and gfAISurvival) <> 0 then
  1093             DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY + smallScreenOffset, AIKillsTex);
  1104             DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY + smallScreenOffset, AIKillsTex);
  1094             end;
       
  1095 
  1105 
  1096         // 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
  1097         // 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
  1098         if highlight then
  1108         if highlight then
  1099             begin
  1109             begin
  1100             if TeamsCount * 100 > Longword(cScreenHeight) then
  1110             if VisibleTeamsCount * 100 > Longword(cScreenHeight) then
  1101                 Tint($FF,$FF,$FF,$80)
  1111                 Tint($FF,$FF,$FF,$80)
  1102             else untint;
  1112             else untint;
  1103 
  1113 
  1104             // draw name
  1114             // draw name
  1105             r.x:= 2;
  1115             r.x:= 2;
  1113                 r.w:= OwnerTex^.w - 4;
  1123                 r.w:= OwnerTex^.w - 4;
  1114                 r.h:= OwnerTex^.h - 4;
  1124                 r.h:= OwnerTex^.h - 4;
  1115                 DrawTextureFromRect(-OwnerTex^.w - NameTagTex^.w - 16, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, OwnerTex)
  1125                 DrawTextureFromRect(-OwnerTex^.w - NameTagTex^.w - 16, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, OwnerTex)
  1116                 end;
  1126                 end;
  1117 
  1127 
  1118             if (GameFlags and gfAISurvival) <> 0 then
  1128             if (hasLuaTeamValue) then
       
  1129                 begin
       
  1130                 r.w:= LuaTeamValueTex^.w - 4;
       
  1131                 r.h:= LuaTeamValueTex^.h - 4;
       
  1132                 DrawTextureFromRect(TeamHealthBarWidth + 24, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, LuaTeamValueTex);
       
  1133                 end
       
  1134             else if (GameFlags and gfAISurvival) <> 0 then
  1119                 begin
  1135                 begin
  1120                 r.w:= AIKillsTex^.w - 4;
  1136                 r.w:= AIKillsTex^.w - 4;
  1121                 r.h:= AIKillsTex^.h - 4;
  1137                 r.h:= AIKillsTex^.h - 4;
  1122                 DrawTextureFromRect(TeamHealthBarWidth + 24, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, AIKillsTex);
  1138                 DrawTextureFromRect(TeamHealthBarWidth + 24, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, AIKillsTex);
  1123                 end;
  1139                 end;
  1134             if OwnerTex <> nil then
  1150             if OwnerTex <> nil then
  1135                 h:= h - OwnerTex^.w - 4;
  1151                 h:= h - OwnerTex^.w - 4;
  1136             DrawSpriteRotatedF(sprFinger, h, cScreenHeight + DrawHealthY + smallScreenOffset + 2 + SpritesData[sprFinger].Width div 4, 0, 1, -90);
  1152             DrawSpriteRotatedF(sprFinger, h, cScreenHeight + DrawHealthY + smallScreenOffset + 2 + SpritesData[sprFinger].Width div 4, 0, 1, -90);
  1137             end;
  1153             end;
  1138         end;
  1154         end;
       
  1155       end;
  1139 if smallScreenOffset <> 0 then
  1156 if smallScreenOffset <> 0 then
  1140     begin
  1157     begin
  1141     SetScale(cDefaultZoomLevel);
  1158     SetScale(cDefaultZoomLevel);
  1142     if TeamsCount * 20 > Longword(cScreenHeight) div 5 then
  1159     if VisibleTeamsCount * 20 > Longword(cScreenHeight) div 5 then
  1143         untint;
  1160         untint;
  1144     end;
  1161     end;
       
  1162 VisibleTeamsCount:= v;
  1145 end;
  1163 end;
  1146 
  1164 
  1147 
  1165 
  1148 var preShiftWorldDx: LongInt;
  1166 var preShiftWorldDx: LongInt;
  1149 
  1167 
  1632         if CountTicks >= 1000 then
  1650         if CountTicks >= 1000 then
  1633             begin
  1651             begin
  1634             FPS:= Frames;
  1652             FPS:= Frames;
  1635             Frames:= 0;
  1653             Frames:= 0;
  1636             CountTicks:= 0;
  1654             CountTicks:= 0;
  1637             s:= inttostr(FPS) + ' fps';
  1655             s:= Format(trmsg[sidFPS], inttostr(FPS));
  1638             tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1656             tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1639             tmpSurface:= doSurfaceConversion(tmpSurface);
  1657             tmpSurface:= doSurfaceConversion(tmpSurface);
  1640             FreeAndNilTexture(fpsTexture);
  1658             FreeAndNilTexture(fpsTexture);
  1641             fpsTexture:= Surface2Tex(tmpSurface, false);
  1659             fpsTexture:= Surface2Tex(tmpSurface, false);
  1642             SDL_FreeSurface(tmpSurface)
  1660             SDL_FreeSurface(tmpSurface)
  1952 procedure HideMission;
  1970 procedure HideMission;
  1953 begin
  1971 begin
  1954     missionTimer:= 0;
  1972     missionTimer:= 0;
  1955 end;
  1973 end;
  1956 
  1974 
  1957 procedure SetAmmoTexts(ammoType: TAmmoType; name: ansistring; caption: ansistring; description: ansistring);
  1975 procedure SetAmmoTexts(ammoType: TAmmoType; name: ansistring; caption: ansistring; description: ansistring; autoLabels: boolean);
  1958 var
  1976 var
  1959     ammoStrId: TAmmoStrId;
  1977     ammoStrId: TAmmoStrId;
  1960     ammoStr: ansistring;
  1978     ammoStr: ansistring;
  1961     tmpsurf: PSDL_Surface;
  1979     tmpsurf: PSDL_Surface;
  1962 begin
  1980 begin
  1977     Ammoz[ammoType].NameTex:= Surface2Tex(tmpsurf, false);
  1995     Ammoz[ammoType].NameTex:= Surface2Tex(tmpsurf, false);
  1978     SDL_FreeSurface(tmpsurf);
  1996     SDL_FreeSurface(tmpsurf);
  1979 
  1997 
  1980     trluaammoc[ammoStrId] := caption;
  1998     trluaammoc[ammoStrId] := caption;
  1981     trluaammod[ammoStrId] := description;
  1999     trluaammod[ammoStrId] := description;
       
  2000     trluaammoe[ammoStrId] := autoLabels;
  1982 end;
  2001 end;
  1983 
  2002 
  1984 procedure ShakeCamera(amount: LongInt);
  2003 procedure ShakeCamera(amount: LongInt);
  1985 begin
  2004 begin
  1986 if isCursorVisible then
  2005 if isCursorVisible then