diff --git a/BetterGenshinImpact/Core/Config/AllConfig.cs b/BetterGenshinImpact/Core/Config/AllConfig.cs
index c5834355..d434b689 100644
--- a/BetterGenshinImpact/Core/Config/AllConfig.cs
+++ b/BetterGenshinImpact/Core/Config/AllConfig.cs
@@ -52,6 +52,11 @@ namespace BetterGenshinImpact.Core.Config
///
public MaskWindowConfig MaskWindowConfig { get; set; } = new();
+ ///
+ /// 通用配置
+ ///
+ public CommonConfig CommonConfig { get; set; } = new();
+
///
/// 原神启动配置
///
@@ -113,6 +118,7 @@ namespace BetterGenshinImpact.Core.Config
{
this.PropertyChanged += OnAnyPropertyChanged;
MaskWindowConfig.PropertyChanged += OnAnyPropertyChanged;
+ CommonConfig.PropertyChanged += OnAnyPropertyChanged;
GenshinStartConfig.PropertyChanged += OnAnyPropertyChanged;
AutoPickConfig.PropertyChanged += OnAnyPropertyChanged;
diff --git a/BetterGenshinImpact/Core/Config/CommonConfig.cs b/BetterGenshinImpact/Core/Config/CommonConfig.cs
new file mode 100644
index 00000000..b077bb78
--- /dev/null
+++ b/BetterGenshinImpact/Core/Config/CommonConfig.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Text.Json.Serialization;
+using CommunityToolkit.Mvvm.ComponentModel;
+using OpenCvSharp;
+
+namespace BetterGenshinImpact.Core.Config
+{
+ ///
+ /// 遮罩窗口配置
+ ///
+ [Serializable]
+ public partial class CommonConfig : ObservableObject
+ {
+ ///
+ /// 是否启用遮罩窗口
+ ///
+ [ObservableProperty] private bool _screenshotEnabled = false;
+ ///
+ /// UID遮盖是否启用
+ ///
+ [ObservableProperty] private bool _screenshotUidCoverEnabled = false;
+ }
+}
\ No newline at end of file
diff --git a/BetterGenshinImpact/Core/Config/HotKeyConfig.cs b/BetterGenshinImpact/Core/Config/HotKeyConfig.cs
index 9fedd131..4e9f1617 100644
--- a/BetterGenshinImpact/Core/Config/HotKeyConfig.cs
+++ b/BetterGenshinImpact/Core/Config/HotKeyConfig.cs
@@ -18,6 +18,10 @@ public partial class HotKeyConfig : ObservableObject
[ObservableProperty] private string _bgiEnabledHotkey = "F11";
[ObservableProperty] private string _bgiEnabledHotkeyType = HotKeyTypeEnum.GlobalRegister.ToString();
+ // 截图
+ [ObservableProperty] private string _takeScreenshotHotkey = "";
+ [ObservableProperty] private string _takeScreenshotHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
+
[ObservableProperty] private string _autoPickEnabledHotkey = "";
[ObservableProperty] private string _autoPickEnabledHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
@@ -27,6 +31,13 @@ public partial class HotKeyConfig : ObservableObject
[ObservableProperty] private string _autoFishingEnabledHotkey = "";
[ObservableProperty] private string _autoFishingEnabledHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
+ [ObservableProperty] private string _quickTeleportEnabledHotkey = "";
+ [ObservableProperty] private string _quickTeleportEnabledHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
+
+ // 快捷传送触发
+ [ObservableProperty] private string _quickTeleportTickHotkey = "";
+ [ObservableProperty] private string _quickTeleportTickHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
+
[ObservableProperty] private string _turnAroundHotkey = "";
[ObservableProperty] private string _turnAroundHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
diff --git a/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs b/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs
index 70f4f727..a048d9af 100644
--- a/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs
+++ b/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs
@@ -16,7 +16,11 @@ using System.Drawing;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using BetterGenshinImpact.Core.Config;
using Vanara.PInvoke;
+using System.IO;
+using System.Drawing.Imaging;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
namespace BetterGenshinImpact.GameTask
{
@@ -100,6 +104,12 @@ namespace BetterGenshinImpact.GameTask
// 启动截图
GameCapture.Start(hWnd);
+ // 捕获模式初始化配置
+ if (TaskContext.Instance().Config.CommonConfig.ScreenshotEnabled)
+ {
+ _dispatcherCacheCaptureMode = DispatcherCaptureModeEnum.CacheCaptureWithTrigger;
+ }
+
// 读取游戏注册表配置
ReadGameSettings();
@@ -135,9 +145,9 @@ namespace BetterGenshinImpact.GameTask
var systemInfo = TaskContext.Instance().SystemInfo;
var width = systemInfo.GameScreenSize.Width;
var height = systemInfo.GameScreenSize.Height;
- var dpiScale = DpiHelper.ScaleY;
+ var dpiScale = TaskContext.Instance().DpiScale;
_logger.LogInformation("当前游戏分辨率{Width}x{Height},素材缩放比率{Scale},DPI缩放{Dpi}",
- width, height, systemInfo.AssetScale.ToString("F"), TaskContext.Instance().DpiScale);
+ width, height, systemInfo.AssetScale.ToString("F"), dpiScale);
if (width * 9 != height * 16)
{
@@ -381,6 +391,11 @@ namespace BetterGenshinImpact.GameTask
_dispatcherCacheCaptureMode = mode;
}
+ public DispatcherCaptureModeEnum GetCacheCaptureMode()
+ {
+ return _dispatcherCacheCaptureMode;
+ }
+
public Bitmap GetLastCaptureBitmap()
{
lock (_bitmapLocker)
@@ -394,5 +409,36 @@ namespace BetterGenshinImpact.GameTask
var bitmap = GetLastCaptureBitmap();
return new CaptureContent(bitmap, _frameIndex, _timer.Interval, this);
}
+
+ public void TakeScreenshot()
+ {
+ if (_dispatcherCacheCaptureMode is DispatcherCaptureModeEnum.OnlyCacheCapture or DispatcherCaptureModeEnum.CacheCaptureWithTrigger)
+ {
+ try
+ {
+ var path = Global.Absolute($@"log\screenshot\");
+ if (!Directory.Exists(path))
+ {
+ Directory.CreateDirectory(path);
+ }
+
+ var bitmap = GetLastCaptureBitmap();
+ var name = $@"{DateTime.Now:yyyyMMddHHmmssffff}.png";
+ var savePath = Global.Absolute($@"log\screenshot\{name}");
+
+ bitmap.Save(savePath, ImageFormat.Png);
+ _logger.LogInformation("截图已保存: {Name}", name);
+ }
+ catch (Exception e)
+ {
+ _logger.LogError("截图保存失败: {Message}", e.Message);
+ _logger.LogDebug("截图保存失败: {StackTrace}", e.StackTrace);
+ }
+ }
+ else
+ {
+ _logger.LogWarning("当前不处于截图模式,无法保存截图");
+ }
+ }
}
}
\ No newline at end of file
diff --git a/BetterGenshinImpact/View/Pages/CommonSettingsPage.xaml b/BetterGenshinImpact/View/Pages/CommonSettingsPage.xaml
index 48691a17..9984c73e 100644
--- a/BetterGenshinImpact/View/Pages/CommonSettingsPage.xaml
+++ b/BetterGenshinImpact/View/Pages/CommonSettingsPage.xaml
@@ -1,13 +1,13 @@
+ Text="软件设置" />
@@ -43,7 +43,7 @@
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
TextWrapping="Wrap"
- Text="重启软件后生效,全屏游戏下此功能无用" />
+ Text="重启软件后生效,独占全屏模式下此模式不一定生效" />
+ IsChecked="{Binding Config.MaskWindowConfig.ShowLogBox, Mode=TwoWay}">
@@ -172,7 +172,7 @@
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,36,0"
- IsChecked="{Binding Config.MaskWindowConfig.UidCoverEnabled, Mode=TwoWay}" >
+ IsChecked="{Binding Config.MaskWindowConfig.UidCoverEnabled, Mode=TwoWay}">
@@ -209,7 +209,7 @@
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,36,0"
- IsChecked="{Binding Config.MaskWindowConfig.DirectionsEnabled, Mode=TwoWay}" >
+ IsChecked="{Binding Config.MaskWindowConfig.DirectionsEnabled, Mode=TwoWay}">
@@ -223,6 +223,115 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 启用后可以通过快捷键截图,文件保存在
+
+ log/screenshot
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/BetterGenshinImpact/ViewModel/Pages/CommonSettingsPageViewModel.cs b/BetterGenshinImpact/ViewModel/Pages/CommonSettingsPageViewModel.cs
index 1f8608c2..58510668 100644
--- a/BetterGenshinImpact/ViewModel/Pages/CommonSettingsPageViewModel.cs
+++ b/BetterGenshinImpact/ViewModel/Pages/CommonSettingsPageViewModel.cs
@@ -1,10 +1,17 @@
-using BetterGenshinImpact.Core.Config;
+using System.Diagnostics;
+using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.Service.Interface;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging.Messages;
using CommunityToolkit.Mvvm.Messaging;
using Wpf.Ui.Controls;
+using BetterGenshinImpact.View.Pages;
+using Wpf.Ui;
+using System;
+using System.IO;
+using BetterGenshinImpact.GameTask;
+using BetterGenshinImpact.GameTask.Model.Enum;
namespace BetterGenshinImpact.ViewModel.Pages;
@@ -12,9 +19,12 @@ public partial class CommonSettingsPageViewModel : ObservableObject, INavigation
{
public AllConfig Config { get; set; }
- public CommonSettingsPageViewModel(IConfigService configService)
+ private readonly INavigationService _navigationService;
+
+ public CommonSettingsPageViewModel(IConfigService configService, INavigationService navigationService)
{
Config = configService.Get();
+ _navigationService = navigationService;
}
public void OnNavigatedTo()
@@ -30,4 +40,34 @@ public partial class CommonSettingsPageViewModel : ObservableObject, INavigation
{
WeakReferenceMessenger.Default.Send(new PropertyChangedMessage