From 5d01f6e12adbece0d68459999531c065f9a516ce Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Sun, 27 Mar 2022 18:44:06 -0700 Subject: [PATCH] Fix render order of inventory item name labels. Fix display of inventory item background outside the bounds of the inventory grid. --- .../HUD/Inventory/InventoryPanelItem.cs | 17 ++++++++++------- EndlessClient/HUD/Panels/InventoryPanel.cs | 4 ++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/EndlessClient/HUD/Inventory/InventoryPanelItem.cs b/EndlessClient/HUD/Inventory/InventoryPanelItem.cs index 148333569..6c4d830f9 100644 --- a/EndlessClient/HUD/Inventory/InventoryPanelItem.cs +++ b/EndlessClient/HUD/Inventory/InventoryPanelItem.cs @@ -27,7 +27,7 @@ public class ItemDragCompletedEventArgs } // uses absolute coordinates - private static readonly Rectangle InventoryGridArea = new Rectangle(110, 334, 377, 116); + private static readonly Rectangle InventoryGridArea = new Rectangle(114, 338, 363, 102); private readonly InventoryPanel _inventoryPanel; private readonly Texture2D _itemGraphic; @@ -214,13 +214,16 @@ protected override void OnDrawControl(GameTime gameTime) if (MouseOver) { - // slot based on current mouse position if being dragged - var currentSlot = GetCurrentSlotBasedOnPosition(); - var drawPosition = GetPosition(currentSlot) + (_beingDragged ? _oldOffset : ImmediateParent.DrawPositionWithParentOffset); - - if (InventoryGridArea.Contains(drawPosition)) + if (!_beingDragged || InventoryGridArea.Contains(CurrentMouseState.Position)) { - _spriteBatch.Draw(_highlightBackground, DrawArea.WithPosition(drawPosition), Color.White); + // slot based on current mouse position if being dragged + var currentSlot = GetCurrentSlotBasedOnPosition(); + var drawPosition = GetPosition(currentSlot) + (_beingDragged ? _oldOffset : ImmediateParent.DrawPositionWithParentOffset); + + if (InventoryGridArea.Contains(DrawArea.WithPosition(drawPosition))) + { + _spriteBatch.Draw(_highlightBackground, DrawArea.WithPosition(drawPosition), Color.White); + } } } diff --git a/EndlessClient/HUD/Panels/InventoryPanel.cs b/EndlessClient/HUD/Panels/InventoryPanel.cs index e551861f1..b867bce02 100644 --- a/EndlessClient/HUD/Panels/InventoryPanel.cs +++ b/EndlessClient/HUD/Panels/InventoryPanel.cs @@ -195,6 +195,10 @@ protected override void OnUpdateControl(GameTime gameTime) newItem.DoubleClick += HandleItemDoubleClick; newItem.DoneDragging += HandleItemDoneDragging; + // side-effect of calling newItem.SetParentControl(this) is that the draw order gets reset + // setting the slot manually here resets it so the item labels render appropriately + newItem.Slot = slot; + _childItems.Add(newItem); }); }