From f2788a34638777a3a748985cf8ab1ea052d6f910 Mon Sep 17 00:00:00 2001 From: DavidWang19 Date: Thu, 20 Oct 2022 17:38:26 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=88=E5=B9=B6=E6=9C=AC=E6=AC=A1?= =?UTF-8?q?=E6=8E=89=E8=90=BD=E5=92=8C=E6=8E=89=E8=90=BD=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Task/Plugin/StageDropsTaskPlugin.cpp | 18 +++++++-------- src/MeoAsstGui/Helper/AsstProxy.cs | 23 ++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/MeoAssistant/Task/Plugin/StageDropsTaskPlugin.cpp b/src/MeoAssistant/Task/Plugin/StageDropsTaskPlugin.cpp index 837a30754b..f31accd811 100644 --- a/src/MeoAssistant/Task/Plugin/StageDropsTaskPlugin.cpp +++ b/src/MeoAssistant/Task/Plugin/StageDropsTaskPlugin.cpp @@ -137,15 +137,10 @@ void asst::StageDropsTaskPlugin::drop_info_callback() { LogTraceFunction; - std::vector drops_vec; + std::unordered_map cur_drops_count; for (const auto& drop : m_cur_drops) { - json::value info; - info["itemId"] = drop.item_id; - info["quantity"] = drop.quantity; m_drop_stats[drop.item_id] += drop.quantity; - info["itemName"] = drop.item_name; - info["dropType"] = drop.drop_type_name; - drops_vec.emplace_back(std::move(info)); + cur_drops_count.emplace(drop.item_id, drop.quantity); } std::vector stats_vec; @@ -154,7 +149,13 @@ void asst::StageDropsTaskPlugin::drop_info_callback() info["itemId"] = id; const std::string& name = ItemData.get_item_name(id); info["itemName"] = name.empty() ? id : name; - info["quantity"] = count; + info["totalQuantity"] = count; + if (auto iter = cur_drops_count.find(id); iter != cur_drops_count.end()) { + info["addQuantity"] = iter->second; + } + else { + info["addQuantity"] = 0; + } stats_vec.emplace_back(std::move(info)); } //// 排个序,数量多的放前面 @@ -167,7 +168,6 @@ void asst::StageDropsTaskPlugin::drop_info_callback() json::value& details = info["details"]; details["stars"] = m_stars; details["stats"] = json::array(std::move(stats_vec)); - details["drops"] = json::array(std::move(drops_vec)); json::value& stage = details["stage"]; stage["stageCode"] = m_stage_code; if (!m_stage_code.empty()) { diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index 2c9f68d2f1..e530032cb7 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -14,6 +14,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; @@ -726,25 +727,19 @@ namespace MeoAsstGui { case "StageDrops": { - string cur_drops = string.Empty; - JArray drops = (JArray)subTaskDetails["drops"]; - foreach (var item in drops) - { - string itemName = item["itemName"].ToString(); - int count = (int)item["quantity"]; - cur_drops += $"{itemName} : {count}\n"; - } - - cur_drops = cur_drops.EndsWith("\n") ? cur_drops.TrimEnd('\n') : Localization.GetString("NoDrop"); - mainModel.AddLog(Localization.GetString("Drop") + "\n" + cur_drops); - string all_drops = string.Empty; JArray statistics = (JArray)subTaskDetails["stats"]; foreach (var item in statistics) { string itemName = item["itemName"].ToString(); - int count = (int)item["quantity"]; - all_drops += $"{itemName} : {count}\n"; + int totalQuantity = (int)item["totalQuantity"]; + int addQuantity = (int)item["addQuantity"]; + all_drops += $"{itemName} : {totalQuantity}"; + if (addQuantity > 0) + { + all_drops += $" (+{addQuantity})"; + } + all_drops += "\n"; } all_drops = all_drops.EndsWith("\n") ? all_drops.TrimEnd('\n') : Localization.GetString("NoDrop");