Skip to content

Commit

Permalink
Merge pull request #224 from elderwyn/feature/ShowTargetIndicator
Browse files Browse the repository at this point in the history
Feature > Show Target Indicator
  • Loading branch information
bittiez committed Apr 10, 2024
2 parents e2293a3 + c27e02a commit 446fef2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ClassicUO.Client/Configuration/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public class General

#region General->Mobiles
public string ShowMobileHP { get; set; } = "Show mobile's HP";
public string ShowTargetIndicator { get; set; } = "Show Target Indicator";
public string MobileHPType { get; set; } = "Type";
public string HPTypePerc { get; set; } = "Percentage";
public string HPTypeBar { get; set; } = "Bar";
Expand Down
1 change: 1 addition & 0 deletions src/ClassicUO.Client/Configuration/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public sealed class Profile
public bool HighlightMobilesByPoisoned { get; set; } = true;
public bool HighlightMobilesByInvul { get; set; } = true;
public bool ShowMobilesHP { get; set; }
public bool ShowTargetIndicator { get; set; }
public int MobileHPType { get; set; } // 0 = %, 1 = line, 2 = both
public int MobileHPShowWhen { get; set; } // 0 = Always, 1 - <100%
public bool DrawRoofs { get; set; } = true;
Expand Down
38 changes: 36 additions & 2 deletions src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
using ClassicUO.Configuration;
using ClassicUO.Game.Data;
using ClassicUO.Game.GameObjects;
using ClassicUO.Assets;
using ClassicUO.Renderer;
using Microsoft.Xna.Framework;
using FontStashSharp;

namespace ClassicUO.Game.Managers
{
Expand Down Expand Up @@ -65,6 +63,7 @@ public void Draw(UltimaBatcher2D batcher)
camera.Bounds.Width,
camera.Bounds.Height
);
DrawTargetIndicator(batcher, TargetManager.LastTargetInfo.Serial);
}

if (SerialHelper.IsMobile(TargetManager.SelectedTarget))
Expand All @@ -75,6 +74,7 @@ public void Draw(UltimaBatcher2D batcher)
camera.Bounds.Width,
camera.Bounds.Height
);
DrawTargetIndicator(batcher, TargetManager.SelectedTarget);
}

if (SerialHelper.IsMobile(TargetManager.LastAttack))
Expand All @@ -85,6 +85,7 @@ public void Draw(UltimaBatcher2D batcher)
camera.Bounds.Width,
camera.Bounds.Height
);
DrawTargetIndicator(batcher, TargetManager.LastAttack);
}

if (!IsEnabled)
Expand Down Expand Up @@ -214,6 +215,39 @@ public void Draw(UltimaBatcher2D batcher)
}
}

private void DrawTargetIndicator(UltimaBatcher2D batcher, uint serial)
{
Entity entity = World.Get(serial);

if (entity == null)
{
return;
}
if (ProfileManager.CurrentProfile == null || !ProfileManager.CurrentProfile.ShowTargetIndicator)
{
return;
}
ref readonly var indicatorInfo = ref Client.Game.Gumps.GetGump(0x756F);
if (indicatorInfo.Texture != null)
{
Point p = entity.RealScreenPosition;
p.Y += (int)(entity.Offset.Y - entity.Offset.Z) + 22 + 5;

p = Client.Game.Scene.Camera.WorldToScreen(p);
p.Y -= entity.FrameInfo.Height + 25;

batcher.Draw(
indicatorInfo.Texture,
new Rectangle(p.X - 24, p.Y, indicatorInfo.UV.Width, indicatorInfo.UV.Height),
indicatorInfo.UV,
ShaderHueTranslator.GetHueVector(0, false, 1.0f)
);
}
else
{
ProfileManager.CurrentProfile.ShowTargetIndicator = false; //This sprite doesn't exist for this client, lets avoid checking for it every frame.
}
}
private void DrawHealthLineWithMath(
UltimaBatcher2D batcher,
uint serial,
Expand Down
3 changes: 3 additions & 0 deletions src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,7 @@ private void BuildTazUO()
{
profile.DisableAutoFollowAlt = i;
}), true, page);
content.RemoveIndent();
content.BlankLine();
content.AddToRight(c = new CheckboxWithLabel(lang.GetTazUO.DisableMouseInteractionsForOverheadText, 0, profile.DisableMouseInteractionOverheadText, (b) =>
{
Expand All @@ -2259,6 +2260,8 @@ private void BuildTazUO()
{
profile.OverridePartyAndGuildHue = b;
}), true, page);
content.BlankLine();
content.AddToRight(new CheckboxWithLabel(lang.GetGeneral.ShowTargetIndicator, isChecked: profile.ShowTargetIndicator, valueChanged: (b) => { profile.ShowTargetIndicator = b; }), true, page);
#endregion

#region Misc
Expand Down

0 comments on commit 446fef2

Please sign in to comment.