mirror of
https://github.com/babalae/better-genshin-impact
synced 2025-01-07 03:17:16 +08:00
auto fix win11 bitblt
This commit is contained in:
parent
4725af5491
commit
dcd7831368
@ -55,6 +55,12 @@ public partial class AllConfig : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _wgcUseBitmapCache = true;
|
private bool _wgcUseBitmapCache = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动修复Win11下BitBlt截图方式不可用的问题
|
||||||
|
/// </summary>
|
||||||
|
[ObservableProperty]
|
||||||
|
private bool _autoFixWin11BitBlt = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 推理使用的设备
|
/// 推理使用的设备
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -143,7 +143,8 @@ namespace BetterGenshinImpact.GameTask
|
|||||||
GameCapture.Start(hWnd,
|
GameCapture.Start(hWnd,
|
||||||
new Dictionary<string, object>()
|
new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{ "useBitmapCache", TaskContext.Instance().Config.WgcUseBitmapCache }
|
{ "useBitmapCache", TaskContext.Instance().Config.WgcUseBitmapCache },
|
||||||
|
{ "autoFixWin11BitBlt", OsVersionHelper.IsWindows11_OrGreater && TaskContext.Instance().Config.AutoFixWin11BitBlt }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using BetterGenshinImpact.Helpers;
|
||||||
using Wpf.Ui.Violeta.Controls;
|
using Wpf.Ui.Violeta.Controls;
|
||||||
|
|
||||||
namespace BetterGenshinImpact.View;
|
namespace BetterGenshinImpact.View;
|
||||||
@ -48,7 +49,8 @@ public partial class CaptureTestWindow : Window
|
|||||||
_capture.Start(hWnd,
|
_capture.Start(hWnd,
|
||||||
new Dictionary<string, object>()
|
new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{ "useBitmapCache", TaskContext.Instance().Config.WgcUseBitmapCache }
|
{ "useBitmapCache", TaskContext.Instance().Config.WgcUseBitmapCache },
|
||||||
|
{ "autoFixWin11BitBlt", OsVersionHelper.IsWindows11 && TaskContext.Instance().Config.AutoFixWin11BitBlt }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -296,23 +296,29 @@
|
|||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<ui:TextBlock Grid.Row="0"
|
<ui:TextBlock Grid.Row="0"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
FontTypography="Body"
|
FontTypography="Body"
|
||||||
Text="系统图形设置"
|
Text="自动关闭 Windows11 窗口化优化以支持 BitBlt"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
<ui:TextBlock Grid.Row="1"
|
<ui:TextBlock Grid.Row="1"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||||
Text="可在此处关闭 Windows11 窗口化优化以支持 BitBlt"
|
Text="修改设置后重启游戏生效"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
|
<ui:ToggleSwitch Grid.Row="0"
|
||||||
|
Grid.RowSpan="2"
|
||||||
|
Grid.Column="1"
|
||||||
|
Margin="0,0,10,0"
|
||||||
|
IsChecked="{Binding Config.AutoFixWin11BitBlt, Mode=TwoWay}" />
|
||||||
<ui:Button Grid.Row="0"
|
<ui:Button Grid.Row="0"
|
||||||
Grid.RowSpan="2"
|
Grid.RowSpan="2"
|
||||||
Grid.Column="1"
|
Grid.Column="2"
|
||||||
Margin="0,0,36,0"
|
Margin="0,0,36,0"
|
||||||
Command="{Binding OpenDisplayAdvancedGraphicsSettingsCommand}"
|
Command="{Binding OpenDisplayAdvancedGraphicsSettingsCommand}"
|
||||||
Content="开始设置" />
|
Content="手动设置" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ui:CardExpander>
|
</ui:CardExpander>
|
||||||
|
@ -13,8 +13,15 @@
|
|||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="300"
|
d:DesignWidth="300"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
<Window.Resources>
|
||||||
|
<SolidColorBrush x:Key="MultiSelectComboBox.Text.Foreground" Color="#ffffff" />
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="MultiSelectComboBox.DropDown.ListBoxItem.SelectedOrder.Foreground" Color="#000000" />
|
||||||
|
<SolidColorBrush x:Key="MultiSelectComboBox.DropDown.ListBoxItem.Selector.Background" Color="#000000" />
|
||||||
|
<SolidColorBrush x:Key="MultiSelectComboBox.DropDown.ListBoxItem.Selector.Border" Color="#000000" />
|
||||||
|
<SolidColorBrush x:Key="MultiSelectComboBox.DropDown.ListBoxItem.Selected.Background" Color="#000000" />
|
||||||
|
<SolidColorBrush x:Key="MultiSelectComboBox.DropDown.ListBoxItem.Selected.Border" Color="#000000" />
|
||||||
|
</Window.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
@ -47,14 +54,24 @@
|
|||||||
<!-- 搜索输入框 -->
|
<!-- 搜索输入框 -->
|
||||||
<sdl:MultiSelectComboBox Width="300"
|
<sdl:MultiSelectComboBox Width="300"
|
||||||
MinWidth="300"
|
MinWidth="300"
|
||||||
|
Background="{DynamicResource ApplicationBackgroundBrush}"
|
||||||
EnableAutoComplete="True"
|
EnableAutoComplete="True"
|
||||||
EnableBatchSelection="True"
|
EnableBatchSelection="True"
|
||||||
EnableFiltering="True"
|
EnableFiltering="True"
|
||||||
|
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
|
||||||
IsEditable="True"
|
IsEditable="True"
|
||||||
ItemsSource="{Binding Definition.ObjectOptions, Mode=TwoWay}"
|
ItemsSource="{Binding Definition.ObjectOptions, Mode=TwoWay}"
|
||||||
MaxDropDownHeight="300"
|
MaxDropDownHeight="300"
|
||||||
SelectedItems="{Binding Object, Mode=TwoWay}"
|
SelectedItems="{Binding Object, Mode=TwoWay}"
|
||||||
SelectionMode="Multiple" />
|
SelectionMode="Multiple">
|
||||||
|
<!--<sdl:MultiSelectComboBox.Resources>
|
||||||
|
<Style TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource ApplicationBackgroundBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
|
||||||
|
</Style>
|
||||||
|
<SolidColorBrush x:Key="MultiSelectComboBox.Text.Foreground" Color="#ffffff" />
|
||||||
|
</sdl:MultiSelectComboBox.Resources>-->
|
||||||
|
</sdl:MultiSelectComboBox>
|
||||||
|
|
||||||
<ui:TextBlock Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}">则使用</ui:TextBlock>
|
<ui:TextBlock Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}">则使用</ui:TextBlock>
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
using BetterGenshinImpact.Core.Config;
|
using BetterGenshinImpact.Core.Config;
|
||||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||||
using BetterGenshinImpact.Core.Script;
|
using BetterGenshinImpact.Core.Script;
|
||||||
|
using BetterGenshinImpact.GameTask;
|
||||||
using BetterGenshinImpact.Helpers;
|
using BetterGenshinImpact.Helpers;
|
||||||
using BetterGenshinImpact.Model;
|
using BetterGenshinImpact.Model;
|
||||||
using BetterGenshinImpact.Service.Interface;
|
using BetterGenshinImpact.Service.Interface;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Fischless.GameCapture.BitBlt;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
using System;
|
using System;
|
||||||
@ -108,6 +110,13 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel
|
|||||||
_logger.LogWarning("获取 BetterGI 最新版本信息失败");
|
_logger.LogWarning("获取 BetterGI 最新版本信息失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Win11下 BitBlt截图方式不可用,需要关闭窗口优化功能
|
||||||
|
if (OsVersionHelper.IsWindows11_OrGreater && TaskContext.Instance().Config.AutoFixWin11BitBlt)
|
||||||
|
{
|
||||||
|
BitBltRegistryHelper.SetDirectXUserGlobalSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新仓库
|
||||||
ScriptRepoUpdater.Instance.AutoUpdate();
|
ScriptRepoUpdater.Instance.AutoUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,13 @@ public class BitBltCapture : IGameCapture
|
|||||||
{
|
{
|
||||||
_hWnd = hWnd;
|
_hWnd = hWnd;
|
||||||
IsCapturing = true;
|
IsCapturing = true;
|
||||||
|
if (settings != null && settings.TryGetValue("autoFixWin11BitBlt", out var value))
|
||||||
|
{
|
||||||
|
if (value is true)
|
||||||
|
{
|
||||||
|
BitBltRegistryHelper.SetDirectXUserGlobalSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap? Capture()
|
public Bitmap? Capture()
|
||||||
|
32
Fischless.GameCapture/BitBlt/BitBltRegistryHelper.cs
Normal file
32
Fischless.GameCapture/BitBlt/BitBltRegistryHelper.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
|
||||||
|
namespace Fischless.GameCapture.BitBlt;
|
||||||
|
|
||||||
|
public class BitBltRegistryHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// https://github.com/babalae/better-genshin-impact/issues/92
|
||||||
|
/// Win11下 BitBlt截图方式不可用,需要关闭窗口优化功能,这是具体的注册表操作
|
||||||
|
/// \HKEY_CURRENT_USER\Software\Microsoft\DirectX\UserGpuPreferences
|
||||||
|
/// DirectXUserGlobalSettings = SwapEffectUpgradeEnable=0;
|
||||||
|
///
|
||||||
|
/// 要在游戏启动前设置才有效
|
||||||
|
/// </summary>
|
||||||
|
public static void SetDirectXUserGlobalSettings()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const string keyPath = @"Software\Microsoft\DirectX\UserGpuPreferences";
|
||||||
|
const string valueName = "DirectXUserGlobalSettings";
|
||||||
|
const string valueData = "SwapEffectUpgradeEnable=0;";
|
||||||
|
|
||||||
|
using var key = Registry.CurrentUser.CreateSubKey(keyPath);
|
||||||
|
key.SetValue(valueName, valueData, RegistryValueKind.String);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user