From bb24abb013296183bcedf1bcad6685543619df85 Mon Sep 17 00:00:00 2001 From: Lou VALADE Date: Mon, 12 Dec 2022 11:57:35 +0100 Subject: [PATCH] =?UTF-8?q?Ajoute=20la=20traduction=20de=20la=20page=20Inv?= =?UTF-8?q?entory=20et=20le=20d=C3=A9but=20de=20l'empilage=20des=20items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/InventoryComponent.razor | 13 ++++++------- .../Components/InventoryComponent.razor.cs | 5 +++++ BlazorApp1/Components/InventoryItem.razor | 6 ++++-- BlazorApp1/Components/InventoryItem.razor.cs | 19 +++++++++++++++++-- BlazorApp1/Components/InventoryItem.razor.css | 4 ++++ BlazorApp1/Pages/Inventory.razor | 3 ++- BlazorApp1/Pages/Inventory.razor.cs | 4 ++++ .../Resources/Pages.Inventory.fr-FR.resx | 12 ++++++++++++ BlazorApp1/Resources/Pages.Inventory.resx | 12 ++++++++++++ 9 files changed, 66 insertions(+), 12 deletions(-) diff --git a/BlazorApp1/Components/InventoryComponent.razor b/BlazorApp1/Components/InventoryComponent.razor index 42b7436..bc1ee38 100644 --- a/BlazorApp1/Components/InventoryComponent.razor +++ b/BlazorApp1/Components/InventoryComponent.razor @@ -1,11 +1,9 @@ -

Inventory

- - +
-
Recipe
+
@Localizer["InventoryTitle"]
@@ -50,7 +48,7 @@
-
Available items:
+
@Localizer["AvailableItems"]
@@ -63,13 +61,14 @@
- +
-
Actions
+
@Localizer["Logs"]
+
\ No newline at end of file diff --git a/BlazorApp1/Components/InventoryComponent.razor.cs b/BlazorApp1/Components/InventoryComponent.razor.cs index 0e1b9a4..ed9f0b7 100644 --- a/BlazorApp1/Components/InventoryComponent.razor.cs +++ b/BlazorApp1/Components/InventoryComponent.razor.cs @@ -1,5 +1,7 @@ using BlazorApp1.Models; +using BlazorApp1.Pages; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; using Microsoft.JSInterop; using System.Collections.ObjectModel; using System.Collections.Specialized; @@ -23,6 +25,9 @@ namespace BlazorApp1.Components public List InventoryItems { get; set; } + [Inject] + public IStringLocalizer Localizer { get; set; } + /// /// Gets or sets the java script runtime. /// diff --git a/BlazorApp1/Components/InventoryItem.razor b/BlazorApp1/Components/InventoryItem.razor index b14c5a7..c51d5cb 100644 --- a/BlazorApp1/Components/InventoryItem.razor +++ b/BlazorApp1/Components/InventoryItem.razor @@ -10,7 +10,9 @@ @ondragleave="@OnDragLeave"> @if (Item != null) - { - @(Item.DisplayName) + {
+ @(Item.DisplayName) + @this.Stack +
}
\ No newline at end of file diff --git a/BlazorApp1/Components/InventoryItem.razor.cs b/BlazorApp1/Components/InventoryItem.razor.cs index a89a4a4..72b2080 100644 --- a/BlazorApp1/Components/InventoryItem.razor.cs +++ b/BlazorApp1/Components/InventoryItem.razor.cs @@ -13,6 +13,9 @@ namespace BlazorApp1.Components [Parameter] public bool NoDrop { get; set; } + + [Parameter] + public int Stack { get; set; } [CascadingParameter] public InventoryComponent Parent { get; set; } @@ -44,9 +47,21 @@ namespace BlazorApp1.Components return; } - this.Item = Parent.CurrentDragItem; + if (this.Item != null) + { + if (this.Item.Name == Parent.CurrentDragItem.Name) + { + this.Stack = this.Stack + 1; + } + else { return; } + } + + else + { + this.Item = Parent.CurrentDragItem; - Parent.Actions.Add(new CraftingAction { Action = "Drop", Item = this.Item, Index = this.Index }); + Parent.Actions.Add(new CraftingAction { Action = "Drop", Item = this.Item, Index = this.Index }); + } } private void OnDragStart() diff --git a/BlazorApp1/Components/InventoryItem.razor.css b/BlazorApp1/Components/InventoryItem.razor.css index b2d4521..288333f 100644 --- a/BlazorApp1/Components/InventoryItem.razor.css +++ b/BlazorApp1/Components/InventoryItem.razor.css @@ -4,3 +4,7 @@ border: 1px solid; overflow: hidden; } + +.oui{ + position: absolute; +} \ No newline at end of file diff --git a/BlazorApp1/Pages/Inventory.razor b/BlazorApp1/Pages/Inventory.razor index dc7eff3..d35e55e 100644 --- a/BlazorApp1/Pages/Inventory.razor +++ b/BlazorApp1/Pages/Inventory.razor @@ -3,7 +3,8 @@ @using BlazorApp1.Components @using BlazorApp1.Models -Inventory +@Localizer["TitlePage"] +

@Localizer["Title"]

diff --git a/BlazorApp1/Pages/Inventory.razor.cs b/BlazorApp1/Pages/Inventory.razor.cs index b920926..6843435 100644 --- a/BlazorApp1/Pages/Inventory.razor.cs +++ b/BlazorApp1/Pages/Inventory.razor.cs @@ -2,6 +2,7 @@ using BlazorApp1.Models; using Blazorise.DataGrid; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; namespace BlazorApp1.Pages { @@ -13,6 +14,9 @@ namespace BlazorApp1.Pages private int totalItem; public List Items { get; set; } = new List(); + [Inject] + public IStringLocalizer Localizer { get; set; } + protected override async Task OnAfterRenderAsync(bool firstRender) { base.OnAfterRenderAsync(firstRender); diff --git a/BlazorApp1/Resources/Pages.Inventory.fr-FR.resx b/BlazorApp1/Resources/Pages.Inventory.fr-FR.resx index 67b7493..d61508d 100644 --- a/BlazorApp1/Resources/Pages.Inventory.fr-FR.resx +++ b/BlazorApp1/Resources/Pages.Inventory.fr-FR.resx @@ -117,7 +117,19 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Items disponibles + + + Votre inventaire + + + Historique des actions + Inventaire + + Inventaire + \ No newline at end of file diff --git a/BlazorApp1/Resources/Pages.Inventory.resx b/BlazorApp1/Resources/Pages.Inventory.resx index 6c5f871..b743558 100644 --- a/BlazorApp1/Resources/Pages.Inventory.resx +++ b/BlazorApp1/Resources/Pages.Inventory.resx @@ -117,7 +117,19 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Available Items + + + Your inventory + + + Action logs + Inventory + + Inventory + \ No newline at end of file