diff --git a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs index 35bd1a943e..c2c83e97a1 100644 --- a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs @@ -7,7 +7,6 @@ using Intersect.Client.Framework.Gwen.Input; using Intersect.Client.Framework.Input; using Intersect.Client.General; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Client.Interface.Game.Inventory; using Intersect.Client.Localization; using Intersect.Client.Networking; @@ -21,7 +20,6 @@ public partial class BagItem : SlotItem // Controls private readonly Label _quantityLabel; private readonly BagWindow _bagWindow; - private ItemDescriptionWindow? _descriptionWindow; // Context Menu Handling private readonly MenuItem _withdrawContextItem; @@ -99,9 +97,6 @@ private void Icon_HoverEnter(Base? sender, EventArgs? arguments) return; } - _descriptionWindow?.Dispose(); - _descriptionWindow = default; - if (Globals.BagSlots is not { Length: > 0 } bagSlots) { return; @@ -113,19 +108,12 @@ private void Icon_HoverEnter(Base? sender, EventArgs? arguments) } var item = bagSlots[SlotIndex]; - _descriptionWindow = new ItemDescriptionWindow( - item.Descriptor, - item.Quantity, - _bagWindow.X, - _bagWindow.Y, - item.ItemProperties - ); + Interface.GameUi.ItemDescriptionWindow?.Show(item.Descriptor, item.Quantity, item.ItemProperties); } private void Icon_HoverLeave(Base sender, EventArgs arguments) { - _descriptionWindow?.Dispose(); - _descriptionWindow = default; + Interface.GameUi.ItemDescriptionWindow?.Hide(); } private void Icon_Clicked(Base sender, MouseButtonState arguments) @@ -232,8 +220,5 @@ public override void Update() Icon.IsVisibleInParent = false; } } - - _descriptionWindow?.Dispose(); - _descriptionWindow = default; } } diff --git a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs index 5bd52ab8bb..a9c7194737 100644 --- a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs @@ -9,7 +9,6 @@ using Intersect.Client.Framework.Input; using Intersect.Client.General; using Intersect.Client.Interface.Game.Chat; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Client.Interface.Game.Inventory; using Intersect.Client.Localization; using Intersect.Client.Networking; @@ -24,7 +23,6 @@ public partial class BankItem : SlotItem // Controls private readonly Label _quantityLabel; private BankWindow _bankWindow; - private ItemDescriptionWindow? _descriptionWindow; // Context Menu Handling private MenuItem _withdrawContextItem; @@ -100,10 +98,6 @@ private void Icon_HoverEnter(Base? sender, EventArgs? arguments) return; } - - _descriptionWindow?.Dispose(); - _descriptionWindow = null; - if (Globals.BankSlots is not { Length: > 0 } bankSlots) { return; @@ -115,19 +109,12 @@ private void Icon_HoverEnter(Base? sender, EventArgs? arguments) } var item = bankSlots[SlotIndex]; - _descriptionWindow = new ItemDescriptionWindow( - item.Descriptor, - item.Quantity, - _bankWindow.X, - _bankWindow.Y, - item.ItemProperties - ); + Interface.GameUi.ItemDescriptionWindow?.Show(item.Descriptor, item.Quantity, item.ItemProperties); } private void Icon_HoverLeave(Base sender, EventArgs arguments) { - _descriptionWindow?.Dispose(); - _descriptionWindow = default; + Interface.GameUi.ItemDescriptionWindow?.Hide(); } private void Icon_Clicked(Base sender, MouseButtonState arguments) @@ -298,8 +285,5 @@ public override void Update() Icon.IsVisibleInParent = false; } } - - _descriptionWindow?.Dispose(); - _descriptionWindow = default; } } diff --git a/Intersect.Client.Core/Interface/Game/Character/EquipmentItem.cs b/Intersect.Client.Core/Interface/Game/Character/EquipmentItem.cs index 440310cbad..9e708d0c11 100644 --- a/Intersect.Client.Core/Interface/Game/Character/EquipmentItem.cs +++ b/Intersect.Client.Core/Interface/Game/Character/EquipmentItem.cs @@ -4,27 +4,20 @@ using Intersect.Client.Framework.Gwen.Input; using Intersect.Client.Framework.Input; using Intersect.Client.General; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Client.Networking; using Intersect.Configuration; using Intersect.Framework.Core.GameObjects.Items; -using Intersect.GameObjects; -using Intersect.Network.Packets.Server; namespace Intersect.Client.Interface.Game.Character; - public partial class EquipmentItem { - public ImagePanel ContentPanel; private WindowControl mCharacterWindow; private Guid mCurrentItemId; - private ItemDescriptionWindow mDescWindow; - private ItemProperties mItemProperties = null; private bool mTexLoaded; @@ -78,11 +71,7 @@ void pnl_RightClicked(Base sender, MouseButtonState arguments) void pnl_HoverLeave(Base sender, EventArgs arguments) { - if (mDescWindow != null) - { - mDescWindow.Dispose(); - mDescWindow = null; - } + Interface.GameUi.ItemDescriptionWindow?.Hide(); } void pnl_HoverEnter(Base sender, EventArgs arguments) @@ -97,19 +86,13 @@ void pnl_HoverEnter(Base sender, EventArgs arguments) return; } - if (mDescWindow != null) - { - mDescWindow.Dispose(); - mDescWindow = null; - } - var item = ItemDescriptor.Get(mCurrentItemId); if (item == null) { return; } - mDescWindow = new ItemDescriptionWindow(item, 1, mCharacterWindow.X, mCharacterWindow.Y, mItemProperties, item.Name); + Interface.GameUi.ItemDescriptionWindow?.Show(item, 1, mItemProperties); } public FloatRect RenderBounds() diff --git a/Intersect.Client.Core/Interface/Game/Crafting/CraftingWindow.cs b/Intersect.Client.Core/Interface/Game/Crafting/CraftingWindow.cs index 840fb5801c..10317b3983 100644 --- a/Intersect.Client.Core/Interface/Game/Crafting/CraftingWindow.cs +++ b/Intersect.Client.Core/Interface/Game/Crafting/CraftingWindow.cs @@ -160,10 +160,7 @@ private void LoadCraftRecipe(CraftingRecipeDescriptor craftDescriptor) RemoveChild(container, true); } - if (craftedItem.DescWindow is { } descriptionWindow) - { - descriptionWindow.Dispose(); - } + Interface.GameUi.ItemDescriptionWindow?.Hide(); } var craftedItemDescriptorId = craftDescriptor.ItemId; @@ -191,7 +188,7 @@ private void LoadCraftRecipe(CraftingRecipeDescriptor craftDescriptor) foreach (var recipeItem in mItems) { //Clear the old item description box - recipeItem.DescWindow?.Dispose(); + Interface.GameUi.ItemDescriptionWindow?.Hide(); if (recipeItem.Container is { } container) { mItemContainer.RemoveChild(container, true); diff --git a/Intersect.Client.Core/Interface/Game/Crafting/RecipeItem.cs b/Intersect.Client.Core/Interface/Game/Crafting/RecipeItem.cs index d0f31715ad..9467c216a6 100644 --- a/Intersect.Client.Core/Interface/Game/Crafting/RecipeItem.cs +++ b/Intersect.Client.Core/Interface/Game/Crafting/RecipeItem.cs @@ -2,7 +2,6 @@ using Intersect.Client.Framework.Gwen.Input; using Intersect.Client.Framework.Input; using Intersect.Client.General; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Framework.Core.GameObjects.Crafting; using Intersect.Framework.Core.GameObjects.Items; using Intersect.GameObjects; @@ -15,8 +14,6 @@ public partial class RecipeItem public ImagePanel? Container; - public ItemDescriptionWindow? DescWindow; - public bool IsDragging; //Dragging @@ -86,11 +83,7 @@ void pnl_HoverLeave(Base sender, EventArgs arguments) mMouseOver = false; mMouseX = -1; mMouseY = -1; - if (DescWindow != null) - { - DescWindow.Dispose(); - DescWindow = null; - } + Interface.GameUi.ItemDescriptionWindow?.Hide(); } void pnl_HoverEnter(Base sender, EventArgs arguments) @@ -109,17 +102,9 @@ void pnl_HoverEnter(Base sender, EventArgs arguments) return; } - if (DescWindow != null) - { - DescWindow.Dispose(); - DescWindow = null; - } - if (mIngredient != null && ItemDescriptor.TryGet(mIngredient.ItemId, out var itemDescriptor)) { - DescWindow = new ItemDescriptionWindow( - itemDescriptor, mIngredient.Quantity, mCraftingWindow.X, mCraftingWindow.Y, null - ); + Interface.GameUi.ItemDescriptionWindow?.Show(itemDescriptor, mIngredient.Quantity); } } diff --git a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/ComponentBase.cs b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/ComponentBase.cs index 0f9797ceb3..0e2935b503 100644 --- a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/ComponentBase.cs +++ b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/ComponentBase.cs @@ -1,115 +1,19 @@ -using Intersect.Client.Core; using Intersect.Client.Framework.Gwen.Control; namespace Intersect.Client.Interface.Game.DescriptionWindows.Components; -public partial class ComponentBase : IDisposable +public partial class ComponentBase(Base parent, string name = "") : ImagePanel(parent, name) { - protected Base mParent; - - protected string mName; - - protected ImagePanel mContainer; - - public ComponentBase(Base parent, string name = "") - { - mParent = parent; - mName = name; - } - - protected virtual void GenerateComponents() - { - mContainer = new ImagePanel(mParent, mName); - } - - /// - /// The name of this control. - /// - public string Name { get { return mName; } } - - /// - /// The base container of this control. - /// - public ImagePanel Container => mContainer; - /// - /// Is this component current visible? - /// - public bool IsVisible => mContainer.IsVisibleInTree; - - /// - /// The current X location of the control. - /// - public int X => mContainer.X; - - /// - /// The current Y location of the control. - /// - public int Y => mContainer.Y; - - /// - /// The current width of the control. - /// - public int Width => mContainer.Width; - - /// - /// The current Height of the control. - /// - public int Height => mContainer.Height; - - /// - /// Hide the control. - /// - public void Hide() => mContainer.Hide(); - - /// - /// Show the control. - /// - public void Show() => mContainer.Show(); - - /// - /// Sets the control position. - /// - /// The X position to move the control to. - /// The Y position to move the control to. - /// The container for the item description. - public virtual void SetPosition(int x, int y, ImagePanel? itemDecriptionContainer = null) => mContainer.SetPosition(x, y); - - /// - /// Sets the control position based on ImagePanel. - /// - public virtual void SetPosition(Base _icon, SpellDescriptionWindow _descriptionWindow) => mContainer.SetPosition(_icon); - - /// - /// Resizes the control to fit its children. - /// - /// Allow the control to resize its width. - /// Allow the control to resize its height. - public void SizeToChildren(bool width = true, bool height = true) => mContainer.SizeToChildren(width, height); - - /// - /// Dispose of the object. + /// Corrects the width of the component compared to the parent size. /// - public virtual void Dispose() + public virtual void CorrectWidth() { - if(!mParent.Children.Contains(mContainer)) + if (Parent == default) { return; } - mParent.RemoveChild(mContainer, true); - } - - /// - /// Load the Json layout of the current component. - /// - public void LoadLayout() => mContainer.LoadJsonUi(Framework.File_Management.GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); - - /// - /// Corrects the width of the component compared to the parent size. - /// - public virtual void CorrectWidth() - { - mContainer.SetSize(mParent.InnerWidth, mContainer.InnerHeight); + SetSize(Parent.InnerWidth, InnerHeight); } } diff --git a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/DescriptionComponent.cs b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/DescriptionComponent.cs index 08a81e228b..a2a914beca 100644 --- a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/DescriptionComponent.cs +++ b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/DescriptionComponent.cs @@ -1,23 +1,15 @@ -using Intersect.Client.Framework.Gwen.Control; +using Intersect.Client.Framework.Gwen.Control; namespace Intersect.Client.Interface.Game.DescriptionWindows.Components; public partial class DescriptionComponent : ComponentBase { - protected RichLabel mDescription; + private readonly RichLabel _description; public DescriptionComponent(Base parent, string name) : base(parent, name) { - GenerateComponents(); - } - - protected override void GenerateComponents() - { - base.GenerateComponents(); - - mDescription = new RichLabel(mContainer, "Description"); - mDescription.SizeChanged += (_, _) => mContainer.SizeToChildren(); - + _description = new RichLabel(this, "Description"); + _description.SizeChanged += (_, _) => SizeToChildren(); } /// @@ -27,26 +19,31 @@ protected override void GenerateComponents() /// The the description text should render with. public void AddText(string description, Color color) { - mDescription.AddText(description, color); - mDescription.SizeToChildren(false, true); - mContainer.SizeToChildren(false, true); + _description.AddText(description, color); + _description.SizeToChildren(false, true); + SizeToChildren(false, true); } /// /// Adds a line break to the description. /// - public void AddLineBreak() => mDescription.AddLineBreak(); + public void AddLineBreak() => _description.AddLineBreak(); /// public override void CorrectWidth() { base.CorrectWidth(); - var margins = mDescription.Margin; - mDescription.SetSize(mContainer.InnerWidth - margins.Right, mContainer.InnerHeight); - mDescription.ForceImmediateRebuild(); - mDescription.SizeToChildren(false, true); - mDescription.SetSize(mDescription.Width, mDescription.Height + margins.Bottom); - mContainer.SizeToChildren(false, true); + if (Parent == default) + { + return; + } + + var margins = _description.Margin; + _description.SetSize(InnerWidth - margins.Right, InnerHeight); + _description.ForceImmediateRebuild(); + _description.SizeToChildren(false, true); + _description.SetSize(_description.Width, _description.Height + margins.Bottom); + SizeToChildren(false, true); } } diff --git a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/DividerComponent.cs b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/DividerComponent.cs index 9891cd31ba..e1ff6d0516 100644 --- a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/DividerComponent.cs +++ b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/DividerComponent.cs @@ -1,11 +1,7 @@ -using Intersect.Client.Framework.Gwen.Control; +using Intersect.Client.Framework.Gwen.Control; namespace Intersect.Client.Interface.Game.DescriptionWindows.Components; -public partial class DividerComponent : ComponentBase +public partial class DividerComponent(Base parent, string name) : ComponentBase(parent, name) { - public DividerComponent(Base parent, string name) : base(parent, name) - { - GenerateComponents(); - } } diff --git a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/HeaderComponent.cs b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/HeaderComponent.cs index 0648ae4114..14096a5661 100644 --- a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/HeaderComponent.cs +++ b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/HeaderComponent.cs @@ -1,4 +1,4 @@ -using Intersect.Client.Framework.Gwen; +using Intersect.Client.Framework.Gwen; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.Control; @@ -6,30 +6,18 @@ namespace Intersect.Client.Interface.Game.DescriptionWindows.Components; public partial class HeaderComponent : ComponentBase { - protected ImagePanel mIconContainer; - - protected ImagePanel mIcon; - - protected Label mTitle; - - protected Label mSubtitle; - - protected Label mDescription; + private readonly ImagePanel _icon; + private readonly Label _title; + private readonly Label _subtitle; + private readonly Label _description; public HeaderComponent(Base parent, string name) : base(parent, name) { - GenerateComponents(); - } - - protected override void GenerateComponents() - { - base.GenerateComponents(); - - mIconContainer = new ImagePanel(mContainer, "IconContainer"); - mIcon = new ImagePanel(mIconContainer, "Icon"); - mTitle = new Label(mContainer, "Title"); - mSubtitle = new Label(mContainer, "Subtitle"); - mDescription = new Label(mContainer, "Description"); + var _iconContainer = new ImagePanel(this, "IconContainer"); + _icon = new ImagePanel(_iconContainer, "Icon"); + _title = new Label(this, "Title"); + _subtitle = new Label(this, "Subtitle"); + _description = new Label(this, "Description"); } /// @@ -39,10 +27,10 @@ protected override void GenerateComponents() /// The to use to display the texture. public void SetIcon(IGameTexture texture, Color color) { - mIcon.Texture = texture; - mIcon.RenderColor = color; - mIcon.SizeToContents(); - Align.Center(mIcon); + _icon.Texture = texture; + _icon.RenderColor = color; + _icon.SizeToContents(); + Align.Center(_icon); } /// @@ -52,8 +40,8 @@ public void SetIcon(IGameTexture texture, Color color) /// The to use to display this title. public void SetTitle(string title, Color color) { - mTitle.SetText(title); - mTitle.SetTextColor(color, ComponentState.Normal); + _title.SetText(title); + _title.SetTextColor(color, ComponentState.Normal); } /// @@ -63,8 +51,8 @@ public void SetTitle(string title, Color color) /// The to use to display this subtitle. public void SetSubtitle(string subtitle, Color color) { - mSubtitle.SetText(subtitle); - mSubtitle.SetTextColor(color, ComponentState.Normal); + _subtitle.SetText(subtitle); + _subtitle.SetTextColor(color, ComponentState.Normal); } /// @@ -74,7 +62,7 @@ public void SetSubtitle(string subtitle, Color color) /// The to use to display this description. public void SetDescription(string description, Color color) { - mDescription.SetText(description); - mDescription.SetTextColor(color, ComponentState.Normal); + _description.SetText(description); + _description.SetTextColor(color, ComponentState.Normal); } } \ No newline at end of file diff --git a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/KeyValueRowComponent.cs b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/KeyValueRowComponent.cs new file mode 100644 index 0000000000..d7a0e058c7 --- /dev/null +++ b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/KeyValueRowComponent.cs @@ -0,0 +1,31 @@ +using Intersect.Client.Framework.Gwen.Control; + +namespace Intersect.Client.Interface.Game.DescriptionWindows.Components; + +public partial class KeyValueRowComponent : ComponentBase +{ + private readonly Label _keyLabel; + private readonly Label _valueLabel; + + public KeyValueRowComponent(Base parent) : this(parent, string.Empty, string.Empty) + { + } + + public KeyValueRowComponent(Base parent, string key, string value) : base(parent, "KeyValueRow") + { + _keyLabel = new Label(this, "Key") { Text = key }; + _valueLabel = new Label(this, "Value") { Text = value }; + } + + /// + /// Set the of the key text. + /// + /// The to draw the key text in. + public void SetKeyTextColor(Color color) => _keyLabel.SetTextColor(color, ComponentState.Normal); + + /// + /// Set the of the value text. + /// + /// The to draw the value text in. + public void SetValueTextColor(Color color) => _valueLabel.SetTextColor(color, ComponentState.Normal); +} diff --git a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/RowContainerComponent.cs b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/RowContainerComponent.cs index 121f1206b4..42a1ba5643 100644 --- a/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/RowContainerComponent.cs +++ b/Intersect.Client.Core/Interface/Game/DescriptionWindows/Components/RowContainerComponent.cs @@ -1,56 +1,37 @@ -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using Intersect.Client.Framework.Gwen.Control; using Intersect.Core; using Microsoft.Extensions.Logging; +using Intersect.Client.Core; namespace Intersect.Client.Interface.Game.DescriptionWindows.Components; public partial class RowContainerComponent : ComponentBase { - protected KeyValueRowComponent mKeyValueRow; + private readonly JObject _keyValueRowLayout; - protected JObject KeyValueRowLayout; - - private int mComponentY = 0; + private int _componentY = 0; public RowContainerComponent(Base parent, string name) : base(parent, name) { - GenerateComponents(); - LoadLayout(); - GetLayoutTemplates(); - DestroyLayoutComponents(); - } - - protected override void GenerateComponents() - { - base.GenerateComponents(); - - mKeyValueRow = new KeyValueRowComponent(mContainer); - } - - private void GetLayoutTemplates() - { - KeyValueRowLayout = mKeyValueRow.GetJson(); - } - - private void DestroyLayoutComponents() - { - mKeyValueRow.Dispose(); + var _keyValueRow = new KeyValueRowComponent(this); + LoadJsonUi(Framework.File_Management.GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); + _keyValueRowLayout = _keyValueRow.GetJson() ?? throw new Exception($"Failed to load {nameof(KeyValueRowComponent)} layout for {Name}."); + RemoveChild(_keyValueRow, true); } private void PositionComponent(ComponentBase component) { - component.SetPosition(component.X, mComponentY); - mComponentY += component.Height; + component.SetPosition(component.X, _componentY); + _componentY += component.Height; } /// public override void CorrectWidth() { base.CorrectWidth(); - var margins = mContainer.Margin; - - mContainer.SetSize(mContainer.Width, mContainer.Height + margins.Bottom); + var margins = Margin; + SetSize(Width, Height + margins.Bottom); } /// @@ -61,16 +42,16 @@ public override void CorrectWidth() /// Returns a new instance of with the provided settings. public KeyValueRowComponent AddKeyValueRow(string key, string value) { - var row = new KeyValueRowComponent(mContainer, key, value); + var row = new KeyValueRowComponent(this, key, value); // Since we're pulling some trickery here, catch any errors doing this ourselves and log them. try { - row.LoadJson(KeyValueRowLayout); + row.LoadJson(_keyValueRowLayout); } catch (Exception ex) { - ApplicationContext.Context.Value?.Logger.LogError(ex, $"An error occured while loading {nameof(KeyValueRowComponent)} Json for {mName}"); + ApplicationContext.Context.Value?.Logger.LogError(ex, $"An error occured while loading {nameof(KeyValueRowComponent)} Json for {Name}"); } row.SizeToChildren(true, false); @@ -78,53 +59,3 @@ public KeyValueRowComponent AddKeyValueRow(string key, string value) return row; } } - -public partial class KeyValueRowComponent : ComponentBase -{ - protected Label mKeyLabel; - - protected Label mValueLabel; - - public KeyValueRowComponent(Base parent) : this(parent, string.Empty, string.Empty) - { - } - - public KeyValueRowComponent(Base parent, string key, string value) : base(parent, "KeyValueRow") - { - GenerateComponents(); - mKeyLabel.SetText(key); - mValueLabel.SetText(value); - } - - protected override void GenerateComponents() - { - base.GenerateComponents(); - - mKeyLabel = new Label(mContainer, "Key"); - mValueLabel = new Label(mContainer, "Value"); - } - - /// - /// Set the of the key text. - /// - /// The to draw the key text in. - public void SetKeyTextColor(Color color) => mKeyLabel.SetTextColor(color, ComponentState.Normal); - - /// - /// Set the of the value text. - /// - /// The to draw the value text in. - public void SetValueTextColor(Color color) => mValueLabel.SetTextColor(color, ComponentState.Normal); - - /// - /// Get the Json layout of the current component. - /// - /// Returns a containing the layout of the current component. - public JObject GetJson() => mContainer.GetJson(); - - /// - /// Set the Json layout of the current component. - /// - /// The new layout to apply to this component in format. - public void LoadJson(JObject json) => mContainer.LoadJson(json); -} diff --git a/Intersect.Client.Core/Interface/Game/DescriptionWindows/DescriptionWindowBase.cs b/Intersect.Client.Core/Interface/Game/DescriptionWindows/DescriptionWindowBase.cs index 4efca0fc6d..e3cac18002 100644 --- a/Intersect.Client.Core/Interface/Game/DescriptionWindows/DescriptionWindowBase.cs +++ b/Intersect.Client.Core/Interface/Game/DescriptionWindows/DescriptionWindowBase.cs @@ -1,4 +1,6 @@ +using Intersect.Client.Core; using Intersect.Client.Framework.Gwen.Control; +using Intersect.Client.Framework.Gwen.Control.EventArguments; using Intersect.Client.Framework.Gwen.Input; using Intersect.Client.Interface.Game.DescriptionWindows.Components; @@ -7,25 +9,24 @@ namespace Intersect.Client.Interface.Game.DescriptionWindows; public partial class DescriptionWindowBase : ComponentBase { // Track current Y height for placing components. - private int mComponentY = 0; + private int _componentY = 0; // Our internal list of components. - private List mComponents; + private readonly List _components = []; public DescriptionWindowBase(Base parent, string name) : base(parent, name) { - // Set up our internal component list we use for re-ordering. - mComponents = new List(); - - GenerateComponents(); + LoadJsonUi(Framework.File_Management.GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); } - protected override void GenerateComponents() + protected override void OnPreDraw(Framework.Gwen.Skin.Base skin) { - base.GenerateComponents(); + base.OnPreDraw(skin); - // Load layout prior to adding components so we can retrieve padding information. - LoadLayout(); + if (!IsOnTop) + { + BringToFront(); + } } /// @@ -36,12 +37,12 @@ protected override void GenerateComponents() /// Returns a new instance of the class public HeaderComponent AddHeader(string name = "DescriptionWindowHeader", bool loadLayout = true) { - var component = new HeaderComponent(mContainer, name); + var component = new HeaderComponent(this, name); if (loadLayout) { - component.LoadLayout(); + component.LoadJsonUi(Framework.File_Management.GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); } - mComponents.Add(component); + _components.Add(component); return component; } @@ -53,12 +54,12 @@ public HeaderComponent AddHeader(string name = "DescriptionWindowHeader", bool l /// Returns a new instance of the class public DividerComponent AddDivider(string name = "DescriptionWindowDivider", bool loadLayout = true) { - var component = new DividerComponent(mContainer, name); + var component = new DividerComponent(this, name); if (loadLayout) { - component.LoadLayout(); + component.LoadJsonUi(Framework.File_Management.GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); } - mComponents.Add(component); + _components.Add(component); return component; } @@ -70,12 +71,12 @@ public DividerComponent AddDivider(string name = "DescriptionWindowDivider", boo /// Returns a new instance of the class public DescriptionComponent AddDescription(string name = "DescriptionWindowDescription", bool loadLayout = true) { - var component = new DescriptionComponent(mContainer, name); + var component = new DescriptionComponent(this, name); if (loadLayout) { - component.LoadLayout(); + component.LoadJsonUi(Framework.File_Management.GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); } - mComponents.Add(component); + _components.Add(component); return component; } @@ -86,8 +87,8 @@ public DescriptionComponent AddDescription(string name = "DescriptionWindowDescr /// Returns a new instance of the class public RowContainerComponent AddRowContainer(string name = "DescriptionWindowRowContainer") { - var component = new RowContainerComponent(mContainer, name); - mComponents.Add(component); + var component = new RowContainerComponent(this, name); + _components.Add(component); return component; } @@ -102,8 +103,8 @@ private void PositionComponent(ComponentBase component) return; } - component.SetPosition(component.X, mComponentY); - mComponentY += component.Height; + component.SetPosition(component.X, _componentY); + _componentY += component.Height; } /// @@ -112,73 +113,55 @@ private void PositionComponent(ComponentBase component) protected void FinalizeWindow() { // Reset our componentY so we start from scratch! - mComponentY = 0; + _componentY = 0; // Correctly set our container width to the largest child start with, this way our other child components will have a width to work with. - mContainer.SizeToChildren(true, false); + SizeToChildren(true, false); // Resize and relocate our components to properly display on our window. - foreach (var component in mComponents) + foreach (var component in _components) { component.CorrectWidth(); PositionComponent(component); } // Correctly set our container height so we display everything. - mContainer.SizeToChildren(false, true); + SizeToChildren(false, true); } /// - public override void SetPosition(int x, int y, ImagePanel? itemDecriptionContainer = null) + public void PositionToHoveredControl() { - if (mContainer == null || mContainer.Canvas == null) + if (Canvas == default) { return; } - int newX, newY; - int HoveredControlX, HoveredControlY; - - // Bind description window to the HoveredControl position. - HoveredControlX = InputHandler.HoveredControl.ToCanvas(new Point(0, 0)).X; - HoveredControlY = InputHandler.HoveredControl.ToCanvas(new Point(0, 0)).Y; - newX = HoveredControlX + InputHandler.HoveredControl.Width; - newY = itemDecriptionContainer != null ? itemDecriptionContainer.Bottom : HoveredControlY + InputHandler.HoveredControl.Height; - - // Do not allow it to render outside of the screen canvas. - if (newX > mContainer.Canvas.Width - mContainer.Width) - { - newX = HoveredControlX - mContainer.Width; - } - - if (newY > mContainer.Canvas.Height - mContainer.Height) + if (InputHandler.HoveredControl == default) { - newY = itemDecriptionContainer != null ? itemDecriptionContainer.Y - mContainer.Height : HoveredControlY - mContainer.Height; + return; } - mContainer.MoveTo(newX, newY); - } - - public override void SetPosition(Base _icon, SpellDescriptionWindow _descriptionWindow) - { - var X = _icon.ToCanvas(new Point(0, 0)).X; - var Y = _icon.ToCanvas(new Point(0, 0)).Y; + int newX, newY; + var hoveredPos = InputHandler.HoveredControl.ToCanvas(new Point(0, 0)); + int HoveredControlX = hoveredPos.X; + int HoveredControlY = hoveredPos.Y; - X = X + _descriptionWindow.Width + _icon.Height; - Y = Y + _icon.Height; + // Bind description window to the right, bottom of HoveredControl. + newX = HoveredControlX + InputHandler.HoveredControl.Width; + newY = HoveredControlY + InputHandler.HoveredControl.Height; - // Do not allow it to render outside of the screen canvas while based on the _icon position. - // Prevents flickering when _icon is hovered near the edge of the screen. - if (X > Interface.GameUi.GameCanvas.Width - _descriptionWindow.Width) + // Do not allow it to render outside of the screen canvas. + if (newX > Canvas.Width - Width) { - X = X - _descriptionWindow.Width - _icon.Height; + newX = HoveredControlX - Width; } - if (Y > Interface.GameUi.GameCanvas.Height - _descriptionWindow.Height) + if (newY > Canvas.Height - Height) { - Y = Y - _descriptionWindow.Height - _icon.Height; + newY = HoveredControlY - Height; } - _descriptionWindow.SetPosition(X, Y); + MoveTo(newX, newY); } } diff --git a/Intersect.Client.Core/Interface/Game/DescriptionWindows/ItemDescriptionWindow.cs b/Intersect.Client.Core/Interface/Game/DescriptionWindows/ItemDescriptionWindow.cs index c0622bf1a2..504492a4ce 100644 --- a/Intersect.Client.Core/Interface/Game/DescriptionWindows/ItemDescriptionWindow.cs +++ b/Intersect.Client.Core/Interface/Game/DescriptionWindows/ItemDescriptionWindow.cs @@ -1,60 +1,109 @@ using Intersect.Enums; -using Intersect.GameObjects; using Intersect.Client.General; using Intersect.Client.Localization; using Intersect.Core; using Intersect.Framework.Core.GameObjects.Items; using Intersect.GameObjects.Ranges; -using Intersect.Network.Packets.Server; using Intersect.Utilities; using Microsoft.Extensions.Logging; +using Intersect.Client.Framework.File_Management; +using Intersect.Client.Framework.Gwen.Input; namespace Intersect.Client.Interface.Game.DescriptionWindows; -public partial class ItemDescriptionWindow : DescriptionWindowBase +public partial class ItemDescriptionWindow() : DescriptionWindowBase(Interface.GameUi.GameCanvas, "DescriptionWindow") { - protected ItemDescriptor mItem; + private ItemDescriptor? _itemDescriptor; + private ItemProperties? _itemProperties; + private int _amount; + private string? _valueLabel; - protected int mAmount; - - protected ItemProperties? mItemProperties; - - protected string mTitleOverride; - - protected string mValueLabel; - - protected SpellDescriptionWindow? mSpellDescWindow; - - public ItemDescriptionWindow( + public void Show( ItemDescriptor item, int amount, - int x, - int y, - ItemProperties? itemProperties, - string titleOverride = "", + ItemProperties? itemProperties = default, string valueLabel = "" - ) : base(Interface.GameUi.GameCanvas, "DescriptionWindow") + ) { - mItem = item; - mAmount = amount; - mItemProperties = itemProperties; - mTitleOverride = titleOverride; - mValueLabel = valueLabel; + _itemDescriptor = item; + _amount = amount; + _itemProperties = itemProperties; + _valueLabel = valueLabel; - GenerateComponents(); SetupDescriptionWindow(); - SetPosition(x, y); + PositionToHoveredControl(); // If a spell, also display the spell description! - if (mItem.ItemType == ItemType.Spell) + if (_itemDescriptor.ItemType == ItemType.Spell && _itemDescriptor.SpellId != Guid.Empty) { - mSpellDescWindow = new SpellDescriptionWindow(mItem.SpellId, x, y, mContainer); + if (Canvas == default || InputHandler.HoveredControl is not { } hoveredControl) + { + return; + } + + var spellDesc = Interface.GameUi.SpellDescriptionWindow; + spellDesc.Show(_itemDescriptor.SpellId); + + // we need to control the spell desc window position here + var hoveredPos = InputHandler.HoveredControl.ToCanvas(new Point(0, 0)); + var windowX = 0; + var windowY = Y; + + // if spell desc is out of screen + if (Y + spellDesc.Height > Canvas.Height) + { + windowY = Canvas.Height - spellDesc.Height; + } + + // let consider some situations + // item desc is on right side of hovered icon + if (X >= hoveredPos.X + hoveredControl.Width) + { + // lets try to put spell desc on left side of hovered icon + windowX = hoveredPos.X - spellDesc.Width; + + // ops, our spell desc is out of screen + if (windowX < 0) + { + windowX = X + Width; + } + } + else + { + // lets try to put spell desc on right side of hovered icon + windowX = hoveredPos.X + hoveredControl.Width; + + // ops, our spell desc is out of screen + if (windowX + spellDesc.Width > Canvas.Width) + { + windowX = X - spellDesc.Width; + } + } + + spellDesc.SetPosition(windowX, windowY); + } + + base.Show(); + } + + public override void Hide() + { + if (Interface.GameUi.ItemDescriptionWindow == this) + { + Interface.GameUi.GameCanvas.RemoveChild(Interface.GameUi.ItemDescriptionWindow, true); + Interface.GameUi.ItemDescriptionWindow = default; + } + + if (Interface.GameUi.SpellDescriptionWindow != default) + { + Interface.GameUi.GameCanvas.RemoveChild(Interface.GameUi.SpellDescriptionWindow, true); + Interface.GameUi.SpellDescriptionWindow = default; } } protected void SetupDescriptionWindow() { - if (mItem == null) + if (_itemDescriptor == default) { return; } @@ -66,13 +115,13 @@ protected void SetupDescriptionWindow() SetupItemLimits(); // if we have a description, set that up. - if (!string.IsNullOrWhiteSpace(mItem.Description)) + if (!string.IsNullOrWhiteSpace(_itemDescriptor.Description)) { SetupDescription(); } // Set up information depending on the item type. - switch (mItem.ItemType) + switch (_itemDescriptor.ItemType) { case ItemType.Equipment: SetupEquipmentInfo(); @@ -100,29 +149,33 @@ protected void SetupDescriptionWindow() protected void SetupHeader() { + if (_itemDescriptor == default) + { + return; + } + // Create our header, but do not load our layout yet since we're adding components manually. var header = AddHeader(); // Set up the icon, if we can load it. - var tex = Globals.ContentManager.GetTexture(Framework.Content.TextureType.Item, mItem.Icon); + var tex = GameContentManager.Current.GetTexture(Framework.Content.TextureType.Item, _itemDescriptor.Icon); if (tex != null) { - header.SetIcon(tex, mItem.Color); + header.SetIcon(tex, _itemDescriptor.Color); } // Set up the header as the item name. - CustomColors.Items.Rarities.TryGetValue(mItem.Rarity, out var rarityColor); - var name = !string.IsNullOrWhiteSpace(mTitleOverride) ? mTitleOverride : mItem.Name; - header.SetTitle(name, rarityColor ?? Color.White); + CustomColors.Items.Rarities.TryGetValue(_itemDescriptor.Rarity, out var rarityColor); + header.SetTitle(_itemDescriptor.Name, rarityColor ?? Color.White); // Set up the description telling us what type of item this is. // if equipment, also list what kind. - Strings.ItemDescription.ItemTypes.TryGetValue((int)mItem.ItemType, out var typeDesc); - if (mItem.ItemType == ItemType.Equipment) + Strings.ItemDescription.ItemTypes.TryGetValue((int)_itemDescriptor.ItemType, out var typeDesc); + if (_itemDescriptor.ItemType == ItemType.Equipment) { - var equipSlot = Options.Instance.Equipment.Slots[mItem.EquipmentSlot]; + var equipSlot = Options.Instance.Equipment.Slots[_itemDescriptor.EquipmentSlot]; var extraInfo = equipSlot; - if (mItem.EquipmentSlot == Options.Instance.Equipment.WeaponSlot && mItem.TwoHanded) + if (_itemDescriptor.EquipmentSlot == Options.Instance.Equipment.WeaponSlot && _itemDescriptor.TwoHanded) { extraInfo = $"{Strings.ItemDescription.TwoHand} {equipSlot}"; } @@ -136,7 +189,7 @@ protected void SetupHeader() // Set up the item rarity label. try { - if (Options.Instance.Items.TryGetRarityName(mItem.Rarity, out var rarityName)) + if (Options.Instance.Items.TryGetRarityName(_itemDescriptor.Rarity, out var rarityName)) { _ = Strings.ItemDescription.Rarity.TryGetValue(rarityName, out var rarityLabel); header.SetDescription(rarityLabel, rarityColor ?? Color.White); @@ -147,7 +200,7 @@ protected void SetupHeader() ApplicationContext.Context.Value?.Logger.LogError( exception, "Error setting rarity description for rarity {Rarity}", - mItem.Rarity + _itemDescriptor.Rarity ); throw; } @@ -157,29 +210,34 @@ protected void SetupHeader() protected void SetupItemLimits() { + if (_itemDescriptor == default) + { + return; + } + // Gather up what limitations apply to this item. var limits = new List(); - if (!mItem.CanBank) + if (!_itemDescriptor.CanBank) { limits.Add(Strings.ItemDescription.Banked); } - if (!mItem.CanGuildBank) + if (!_itemDescriptor.CanGuildBank) { limits.Add(Strings.ItemDescription.GuildBanked); } - if (!mItem.CanBag) + if (!_itemDescriptor.CanBag) { limits.Add(Strings.ItemDescription.Bagged); } - if (!mItem.CanTrade) + if (!_itemDescriptor.CanTrade) { limits.Add(Strings.ItemDescription.Traded); } - if (!mItem.CanDrop) + if (!_itemDescriptor.CanDrop) { limits.Add(Strings.ItemDescription.Dropped); } - if (!mItem.CanSell) + if (!_itemDescriptor.CanSell) { limits.Add(Strings.ItemDescription.Sold); } @@ -200,16 +258,31 @@ protected void SetupItemLimits() protected void SetupDescription() { + if (_itemDescriptor == default) + { + return; + } + // Add a divider. AddDivider(); // Add the actual description. var description = AddDescription(); - description.AddText(Strings.ItemDescription.Description.ToString(mItem.Description), Color.White); + description.AddText(Strings.ItemDescription.Description.ToString(_itemDescriptor.Description), Color.White); } protected void SetupEquipmentInfo() { + if (_itemDescriptor == default) + { + return; + } + + if (Globals.Me is not { } player) + { + return; + } + // Add a divider. AddDivider(); @@ -217,42 +290,42 @@ protected void SetupEquipmentInfo() var rows = AddRowContainer(); // Is this a weapon? - if (mItem.EquipmentSlot == Options.Instance.Equipment.WeaponSlot) + if (_itemDescriptor.EquipmentSlot == Options.Instance.Equipment.WeaponSlot) { // Base Damage: - rows.AddKeyValueRow(Strings.ItemDescription.BaseDamage, mItem.Damage.ToString()); + rows.AddKeyValueRow(Strings.ItemDescription.BaseDamage, _itemDescriptor.Damage.ToString()); // Damage Type: - Strings.ItemDescription.DamageTypes.TryGetValue(mItem.DamageType, out var damageType); + Strings.ItemDescription.DamageTypes.TryGetValue(_itemDescriptor.DamageType, out var damageType); rows.AddKeyValueRow(Strings.ItemDescription.BaseDamageType, damageType); - if (mItem.Scaling > 0) + if (_itemDescriptor.Scaling > 0) { - Strings.ItemDescription.Stats.TryGetValue(mItem.ScalingStat, out var stat); + Strings.ItemDescription.Stats.TryGetValue(_itemDescriptor.ScalingStat, out var stat); rows.AddKeyValueRow(Strings.ItemDescription.ScalingStat, stat); - rows.AddKeyValueRow(Strings.ItemDescription.ScalingPercentage, Strings.ItemDescription.Percentage.ToString(mItem.Scaling)); + rows.AddKeyValueRow(Strings.ItemDescription.ScalingPercentage, Strings.ItemDescription.Percentage.ToString(_itemDescriptor.Scaling)); } // Crit Chance - if (mItem.CritChance > 0) + if (_itemDescriptor.CritChance > 0) { - rows.AddKeyValueRow(Strings.ItemDescription.CritChance, Strings.ItemDescription.Percentage.ToString(mItem.CritChance)); - rows.AddKeyValueRow(Strings.ItemDescription.CritMultiplier, Strings.ItemDescription.Multiplier.ToString(mItem.CritMultiplier)); + rows.AddKeyValueRow(Strings.ItemDescription.CritChance, Strings.ItemDescription.Percentage.ToString(_itemDescriptor.CritChance)); + rows.AddKeyValueRow(Strings.ItemDescription.CritMultiplier, Strings.ItemDescription.Multiplier.ToString(_itemDescriptor.CritMultiplier)); } // Attack Speed // Are we supposed to change our attack time based on a modifier? - if (mItem.AttackSpeedModifier == 0) + if (_itemDescriptor.AttackSpeedModifier == 0) { // No modifier, assuming base attack rate? We have to calculate the speed stat manually here though..! - var speed = Globals.Me.Stat[(int)Stat.Speed]; + var speed = player.Stat[(int)Stat.Speed]; // Remove currently equipped weapon stats.. We want to create a fair display! - var weaponSlot = Globals.Me.MyEquipment[Options.Instance.Equipment.WeaponSlot]; + var weaponSlot = player.MyEquipment[Options.Instance.Equipment.WeaponSlot]; if (weaponSlot != -1) { - var randomStats = Globals.Me.Inventory[weaponSlot].ItemProperties.StatModifiers; - var weapon = ItemDescriptor.Get(Globals.Me.Inventory[weaponSlot].ItemId); + var randomStats = player.Inventory[weaponSlot].ItemProperties.StatModifiers; + var weapon = ItemDescriptor.Get(player.Inventory[weaponSlot].ItemId); if (weapon != null && randomStats != null) { speed = (int)Math.Round(speed / ((100 + weapon.PercentageStatsGiven[(int)Stat.Speed]) / 100f)); @@ -262,85 +335,85 @@ protected void SetupEquipmentInfo() } // Add current item's speed stats! - if (mItemProperties?.StatModifiers != default) + if (_itemProperties?.StatModifiers != default) { - speed += mItem.StatsGiven[(int)Stat.Speed]; - speed += mItemProperties.StatModifiers[(int)Stat.Speed]; - speed += (int)Math.Floor(speed * (mItem.PercentageStatsGiven[(int)Stat.Speed] / 100f)); + speed += _itemDescriptor.StatsGiven[(int)Stat.Speed]; + speed += _itemProperties.StatModifiers[(int)Stat.Speed]; + speed += (int)Math.Floor(speed * (_itemDescriptor.PercentageStatsGiven[(int)Stat.Speed] / 100f)); } // Display the actual speed this weapon would have based off of our calculated speed stat. - rows.AddKeyValueRow(Strings.ItemDescription.AttackSpeed, TimeSpan.FromMilliseconds(Globals.Me.CalculateAttackTime(speed)).WithSuffix()); + rows.AddKeyValueRow(Strings.ItemDescription.AttackSpeed, TimeSpan.FromMilliseconds(player.CalculateAttackTime(speed)).WithSuffix()); } - else if (mItem.AttackSpeedModifier == 1) + else if (_itemDescriptor.AttackSpeedModifier == 1) { // Static, so this weapon's attack speed. - rows.AddKeyValueRow(Strings.ItemDescription.AttackSpeed, TimeSpan.FromMilliseconds(mItem.AttackSpeedValue).WithSuffix()); + rows.AddKeyValueRow(Strings.ItemDescription.AttackSpeed, TimeSpan.FromMilliseconds(_itemDescriptor.AttackSpeedValue).WithSuffix()); } - else if (mItem.AttackSpeedModifier == 2) + else if (_itemDescriptor.AttackSpeedModifier == 2) { // Percentage based. - rows.AddKeyValueRow(Strings.ItemDescription.AttackSpeed, Strings.ItemDescription.Percentage.ToString(mItem.AttackSpeedValue)); + rows.AddKeyValueRow(Strings.ItemDescription.AttackSpeed, Strings.ItemDescription.Percentage.ToString(_itemDescriptor.AttackSpeedValue)); } } //Blocking options - if (mItem.EquipmentSlot == Options.Instance.Equipment.ShieldSlot) + if (_itemDescriptor.EquipmentSlot == Options.Instance.Equipment.ShieldSlot) { - if (mItem.BlockChance > 0) + if (_itemDescriptor.BlockChance > 0) { - rows.AddKeyValueRow(Strings.ItemDescription.BlockChance, Strings.ItemDescription.Percentage.ToString(mItem.BlockChance)); + rows.AddKeyValueRow(Strings.ItemDescription.BlockChance, Strings.ItemDescription.Percentage.ToString(_itemDescriptor.BlockChance)); } - if (mItem.BlockAmount > 0) + if (_itemDescriptor.BlockAmount > 0) { - rows.AddKeyValueRow(Strings.ItemDescription.BlockAmount, Strings.ItemDescription.Percentage.ToString(mItem.BlockAmount)); + rows.AddKeyValueRow(Strings.ItemDescription.BlockAmount, Strings.ItemDescription.Percentage.ToString(_itemDescriptor.BlockAmount)); } - if (mItem.BlockAbsorption > 0) + if (_itemDescriptor.BlockAbsorption > 0) { - rows.AddKeyValueRow(Strings.ItemDescription.BlockAbsorption, Strings.ItemDescription.Percentage.ToString(mItem.BlockAbsorption)); + rows.AddKeyValueRow(Strings.ItemDescription.BlockAbsorption, Strings.ItemDescription.Percentage.ToString(_itemDescriptor.BlockAbsorption)); } } // Vitals for (var i = 0; i < Enum.GetValues().Length; i++) { - if (mItem.VitalsGiven[i] != 0 && mItem.PercentageVitalsGiven[i] != 0) + if (_itemDescriptor.VitalsGiven[i] != 0 && _itemDescriptor.PercentageVitalsGiven[i] != 0) { - rows.AddKeyValueRow(Strings.ItemDescription.Vitals[i], Strings.ItemDescription.RegularAndPercentage.ToString(mItem.VitalsGiven[i], mItem.PercentageVitalsGiven[i])); + rows.AddKeyValueRow(Strings.ItemDescription.Vitals[i], Strings.ItemDescription.RegularAndPercentage.ToString(_itemDescriptor.VitalsGiven[i], _itemDescriptor.PercentageVitalsGiven[i])); } - else if (mItem.VitalsGiven[i] != 0) + else if (_itemDescriptor.VitalsGiven[i] != 0) { - rows.AddKeyValueRow(Strings.ItemDescription.Vitals[i], mItem.VitalsGiven[i].ToString()); + rows.AddKeyValueRow(Strings.ItemDescription.Vitals[i], _itemDescriptor.VitalsGiven[i].ToString()); } - else if (mItem.PercentageVitalsGiven[i] != 0) + else if (_itemDescriptor.PercentageVitalsGiven[i] != 0) { - rows.AddKeyValueRow(Strings.ItemDescription.Vitals[i], Strings.ItemDescription.Percentage.ToString(mItem.PercentageVitalsGiven[i])); + rows.AddKeyValueRow(Strings.ItemDescription.Vitals[i], Strings.ItemDescription.Percentage.ToString(_itemDescriptor.PercentageVitalsGiven[i])); } } // Vitals Regen for (var i = 0; i < Enum.GetValues().Length; i++) { - if (mItem.VitalsRegen[i] != 0) + if (_itemDescriptor.VitalsRegen[i] != 0) { - rows.AddKeyValueRow(Strings.ItemDescription.VitalsRegen[i], Strings.ItemDescription.Percentage.ToString(mItem.VitalsRegen[i])); + rows.AddKeyValueRow(Strings.ItemDescription.VitalsRegen[i], Strings.ItemDescription.Percentage.ToString(_itemDescriptor.VitalsRegen[i])); } } // Stats - var statModifiers = mItemProperties?.StatModifiers; + var statModifiers = _itemProperties?.StatModifiers; for (var statIndex = 0; statIndex < Enum.GetValues().Length; statIndex++) { var stat = (Stat)statIndex; // Do we have item properties, if so this is a finished item. Otherwise does this item not have growing stats? var statLabel = Strings.ItemDescription.StatCounts[statIndex]; ItemRange? rangeForStat = default; - var percentageGivenForStat = mItem.PercentageStatsGiven[statIndex]; - if (statModifiers != default || !mItem.TryGetRangeFor(stat, out rangeForStat) || rangeForStat.LowRange == rangeForStat.HighRange) + var percentageGivenForStat = _itemDescriptor.PercentageStatsGiven[statIndex]; + if (statModifiers != default || !_itemDescriptor.TryGetRangeFor(stat, out rangeForStat) || rangeForStat.LowRange == rangeForStat.HighRange) { - var flatValueGivenForStat = mItem.StatsGiven[statIndex]; + var flatValueGivenForStat = _itemDescriptor.StatsGiven[statIndex]; if (statModifiers != default) { flatValueGivenForStat += statModifiers[statIndex]; @@ -369,9 +442,9 @@ protected void SetupEquipmentInfo() } } // We do not have item properties and have growing stats! So don't display a finished stat but a range instead. - else if (mItem.TryGetRangeFor(stat, out var range)) + else if (_itemDescriptor.TryGetRangeFor(stat, out var range)) { - var statGiven = mItem.StatsGiven[statIndex]; + var statGiven = _itemDescriptor.StatsGiven[statIndex]; var percentageStatGiven = percentageGivenForStat; var statLow = statGiven + range.LowRange; var statHigh = statGiven + range.HighRange; @@ -391,7 +464,7 @@ protected void SetupEquipmentInfo() } // Bonus Effect - foreach (var effect in mItem.Effects) + foreach (var effect in _itemDescriptor.Effects) { if (effect.Type != ItemEffect.None && effect.Percentage != 0) { @@ -405,6 +478,11 @@ protected void SetupEquipmentInfo() protected void SetupConsumableInfo() { + if (_itemDescriptor == default) + { + return; + } + // Add a divider. AddDivider(); @@ -412,19 +490,19 @@ protected void SetupConsumableInfo() var rows = AddRowContainer(); // Consumable data. - if (mItem.Consumable != null) + if (_itemDescriptor.Consumable != null) { - if (mItem.Consumable.Value > 0 && mItem.Consumable.Percentage > 0) + if (_itemDescriptor.Consumable.Value > 0 && _itemDescriptor.Consumable.Percentage > 0) { - rows.AddKeyValueRow(Strings.ItemDescription.ConsumableTypes[(int)mItem.Consumable.Type], Strings.ItemDescription.RegularAndPercentage.ToString(mItem.Consumable.Value, mItem.Consumable.Percentage)); + rows.AddKeyValueRow(Strings.ItemDescription.ConsumableTypes[(int)_itemDescriptor.Consumable.Type], Strings.ItemDescription.RegularAndPercentage.ToString(_itemDescriptor.Consumable.Value, _itemDescriptor.Consumable.Percentage)); } - else if (mItem.Consumable.Value > 0) + else if (_itemDescriptor.Consumable.Value > 0) { - rows.AddKeyValueRow(Strings.ItemDescription.ConsumableTypes[(int)mItem.Consumable.Type], mItem.Consumable.Value.ToString()); + rows.AddKeyValueRow(Strings.ItemDescription.ConsumableTypes[(int)_itemDescriptor.Consumable.Type], _itemDescriptor.Consumable.Value.ToString()); } - else if (mItem.Consumable.Percentage > 0) + else if (_itemDescriptor.Consumable.Percentage > 0) { - rows.AddKeyValueRow(Strings.ItemDescription.ConsumableTypes[(int)mItem.Consumable.Type], Strings.ItemDescription.Percentage.ToString(mItem.Consumable.Percentage)); + rows.AddKeyValueRow(Strings.ItemDescription.ConsumableTypes[(int)_itemDescriptor.Consumable.Type], Strings.ItemDescription.Percentage.ToString(_itemDescriptor.Consumable.Percentage)); } } @@ -434,6 +512,11 @@ protected void SetupConsumableInfo() protected void SetupSpellInfo() { + if (_itemDescriptor == default) + { + return; + } + // Add a divider. AddDivider(); @@ -441,18 +524,18 @@ protected void SetupSpellInfo() var rows = AddRowContainer(); // Spell data. - if (mItem.Spell != null) + if (_itemDescriptor.Spell != null) { - if (mItem.QuickCast) + if (_itemDescriptor.QuickCast) { - rows.AddKeyValueRow(Strings.ItemDescription.CastSpell.ToString(mItem.Spell.Name), string.Empty); + rows.AddKeyValueRow(Strings.ItemDescription.CastSpell.ToString(_itemDescriptor.Spell.Name), string.Empty); } else { - rows.AddKeyValueRow(Strings.ItemDescription.TeachSpell.ToString(mItem.Spell.Name), string.Empty); + rows.AddKeyValueRow(Strings.ItemDescription.TeachSpell.ToString(_itemDescriptor.Spell.Name), string.Empty); } - if (mItem.SingleUse) + if (_itemDescriptor.SingleUse) { rows.AddKeyValueRow(Strings.ItemDescription.SingleUse, string.Empty); } @@ -464,6 +547,11 @@ protected void SetupSpellInfo() protected void SetupBagInfo() { + if (_itemDescriptor == default) + { + return; + } + // Add a divider. AddDivider(); @@ -471,7 +559,7 @@ protected void SetupBagInfo() var rows = AddRowContainer(); // Bag data. - rows.AddKeyValueRow(Strings.ItemDescription.BagSlots, mItem.SlotCount.ToString()); + rows.AddKeyValueRow(Strings.ItemDescription.BagSlots, _itemDescriptor.SlotCount.ToString()); // Resize and position the container. rows.SizeToChildren(true, true); @@ -479,25 +567,30 @@ protected void SetupBagInfo() protected void SetupExtraInfo() { + if (_itemDescriptor == default) + { + return; + } + // Our list of data to add, should we need to. var data = new List>(); // Display our amount, but only if we are stackable and have more than one. - if (mItem.IsStackable && mAmount > 1) + if (_itemDescriptor.IsStackable && _amount > 1) { - data.Add(new Tuple(Strings.ItemDescription.Amount, mAmount.ToString("N0").Replace(",", Strings.Numbers.Comma))); + data.Add(new Tuple(Strings.ItemDescription.Amount, _amount.ToString("N0").Replace(",", Strings.Numbers.Comma))); } // Display item drop chance if configured. - if (mItem.DropChanceOnDeath > 0) + if (_itemDescriptor.DropChanceOnDeath > 0) { - data.Add(new Tuple(Strings.ItemDescription.DropOnDeath, Strings.ItemDescription.Percentage.ToString(mItem.DropChanceOnDeath))); + data.Add(new Tuple(Strings.ItemDescription.DropOnDeath, Strings.ItemDescription.Percentage.ToString(_itemDescriptor.DropChanceOnDeath))); } // Display shop value if we have one. - if (!string.IsNullOrWhiteSpace(mValueLabel)) + if (!string.IsNullOrWhiteSpace(_valueLabel)) { - data.Add(new Tuple(mValueLabel, string.Empty)); + data.Add(new Tuple(_valueLabel, string.Empty)); } // Do we have any data to display? If so, generate the element and add the data to it. @@ -518,11 +611,4 @@ protected void SetupExtraInfo() rows.SizeToChildren(true, true); } } - - /// - public override void Dispose() - { - base.Dispose(); - mSpellDescWindow?.Dispose(); - } } diff --git a/Intersect.Client.Core/Interface/Game/DescriptionWindows/SpellDescriptionWindow.cs b/Intersect.Client.Core/Interface/Game/DescriptionWindows/SpellDescriptionWindow.cs index d5b8a01e3c..b94931bdc5 100644 --- a/Intersect.Client.Core/Interface/Game/DescriptionWindows/SpellDescriptionWindow.cs +++ b/Intersect.Client.Core/Interface/Game/DescriptionWindows/SpellDescriptionWindow.cs @@ -1,37 +1,45 @@ using Intersect.Enums; using Intersect.GameObjects; -using Intersect.Client.General; using Intersect.Client.Localization; using Intersect.Utilities; -using Intersect.Client.Framework.Gwen.Control; +using Intersect.Client.Framework.File_Management; namespace Intersect.Client.Interface.Game.DescriptionWindows; -public partial class SpellDescriptionWindow : DescriptionWindowBase +public partial class SpellDescriptionWindow() : DescriptionWindowBase(Interface.GameUi.GameCanvas, "DescriptionWindow") { - protected SpellDescriptor mSpell; + private SpellDescriptor? _spellDescriptor; - public SpellDescriptionWindow(Guid spellId, int x, int y, ImagePanel? itemDecriptionContainer = null) : base(Interface.GameUi.GameCanvas, "DescriptionWindow") + public void Show(Guid spellId, ItemDescriptionWindow? itemDecriptionContainer = default) { - mSpell = SpellDescriptor.Get(spellId); - - GenerateComponents(); + _spellDescriptor = SpellDescriptor.Get(spellId); SetupDescriptionWindow(); - SetPosition(x, y, itemDecriptionContainer); + + if (itemDecriptionContainer != default) + { + SetPosition(itemDecriptionContainer.X, itemDecriptionContainer.Y + itemDecriptionContainer.Height); + SetSize(itemDecriptionContainer.Width, itemDecriptionContainer.Height); + } + else + { + PositionToHoveredControl(); + } + + base.Show(); } - public SpellDescriptionWindow(Guid spellId, ImagePanel _statusIcon) : base(Interface.GameUi.GameCanvas, "DescriptionWindow") + public override void Hide() { - mSpell = SpellDescriptor.Get(spellId); - - GenerateComponents(); - SetupDescriptionWindow(); - SetPosition(_statusIcon, this); + if (Interface.GameUi.SpellDescriptionWindow == this) + { + Interface.GameUi.GameCanvas.RemoveChild(Interface.GameUi.SpellDescriptionWindow, true); + Interface.GameUi.SpellDescriptionWindow = default; + } } protected void SetupDescriptionWindow() { - if (mSpell == null) + if (_spellDescriptor == default) { return; } @@ -43,13 +51,13 @@ protected void SetupDescriptionWindow() SetupSpellInfo(); // if we have a description, set that up. - if (!string.IsNullOrWhiteSpace(mSpell.Description)) + if (!string.IsNullOrWhiteSpace(_spellDescriptor.Description)) { SetupDescription(); } // Set up information depending on the item type. - switch (mSpell.SpellType) + switch (_spellDescriptor.SpellType) { case SpellType.CombatSpell: case SpellType.WarpTo: @@ -70,34 +78,39 @@ protected void SetupDescriptionWindow() protected void SetupHeader() { + if (_spellDescriptor == default) + { + return; + } + // Create our header, but do not load our layout yet since we're adding components manually. var header = AddHeader(); // Set up the icon, if we can load it. - var tex = Globals.ContentManager.GetTexture(Framework.Content.TextureType.Spell, mSpell.Icon); + var tex = GameContentManager.Current.GetTexture(Framework.Content.TextureType.Spell, _spellDescriptor.Icon); if (tex != null) { header.SetIcon(tex, Color.White); } // Set up the header as the item name. - header.SetTitle(mSpell.Name, Color.White); + header.SetTitle(_spellDescriptor.Name, Color.White); // Set up the spell type description. - Strings.SpellDescription.SpellTypes.TryGetValue((int)mSpell.SpellType, out var spellType); + Strings.SpellDescription.SpellTypes.TryGetValue((int)_spellDescriptor.SpellType, out var spellType); header.SetSubtitle(spellType, Color.White); // Set up the spelldescription based on what kind of spell it is. - if (mSpell.SpellType == (int)SpellType.CombatSpell) + if (_spellDescriptor.SpellType == (int)SpellType.CombatSpell) { - if (mSpell.Combat.TargetType == SpellTargetType.Projectile) + if (_spellDescriptor.Combat.TargetType == SpellTargetType.Projectile) { - var proj = ProjectileDescriptor.Get(mSpell.Combat.ProjectileId); - header.SetDescription(Strings.SpellDescription.TargetTypes[(int)mSpell.Combat.TargetType].ToString(proj?.Range ?? 0, mSpell.Combat.HitRadius), Color.White); + var proj = ProjectileDescriptor.Get(_spellDescriptor.Combat.ProjectileId); + header.SetDescription(Strings.SpellDescription.TargetTypes[(int)_spellDescriptor.Combat.TargetType].ToString(proj?.Range ?? 0, _spellDescriptor.Combat.HitRadius), Color.White); } else { - header.SetDescription(Strings.SpellDescription.TargetTypes[(int)mSpell.Combat.TargetType].ToString(mSpell.Combat.CastRange, mSpell.Combat.HitRadius), Color.White); + header.SetDescription(Strings.SpellDescription.TargetTypes[(int)_spellDescriptor.Combat.TargetType].ToString(_spellDescriptor.Combat.CastRange, _spellDescriptor.Combat.HitRadius), Color.White); } } @@ -106,6 +119,11 @@ protected void SetupHeader() protected void SetupSpellInfo() { + if (_spellDescriptor == default) + { + return; + } + // Add a divider. AddDivider(); @@ -113,9 +131,9 @@ protected void SetupSpellInfo() var rows = AddRowContainer(); // Friendly / Non Friendly for combat spells. - if (mSpell.SpellType == SpellType.CombatSpell || mSpell.SpellType == SpellType.WarpTo) + if (_spellDescriptor.SpellType == SpellType.CombatSpell || _spellDescriptor.SpellType == SpellType.WarpTo) { - if (mSpell.Combat.Friendly) + if (_spellDescriptor.Combat.Friendly) { rows.AddKeyValueRow(Strings.SpellDescription.Friendly, string.Empty); } @@ -127,41 +145,41 @@ protected void SetupSpellInfo() // Add cast time var castTime = Strings.SpellDescription.Instant; - if (mSpell.CastDuration > 0) + if (_spellDescriptor.CastDuration > 0) { - castTime = TimeSpan.FromMilliseconds(mSpell.CastDuration).WithSuffix(); + castTime = TimeSpan.FromMilliseconds(_spellDescriptor.CastDuration).WithSuffix(); } rows.AddKeyValueRow(Strings.SpellDescription.CastTime, castTime); // Add Vital Costs for (var i = 0; i < Enum.GetValues().Length; i++) { - if (mSpell.VitalCost[i] != 0) + if (_spellDescriptor.VitalCost[i] != 0) { - rows.AddKeyValueRow(Strings.SpellDescription.VitalCosts[i], mSpell.VitalCost[i].ToString()); + rows.AddKeyValueRow(Strings.SpellDescription.VitalCosts[i], _spellDescriptor.VitalCost[i].ToString()); } } // Add Cooldown time - if (mSpell.CooldownDuration > 0) + if (_spellDescriptor.CooldownDuration > 0) { - rows.AddKeyValueRow(Strings.SpellDescription.Cooldown, TimeSpan.FromMilliseconds(mSpell.CooldownDuration).WithSuffix()); + rows.AddKeyValueRow(Strings.SpellDescription.Cooldown, TimeSpan.FromMilliseconds(_spellDescriptor.CooldownDuration).WithSuffix()); } // Add Cooldown Group - if (!string.IsNullOrWhiteSpace(mSpell.CooldownGroup)) + if (!string.IsNullOrWhiteSpace(_spellDescriptor.CooldownGroup)) { - rows.AddKeyValueRow(Strings.SpellDescription.CooldownGroup, mSpell.CooldownGroup); + rows.AddKeyValueRow(Strings.SpellDescription.CooldownGroup, _spellDescriptor.CooldownGroup); } // Ignores global cooldown if enabled? - if (Options.Instance.Combat.EnableGlobalCooldowns && mSpell.IgnoreGlobalCooldown) + if (Options.Instance.Combat.EnableGlobalCooldowns && _spellDescriptor.IgnoreGlobalCooldown) { rows.AddKeyValueRow(Strings.SpellDescription.IgnoreGlobalCooldown, string.Empty); } // Ignore cooldown reduction stat? - if (mSpell.IgnoreCooldownReduction) + if (_spellDescriptor.IgnoreCooldownReduction) { rows.AddKeyValueRow(Strings.SpellDescription.IgnoreCooldownReduction, string.Empty); } @@ -172,16 +190,26 @@ protected void SetupSpellInfo() protected void SetupDescription() { + if (_spellDescriptor == default) + { + return; + } + // Add a divider. AddDivider(); // Add the actual description. var description = AddDescription(); - description.AddText(Strings.ItemDescription.Description.ToString(mSpell.Description), Color.White); + description.AddText(Strings.ItemDescription.Description.ToString(_spellDescriptor.Description), Color.White); } protected void SetupCombatInfo() { + if (_spellDescriptor == default) + { + return; + } + // Add a divider. AddDivider(); @@ -194,34 +222,34 @@ protected void SetupCombatInfo() var isDamage = false; for (var i = 0; i < Enum.GetValues().Length; i++) { - if (mSpell.Combat.VitalDiff[i] < 0) + if (_spellDescriptor.Combat.VitalDiff[i] < 0) { - rows.AddKeyValueRow(Strings.SpellDescription.VitalRecovery[i], Math.Abs(mSpell.Combat.VitalDiff[i]).ToString()); + rows.AddKeyValueRow(Strings.SpellDescription.VitalRecovery[i], Math.Abs(_spellDescriptor.Combat.VitalDiff[i]).ToString()); isHeal = true; } - else if (mSpell.Combat.VitalDiff[i] > 0) + else if (_spellDescriptor.Combat.VitalDiff[i] > 0) { - rows.AddKeyValueRow(Strings.SpellDescription.VitalDamage[i], mSpell.Combat.VitalDiff[i].ToString()); + rows.AddKeyValueRow(Strings.SpellDescription.VitalDamage[i], _spellDescriptor.Combat.VitalDiff[i].ToString()); isDamage = true; } } // Damage Type: - Strings.SpellDescription.DamageTypes.TryGetValue(mSpell.Combat.DamageType, out var damageType); + Strings.SpellDescription.DamageTypes.TryGetValue(_spellDescriptor.Combat.DamageType, out var damageType); rows.AddKeyValueRow(Strings.SpellDescription.DamageType, damageType); - if (mSpell.Combat.Scaling > 0) + if (_spellDescriptor.Combat.Scaling > 0) { - Strings.SpellDescription.Stats.TryGetValue(mSpell.Combat.ScalingStat, out var stat); + Strings.SpellDescription.Stats.TryGetValue(_spellDescriptor.Combat.ScalingStat, out var stat); rows.AddKeyValueRow(Strings.SpellDescription.ScalingStat, stat); - rows.AddKeyValueRow(Strings.SpellDescription.ScalingPercentage, Strings.SpellDescription.Percentage.ToString(mSpell.Combat.Scaling)); + rows.AddKeyValueRow(Strings.SpellDescription.ScalingPercentage, Strings.SpellDescription.Percentage.ToString(_spellDescriptor.Combat.Scaling)); } // Crit Chance - if (mSpell.Combat.CritChance > 0) + if (_spellDescriptor.Combat.CritChance > 0) { - rows.AddKeyValueRow(Strings.SpellDescription.CritChance, Strings.SpellDescription.Percentage.ToString(mSpell.Combat.CritChance)); - rows.AddKeyValueRow(Strings.SpellDescription.CritMultiplier, Strings.SpellDescription.Multiplier.ToString(mSpell.Combat.CritMultiplier)); + rows.AddKeyValueRow(Strings.SpellDescription.CritChance, Strings.SpellDescription.Percentage.ToString(_spellDescriptor.Combat.CritChance)); + rows.AddKeyValueRow(Strings.SpellDescription.CritMultiplier, Strings.SpellDescription.Multiplier.ToString(_spellDescriptor.Combat.CritMultiplier)); } var showDuration = false; @@ -230,17 +258,17 @@ protected void SetupCombatInfo() for (var i = 0; i < Enum.GetValues().Length; i++) { Tuple data = null; - if (mSpell.Combat.StatDiff[i] != 0 && mSpell.Combat.PercentageStatDiff[i] != 0) + if (_spellDescriptor.Combat.StatDiff[i] != 0 && _spellDescriptor.Combat.PercentageStatDiff[i] != 0) { - data = new Tuple(Strings.SpellDescription.StatCounts[i], Strings.SpellDescription.RegularAndPercentage.ToString(mSpell.Combat.StatDiff[i], mSpell.Combat.PercentageStatDiff[i])); + data = new Tuple(Strings.SpellDescription.StatCounts[i], Strings.SpellDescription.RegularAndPercentage.ToString(_spellDescriptor.Combat.StatDiff[i], _spellDescriptor.Combat.PercentageStatDiff[i])); } - else if (mSpell.Combat.StatDiff[i] != 0) + else if (_spellDescriptor.Combat.StatDiff[i] != 0) { - data = new Tuple(Strings.SpellDescription.StatCounts[i], mSpell.Combat.StatDiff[i].ToString()); + data = new Tuple(Strings.SpellDescription.StatCounts[i], _spellDescriptor.Combat.StatDiff[i].ToString()); } - else if (mSpell.Combat.PercentageStatDiff[i] != 0) + else if (_spellDescriptor.Combat.PercentageStatDiff[i] != 0) { - data = new Tuple(Strings.SpellDescription.StatCounts[i], Strings.ItemDescription.Percentage.ToString(mSpell.Combat.PercentageStatDiff[i])); + data = new Tuple(Strings.SpellDescription.StatCounts[i], Strings.ItemDescription.Percentage.ToString(_spellDescriptor.Combat.PercentageStatDiff[i])); } // Make sure we only add a blank row the first time we add a stat row. @@ -259,7 +287,7 @@ protected void SetupCombatInfo() } // Handle HoT and DoT displays. - if (mSpell.Combat.HoTDoT) + if (_spellDescriptor.Combat.HoTDoT) { showDuration = true; rows.AddKeyValueRow(string.Empty, string.Empty); @@ -271,21 +299,21 @@ protected void SetupCombatInfo() { rows.AddKeyValueRow(Strings.SpellDescription.DoT, string.Empty); } - rows.AddKeyValueRow(Strings.SpellDescription.Tick, TimeSpan.FromMilliseconds(mSpell.Combat.HotDotInterval).WithSuffix()); + rows.AddKeyValueRow(Strings.SpellDescription.Tick, TimeSpan.FromMilliseconds(_spellDescriptor.Combat.HotDotInterval).WithSuffix()); } // Handle effect display. - if (mSpell.Combat.Effect != SpellEffect.None) + if (_spellDescriptor.Combat.Effect != SpellEffect.None) { showDuration = true; rows.AddKeyValueRow(string.Empty, string.Empty); - rows.AddKeyValueRow(Strings.SpellDescription.Effect, Strings.SpellDescription.Effects[(int)mSpell.Combat.Effect]); + rows.AddKeyValueRow(Strings.SpellDescription.Effect, Strings.SpellDescription.Effects[(int)_spellDescriptor.Combat.Effect]); } // Show Stat Buff / Effect / HoT / DoT duration. if (showDuration) { - rows.AddKeyValueRow(Strings.SpellDescription.Duration, TimeSpan.FromMilliseconds(mSpell.Combat.Duration).WithSuffix("0.#")); + rows.AddKeyValueRow(Strings.SpellDescription.Duration, TimeSpan.FromMilliseconds(_spellDescriptor.Combat.Duration).WithSuffix("0.#")); } // Resize and position the container. @@ -294,6 +322,11 @@ protected void SetupCombatInfo() protected void SetupDashInfo() { + if (_spellDescriptor == default) + { + return; + } + // Add a divider. AddDivider(); @@ -301,30 +334,30 @@ protected void SetupDashInfo() var rows = AddRowContainer(); // Dash Distance Information. - rows.AddKeyValueRow(Strings.SpellDescription.Distance, Strings.SpellDescription.Tiles.ToString(mSpell.Combat.CastRange)); + rows.AddKeyValueRow(Strings.SpellDescription.Distance, Strings.SpellDescription.Tiles.ToString(_spellDescriptor.Combat.CastRange)); // Ignore map blocks? - if (mSpell.Dash.IgnoreMapBlocks) + if (_spellDescriptor.Dash.IgnoreMapBlocks) { - rows.AddKeyValueRow(Strings.SpellDescription.IgnoreMapBlock, String.Empty); + rows.AddKeyValueRow(Strings.SpellDescription.IgnoreMapBlock, string.Empty); } // Ignore resource blocks? - if (mSpell.Dash.IgnoreActiveResources) + if (_spellDescriptor.Dash.IgnoreActiveResources) { - rows.AddKeyValueRow(Strings.SpellDescription.IgnoreResourceBlock, String.Empty); + rows.AddKeyValueRow(Strings.SpellDescription.IgnoreResourceBlock, string.Empty); } // Ignore inactive resource blocks? - if (mSpell.Dash.IgnoreInactiveResources) + if (_spellDescriptor.Dash.IgnoreInactiveResources) { - rows.AddKeyValueRow(Strings.SpellDescription.IgnoreConsumedResourceBlock, String.Empty); + rows.AddKeyValueRow(Strings.SpellDescription.IgnoreConsumedResourceBlock, string.Empty); } // Ignore Z-Dimension? - if (Options.Instance.Map.ZDimensionVisible && mSpell.Dash.IgnoreZDimensionAttributes) + if (Options.Instance.Map.ZDimensionVisible && _spellDescriptor.Dash.IgnoreZDimensionAttributes) { - rows.AddKeyValueRow(Strings.SpellDescription.IgnoreZDimension, String.Empty); + rows.AddKeyValueRow(Strings.SpellDescription.IgnoreZDimension, string.Empty); } // Resize and position the container. @@ -333,8 +366,13 @@ protected void SetupDashInfo() protected void SetupExtraInfo() { + if (_spellDescriptor == default) + { + return; + } + // Display only if this spell is bound. - if (mSpell.Bound) + if (_spellDescriptor.Bound) { // Add a divider. AddDivider(); diff --git a/Intersect.Client.Core/Interface/Game/EntityPanel/SpellStatus.cs b/Intersect.Client.Core/Interface/Game/EntityPanel/SpellStatus.cs index 54e8d3d977..32f2a33ecb 100644 --- a/Intersect.Client.Core/Interface/Game/EntityPanel/SpellStatus.cs +++ b/Intersect.Client.Core/Interface/Game/EntityPanel/SpellStatus.cs @@ -1,10 +1,9 @@ -using Intersect.Client.Core; +using Intersect.Client.Core; using Intersect.Client.Entities; using Intersect.Client.Framework.Entities; using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.Gwen.Control; using Intersect.Client.General; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.GameObjects; using Intersect.Utilities; using Label = Intersect.Client.Framework.Gwen.Control.Label; @@ -16,8 +15,6 @@ public partial class SpellStatus { private Guid _currentSpellId; - private SpellDescriptionWindow? _descriptionWindow; - private Label _durationLabel; private Status _status; @@ -43,25 +40,12 @@ public void Setup() public void pnl_HoverLeave(Base sender, EventArgs arguments) { - if (_descriptionWindow != null) - { - _descriptionWindow.Dispose(); - _descriptionWindow = null; - } + Interface.GameUi.SpellDescriptionWindow?.Hide(); } void pnl_HoverEnter(Base sender, EventArgs arguments) { - if (_descriptionWindow != null) - { - _descriptionWindow.Dispose(); - _descriptionWindow = null; - } - - var X = _statusIcon.ToCanvas(new Point(0, 0)).X; - var Y = _statusIcon.ToCanvas(new Point(0, 0)).Y; - - _descriptionWindow = new SpellDescriptionWindow(_status.SpellId, _statusIcon); + Interface.GameUi.SpellDescriptionWindow?.Show(_status.SpellId); } public void UpdateStatus(Status status) diff --git a/Intersect.Client.Core/Interface/Game/GameInterface.cs b/Intersect.Client.Core/Interface/Game/GameInterface.cs index 45ce04e1a5..274b425f04 100644 --- a/Intersect.Client.Core/Interface/Game/GameInterface.cs +++ b/Intersect.Client.Core/Interface/Game/GameInterface.cs @@ -5,6 +5,7 @@ using Intersect.Client.Interface.Game.Bank; using Intersect.Client.Interface.Game.Chat; using Intersect.Client.Interface.Game.Crafting; +using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Client.Interface.Game.EntityPanel; using Intersect.Client.Interface.Game.Hotbar; using Intersect.Client.Interface.Game.Inventory; @@ -20,10 +21,8 @@ namespace Intersect.Client.Interface.Game; - public partial class GameInterface : MutableInterface { - public bool FocusChat; public bool UnfocusChat; @@ -53,6 +52,10 @@ public partial class GameInterface : MutableInterface private SettingsWindow? _settingsWindow; + private ItemDescriptionWindow? _itemDescriptionWindow; + + private SpellDescriptionWindow? _spellDescriptionWindow; + private bool mShouldCloseBag; private bool _shouldCloseBank; @@ -128,6 +131,18 @@ public GameInterface(Canvas canvas) : base(canvas) public AnnouncementWindow AnnouncementWindow => _announcementWindow ??= new AnnouncementWindow(GameCanvas) { IsHidden = true }; + public ItemDescriptionWindow? ItemDescriptionWindow + { + get => _itemDescriptionWindow ??= new ItemDescriptionWindow(); + set => _itemDescriptionWindow = value; + } + + public SpellDescriptionWindow? SpellDescriptionWindow + { + get => _spellDescriptionWindow ??= new SpellDescriptionWindow(); + set => _spellDescriptionWindow = value; + } + public MenuContainer GameMenu { get; private set; } public void InitGameGui() @@ -612,5 +627,4 @@ public void Dispose() CloseTrading(); GameCanvas.Dispose(); } - } diff --git a/Intersect.Client.Core/Interface/Game/Hotbar/HotbarItem.cs b/Intersect.Client.Core/Interface/Game/Hotbar/HotbarItem.cs index 122e2a5a6d..1783f5fa6f 100644 --- a/Intersect.Client.Core/Interface/Game/Hotbar/HotbarItem.cs +++ b/Intersect.Client.Core/Interface/Game/Hotbar/HotbarItem.cs @@ -8,7 +8,6 @@ using Intersect.Client.Framework.Gwen.Input; using Intersect.Client.Framework.Input; using Intersect.Client.General; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Client.Items; using Intersect.Client.Localization; using Intersect.Client.Spells; @@ -34,10 +33,8 @@ public partial class HotbarItem : SlotItem private ControlBinding? _hotKey; private Item? _inventoryItem = null; private int _inventoryItemIndex = -1; - private ItemDescriptionWindow? _itemDescriptionWindow; private Label _quantityLabel; private Spell? _spellBookItem = null; - private SpellDescriptionWindow? _spellDescriptionWindow; private bool _textureLoaded; public HotbarItem(int hotbarSlotIndex, Base hotbarWindow) @@ -173,11 +170,7 @@ private void Icon_DoubleClicked(Base sender, MouseButtonState arguments) private void Icon_HoverLeave(Base sender, EventArgs arguments) { - _itemDescriptionWindow?.Dispose(); - _itemDescriptionWindow = null; - - _spellDescriptionWindow?.Dispose(); - _spellDescriptionWindow = null; + Interface.GameUi.ItemDescriptionWindow?.Hide(); } private void Icon_HoverEnter(Base sender, EventArgs arguments) @@ -194,9 +187,6 @@ private void Icon_HoverEnter(Base sender, EventArgs arguments) if (_currentItem != null && _inventoryItem != null) { - _itemDescriptionWindow?.Dispose(); - _itemDescriptionWindow = null; - var quantityOfItem = 1; if (_currentItem.IsStackable) @@ -204,19 +194,11 @@ private void Icon_HoverEnter(Base sender, EventArgs arguments) quantityOfItem = Globals.Me.GetQuantityOfItemInInventory(_currentItem.Id); } - _itemDescriptionWindow = new ItemDescriptionWindow( - _currentItem, quantityOfItem, _hotbarWindow.X + (_hotbarWindow.Width / 2), _hotbarWindow.Y + _hotbarWindow.Height + 2, - _inventoryItem.ItemProperties, _currentItem.Name, "" - ); + Interface.GameUi.ItemDescriptionWindow?.Show(_currentItem, quantityOfItem, _inventoryItem.ItemProperties); } else if (_currentSpell != null) { - _spellDescriptionWindow?.Dispose(); - _spellDescriptionWindow = null; - - _spellDescriptionWindow = new SpellDescriptionWindow( - _currentSpell.Id, _hotbarWindow.X + (_hotbarWindow.Width / 2), _hotbarWindow.Y + _hotbarWindow.Height + 2 - ); + Interface.GameUi.SpellDescriptionWindow?.Show(_currentSpell.Id); } } diff --git a/Intersect.Client.Core/Interface/Game/Inventory/InventoryItem.cs b/Intersect.Client.Core/Interface/Game/Inventory/InventoryItem.cs index 61e39b21a2..bfa5324fec 100644 --- a/Intersect.Client.Core/Interface/Game/Inventory/InventoryItem.cs +++ b/Intersect.Client.Core/Interface/Game/Inventory/InventoryItem.cs @@ -10,7 +10,6 @@ using Intersect.Client.General; using Intersect.Client.Interface.Game.Bag; using Intersect.Client.Interface.Game.Bank; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Client.Interface.Game.Hotbar; using Intersect.Client.Interface.Game.Shop; using Intersect.Client.Localization; @@ -30,7 +29,6 @@ public partial class InventoryItem : SlotItem private readonly Label _cooldownLabel; private readonly ImagePanel _equipImageBackground; private readonly InventoryWindow _inventoryWindow; - private ItemDescriptionWindow? _descriptionWindow; // Context Menu Handling private readonly MenuItem _useItemMenuItem; @@ -300,8 +298,7 @@ private void Icon_Clicked(Base sender, MouseButtonState arguments) private void Icon_HoverLeave(Base sender, EventArgs arguments) { - _descriptionWindow?.Dispose(); - _descriptionWindow = null; + Interface.GameUi.ItemDescriptionWindow?.Hide(); } void Icon_HoverEnter(Base? sender, EventArgs? arguments) @@ -316,12 +313,6 @@ void Icon_HoverEnter(Base? sender, EventArgs? arguments) return; } - if (_descriptionWindow != null) - { - _descriptionWindow.Dispose(); - _descriptionWindow = null; - } - if (Globals.Me?.Inventory[SlotIndex] is not { } inventorySlot) { return; @@ -335,13 +326,7 @@ void Icon_HoverEnter(Base? sender, EventArgs? arguments) if (Globals.GameShop == null) { - _descriptionWindow = new ItemDescriptionWindow( - inventorySlotDescriptor, - inventorySlot.Quantity, - _inventoryWindow.X, - _inventoryWindow.Y, - inventorySlot.ItemProperties - ); + Interface.GameUi.ItemDescriptionWindow?.Show(inventorySlotDescriptor, inventorySlot.Quantity, inventorySlot.ItemProperties); } else { @@ -363,41 +348,34 @@ void Icon_HoverEnter(Base? sender, EventArgs? arguments) return; } - _descriptionWindow = new ItemDescriptionWindow( + Interface.GameUi.ItemDescriptionWindow?.Show( inventorySlotDescriptor, inventorySlot.Quantity, - _inventoryWindow.X, - _inventoryWindow.Y, inventorySlot.ItemProperties, - "", Strings.Shop.SellsFor.ToString(shopItemDescriptor.CostItemQuantity, hoveredItem.Name) ); } else if (shopItemDescriptor == null) { var costItem = Globals.GameShop.DefaultCurrency; - if (inventorySlotDescriptor != null && costItem != null) + if (inventorySlotDescriptor == null || costItem == null) { - _descriptionWindow = new ItemDescriptionWindow( - inventorySlotDescriptor, - inventorySlot.Quantity, - _inventoryWindow.X, - _inventoryWindow.Y, - inventorySlot.ItemProperties, - "", - Strings.Shop.SellsFor.ToString(inventorySlotDescriptor.Price.ToString(), costItem.Name) - ); + return; } + + Interface.GameUi.ItemDescriptionWindow?.Show( + inventorySlotDescriptor, + inventorySlot.Quantity, + inventorySlot.ItemProperties, + Strings.Shop.SellsFor.ToString(inventorySlotDescriptor.Price.ToString(), costItem.Name) + ); } else { - _descriptionWindow = new ItemDescriptionWindow( + Interface.GameUi.ItemDescriptionWindow?.Show( inventorySlotDescriptor, inventorySlot.Quantity, - _inventoryWindow.X, - _inventoryWindow.Y, inventorySlot.ItemProperties, - "", Strings.Shop.WontBuy ); } @@ -564,13 +542,6 @@ public override void Update() Icon.IsVisibleInParent = false; } } - - if (_descriptionWindow != null) - { - _descriptionWindow.Dispose(); - _descriptionWindow = null; - Icon_HoverEnter(null, null); - } } private void _reset() @@ -581,7 +552,5 @@ private void _reset() _quantityLabel.IsVisibleInParent = false; _equipLabel.IsVisibleInParent = false; _cooldownLabel.IsVisibleInParent = false; - _descriptionWindow?.Dispose(); - _descriptionWindow = default; } } diff --git a/Intersect.Client.Core/Interface/Game/MapItem/MapItemIcon.cs b/Intersect.Client.Core/Interface/Game/MapItem/MapItemIcon.cs index 358a329d7d..8954a226c1 100644 --- a/Intersect.Client.Core/Interface/Game/MapItem/MapItemIcon.cs +++ b/Intersect.Client.Core/Interface/Game/MapItem/MapItemIcon.cs @@ -5,17 +5,13 @@ using Intersect.Client.Framework.Gwen.Input; using Intersect.Client.Framework.Input; using Intersect.Client.General; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Client.Items; using Intersect.Framework.Core.GameObjects.Items; -using Intersect.GameObjects; namespace Intersect.Client.Interface.Game.Inventory; - public partial class MapItemIcon { - public ImagePanel Container; public MapItemInstance? MyItem; @@ -28,8 +24,6 @@ public partial class MapItemIcon private MapItemWindow mMapItemWindow; - private ItemDescriptionWindow mDescWindow; - public MapItemIcon(MapItemWindow window) { mMapItemWindow = window; @@ -55,14 +49,10 @@ void pnl_Clicked(Base sender, MouseButtonState arguments) void pnl_HoverLeave(Base sender, EventArgs arguments) { - if (mDescWindow != null) - { - mDescWindow.Dispose(); - mDescWindow = null; - } + Interface.GameUi.ItemDescriptionWindow?.Hide(); } - void pnl_HoverEnter(Base sender, EventArgs arguments) + void pnl_HoverEnter(Base? sender, EventArgs? arguments) { if (MyItem == null) { @@ -79,15 +69,7 @@ void pnl_HoverEnter(Base sender, EventArgs arguments) return; } - if (mDescWindow != null) - { - mDescWindow.Dispose(); - mDescWindow = null; - } - mDescWindow = new ItemDescriptionWindow( - ItemDescriptor.Get(MyItem.ItemId), MyItem.Quantity, mMapItemWindow.X, - mMapItemWindow.Y, MyItem.ItemProperties - ); + Interface.GameUi.ItemDescriptionWindow?.Show(ItemDescriptor.Get(MyItem.ItemId), MyItem.Quantity, MyItem.ItemProperties); } public FloatRect RenderBounds() @@ -136,11 +118,6 @@ public void Update() } - if (mDescWindow != null) - { - mDescWindow.Dispose(); - mDescWindow = null; - pnl_HoverEnter(null, null); - } + pnl_HoverEnter(null, null); } } diff --git a/Intersect.Client.Core/Interface/Game/Shop/ShopItem.cs b/Intersect.Client.Core/Interface/Game/Shop/ShopItem.cs index 18332db7fe..f56ef18ef6 100644 --- a/Intersect.Client.Core/Interface/Game/Shop/ShopItem.cs +++ b/Intersect.Client.Core/Interface/Game/Shop/ShopItem.cs @@ -6,7 +6,6 @@ using Intersect.Client.Framework.Gwen.Input; using Intersect.Client.Framework.Input; using Intersect.Client.General; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Client.Interface.Game.Inventory; using Intersect.Client.Localization; using Intersect.Configuration; @@ -19,7 +18,6 @@ public partial class ShopItem : SlotItem private readonly int _mySlot; private readonly ShopWindow _shopWindow; private readonly MenuItem _buyMenuItem; - private ItemDescriptionWindow? _descriptionWindow; public ShopItem(ShopWindow shopWindow, Base parent, int index, ContextMenu contextMenu) : base(parent, nameof(ShopItem), index, contextMenu) @@ -55,12 +53,6 @@ private void Icon_HoverEnter(Base sender, EventArgs arguments) return; } - if (_descriptionWindow != default) - { - _descriptionWindow.Dispose(); - _descriptionWindow = default; - } - if (Globals.GameShop is not { SellingItems.Count: > 0 } gameShop) { return; @@ -78,24 +70,18 @@ private void Icon_HoverEnter(Base sender, EventArgs arguments) StatModifiers = item.StatsGiven, }; - _descriptionWindow = new ItemDescriptionWindow( - item: gameShop.SellingItems[_mySlot].Item, + Interface.GameUi.ItemDescriptionWindow?.Show( + gameShop.SellingItems[_mySlot].Item, amount: 1, - x: _shopWindow.X, - y: _shopWindow.Y, itemProperties: itemProperty, - valueLabel: Strings.Shop.Costs.ToString(gameShop.SellingItems[_mySlot].CostItemQuantity, item.Name) + Strings.Shop.Costs.ToString(gameShop.SellingItems[_mySlot].CostItemQuantity, item.Name) ); } } private void Icon_HoverLeave(Base sender, EventArgs arguments) { - if (_descriptionWindow != null) - { - _descriptionWindow.Dispose(); - _descriptionWindow = null; - } + Interface.GameUi.ItemDescriptionWindow?.Hide(); } private void Icon_RightClicked(Base sender, MouseButtonState arguments) diff --git a/Intersect.Client.Core/Interface/Game/Spells/SpellItem.cs b/Intersect.Client.Core/Interface/Game/Spells/SpellItem.cs index 65bb84869a..a10b3a6ebe 100644 --- a/Intersect.Client.Core/Interface/Game/Spells/SpellItem.cs +++ b/Intersect.Client.Core/Interface/Game/Spells/SpellItem.cs @@ -8,7 +8,6 @@ using Intersect.Client.Framework.Gwen.Input; using Intersect.Client.Framework.Input; using Intersect.Client.General; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Client.Interface.Game.Hotbar; using Intersect.Client.Localization; using Intersect.Configuration; @@ -22,7 +21,6 @@ public partial class SpellItem : SlotItem // Controls private readonly Label _cooldownLabel; private readonly SpellsWindow _spellWindow; - private SpellDescriptionWindow? _descriptionWindow; // Context Menu Handling private readonly MenuItem _useSpellMenuItem; @@ -118,21 +116,17 @@ private void Icon_HoverEnter(Base? sender, EventArgs? arguments) return; } - _descriptionWindow?.Dispose(); - _descriptionWindow = null; - if (Globals.Me?.Spells is not { Length: > 0 } spellSlots) { return; } - _descriptionWindow = new SpellDescriptionWindow(spellSlots[SlotIndex].Id, _spellWindow.X, _spellWindow.Y); + Interface.GameUi.SpellDescriptionWindow?.Show(spellSlots[SlotIndex].Id); } private void Icon_HoverLeave(Base sender, EventArgs arguments) { - _descriptionWindow?.Dispose(); - _descriptionWindow = null; + Interface.GameUi.SpellDescriptionWindow?.Hide(); } private void Icon_Clicked(Base sender, MouseButtonState arguments) @@ -242,9 +236,6 @@ public override void Update() Icon.IsVisibleInParent = false; } } - - _descriptionWindow?.Dispose(); - _descriptionWindow = null; } } } diff --git a/Intersect.Client.Core/Interface/Game/Trades/TradeItem.cs b/Intersect.Client.Core/Interface/Game/Trades/TradeItem.cs index f8908822fa..0384b263d9 100644 --- a/Intersect.Client.Core/Interface/Game/Trades/TradeItem.cs +++ b/Intersect.Client.Core/Interface/Game/Trades/TradeItem.cs @@ -4,7 +4,6 @@ using Intersect.Client.Framework.Gwen.Input; using Intersect.Client.Framework.Input; using Intersect.Client.General; -using Intersect.Client.Interface.Game.DescriptionWindows; using Intersect.Configuration; using Intersect.Framework.Core.GameObjects.Items; using Intersect.GameObjects; @@ -23,8 +22,6 @@ public partial class TradeItem private Guid mCurrentItemId; - private ItemDescriptionWindow mDescWindow; - private Draggable mDragIcon; //Mouse Event Variables @@ -102,11 +99,7 @@ void pnl_HoverLeave(Base sender, EventArgs arguments) mMouseOver = false; mMouseX = -1; mMouseY = -1; - if (mDescWindow != null) - { - mDescWindow.Dispose(); - mDescWindow = null; - } + Interface.GameUi.ItemDescriptionWindow?.Hide(); } void pnl_HoverEnter(Base sender, EventArgs arguments) @@ -118,19 +111,17 @@ void pnl_HoverEnter(Base sender, EventArgs arguments) mMouseOver = true; - if (mDescWindow != null) + if (Globals.Trade[mMySide, mMySlot] is not { } tradeItem) { - mDescWindow.Dispose(); - mDescWindow = null; + return; } - if (ItemDescriptor.Get(Globals.Trade[mMySide, mMySlot].ItemId) != null) + if (!ItemDescriptor.TryGet(Globals.Trade[mMySide, mMySlot].ItemId, out var descriptor)) { - mDescWindow = new ItemDescriptionWindow( - Globals.Trade[mMySide, mMySlot].Descriptor, Globals.Trade[mMySide, mMySlot].Quantity, mTradeWindow.X, - mTradeWindow.Y, Globals.Trade[mMySide, mMySlot].ItemProperties - ); + return; } + + Interface.GameUi.ItemDescriptionWindow?.Show(descriptor, tradeItem.Quantity, tradeItem.ItemProperties); } public FloatRect RenderBounds() diff --git a/Intersect.Client.Core/Interface/Interface.cs b/Intersect.Client.Core/Interface/Interface.cs index f19cf99607..c0de875afe 100644 --- a/Intersect.Client.Core/Interface/Interface.cs +++ b/Intersect.Client.Core/Interface/Interface.cs @@ -292,6 +292,14 @@ public static void DestroyGwen(bool exiting = false) _canvasMainMenu = null; _uiMainMenu = null; + // Destroy our target UI as well! Above code does NOT appear to clear this properly. + if (Globals.Me != null) + { + Globals.Me.ClearTarget(); + Globals.Me.TargetBox?.Dispose(); + Globals.Me.TargetBox = null; + } + if (_uiInGame is { } gameUi) { gameUi.Dispose(); @@ -304,14 +312,6 @@ public static void DestroyGwen(bool exiting = false) _canvasInGame = null; _uiInGame = null; - // Destroy our target UI as well! Above code does NOT appear to clear this properly. - if (Globals.Me != null) - { - Globals.Me.ClearTarget(); - Globals.Me.TargetBox?.Dispose(); - Globals.Me.TargetBox = null; - } - _initialized = false; } diff --git a/Intersect.Client.Framework/Gwen/Control/Base.cs b/Intersect.Client.Framework/Gwen/Control/Base.cs index a1efb19944..606782f476 100644 --- a/Intersect.Client.Framework/Gwen/Control/Base.cs +++ b/Intersect.Client.Framework/Gwen/Control/Base.cs @@ -2728,14 +2728,6 @@ public virtual void MoveTo(int x, int y, bool aligning = false) SetBounds(x, y, ownWidth, ownHeight); } - /// - /// Sets the control position based on ImagePanel - /// - public virtual void SetPosition(Base _icon) - { - SetPosition((int)_icon.ToCanvas(new Point(0, 0)).X, (int)_icon.ToCanvas(new Point(0, 0)).Y); - } - /// /// Sets the control position. ///