Skip to content

Commit

Permalink
Fix render order of inventory item name labels. Fix display of invent…
Browse files Browse the repository at this point in the history
…ory item background outside the bounds of the inventory grid.
  • Loading branch information
ethanmoffat committed Mar 28, 2022
1 parent e5b6c1b commit 5d01f6e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 10 additions & 7 deletions EndlessClient/HUD/Inventory/InventoryPanelItem.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions EndlessClient/HUD/Panels/InventoryPanel.cs
Expand Up @@ -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);
});
}
Expand Down

0 comments on commit 5d01f6e

Please sign in to comment.