diff --git a/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs b/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs index e63b4b749..6ccfbc19c 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs @@ -95,18 +95,15 @@ namespace Barotrauma int rectWidth = 40, rectHeight = 40; - Rectangle slotRect = new Rectangle(0, 0, rectWidth, rectHeight); for (int i = 0; i < capacity; i++) { - if (slots[i] == null) slots[i] = new InventorySlot(slotRect); - - slots[i].Disabled = false; - - slotRect.X = (int)(SlotPositions[i].X + DrawOffset.X); - slotRect.Y = (int)(SlotPositions[i].Y + DrawOffset.Y); - - slots[i].Rect = slotRect; + Rectangle slotRect = new Rectangle( + (int)(SlotPositions[i].X + DrawOffset.X), + (int)(SlotPositions[i].Y + DrawOffset.Y), + rectWidth, rectHeight); + slots[i] = new InventorySlot(slotRect); + slots[i].Disabled = false; slots[i].Color = limbSlots[i] == InvSlotType.Any ? Color.White * 0.2f : Color.White * 0.4f; } @@ -182,7 +179,7 @@ namespace Barotrauma if (rootContainer != null) { rootInventory = rootContainer.ParentInventory != null ? - rootContainer.ParentInventory : rootContainer.GetComponent().Inventory; + rootContainer.ParentInventory : rootContainer.GetComponent().Inventory; } if (rootInventory != null && @@ -209,6 +206,7 @@ namespace Barotrauma if (Items[n] == Items[i]) { slots[i].Rect = Rectangle.Union(slots[i].Rect, slots[n].Rect); + slots[i].InteractRect = Rectangle.Union(slots[i].InteractRect, slots[n].InteractRect); slots[n].Disabled = true; } } diff --git a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs index 41779cf36..bdde02fa6 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs @@ -10,6 +10,8 @@ namespace Barotrauma { public Rectangle Rect; + public Rectangle InteractRect; + public bool Disabled; public GUIComponent.ComponentState State; @@ -30,6 +32,8 @@ namespace Barotrauma public InventorySlot(Rectangle rect) { Rect = rect; + InteractRect = rect; + InteractRect.Inflate(5, 5); State = GUIComponent.ComponentState.None; Color = Color.White * 0.4f; } @@ -151,7 +155,7 @@ namespace Barotrauma if (draggingItem != null && - (draggingSlot == null || (!draggingSlot.Rect.Contains(PlayerInput.MousePosition) && draggingItem.ParentInventory == this))) + (draggingSlot == null || (!draggingSlot.InteractRect.Contains(PlayerInput.MousePosition) && draggingItem.ParentInventory == this))) { if (!PlayerInput.LeftButtonHeld()) { @@ -166,7 +170,7 @@ namespace Barotrauma protected void UpdateSlot(InventorySlot slot, int slotIndex, Item item, bool isSubSlot) { - bool mouseOn = slot.Rect.Contains(PlayerInput.MousePosition) && !Locked; + bool mouseOn = slot.InteractRect.Contains(PlayerInput.MousePosition) && !Locked; slot.State = GUIComponent.ComponentState.None; @@ -268,7 +272,7 @@ namespace Barotrauma } if (draggingItem != null && - (draggingSlot == null || (!draggingSlot.Rect.Contains(PlayerInput.MousePosition) && draggingItem.ParentInventory == this))) + (draggingSlot == null || (!draggingSlot.InteractRect.Contains(PlayerInput.MousePosition) && draggingItem.ParentInventory == this))) { Rectangle dragRect = new Rectangle( (int)PlayerInput.MousePosition.X - 10,