Files
better-genshin-impact/BetterGenshinImpact/Core/Config/AllConfig.cs
Takaranoao 5b3bac478d 升级多个依赖&增加额外的推理加速功能&迁移OCR (#1459)
* 更新多个NuGet包至最新版本

* 重构模型加载以适应yolosharp

* feat: 改变接口。TensorRT缓存的初步支持,修改配置项。

* 更新依赖并调整变量顺序,修复加载问题

* 更新AvalonEdit和Microsoft.ML.OnnxRuntime包至最新版本,以修复问题

* fix: downgrade Microsoft.ML.OnnxRuntime.DirectML to version 1.21.0

* typo

* fix: change log level from warning to error for ONNX provider loading failure

* 增加 paddle ocr 的 onnx 模型

* feat: add PaddleOCR models for Chinese, English, and Latin recognition

* 使用cv的DNN生成Tensor,加速Yap文字识别

* feat: 尝试搓一个onnx的ocr

* clean up code

* chore: update OpenCvSharp4 package versions to 4.10.0.20241108

* 修复因格式化代码而丢的引用

* chore: update Microsoft.ML.OnnxRuntime.DirectML package to version 1.21.1 and improve logging for ONNX provider initialization

* chore: 等yolosharp更新再升级onnx

* chore: add Microsoft.ML.OnnxRuntime.Managed package and clean up logging in Det class

* fix: refactor output tensor handling in Det class for improved clarity

* 补充注释,修复DML的OCR问题

* 默认OCR推理使用CPU,整理配置

* fix error NETSDK1152: 找到了多个具有相同相对路径的发布输出文件

* fix(logging): enhance debug log for ONNX initialization with provider details

* 修复TensorRT模型缓存的加载问题

* fix(onnx): improve cached model retrieval and add file existence check

* fix(ocr): replace SrcGreyMat with SrcMat for region of interest processing

* fix(onnx): add file existence check for cached model and adjust session options for DirectML provider

* 增加硬件加速配置UI界面

* 移除旧的OCR模型

* 错别字

---------

Co-authored-by: 辉鸭蛋 <huiyadanli@gmail.com>
2025-05-11 01:08:37 +08:00

248 lines
7.7 KiB
C#

using BetterGenshinImpact.GameTask;
using BetterGenshinImpact.GameTask.AutoCook;
using BetterGenshinImpact.GameTask.AutoDomain;
using BetterGenshinImpact.GameTask.AutoFight;
using BetterGenshinImpact.GameTask.AutoFishing;
using BetterGenshinImpact.GameTask.AutoGeniusInvokation;
using BetterGenshinImpact.GameTask.AutoPick;
using BetterGenshinImpact.GameTask.AutoSkip;
using BetterGenshinImpact.GameTask.AutoWood;
using BetterGenshinImpact.GameTask.AutoMusicGame;
using BetterGenshinImpact.GameTask.QuickTeleport;
using BetterGenshinImpact.Service.Notification;
using CommunityToolkit.Mvvm.ComponentModel;
using Fischless.GameCapture;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using BetterGenshinImpact.GameTask.AutoTrackPath;
using BetterGenshinImpact.GameTask.AutoArtifactSalvage;
namespace BetterGenshinImpact.Core.Config;
/// <summary>
/// 更好的原神配置
/// </summary>
[Serializable]
public partial class AllConfig : ObservableObject
{
/// <summary>
/// 窗口捕获的方式
/// </summary>
[ObservableProperty]
private string _captureMode = CaptureModes.BitBlt.ToString();
/// <summary>
/// 详细的错误日志
/// </summary>
[ObservableProperty]
private bool _detailedErrorLogs;
/// <summary>
/// 不展示新版本提示的最新版本
/// </summary>
[ObservableProperty]
private string _notShowNewVersionNoticeEndVersion = "";
/// <summary>
/// 触发器触发频率(ms)
/// </summary>
[ObservableProperty]
private int _triggerInterval = 50;
// /// <summary>
// /// WGC使用位图缓存
// /// 高帧率情况下,可能会导致卡顿
// /// 云原神可能会出现黑屏
// /// </summary>
// [ObservableProperty]
// private bool _wgcUseBitmapCache = true;
/// <summary>
/// 自动修复Win11下BitBlt截图方式不可用的问题
/// </summary>
[ObservableProperty]
private bool _autoFixWin11BitBlt = true;
// /// <summary>
// /// 推理使用的设备
// /// </summary>
// [ObservableProperty]
// private string _inferenceDevice = "CPU";
[ObservableProperty]
private List<ValueTuple<string, int, string, string>> _nextScheduledTask = [];
/// <summary>
/// 一条龙选中使用的配置
/// </summary>
[ObservableProperty]
private string _selectedOneDragonFlowConfigName = string.Empty;
/// <summary>
/// 遮罩窗口配置
/// </summary>
public MaskWindowConfig MaskWindowConfig { get; set; } = new();
/// <summary>
/// 通用配置
/// </summary>
public CommonConfig CommonConfig { get; set; } = new();
/// <summary>
/// 原神启动配置
/// </summary>
public GenshinStartConfig GenshinStartConfig { get; set; } = new();
/// <summary>
/// 自动拾取配置
/// </summary>
public AutoPickConfig AutoPickConfig { get; set; } = new();
/// <summary>
/// 自动剧情配置
/// </summary>
public AutoSkipConfig AutoSkipConfig { get; set; } = new();
/// <summary>
/// 自动钓鱼配置
/// </summary>
public AutoFishingConfig AutoFishingConfig { get; set; } = new();
/// <summary>
/// 快速传送配置
/// </summary>
public QuickTeleportConfig QuickTeleportConfig { get; set; } = new();
/// <summary>
/// 自动烹饪配置
/// </summary>
public AutoCookConfig AutoCookConfig { get; set; } = new();
/// <summary>
/// 自动打牌配置
/// </summary>
public AutoGeniusInvokationConfig AutoGeniusInvokationConfig { get; set; } = new();
/// <summary>
/// 自动伐木配置
/// </summary>
public AutoWoodConfig AutoWoodConfig { get; set; } = new();
/// <summary>
/// 自动战斗配置
/// </summary>
public AutoFightConfig AutoFightConfig { get; set; } = new();
/// <summary>
/// 自动乐曲配置 - 千音雅集
/// </summary>
public AutoMusicGameConfig AutoMusicGameConfig { get; set; } = new();
/// <summary>
/// 自动秘境配置
/// </summary>
public AutoDomainConfig AutoDomainConfig { get; set; } = new();
/// <summary>
/// 自动分解圣遗物配置
/// </summary>
public AutoArtifactSalvageConfig AutoArtifactSalvageConfig { get; set; } = new();
/// <summary>
/// 宏配置
/// </summary>
public MacroConfig MacroConfig { get; set; } = new();
public RecordConfig RecordConfig { get; set; } = new();
/// <summary>
/// 脚本配置
/// </summary>
public ScriptConfig ScriptConfig { get; set; } = new();
/// <summary>
/// 地图追踪配置
/// </summary>
public PathingConditionConfig PathingConditionConfig { get; set; } = PathingConditionConfig.Default;
/// <summary>
/// 快捷键配置
/// </summary>
public HotKeyConfig HotKeyConfig { get; set; } = new();
/// <summary>
/// 通知配置
/// </summary>
public NotificationConfig NotificationConfig { get; set; } = new();
/// <summary>
/// 原神按键绑定配置
/// </summary>
public KeyBindingsConfig KeyBindingsConfig { get; set; } = new();
/// <summary>
/// 其他配置
/// </summary>
public OtherConfig OtherConfig { get; set; } = new();
/// <summary>
/// 传送相关配置
/// </summary>
public TpConfig TpConfig { get; set; } = new();
/// <summary>
/// 开发者配置
/// </summary>
public DevConfig DevConfig { get; set; } = new();
/// <summary>
/// 硬件加速设置
/// </summary>
public HardwareAccelerationConfig HardwareAccelerationConfig { get; set; } = new();
[JsonIgnore]
public Action? OnAnyChangedAction { get; set; }
public void InitEvent()
{
PropertyChanged += OnAnyPropertyChanged;
MaskWindowConfig.PropertyChanged += OnAnyPropertyChanged;
CommonConfig.PropertyChanged += OnAnyPropertyChanged;
GenshinStartConfig.PropertyChanged += OnAnyPropertyChanged;
NotificationConfig.PropertyChanged += OnAnyPropertyChanged;
NotificationConfig.PropertyChanged += OnNotificationPropertyChanged;
KeyBindingsConfig.PropertyChanged += OnAnyPropertyChanged;
AutoPickConfig.PropertyChanged += OnAnyPropertyChanged;
AutoSkipConfig.PropertyChanged += OnAnyPropertyChanged;
AutoFishingConfig.PropertyChanged += OnAnyPropertyChanged;
QuickTeleportConfig.PropertyChanged += OnAnyPropertyChanged;
AutoCookConfig.PropertyChanged += OnAnyPropertyChanged;
MacroConfig.PropertyChanged += OnAnyPropertyChanged;
HotKeyConfig.PropertyChanged += OnAnyPropertyChanged;
AutoWoodConfig.PropertyChanged += OnAnyPropertyChanged;
AutoFightConfig.PropertyChanged += OnAnyPropertyChanged;
AutoDomainConfig.PropertyChanged += OnAnyPropertyChanged;
AutoArtifactSalvageConfig.PropertyChanged += OnAnyPropertyChanged;
AutoMusicGameConfig.PropertyChanged += OnAnyPropertyChanged;
TpConfig.PropertyChanged += OnAnyPropertyChanged;
ScriptConfig.PropertyChanged += OnAnyPropertyChanged;
PathingConditionConfig.PropertyChanged += OnAnyPropertyChanged;
DevConfig.PropertyChanged += OnAnyPropertyChanged;
HardwareAccelerationConfig.PropertyChanged += OnAnyPropertyChanged;
}
public void OnAnyPropertyChanged(object? sender, EventArgs args)
{
GameTaskManager.RefreshTriggerConfigs();
OnAnyChangedAction?.Invoke();
}
public void OnNotificationPropertyChanged(object? sender, PropertyChangedEventArgs args)
{
NotificationService.Instance().RefreshNotifiers();
}
}