diff --git a/BetterGenshinImpact/Core/Script/Dependence/GlobalMethod.cs b/BetterGenshinImpact/Core/Script/Dependence/GlobalMethod.cs
index a7a150b5..fcb47fb3 100644
--- a/BetterGenshinImpact/Core/Script/Dependence/GlobalMethod.cs
+++ b/BetterGenshinImpact/Core/Script/Dependence/GlobalMethod.cs
@@ -223,6 +223,11 @@ public class GlobalMethod
Simulation.SendInput.Mouse.MiddleButtonUp();
}
+ public static void VerticalScroll(int scrollAmountInClicks)
+ {
+ Simulation.SendInput.Mouse.VerticalScroll(scrollAmountInClicks);
+ }
+
#endregion 鼠标操作
#region 识图操作
@@ -263,7 +268,7 @@ public class GlobalMethod
}
catch (Exception ex)
{
- TaskControl.Logger.LogDebug("输入文本时发生错误: {Msg}",ex.Message);
+ TaskControl.Logger.LogDebug("输入文本时发生错误: {Msg}", ex.Message);
}
finally
{
diff --git a/BetterGenshinImpact/Core/Script/Dependence/Log.cs b/BetterGenshinImpact/Core/Script/Dependence/Log.cs
index 59f2cce7..4f0cdde7 100644
--- a/BetterGenshinImpact/Core/Script/Dependence/Log.cs
+++ b/BetterGenshinImpact/Core/Script/Dependence/Log.cs
@@ -8,7 +8,7 @@ public class Log
public void Debug(string? message, params object?[] args)
{
- _logger.LogInformation(message, args);
+ _logger.LogDebug(message, args);
}
public void Info(string? message, params object?[] args)
diff --git a/BetterGenshinImpact/Core/Script/EngineExtend.cs b/BetterGenshinImpact/Core/Script/EngineExtend.cs
index 5510fae6..001011e7 100644
--- a/BetterGenshinImpact/Core/Script/EngineExtend.cs
+++ b/BetterGenshinImpact/Core/Script/EngineExtend.cs
@@ -98,6 +98,7 @@ public class EngineExtend
engine.AddHostObject("middleButtonClick", GlobalMethod.MiddleButtonClick);
engine.AddHostObject("middleButtonDown", GlobalMethod.MiddleButtonDown);
engine.AddHostObject("middleButtonUp", GlobalMethod.MiddleButtonUp);
+ engine.AddHostObject("verticalScroll", GlobalMethod.VerticalScroll);
engine.AddHostObject("captureGameRegion", GlobalMethod.CaptureGameRegion);
engine.AddHostObject("inputText", GlobalMethod.InputText);
#pragma warning restore CS8974 // Converting method group to non-delegate type
diff --git a/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs b/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs
index defb3042..cd6776d6 100644
--- a/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs
+++ b/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs
@@ -119,10 +119,10 @@ public class Avatar
/// tp 到七天神像恢复
///
///
+ ///
///
public static void TpForRecover(CancellationToken ct, Exception ex)
{
- Simulation.SendInput.SimulateAction(GIActions.OpenMap);
// tp 到七天神像复活
var tpTask = new TpTask(ct);
tpTask.TpToStatueOfTheSeven().Wait(ct);
diff --git a/BetterGenshinImpact/GameTask/AutoFight/Model/CombatScenes.cs b/BetterGenshinImpact/GameTask/AutoFight/Model/CombatScenes.cs
index 5180d642..d4a2607b 100644
--- a/BetterGenshinImpact/GameTask/AutoFight/Model/CombatScenes.cs
+++ b/BetterGenshinImpact/GameTask/AutoFight/Model/CombatScenes.cs
@@ -318,8 +318,9 @@ public class CombatScenes : IDisposable
///
public Avatar? SelectAvatar(int avatarIndex)
{
- if (avatarIndex < 1 || avatarIndex >= AvatarCount)
+ if (avatarIndex < 1 || avatarIndex > AvatarCount)
{
+ Logger.LogError("切换角色编号错误,当前角色数量{Count},编号{Index}", AvatarCount, avatarIndex);
return null;
}
diff --git a/BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs b/BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs
index 1ee429c1..aab392b0 100644
--- a/BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs
+++ b/BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs
@@ -336,6 +336,7 @@ public class TpTask(CancellationToken ct)
if (!await TryToOpenBigMapUi())
{
await new ReturnMainUiTask().Start(ct);
+ await Delay(500, ct);
if (!await TryToOpenBigMapUi())
{
throw new RetryException("打开大地图失败,请检查按键绑定中「打开地图」按键设置是否和原神游戏中一致!");
diff --git a/Fischless.GameCapture/BitBlt/BitBltCapture.cs b/Fischless.GameCapture/BitBlt/BitBltCapture.cs
index a1c631da..6fb10f14 100644
--- a/Fischless.GameCapture/BitBlt/BitBltCapture.cs
+++ b/Fischless.GameCapture/BitBlt/BitBltCapture.cs
@@ -7,7 +7,6 @@ namespace Fischless.GameCapture.BitBlt;
public class BitBltCapture : IGameCapture
{
- public CaptureModes Mode => CaptureModes.BitBltNew;
public bool IsCapturing { get; private set; }
private readonly Stopwatch _sizeCheckTimer = new();
private readonly ReaderWriterLockSlim _lockSlim = new();
@@ -136,7 +135,7 @@ public class BitBltCapture : IGameCapture
{
_lockSlim.EnterReadLock();
var result = Capture0();
- if (result is not null && !result.Empty())
+ if (result is not null)
{
// 成功截图
_lastCaptureFailed = false;
@@ -166,9 +165,9 @@ public class BitBltCapture : IGameCapture
/// 截图功能的实现。需要加锁后调用,一般只由 Capture 方法调用。
///
///
- private Mat? Capture0()
+ private Bitmap? Capture0()
{
- Mat? mat = null;
+ Bitmap? bitmap = null;
try
{
if (_session is null)
@@ -176,27 +175,14 @@ public class BitBltCapture : IGameCapture
// 没有成功创建会话,直接返回空
return null;
}
-
- mat = _session.GetMat();
-
- if (mat is null) return null; // 执行失败
- if (!mat.Empty()) // 成功执行并且获取到了图
- {
- return mat;
- }
- else // 成功执行但是没有图,可能是截图过快导致的
- {
- mat.Dispose();
- mat = null; // 防止二次释放
- }
-
- return null;
+ bitmap = _session.GetImage();
+ return bitmap;
}
catch (Exception e)
{
// 理论这里不应出现异常,除非窗口不存在了或者有什么bug
// 出现异常的时候释放内存
- mat?.Dispose();
+ bitmap?.Dispose();
Error.WriteLine("[BitBlt]Failed to capture image {0}", e);
return null;
}
diff --git a/Fischless.GameCapture/BitBlt/BitBltOldCapture.cs b/Fischless.GameCapture/BitBlt/BitBltOldCapture.cs
index c1c77325..64875683 100644
--- a/Fischless.GameCapture/BitBlt/BitBltOldCapture.cs
+++ b/Fischless.GameCapture/BitBlt/BitBltOldCapture.cs
@@ -7,8 +7,6 @@ public class BitBltOldCapture : IGameCapture
{
private nint _hWnd;
- public CaptureModes Mode => CaptureModes.BitBlt;
-
public static object LockObject { get; } = new();
public bool IsCapturing { get; private set; }
diff --git a/Fischless.GameCapture/BitBlt/BitBltSession.cs b/Fischless.GameCapture/BitBlt/BitBltSession.cs
index ad9dd01e..3714d6d1 100644
--- a/Fischless.GameCapture/BitBlt/BitBltSession.cs
+++ b/Fischless.GameCapture/BitBlt/BitBltSession.cs
@@ -160,10 +160,9 @@ public class BitBltSession : IDisposable
///
- /// 调用GDI复制到缓冲区并返回新的mat
+ /// 调用GDI复制到缓冲区并返回新Image
///
- /// MatType.CV_8UC3
- public Mat? GetMat()
+ public Bitmap? GetImage()
{
lock (_lockObject)
{
@@ -184,17 +183,18 @@ public class BitBltSession : IDisposable
return null;
}
+ // 这个是bitmap的结构信息,不用手动释放
+ if (bitmap.bmPlanes != 1 || bitmap.bmBitsPixel != 24)
+ // 不支持的位图格式
+ return null;
// 直接返回转换后的位图
var success = Gdi32.AlphaBlend(_hdcDest, 0, 0, _width, _height, _hdcSrc, 0, 0,
_width, _height, BlendFunction);
if (!success || !Gdi32.GdiFlush()) return null;
- // 这个是bitmap的结构信息,不用手动释放
- if (bitmap.bmPlanes != 1 || bitmap.bmBitsPixel != 24)
- // 不支持的位图格式
- return null;
- return Mat.FromPixelData(bitmap.bmHeight, bitmap.bmWidth, MatType.CV_8UC3, bitmap.bmBits,
- bitmap.bmWidthBytes);
+ // return Mat.FromPixelData(bitmap.bmHeight, bitmap.bmWidth, MatType.CV_8UC3, bitmap.bmBits,bitmap.bmWidthBytes);
+ return _hBitmap.ToBitmap();
+
// 原始宏 ((((biWidth * biBitCount) + 31) & ~31) >> 3) => (biWidth * biBitCount + 3) & ~3) (在总位数是8的倍数时,两者等价)
// 对齐 https://learn.microsoft.com/zh-cn/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader
diff --git a/Fischless.GameCapture/CaptureModes.cs b/Fischless.GameCapture/CaptureModes.cs
index 27b951c5..eeade079 100644
--- a/Fischless.GameCapture/CaptureModes.cs
+++ b/Fischless.GameCapture/CaptureModes.cs
@@ -4,11 +4,11 @@ namespace Fischless.GameCapture;
public enum CaptureModes
{
- [Description("BitBlt(稳定)")]
- BitBlt,
+ // [Description("BitBlt(稳定)")]
+ // BitBlt,
- [Description("BitBlt(极速)")]
- BitBltNew,
+ [Description("BitBlt")]
+ BitBlt,
[Description("WindowsGraphicsCapture")]
WindowsGraphicsCapture,
diff --git a/Fischless.GameCapture/DwmSharedSurface/SharedSurfaceCapture.cs b/Fischless.GameCapture/DwmSharedSurface/SharedSurfaceCapture.cs
index 27e4671d..0ca6ec43 100644
--- a/Fischless.GameCapture/DwmSharedSurface/SharedSurfaceCapture.cs
+++ b/Fischless.GameCapture/DwmSharedSurface/SharedSurfaceCapture.cs
@@ -22,7 +22,6 @@ namespace Fischless.GameCapture.DwmSharedSurface
private ResourceRegion? _region;
- public CaptureModes Mode => CaptureModes.DwmGetDxSharedSurface;
public void Start(nint hWnd, Dictionary? settings = null)
{
diff --git a/Fischless.GameCapture/GameCaptureFactory.cs b/Fischless.GameCapture/GameCaptureFactory.cs
index 36c4730e..5e3baa3a 100644
--- a/Fischless.GameCapture/GameCaptureFactory.cs
+++ b/Fischless.GameCapture/GameCaptureFactory.cs
@@ -11,8 +11,8 @@ public class GameCaptureFactory
{
return mode switch
{
- CaptureModes.BitBltNew => new BitBlt.BitBltCapture(),
- CaptureModes.BitBlt => new BitBlt.BitBltOldCapture(),
+ CaptureModes.BitBlt => 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),
diff --git a/Fischless.GameCapture/Graphics/GraphicsCapture.cs b/Fischless.GameCapture/Graphics/GraphicsCapture.cs
index e1c94ca2..8cb1b33f 100644
--- a/Fischless.GameCapture/Graphics/GraphicsCapture.cs
+++ b/Fischless.GameCapture/Graphics/GraphicsCapture.cs
@@ -24,7 +24,6 @@ public class GraphicsCapture : IGameCapture
private IDirect3DDevice _d3dDevice = null!;
- public CaptureModes Mode => CaptureModes.WindowsGraphicsCapture;
public bool IsCapturing { get; private set; }
private ResourceRegion? _region;
diff --git a/Fischless.GameCapture/IGameCapture.cs b/Fischless.GameCapture/IGameCapture.cs
index 38fe1564..07dbf145 100644
--- a/Fischless.GameCapture/IGameCapture.cs
+++ b/Fischless.GameCapture/IGameCapture.cs
@@ -4,7 +4,6 @@ namespace Fischless.GameCapture;
public interface IGameCapture : IDisposable
{
- public CaptureModes Mode { get; }
public bool IsCapturing { get; }
public void Start(nint hWnd, Dictionary? settings = null);