AutoGeniusInvokation: add hotkey

This commit is contained in:
huiyadanli
2023-10-22 15:28:38 +08:00
parent 6256a80c01
commit bfca926c07
9 changed files with 35 additions and 6 deletions

View File

@@ -82,6 +82,16 @@ public class GeniusInvokationControl
VisionContext.Instance().DrawContent.ClearAll();
CheckTask();
var bitmap = _gameCapture?.Capture();
// wgc 缓冲区设置的2 所以至少截图3次
if (_gameCapture?.Mode == CaptureModes.WindowsGraphicsCapture)
{
for (int i = 0; i < 2; i++)
{
bitmap = _gameCapture?.Capture();
Sleep(50);
}
}
if (bitmap == null)
{
_logger.LogWarning("截图失败!");
@@ -545,7 +555,7 @@ public class GeniusInvokationControl
public bool ActionPhaseElementalTuningConfirm()
{
var ra = CaptureGameRectArea();
//Cv2.ImWrite("log\\" + DateTime.Now.ToString("yyyy-MM-dd HHmmssffff") + ".png", ra.SrcMat);
// Cv2.ImWrite("log\\" + DateTime.Now.ToString("yyyy-MM-dd HHmmssffff") + ".png", ra.SrcMat);
var foundRectArea = ra.Find(_assets.ElementalTuningConfirmButtonRo);
if (!foundRectArea.IsEmpty())
{

View File

@@ -81,8 +81,9 @@ public class Duel
// ignored
}
if (CharacterCardRects.Count != 3)
if (CharacterCardRects is not { Count: 3 })
{
CharacterCardRects = new List<Rect>();
var defaultCharacterCardRects = TaskContext.Instance().Config.AutoGeniusInvokationConfig.DefaultCharacterCardRects;
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
for (var i = 0; i < defaultCharacterCardRects.Count; i++)
@@ -270,7 +271,7 @@ public class Duel
}
catch (System.Exception ex)
{
_logger.LogError(ex.ToString());
_logger.LogError(ex.Message);
}
finally
{

View File

@@ -59,7 +59,7 @@
HorizontalAlignment="Left"
VerticalAlignment="Top" Canvas.Left="27" Canvas.Top="409" />-->
<ContentControl Height="188" Canvas.Left="20" Canvas.Top="500" Width="477"
<ContentControl x:Name="LogTextBoxWrapper" Height="188" Canvas.Left="20" Canvas.Top="500" Width="477"
Style="{StaticResource OuterDraggableResizableItemStyle}">
<RichTextBox
x:Name="LogTextBox"

View File

@@ -71,8 +71,10 @@ namespace BetterGenshinImpact.View
{
Left = currentRect.Left / dpiScale;
Top = currentRect.Top / dpiScale;
Width = currentRect.Width /dpiScale;
Width = currentRect.Width / dpiScale;
Height = currentRect.Height / dpiScale;
Canvas.SetTop(LogTextBoxWrapper, Height - LogTextBoxWrapper.Height - 65);
});
// 重新计算控件位置
// shit code 预定了

View File

@@ -14,13 +14,15 @@ namespace BetterGenshinImpact.ViewModel.Pages;
public partial class HotKeyPageViewModel : ObservableObject
{
private readonly ILogger<HotKeyPageViewModel> _logger;
private readonly TaskSettingsPageViewModel _taskSettingsPageViewModel;
public AllConfig Config { get; set; }
[ObservableProperty] private ObservableCollection<HotKeySettingModel> _hotKeySettingModels = new();
public HotKeyPageViewModel(IConfigService configService, ILogger<HotKeyPageViewModel> logger)
public HotKeyPageViewModel(IConfigService configService, ILogger<HotKeyPageViewModel> logger, TaskSettingsPageViewModel taskSettingsPageViewModel)
{
_logger = logger;
_taskSettingsPageViewModel = taskSettingsPageViewModel;
// 获取配置
Config = configService.Get();
@@ -109,6 +111,13 @@ public partial class HotKeyPageViewModel : ObservableObject
hotKey => { QuickEnhanceArtifactMacro.Done(); }
);
HotKeySettingModels.Add(enhanceArtifactHotKeySettingModel);
HotKeySettingModels.Add(new HotKeySettingModel(
"启动/停止自动七圣召唤",
nameof(Config.HotKeyConfig.AutoGeniusInvokation),
Config.HotKeyConfig.AutoGeniusInvokation,
hotKey => { _taskSettingsPageViewModel.OnSwitchAutoGeniusInvokation(); }
));
}
private string ToChinese(bool enabled)

View File

@@ -6,6 +6,9 @@ namespace Fischless.GameCapture.BitBlt;
public class BitBltCapture : IGameCapture
{
private nint _hWnd;
public CaptureModes Mode => CaptureModes.BitBlt;
public bool IsCapturing { get; private set; }
public void Dispose() => Stop();

View File

@@ -19,6 +19,8 @@ namespace Fischless.GameCapture.DwmSharedSurface
private ResourceRegion? _region;
public CaptureModes Mode => CaptureModes.DwmGetDxSharedSurface;
public void Start(nint hWnd)
{
_hWnd = hWnd;

View File

@@ -16,6 +16,7 @@ public class GraphicsCapture : IGameCapture
private GraphicsCaptureItem _captureItem = null!;
private GraphicsCaptureSession _captureSession = null!;
public CaptureModes Mode => CaptureModes.WindowsGraphicsCapture;
public bool IsCapturing { get; private set; }
private ResourceRegion? _region;

View File

@@ -2,6 +2,7 @@
public interface IGameCapture : IDisposable
{
public CaptureModes Mode { get; }
public bool IsCapturing { get; }
public void Start(nint hWnd);