Compare commits

..

No commits in common. '4eb910d939d011c5cb8cdbdc697f4a77d02270d4' and '43066e729aa4be9a12b70fc355912386b8716d9d' have entirely different histories.

@ -125,10 +125,9 @@ namespace Minecraft.Crafting.Api.Controllers
throw new Exception("Unable to get the inventory."); throw new Exception("Unable to get the inventory.");
} }
data.ToArray()[Int32.Parse(infos[1]) - 1].ItemName = infos[0]; data.ToArray()[Int32.Parse(infos[1])-1].ItemName = infos[0];
data.ToArray()[Int32.Parse(infos[1]) - 1].Position = Int32.Parse(infos[1]); data.ToArray()[Int32.Parse(infos[1])-1].Position = Int32.Parse(infos[1]);
data.ToArray()[Int32.Parse(infos[1]) - 1].Number = Int32.Parse(infos[2]); data.ToArray()[Int32.Parse(infos[1])-1].Number = Int32.Parse(infos[2]);
data.ToArray()[Int32.Parse(infos[1]) - 1].StackSize = Int32.Parse(infos[3]);
System.IO.File.WriteAllText("Data/inventory.json", JsonSerializer.Serialize(data, _jsonSerializerOptions)); System.IO.File.WriteAllText("Data/inventory.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));

@ -4,16 +4,12 @@
"position": 1 "position": 1
}, },
{ {
"itemName": "lili", "itemName": "null",
"position": 2, "position": 2
"number": 11,
"stackSize": 64
}, },
{ {
"itemName": "lulu", "itemName": "null",
"position": 3, "position": 3
"number": 11,
"stackSize": 12
}, },
{ {
"itemName": "null", "itemName": "null",

@ -22,7 +22,5 @@ namespace Minecraft.Crafting.Api.Models
public int Position { get; set; } public int Position { get; set; }
public int Number { get; set; } public int Number { get; set; }
public int StackSize { get; set; }
} }
} }

@ -8,7 +8,6 @@ namespace myBlazorApp.Components
public int Index { get; set; } public int Index { get; set; }
public string ItemName { get; set; } public string ItemName { get; set; }
public int Number { get; set; } public int Number { get; set; }
public int StackSize { get; set; }
} }
} }

@ -9,13 +9,12 @@
@ondragleave="@OnDragLeave"> @ondragleave="@OnDragLeave">
@if (Item != "null") @if (Item != "null")
{ {
<label id="name">@Item</label> <p>@Item</p>
<label id="number">@Number</label> <p>@Number</p>
<label id="stackSize">@StackSize</label>
} }
else else
{ {
<p id="vide">Empty</p> <p>Empty</p>
} }
</div> </div>

@ -17,9 +17,6 @@ public partial class InventoryItem
[Parameter] [Parameter]
public int Number { get; set; } public int Number { get; set; }
[Parameter]
public int StackSize { get; set; }
[Parameter] [Parameter]
public bool NoDrop { get; set; } public bool NoDrop { get; set; }
@ -32,7 +29,7 @@ public partial class InventoryItem
{ {
return; return;
} }
Parent.Actions.Add(new InventoryAction { Action = "Drag Enter", ItemName = this.Item, Index = this.Index, Number = this.Number, StackSize = this.StackSize }); Parent.Actions.Add(new InventoryAction { Action = "Drag Enter", ItemName = this.Item, Index = this.Index, Number = this.Number });
} }
internal void OnDragLeave() internal void OnDragLeave()
@ -41,7 +38,7 @@ public partial class InventoryItem
{ {
return; return;
} }
Parent.Actions.Add(new InventoryAction { Action = "Drag Leave", ItemName = this.Item, Index = this.Index, Number = this.Number, StackSize = this.StackSize }); Parent.Actions.Add(new InventoryAction { Action = "Drag Leave", ItemName = this.Item, Index = this.Index, Number = this.Number });
} }
internal void OnDrop() internal void OnDrop()
@ -57,26 +54,22 @@ public partial class InventoryItem
this.Number = this.Number + Parent.CurrentDragNumber; this.Number = this.Number + Parent.CurrentDragNumber;
Parent.CurrentInventoryItem.Number = 0; Parent.CurrentInventoryItem.Number = 0;
Parent.CurrentInventoryItem.Item = "null"; Parent.CurrentInventoryItem.Item = "null";
Parent.CurrentInventoryItem.StackSize = 0; Parent.ItemsInventory[Parent.CurrentInventoryItem.Index-1] = new InventoryListItem(Parent.CurrentInventoryItem.Item, Parent.CurrentInventoryItem.Index, Parent.CurrentInventoryItem.Number);
Parent.ItemsInventory[Parent.CurrentInventoryItem.Index-1] = new InventoryListItem(Parent.CurrentInventoryItem.Item, Parent.CurrentInventoryItem.Index, Parent.CurrentInventoryItem.Number, Parent.CurrentInventoryItem.StackSize); Parent.Actions.Add(new InventoryAction { Action = "End", ItemName = Parent.CurrentInventoryItem.Item, Index = Parent.CurrentInventoryItem.Index, Number = Parent.CurrentInventoryItem.Number });
Parent.Actions.Add(new InventoryAction { Action = "End", ItemName = Parent.CurrentInventoryItem.Item, Index = Parent.CurrentInventoryItem.Index, Number = Parent.CurrentInventoryItem.Number, StackSize = Parent.CurrentInventoryItem.StackSize });
} }
else else
{ {
string tmpItem = this.Item; string tmpItem = this.Item;
int tmpNumber = this.Number; int tmpNumber = this.Number;
int tmpStackSize = this.StackSize; Parent.ItemsInventory[Parent.CurrentDragIndex-1] = new InventoryListItem(tmpItem, Parent.CurrentDragIndex, tmpNumber);
Parent.ItemsInventory[Parent.CurrentDragIndex-1] = new InventoryListItem(tmpItem, Parent.CurrentDragIndex, tmpNumber, tmpStackSize);
this.Item = Parent.CurrentDragItem; this.Item = Parent.CurrentDragItem;
this.Number = Parent.CurrentDragNumber; this.Number = Parent.CurrentDragNumber;
this.StackSize = Parent.CurrentDragStackSize;
Parent.CurrentInventoryItem.Item = tmpItem; Parent.CurrentInventoryItem.Item = tmpItem;
Parent.CurrentInventoryItem.Number = tmpNumber; Parent.CurrentInventoryItem.Number = tmpNumber;
Parent.CurrentInventoryItem.StackSize = tmpStackSize;
} }
} }
Parent.Actions.Add(new InventoryAction { Action = "Drop", ItemName = this.Item, Index = this.Index, Number = this.Number, StackSize = this.StackSize }); Parent.Actions.Add(new InventoryAction { Action = "Drop", ItemName = this.Item, Index = this.Index, Number = this.Number });
} }
internal void OnDragEnd() internal void OnDragEnd()
@ -87,16 +80,14 @@ public partial class InventoryItem
} }
if (Parent.CurrentDragIndex != -1 && Parent.CurrentDragIndex != this.Index) if (Parent.CurrentDragIndex != -1 && Parent.CurrentDragIndex != this.Index)
{ {
Parent.ItemsInventory[this.Index-1] = new InventoryListItem(Parent.CurrentDragItem, Parent.CurrentDragIndex, Parent.CurrentDragNumber, Parent.CurrentDragStackSize); Parent.ItemsInventory[this.Index-1] = new InventoryListItem(Parent.CurrentDragItem, Parent.CurrentDragIndex, Parent.CurrentDragNumber);
this.Item = Parent.CurrentDragItem; this.Item = Parent.CurrentDragItem;
this.Number = Parent.CurrentDragNumber; this.Number = Parent.CurrentDragNumber;
this.StackSize = Parent.CurrentDragStackSize;
} }
Parent.CurrentDragIndex = -1; Parent.CurrentDragIndex = -1;
Parent.CurrentDragItem = "null"; Parent.CurrentDragItem = "null";
Parent.CurrentDragNumber = 0; Parent.CurrentDragNumber = 0;
Parent.CurrentDragStackSize = 0; Parent.Actions.Add(new InventoryAction { Action = "End", ItemName = this.Item, Index = this.Index, Number = this.Number });
Parent.Actions.Add(new InventoryAction { Action = "End", ItemName = this.Item, Index = this.Index, Number = this.Number, StackSize = this.StackSize });
} }
@ -106,11 +97,9 @@ public partial class InventoryItem
Parent.CurrentDragIndex = this.Index; Parent.CurrentDragIndex = this.Index;
Parent.CurrentDragItem = this.Item; Parent.CurrentDragItem = this.Item;
Parent.CurrentDragNumber = this.Number; Parent.CurrentDragNumber = this.Number;
Parent.CurrentDragStackSize = this.StackSize;
this.Item = "null"; this.Item = "null";
this.Number = 0; this.Number = 0;
this.StackSize = 0; Parent.Actions.Add(new InventoryAction { Action = "Drag Start", ItemName = this.Item, Index = this.Index, Number = this.Number});
Parent.Actions.Add(new InventoryAction { Action = "Drag Start", ItemName = this.Item, Index = this.Index, Number = this.Number, StackSize = this.StackSize});
} }
} }

@ -1,26 +1,7 @@
.inventory-item { .inventory-item {
display:flex;
flex-direction:column;
width: 64px; width: 64px;
height: 64px; height: 64px;
border: 1px solid; border: 1px solid;
overflow: hidden; overflow: hidden;
align-content:center; align-content:center
}
#name {
text-align: center;
}
#number {
text-align: center;
}
#stackSize {
font-weight:lighter;
text-align:right;
margin-top:-5px;
margin-right:2px;
}
#vide {
align-self:center;
margin-top:20px;
} }

@ -6,18 +6,16 @@ namespace myBlazorApp.Components
{ {
//public InventoryListItem() { } //public InventoryListItem() { }
public InventoryListItem(string itemName, int position, int number, int stackSize) public InventoryListItem(string itemName, int position, int number)
{ {
this.itemName = itemName; this.itemName = itemName;
this.position = position; this.position = position;
this.number = number; this.number = number;
this.stackSize = stackSize;
} }
public string itemName { get; set; } public string itemName { get; set; }
public int position { get; set; } public int position { get; set; }
public int number { get; set; } public int number { get; set; }
public int stackSize { get; set; }
} }
} }

@ -5,7 +5,7 @@
<div class="inventory-items"> <div class="inventory-items">
@foreach(InventoryListItem i in ItemsInventory) @foreach(InventoryListItem i in ItemsInventory)
{ {
<InventoryItem Index="@i.position" Item="@i.itemName" Number="@i.number" StackSize="@i.stackSize" /> <InventoryItem Index="@i.position" Item="@i.itemName" Number="@i.number" />
} }
</div> </div>

@ -19,7 +19,6 @@ namespace myBlazorApp.Components
public string CurrentDragItem { get; set; } public string CurrentDragItem { get; set; }
public int CurrentDragIndex { get; set; } public int CurrentDragIndex { get; set; }
public int CurrentDragNumber { get; set; } public int CurrentDragNumber { get; set; }
public int CurrentDragStackSize { get; set; }
public InventoryItem CurrentInventoryItem {get; set;} = new InventoryItem(); public InventoryItem CurrentInventoryItem {get; set;} = new InventoryItem();
public MyInventory() public MyInventory()
@ -46,7 +45,7 @@ namespace myBlazorApp.Components
JavaScriptRuntime.InvokeVoidAsync("MyInventory.AddActions", e.NewItems); JavaScriptRuntime.InvokeVoidAsync("MyInventory.AddActions", e.NewItems);
if (this.Actions.Last().Action == "End" || this.Actions.Last().Action == "Drop" || this.Actions.Last().Action == "Start") if (this.Actions.Last().Action == "End" || this.Actions.Last().Action == "Drop" || this.Actions.Last().Action == "Start")
{ {
string[] infos = new string[] { this.Actions.Last().ItemName, this.Actions.Last().Index.ToString(), this.Actions.Last().Number.ToString(), this.Actions.Last().StackSize.ToString() }; string[] infos = new string[] { this.Actions.Last().ItemName, this.Actions.Last().Index.ToString(), this.Actions.Last().Number.ToString() };
await DataService.UpdateInventory(infos); await DataService.UpdateInventory(infos);
} }
} }

Loading…
Cancel
Save