Skip to content

Commit 62e3ebb

Browse files
committed
refactor the core of system with correct data/type
1 parent e885719 commit 62e3ebb

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ public partial class Draggable(Base parent, string name) : ImagePanel(parent, na
88
{
99
public bool IsDragging => DragAndDrop.CurrentPackage?.DrawControl == this;
1010

11+
// TODO: Fix drag and drop names
1112
public override bool DragAndDrop_Draggable()
1213
{
1314
return true;
1415
}
1516

16-
public override Package DragAndDrop_GetPackage(int x, int y)
17+
public override bool DragAndDrop_CanAcceptPackage(Package package)
18+
{
19+
return true;
20+
}
21+
22+
public override Package? DragAndDrop_GetPackage(int x, int y)
1723
{
1824
return new Package()
1925
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void LoadItem()
163163
}
164164
}
165165

166-
public override bool DragAndDrop_HandleDrop(Package p, int x, int y)
166+
public override bool DragAndDrop_HandleDrop(Package package, int x, int y)
167167
{
168168
var targetNode = Interface.FindComponentUnderCursor();
169169

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Intersect.Client.Framework.Gwen;
22
using Intersect.Client.Framework.Gwen.Control;
3+
using Intersect.Client.Framework.Gwen.DragDrop;
34

45
namespace Intersect.Client.Interface.Game;
56

@@ -42,6 +43,11 @@ public void OpenContextMenu()
4243
OnContextMenuOpening(contextMenu);
4344
}
4445

46+
public override bool DragAndDrop_CanAcceptPackage(Package package)
47+
{
48+
return true;
49+
}
50+
4551
protected virtual void OnContextMenuOpening(ContextMenu contextMenu)
4652
{
4753
// Display our menu... If we have anything to display.

Intersect.Client.Core/Interface/Game/Spells/SpellItem.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ private void Icon_DoubleClicked(Base sender, MouseButtonState arguments)
161161

162162
public override bool DragAndDrop_HandleDrop(Package package, int x, int y)
163163
{
164+
if (Globals.Me is not { } player)
165+
{
166+
return false;
167+
}
168+
164169
var targetNode = Interface.FindComponentUnderCursor();
165170

166171
// Find the first parent acceptable in that tree that can accept the package
@@ -169,11 +174,11 @@ public override bool DragAndDrop_HandleDrop(Package package, int x, int y)
169174
switch (targetNode)
170175
{
171176
case SpellItem spellItem:
172-
Globals.Me?.SwapSpells(SlotIndex, spellItem.SlotIndex);
177+
player.SwapSpells(SlotIndex, spellItem.SlotIndex);
173178
return true;
174179

175180
case HotbarItem hotbarItem:
176-
Globals.Me?.AddToHotbar(hotbarItem.SlotIndex, 1, SlotIndex);
181+
player.AddToHotbar(hotbarItem.SlotIndex, 1, SlotIndex);
177182
return true;
178183

179184
default:

Intersect.Client.Framework/Gwen/Control/Base.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4258,7 +4258,7 @@ public virtual void UpdateCursor()
42584258
}
42594259

42604260
// giver
4261-
public virtual Package DragAndDrop_GetPackage(int x, int y)
4261+
public virtual Package? DragAndDrop_GetPackage(int x, int y)
42624262
{
42634263
return _dragPayload;
42644264
}
@@ -4330,7 +4330,7 @@ public virtual void DragAndDrop_Hover(Package p, int x, int y)
43304330
// receiver
43314331
public virtual bool DragAndDrop_CanAcceptPackage(Package p)
43324332
{
4333-
return true;
4333+
return false;
43344334
}
43354335

43364336
public record struct SizeToChildrenArgs(

0 commit comments

Comments
 (0)