From ec76b828d35779b39a702c796d66090e2cea588b Mon Sep 17 00:00:00 2001 From: elderwyn Date: Fri, 29 Mar 2024 22:48:47 -0400 Subject: [PATCH 1/3] Feature > Show Target Indicator https://discord.com/channels/1087124353155608617/1192285684493451404/1192285684493451404 --- .../Configuration/Language.cs | 1 + src/ClassicUO.Client/Configuration/Profile.cs | 1 + .../Game/Managers/HealthLinesManager.cs | 35 +++++++++++++++++-- .../Game/UI/Gumps/ModernOptionsGump.cs | 4 +++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/ClassicUO.Client/Configuration/Language.cs b/src/ClassicUO.Client/Configuration/Language.cs index 2d92b78767..4f88903487 100644 --- a/src/ClassicUO.Client/Configuration/Language.cs +++ b/src/ClassicUO.Client/Configuration/Language.cs @@ -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"; diff --git a/src/ClassicUO.Client/Configuration/Profile.cs b/src/ClassicUO.Client/Configuration/Profile.cs index e2c69894c5..0513f288e1 100644 --- a/src/ClassicUO.Client/Configuration/Profile.cs +++ b/src/ClassicUO.Client/Configuration/Profile.cs @@ -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; diff --git a/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs b/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs index 916954cd3e..220459e7aa 100644 --- a/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs +++ b/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs @@ -65,6 +65,7 @@ public void Draw(UltimaBatcher2D batcher) camera.Bounds.Width, camera.Bounds.Height ); + DrawTargetIndicator(batcher, TargetManager.LastTargetInfo.Serial); } if (SerialHelper.IsMobile(TargetManager.SelectedTarget)) @@ -75,6 +76,7 @@ public void Draw(UltimaBatcher2D batcher) camera.Bounds.Width, camera.Bounds.Height ); + DrawTargetIndicator(batcher, TargetManager.SelectedTarget); } if (SerialHelper.IsMobile(TargetManager.LastAttack)) @@ -85,6 +87,7 @@ public void Draw(UltimaBatcher2D batcher) camera.Bounds.Width, camera.Bounds.Height ); + DrawTargetIndicator(batcher, TargetManager.LastAttack); } if (!IsEnabled) @@ -214,6 +217,34 @@ 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); + 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; + if (indicatorInfo.Texture != null) + { + 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) + ); + } + } private void DrawHealthLineWithMath( UltimaBatcher2D batcher, uint serial, @@ -246,7 +277,7 @@ int screenH return; } - DrawHealthLine(batcher, entity, p.X, p.Y, false); + DrawHealthLine(batcher, entity, p.X, p.Y, false); } private void DrawHealthLine( @@ -301,7 +332,7 @@ bool passive new Rectangle(x, y, gumpInfo.UV.Width * multiplier, gumpInfo.UV.Height * multiplier), gumpInfo.UV, hueVec - ); + ); hueVec.X = 90; diff --git a/src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs b/src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs index d631d0bbaf..5f2f7274c4 100644 --- a/src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs +++ b/src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs @@ -217,6 +217,10 @@ private void BuildGeneral() content.BlankLine(); + content.AddToRight(new CheckboxWithLabel(lang.GetGeneral.ShowTargetIndicator, isChecked: profile.ShowTargetIndicator, valueChanged: (b) => { profile.ShowTargetIndicator = b; }), true, page); + + content.BlankLine(); + content.AddToRight(new CheckboxWithLabel(lang.GetGeneral.HighlightPoisoned, isChecked: profile.HighlightMobilesByPoisoned, valueChanged: (b) => { profile.HighlightMobilesByPoisoned = b; }), true, page); content.Indent(); content.AddToRight(new ModernColorPickerWithLabel(lang.GetGeneral.PoisonHighlightColor, profile.PoisonHue, (h) => { profile.PoisonHue = h; }), true, page); From 68a727a1c1c4dfa613dab7b94135ffee5ff1a62c Mon Sep 17 00:00:00 2001 From: elderwyn Date: Sun, 31 Mar 2024 20:45:02 -0400 Subject: [PATCH 2/3] Moving Texture null check abot Point declarations. --- .../Game/Managers/HealthLinesManager.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs b/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs index 220459e7aa..3a8fb4e8ee 100644 --- a/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs +++ b/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs @@ -230,13 +230,14 @@ private void DrawTargetIndicator(UltimaBatcher2D batcher, uint serial) return; } ref readonly var indicatorInfo = ref Client.Game.Gumps.GetGump(0x756F); - 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; 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), From c27e02a6a27e7a6a4fee40d2926a7c3baf7beadc Mon Sep 17 00:00:00 2001 From: Tad Taylor Date: Wed, 10 Apr 2024 09:26:08 -0600 Subject: [PATCH 3/3] Move option to TUO options & disable if no sprite found --- .../Game/Managers/HealthLinesManager.cs | 10 ++++++---- .../Game/UI/Gumps/ModernOptionsGump.cs | 7 +++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs b/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs index 3a8fb4e8ee..854c4c170d 100644 --- a/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs +++ b/src/ClassicUO.Client/Game/Managers/HealthLinesManager.cs @@ -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 { @@ -245,6 +243,10 @@ private void DrawTargetIndicator(UltimaBatcher2D batcher, uint serial) 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, @@ -278,7 +280,7 @@ int screenH return; } - DrawHealthLine(batcher, entity, p.X, p.Y, false); + DrawHealthLine(batcher, entity, p.X, p.Y, false); } private void DrawHealthLine( @@ -333,7 +335,7 @@ bool passive new Rectangle(x, y, gumpInfo.UV.Width * multiplier, gumpInfo.UV.Height * multiplier), gumpInfo.UV, hueVec - ); + ); hueVec.X = 90; diff --git a/src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs b/src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs index 5f2f7274c4..fec41d725f 100644 --- a/src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs +++ b/src/ClassicUO.Client/Game/UI/Gumps/ModernOptionsGump.cs @@ -217,10 +217,6 @@ private void BuildGeneral() content.BlankLine(); - content.AddToRight(new CheckboxWithLabel(lang.GetGeneral.ShowTargetIndicator, isChecked: profile.ShowTargetIndicator, valueChanged: (b) => { profile.ShowTargetIndicator = b; }), true, page); - - content.BlankLine(); - content.AddToRight(new CheckboxWithLabel(lang.GetGeneral.HighlightPoisoned, isChecked: profile.HighlightMobilesByPoisoned, valueChanged: (b) => { profile.HighlightMobilesByPoisoned = b; }), true, page); content.Indent(); content.AddToRight(new ModernColorPickerWithLabel(lang.GetGeneral.PoisonHighlightColor, profile.PoisonHue, (h) => { profile.PoisonHue = h; }), true, page); @@ -2253,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) => { @@ -2263,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