From 9f3915d748dfd4b727e96b2a51a250f37c2cd8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89=E9=B8=AD=E8=9B=8B?= Date: Fri, 11 Apr 2025 00:18:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=BD=BF=E7=94=A8=E6=97=A7?= =?UTF-8?q?=E7=89=88=E6=88=AA=E5=9B=BE=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/Pages/HomePageViewModel.cs | 15 ++++++++++++++- Fischless.GameCapture/BitBlt/BitBltCapture.cs | 2 +- Fischless.GameCapture/BitBlt/BitBltOldCapture.cs | 2 +- Fischless.GameCapture/CaptureModeExtensions.cs | 2 +- Fischless.GameCapture/CaptureModes.cs | 8 ++++---- Fischless.GameCapture/GameCaptureFactory.cs | 4 ++-- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/BetterGenshinImpact/ViewModel/Pages/HomePageViewModel.cs b/BetterGenshinImpact/ViewModel/Pages/HomePageViewModel.cs index 526d8015..ba72dd91 100644 --- a/BetterGenshinImpact/ViewModel/Pages/HomePageViewModel.cs +++ b/BetterGenshinImpact/ViewModel/Pages/HomePageViewModel.cs @@ -256,7 +256,7 @@ public partial class HomePageViewModel : ViewModel if (!TaskDispatcherEnabled) { _hWnd = hWnd; - _taskDispatcher.Start(hWnd, Config.CaptureMode.ToCaptureMode(), Config.TriggerInterval); + _taskDispatcher.Start(hWnd, GetCaptureMode(), Config.TriggerInterval); _taskDispatcher.UiTaskStopTickEvent -= OnUiTaskStopTick; _taskDispatcher.UiTaskStartTickEvent -= OnUiTaskStartTick; _taskDispatcher.UiTaskStopTickEvent += OnUiTaskStopTick; @@ -270,6 +270,19 @@ public partial class HomePageViewModel : ViewModel } } + private CaptureModes GetCaptureMode() + { + try + { + return Config.CaptureMode.ToCaptureMode(); + } + catch (Exception e) + { + TaskContext.Instance().Config.CaptureMode = CaptureModes.BitBlt.ToString(); + return CaptureModes.BitBlt; + } + } + private bool CanStopTrigger() => StopButtonEnabled; [RelayCommand(CanExecute = nameof(CanStopTrigger))] diff --git a/Fischless.GameCapture/BitBlt/BitBltCapture.cs b/Fischless.GameCapture/BitBlt/BitBltCapture.cs index b1407cf0..a1c631da 100644 --- a/Fischless.GameCapture/BitBlt/BitBltCapture.cs +++ b/Fischless.GameCapture/BitBlt/BitBltCapture.cs @@ -7,7 +7,7 @@ namespace Fischless.GameCapture.BitBlt; public class BitBltCapture : IGameCapture { - public CaptureModes Mode => CaptureModes.BitBlt; + public CaptureModes Mode => CaptureModes.BitBltNew; public bool IsCapturing { get; private set; } private readonly Stopwatch _sizeCheckTimer = new(); private readonly ReaderWriterLockSlim _lockSlim = new(); diff --git a/Fischless.GameCapture/BitBlt/BitBltOldCapture.cs b/Fischless.GameCapture/BitBlt/BitBltOldCapture.cs index 3f740a84..c1c77325 100644 --- a/Fischless.GameCapture/BitBlt/BitBltOldCapture.cs +++ b/Fischless.GameCapture/BitBlt/BitBltOldCapture.cs @@ -7,7 +7,7 @@ public class BitBltOldCapture : IGameCapture { private nint _hWnd; - public CaptureModes Mode => CaptureModes.BitBltOld; + public CaptureModes Mode => CaptureModes.BitBlt; public static object LockObject { get; } = new(); diff --git a/Fischless.GameCapture/CaptureModeExtensions.cs b/Fischless.GameCapture/CaptureModeExtensions.cs index b2140dda..f1149a16 100644 --- a/Fischless.GameCapture/CaptureModeExtensions.cs +++ b/Fischless.GameCapture/CaptureModeExtensions.cs @@ -6,4 +6,4 @@ public static class CaptureModeExtensions { return (CaptureModes)Enum.Parse(typeof(CaptureModes), modeName); } -} +} \ No newline at end of file diff --git a/Fischless.GameCapture/CaptureModes.cs b/Fischless.GameCapture/CaptureModes.cs index 31b8cf65..27b951c5 100644 --- a/Fischless.GameCapture/CaptureModes.cs +++ b/Fischless.GameCapture/CaptureModes.cs @@ -4,12 +4,12 @@ namespace Fischless.GameCapture; public enum CaptureModes { - [Description("BitBlt(稳定)")] - BitBltOld, - - [Description("BitBlt(极速)")] + [Description("BitBlt(稳定)")] BitBlt, + [Description("BitBlt(极速)")] + BitBltNew, + [Description("WindowsGraphicsCapture")] WindowsGraphicsCapture, diff --git a/Fischless.GameCapture/GameCaptureFactory.cs b/Fischless.GameCapture/GameCaptureFactory.cs index bb576e0f..36c4730e 100644 --- a/Fischless.GameCapture/GameCaptureFactory.cs +++ b/Fischless.GameCapture/GameCaptureFactory.cs @@ -11,8 +11,8 @@ public class GameCaptureFactory { return mode switch { - CaptureModes.BitBlt => new BitBlt.BitBltCapture(), - CaptureModes.BitBltOld => new BitBlt.BitBltOldCapture(), + CaptureModes.BitBltNew => new BitBlt.BitBltCapture(), + CaptureModes.BitBlt => new BitBlt.BitBltOldCapture(), CaptureModes.WindowsGraphicsCapture => new Graphics.GraphicsCapture(), CaptureModes.DwmGetDxSharedSurface => new DwmSharedSurface.SharedSurfaceCapture(), _ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null),