From 613eff6eb4d54910bfa3a8bb44b2e31b96b4f503 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:54:50 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E7=BB=93=E6=9E=9C=E5=B1=95=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E8=AF=AD=E8=A8=80=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=20(#9434)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Helper/ItemListHelper.cs | 19 +++++++++++ .../ViewModels/UI/RecognizerViewModel.cs | 13 ++++++- src/MaaWpfGui/Views/UI/RecognizerView.xaml | 34 ++++++++++++++++--- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/MaaWpfGui/Helper/ItemListHelper.cs b/src/MaaWpfGui/Helper/ItemListHelper.cs index dac0755c77..5a5e817d7e 100644 --- a/src/MaaWpfGui/Helper/ItemListHelper.cs +++ b/src/MaaWpfGui/Helper/ItemListHelper.cs @@ -15,6 +15,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Text.Json; +using System.Windows.Media.Imaging; using MaaWpfGui.Constants; using MaaWpfGui.Models; using Serilog; @@ -76,11 +77,29 @@ namespace MaaWpfGui.Helper ArkItems = tempItems ?? new Dictionary(); } + /// + /// 获取当前语言下的物品名称 / Get the name of the item in the current language + /// + /// 物品 id / Item id + /// public static string GetItemName(string itemId) { return ArkItems.TryGetValue(itemId, out var item) ? item.Name : itemId; } + + /// + /// 获取对应物品的图标 / Get the icon of the corresponding item + /// + /// 物品 id / Item id + /// + public static BitmapImage GetItemImage(string itemId) + { + var imagePath = Path.Combine(Environment.CurrentDirectory, $"resource/template/items/{itemId}.png"); + return File.Exists(imagePath) + ? new BitmapImage(new Uri(imagePath, UriKind.RelativeOrAbsolute)) + : new BitmapImage(); + } } } diff --git a/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs b/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs index d8e36f09c8..38d8c61f5b 100644 --- a/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs @@ -377,6 +377,10 @@ namespace MaaWpfGui.ViewModels.UI { public string Name { get; set; } + public string Id { get; set; } + + public BitmapImage Image { get; set; } + public int Count { get; set; } } @@ -405,7 +409,14 @@ namespace MaaWpfGui.ViewModels.UI DepotResult.Clear(); foreach (var item in details["arkplanner"]?["object"]?["items"]?.Cast()!) { - DepotResultDate result = new DepotResultDate() { Name = (string)item["name"], Count = (int)item["have"] }; + var id = (string)item["id"]; + DepotResultDate result = new DepotResultDate() + { + Id = id, + Name = ItemListHelper.GetItemName(id), + Image = ItemListHelper.GetItemImage(id), + Count = (int)item["have"] + }; DepotResult.Add(result); } diff --git a/src/MaaWpfGui/Views/UI/RecognizerView.xaml b/src/MaaWpfGui/Views/UI/RecognizerView.xaml index ee2d06f699..e378d7daea 100644 --- a/src/MaaWpfGui/Views/UI/RecognizerView.xaml +++ b/src/MaaWpfGui/Views/UI/RecognizerView.xaml @@ -205,15 +205,39 @@ + ItemsSource="{Binding DepotResult}" + ScrollViewer.CanContentScroll="True" + ScrollViewer.HorizontalScrollBarVisibility="Disabled"> - + + + + + + + + + + + + + + + + IsChecked="{Binding GachaShowDisclaimerNoMore}" + IsEnabled="False" />