Lucas Delanier 2 years ago
parent ab49c32f19
commit 4192e934ce

@ -11,6 +11,7 @@
<div class="slotSpace">
<h1>Inventory</h1>
<InventoryItem Index="0" />
<InventoryItem Index="1" />
<InventoryItem Index="2" />
<InventoryItem Index="3" />

@ -17,6 +17,8 @@ namespace BlazorApp.Components
public Item CurrentDragItem { get; set; }
public int CurrentDragItemIndex { get; set; }
[CascadingParameter]
public InventoryComponent Parent { get; set; }
public List<Item> RecipeItems { get; set; }

@ -25,7 +25,6 @@ h1 {
flex-wrap: wrap;
}
.css-inv {
grid-template-columns: repeat(6,minmax(0,1fr));
gap: 10px;

@ -11,7 +11,12 @@
{
<div style="position:relative">
<img src="data:image/png;base64, @(Item.ImageBase64)" title="@Item.DisplayName" alt="@Item.DisplayName" style="min-width: 64px; max-width: 64px" />
<p >@(Item.Num)</p>
@if (Item.Num > 0)
{
<div class="number">@(
Item.Num
)</div>
}
</div>
}
</div>

@ -15,6 +15,7 @@ namespace BlazorApp.Components
[Parameter]
public bool NoDrop { get; set; }
@ -43,17 +44,25 @@ namespace BlazorApp.Components
internal void OnDrop()
{
if (NoDrop)
if (NoDrop == true || Parent.CurrentDragItem == null)
{
return;
}
if(this.Item == null)
{
this.Item = Parent.CurrentDragItem;
this.Item = ItemFactory.Create(Parent.CurrentDragItem);
}
else if(this.Item.Id == Parent.CurrentDragItem.Id){
this.Item = Parent.CurrentDragItem;
this.Item.Num += 1;
if(this.Item.StackSize > this.Item.Num){
ItemFactory.Add1(this.Item, this.Item);
}
}
else if (this.Item.Id != Parent.CurrentDragItem.Id)
{
Item temp = ItemFactory.Create(this.Item);
this.Item = ItemFactory.Create(Parent.CurrentDragItem);
Parent.CurrentDragItem = ItemFactory.Create(temp);
}
@ -63,7 +72,9 @@ namespace BlazorApp.Components
private void OnDragStart()
{
Parent.CurrentDragItem = this.Item;
Parent.CurrentDragItemIndex = this.Index;
Parent.Actions.Add(new InventoryAction { Action = "Drag Start", Item = this.Item, Index = this.Index });
}

@ -7,4 +7,15 @@
background-color: rgba(139, 139, 139, 1);
box-shadow: inset 1.5px 1.5px 0px rgba(55, 55, 55, 0.8), inset -2px -2px 0px #ffffff;
}
.number {
font-family: 'VT323', monospace;
font-size: 24px;
color: #fefefe;
position: relative;
text-shadow: #333 1px 2px 1px;
top: -30px;
right: -40px;
cursor: default;
z-index: 20;
pointer-events: none;
}

@ -30,7 +30,8 @@ public static class ItemFactory
MaxDurability = model.MaxDurability,
StackSize = model.StackSize,
CreatedDate = DateTime.Now,
ImageBase64 = Convert.ToBase64String(model.ImageContent)
ImageBase64 = Convert.ToBase64String(model.ImageContent),
Num = 1
};
}
@ -45,4 +46,39 @@ public static class ItemFactory
item.UpdatedDate = DateTime.Now;
item.ImageBase64 = Convert.ToBase64String(model.ImageContent);
}
public static Item Create(Item model)
{
return new Item
{
Id = model.Id,
DisplayName = model.DisplayName,
Name = model.Name,
RepairWith = model.RepairWith,
EnchantCategories = model.EnchantCategories,
MaxDurability = model.MaxDurability,
StackSize = model.StackSize,
CreatedDate = DateTime.Now,
ImageBase64 = model.ImageBase64,
Num = 1,
};
}
public static void Update(Item item, Item model)
{
item.DisplayName = model.DisplayName;
item.Name = model.Name;
item.RepairWith = model.RepairWith;
item.EnchantCategories = model.EnchantCategories;
item.MaxDurability = model.MaxDurability;
item.StackSize = model.StackSize;
item.UpdatedDate = DateTime.Now;
item.ImageBase64 = model.ImageBase64;
item.Num = model.Num;
}
public static void Add1(Item item, Item model)
{
item.Num = model.Num + 1;
}
}

@ -12,7 +12,7 @@
public DateTime CreatedDate { get; set; }
public DateTime? UpdatedDate { get; set; }
public string ImageBase64 { get; set; }
public int Num = 1;
public int Num { get; set; }
}
}

@ -56,7 +56,6 @@ h1[b-hwopnmcvyc] {
flex-wrap: wrap;
}
.css-inv[b-hwopnmcvyc] {
grid-template-columns: repeat(6,minmax(0,1fr));
gap: 10px;
@ -92,7 +91,18 @@ h1[b-hwopnmcvyc] {
background-color: rgba(139, 139, 139, 1);
box-shadow: inset 1.5px 1.5px 0px rgba(55, 55, 55, 0.8), inset -2px -2px 0px #ffffff;
}
.number[b-qvaqnp1p6p] {
font-family: 'VT323', monospace;
font-size: 24px;
color: #fefefe;
position: relative;
text-shadow: #333 1px 2px 1px;
top: -30px;
right: -40px;
cursor: default;
z-index: 20;
pointer-events: none;
}
/* _content/BlazorApp/Shared/MainLayout.razor.rz.scp.css */
.page[b-3dsd3z3yec] {
position: relative;

@ -54,7 +54,6 @@ h1[b-hwopnmcvyc] {
flex-wrap: wrap;
}
.css-inv[b-hwopnmcvyc] {
grid-template-columns: repeat(6,minmax(0,1fr));
gap: 10px;
@ -90,7 +89,18 @@ h1[b-hwopnmcvyc] {
background-color: rgba(139, 139, 139, 1);
box-shadow: inset 1.5px 1.5px 0px rgba(55, 55, 55, 0.8), inset -2px -2px 0px #ffffff;
}
.number[b-qvaqnp1p6p] {
font-family: 'VT323', monospace;
font-size: 24px;
color: #fefefe;
position: relative;
text-shadow: #333 1px 2px 1px;
top: -30px;
right: -40px;
cursor: default;
z-index: 20;
pointer-events: none;
}
/* _content/BlazorApp/Shared/MainLayout.razor.rz.scp.css */
.page[b-3dsd3z3yec] {
position: relative;

@ -109,3 +109,48 @@
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0

Loading…
Cancel
Save