Compare commits

...
Author SHA1 Message Date
辉鸭蛋 0c8210c3b5 调整置信度 2026-04-19 01:23:41 +08:00
辉鸭蛋 ad4125510b 修改输入 2026-04-19 01:19:08 +08:00
辉鸭蛋 ffd87f2b11 删掉debug日志 2026-04-19 01:03:03 +08:00
辉鸭蛋 dca422de8e init 2026-04-19 00:32:33 +08:00
辉鸭蛋 2ea663b0ff #3054 越界逻辑错误修复 2026-04-16 23:57:57 +08:00
huiyadanli bbf1be3de9 Update version to 0.60.2-alpha.1 2026-04-16 15:40:56 +00:00
kaedelcb 3586e37c69 战斗过程卡切换角色优化 (#3054) 2026-04-16 23:37:52 +08:00
辉鸭蛋 4896d0344a fix(AutoEat): 将复活按键改为跟随快捷使用小道具键位 #2930
复活逻辑不再硬编码为Z键,改为使用`GIActions.QuickUseGadget`模拟输入,使其与游戏内的“快捷使用小道具”键位配置保持一致。
2026-04-16 00:55:28 +08:00
辉鸭蛋 c1d0a53110 OCR不再限制算子 2026-04-16 00:30:21 +08:00
辉鸭蛋 0eedfb6969 实时任务中对遮罩的操作异步化 2026-04-16 00:29:56 +08:00
LXYan2333 d0c02717e8 胡桃 10aaz 宏 (#3049) 2026-04-15 23:34:37 +08:00
kaedelcb 2a53fb9742 新增基于怪物死亡经验判断是否执行聚集材料 (#3051) 2026-04-15 23:34:07 +08:00
ShadowLemoon bd8451a190 perf: 增强幽境任务鲁棒性 (#3050) 2026-04-15 23:33:28 +08:00
辉鸭蛋 ee500b2971 Update OpenAI model version in repo-bot.yml 2026-04-15 11:20:56 +08:00
Yushao Chen (Jerry)andJerryChen97 b0a1715ba3 fix: 移除 TrySwitch 中遗留的调试用 SaveImage 调用 (#3032)
Co-authored-by: JerryChen97 <[email protected]>
2026-04-12 21:57:00 +08:00
ddaodan 33760242ea feat: 地脉花新增"蒙德8-风车镇"路径 (#3029) 2026-04-12 21:56:30 +08:00
Yushao Chen (Jerry)andJerryChen97 7d91fba327 fix: FindActiveIndexRectByColor 方法3 返回 0-based 索引修正为 1-based (#3035)
Co-authored-by: JerryChen97 <[email protected]>
2026-04-12 21:54:16 +08:00
Jamis 8956c306c2 增加支持新地图空之神殿 (#3041) 2026-04-12 21:52:53 +08:00
ddaodan a7dac95468 优化 GitHub Issue 模板 (#3030) 2026-04-11 18:47:25 +08:00
huiyadanli dea40ce177 Update version to 0.60.1 2026-04-09 16:18:49 +00:00
辉鸭蛋 410c3f2a92 处理 Paddle OCR 逻辑可能造成的 JSON 序列化问题 2026-04-10 00:03:19 +08:00
ema 30d11bed4c 替换修复秘境选择控件 (#3019) 2026-04-09 23:21:35 +08:00
郝凯阳 cfebcd0b8d auto tcg: update character card config to v6.5 (#3016) 2026-04-09 18:08:57 +08:00
Jamis 43f2263cfa 增加空之神殿TP点位信息 (#3015) 2026-04-09 18:08:45 +08:00
57 changed files with 3468 additions and 1982 deletions

No files matched your search

+41 -8
View File
@@ -4,12 +4,23 @@ title: "[bug] "
labels:
- BUG
body:
- type: checkboxes
id: checks
attributes:
label: 提交确认 / Checklist
description: Checklist before submitting
options:
- label: 我已经搜索过现有 issue,确认这不是重复问题 / I have searched existing issues and confirmed this is not a duplicate
required: true
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem"
required: true
- label: 我愿意为了解决这个问题尽自己所能 / I am willing to do my part to help resolve this issue
- type: textarea
id: environment
attributes:
label: 系统环境
description: System Environment,例如系统版本、运行环境
placeholder: Win11 / BetterGI 0.58.0 / .NET 8
description: System environment,例如操作系统版本、运行时版本、显卡驱动版本
placeholder: Windows 11 24H2 (26100.3775) / .NET Desktop Runtime 8.0.15 / NVIDIA 572.83
validations:
required: true
- type: input
@@ -17,15 +28,23 @@ body:
attributes:
label: BetterGI 版本号
description: BetterGI Version
placeholder: 0.58.0
placeholder: e.g. 0.58.0
validations:
required: true
- type: textarea
id: description
attributes:
label: 问题描述
description: Description of the issue
placeholder: 请详细描述你遇到的问题,可直接粘贴日志并附带截图
description: Describe the actual behavior and impact
placeholder: 请描述实际出现的问题,以及这个问题对使用造成了什么影响 / Describe the actual behavior and impact
validations:
required: true
- type: textarea
id: expected
attributes:
label: 期望结果
description: Expected behavior
placeholder: 请描述你期望出现的正确行为或结果 / Describe the expected behavior or result
validations:
required: true
- type: textarea
@@ -34,8 +53,22 @@ body:
label: 复现步骤
description: Reproduction steps
placeholder: |-
1. 打开……
2. 点击……
3. 出现……
1. 打开…… / Open ...
2. 点击…… / Click ...
3. 出现…… / Observe ...
validations:
required: true
- type: textarea
id: logs
attributes:
label: 日志与附件
description: Logs and attachments,可直接拖拽上传日志文件、压缩包、截图或视频
placeholder: |-
可在这里补充日志和附件说明 / Add logs and attachment notes here:
- 可直接粘贴关键日志片段 / Paste key log snippets directly
- 可拖拽上传日志文件或压缩包 / Drag and drop log files or archives
- 可拖拽上传截图、录屏或演示视频 / Drag and drop screenshots or videos
- 若附件较多,请说明对应的时间点、任务名称或异常现象 / If there are many files, explain the relevant timestamps or symptoms
- 提交前请注意移除账号、路径等隐私信息 / Remove private information before submitting
validations:
required: false
+2 -2
View File
@@ -1,9 +1,9 @@
blank_issues_enabled: false
contact_links:
- name: 官方文档 / Document
url: https://bgi.huiyadan.com/doc.html
url: https://www.bettergi.com/doc.html
about: 请在提出问题前阅读文档 / Read the document before submit the issue
- name: 常见问题 / FAQ
url: https://bgi.huiyadan.com/faq.html
url: https://www.bettergi.com/faq.html
about: 常见的用户提出的问题 / Common questions asked by users
+25 -3
View File
@@ -4,12 +4,26 @@ title: "[feature] "
labels:
- 功能建议
body:
- type: checkboxes
id: checks
attributes:
label: 提交确认 / Checklist
description: Please confirm the following before submitting
options:
- label: 我已经搜索过现有 issue,确认这不是重复建议 / I have searched existing issues and confirmed this is not a duplicate request
required: true
- label: 我已确认当前版本中尚未提供该功能,或至少没有等价实现 / I have confirmed this feature, or an equivalent one, is not already available in the current version
required: true
- label: 我认为这个需求能为更多用户带来明确收益,而不仅仅是个人偏好 / I believe this request provides clear value to a broader group of users, not just my personal preference
required: true
- label: 我理解这个需求可能因实现成本、维护成本或项目方向而暂不采纳 / I understand this request may not be accepted due to implementation cost, maintenance cost, or project direction
required: true
- type: textarea
id: request
attributes:
label: 功能请求
description: Feature Request
placeholder: 请简要说明你希望新增什么能力
placeholder: 请简要说明你希望新增什么能力 / Briefly describe the capability you want to add
validations:
required: true
- type: textarea
@@ -17,7 +31,15 @@ body:
attributes:
label: 使用场景
description: Use Case
placeholder: 这个功能要解决什么问题?在哪些场景下使用?
placeholder: 这个功能要解决什么问题?在哪些场景下使用? / What problem does this feature solve, and when would it be used?
validations:
required: true
- type: textarea
id: impact
attributes:
label: 潜在影响
description: Potential Impact
placeholder: 请说明这个功能是否可能带来新的问题、维护成本、使用门槛或兼容性影响;如果没有,请填写“无” / Describe any potential downsides such as new issues, maintenance cost, usability barriers, or compatibility impact. Write "None" if there are no obvious downsides.
validations:
required: true
- type: textarea
@@ -25,6 +47,6 @@ body:
attributes:
label: 补充信息
description: Optional
placeholder: 可选,补充示意图、参考方案或限制条件
placeholder: "可选,补充示意图、交互草图、参考链接或相关背景信息 / Optional: add mockups, interaction sketches, reference links, or other background information"
validations:
required: false
+11 -1
View File
@@ -2,11 +2,21 @@ name: Feel free to express / 自由描述
description: 记录你想反馈的内容 / Share general feedback
title: "[feedback] "
body:
- type: checkboxes
id: checks
attributes:
label: 提交确认 / Checklist
description: Please confirm the following before submitting
options:
- label: 我已经搜索过现有 issue,确认这不是重复反馈 / I have searched existing issues and confirmed this is not duplicate feedback
required: true
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题或覆盖我的反馈 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem or cover my feedback"
required: true
- type: textarea
id: description
attributes:
label: 描述
description: Description
placeholder: 请描述你想反馈的内容
placeholder: 请描述你想反馈的内容 / Describe what you want to share
validations:
required: true
+12 -2
View File
@@ -4,12 +4,22 @@ title: "[question] "
labels:
- 问题咨询
body:
- type: checkboxes
id: checks
attributes:
label: 提交确认 / Checklist
description: Please confirm the following before submitting
options:
- label: 我已经搜索过现有 issue,确认这不是重复问题 / I have searched existing issues and confirmed this is not a duplicate question
required: true
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem"
required: true
- type: textarea
id: question
attributes:
label: 问题描述
description: Problem Description
placeholder: 请清楚描述你的问题
placeholder: 请清楚描述你的问题 / Clearly describe your question
validations:
required: true
- type: textarea
@@ -17,6 +27,6 @@ body:
attributes:
label: 已尝试内容
description: Screenshots / logs / what you already tried
placeholder: 可附上截图、日志,以及你已经尝试过的排查过程
placeholder: 可附上截图、日志,以及你已经尝试过的排查过程 / Add screenshots, logs, and what you have already tried
validations:
required: true
+12 -2
View File
@@ -4,12 +4,22 @@ title: "[suggestion] "
labels:
- 功能建议
body:
- type: checkboxes
id: checks
attributes:
label: 提交确认 / Checklist
description: Please confirm the following before submitting
options:
- label: 我已经搜索过现有 issue,确认这不是重复建议 / I have searched existing issues and confirmed this is not a duplicate suggestion
required: true
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题或覆盖我的建议 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem or cover my suggestion"
required: true
- type: textarea
id: suggestion
attributes:
label: 建议内容
description: Suggestion
placeholder: 请描述你的建议内容
placeholder: 请描述你的建议内容 / Describe your suggestion
validations:
required: true
- type: textarea
@@ -17,6 +27,6 @@ body:
attributes:
label: 预期收益
description: Expected Benefit
placeholder: 这个建议会给用户或项目带来什么帮助?
placeholder: 这个建议会给用户或项目带来什么帮助? / What benefits would this suggestion bring to users or the project?
validations:
required: true
+1 -1
View File
@@ -6,7 +6,7 @@ providers:
openAiCompatible:
enabled: true
baseUrl: https://api.openai.com/v1
model: gpt-5.2-codex
model: gpt-5.4
apiStyle: responses
timeoutMs: 30000
+1
View File
@@ -17,6 +17,7 @@
<FontFamily x:Key="TextThemeFontFamily">/Resources/Fonts/MiSans-Regular.ttf#MiSans</FontFamily>
<FontFamily x:Key="DigitalThemeFontFamily">/Resources/Fonts/deluge-led.ttf#Deluge LED</FontFamily>
<bgivc:DomainNameToCascadingItemConverter x:Key="DomainNameConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<bgivc:BooleanToVisibilityRevertConverter x:Key="BooleanToVisibilityRevertConverter" />
<bgivc:BooleanToEnableTextConverter x:Key="BooleanToEnableTextConverter" />
@@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyName>BetterGI</AssemblyName>
<Version>0.60.0</Version>
<Version>0.60.2-alpha.1</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
@@ -95,7 +95,7 @@
<PackageReference Include="WPF-UI" Version="4.2.0" />
<PackageReference Include="WPF-UI.DependencyInjection" Version="4.2.0" />
<PackageReference Include="WPF-UI.Tray" Version="4.2.0" />
<PackageReference Include="WPF-UI.Violeta" Version="4.2.0.1" />
<PackageReference Include="WPF-UI.Violeta" Version="4.2.0.10" />
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
<PackageReference Include="YoloSharp" Version="6.0.3" />
@@ -2,7 +2,6 @@ using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using BetterGenshinImpact.Core.Recognition.OCR.Engine;
using BetterGenshinImpact.Core.Recognition.OCR.Engine.data;
@@ -153,46 +152,46 @@ public class Rec(
{
var resultArray = resultTensor.Item2;
var resultShape = resultTensor.Item1;
GCHandle dataHandle = default;
try
{
dataHandle = GCHandle.Alloc(resultArray, GCHandleType.Pinned);
var dataPtr = dataHandle.AddrOfPinnedObject();
var labelCount = resultShape[2];
var charCount = resultShape[1];
var labelCount = resultShape[2];
var charCount = resultShape[1];
return Enumerable.Range(0, resultShape[0])
.Select(i =>
return Enumerable.Range(0, resultShape[0])
.Select(i =>
{
StringBuilder sb = new();
var lastIndex = 0;
float score = 0;
var batchOffset = i * charCount * labelCount;
for (var n = 0; n < charCount; ++n)
{
StringBuilder sb = new();
var lastIndex = 0;
float score = 0;
for (var n = 0; n < charCount; ++n)
var rowOffset = batchOffset + n * labelCount;
var maxVal = float.MinValue;
var maxIndex = 0;
for (var c = 0; c < labelCount; c++)
{
using var mat = Mat.FromPixelData(1, labelCount, MatType.CV_32FC1,
dataPtr + (n + i * charCount) * labelCount * sizeof(float));
var maxIdx = new int[2];
mat.MinMaxIdx(out _, out var maxVal, [], maxIdx);
if (maxIdx[1] > 0 && !(n > 0 && maxIdx[1] == lastIndex))
var value = resultArray[rowOffset + c];
if (value > maxVal)
{
score += (float)maxVal;
sb.Append(OcrUtils.GetLabelByIndex(maxIdx[1], labels));
maxVal = value;
maxIndex = c;
}
lastIndex = maxIdx[1];
}
return new OcrRecognizerResult(sb.ToString(), score / sb.Length);
})
.ToArray();
}
finally
{
dataHandle.Free();
}
if (maxIndex > 0 && !(n > 0 && maxIndex == lastIndex))
{
score += maxVal;
sb.Append(OcrUtils.GetLabelByIndex(maxIndex, labels));
}
lastIndex = maxIndex;
}
var text = sb.ToString();
return new OcrRecognizerResult(text, text.Length > 0 ? score / text.Length : 0);
})
.ToArray();
}).ToArray();
}
public string GetConfigName => config.Name;
}
}
@@ -311,6 +311,17 @@ public class BgiOnnxFactory
: new BgiYoloPredictor(model, cached, CreateSessionOptions(model, false));
}
/// <summary>
/// 根据模型创建一个 RedNet 分类预测器
/// </summary>
/// <param name="model">模型</param>
/// <param name="labelRelativePath">标签文件相对路径,可选,支持 .txt/.json</param>
/// <returns>BgiRedNetPredictor</returns>
public BgiRedNetPredictor CreateRedNetPredictor(BgiOnnxModel model, string? labelRelativePath = null)
{
return new BgiRedNetPredictor(model, CreateInferenceSession(model), labelRelativePath);
}
/// <summary>
/// 根据模型创建一个onnx运行时的InferenceSession
/// </summary>
@@ -407,11 +418,11 @@ public class BgiOnnxFactory
break;
case ProviderType.Cpu:
sessionOptions.AppendExecutionProvider_CPU();
if (model.Name.Contains("PpOcr") || model.Name.Contains("Yap"))
{
sessionOptions.IntraOpNumThreads = 2; // 限制算子内部并行线程数
sessionOptions.InterOpNumThreads = 1; // 限制算子间并行线程数(顺序执行)
}
// if (model.Name.Contains("PpOcr") || model.Name.Contains("Yap"))
// {
// sessionOptions.IntraOpNumThreads = 2; // 限制算子内部并行线程数
// sessionOptions.InterOpNumThreads = 1; // 限制算子间并行线程数(顺序执行)
// }
break;
case ProviderType.Dnnl:
sessionOptions.AppendExecutionProvider_Dnnl();
@@ -582,4 +593,4 @@ public class BgiOnnxFactory
result["enable_opencl_throttling"] = "true";
return result;
}
}
}
@@ -50,6 +50,12 @@ public class BgiOnnxModel
public static readonly BgiOnnxModel BgiAvatarSide =
Register("BgiAvatarSide", @"Assets\Model\Common\avatar_side_classify_sim.onnx");
/// <summary>
/// 角色识别(RedNet-110)
/// </summary>
public static readonly BgiOnnxModel BgiPickRedNet110 =
Register("BgiPickRedNet110", @"Assets\Model\Common\resnet_pick.onnx");
/// <summary>
/// paddleOCR V4 检测模型
/// </summary>
@@ -139,4 +145,4 @@ public class BgiOnnxModel
RegisteredModels.Add(model);
return model;
}
}
}
@@ -0,0 +1,157 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using Microsoft.ML.OnnxRuntime;
using Microsoft.ML.OnnxRuntime.Tensors;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
namespace BetterGenshinImpact.Core.Recognition.ONNX;
public sealed class BgiRedNetPredictor : IDisposable
{
private const int DefaultInputSize = 224;
private static readonly float[] ImagenetMean = [0.485f, 0.456f, 0.406f];
private static readonly float[] ImagenetStd = [0.229f, 0.224f, 0.225f];
private readonly InferenceSession _session;
private readonly string[]? _labels;
private readonly string _inputName;
private readonly int _inputWidth;
private readonly int _inputHeight;
/// <summary>
/// 使用 BgiOnnxFactory 创建这个类的实例
/// </summary>
internal BgiRedNetPredictor(BgiOnnxModel model, InferenceSession session, string? labelRelativePath = null)
{
_session = session;
var input = _session.InputMetadata.FirstOrDefault();
if (input.Key is null || input.Value is null)
{
throw new InvalidDataException("ONNX 模型输入信息为空");
}
_inputName = input.Key;
var dimensions = input.Value.Dimensions;
if (dimensions.Length < 4)
{
throw new InvalidDataException($"ONNX 模型输入维度不正确,预期 >=4,实际 {dimensions.Length}");
}
_inputHeight = dimensions[^2] > 0 ? dimensions[^2] : DefaultInputSize;
_inputWidth = dimensions[^1] > 0 ? dimensions[^1] : DefaultInputSize;
_labels = LoadLabels(labelRelativePath ?? Path.ChangeExtension(model.ModelRelativePath, ".labels.txt"));
}
public RedNetPrediction Predict(Image<Rgb24> image)
{
using var resized = image.Clone(ctx => ctx.Resize(_inputWidth, _inputHeight));
var tensorInput = BuildInputTensor(resized);
using var results = _session.Run([
NamedOnnxValue.CreateFromTensor(_inputName, tensorInput)
]);
var logits = results.First().AsEnumerable<float>().ToArray();
if (logits.Length == 0)
{
throw new InvalidDataException("ONNX 模型输出为空");
}
var probabilities = Softmax(logits);
var maxIndex = 0;
var maxValue = probabilities[0];
for (var i = 1; i < probabilities.Length; i++)
{
if (probabilities[i] <= maxValue) continue;
maxValue = probabilities[i];
maxIndex = i;
}
var label = maxIndex >= 0 && _labels is not null && maxIndex < _labels.Length
? _labels[maxIndex]
: $"Class_{maxIndex}";
return new RedNetPrediction(maxIndex, label, maxValue);
}
private DenseTensor<float> BuildInputTensor(Image<Rgb24> image)
{
var tensor = new DenseTensor<float>([1, 3, _inputHeight, _inputWidth]);
for (var y = 0; y < _inputHeight; y++)
{
for (var x = 0; x < _inputWidth; x++)
{
var pixel = image[x, y];
var r = pixel.R / 255f;
var g = pixel.G / 255f;
var b = pixel.B / 255f;
tensor[0, 0, y, x] = (r - ImagenetMean[0]) / ImagenetStd[0];
tensor[0, 1, y, x] = (g - ImagenetMean[1]) / ImagenetStd[1];
tensor[0, 2, y, x] = (b - ImagenetMean[2]) / ImagenetStd[2];
}
}
return tensor;
}
private static float[] Softmax(float[] logits)
{
var max = logits.Max();
var result = new float[logits.Length];
var sum = 0d;
for (var i = 0; i < logits.Length; i++)
{
var value = Math.Exp(logits[i] - max);
result[i] = (float)value;
sum += value;
}
if (sum <= 0)
{
return result;
}
for (var i = 0; i < result.Length; i++)
{
result[i] = (float)(result[i] / sum);
}
return result;
}
private static string[]? LoadLabels(string labelRelativePath)
{
var labelAbsolutePath = Core.Config.Global.Absolute(labelRelativePath);
if (!File.Exists(labelAbsolutePath))
{
return null;
}
var ext = Path.GetExtension(labelAbsolutePath);
if (ext.Equals(".json", StringComparison.OrdinalIgnoreCase))
{
var labels = JsonSerializer.Deserialize<string[]>(File.ReadAllText(labelAbsolutePath));
return labels is { Length: > 0 } ? labels : null;
}
var lines = File.ReadAllLines(labelAbsolutePath)
.Where(t => !string.IsNullOrWhiteSpace(t))
.Select(t => t.Trim())
.ToArray();
return lines.Length > 0 ? lines : null;
}
public void Dispose()
{
_session.Dispose();
}
}
public readonly record struct RedNetPrediction(int ClassIndex, string ClassLabel, float Confidence);
@@ -9,13 +9,12 @@ using BetterGenshinImpact.Service.Notification.Model.Enum;
using Microsoft.Extensions.Logging;
using System;
using static BetterGenshinImpact.GameTask.Common.TaskControl;
using static Vanara.PInvoke.User32;
namespace BetterGenshinImpact.GameTask.AutoEat;
/// <summary>
/// 自动吃药触发器
/// 检测红血状态时自动使用Recovery.png,检测到Resurrection.png时按z复活
/// 检测红血状态时自动使用Recovery.png,检测到Resurrection.png时按快捷使用小道具键复活
/// </summary>
public class AutoEatTrigger : ITaskTrigger
{
@@ -94,8 +93,8 @@ public class AutoEatTrigger : ITaskTrigger
// 检查复活CD(2秒)
if ((now - _lastResurrectionTime).TotalSeconds >= 2)
{
// 按z键复活
Simulation.SendInput.Keyboard.KeyPress(VK.VK_Z);
// 走原神动作映射,跟随“快捷使用小道具”键位配置
Simulation.SendInput.SimulateAction(GIActions.QuickUseGadget);
_lastResurrectionTime = now;
_logger.LogInformation("检测到复活图标,自动复活");
}
@@ -140,4 +139,4 @@ public class AutoEatTrigger : ITaskTrigger
return false;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@@ -1,8 +1,12 @@
using BetterGenshinImpact.Core.Recognition;
using BetterGenshinImpact.GameTask.Model;
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.IO;
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model;
using BetterGenshinImpact.GameTask.Common;
using Microsoft.Extensions.Logging;
namespace BetterGenshinImpact.GameTask.AutoFight.Assets;
@@ -45,6 +49,11 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
public RecognitionObject AbnormalIconRa;
/// <summary>
/// 经验值模板识别对象列表,用于检测怪物死亡时掉落的经验值数字图标
/// </summary>
public IReadOnlyList<RecognitionObject> ExperienceRecognitionObjects { get; private set; } = Array.Empty<RecognitionObject>();
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑添加 "required" 修饰符或声明为可为 null。
private AutoFightAssets() : base()
{
@@ -264,5 +273,56 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
RegionOfInterest = new Rect(0, (int)(CaptureRect.Height * 0.08), (int)(CaptureRect.Width * 0.04), (int)(CaptureRect.Height * 0.07)),
DrawOnWindow = false
}.InitTemplate();
// 加载经验值模板图片(用于检测精英怪死亡时的经验值数字图标)
try
{
LoadExperienceRecognitionObjects();
}
catch (Exception)
{
// 经验值模板加载失败不应阻止 AutoFightAssets 初始化
ExperienceRecognitionObjects = Array.Empty<RecognitionObject>();
}
}
/// <summary>
/// 加载经验值模板图片,文件缺失时跳过,不影响其他功能
/// </summary>
private void LoadExperienceRecognitionObjects()
{
var experienceValues = new[] { 57, 58, 60 };
var threshold = CaptureRect.Width > 1920 ? 0.6 : 0.9;
var roi = new Rect(
(int)(CaptureRect.Width * 0.145),
(int)(CaptureRect.Height * 0.5),
(int)(CaptureRect.Width * 0.02),
(int)(CaptureRect.Height * 0.22));
var list = new List<RecognitionObject>();
foreach (var exp in experienceValues)
{
var fileName = $"experience_{exp}.png";
try
{
var ro = new RecognitionObject
{
Name = $"Experience_{exp}",
RecognitionType = RecognitionTypes.TemplateMatch,
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoFight", fileName, this.systemInfo),
RegionOfInterest = roi,
UseMask = true,
Threshold = threshold,
DrawOnWindow = true,
}.InitTemplate();
list.Add(ro);
}
catch (Exception)
{
// 构造阶段 Logger 可能不可用,静默跳过缺失的模板
}
}
ExperienceRecognitionObjects = list.AsReadOnly();
}
}
@@ -157,6 +157,12 @@ public partial class AutoFightConfig : ObservableObject
[ObservableProperty]
private bool _swimmingEnabled = false;
/// <summary>
/// 基于经验值判断是否执行战后拾取(检测到精英怪经验值图标时才拾取)
/// </summary>
[ObservableProperty]
private bool _expBasedPickupEnabled = false;
/// <summary>
/// 战斗超时,单位秒
/// </summary>
@@ -56,6 +56,7 @@ public class AutoFightParam : BaseTaskParam<AutoFightTask>
RotaryFactor = autoFightConfig.FinishDetectConfig.RotaryFactor;
QinDoublePickUp = autoFightConfig.QinDoublePickUp;
SwimmingEnabled = autoFightConfig.SwimmingEnabled;
ExpBasedPickupEnabled = autoFightConfig.ExpBasedPickupEnabled;
}
public FightFinishDetectConfig FinishDetectConfig { get; set; } = new();
@@ -84,6 +85,11 @@ public class AutoFightParam : BaseTaskParam<AutoFightTask>
public bool QinDoublePickUp { get; set; } = false;
public static bool SwimmingEnabled { get; set; } = false;
/// <summary>
/// 基于经验值判断是否执行战后拾取
/// </summary>
public bool ExpBasedPickupEnabled { get; set; } = false;
public AutoFightParam(string? strategyName = null) : base(null, null)
{
SetCombatStrategyPath(strategyName);
@@ -140,5 +146,6 @@ public class AutoFightParam : BaseTaskParam<AutoFightTask>
GuardianAvatarHold = autoFightConfig.GuardianAvatarHold;
SwimmingEnabled = autoFightConfig.SwimmingEnabled;
QinDoublePickUp = autoFightConfig.QinDoublePickUp;
ExpBasedPickupEnabled = autoFightConfig.ExpBasedPickupEnabled;
}
}
@@ -25,6 +25,7 @@ using BetterGenshinImpact.GameTask.AutoPick.Assets;
using BetterGenshinImpact.Core.Recognition;
using BetterGenshinImpact.GameTask.Common.Element.Assets;
using BetterGenshinImpact.GameTask.Common;
using BetterGenshinImpact.GameTask.AutoFight.Assets;
namespace BetterGenshinImpact.GameTask.AutoFight;
@@ -299,6 +300,16 @@ public class AutoFightTask : ISoloTask
AutoFightSeek.RotationCount= 0; // 重置旋转次数
// 基于经验值的战后拾取检测:在战斗过程中异步检测精英怪经验值图标
// 仅在万叶拾取总开关开启时才启动经验值检测
ExperienceDetector? expDetector = null;
if (_taskParam.KazuhaPickupEnabled && _taskParam.ExpBasedPickupEnabled)
{
var expRos = AutoFightAssets.Instance.ExperienceRecognitionObjects;
expDetector = new ExperienceDetector(expRos, cts2.Token);
expDetector.Start();
}
// 战斗操作
var fightTask = Task.Run(async () =>
{
@@ -489,6 +500,50 @@ public class AutoFightTask : ISoloTask
}, cts2.Token);
await fightTask;
try
{
// 基于经验值检测结果的拾取判断
if (_taskParam.KazuhaPickupEnabled && _taskParam.ExpBasedPickupEnabled && expDetector != null)
{
// 战斗结束与怪物死亡可能几乎同时发生,检测器可能还没来得及捕获经验值图标
// 保持检测器运行,每 100ms 轮询一次结果,最多等待 1.1 秒
if (!expDetector.HasDetectedExperience)
{
Logger.LogInformation("基于经验值判断:等待经验值检测结果");
var waitMs = 1100;
while (!expDetector.HasDetectedExperience && waitMs > 0)
{
await Delay(100, ct);
waitMs -= 100;
}
}
await expDetector.StopAsync();
var shouldPickup = expDetector.HasDetectedExperience;
Logger.LogInformation("基于经验值判断:{Result} 战后拾取", shouldPickup ? "执行" : "不执行");
if (!shouldPickup)
{
// 经验值检测未通过,跳过拾取(但仍执行扫描拾取逻辑)
if (_taskParam is { PickDropsAfterFightEnabled: true })
{
await new ScanPickTask().Start(ct);
}
return;
}
}
}
finally
{
// 确保检测器在任何路径(异常/取消/正常)都被停止和释放
if (expDetector != null)
{
await expDetector.StopAsync();
expDetector.Dispose();
}
}
if (_taskParam.BattleThresholdForLoot>=2 && countFight < _taskParam.BattleThresholdForLoot)
{
Logger.LogInformation($"战斗人次({countFight})低于配置人次({_taskParam.BattleThresholdForLoot}),跳过此次拾取!");
@@ -0,0 +1,165 @@
using BetterGenshinImpact.Core.Recognition;
using BetterGenshinImpact.GameTask.Common;
using BetterGenshinImpact.GameTask.Model.Area;
using Microsoft.Extensions.Logging;
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace BetterGenshinImpact.GameTask.AutoFight;
/// <summary>
/// 经验值检测器:在战斗过程中异步检测屏幕上怪物死亡时掉落的经验值数字图标,
/// 用于判断是否有精英怪被击杀,从而决定战后是否执行拾取。
/// </summary>
public sealed class ExperienceDetector : IDisposable
{
private static readonly ILogger Logger = TaskControl.Logger;
/// <summary>
/// 经验值图标左侧特征像素的水平偏移量(相对于模板匹配位置)
/// </summary>
private const int ExpIconPixelOffsetX = -147;
/// <summary>
/// 经验值图标特征颜色 BGR 范围(用于二次验证模板匹配结果)
/// </summary>
private static readonly Vec3b ExpColorMin = new(200, 200, 150);
private static readonly Vec3b ExpColorMax = new(255, 255, 200);
/// <summary>
/// 检测循环间隔(毫秒)
/// </summary>
private const int DetectionIntervalMs = 100;
private readonly IReadOnlyList<RecognitionObject> _experienceRos;
private readonly CancellationTokenSource _linkedCts;
private readonly TaskCompletionSource<bool> _resultTcs;
private Task? _detectionTask;
private bool _disposed;
/// <summary>
/// 获取检测结果:是否检测到经验值图标
/// </summary>
public bool HasDetectedExperience =>
_resultTcs.Task.IsCompletedSuccessfully && _resultTcs.Task.Result;
public ExperienceDetector(
IReadOnlyList<RecognitionObject> experienceRos,
CancellationToken externalToken)
{
_experienceRos = experienceRos ?? throw new ArgumentNullException(nameof(experienceRos));
_linkedCts = CancellationTokenSource.CreateLinkedTokenSource(externalToken);
_resultTcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
}
/// <summary>
/// 启动后台经验值检测循环
/// </summary>
public void
Start()
{
if (_experienceRos.Count == 0)
{
Logger.LogWarning("经验值检测:无可用模板,跳过检测");
return;
}
_detectionTask = Task.Run(() => DetectionLoop(_linkedCts.Token), _linkedCts.Token);
}
/// <summary>
/// 停止检测并等待后台任务结束
/// </summary>
public async Task StopAsync()
{
_linkedCts.Cancel();
if (_detectionTask != null)
{
try
{
await _detectionTask.ConfigureAwait(false);
}
catch (OperationCanceledException)
{
// 正常取消,忽略
}
}
// 确保结果有值(未检测到时设为 false)
_resultTcs.TrySetResult(false);
}
/// <summary>
/// 后台检测循环:截屏 → 模板匹配 → 像素颜色验证
/// </summary>
private void DetectionLoop(CancellationToken ct)
{
while (!ct.IsCancellationRequested)
{
try
{
using var capture = TaskControl.CaptureToRectArea();
foreach (var ro in _experienceRos)
{
ct.ThrowIfCancellationRequested();
var matchResult = capture.Find(ro);
if (!matchResult.IsExist())
continue;
// 模板匹配成功,执行像素颜色二次验证
if (ValidateExpPixelColor(capture, matchResult))
{
Logger.LogInformation("基于经验值判断:检测到 {Name} 经验值图标,启用战后拾取", ro.Name.Replace("Experience_", ""));
_resultTcs.TrySetResult(true);
return; // 检测到后退出循环
}
}
// 短暂等待后继续下一轮检测
Thread.Sleep(DetectionIntervalMs);
}
catch (OperationCanceledException)
{
break;
}
catch (Exception ex)
{
Logger.LogError(ex, "经验值检测循环中发生异常,继续下一轮");
}
}
}
/// <summary>
/// 像素颜色验证:检查匹配位置左侧偏移处的像素是否符合经验值图标特征色
/// </summary>
private static bool ValidateExpPixelColor(ImageRegion capture, Region matchResult)
{
var checkX = matchResult.X + ExpIconPixelOffsetX;
var checkY = matchResult.Y;
// 边界检查
if (checkX < 0 || checkX >= capture.SrcMat.Cols || checkY < 0 || checkY >= capture.SrcMat.Rows)
return false;
var pixel = capture.SrcMat.At<Vec3b>(checkY, checkX);
return pixel[0] >= ExpColorMin[0] && pixel[0] <= ExpColorMax[0] // B
&& pixel[1] >= ExpColorMin[1] && pixel[1] <= ExpColorMax[1] // G
&& pixel[2] >= ExpColorMin[2] && pixel[2] <= ExpColorMax[2]; // R
}
public void Dispose()
{
if (_disposed) return;
_disposed = true;
_linkedCts.Cancel();
_linkedCts.Dispose();
_resultTcs.TrySetResult(false);
_detectionTask = null;
}
}
@@ -86,6 +86,19 @@ public class Avatar
/// 战斗场景
/// </summary>
public CombatScenes CombatScenes { get; set; }
/// <summary>
/// 脱困方向数组(前/后/左/右)
/// </summary>
private static readonly GIActions[] UnstuckDirections =
{
GIActions.MoveForward,
GIActions.MoveBackward,
GIActions.MoveLeft,
GIActions.MoveRight
};
private static readonly Random UnstuckRandom = new();
public Avatar(CombatScenes combatScenes, string name, int index, Rect nameRect, double manualSkillCd = -1)
@@ -229,6 +242,13 @@ public class Avatar
SimulateSwitchAction(Index);
// Debug.WriteLine($"切换到{Index}号位");
// Cv2.ImWrite($"log/切换.png", region.SrcMat);
// 第13次重试时,战斗状态下执行脱困动作
if (i == 10 && AutoFightTask.FightStatusFlag)
{
PerformUnstuckAction(Ct);
}
Sleep(250, Ct);
}
}
@@ -259,14 +279,20 @@ public class Avatar
}
else
{
if (i == tryTimes - 1)
if (i == tryTimes - 1 && tryTimes == 4) //默认状态,没有特意设置重试次数的情况下,最后一次重试失败才输出日志
{
Logger.LogWarning("切换角色失败,最后一次尝试,当前角色编号:{CurrentIndex},期望角色编号:{ExpectedIndex}", CombatScenes.GetActiveAvatarIndex(region, context), Index);
region.SrcMat.SaveImage($"log/{Name}_切换失败.png");
}
else
{
// 特意需要脱困情形下,会设置重试次数激活脱困检测,第10次重试时(2.5秒切换失败,超过角色的大招动画时间),如在盾奶位功能中次数会到第十次。
if (i == 9 && AutoFightTask.FightStatusFlag)
{
PerformUnstuckAction(Ct);
}
}
}
SimulateSwitchAction(Index);
Sleep(250, Ct);
@@ -302,6 +328,23 @@ public class Avatar
}
}
/// <summary>
/// 战斗中切换角色卡住时的脱困动作:跳跃 → 随机方向移动+切换 → 攻击 → 释放按键
/// </summary>
private void PerformUnstuckAction(CancellationToken ct)
{
var direction = UnstuckDirections[UnstuckRandom.Next(4)];
Logger.LogWarning("切换角色卡住,执行脱困(方向:{Dir})", direction);
Simulation.SendInput.SimulateAction(GIActions.Jump);
Sleep(200, ct);
Simulation.SendInput.SimulateAction(direction, KeyType.KeyDown);
SimulateSwitchAction(Index);
Sleep(1000, ct);
Simulation.SendInput.SimulateAction(GIActions.NormalAttack);
Simulation.ReleaseAllKey();
}
/// <summary>
/// 切换到本角色
/// 切换cd是1秒,如果切换失败,会尝试再次切换,最多尝试5次
@@ -407,7 +407,8 @@ public class PartyAvatarSideIndexHelper
// 方法3:使用更加靠谱的差值识别(-1是未识别),但是不支持非满队
if (mats.Length == 4)
{
return ImageDifferenceDetector.FindMostDifferentImage(mats);
var result = ImageDifferenceDetector.FindMostDifferentImage(mats);
return result >= 0 ? result + 1 : -1;
}
else
{
@@ -1226,7 +1226,7 @@
"nameEn": "barbara",
"type": "character",
"name": "芭芭拉",
"hp": 10,
"hp": 12,
"energy": 3,
"element": "水元素",
"weapon": "法器",
@@ -2158,6 +2158,152 @@
}
]
},
{
"id": 1215,
"nameEn": "dahlia",
"type": "character",
"name": "塔利雅",
"hp": 10,
"energy": 2,
"element": "水元素",
"weapon": "单手剑",
"skills": [
{
"nameEn": "favonius_bladework_ritual",
"name": "西风剑术·祭仪",
"skillTag": [
"普通攻击"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 1
},
{
"id": 1109,
"nameEn": "unaligned_element",
"type": "无色元素",
"count": 2
}
]
},
{
"nameEn": "immersive_ordinance",
"name": "圣浸的礼典",
"skillTag": [
"元素战技"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 3
}
]
},
{
"nameEn": "radiant_psalter",
"name": "纯耀的祷咏",
"skillTag": [
"元素爆发"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 3
},
{
"id": 1110,
"nameEn": "energy",
"type": "充能",
"count": 2
}
]
}
]
},
{
"id": 1216,
"nameEn": "aino",
"type": "character",
"name": "爱诺",
"hp": 10,
"energy": 2,
"element": "水元素",
"weapon": "双手剑",
"skills": [
{
"nameEn": "bishbashbosh_repair",
"name": "敲打修理法",
"skillTag": [
"普通攻击"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 1
},
{
"id": 1109,
"nameEn": "unaligned_element",
"type": "无色元素",
"count": 2
}
]
},
{
"nameEn": "musecatcher",
"name": "妙思捕手",
"skillTag": [
"元素战技"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 3
}
]
},
{
"nameEn": "precision_hydronic_cooler",
"name": "精密水冷仪",
"skillTag": [
"元素爆发"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 3
},
{
"id": 1110,
"nameEn": "energy",
"type": "充能",
"count": 2
}
]
},
{
"nameEn": "modular_efficiency_protocol",
"name": "模块式高效运作",
"skillTag": [
"被动技能"
],
"cost": []
}
]
},
{
"id": 1301,
"nameEn": "diluc",
@@ -9676,5 +9822,82 @@
"cost": []
}
]
},
{
"id": 2705,
"nameEn": "consecrated_fanged_beast",
"type": "character",
"name": "圣骸牙兽",
"hp": 10,
"energy": 2,
"element": "草元素",
"weapon": "其他武器",
"skills": [
{
"nameEn": "claw_slash",
"name": "利爪猛击",
"skillTag": [
"普通攻击"
],
"cost": [
{
"id": 1107,
"nameEn": "dendro",
"type": "草元素",
"count": 1
},
{
"id": 1109,
"nameEn": "unaligned_element",
"type": "无色元素",
"count": 2
}
]
},
{
"nameEn": "siphon_wave",
"name": "掠能绿波",
"skillTag": [
"元素战技"
],
"cost": [
{
"id": 1107,
"nameEn": "dendro",
"type": "草元素",
"count": 3
}
]
},
{
"nameEn": "sprawling_blighted_vines",
"name": "横生厄蔓",
"skillTag": [
"元素爆发"
],
"cost": [
{
"id": 1107,
"nameEn": "dendro",
"type": "草元素",
"count": 3
},
{
"id": 1110,
"nameEn": "energy",
"type": "充能",
"count": 2
}
]
},
{
"nameEn": "hunger_from_the_remains",
"name": "亡骸饥渴",
"skillTag": [
"被动技能"
],
"cost": []
}
]
}
]
File diff suppressed because it is too large. Load diff
@@ -1715,6 +1715,27 @@
"strategy": "蒙德7-达达乌帕谷",
"steps": 6,
"order": 6
},
{
"x": -155,
"y": 3324,
"strategy": "蒙德8-风车镇",
"steps": 3,
"order": 1
},
{
"x": -256,
"y": 3295,
"strategy": "蒙德8-风车镇",
"steps": 3,
"order": 2
},
{
"x": -330,
"y": 3226,
"strategy": "蒙德8-风车镇",
"steps": 3,
"order": 3
}
],
"须弥": [
@@ -0,0 +1,29 @@
{
"info": {
"authors": [
{
"links": "",
"name": "ddaodan"
}
],
"bgi_version": "0.60.0",
"description": "",
"enable_monster_loot_split": false,
"last_modified_time": 1775792800230,
"map_match_method": "SIFT",
"map_name": "Teyvat",
"name": "蒙德8-风车镇-1",
"tags": [],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"id": 1,
"x": -155.69140625,
"y": 3324.93212890625,
"type": "target",
"move_mode": "walk"
}
]
}
@@ -0,0 +1,29 @@
{
"info": {
"authors": [
{
"links": "",
"name": "ddaodan"
}
],
"bgi_version": "0.60.0",
"description": "",
"enable_monster_loot_split": false,
"last_modified_time": 1775792896742,
"map_match_method": "SIFT",
"map_name": "Teyvat",
"name": "蒙德8-风车镇-2",
"tags": [],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"id": 1,
"x": -256.87890625,
"y": 3295.62060546875,
"type": "target",
"move_mode": "walk"
}
]
}
@@ -0,0 +1,29 @@
{
"info": {
"authors": [
{
"links": "",
"name": "ddaodan"
}
],
"bgi_version": "0.60.0",
"description": "",
"enable_monster_loot_split": false,
"last_modified_time": 1775793214341,
"map_match_method": "SIFT",
"map_name": "Teyvat",
"name": "蒙德8-风车镇-3",
"tags": [],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"id": 1,
"x": -330.87890625,
"y": 3226.130859375,
"type": "target",
"move_mode": "walk"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"authors": [
{
"links": "",
"name": "ddaodan"
}
],
"bgi_version": "0.60.0",
"description": "",
"enable_monster_loot_split": false,
"last_modified_time": 1775792800230,
"map_match_method": "SIFT",
"map_name": "Teyvat",
"name": "蒙德8-风车镇-1",
"tags": [],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "walk",
"type": "teleport",
"x": -82.462890625,
"y": 3309.48583984375
},
{
"action": "stop_flying",
"action_params": "",
"id": 2,
"locked": false,
"move_mode": "fly",
"type": "path",
"x": -155.69140625,
"y": 3324.93212890625
},
{
"action": "",
"action_params": "",
"id": 3,
"move_mode": "walk",
"type": "target",
"x": -155.69140625,
"y": 3324.93212890625
}
]
}
@@ -0,0 +1,40 @@
{
"info": {
"authors": [
{
"links": "",
"name": "ddaodan"
}
],
"bgi_version": "0.60.0",
"description": "",
"enable_monster_loot_split": false,
"last_modified_time": 1775792896742,
"map_match_method": "SIFT",
"map_name": "Teyvat",
"name": "蒙德8-风车镇-2",
"tags": [],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "dash",
"type": "path",
"x": -193.931640625,
"y": 3335.927734375
},
{
"action": "",
"action_params": "",
"id": 2,
"move_mode": "dash",
"type": "target",
"x": -256.87890625,
"y": 3295.62060546875
}
]
}
@@ -0,0 +1,40 @@
{
"info": {
"authors": [
{
"links": "",
"name": "ddaodan"
}
],
"bgi_version": "0.60.0",
"description": "",
"enable_monster_loot_split": false,
"last_modified_time": 1775793214341,
"map_match_method": "SIFT",
"map_name": "Teyvat",
"name": "蒙德8-风车镇-3",
"tags": [],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "dash",
"type": "path",
"x": -273.49609375,
"y": 3291.94677734375
},
{
"action": "",
"action_params": "",
"id": 2,
"move_mode": "dash",
"type": "target",
"x": -330.87890625,
"y": 3226.130859375
}
]
}
@@ -1,4 +1,4 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
namespace BetterGenshinImpact.GameTask.AutoPick
@@ -37,6 +37,14 @@ namespace BetterGenshinImpact.GameTask.AutoPick
[ObservableProperty]
private string _ocrEngine = PickOcrEngineEnum.Paddle.ToString();
/// <summary>
/// 拾取识别模式
/// - Ocr: 通过OCR识别物品名
/// - RedNet: 通过分类模型直接识别物品名
/// </summary>
[ObservableProperty]
private string _recognitionMode = PickRecognitionModeEnum.Ocr.ToString();
/// <summary>
/// 急速模式
/// 无视文字识别结果,直接拾取
@@ -1,5 +1,6 @@
using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.Core.Recognition;
using BetterGenshinImpact.Core.Recognition.ONNX;
using BetterGenshinImpact.Core.Recognition.OCR;
using BetterGenshinImpact.Core.Recognition.ONNX.SVTR;
using BetterGenshinImpact.Core.Script.Dependence.Model.TimerConfig;
@@ -8,6 +9,7 @@ using BetterGenshinImpact.GameTask.AutoPick.Assets;
using BetterGenshinImpact.Helpers;
using BetterGenshinImpact.Service;
using BetterGenshinImpact.View.Windows;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OpenCvSharp;
using System;
@@ -49,9 +51,14 @@ public partial class AutoPickTrigger : ITaskTrigger
private HashSet<string> _whiteList = [];
private RecognitionObject _pickRo;
private readonly Lazy<BgiRedNetPredictor> _pickRedNetPredictor = new(() =>
App.ServiceProvider.GetRequiredService<BgiOnnxFactory>().CreateRedNetPredictor(BgiOnnxModel.BgiPickRedNet110));
// 外部配置
private AutoPickExternalConfig? _externalConfig;
double scale = TaskContext.Instance().SystemInfo.AssetScale;
AutoPickConfig config = TaskContext.Instance().Config.AutoPickConfig;
public AutoPickTrigger()
{
@@ -192,8 +199,7 @@ public partial class AutoPickTrigger : ITaskTrigger
return;
}
var scale = TaskContext.Instance().SystemInfo.AssetScale;
var config = TaskContext.Instance().Config.AutoPickConfig;
// 存在 L 键位是千星奇遇,无需拾取
using var lKeyRa = content.CaptureRectArea.Find(_autoPickAssets.LRo);
@@ -204,9 +210,10 @@ public partial class AutoPickTrigger : ITaskTrigger
// 识别到拾取键,开始识别物品图标
var isExcludeIcon = false;
_autoPickAssets.ChatIconRo.RegionOfInterest = new Rect(
var iconRect = new Rect(
foundRectArea.X + (int)(config.ItemIconLeftOffset * scale), foundRectArea.Y,
(int)((config.ItemTextLeftOffset - config.ItemIconLeftOffset) * scale), foundRectArea.Height);
_autoPickAssets.ChatIconRo.RegionOfInterest = iconRect;
using var chatIconRa = content.CaptureRectArea.Find(_autoPickAssets.ChatIconRo);
speedTimer.Record("识别聊天图标");
if (!chatIconRa.IsEmpty())
@@ -251,66 +258,15 @@ public partial class AutoPickTrigger : ITaskTrigger
// return;
//}
// 这类文字识别比较特殊,都是针对某个场景的文字识别,所以暂时未抽象到识别对象中
// 计算出文字区域
var textRect = new Rect(foundRectArea.X + (int)(config.ItemTextLeftOffset * scale), foundRectArea.Y,
(int)((config.ItemTextRightOffset - config.ItemTextLeftOffset) * scale), foundRectArea.Height);
if (textRect.X + textRect.Width > content.CaptureRectArea.CacheGreyMat.Width
|| textRect.Y + textRect.Height > content.CaptureRectArea.CacheGreyMat.Height)
{
Debug.WriteLine("AutoPickTrigger: 文字区域 out of range");
return;
}
using var gradMat = new Mat(content.CaptureRectArea.CacheGreyMat,
new Rect(textRect.X, textRect.Y, textRect.Width, Math.Min(textRect.Height, 3)));
var avgGrad = gradMat.Sobel(MatType.CV_32F, 1, 0).Mean().Val0;
if (avgGrad < -3)
{
Debug.WriteLine($"AutoPickTrigger: 已在拾取中,跳过本次拾取 {avgGrad}");
return;
}
string text;
if (config.OcrEngine == nameof(PickOcrEngineEnum.Yap))
if (config.RecognitionMode == nameof(PickRecognitionModeEnum.RedNet))
{
var textMat = new Mat(content.CaptureRectArea.CacheGreyMat, textRect);
text = TextInferenceFactory.Pick.Value.Inference(textMat);
text = RecognizePickTextByRedNet(content, foundRectArea);
}
else
{
using var textMat = new Mat(content.CaptureRectArea.SrcMat, textRect);
var boundingRect = TextRectExtractor.GetTextBoundingRect(textMat);
// var boundingRect = new Rect(); // 不使用自己写的文字区域提取
// 如果找到有效区域
if (boundingRect.X < 20 && boundingRect.Width > 5 && boundingRect.Height > 5)
{
// 截取只包含文字的区域
using var textOnlyMat = new Mat(textMat, new Rect(0, 0,
boundingRect.Right + 5 < textMat.Width ? boundingRect.Right + 5 : textMat.Width, textMat.Height));
text = OcrFactory.Paddle.OcrWithoutDetector(textOnlyMat);
// if (RuntimeHelper.IsDebug)
// {
// // 如果不等于正确文字,则保存图片
// if (text != "烹饪")
// {
// var path = Global.Absolute("log/pick");
// Directory.CreateDirectory(path);
// var str = $"{DateTime.Now:yyyyMMddHHmmssfff}";
// // textMat.SaveImage(Path.Combine(path, $"pick_ocr_ori_{str}.png"));
// // 画上 boundingRect
// Cv2.Rectangle(textMat, boundingRect, new Scalar(0, 0, 255), 1);
// textMat.SaveImage(Path.Combine(path, $"pick_ocr_rect_{str}.png"));
// bin.SaveImage(Path.Combine(path, $"bin_{str}.png"));
// }
// }
}
else
{
Debug.WriteLine("-- 无法识别到有效文字区域,尝试直接OCR DET");
text = OcrFactory.Paddle.Ocr(textMat);
}
text = RecognizePickTextByOcr(content, foundRectArea, config.OcrEngine);
}
speedTimer.Record("文字识别");
@@ -370,6 +326,90 @@ public partial class AutoPickTrigger : ITaskTrigger
speedTimer.DebugPrint();
}
private string RecognizePickTextByRedNet(CaptureContent content, Region foundRectArea)
{
try
{
// 32x32 图片
var iconRect = new Rect(foundRectArea.X + (int)((config.ItemIconLeftOffset + 10) * scale), foundRectArea.Y, (int)(32 * scale), (int)(32 * scale));
using var imageRegion = content.CaptureRectArea.DeriveCrop(iconRect);
imageRegion.SrcMat.SaveImage(@"log/pick/rednet_input.png");
var prediction = _pickRedNetPredictor.Value.Predict(imageRegion.CacheImage);
// Debug.WriteLine($"AutoPickTrigger: RedNet预测结果 {prediction.ClassLabel} 置信度 {prediction.Confidence}");
if (prediction.Confidence < 0.47)
{
return string.Empty;
}
return prediction.ClassLabel;
}
catch (Exception e)
{
_logger.LogWarning(e, "AutoPick RedNet推理失败,回退OCR");
return string.Empty;
}
}
private string RecognizePickTextByOcr(CaptureContent content, Region foundRectArea, string ocrEngine)
{
// 这类文字识别比较特殊,都是针对某个场景的文字识别,所以暂时未抽象到识别对象中
// 计算出文字区域
var textRect = new Rect(foundRectArea.X + (int)(config.ItemTextLeftOffset * scale), foundRectArea.Y,
(int)((config.ItemTextRightOffset - config.ItemTextLeftOffset) * scale), foundRectArea.Height);
if (textRect.X + textRect.Width > content.CaptureRectArea.CacheGreyMat.Width
|| textRect.Y + textRect.Height > content.CaptureRectArea.CacheGreyMat.Height)
{
Debug.WriteLine("AutoPickTrigger: 文字区域 out of range");
return string.Empty;
}
using var gradMat = new Mat(content.CaptureRectArea.CacheGreyMat,
new Rect(textRect.X, textRect.Y, textRect.Width, Math.Min(textRect.Height, 3)));
var avgGrad = gradMat.Sobel(MatType.CV_32F, 1, 0).Mean().Val0;
if (avgGrad < -3)
{
Debug.WriteLine($"AutoPickTrigger: 已在拾取中,跳过本次拾取 {avgGrad}");
return string.Empty;
}
if (ocrEngine == nameof(PickOcrEngineEnum.Yap))
{
using var textMat = new Mat(content.CaptureRectArea.CacheGreyMat, textRect);
return TextInferenceFactory.Pick.Value.Inference(textMat);
}
using var paddleMat = new Mat(content.CaptureRectArea.SrcMat, textRect);
var boundingRect = TextRectExtractor.GetTextBoundingRect(paddleMat);
// var boundingRect = new Rect(); // 不使用自己写的文字区域提取
// 如果找到有效区域
if (boundingRect.X < 20 && boundingRect.Width > 5 && boundingRect.Height > 5)
{
// 截取只包含文字的区域
using var textOnlyMat = new Mat(paddleMat, new Rect(0, 0,
boundingRect.Right + 5 < paddleMat.Width ? boundingRect.Right + 5 : paddleMat.Width, paddleMat.Height));
return OcrFactory.Paddle.OcrWithoutDetector(textOnlyMat);
// if (RuntimeHelper.IsDebug)
// {
// // 如果不等于正确文字,则保存图片
// if (text != "烹饪")
// {
// var path = Global.Absolute("log/pick");
// Directory.CreateDirectory(path);
// var str = $"{DateTime.Now:yyyyMMddHHmmssfff}";
// // textMat.SaveImage(Path.Combine(path, $"pick_ocr_ori_{str}.png"));
// // 画上 boundingRect
// Cv2.Rectangle(textMat, boundingRect, new Scalar(0, 0, 255), 1);
// textMat.SaveImage(Path.Combine(path, $"pick_ocr_rect_{str}.png"));
// bin.SaveImage(Path.Combine(path, $"bin_{str}.png"));
// }
// }
}
Debug.WriteLine("-- 无法识别到有效文字区域,尝试直接OCR DET");
return OcrFactory.Paddle.Ocr(paddleMat);
}
private bool DoNotPick(string text)
{
// 唯一一个动态拾取项,特殊处理,不拾取
@@ -576,4 +616,4 @@ public partial class AutoPickTrigger : ITaskTrigger
return cleanedSpan.ToString();
}
}
}
@@ -1,4 +1,4 @@
namespace BetterGenshinImpact.GameTask.AutoPick;
namespace BetterGenshinImpact.GameTask.AutoPick;
public enum PickOcrEngineEnum
{
@@ -0,0 +1,7 @@
namespace BetterGenshinImpact.GameTask.AutoPick;
public enum PickRecognitionModeEnum
{
Ocr,
RedNet
}
@@ -164,7 +164,7 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
(StygianState.EventMenu, [StygianState.StygianOnslaughtPage]),
(StygianState.StygianOnslaughtPage, [StygianState.TeleportMap, StygianState.DomainEntrance]),
(StygianState.TeleportMap, [StygianState.DomainEntrance]),
(StygianState.DomainEntrance, [StygianState.DifficultySelect]),
(StygianState.DomainEntrance, [StygianState.DomainEntrance, StygianState.DifficultySelect]),
(StygianState.DifficultySelect, [StygianState.DomainLobby]),
(StygianState.DomainLobby, [StygianState.BossSelect, StygianState.LeylineFlowerPrompt]),
@@ -369,10 +369,10 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
await Delay(500, _ct);
// 2. 在列表区域内查找"幽境危战"并点击
var listItem = page.GetByText("幽境危战").WithRoi(listRegion);
if (listItem.IsExist())
var target = page.GetByText("幽境危战").WithRoi(listRegion).FindAll().FirstOrDefault();
if (target != null)
{
listItem.FindAll().FirstOrDefault()?.Click();
target.Click();
await Delay(300, _ct);
return StateHandlerResult.Success; // 等待转换到 StygianOnslaughtPage
}
@@ -382,15 +382,20 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
// 如果两次都没找到,可能"幽境危战"已经被选中,直接尝试检测下一状态
Logger.LogWarning($"{Name}:未找到幽境危战,可能已被选中,尝试检测 StygianOnslaughtPage");
page.GetByText("幽境危战").WithRoi(listRegion).FindAll().FirstOrDefault()?.Click();
await Delay(300, _ct);
return StateHandlerResult.Success; // 等待转换到 StygianOnslaughtPage
return StateHandlerResult.Success; // 让状态机继续等待邻接状态出现
}
private async Task<StateHandlerResult> HandleStygianOnslaughtPageState(BvPage page)
{
Logger.LogInformation($"{Name}:点击前往挑战");
page.GetByText("前往挑战").WithRoi(r => r.CutRight(0.5)).FindAll().FirstOrDefault()?.Click();
var challengeButton = page.GetByText("前往挑战").WithRoi(r => r.CutRight(0.5)).FindAll().FirstOrDefault();
if (challengeButton == null)
{
Logger.LogWarning($"{Name}:未找到前往挑战按钮");
return StateHandlerResult.Retry;
}
challengeButton.Click();
await Delay(300, _ct);
return StateHandlerResult.Success; // 等待转换到 TeleportMap 或 DomainEntrance
}
@@ -398,7 +403,14 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
private async Task<StateHandlerResult> HandleTeleportMapState(BvPage page)
{
Logger.LogInformation($"{Name}:点击传送");
page.Locator(QuickTeleportAssets.Instance.TeleportButtonRo).FindAll().FirstOrDefault()?.Click();
var teleportButton = page.Locator(QuickTeleportAssets.Instance.TeleportButtonRo).FindAll().FirstOrDefault();
if (teleportButton == null)
{
Logger.LogWarning($"{Name}:未找到传送按钮");
return StateHandlerResult.Retry;
}
teleportButton.Click();
await Delay(300, _ct);
return StateHandlerResult.Success; // 等待转换到 DomainEntrance
}
@@ -421,6 +433,12 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
// 点击确认进入
using var ra = CaptureToRectArea();
var btn = ra.Find(ElementAssets.Instance.BtnWhiteConfirm);
if (btn.IsEmpty())
{
Logger.LogWarning($"{Name}:未找到进入确认按钮");
return StateHandlerResult.Retry;
}
btn.Click();
await Delay(300, _ct);
return StateHandlerResult.Success; // 等待转换到 DomainLobby
@@ -15827,6 +15827,411 @@
]
}
]
},
{
"sceneId": 103,
"mapName": "TempleOfSpace",
"description": "空之神殿",
"points": [
{
"id": 1,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿"
],
"position": [
-54.55967,
94.86076,
422.8673
],
"tranPosition": [
-56.074036,
94.98824,
416.23694
]
},
{
"id": 2,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"「沙上楼阁」"
],
"position": [
753.4533,
167.7142,
406.8993
],
"tranPosition": [
750.10944,
168.12778,
404.4207
]
},
{
"id": 3,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"柱殿中央区"
],
"position": [
199.4993,
285.1512,
421.763
],
"tranPosition": [
188.9862,
286,
415.9903
]
},
{
"id": 4,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"非有非无有之笼"
],
"position": [
141.1487,
1023.361,
397.4059
],
"tranPosition": [
146.44849,
1023.595,
398.8499
]
},
{
"id": 5,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"大方广"
],
"position": [
-211.06,
99.55,
1077.296
],
"tranPosition": [
-208.68654,
99.78452,
1078.6156
]
},
{
"id": 6,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"「沙上楼阁」"
],
"position": [
820.533,
205.5557,
398.7081
],
"tranPosition": [
827.40546,
205.42303,
397.87726
]
},
{
"id": 7,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"麓阳书院"
],
"position": [
278.373,
76.166,
-63.747
],
"tranPosition": [
274.3983,
81.7,
-90.75065
]
},
{
"id": 8,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"无想之间"
],
"position": [
223.6314,
-639.5626,
340.3265
],
"tranPosition": [
234.13805,
-639.21765,
340.76056
]
},
{
"id": 9,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"柱殿中央区"
],
"position": [
488.6741,
222.6675,
420.6201
],
"tranPosition": [
486.98044,
222.82823,
412.4271
]
},
{
"id": 10,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"柱殿中央区"
],
"position": [
155.0897,
149.385,
554.323
],
"tranPosition": [
152.0113,
149,
557.715
]
},
{
"id": 11,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"大方广"
],
"position": [
-29.19872,
96.02325,
798.1201
],
"tranPosition": [
-33.452164,
95.713165,
797.0473
]
},
{
"id": 13,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"「沙上楼阁」"
],
"position": [
775.6891,
-327.1821,
377.7858
],
"tranPosition": [
774.40875,
-327.0491,
373.75824
]
},
{
"id": 15,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"非有非无有之笼·偏观"
],
"position": [
182.5881,
849.3398,
439.3099
],
"tranPosition": [
187.40652,
853.72705,
456.6145
]
},
{
"id": 16,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"麓阳书院"
],
"position": [
246.311,
98.3308,
-386.82
],
"tranPosition": [
245.6576,
98.5,
-384.9
]
},
{
"id": 17,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"麓阳书院"
],
"position": [
308.613,
144.1657,
-471.317
],
"tranPosition": [
311.5699,
144.1,
-470.9256
]
},
{
"id": 18,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿"
],
"position": [
-151.602,
90.222,
61.155
],
"tranPosition": [
-156,
90.57036,
61
]
},
{
"id": 19,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"遗世之路"
],
"position": [
-320.8844,
-503.6001,
319.1273
],
"tranPosition": [
-320.71454,
-503.4747,
309.4051
]
},
{
"id": 20,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"柱殿中央区"
],
"position": [
339.9739,
205.945,
519.2927
],
"tranPosition": [
329.09018,
206.11433,
517.0902
]
},
{
"id": 25,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"麓阳书院"
],
"position": [
303.0637,
247.7,
-557.0782
],
"tranPosition": [
307.1052,
247.2,
-565.4739
]
},
{
"id": 26,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"大方广"
],
"position": [
-214.0386,
136.9813,
1307.659
],
"tranPosition": [
-204.69,
137.13,
1305.77
]
}
]
}
]
}
@@ -1007,7 +1007,7 @@ public class TpTask
if (matchRect == null)
{
Logger.LogWarning("切换区域失败:{Country}", areaName);
if (areaName == MapTypes.TheChasm.GetDescription() || areaName == MapTypes.Enkanomiya.GetDescription() || areaName == MapTypes.SeaOfBygoneEras.GetDescription() || areaName == MapTypes.AncientSacredMountain.GetDescription())
if (areaName == MapTypes.TheChasm.GetDescription() || areaName == MapTypes.Enkanomiya.GetDescription() || areaName == MapTypes.SeaOfBygoneEras.GetDescription() || areaName == MapTypes.AncientSacredMountain.GetDescription() || areaName == MapTypes.TempleOfSpace.GetDescription())
{
throw new Exception($"切换独立地图区域[{areaName}]失败");
}
@@ -19,4 +19,7 @@ public enum DisplayMapTypes
[Description("远古圣山")]
AncientSacredMountain,
[Description("空之神殿")]
TempleOfSpace,
}
@@ -18,7 +18,10 @@ public enum MapTypes
SeaOfBygoneEras,
[Description("远古圣山")]
AncientSacredMountain
AncientSacredMountain,
[Description("空之神殿")]
TempleOfSpace,
}
public static class MapTypesExtensions
{
@@ -58,6 +58,7 @@ public static class MapManager
MapTypes.Enkanomiya => new EnkanomiyaMap(),
MapTypes.AncientSacredMountain => new AncientSacredMountainMap(),
MapTypes.SeaOfBygoneEras => new SeaOfBygoneErasMap(),
MapTypes.TempleOfSpace => new TempleOfSpaceMap(),
_ => throw new System.ArgumentException($"未知的地图类型: {mapType}", nameof(mapType))
};
}
@@ -70,6 +71,7 @@ public static class MapManager
MapTypes.Enkanomiya => new EnkanomiyaMapTest(),
MapTypes.AncientSacredMountain => new AncientSacredMountainMap(),
MapTypes.SeaOfBygoneEras => new SeaOfBygoneErasMap(),
MapTypes.TempleOfSpace => new TempleOfSpaceMap(),
_ => throw new System.ArgumentException($"未知的地图类型: {mapType}", nameof(mapType))
};
}
@@ -0,0 +1,33 @@
using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.GameTask.Common.Map.Maps.Base;
using OpenCvSharp;
namespace BetterGenshinImpact.GameTask.Common.Map.Maps;
/// <summary>
/// 空之神殿
/// </summary>
public class TempleOfSpaceMap : SceneBaseMap
{
#region 每次地图扩大都要更新的参数
static readonly int GameMapRows = 4; // 游戏坐标下地图块的行数
static readonly int GameMapCols = 3; // 游戏坐标下地图块的列数
static readonly int GameMapUpRows = 1; // 游戏坐标下 左上角离地图原点的行数(注意原点在0_0块的右下角)
static readonly int GameMapLeftCols = 1; // 游戏坐标下 左上角离地图原点的列数(注意原点在0_0块的右下角)
#endregion 每次地图扩大都要更新的参数
static readonly int TempleOfSpaceMapImageBlockWidth = 1024;
public TempleOfSpaceMap() : base(type: MapTypes.TempleOfSpace,
mapSize: new Size(GameMapCols * TempleOfSpaceMapImageBlockWidth, GameMapRows * TempleOfSpaceMapImageBlockWidth),
mapOriginInImageCoordinate: new Point2f((GameMapLeftCols + 1) * TempleOfSpaceMapImageBlockWidth, (GameMapUpRows + 1) * TempleOfSpaceMapImageBlockWidth),
mapImageBlockWidth: TempleOfSpaceMapImageBlockWidth,
splitRow: 0,
splitCol: 0)
{
ExtractAndSaveFeature(Global.Absolute("Assets/Map/TempleOfSpace/TempleOfSpace_0_1024.png"));
}
}
@@ -315,7 +315,7 @@ namespace BetterGenshinImpact.GameTask
PictureInPictureService.Hide(resetManual: true);
// if (!_prevGameActive)
// {
maskWindow.Invoke(() =>
maskWindow.BeginInvoke(() =>
{
if (maskWindow.IsExist())
{
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Linq;
using BetterGenshinImpact.GameTask.Common.Element.Assets;
using Wpf.Ui.Violeta.Controls;
namespace BetterGenshinImpact.Helpers;
public static class DomainCascadingItems
{
private static IReadOnlyList<ICascadingItem>? _items;
public static IReadOnlyList<ICascadingItem> Items =>
_items ??= BuildItems();
private static IReadOnlyList<ICascadingItem> BuildItems()
{
return MapLazyAssets.Instance.CountryToDomains.Keys
.Reverse()
.Select(country => (ICascadingItem)new CascadingItem(
country,
MapLazyAssets.Instance.CountryToDomains[country]
.AsEnumerable()
.Reverse()
.Select(d => (ICascadingItem)new CascadingItem(
d.Name! + " | " + string.Join(" ", d.Rewards))
{
Tag = d.Name
})
))
.ToList();
}
}
@@ -163,7 +163,7 @@
},
{
"name": "胡桃",
"scriptContent1": "charge(0.3),wait(0.1),dash,wait(0.1),charge(0.3),wait(0.1),dash,wait(0.1),charge(0.3),wait(0.1),j,wait(0.52)",
"scriptContent1": "click,wait(0.25),click,wait(0.05),mousedown,wait(0.265),mouseup,click(right),wait(0.02),keypress(S),wait(0.02),keypress(w),wait(0.35)",
"macroPriority": 0
},
{
@@ -1,108 +0,0 @@
<UserControl x:Class="BetterGenshinImpact.View.Controls.DomainSelector"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
d:DesignHeight="60" d:DesignWidth="300"
Name="Root">
<Grid>
<ToggleButton x:Name="MainToggle"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Padding="12,6"
Height="34"
Background="{DynamicResource ControlFillColorDefaultBrush}"
BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1">
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding SelectedDomain, ElementName=Root, TargetNullValue='请选择', FallbackValue='请选择'}"
VerticalAlignment="Center"
Margin="5,0,0,0"
TextTrimming="CharacterEllipsis"/>
<ui:SymbolIcon Grid.Column="1" Symbol="ChevronDown24" Margin="0,0,10,0"/>
</Grid>
</Border>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
<Popup x:Name="MainPopup"
IsOpen="{Binding IsChecked, ElementName=MainToggle, Mode=TwoWay}"
PlacementTarget="{Binding ElementName=MainToggle}"
StaysOpen="False"
AllowsTransparency="True"
PopupAnimation="Slide"
Opened="MainPopup_Opened"
Closed="MainPopup_Closed">
<Border x:Name="PopupBorder"
Background="{DynamicResource ApplicationBackgroundBrush}"
BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="8"
Margin="0,4,0,0"
Padding="4"
MinHeight="200"
MaxHeight="400"
Width="350"
PreviewMouseWheel="PopupBorder_PreviewMouseWheel">
<Border.Effect>
<DropShadowEffect BlurRadius="10" ShadowDepth="2" Direction="270" Color="Black" Opacity="0.2"/>
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Countries -->
<ui:ListView x:Name="CountriesListView"
ItemsSource="{Binding Countries, ElementName=Root}"
SelectedItem="{Binding SelectedCountry, ElementName=Root, Mode=TwoWay}"
BorderThickness="0"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="False">
<ui:ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Margin="8,4"/>
</DataTemplate>
</ui:ListView.ItemTemplate>
</ui:ListView>
<!-- Divider -->
<Rectangle Grid.Column="1" Width="1" Fill="{DynamicResource SurfaceStrokeColorDefaultBrush}" Margin="2,0"/>
<!-- Domains -->
<ui:ListView Grid.Column="2" x:Name="DomainsListView"
ItemsSource="{Binding FilteredDomains, ElementName=Root}"
SelectedValue="{Binding SelectedDomain, ElementName=Root, Mode=TwoWay}"
SelectedValuePath="Item2.Name"
BorderThickness="0"
SelectionChanged="DomainListView_SelectionChanged"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="False">
<ui:ListView.ItemTemplate>
<DataTemplate>
<TextBlock Margin="8,4">
<Run Text="{Binding Item1, Mode=OneWay}"/>
</TextBlock>
</DataTemplate>
</ui:ListView.ItemTemplate>
</ui:ListView>
</Grid>
</Border>
</Popup>
</Grid>
</UserControl>
@@ -1,218 +0,0 @@
using System;
using BetterGenshinImpact.GameTask.AutoTrackPath.Model;
using BetterGenshinImpact.GameTask.Common.Element.Assets;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace BetterGenshinImpact.View.Controls;
public partial class DomainSelector : UserControl
{
public DomainSelector()
{
InitializeComponent();
Countries = MapLazyAssets.Instance.CountryToDomains.Keys.Reverse().ToList();
Unloaded += OnUnloaded;
}
/// <summary>
/// 控件卸载时清理事件处理器,防止内存泄漏
/// </summary>
private void OnUnloaded(object sender, RoutedEventArgs e)
{
RemoveWindowMouseWheelHandler();
}
public List<string> Countries
{
get { return (List<string>)GetValue(CountriesProperty); }
set { SetValue(CountriesProperty, value); }
}
public static readonly DependencyProperty CountriesProperty =
DependencyProperty.Register("Countries", typeof(List<string>), typeof(DomainSelector), new PropertyMetadata(null));
public string SelectedCountry
{
get { return (string)GetValue(SelectedCountryProperty); }
set { SetValue(SelectedCountryProperty, value); }
}
public static readonly DependencyProperty SelectedCountryProperty =
DependencyProperty.Register("SelectedCountry", typeof(string), typeof(DomainSelector), new PropertyMetadata(null, OnSelectedCountryChanged));
private static void OnSelectedCountryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (DomainSelector)d;
var country = (string)e.NewValue;
if (string.IsNullOrEmpty(country))
{
control.FilteredDomains = new List<System.Tuple<string, GiTpPosition>>();
}
else
{
if (MapLazyAssets.Instance.CountryToDomains.TryGetValue(country, out var domains))
{
// Reverse the list for display
control.FilteredDomains = domains.Select(i => new System.Tuple<string, GiTpPosition>(i.Name! + " | " + string.Join(" ", i.Rewards), i)).Reverse().ToList();
}
else
{
control.FilteredDomains = new List<System.Tuple<string, GiTpPosition>>();
}
}
}
public List<System.Tuple<string, GiTpPosition>> FilteredDomains
{
get { return (List<System.Tuple<string, GiTpPosition>>)GetValue(FilteredDomainsProperty); }
set { SetValue(FilteredDomainsProperty, value); }
}
public static readonly DependencyProperty FilteredDomainsProperty =
DependencyProperty.Register("FilteredDomains", typeof(List<System.Tuple<string, GiTpPosition>>), typeof(DomainSelector), new PropertyMetadata(null));
public string SelectedDomain
{
get { return (string)GetValue(SelectedDomainProperty); }
set { SetValue(SelectedDomainProperty, value); }
}
public static readonly DependencyProperty SelectedDomainProperty =
DependencyProperty.Register("SelectedDomain", typeof(string), typeof(DomainSelector), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedDomainChanged));
private static void OnSelectedDomainChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (DomainSelector)d;
var domain = (string)e.NewValue;
if (string.IsNullOrEmpty(domain)) return;
// Verify if domain matches current country, if not, update country
var country = MapLazyAssets.Instance.GetCountryByDomain(domain);
if (country != null && country != control.SelectedCountry)
{
control.SelectedCountry = country;
}
}
private void DomainListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (MainToggle.IsChecked == true)
{
MainToggle.IsChecked = false;
}
}
/// <summary>
/// Popup 打开时添加全局滚轮事件拦截
/// </summary>
private void MainPopup_Opened(object sender, EventArgs e)
{
var window = Window.GetWindow(this);
if (window != null)
{
window.PreviewMouseWheel -= Window_PreviewMouseWheel;
window.PreviewMouseWheel += Window_PreviewMouseWheel;
}
}
/// <summary>
/// Popup 关闭时移除全局滚轮事件拦截
/// </summary>
private void MainPopup_Closed(object sender, EventArgs e)
{
RemoveWindowMouseWheelHandler();
}
/// <summary>
/// 移除窗口级滚轮事件处理器
/// </summary>
private void RemoveWindowMouseWheelHandler()
{
var window = Window.GetWindow(this);
if (window != null)
{
window.PreviewMouseWheel -= Window_PreviewMouseWheel;
}
}
/// <summary>
/// 全局滚轮事件处理,当 Popup 打开时拦截所有滚轮事件
/// </summary>
private void Window_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (MainPopup.IsOpen)
{
e.Handled = true;
var scrollViewer1 = FindScrollViewer(CountriesListView);
var scrollViewer2 = FindScrollViewer(DomainsListView);
if (scrollViewer1 != null && scrollViewer1.IsMouseOver)
{
scrollViewer1.ScrollToVerticalOffset(scrollViewer1.VerticalOffset - e.Delta / 2.0);
return;
}
if (scrollViewer2 != null && scrollViewer2.IsMouseOver)
{
scrollViewer2.ScrollToVerticalOffset(scrollViewer2.VerticalOffset - e.Delta / 2.0);
return;
}
}
}
/// <summary>
/// 处理 Popup 内的鼠标滚轮事件,防止滚动穿透到外部页面
/// </summary>
private void PopupBorder_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
e.Handled = true;
var scrollViewer1 = FindScrollViewer(CountriesListView);
var scrollViewer2 = FindScrollViewer(DomainsListView);
if (scrollViewer1 != null && scrollViewer1.IsMouseOver)
{
scrollViewer1.ScrollToVerticalOffset(scrollViewer1.VerticalOffset - e.Delta / 2.0);
return;
}
if (scrollViewer2 != null && scrollViewer2.IsMouseOver)
{
scrollViewer2.ScrollToVerticalOffset(scrollViewer2.VerticalOffset - e.Delta / 2.0);
return;
}
}
/// <summary>
/// 在视觉树中查找 ScrollViewer
/// </summary>
private ScrollViewer? FindScrollViewer(DependencyObject parent)
{
if (parent == null) return null;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
if (child is ScrollViewer scrollViewer)
{
return scrollViewer;
}
var result = FindScrollViewer(child);
if (result != null)
{
return result;
}
}
return null;
}
}
@@ -0,0 +1,33 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using BetterGenshinImpact.Helpers;
using Wpf.Ui.Violeta.Controls;
namespace BetterGenshinImpact.View.Converters;
public class DomainNameToCascadingItemConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string name && !string.IsNullOrEmpty(name))
{
foreach (var country in DomainCascadingItems.Items)
{
var found = country.Children?.FirstOrDefault(d => d.Tag as string == name);
if (found != null)
return found;
}
}
return null;
}
public object? ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is ICascadingItem item)
return item.Tag as string;
return null;
}
}
@@ -441,6 +441,20 @@ public partial class MaskWindow : Window
{
}
}
public void BeginInvoke(Action action)
{
try
{
Dispatcher.BeginInvoke(action);
}
catch (TaskCanceledException)
{
}
catch (OperationCanceledException)
{
}
}
public void HideSelf()
{
@@ -5,12 +5,14 @@
xmlns:controls="clr-namespace:BetterGenshinImpact.View.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:helpers="clr-namespace:BetterGenshinImpact.Helpers"
xmlns:local="clr-namespace:BetterGenshinImpact.View.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:oneDragon="clr-namespace:BetterGenshinImpact.ViewModel.Pages.OneDragon"
xmlns:oneDragonView="clr-namespace:BetterGenshinImpact.View.Pages.OneDragon"
xmlns:pages="clr-namespace:BetterGenshinImpact.ViewModel.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:vio="http://schemas.lepo.co/wpfui/2022/xaml/violeta"
d:DataContext="{d:DesignInstance Type=pages:OneDragonFlowViewModel}"
d:DesignHeight="1000"
d:DesignWidth="800"
@@ -444,13 +446,14 @@
Text="秘境名称"
Width="Auto"
TextWrapping="Wrap" />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Width="100"
HorizontalAlignment="Left"
Margin="10,0,10,0"
SelectedDomain="{Binding SelectedConfig.DomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.DomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
<ui:TextBlock Grid.Row="0"
Grid.Column="2"
Margin="10,0,10,0"
@@ -550,11 +553,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.MondayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.MondayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
<Grid.ColumnDefinitions>
@@ -578,11 +582,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.TuesdayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.TuesdayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
<Grid.ColumnDefinitions>
@@ -605,11 +610,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.WednesdayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.WednesdayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
@@ -633,11 +639,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.ThursdayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.ThursdayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
@@ -661,11 +668,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.FridayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.FridayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
@@ -690,11 +698,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.SaturdayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.SaturdayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
@@ -723,11 +732,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.SundayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.SundayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
<Border Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="3"
@@ -9,6 +9,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:BetterGenshinImpact.ViewModel.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:vio="http://schemas.lepo.co/wpfui/2022/xaml/violeta"
xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="TaskSettingsPage"
@@ -1101,6 +1102,36 @@
</Grid>
<Separator Margin="-18,0"
BorderThickness="0,1,0,0" />
<Grid Margin="16,16,16,16"
Visibility="{Binding Config.AutoFightConfig.KazuhaPickupEnabled, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="基于经验值判断拾取(经验值57/58/60,不含传奇120等数字)"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="战斗中检测精英怪死亡经验值图标,未检测到时跳过拾取,避免无价值战斗后浪费时间"
TextWrapping="Wrap" />
<ui:ToggleSwitch Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,36,0"
IsChecked="{Binding Config.AutoFightConfig.ExpBasedPickupEnabled, Mode=TwoWay}" />
</Grid>
<Separator Margin="-18,0"
BorderThickness="0,1,0,0"
Visibility="{Binding Config.AutoFightConfig.KazuhaPickupEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" />
<Grid Margin="16,16,16,16">
<Grid.RowDefinitions>
@@ -1290,12 +1321,13 @@
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="自动传送到刷取的秘境"
TextWrapping="Wrap" />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Width="180"
Margin="0,0,36,0"
SelectedDomain="{Binding Config.AutoDomainConfig.DomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding Config.AutoDomainConfig.DomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
@@ -92,12 +92,39 @@
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="选择自动拾取文字识别引擎"
Text="选择自动拾取识别模式"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="Paddle可识别所有文字,速度慢,消耗少;Yap可识别部分文字,快且准,消耗大"
Text="Ocr: 通过OCR识别物品名; RedNet: 直接推理拾取图像识别物品名"
TextWrapping="Wrap" />
<ComboBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Width="100"
Margin="0,0,8,0"
ItemsSource="{Binding PickRecognitionModeNames}"
SelectedItem="{Binding Config.AutoPickConfig.RecognitionMode, Mode=TwoWay}" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="选择OCR引擎"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="仅在识别模式为 Ocr 时生效:Paddle可识别所有文字,速度慢,消耗少;Yap可识别部分文字,快且准,消耗大"
TextWrapping="Wrap" />
<ComboBox Grid.Row="0"
Grid.RowSpan="2"
@@ -1482,6 +1482,41 @@
Text="二次拾取"
TextWrapping="Wrap" />
</Grid>
<Grid Margin="16">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<DataTrigger Binding="{Binding PathingConfig.AutoFightConfig.KazuhaPickupEnabled}" Value="False">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="基于经验值判断拾取(经验值57/58/60,不含传奇120等数字)"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="战斗中检测精英怪死亡经验数字值图标,未检测到时跳过拾取,避免无价值战斗后浪费时间"
TextWrapping="Wrap" />
<ui:ToggleSwitch Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,36,0"
IsChecked="{Binding PathingConfig.AutoFightConfig.ExpBasedPickupEnabled, Mode=TwoWay}" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -30,6 +30,8 @@ public partial class TriggerSettingsPageViewModel : ViewModel
[ObservableProperty] private string[] _selectChatOptionTypeNames = [SelectChatOptionTypes.UseMouse, SelectChatOptionTypes.UseInteractionKey];
[ObservableProperty] private string[] _pickRecognitionModeNames = [PickRecognitionModeEnum.Ocr.ToString(), PickRecognitionModeEnum.RedNet.ToString()];
[ObservableProperty] private string[] _pickOcrEngineNames = [PickOcrEngineEnum.Paddle.ToString(), PickOcrEngineEnum.Yap.ToString()];
[ObservableProperty] private List<string> _pickButtonNames;
@@ -106,6 +106,10 @@ public partial class MapViewerViewModel : ObservableObject
{
_mapImage = new Mat(Global.Absolute(@"Assets/Map/AncientSacredMountain/AncientSacredMountain_0_1024.png"));
}
else if (mapName == MapTypes.TempleOfSpace.ToString())
{
_mapImage = new Mat(Global.Absolute(@"Assets/Map/TempleOfSpace/TempleOfSpace_0_1024.png"));
}
else
{
throw new Exception("暂时不支持展示路径的地图类型:" + mapName);