From 8a78a80417c0e6ba6af15c5d0ebc19b651650778 Mon Sep 17 00:00:00 2001
From: travellerse <58685479+travellerse@users.noreply.github.com>
Date: Thu, 31 Jul 2025 19:27:29 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=B9=E6=8E=89=E8=90=BD=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E8=BF=9B=E8=A1=8C=E6=8E=92=E5=BA=8F=20=E4=B8=8EToolTi?=
=?UTF-8?q?p=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4=20(#13404)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: 对掉落信息进行排序 与ToolTip保持一致
* fix: 在 wpf 里对掉落信息进行排序
---
.../Task/Fight/StageDropsTaskPlugin.cpp | 5 ----
src/MaaWpfGui/Helper/ToolTipHelper.cs | 6 ++---
src/MaaWpfGui/Main/AsstProxy.cs | 24 ++++++++++++-------
3 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/src/MaaCore/Task/Fight/StageDropsTaskPlugin.cpp b/src/MaaCore/Task/Fight/StageDropsTaskPlugin.cpp
index 6c8b65409a..c291c52863 100644
--- a/src/MaaCore/Task/Fight/StageDropsTaskPlugin.cpp
+++ b/src/MaaCore/Task/Fight/StageDropsTaskPlugin.cpp
@@ -242,11 +242,6 @@ void asst::StageDropsTaskPlugin::drop_info_callback()
}
stats_vec.emplace_back(std::move(info));
}
- //// 排个序,数量多的放前面
- // std::sort(stats_vec.begin(), stats_vec.end(),
- // [](const json::value& lhs, const json::value& rhs) -> bool {
- // return lhs.at("count").as_integer() > rhs.at("count").as_integer();
- // });
json::value info = basic_info_with_what("StageDrops");
json::value& details = info["details"];
diff --git a/src/MaaWpfGui/Helper/ToolTipHelper.cs b/src/MaaWpfGui/Helper/ToolTipHelper.cs
index 5d9eb2d4ef..76eb391423 100644
--- a/src/MaaWpfGui/Helper/ToolTipHelper.cs
+++ b/src/MaaWpfGui/Helper/ToolTipHelper.cs
@@ -129,7 +129,7 @@ namespace MaaWpfGui.Helper
///
/// 掉落物列表
/// ToolTip
- public static ToolTip CreateMaterialDropTooltip(this IEnumerable<(string ItemId, int Total, int Add)> drops)
+ public static ToolTip CreateMaterialDropTooltip(this IEnumerable<(string ItemId, string ItemName, int Total, int Add)> drops)
{
var row = new WrapPanel
{
@@ -140,9 +140,7 @@ namespace MaaWpfGui.Helper
MaxWidth = (64 * 5) + (4 * 10),
};
- foreach (var (itemId, total, add) in drops
- .OrderByDescending(x => x.Add)
- .ThenByDescending(x => x.Total))
+ foreach (var (itemId, _, total, add) in drops)
{
var image = new Image
{
diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs
index 2972cea86d..e40f91db5d 100644
--- a/src/MaaWpfGui/Main/AsstProxy.cs
+++ b/src/MaaWpfGui/Main/AsstProxy.cs
@@ -1515,12 +1515,12 @@ namespace MaaWpfGui.Main
var statistics = subTaskDetails!["stats"] ?? new JArray();
var stageInfo = subTaskDetails!["stage"] ?? new JObject();
int curTimes = (int)(subTaskDetails["cur_times"] ?? -1);
- var drops = new List<(string ItemId, int Total, int Add)>();
+ var drops = new List<(string ItemId, string ItemName, int Total, int Add)>();
foreach (var item in statistics)
{
- var itemId = item["itemId"]?.ToString();
- var itemName = item["itemName"]?.ToString();
+ var itemId = item["itemId"]?.ToString() ?? string.Empty;
+ var itemName = item["itemName"]?.ToString() ?? string.Empty;
if (itemName == "furni")
{
itemName = LocalizationHelper.GetString("FurnitureDrop");
@@ -1529,28 +1529,34 @@ namespace MaaWpfGui.Main
int totalQuantity = (int)(item["quantity"] ?? -1);
int addQuantity = (int)(item["addQuantity"] ?? -1);
+ drops.Add((itemId, itemName, totalQuantity, addQuantity));
+ }
+
+ // 先按新增数量降序,再按总数量降序
+ drops = [.. drops.OrderByDescending(x => x.Add).ThenByDescending(x => x.Total)];
+
+ foreach (var (_, itemName, totalQuantity, addQuantity) in drops)
+ {
allDrops += $"{itemName} : {totalQuantity:#,#}";
if (addQuantity > 0)
{
allDrops += $" (+{addQuantity:#,#})";
}
- if (!string.IsNullOrEmpty(itemId))
- {
- drops.Add((itemId, totalQuantity, addQuantity));
- }
-
allDrops += "\n";
}
var stageCode = stageInfo["stageCode"]?.ToString();
allDrops = allDrops.EndsWith('\n') ? allDrops.TrimEnd('\n') : LocalizationHelper.GetString("NoDrop");
+
+ var dropsForTooltip = drops.Where(x => !string.IsNullOrEmpty(x.ItemId)).ToList();
+
Instances.TaskQueueViewModel.AddLog(
$"{stageCode} {LocalizationHelper.GetString("TotalDrop")}\n" +
$"{allDrops}{(curTimes >= 0
? $"\n{LocalizationHelper.GetString("CurTimes")} : {curTimes}"
: string.Empty)}",
- toolTip: drops.CreateMaterialDropTooltip());
+ toolTip: dropsForTooltip.CreateMaterialDropTooltip());
AchievementTrackerHelper.Instance.AddProgressToGroup(AchievementIds.SanitySpenderGroup, curTimes > 0 ? curTimes : 1);