hedgewars/uGearsRender.pas
changeset 14660 bf37a416ad8f
parent 14603 62dea281e4d5
child 14661 db05d9bf7466
equal deleted inserted replaced
14659:8bd005067f4a 14660:bf37a416ad8f
   258 end;
   258 end;
   259 
   259 
   260 // Render some informational GUI next to hedgehog, like fuel and alternate weapon
   260 // Render some informational GUI next to hedgehog, like fuel and alternate weapon
   261 procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
   261 procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
   262 var HH: PHedgehog;
   262 var HH: PHedgehog;
   263     sx, sy, sign, m: LongInt;
   263     sx, sy, tx, ty, t, sign, m: LongInt;
       
   264     dAngle: real;
   264 begin
   265 begin
   265     HH:= Gear^.Hedgehog;
   266     HH:= Gear^.Hedgehog;
   266     sx:= ox + 1; // this offset is very common
   267     sx:= ox + 1; // this offset is very common
   267     sy:= oy - 3;
   268     sy:= oy - 3;
   268     if HH^.Unplaced then
   269     if HH^.Unplaced then
   269         exit;
   270         exit;
   270     if (Gear^.State and gstHHDeath) <> 0 then
   271     if (Gear^.State and gstHHDeath) <> 0 then
   271         exit;
   272         exit;
   272     if (Gear^.State and gstHHGone) <> 0 then
   273     if (Gear^.State and gstHHGone) <> 0 then
   273         exit;
   274         exit;
       
   275 
       
   276     // render finger (pointing arrow)
       
   277     if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
       
   278         begin
       
   279         ty := oy - 32;
       
   280         // move finger higher up if tags are above hog
       
   281         if (cTagsMask and htTeamName) <> 0 then
       
   282             ty := ty - HH^.Team^.NameTagTex^.h - 2;
       
   283         if (cTagsMask and htName) <> 0 then
       
   284             ty := ty - HH^.NameTagTex^.h - 2;
       
   285         if (cTagsMask and htHealth) <> 0 then
       
   286             ty := ty - HH^.HealthTagTex^.h - 2;
       
   287         tx := ox;
       
   288 
       
   289         // don't go offscreen
       
   290         t:= 32;
       
   291         tx := min(max(tx, ViewLeftX + t), ViewRightX - t);
       
   292         ty := min(ty, ViewBottomY - 96);
       
   293         // don't overlap with HH or HH tags
       
   294         if ty < ViewTopY + t then
       
   295             begin
       
   296             if abs(tx - ox) < abs(ty - oy)  then
       
   297                 ty:= max(ViewTopY + t, oy + t)
       
   298             else
       
   299                 ty:= max(ViewTopY + t, ty);
       
   300             end;
       
   301 
       
   302         dAngle := DxDy2Angle(int2hwfloat(ty - oy), int2hwfloat(tx - ox)) + 90;
       
   303 
       
   304         Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
       
   305         DrawSpriteRotatedF(sprFinger, tx, ty, RealTicks div 32 mod 16, 1, dAngle);
       
   306         untint;
       
   307         end;
   274 
   308 
   275     // render crosshair
   309     // render crosshair
   276     if (CrosshairGear <> nil) and (Gear = CrosshairGear) then
   310     if (CrosshairGear <> nil) and (Gear = CrosshairGear) then
   277         begin
   311         begin
   278         sign:= hwSign(Gear^.dX);
   312         sign:= hwSign(Gear^.dX);
  1150             end;
  1184             end;
  1151         if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
  1185         if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
  1152             begin
  1186             begin
  1153             if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtResurrector) then
  1187             if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtResurrector) then
  1154                 DrawTextureCentered(ox, sy - cHHRadius - 7 - HealthTagTex^.h, HealthTagTex);
  1188                 DrawTextureCentered(ox, sy - cHHRadius - 7 - HealthTagTex^.h, HealthTagTex);
  1155 
       
  1156             if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
       
  1157                 begin
       
  1158                 ty := oy - 32;
       
  1159                 // move finger higher up if tags are above hog
       
  1160                 if (cTagsMask and htTeamName) <> 0 then
       
  1161                     ty := ty - Team^.NameTagTex^.h - 2;
       
  1162                 if (cTagsMask and htName) <> 0 then
       
  1163                     ty := ty - NameTagTex^.h - 2;
       
  1164                 if (cTagsMask and htHealth) <> 0 then
       
  1165                     ty := ty - HealthTagTex^.h - 2;
       
  1166                 tx := ox;
       
  1167 
       
  1168                 // don't go offscreen
       
  1169                 t:= 32;
       
  1170                 tx := min(max(tx, ViewLeftX + t), ViewRightX  - t);
       
  1171                 t:= 32;
       
  1172                 ty := min(ty, ViewBottomY - 96);
       
  1173                 // don't overlap with HH or HH tags
       
  1174                 if ty < ViewTopY + t then
       
  1175                     begin
       
  1176                     if abs(tx - ox) < abs(ty - oy)  then
       
  1177                         ty:= max(ViewTopY + t, oy + t)
       
  1178                     else
       
  1179                         ty:= max(ViewTopY + t, ty);
       
  1180                     end;
       
  1181 
       
  1182                 dAngle := DxDy2Angle(int2hwfloat(ty - oy), int2hwfloat(tx - ox)) + 90;
       
  1183 
       
  1184                 Tint(Team^.Clan^.Color shl 8 or $FF);
       
  1185                 DrawSpriteRotatedF(sprFinger, tx, ty, RealTicks div 32 mod 16, 1, dAngle);
       
  1186                 untint;
       
  1187                 end;
       
  1188 
       
  1189 
  1189 
  1190             if (Gear^.State and gstDrowning) = 0 then
  1190             if (Gear^.State and gstDrowning) = 0 then
  1191                 if (Gear^.State and gstHHThinking) <> 0 then
  1191                 if (Gear^.State and gstHHThinking) <> 0 then
  1192                     DrawSprite(sprQuestion, ox - 10, oy - cHHRadius - 34, (RealTicks shr 9) mod 8)
  1192                     DrawSprite(sprQuestion, ox - 10, oy - cHHRadius - 34, (RealTicks shr 9) mod 8)
  1193             end
  1193             end