Skip to content

Commit e885719

Browse files
committed
add buy item when dragging from shop to inventory
1 parent f54e409 commit e885719

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

Intersect.Client.Core/Interface/Game/Draggable.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ namespace Intersect.Client.Interface.Game;
66

77
public partial class Draggable(Base parent, string name) : ImagePanel(parent, name)
88
{
9-
public bool DisableDragAndDrop { get; set; } = false;
10-
119
public bool IsDragging => DragAndDrop.CurrentPackage?.DrawControl == this;
1210

1311
public override bool DragAndDrop_Draggable()
@@ -17,11 +15,6 @@ public override bool DragAndDrop_Draggable()
1715

1816
public override Package DragAndDrop_GetPackage(int x, int y)
1917
{
20-
if (DisableDragAndDrop)
21-
{
22-
return null;
23-
}
24-
2518
return new Package()
2619
{
2720
IsDraggable = true,

Intersect.Client.Core/Interface/Game/Shop/ShopItem.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
using Intersect.Client.Framework.File_Management;
33
using Intersect.Client.Framework.Gwen.Control;
44
using Intersect.Client.Framework.Gwen.Control.EventArguments;
5+
using Intersect.Client.Framework.Gwen.DragDrop;
56
using Intersect.Client.Framework.Gwen.Input;
67
using Intersect.Client.Framework.Input;
78
using Intersect.Client.General;
89
using Intersect.Client.Interface.Game.DescriptionWindows;
10+
using Intersect.Client.Interface.Game.Inventory;
911
using Intersect.Client.Localization;
1012
using Intersect.Configuration;
1113
using Intersect.Framework.Core.GameObjects.Items;
@@ -30,7 +32,6 @@ public ShopItem(ShopWindow shopWindow, Base parent, int index, ContextMenu conte
3032
Icon.HoverLeave += Icon_HoverLeave;
3133
Icon.Clicked += Icon_RightClicked;
3234
Icon.DoubleClicked += Icon_DoubleClicked;
33-
Icon.DisableDragAndDrop = true;
3435

3536
LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
3637

@@ -161,4 +162,25 @@ public void LoadItem()
161162
Icon.RenderColor = itemDescriptor.Color;
162163
}
163164
}
165+
166+
public override bool DragAndDrop_HandleDrop(Package p, int x, int y)
167+
{
168+
var targetNode = Interface.FindComponentUnderCursor();
169+
170+
// Find the first parent acceptable in that tree that can accept the package
171+
while (targetNode != default)
172+
{
173+
if (targetNode is not InventoryWindow)
174+
{
175+
targetNode = targetNode.Parent;
176+
continue;
177+
}
178+
179+
Globals.Me?.TryBuyItem(_mySlot);
180+
return true;
181+
}
182+
183+
// If we've reached the top of the tree, we can't drop here, so cancel drop
184+
return false;
185+
}
164186
}

0 commit comments

Comments
 (0)