Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature > Show Target Indicator #224

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ out int height
}
}

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a check if the texture is empty because I don't believe all client versions have this graphic

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 @@
{
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 @@
{
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 Expand Up @@ -4718,7 +4721,7 @@
private class LeftSideMenuRightSideContent : Control
{
private ScrollArea left, right;
private int leftY, rightY = Theme.TOP_PADDING, leftX, rightX;

Check warning on line 4724 in src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Field 'ModernOptionsGump.LeftSideMenuRightSideContent.leftX' is never assigned to, and will always have its default value 0

public ScrollArea LeftArea => left;
public ScrollArea RightArea => right;
Expand Down Expand Up @@ -4821,7 +4824,7 @@
private readonly int _groupnumber;
private bool _isSelected;

public bool DisplayBorder;

Check warning on line 4827 in src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Field 'ModernOptionsGump.ModernButton.DisplayBorder' is never assigned to, and will always have its default value false

public bool FullPageSwitch;

Expand Down
Loading