hedgewars/uGearsRender.pas
changeset 14553 5ae97eab70eb
parent 14552 05b929808585
child 14572 34e810295d08
equal deleted inserted replaced
14552:05b929808585 14553:5ae97eab70eb
   261 end;
   261 end;
   262 
   262 
   263 // Render some informational GUI next to hedgehog, like fuel and alternate weapon
   263 // Render some informational GUI next to hedgehog, like fuel and alternate weapon
   264 procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
   264 procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
   265 var HH: PHedgehog;
   265 var HH: PHedgehog;
   266     sx, sy: LongInt;
   266     sx, sy, sign, m: LongInt;
   267 begin
   267 begin
   268     HH:= Gear^.Hedgehog;
   268     HH:= Gear^.Hedgehog;
   269     sx:= ox + 1; // this offset is very common
   269     sx:= ox + 1; // this offset is very common
   270     sy:= oy - 3;
   270     sy:= oy - 3;
   271     if HH^.Unplaced then
   271     if HH^.Unplaced then
   273     if (Gear^.State and gstHHDeath) <> 0 then
   273     if (Gear^.State and gstHHDeath) <> 0 then
   274         exit;
   274         exit;
   275     if (Gear^.State and gstHHGone) <> 0 then
   275     if (Gear^.State and gstHHGone) <> 0 then
   276         exit;
   276         exit;
   277 
   277 
       
   278     // render crosshair
       
   279     if (Gear = CrosshairGear) then
       
   280         begin
       
   281         sign:= hwSign(Gear^.dX);
       
   282         m:= 1;
       
   283         if ((Gear^.State and gstHHHJump) <> 0) and (HH^.Effects[heArtillery] = 0) then
       
   284             m:= -1;
       
   285         setTintAdd(true);
       
   286         Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
       
   287         DrawTextureRotated(CrosshairTexture,
       
   288                 12, 12, CrosshairX + WorldDx, CrosshairY + WorldDy, 0,
       
   289                 sign * m * (Gear^.Angle * 180.0) / cMaxAngle);
       
   290         untint;
       
   291         setTintAdd(false);
       
   292         end;
       
   293 
       
   294     // render gear-related extras: alt weapon, fuel, other
   278     if ((Gear^.State and gstHHDriven) <> 0) and (CurAmmoGear <> nil) then
   295     if ((Gear^.State and gstHHDriven) <> 0) and (CurAmmoGear <> nil) then
   279         begin
   296         begin
   280         case CurAmmoGear^.Kind of
   297         case CurAmmoGear^.Kind of
   281             gtJetpack:      begin
   298             gtJetpack:      begin
   282                             // render jetpack contour if underwater
   299                             // render jetpack contour if underwater
   494                         end;
   511                         end;
   495                     end;
   512                     end;
   496 
   513 
   497                 DrawLineWrapped(hx, hy, tx, ty, 1.0, (sign*m) < 0, wraps, $FF, $00, $00, $C0);
   514                 DrawLineWrapped(hx, hy, tx, ty, 1.0, (sign*m) < 0, wraps, $FF, $00, $00, $C0);
   498                 end;
   515                 end;
   499             // draw crosshair
   516             // calculate crosshair position
   500             CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
   517             CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
   501             CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
   518             CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
   502 
   519             // crosshair will be rendered in RenderHHGuiExtras
   503             setTintAdd(true);
   520             CrosshairGear := Gear;
   504             Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
       
   505             DrawTextureRotated(CrosshairTexture,
       
   506                     12, 12, CrosshairX + WorldDx, CrosshairY + WorldDy, 0,
       
   507                     sign * m * (Gear^.Angle * 180.0) / cMaxAngle);
       
   508             untint;
       
   509             setTintAdd(false);
       
   510             end;
   521             end;
   511 
   522 
   512         hx:= ox + 8 * sign;
   523         hx:= ox + 8 * sign;
   513         hy:= oy - 2;
   524         hy:= oy - 2;
   514         aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
   525         aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
   920             defaultPos:= false
   931             defaultPos:= false
   921         end;
   932         end;
   922 
   933 
   923     end else // not gstHHDriven
   934     end else // not gstHHDriven
   924         begin
   935         begin
       
   936         CrosshairGear:= nil;
   925         // check if hedgehog is sliding/rolling
   937         // check if hedgehog is sliding/rolling
   926         if (Gear^.Damage > 0) and (HH^.Effects[heFrozen] = 0)
   938         if (Gear^.Damage > 0) and (HH^.Effects[heFrozen] = 0)
   927         and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   939         and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   928             begin
   940             begin
   929             defaultPos:= false;
   941             defaultPos:= false;