Skip to content

Commit f65d760

Browse files
unify items (#2634)
* unify "items" files under SlotItem class * created PopulateSlotContainer * making items having 1 context menu shared between all items * initialize menu context on construtor
1 parent 79ae52e commit f65d760

File tree

8 files changed

+171
-153
lines changed

8 files changed

+171
-153
lines changed

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

+11-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Intersect.Client.Framework.Input;
66
using Intersect.Client.General;
77
using Intersect.Client.Interface.Game.DescriptionWindows;
8+
using Intersect.Client.Interface.Game.Inventory;
89
using Intersect.Client.Networking;
910
using Intersect.Configuration;
1011
using Intersect.Framework.Core;
@@ -280,15 +281,20 @@ public void Update()
280281
{
281282
for (var i = 0; i < Options.Instance.Player.MaxInventory; i++)
282283
{
283-
if (invWindow.Items[i].RenderBounds().IntersectsWith(dragRect))
284+
if(invWindow.Items[i] is not InventoryItem inventoryItem)
284285
{
285-
if (FloatRect.Intersect(invWindow.Items[i].RenderBounds(), dragRect).Width *
286-
FloatRect.Intersect(invWindow.Items[i].RenderBounds(), dragRect).Height >
286+
continue;
287+
}
288+
289+
if (inventoryItem.RenderBounds().IntersectsWith(dragRect))
290+
{
291+
if (FloatRect.Intersect(inventoryItem.RenderBounds(), dragRect).Width *
292+
FloatRect.Intersect(inventoryItem.RenderBounds(), dragRect).Height >
287293
bestIntersect)
288294
{
289295
bestIntersect =
290-
FloatRect.Intersect(invWindow.Items[i].RenderBounds(), dragRect).Width *
291-
FloatRect.Intersect(invWindow.Items[i].RenderBounds(), dragRect).Height;
296+
FloatRect.Intersect(inventoryItem.RenderBounds(), dragRect).Width *
297+
FloatRect.Intersect(inventoryItem.RenderBounds(), dragRect).Height;
292298

293299
bestIntersectIndex = i;
294300
}

Intersect.Client.Core/Interface/Game/Bank/BankItem.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Intersect.Client.General;
77
using Intersect.Client.Interface.Game.Chat;
88
using Intersect.Client.Interface.Game.DescriptionWindows;
9+
using Intersect.Client.Interface.Game.Inventory;
910
using Intersect.Client.Localization;
1011
using Intersect.Client.Networking;
1112
using Intersect.Configuration;
@@ -330,7 +331,11 @@ public void Update()
330331
);
331332
for (var inventoryIndex = 0; inventoryIndex < inventorySlotLimit; inventoryIndex++)
332333
{
333-
var inventorySlotComponent = inventorySlots[inventoryIndex];
334+
if (inventorySlots[inventoryIndex] is not InventoryItem inventorySlotComponent)
335+
{
336+
continue;
337+
}
338+
334339
var inventorySlotRenderBounds = inventorySlotComponent.RenderBounds();
335340
if (!inventorySlotRenderBounds.IntersectsWith(dragRect))
336341
{

0 commit comments

Comments
 (0)