Skip to content

Commit c361198

Browse files
committed
visually functional bags when moving items around
Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
1 parent c68a947 commit c361198

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Intersect.Client.Core/Interface/Game/Bag/BagItem.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ public partial class BagItem : SlotItem
1919
{
2020
// Controls
2121
private readonly Label _quantityLabel;
22-
private readonly BagWindow _bagWindow;
2322

2423
// Context Menu Handling
2524
private readonly MenuItem _withdrawContextItem;
2625

27-
public BagItem(BagWindow bagWindow, Base parent, int index, ContextMenu contextMenu)
26+
public BagItem(Base parent, int index, ContextMenu contextMenu)
2827
: base(parent, nameof(BagItem), index, contextMenu)
2928
{
30-
_bagWindow = bagWindow;
3129
TextureFilename = "bagitem.png";
3230

3331
Icon.HoverEnter += Icon_HoverEnter;
@@ -145,6 +143,16 @@ private void Icon_DoubleClicked(Base sender, MouseButtonState arguments)
145143

146144
public override bool DragAndDrop_HandleDrop(Package package, int x, int y)
147145
{
146+
if (Globals.Me is not { } player)
147+
{
148+
return false;
149+
}
150+
151+
if (Globals.BagSlots is not { Length: > 0 } bagSlots)
152+
{
153+
return false;
154+
}
155+
148156
var targetNode = Interface.FindComponentUnderCursor();
149157

150158
// Find the first parent acceptable in that tree that can accept the package
@@ -154,11 +162,11 @@ public override bool DragAndDrop_HandleDrop(Package package, int x, int y)
154162
{
155163
case BagItem bagItem:
156164
PacketSender.SendMoveBagItems(SlotIndex, bagItem.SlotIndex);
157-
return true;
165+
return bagSlots[bagItem.SlotIndex] is not { Quantity: > 0 };
158166

159167
case InventoryItem inventoryItem:
160-
Globals.Me?.TryRetrieveItemFromBag(SlotIndex, inventoryItem.SlotIndex);
161-
return true;
168+
player.TryRetrieveItemFromBag(SlotIndex, inventoryItem.SlotIndex);
169+
return bagSlots[inventoryItem.SlotIndex] is not { Quantity: > 0 };
162170

163171
default:
164172
targetNode = targetNode.Parent;

Intersect.Client.Core/Interface/Game/Bag/BagWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private void InitItemContainer()
5858

5959
for (var slotIndex = 0; slotIndex < bagSlots.Length; slotIndex++)
6060
{
61-
Items.Add(new BagItem(this, _slotContainer, slotIndex, _contextMenu));
61+
Items.Add(new BagItem(_slotContainer, slotIndex, _contextMenu));
6262
}
6363

6464
PopulateSlotContainer.Populate(_slotContainer, Items);

0 commit comments

Comments
 (0)