mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-21 09:45:48 +08:00
清理无用的截图器模式
This commit is contained in:
@@ -153,6 +153,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="GameTask\Model\Enum\" />
|
||||
<Folder Include="GameTask\OneDragon\" />
|
||||
<Folder Include="Service\Notification\Builder\" />
|
||||
<Folder Include="User\AutoPathing\" />
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
// using BetterGenshinImpact.GameTask.Common.Map;
|
||||
// using BetterGenshinImpact.GameTask.Model.Area;
|
||||
// using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
//
|
||||
// using BetterGenshinImpact.View.Drawable;
|
||||
// using BetterGenshinImpact.ViewModel.Pages;
|
||||
// using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -4,10 +4,8 @@ using BetterGenshinImpact.ViewModel.Pages;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoDomain;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoFishing;
|
||||
using BetterGenshinImpact.GameTask.AutoWood;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Script;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using BetterGenshinImpact.Model;
|
||||
using BetterGenshinImpact.Service;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -128,14 +128,6 @@ public class OneKeyFightTask : Singleton<OneKeyFightTask>
|
||||
/// </summary>
|
||||
private Task FightTask(CancellationToken ct)
|
||||
{
|
||||
// 切换截图模式
|
||||
var dispatcherCaptureMode = TaskTriggerDispatcher.Instance().GetCacheCaptureMode();
|
||||
if (dispatcherCaptureMode != DispatcherCaptureModeEnum.CacheCaptureWithTrigger)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.CacheCaptureWithTrigger);
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 2, ct); // 等待缓存图像
|
||||
}
|
||||
|
||||
var imageRegion = CaptureToRectArea();
|
||||
var combatScenes = new CombatScenes().InitializeTeam(imageRegion);
|
||||
if (!combatScenes.CheckTeamInitialized())
|
||||
|
||||
@@ -9,7 +9,7 @@ using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using BetterGenshinImpact.Helpers.Extensions;
|
||||
using BetterGenshinImpact.Service;
|
||||
@@ -87,7 +87,6 @@ public class AutoTrackPathTask
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.NormalTrigger);
|
||||
Logger.LogInformation("→ {Text}", "自动路线结束");
|
||||
|
||||
if (hasLock)
|
||||
@@ -101,8 +100,6 @@ public class AutoTrackPathTask
|
||||
{
|
||||
SystemControl.ActivateWindow();
|
||||
Logger.LogInformation("→ {Text}", "自动路线,启动!");
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.OnlyCacheCapture);
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 5, _ct); // 等待缓存图像
|
||||
}
|
||||
|
||||
public async Task DoTask()
|
||||
|
||||
@@ -4,7 +4,7 @@ using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath.Model;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using BetterGenshinImpact.Helpers.Extensions;
|
||||
using BetterGenshinImpact.Model;
|
||||
using BetterGenshinImpact.Service;
|
||||
@@ -34,16 +34,12 @@ public class PathPointRecorder : Singleton<PathPointRecorder>
|
||||
{
|
||||
if (_recordTask == null)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.OnlyCacheCapture);
|
||||
|
||||
_recordTaskCts = new CancellationTokenSource();
|
||||
_recordTask = RecordTask(_recordTaskCts.Token);
|
||||
_recordTask.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.NormalTrigger);
|
||||
|
||||
_recordTaskCts?.Cancel();
|
||||
_recordTask = null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Model;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
namespace BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
/// <summary>
|
||||
/// 调度器捕获模式, 影响以下内容:
|
||||
/// 1. 是否缓存图像
|
||||
/// 2. 是否执行触发器
|
||||
/// </summary>
|
||||
public enum DispatcherCaptureModeEnum
|
||||
{
|
||||
// 正常运行调度器
|
||||
NormalTrigger,
|
||||
|
||||
// 正常运行调度器,但不执行触发器,仅捕获并缓存图像模式
|
||||
OnlyCacheCapture,
|
||||
|
||||
// 正常运行调度器,捕获并缓存图像模式,并执行触发器
|
||||
CacheCaptureWithTrigger,
|
||||
|
||||
// --------------------------------------------
|
||||
// 下面两个模式无法直接设置,只能通过调度器的 StartTimer 和 StopTimer 方法来设置
|
||||
|
||||
// 停止运行整个调度器
|
||||
Stop,
|
||||
|
||||
// 启动整个调度器
|
||||
Start,
|
||||
|
||||
// --------------------------------------------
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// namespace BetterGenshinImpact.GameTask.Model.Enum;
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 存在触发器运行的情况下,优先使用触发器的缓存图像
|
||||
// /// 此枚举会影响调度器使用的 DispatcherCaptureModeEnum 模式
|
||||
// /// </summary>
|
||||
// public enum DispatcherTimerOperationEnum
|
||||
// {
|
||||
// // 关闭实时触发器,自己主动获取图像
|
||||
// UseSelfCaptureImage,
|
||||
//
|
||||
// // 使用实时触发器的缓存图模式,但是不执行触发器
|
||||
// UseCacheImage,
|
||||
//
|
||||
// // 使用实时触发器的缓存图模式,并执行触发器
|
||||
// UseCacheImageWithTrigger,
|
||||
//
|
||||
// // 使用实时触发器的缓存图模式,并清空当前已有触发器,执行触发器
|
||||
// // 清空触发器是为了让js脚本手动添加触发器
|
||||
// UseCacheImageWithTriggerEmpty,
|
||||
//
|
||||
// // 不做任何操作
|
||||
// None
|
||||
// }
|
||||
@@ -1,6 +1,6 @@
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using BetterGenshinImpact.View;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -134,27 +134,6 @@ public class TaskRunner
|
||||
var maskWindow = MaskWindow.Instance();
|
||||
SystemControl.ActivateWindow();
|
||||
maskWindow.Invoke(maskWindow.Show);
|
||||
// if (_timerOperation == DispatcherTimerOperationEnum.UseSelfCaptureImage)
|
||||
// {
|
||||
// Thread.Sleep(TaskContext.Instance().Config.TriggerInterval * 5); // 等待日志窗口被激活
|
||||
// TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.Stop);
|
||||
// }
|
||||
// else if (_timerOperation == DispatcherTimerOperationEnum.UseCacheImage)
|
||||
// {
|
||||
// TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.OnlyCacheCapture);
|
||||
// Thread.Sleep(TaskContext.Instance().Config.TriggerInterval * 5); // 等待缓存图像
|
||||
// }
|
||||
// else if (_timerOperation == DispatcherTimerOperationEnum.UseCacheImageWithTrigger)
|
||||
// {
|
||||
// TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.CacheCaptureWithTrigger);
|
||||
// Thread.Sleep(TaskContext.Instance().Config.TriggerInterval * 5); // 等待缓存图像
|
||||
// }
|
||||
// else if (_timerOperation == DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty)
|
||||
// {
|
||||
// TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.CacheCaptureWithTrigger);
|
||||
// TaskTriggerDispatcher.Instance().ClearTriggers();
|
||||
// Thread.Sleep(TaskContext.Instance().Config.TriggerInterval * 5); // 等待缓存图像
|
||||
// }
|
||||
}
|
||||
|
||||
public void End()
|
||||
@@ -165,27 +144,6 @@ public class TaskRunner
|
||||
}
|
||||
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
// if (_timerOperation == DispatcherTimerOperationEnum.UseSelfCaptureImage)
|
||||
// {
|
||||
// TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.Start);
|
||||
// }
|
||||
// else if (_timerOperation is DispatcherTimerOperationEnum.UseCacheImage or DispatcherTimerOperationEnum.UseCacheImageWithTrigger or DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty)
|
||||
// {
|
||||
// // 还原到原来的模式
|
||||
// if (TaskContext.Instance().Config.CommonConfig.ScreenshotEnabled || TaskContext.Instance().Config.MacroConfig.CombatMacroEnabled)
|
||||
// {
|
||||
// TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.CacheCaptureWithTrigger);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.NormalTrigger);
|
||||
// }
|
||||
//
|
||||
// if (_timerOperation == DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty)
|
||||
// {
|
||||
// TaskTriggerDispatcher.Instance().SetTriggers(GameTaskManager.LoadInitialTriggers());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using BetterGenshinImpact.View;
|
||||
using Fischless.GameCapture;
|
||||
@@ -36,13 +36,6 @@ namespace BetterGenshinImpact.GameTask
|
||||
|
||||
private DateTime _prevManualGc = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// 调度器捕获模式, 影响以下内容:
|
||||
/// 1. 是否缓存图像
|
||||
/// 2. 是否执行触发器
|
||||
/// </summary>
|
||||
private DispatcherCaptureModeEnum _dispatcherCacheCaptureMode = DispatcherCaptureModeEnum.NormalTrigger;
|
||||
|
||||
private static readonly object _triggerListLocker = new();
|
||||
|
||||
public event EventHandler? UiTaskStopTickEvent;
|
||||
@@ -132,13 +125,7 @@ namespace BetterGenshinImpact.GameTask
|
||||
{ "autoFixWin11BitBlt", OsVersionHelper.IsWindows11_OrGreater && TaskContext.Instance().Config.AutoFixWin11BitBlt }
|
||||
}
|
||||
);
|
||||
|
||||
// 捕获模式初始化配置
|
||||
if (TaskContext.Instance().Config.CommonConfig.ScreenshotEnabled || TaskContext.Instance().Config.MacroConfig.CombatMacroEnabled)
|
||||
{
|
||||
_dispatcherCacheCaptureMode = DispatcherCaptureModeEnum.CacheCaptureWithTrigger;
|
||||
}
|
||||
|
||||
|
||||
// 启动定时器
|
||||
_frameIndex = 0;
|
||||
_timer.Interval = interval;
|
||||
@@ -384,27 +371,6 @@ namespace BetterGenshinImpact.GameTask
|
||||
{
|
||||
return rect.Width == 0 || rect.Height == 0;
|
||||
}
|
||||
|
||||
public void SetCacheCaptureMode(DispatcherCaptureModeEnum mode)
|
||||
{
|
||||
// if (mode is DispatcherCaptureModeEnum.Start)
|
||||
// {
|
||||
// this.StartTimer();
|
||||
// }
|
||||
// else if (mode is DispatcherCaptureModeEnum.Stop)
|
||||
// {
|
||||
// this.StopTimer();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _dispatcherCacheCaptureMode = mode;
|
||||
// }
|
||||
}
|
||||
|
||||
public DispatcherCaptureModeEnum GetCacheCaptureMode()
|
||||
{
|
||||
return _dispatcherCacheCaptureMode;
|
||||
}
|
||||
|
||||
public void TakeScreenshot()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using BetterGenshinImpact.Core.Script.Group;
|
||||
using BetterGenshinImpact.Core.Script.Project;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using BetterGenshinImpact.View.Pages;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
@@ -164,13 +163,6 @@ public partial class CommonSettingsPageViewModel : ViewModel
|
||||
[RelayCommand]
|
||||
public void OnSwitchTakenScreenshotEnabled()
|
||||
{
|
||||
if (Config.CommonConfig.ScreenshotEnabled)
|
||||
{
|
||||
if (TaskTriggerDispatcher.Instance().GetCacheCaptureMode() == DispatcherCaptureModeEnum.NormalTrigger)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.CacheCaptureWithTrigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using BetterGenshinImpact.Core.Recorder;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.Model;
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using BetterGenshinImpact.View.Windows;
|
||||
|
||||
@@ -15,7 +15,7 @@ using BetterGenshinImpact.Core.Script.Group;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common.Job;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using BetterGenshinImpact.Service;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
|
||||
@@ -23,7 +23,7 @@ using System.Threading.Tasks;
|
||||
using Windows.System;
|
||||
using BetterGenshinImpact.GameTask.AutoFishing;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
Reference in New Issue
Block a user