From e207a74995318aacf2f03189ffdfb5865dd976cc Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:19:48 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=88=AA=E5=9B=BE?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Constants/UILogColor.cs | 5 +++++ src/MaaWpfGui/Main/AsstProxy.cs | 29 +++++++++++++++++++++------ src/MaaWpfGui/Res/Themes/Dark.xaml | 3 ++- src/MaaWpfGui/Res/Themes/Light.xaml | 3 ++- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/MaaWpfGui/Constants/UILogColor.cs b/src/MaaWpfGui/Constants/UILogColor.cs index e680840edc..8978fab1e5 100644 --- a/src/MaaWpfGui/Constants/UILogColor.cs +++ b/src/MaaWpfGui/Constants/UILogColor.cs @@ -59,6 +59,11 @@ namespace MaaWpfGui.Constants /// public const string Download = "DownloadLogBrush"; + /// + /// The recommended color for special screenshot. + /// + public const string SpecialScreenshot = "HighlightBrush"; + // 颜色在MaaWpfGui\Res\Themes中定义 // Brush are defined in MaaWpfGui\Res\Themes } diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 6773261e62..6befc6b844 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -493,6 +493,7 @@ namespace MaaWpfGui.Main { string costString = details["details"]?["cost"]?.ToString() ?? "???"; string method = details["details"]?["method"]?.ToString() ?? "???"; + Instances.SettingsViewModel.ScreencapMethod = method; StringBuilder fastestScreencapStringBuilder = new(); string color = UiLogColor.Trace; @@ -515,21 +516,37 @@ namespace MaaWpfGui.Main color = UiLogColor.Error; } - fastestScreencapStringBuilder.Insert(0, string.Format(LocalizationHelper.GetString("FastestWayToScreencap"), costString, method)); - Instances.TaskQueueViewModel.AddLog(fastestScreencapStringBuilder.ToString(), color); - Instances.CopilotViewModel.AddLog(fastestScreencapStringBuilder.ToString(), color, showTime: false); - + var needToStop = false; switch (Instances.SettingsViewModel.ConnectConfig) { case "MuMuEmulator12": if (Instances.SettingsViewModel.MuMuEmulator12Extras.Enable && method != "MumuExtras") { - Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("MuMuExtrasNotEnabledMessage"), UiLogColor.Warning); - Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("MuMuExtrasNotEnabledMessage"), UiLogColor.Warning, showTime: false); + Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("MuMuExtrasNotEnabledMessage"), UiLogColor.Error); + Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("MuMuExtrasNotEnabledMessage"), UiLogColor.Error, showTime: false); + needToStop = true; + } + else if (timeCost < 100) + { + color = UiLogColor.SpecialScreenshot; } break; } + + fastestScreencapStringBuilder.Insert(0, string.Format(LocalizationHelper.GetString("FastestWayToScreencap"), costString, method)); + Instances.TaskQueueViewModel.AddLog(fastestScreencapStringBuilder.ToString(), color); + Instances.CopilotViewModel.AddLog(fastestScreencapStringBuilder.ToString(), color, showTime: false); + + // 截图增强未生效自动停止一次,再开就不管了 + if (needToStop) + { + Execute.OnUIThreadAsync(async () => + { + await Instances.TaskQueueViewModel.Stop(); + Instances.TaskQueueViewModel.SetStopped(); + }); + } } break; diff --git a/src/MaaWpfGui/Res/Themes/Dark.xaml b/src/MaaWpfGui/Res/Themes/Dark.xaml index 65991db3dd..7066219e1c 100644 --- a/src/MaaWpfGui/Res/Themes/Dark.xaml +++ b/src/MaaWpfGui/Res/Themes/Dark.xaml @@ -33,7 +33,7 @@ - + @@ -43,4 +43,5 @@ + diff --git a/src/MaaWpfGui/Res/Themes/Light.xaml b/src/MaaWpfGui/Res/Themes/Light.xaml index 1ec11ea0f9..e8bca1ec31 100644 --- a/src/MaaWpfGui/Res/Themes/Light.xaml +++ b/src/MaaWpfGui/Res/Themes/Light.xaml @@ -14,7 +14,7 @@ - + @@ -25,4 +25,5 @@ +