From fe61549c953db8363404a0fd15d22f7cf54d4bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89=E9=B8=AD=E8=9B=8B?= Date: Sun, 22 Feb 2026 18:17:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=BB=E5=BA=95=E5=88=A0=E9=99=A4=20?= =?UTF-8?q?=E5=AE=9E=E9=AA=8C=E5=8A=9F=E8=83=BD=20=E9=81=AE=E7=BD=A9?= =?UTF-8?q?=E4=BB=A5=E5=8E=9F=E7=A5=9E=E5=AD=90=E7=AA=97=E4=BD=93=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E5=90=AF=E5=8A=A8=20UseSubform?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Config/MaskWindowConfig.cs | 7 ---- .../GameTask/TaskTriggerDispatcher.cs | 38 ++++++++----------- BetterGenshinImpact/View/MaskWindow.xaml.cs | 28 +------------- .../View/Pages/CommonSettingsPage.xaml | 27 ------------- 4 files changed, 17 insertions(+), 83 deletions(-) diff --git a/BetterGenshinImpact/Core/Config/MaskWindowConfig.cs b/BetterGenshinImpact/Core/Config/MaskWindowConfig.cs index 98cfccd1..49143e8b 100644 --- a/BetterGenshinImpact/Core/Config/MaskWindowConfig.cs +++ b/BetterGenshinImpact/Core/Config/MaskWindowConfig.cs @@ -63,13 +63,6 @@ public partial class MaskWindowConfig : ObservableObject [ObservableProperty] private bool _showFps = false; - /// - /// 作为原神子窗体 - /// 有些bug没解决 - /// - [ObservableProperty] - private bool _useSubform = false; - /// /// 遮罩文本透明度 (0.0-1.0) /// diff --git a/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs b/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs index f274c93a..41e7e5f8 100644 --- a/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs +++ b/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs @@ -1,4 +1,4 @@ -using BetterGenshinImpact.Core.Config; +using BetterGenshinImpact.Core.Config; using BetterGenshinImpact.GameTask.Common; using BetterGenshinImpact.Helpers; using BetterGenshinImpact.View; @@ -259,14 +259,11 @@ namespace BetterGenshinImpact.GameTask Debug.WriteLine("游戏窗口不在前台, 不再进行截屏"); } - if (!TaskContext.Instance().Config.MaskWindowConfig.UseSubform) + var pName = SystemControl.GetActiveProcessName(); + if (pName != "Idle" && pName != "BetterGI" && pName != "YuanShen" && pName != "GenshinImpact" && pName != "Genshin Impact Cloud Game") { - var pName = SystemControl.GetActiveProcessName(); - if (pName != "Idle" && pName != "BetterGI" && pName != "YuanShen" && pName != "GenshinImpact" && pName != "Genshin Impact Cloud Game") - { - // Debug.WriteLine(pName + ":hide mask window"); - maskWindow.Invoke(() => { maskWindow.HideSelf(); }); - } + // Debug.WriteLine(pName + ":hide mask window"); + maskWindow.Invoke(() => { maskWindow.HideSelf(); }); } _prevGameActive = active; @@ -302,23 +299,20 @@ namespace BetterGenshinImpact.GameTask else { PictureInPictureService.Hide(resetManual: true); - if (!TaskContext.Instance().Config.MaskWindowConfig.UseSubform) + // if (!_prevGameActive) + // { + maskWindow.Invoke(() => { - // if (!_prevGameActive) - // { - maskWindow.Invoke(() => + if (maskWindow.IsExist()) { - if (maskWindow.IsExist()) + maskWindow.Show(); + if (!_prevGameActive) { - maskWindow.Show(); - if (!_prevGameActive) - { - maskWindow.BringToTop(); - } + maskWindow.BringToTop(); } - }); - // } - } + } + }); + // } _prevGameActive = active; // // 移动游戏窗口的时候同步遮罩窗口的位置,此时不进行捕获 @@ -528,4 +522,4 @@ namespace BetterGenshinImpact.GameTask } } } -} \ No newline at end of file +} diff --git a/BetterGenshinImpact/View/MaskWindow.xaml.cs b/BetterGenshinImpact/View/MaskWindow.xaml.cs index ba5d0e9b..26d3c830 100644 --- a/BetterGenshinImpact/View/MaskWindow.xaml.cs +++ b/BetterGenshinImpact/View/MaskWindow.xaml.cs @@ -43,7 +43,6 @@ public partial class MaskWindow : Window private static readonly Typeface _typeface; private static readonly Typeface _fgiTypeface; - private nint _hWnd; private MaskWindowViewModel? _viewModel; private IRichTextBox? _richTextBox; @@ -104,14 +103,7 @@ public partial class MaskWindow : Window public void RefreshPosition() { - if (TaskContext.Instance().Config.MaskWindowConfig.UseSubform) - { - RefreshPositionForSubform(); - } - else - { - RefreshPositionForNormal(); - } + RefreshPositionForNormal(); } public void RefreshPositionForNormal() @@ -130,13 +122,6 @@ public partial class MaskWindow : Window }); } - public void RefreshPositionForSubform() - { - nint targetHWnd = TaskContext.Instance().GameHandle; - _ = User32.GetClientRect(targetHWnd, out RECT targetRect); - _ = User32.SetWindowPos(_hWnd, IntPtr.Zero, 0, 0, targetRect.Width, targetRect.Height, User32.SetWindowPosFlags.SWP_SHOWWINDOW); - } - public MaskWindow() { _maskWindow = this; @@ -204,17 +189,6 @@ public partial class MaskWindow : Window UpdateClickThroughState(); - if (TaskContext.Instance().Config.MaskWindowConfig.UseSubform) - { - _hWnd = new WindowInteropHelper(this).Handle; - nint targetHWnd = TaskContext.Instance().GameHandle; - - if (User32.GetParent(_hWnd) != targetHWnd) - { - _ = User32.SetParent(_hWnd, targetHWnd); - } - } - RefreshPosition(); PrintSystemInfo(); if (_viewModel != null) diff --git a/BetterGenshinImpact/View/Pages/CommonSettingsPage.xaml b/BetterGenshinImpact/View/Pages/CommonSettingsPage.xaml index 578bb8a4..1f223a77 100644 --- a/BetterGenshinImpact/View/Pages/CommonSettingsPage.xaml +++ b/BetterGenshinImpact/View/Pages/CommonSettingsPage.xaml @@ -449,33 +449,6 @@ FontSize="14" Text="{Binding Config.MaskWindowConfig.TextOpacity, StringFormat=F2}" /> - - -