From f7f9a4f44cf31c19e4486e0e33792ac154c580a0 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Mon, 16 Feb 2026 02:04:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=B9=B2=E5=91=98=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E6=8C=89=E7=85=A7=20=E7=A8=80=E6=9C=89=E5=BA=A6->=E7=B2=BE?= =?UTF-8?q?=E8=8B=B1=E5=8C=96->=E7=AD=89=E7=BA=A7->=E6=BD=9C=E8=83=BD->Id?= =?UTF-8?q?=20=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Models/OperBoxData.cs | 12 +++++++ .../ViewModels/UI/ToolboxViewModel.cs | 36 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/MaaWpfGui/Models/OperBoxData.cs b/src/MaaWpfGui/Models/OperBoxData.cs index 62604f2b28..f06964d121 100644 --- a/src/MaaWpfGui/Models/OperBoxData.cs +++ b/src/MaaWpfGui/Models/OperBoxData.cs @@ -23,15 +23,27 @@ public class OperBoxData [JsonProperty("id")] public string Id { get; set; } = null!; // char_2024_chyue + /// + /// Gets or sets 干员名称 + /// [JsonProperty("name")] public string Name { get; set; } = null!; // 重岳 + /// + /// Gets or sets 精英化等级 + /// [JsonProperty("elite")] public int Elite { get; set; } = 0; + /// + /// Gets or sets 等级 + /// [JsonProperty("level")] public int Level { get; set; } = 0; + /// + /// Gets or sets a value indicating whether 是否拥有 + /// [JsonProperty("own")] public bool Own { get; set; } = false; diff --git a/src/MaaWpfGui/ViewModels/UI/ToolboxViewModel.cs b/src/MaaWpfGui/ViewModels/UI/ToolboxViewModel.cs index 07e9b4c19a..73cee83ba3 100644 --- a/src/MaaWpfGui/ViewModels/UI/ToolboxViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/ToolboxViewModel.cs @@ -1028,6 +1028,8 @@ public class ToolboxViewModel : Screen [JsonProperty("potential")] public int Potential { get; } = potential; + public int IdNumber { get; } = ExtractIdNumber(id); + public string RarityStars => IsPallas ? LocalizationHelper.GetPallasString(6, 6) : new('★', Rarity); /// @@ -1056,6 +1058,15 @@ public class ToolboxViewModel : Screen public override string ToString() => $"{Name} (★{Rarity})"; private bool IsPallas => Id == "char_485_pallas"; + + private static int ExtractIdNumber(string id) + { + // char_002_amiya + // ↑取中间 + int start = id.IndexOf('_') + 1; + int end = id.IndexOf('_', start); + return int.Parse(id.AsSpan(start, end - start)); + } } private ObservableCollection _operBoxHaveList = []; @@ -1081,6 +1092,27 @@ public class ToolboxViewModel : Screen JsonDataHelper.Set(JsonDataKey.OperBoxData, JArray.FromObject(details)); } + private void SortOperBoxLists() + { + OperBoxHaveList = SortOperBoxList(OperBoxHaveList); + OperBoxNotHaveList = SortOperBoxList(OperBoxNotHaveList); + } + + private static ObservableCollection SortOperBoxList(ObservableCollection list) + { + if (list == null || list.Count <= 0) + { + return list ?? []; + } + + return [.. list + .OrderByDescending(x => x.Rarity) + .ThenByDescending(x => x.Elite) + .ThenByDescending(x => x.Level) + .ThenByDescending(x => x.Potential) + .ThenByDescending(x => x.IdNumber)]; + } + private void LoadOperBoxDetails() { // TODO: 删除老数据节省 gui.json 的大小,后续版本可以删除 @@ -1121,6 +1153,8 @@ public class ToolboxViewModel : Screen } } } + + SortOperBoxLists(); } catch { @@ -1174,6 +1208,8 @@ public class ToolboxViewModel : Screen } } + SortOperBoxLists(); + if (OperBoxNotHaveList.Count > 0) { OperBoxSelectedIndex = 0;