hedgewars/uGearsRender.pas
changeset 15441 617f4c092e3d
parent 15332 2196aa902d2d
child 15470 a18f7e4681b8
equal deleted inserted replaced
15440:e9fd2527a457 15441:617f4c092e3d
    36             rounded   : array[0..MAXROPEPOINTS + 2] of TVertex2f;
    36             rounded   : array[0..MAXROPEPOINTS + 2] of TVertex2f;
    37          end;
    37          end;
    38 procedure RenderGear(Gear: PGear; x, y: LongInt);
    38 procedure RenderGear(Gear: PGear; x, y: LongInt);
    39 procedure RenderGearTimer(Gear: PGear; x, y: LongInt);
    39 procedure RenderGearTimer(Gear: PGear; x, y: LongInt);
    40 procedure RenderGearHealth(Gear: PGear; x, y: LongInt);
    40 procedure RenderGearHealth(Gear: PGear; x, y: LongInt);
       
    41 procedure RenderFinger(Gear: PGear; ox, oy: LongInt);
    41 procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
    42 procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
    42 procedure RenderAirMineGuiExtras(Gear: PGear; ox, oy: LongInt);
    43 procedure RenderAirMineGuiExtras(Gear: PGear; ox, oy: LongInt);
    43 procedure DrawHHOrder();
    44 procedure DrawHHOrder();
    44 
    45 
    45 var RopePoints: record
    46 var RopePoints: record
   236         until (i > cMaxHHIndex);
   237         until (i > cMaxHHIndex);
   237     end
   238     end
   238 
   239 
   239 end;
   240 end;
   240 
   241 
       
   242 procedure RenderFinger(Gear: PGear; ox, oy: LongInt);
       
   243 var HH: PHedgehog;
       
   244     tx, ty, t: LongInt;
       
   245     dAngle: real;
       
   246 begin
       
   247     HH:= Gear^.Hedgehog;
       
   248     if HH^.Unplaced then
       
   249         exit;
       
   250     if (Gear^.State and gstHHDeath) <> 0 then
       
   251         exit;
       
   252     if (Gear^.State and gstHHGone) <> 0 then
       
   253         exit;
       
   254     if (CinematicScript) then
       
   255         exit;
       
   256 
       
   257     // render finger (arrow pointing to hog)
       
   258     if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
       
   259         begin
       
   260         ty := oy - 32;
       
   261         // move finger higher up if tags or switching arrows are above hog
       
   262         if (cTagsMask and htTeamName) <> 0 then
       
   263             ty := ty - HH^.Team^.NameTagTex^.h - 2;
       
   264         if (cTagsMask and htName) <> 0 then
       
   265             ty := ty - HH^.NameTagTex^.h - 2;
       
   266         if (cTagsMask and htHealth) <> 0 then
       
   267             ty := ty - HH^.HealthTagTex^.h - 2;
       
   268         if bShowSwitcher then
       
   269             ty := ty - SpritesData[sprSwitch].Height - 4;
       
   270         tx := ox;
       
   271 
       
   272         // don't go offscreen
       
   273         t:= 32;
       
   274         tx := min(max(tx, ViewLeftX + t), ViewRightX - t);
       
   275         ty := min(ty, ViewBottomY - 96);
       
   276         // don't overlap with HH or HH tags
       
   277         if ty < ViewTopY + t then
       
   278             begin
       
   279             if abs(tx - ox) < abs(ty - oy)  then
       
   280                 ty:= max(ViewTopY + t, oy + t)
       
   281             else
       
   282                 ty:= max(ViewTopY + t, ty);
       
   283             end;
       
   284 
       
   285         dAngle := DxDy2Angle(int2hwfloat(ty - oy), int2hwfloat(tx - ox)) + 90;
       
   286 
       
   287         if (IsTooDarkToRead(HH^.Team^.Clan^.Color)) then
       
   288             DrawSpriteRotatedF(sprFingerBackInv, tx, ty, RealTicks div 32 mod 16, 1, dAngle)
       
   289         else
       
   290             DrawSpriteRotatedF(sprFingerBack, tx, ty, RealTicks div 32 mod 16, 1, dAngle);
       
   291         Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
       
   292         DrawSpriteRotatedF(sprFinger, tx, ty, RealTicks div 32 mod 16, 1, dAngle);
       
   293         untint;
       
   294         end;
       
   295 end;
       
   296 
       
   297 
   241 // Render some informational GUI next to hedgehog, like fuel and alternate weapon
   298 // Render some informational GUI next to hedgehog, like fuel and alternate weapon
   242 procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
   299 procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
   243 var HH: PHedgehog;
   300 var HH: PHedgehog;
   244     sx, sy, tx, ty, t, hogLR: LongInt;
   301     sx, sy, hogLR: LongInt;
   245     dAngle: real;
       
   246 begin
   302 begin
   247     HH:= Gear^.Hedgehog;
   303     HH:= Gear^.Hedgehog;
   248     sx:= ox + 1; // this offset is very common
   304     sx:= ox + 1; // this offset is very common
   249     sy:= oy - 3;
   305     sy:= oy - 3;
   250     if HH^.Unplaced then
   306     if HH^.Unplaced then
   253         exit;
   309         exit;
   254     if (Gear^.State and gstHHGone) <> 0 then
   310     if (Gear^.State and gstHHGone) <> 0 then
   255         exit;
   311         exit;
   256     if (CinematicScript) then
   312     if (CinematicScript) then
   257         exit;
   313         exit;
   258 
       
   259     // render finger (pointing arrow)
       
   260     if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
       
   261         begin
       
   262         ty := oy - 32;
       
   263         // move finger higher up if tags or switching arrows are above hog
       
   264         if (cTagsMask and htTeamName) <> 0 then
       
   265             ty := ty - HH^.Team^.NameTagTex^.h - 2;
       
   266         if (cTagsMask and htName) <> 0 then
       
   267             ty := ty - HH^.NameTagTex^.h - 2;
       
   268         if (cTagsMask and htHealth) <> 0 then
       
   269             ty := ty - HH^.HealthTagTex^.h - 2;
       
   270         if bShowSwitcher then
       
   271             ty := ty - SpritesData[sprSwitch].Height - 4;
       
   272         tx := ox;
       
   273 
       
   274         // don't go offscreen
       
   275         t:= 32;
       
   276         tx := min(max(tx, ViewLeftX + t), ViewRightX - t);
       
   277         ty := min(ty, ViewBottomY - 96);
       
   278         // don't overlap with HH or HH tags
       
   279         if ty < ViewTopY + t then
       
   280             begin
       
   281             if abs(tx - ox) < abs(ty - oy)  then
       
   282                 ty:= max(ViewTopY + t, oy + t)
       
   283             else
       
   284                 ty:= max(ViewTopY + t, ty);
       
   285             end;
       
   286 
       
   287         dAngle := DxDy2Angle(int2hwfloat(ty - oy), int2hwfloat(tx - ox)) + 90;
       
   288 
       
   289         if (IsTooDarkToRead(HH^.Team^.Clan^.Color)) then
       
   290             DrawSpriteRotatedF(sprFingerBackInv, tx, ty, RealTicks div 32 mod 16, 1, dAngle)
       
   291         else
       
   292             DrawSpriteRotatedF(sprFingerBack, tx, ty, RealTicks div 32 mod 16, 1, dAngle);
       
   293         Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
       
   294         DrawSpriteRotatedF(sprFinger, tx, ty, RealTicks div 32 mod 16, 1, dAngle);
       
   295         untint;
       
   296         end;
       
   297 
   314 
   298     // render crosshair
   315     // render crosshair
   299     if (CrosshairGear <> nil) and (Gear = CrosshairGear) then
   316     if (CrosshairGear <> nil) and (Gear = CrosshairGear) then
   300         begin
   317         begin
   301         hogLR:= 1;
   318         hogLR:= 1;