From 3b31ca5865a49de9bc9f4d28362fb684011ec5d6 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Wed, 6 Mar 2024 14:54:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=A7=BB=E9=99=A4=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E8=BE=BE=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [skip changelog] --- src/MaaWpfGui/Main/AsstProxy.cs | 3 +-- .../ViewModels/UI/CopilotViewModel.cs | 22 +++++-------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index c643059a59..4bf91a4bab 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -496,6 +496,7 @@ namespace MaaWpfGui.Main { Instances.TaskQueueViewModel.AddLog(message, color); Instances.CopilotViewModel.AddLog(message, color); + HasPrintedScreencapWarning = true; } switch (screencapCostAvgInt) @@ -503,12 +504,10 @@ namespace MaaWpfGui.Main case >= 800: AddLog(string.Format(LocalizationHelper.GetString("FastestWayToScreencapErrorTip"), screencapCostAvgInt), UiLogColor.Error); AddLog(string.Format(LocalizationHelper.GetString("OptimizationTips"), screencapCostAvgInt), UiLogColor.Error); - HasPrintedScreencapWarning = true; break; case >= 400: AddLog(string.Format(LocalizationHelper.GetString("FastestWayToScreencapWarningTip"), screencapCostAvgInt), UiLogColor.Warning); AddLog(string.Format(LocalizationHelper.GetString("OptimizationTips"), screencapCostAvgInt), UiLogColor.Warning); - HasPrintedScreencapWarning = true; break; } } diff --git a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs index 4c86b775cc..473352003c 100644 --- a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs @@ -268,7 +268,7 @@ namespace MaaWpfGui.ViewModels.UI private const string TempCopilotFile = "cache/_temp_copilot.json"; private string _taskType = "General"; - private const string StageNameRegex = @"(?:[a-z]{0,3})(?:\d{0,2})-(?:(?:A|B|C|D|EX|S|TR)-)?(?:\d{1,2})(\(Raid\))?"; + private const string StageNameRegex = @"(?:[a-z]{0,3})(?:\d{0,2})-(?:(?:A|B|C|D|EX|S|TR|MO)-)?(?:\d{1,2})(\(Raid\))?"; /// /// 为自动战斗列表匹配名字 @@ -317,7 +317,6 @@ namespace MaaWpfGui.ViewModels.UI if (doc != null && doc.TryGetValue("title", out var titleValue)) { title = titleValue.ToString(); - CopilotTaskName = FindStageName((IsDataFromWeb ? string.Empty : _filename).Split(Path.DirectorySeparatorChar).LastOrDefault()?.Split('.').FirstOrDefault() ?? string.Empty, title); } @@ -355,18 +354,7 @@ namespace MaaWpfGui.ViewModels.UI CopilotUrl = MaaUrls.BilibiliVideo + match.Value; break; } - - if (string.IsNullOrEmpty(CopilotUrl)) - { - linkParser = new Regex(@"(?:https?://)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); - - foreach (Match m in linkParser.Matches(details)) - { - CopilotUrl = m.Value; - break; - } - } - } + }// 视频链接 } AddLog(string.Empty, UiLogColor.Message); @@ -935,7 +923,7 @@ namespace MaaWpfGui.ViewModels.UI UserAdditional = UserAdditional.Replace(",", ",").Replace(";", ";").Trim(); Regex regex = new Regex(@"(?<=;)(?[^,;]+)(?:, *(?\d))?(?=;)", RegexOptions.Compiled); - JArray mUserAdditional = new(regex.Matches(";" + UserAdditional + ";").ToList().Select(match => new JObject + JArray userAdditional = new(regex.Matches(";" + UserAdditional + ";").ToList().Select(match => new JObject { ["name"] = match.Groups[1].Value.Trim(), ["skill"] = string.IsNullOrEmpty(match.Groups[2].Value) ? 0 : int.Parse(match.Groups[2].Value), @@ -949,7 +937,7 @@ namespace MaaWpfGui.ViewModels.UI foreach (var model in CopilotItemViewModels.Where(i => i.IsChecked)) { _copilotIdList.Add(model.CopilotId); - ret &= Instances.AsstProxy.AsstStartCopilot(model.FilePath, Form, AddTrust, AddUserAdditional, mUserAdditional, UseCopilotList, model.Name, model.IsRaid, _taskType, Loop ? LoopTimes : 1, _useSanityPotion, false); + ret &= Instances.AsstProxy.AsstStartCopilot(model.FilePath, Form, AddTrust, AddUserAdditional, userAdditional, UseCopilotList, model.Name, model.IsRaid, _taskType, Loop ? LoopTimes : 1, _useSanityPotion, false); startAny = true; } @@ -965,7 +953,7 @@ namespace MaaWpfGui.ViewModels.UI } else { - ret &= Instances.AsstProxy.AsstStartCopilot(IsDataFromWeb ? TempCopilotFile : Filename, Form, AddTrust, AddUserAdditional, mUserAdditional, UseCopilotList, string.Empty, false, _taskType, Loop ? LoopTimes : 1, _useSanityPotion); + ret &= Instances.AsstProxy.AsstStartCopilot(IsDataFromWeb ? TempCopilotFile : Filename, Form, AddTrust, AddUserAdditional, userAdditional, UseCopilotList, string.Empty, false, _taskType, Loop ? LoopTimes : 1, _useSanityPotion); } if (ret)