+ @if(Items != null)
{
- @if(!string.IsNullOrWhiteSpace(items.item.ImageBase64))
+ @if(!string.IsNullOrWhiteSpace(Items.item.ImageBase64))
{
-
)
+
)
}
else
{
-

+

}
}
else
diff --git a/Blazor/Blazor/Components/ItemInventory.razor.cs b/Blazor/Blazor/Components/ItemInventory.razor.cs
index c1ad38e..e7e80e2 100644
--- a/Blazor/Blazor/Components/ItemInventory.razor.cs
+++ b/Blazor/Blazor/Components/ItemInventory.razor.cs
@@ -1,4 +1,5 @@
using Blazor.Models;
+using Blazorise.Extensions;
using Microsoft.AspNetCore.Components;
namespace Blazor.Components
@@ -6,9 +7,65 @@ namespace Blazor.Components
public partial class ItemInventory
{
[Parameter]
- public InventoryItem items { get; set; }
+ public bool NoDrop { get; set; }
[Parameter]
- public int index { get; set; }
+ public InventoryItem Items { get; set; }
+
+ [Parameter]
+ public int Index { get; set; }
+
+ [CascadingParameter]
+ public Inventory Parent { get; set; }
+
+ public void OnDragStart()
+ {
+ if(!NoDrop)
+ {
+ return;
+ }
+ Parent.CurrentDragItem = this.Items;
+ Parent.inventory.inventoryItems[Index] = null;
+ Parent.update();
+ }
+
+
+ public void OnDrop()
+ {
+ if (!NoDrop)
+ {
+ this.Items = Parent.CurrentDragItem;
+ NoDrop = true;
+ }
+
+ if (Parent.CurrentDragItem != this.Items)
+ {
+ InventoryItem tmp = Parent.CurrentDragItem;
+ Parent.CurrentDragItem = this.Items;
+ this.Items = tmp;
+ }
+ else
+ {
+ int total = Parent.CurrentDragItem.Stack + this.Items.Stack;
+ if (total >this.Items.item.StackSize)
+ {
+ this.Items.Stack = this.Items.item.StackSize;
+ Parent.CurrentDragItem.Stack=total - this.Items.item.StackSize;
+ }
+ else
+ {
+ this.Items.Stack = total;
+ }
+ }
+ }
+ internal void OnDragEnter()
+ {
+ Parent.Actions.Add(new InventoryAction { Action = "Drag Enter", Item = this, Index = this.Index });
+ }
+
+ internal void OnDragLeave()
+ {
+ Parent.Actions.Add(new InventoryAction { Action = "Drag Leave", Item = this, Index = this.Index });
+ }
}
}
diff --git a/Blazor/Blazor/Pages/_Layout.cshtml b/Blazor/Blazor/Pages/_Layout.cshtml
index 1fdfc6e..f647c5b 100644
--- a/Blazor/Blazor/Pages/_Layout.cshtml
+++ b/Blazor/Blazor/Pages/_Layout.cshtml
@@ -8,6 +8,7 @@
@*
*@
+