Compare commits

...
Author SHA1 Message Date
huiyadanli 275b2a5b90 Update version to 0.54.0 2025-12-08 14:16:52 +00:00
Bread Grocery 08f9312fb3 fix: 清除模块加载缓存导致library中的文件变动后无法生效 (#2525) 2025-12-07 23:38:35 +08:00
ShadowLemoon 15d688797f fix: 优化启动参数的文本框 (#2523) 2025-12-07 23:37:52 +08:00
辉鸭蛋 d282abfd49 恢复自定义的文字区域提取 2025-12-07 10:59:29 +08:00
huiyadanli a0cea560d6 Update version to 0.53.3-alpha.2 2025-12-06 18:15:18 +00:00
辉鸭蛋 9eac844757 优化OCR模型的CPU占用和执行速度 2025-12-07 02:11:04 +08:00
huiyadanli 5b748d6774 Update version to 0.53.3-alpha.1 2025-12-06 13:56:08 +00:00
辉鸭蛋 773b129bde 千星奇遇大厅F键不触发 2025-12-06 18:30:44 +08:00
辉鸭蛋 c26fde5644 6.2 模型 2025-12-06 13:59:18 +08:00
辉鸭蛋 10dcf831e8 6.2 每日提示确认 2025-12-06 13:57:18 +08:00
辉鸭蛋 91c370433c Merge remote-tracking branch 'origin/main' 2025-12-06 11:51:49 +08:00
辉鸭蛋 a9f3f563e1 增强 AutoSkipTrigger 以支持无气泡时识别 F 选项 2025-12-06 11:51:42 +08:00
kaedelcb e3a67f309d F文字菜单UI区域适配 (#2511) 2025-12-06 10:41:54 +08:00
辉鸭蛋 be25f42e47 补充少女的别名 2025-12-06 10:40:54 +08:00
辉鸭蛋 90c6a7d93a 补充少女名字 2025-12-06 09:42:52 +08:00
辉鸭蛋 47f7ac1995 新增角色 2025-12-03 23:51:53 +08:00
郝凯阳 63a936afee auto tcg: update character card config to v6.2 (#2509) 2025-12-03 17:49:43 +08:00
躁动的氨气 7035bca982 Fix namespace import for AutoWoodTask.cs (#2505) 2025-12-01 11:34:24 +08:00
DarkFlameMaster f19a16e1d3 增加模块导入的支持 (#2494) 2025-12-01 00:40:04 +08:00
躁动的氨气 e62a76d238 B服登录的第N次优化 (#2504) 2025-11-30 21:47:46 +08:00
DarkFlameMaster c4df2324b5 自动剧情支持自定义关键词 #2435 (#2497) 2025-11-30 21:47:18 +08:00
ShadowLemoon a9f5541145 refactor: 提取识别并点击按钮的通用方法并添加延迟 (#2503) 2025-11-30 19:37:48 +08:00
ShadowLemoon f8ec331a65 fix: 修复推理设备的更多弹窗大小 (#2502) 2025-11-30 19:36:04 +08:00
躁动的氨气 18efc69d0d 配置弹窗UI优化,更新截取物品图标导航地址 (#2499) 2025-11-30 19:35:46 +08:00
辉鸭蛋 fdd270068d 修复鱼类枚举 2025-11-30 10:36:06 +08:00
huiyadanli 38e541137e Update version to 0.53.2-alpha.4 2025-11-28 13:23:40 +00:00
辉鸭蛋 7bfe4ab87a Merge remote-tracking branch 'origin/main' 2025-11-28 21:21:35 +08:00
辉鸭蛋 ba4ec6f7f6 fix fish type 2025-11-28 21:21:26 +08:00
Jamis 55ed41f878 optimise log display in mask window (#2496) 2025-11-28 10:24:31 +08:00
辉鸭蛋 971151eaa1 添加 using 2025-11-26 21:24:16 +08:00
辉鸭蛋 ea40534851 添加出战角色检测方法2:边缘像素白色比例 2025-11-26 00:17:43 +08:00
huiyadanli 56959d356f Update version to 0.53.2-alpha.3 2025-11-25 14:31:29 +00:00
辉鸭蛋 16f4f5c311 UseGadgetHandler 支持最大CD参数 2025-11-25 22:28:35 +08:00
辉鸭蛋 12efb98edc Merge remote-tracking branch 'origin/main' 2025-11-25 22:19:56 +08:00
辉鸭蛋 b9707c43af 非4个角色情况下,ImageDifferenceDetector.FindMostDifferentImage 抛出错误的问题 2025-11-25 22:19:48 +08:00
huiyadanli eb1a06f4b6 Update version to 0.53.2-alpha.2 2025-11-24 15:01:29 +00:00
辉鸭蛋 89beeeccef 6.0 fish model 2 2025-11-24 22:58:36 +08:00
FishmanTheMurloc 49b78aafe2 修复群友发现的bug (#2492) 2025-11-24 11:03:39 +08:00
kaedelcb dbf489fd04 适配联机相关UI (#2488) 2025-11-23 00:29:13 +08:00
37 changed files with 818 additions and 283 deletions

No files matched your search

@@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyName>BetterGI</AssemblyName>
<Version>0.53.2-alpha.1</Version>
<Version>0.54.0</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
@@ -44,7 +44,7 @@
<PackageReference Include="BetterGI.VCRuntime" Version="14.44.35208" />
<PackageReference Include="BetterGI.Assets.Map" Version="1.0.13" />
<PackageReference Include="BetterGI.Assets.Model" Version="1.0.15" />
<PackageReference Include="BetterGI.Assets.Model" Version="1.0.17" />
<PackageReference Include="BetterGI.Assets.Other" Version="1.0.10" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
@@ -281,8 +281,10 @@ public class PaddleOcrService : IOcrService, IDisposable
/// </summary>
public string OcrWithoutDetector(Mat mat)
{
var startTime = Stopwatch.GetTimestamp();
var str = _localRecModel.Run(mat).Text;
Debug.WriteLine($"PaddleOcrWithoutDetector 结果: {str}");
var time = Stopwatch.GetElapsedTime(startTime);
Debug.WriteLine($"PaddleOcrWithoutDetector 耗时 {time.TotalMilliseconds}ms 结果: {str}");
return str;
}
@@ -407,6 +407,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; // 限制算子间并行线程数(顺序执行)
}
break;
case ProviderType.Dnnl:
sessionOptions.AppendExecutionProvider_Dnnl();
@@ -14,71 +14,79 @@ public class ImageDifferenceDetector
/// <returns>差异最大的图片索引(0-3),如果没有图片获得3票则返回-1</returns>
public static int FindMostDifferentImage(Mat[] images)
{
if (images is not { Length: 4 })
try
{
throw new ArgumentException("必须提供4张图片");
}
// 验证所有图片尺寸相同
Size firstSize = images[0].Size();
for (int i = 1; i < 4; i++)
{
if (images[i].Size() != firstSize)
if (images is not { Length: 4 })
{
throw new ArgumentException("所有图片必须具有相同的尺寸");
throw new ArgumentException("必须提供4张图片");
}
}
// 存储每张图片获得的投票数
int[] votes = new int[4];
// 每张图片投票给与它差异最大的图片
for (int i = 0; i < 4; i++)
{
int maxDiffImageIndex = -1;
double maxDifference = 0;
// 找出与图片i差异最大的图片
for (int j = 0; j < 4; j++)
// 验证所有图片尺寸相同
Size firstSize = images[0].Size();
for (int i = 1; i < 4; i++)
{
if (i != j)
if (images[i].Size() != firstSize)
{
double difference = CalculateDifference(images[i], images[j]);
Debug.WriteLine($"{i} vs {j} 差异像素数量: {difference}");
if (difference > maxDifference)
{
maxDifference = difference;
maxDiffImageIndex = j;
}
throw new ArgumentException("所有图片必须具有相同的尺寸");
}
}
// 图片i投票给差异最大的图片
if (maxDiffImageIndex != -1)
{
votes[maxDiffImageIndex]++;
Debug.WriteLine($"图片 {i} 投票给图片 {maxDiffImageIndex} (差异值: {maxDifference:F2})");
}
}
// 存储每张图片获得的投票数
int[] votes = new int[4];
// 输出投票结果
Debug.WriteLine("\n投票结果:");
for (int i = 0; i < 4; i++)
{
Debug.WriteLine($"图片 {i}: {votes[i]} 票");
}
// 检查是否有图片获得3票
for (int i = 0; i < 4; i++)
{
if (votes[i] >= 3)
// 每张图片投票给与它差异最大的图片
for (int i = 0; i < 4; i++)
{
return i;
int maxDiffImageIndex = -1;
double maxDifference = 0;
// 找出与图片i差异最大的图片
for (int j = 0; j < 4; j++)
{
if (i != j)
{
double difference = CalculateDifference(images[i], images[j]);
Debug.WriteLine($"{i} vs {j} 差异像素数量: {difference}");
if (difference > maxDifference)
{
maxDifference = difference;
maxDiffImageIndex = j;
}
}
}
// 图片i投票给差异最大的图片
if (maxDiffImageIndex != -1)
{
votes[maxDiffImageIndex]++;
Debug.WriteLine($"图片 {i} 投票给图片 {maxDiffImageIndex} (差异值: {maxDifference:F2})");
}
}
// 输出投票结果
Debug.WriteLine("\n投票结果:");
for (int i = 0; i < 4; i++)
{
Debug.WriteLine($"图片 {i}: {votes[i]} 票");
}
// 检查是否有图片获得3票
for (int i = 0; i < 4; i++)
{
if (votes[i] >= 3)
{
return i;
}
}
return -1;
}
catch (Exception ex)
{
Debug.WriteLine($"FindMostDifferentImage 出错: {ex.Message}");
return -1;
}
return -1;
}
/// <summary>
@@ -1,13 +1,14 @@
using BetterGenshinImpact.Core.Script.Dependence;
using System;
using System.Collections.Generic;
using BetterGenshinImpact.Core.Script.Dependence;
using BetterGenshinImpact.Core.Script.Dependence.Model;
using Microsoft.ClearScript;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using OpenCvSharp;
using BetterGenshinImpact.Core.Recognition;
using BetterGenshinImpact.GameTask.Model.Area;
using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.Core.Script.Utils;
using BetterGenshinImpact.GameTask.AutoDomain;
using BetterGenshinImpact.GameTask.AutoFight;
using BetterGenshinImpact.GameTask.AutoFight.Model;
@@ -75,13 +76,30 @@ public class EngineExtend
// 添加C#的类型
engine.AddHostType(typeof(Task));
// 导入 CommonJS 模块
// 导入 JavaScript 模块
// https://microsoft.github.io/ClearScript/2023/01/24/module-interop.html
// https://github.com/microsoft/ClearScript/blob/master/ClearScriptTest/V8ModuleTest.cs
engine.DocumentSettings.AccessFlags = DocumentAccessFlags.EnableFileLoading | DocumentAccessFlags.AllowCategoryMismatch;
if (searchPaths != null)
{
engine.DocumentSettings.SearchPath = string.Join(';', searchPaths);
var normalizedPaths = new List<string>();
foreach (var path in searchPaths)
{
try
{
var normalizedPath = ScriptUtils.NormalizePath(workDir, path);
normalizedPaths.Add(normalizedPath);
}
catch (Exception ex)
{
throw new Exception($"从 library 字段读取路径 '{path}' 失败: {ex.Message}", ex);
}
}
if (normalizedPaths.Count > 0)
{
engine.DocumentSettings.SearchPath = string.Join(';', normalizedPaths);
}
}
}
@@ -122,4 +140,4 @@ public class EngineExtend
engine.AddHostObject("inputText", GlobalMethod.InputText);
#pragma warning restore CS8974 // Converting method group to non-delegate type
}
}
}
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using BetterGenshinImpact.Core.Script.Dependence;
using Microsoft.ClearScript.JavaScript;
namespace BetterGenshinImpact.Core.Script.Project;
@@ -89,7 +90,16 @@ public class ScriptProject
}
try
{
await (Task)engine.Evaluate(code);
if (Manifest.Library.Length != 0)
{
// 清除Document缓存
DocumentLoader.Default.DiscardCachedDocuments();
await (Task)engine.Evaluate(new DocumentInfo { Category = ModuleCategory.Standard }, code);
}
else
{
await (Task)engine.Evaluate(code);
}
}
catch (Exception e)
{
Binary file not shown.

Before

Width:  |  Height:  |  Size: 607 B

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -52,7 +52,7 @@
"奇偶(男)",
"MannequinBoy"
],
"id": "20000001",
"id": "10000117",
"name": "奇偶(男)",
"nameEn": "MannequinBoy",
"weapon": "1"
@@ -62,7 +62,7 @@
"奇偶(女)",
"MannequinGirl"
],
"id": "20000002",
"id": "10000118",
"name": "奇偶(女)",
"nameEn": "MannequinGirl",
"weapon": "1"
@@ -1981,5 +1981,45 @@
"nameEn": "Nefer",
"skillCD": 9,
"weapon": "10"
},
{
"alias": [
"杜林",
"Durin"
],
"burstCD": 18,
"id": "10000123",
"name": "杜林",
"nameEn": "Durin",
"skillCD": 12,
"weapon": "10"
},
{
"alias": [
"雅珂达",
"Jahoda"
],
"burstCD": 18,
"id": "10000124",
"name": "雅珂达",
"nameEn": "Jahoda",
"skillCD": 15,
"weapon": "10"
},
{
"alias": [
"哥伦比娅",
"Columbina",
"少女",
"库塔尔",
"月神",
"月之少女"
],
"burstCD": 15,
"id": "10000125",
"name": "哥伦比娅",
"nameEn": "Columbina",
"skillCD": 17,
"weapon": "10"
}
]
@@ -35,10 +35,12 @@ public class PartyAvatarSideIndexHelper
{
autoFightAssets = AutoFightAssets.Instance;
}
if (logger == null)
{
logger = TaskControl.Logger;
}
var status = new MultiGameStatus();
// 判断当前联机人数
var pRaList = imageRegion.FindMulti(autoFightAssets.PRa);
@@ -246,7 +248,7 @@ public class PartyAvatarSideIndexHelper
public static List<Rect> GetAvatarSideIconRectFromIndexRect(List<Rect> indexRect, ISystemInfo systemInfo)
{
return indexRect.Select(r=> GetAvatarSideIconRectFromIndexRect(r, systemInfo)).ToList();
return indexRect.Select(r => GetAvatarSideIconRectFromIndexRect(r, systemInfo)).ToList();
}
public static bool IsIntersecting(double y1, double h1, double y2, double h2)
@@ -373,8 +375,7 @@ public class PartyAvatarSideIndexHelper
Mat[] mats = new Mat[rectArray.Length];
try
{
var whiteCount = 0;
var notWhiteRectNum = 0;
int whiteCount = 0, notWhiteRectNum = 0;
var mat = imageRegion.CacheGreyMat;
for (int i = 0; i < rectArray.Length; i++)
{
@@ -396,8 +397,22 @@ public class PartyAvatarSideIndexHelper
}
else
{
// 使用更加靠谱的差值识别(-1是未识别)
return ImageDifferenceDetector.FindMostDifferentImage(mats);
// 方法2:边缘像素白色比例
int m2 = FindActiveIndexRectByEdgeColor(mats);
if (m2 > 0)
{
return m2;
}
// 方法3:使用更加靠谱的差值识别(-1是未识别),但是不支持非满队
if (mats.Length == 4)
{
return ImageDifferenceDetector.FindMostDifferentImage(mats);
}
else
{
return -1;
}
}
}
finally
@@ -407,15 +422,13 @@ public class PartyAvatarSideIndexHelper
mat?.Dispose();
}
}
}
public static bool IsWhiteRect(Mat indexMat)
{
var count1 = OpenCvCommonHelper.CountGrayMatColor(indexMat, 251, 255); // 白
var count2 = OpenCvCommonHelper.CountGrayMatColor(indexMat, 50, 54); // 黑色文字
if ((count1 + count2) * 1.0 / (indexMat.Width * indexMat.Height) > 0.4)
if ((count1 + count2) * 1.0 / (indexMat.Width * indexMat.Height) > 0.35)
{
// Debug.WriteLine($"白色矩形占比{(count1 + count2) * 1.0 / (indexMat.Width * indexMat.Height)}");
return true;
@@ -443,7 +456,7 @@ public class PartyAvatarSideIndexHelper
{
return -1;
}
for (int i = 0; i < rectArray.Length; i++)
{
if (IsIntersecting(curr.Y, curr.Height, rectArray[i].Y, rectArray[i].Height))
@@ -454,4 +467,98 @@ public class PartyAvatarSideIndexHelper
return -1;
}
/// <summary>
/// 通过边缘像素颜色识别出战角色编号
/// </summary>
/// <param name="mats"></param>
/// <returns></returns>
public static int FindActiveIndexRectByEdgeColor(Mat[] mats)
{
try
{
int whiteCount = 0, notWhiteRectNum = 0;
for (int i = 0; i < mats.Length; i++)
{
if (CalculateWhiteEdgePixelsRatio(mats[i]) > 0.5)
{
whiteCount++;
}
else
{
notWhiteRectNum = i + 1;
}
}
if (whiteCount == mats.Length - 1)
{
return notWhiteRectNum;
}
else
{
return -1;
}
}
catch (Exception e)
{
Debug.WriteLine(e);
}
return -1;
}
/// <summary>
/// 计算灰度图最边缘一圈中纯白色(255)像素的占比
/// </summary>
/// <returns>返回纯白像素占比 (0.0 到 1.0)</returns>
public static double CalculateWhiteEdgePixelsRatio(Mat image)
{
int whiteCount = 0;
int height = image.Height;
int width = image.Width;
// 如果图片太小,无法获取边缘
if (height < 1 || width < 1)
{
return 0.0;
}
// 计算总边缘像素数
int totalCount = 2 * (width + height - 2);
// 顶边和底边
for (int x = 0; x < width; x++)
{
// 顶边
if (image.At<byte>(0, x) >= 251)
{
whiteCount++;
}
// 底边(避免只有一行时重复计数)
if (height > 1 && image.At<byte>(height - 1, x) >= 251)
{
whiteCount++;
}
}
// 左边和右边(不包括四个角,因为已经在顶边和底边中计算过)
for (int y = 1; y < height - 1; y++)
{
// 左边
if (image.At<byte>(y, 0) >= 251)
{
whiteCount++;
}
// 右边(避免只有一列时重复计数)
if (width > 1 && image.At<byte>(y, width - 1) >= 251)
{
whiteCount++;
}
}
// 计算并返回占比
return totalCount > 0 ? (double)whiteCount / totalCount : 0.0;
}
}
@@ -30,7 +30,7 @@ public class BigFishType
public static readonly BigFishType Rapidfish = new("rapidfish", BaitType.SpinelgrainBait, "斗士急流鱼", 9);
public static readonly BigFishType PhonyUnihornfish = new("phony unihornfish", BaitType.EmberglowBait, "燃素独角鱼", 10);
public static readonly BigFishType MagmaRapidfish = new("magma rapidfish", BaitType.EmberglowBait, "炽岩斗士急流鱼", 9);
public static readonly BigFishType SecretSourceScoutSweeper = new ("secret", BaitType.EmberglowBait, "秘源机关・巡戒使", 9);
public static readonly BigFishType SecretSourceScoutSweeper = new ("secret source", BaitType.EmberglowBait, "秘源机关・巡戒使", 9);
public static readonly BigFishType MaulerShark = new ("mauler shark", BaitType.RefreshingLakkaBait, "凶凶鲨", 9);
public static readonly BigFishType CrystalEye = new("crystal eye", BaitType.RefreshingLakkaBait, "明眼鱼", 9);
@@ -59,6 +59,7 @@ public class BigFishType
yield return Rapidfish;
yield return PhonyUnihornfish;
yield return MagmaRapidfish;
yield return SecretSourceScoutSweeper;
yield return MaulerShark;
yield return CrystalEye;
yield return AxeheadFish;
@@ -996,6 +996,83 @@
}
]
},
{
"id": 1115,
"nameEn": "escoffier",
"type": "character",
"name": "爱可菲",
"hp": 11,
"energy": 2,
"element": "冰元素",
"weapon": "长柄武器",
"skills": [
{
"nameEn": "kitchen_skills",
"name": "后厨手艺",
"skillTag": [
"普通攻击"
],
"cost": [
{
"id": 1101,
"nameEn": "cryo",
"type": "冰元素",
"count": 1
},
{
"id": 1109,
"nameEn": "unaligned_element",
"type": "无色元素",
"count": 2
}
]
},
{
"nameEn": "lowtemperature_cooking",
"name": "低温烹饪",
"skillTag": [
"元素战技"
],
"cost": [
{
"id": 1101,
"nameEn": "cryo",
"type": "冰元素",
"count": 3
}
]
},
{
"nameEn": "scoring_cuts",
"name": "花刀技法",
"skillTag": [
"元素爆发"
],
"cost": [
{
"id": 1101,
"nameEn": "cryo",
"type": "冰元素",
"count": 3
},
{
"id": 1110,
"nameEn": "energy",
"type": "充能",
"count": 2
}
]
},
{
"nameEn": "constant_offthecuff_cookery",
"name": "时时刻刻的即兴料理",
"skillTag": [
"被动技能"
],
"cost": []
}
]
},
{
"id": 1201,
"nameEn": "barbara",
@@ -1715,7 +1792,7 @@
"nameEn": "furina",
"type": "character",
"name": "芙宁娜",
"hp": 10,
"hp": 12,
"energy": 2,
"element": "水元素",
"weapon": "单手剑",
@@ -3001,6 +3078,75 @@
}
]
},
{
"id": 1316,
"nameEn": "gaming",
"type": "character",
"name": "嘉明",
"hp": 10,
"energy": 3,
"element": "火元素",
"weapon": "双手剑",
"skills": [
{
"nameEn": "stellar_rend",
"name": "刃爪悬星",
"skillTag": [
"普通攻击"
],
"cost": [
{
"id": 1103,
"nameEn": "pyro",
"type": "火元素",
"count": 1
},
{
"id": 1109,
"nameEn": "unaligned_element",
"type": "无色元素",
"count": 2
}
]
},
{
"nameEn": "bestial_ascent",
"name": "瑞兽登高楼",
"skillTag": [
"元素战技"
],
"cost": [
{
"id": 1103,
"nameEn": "pyro",
"type": "火元素",
"count": 3
}
]
},
{
"nameEn": "suannis_gilded_dance",
"name": "璨焰金猊舞",
"skillTag": [
"元素爆发"
],
"cost": [
{
"id": 1103,
"nameEn": "pyro",
"type": "火元素",
"count": 3
},
{
"id": 1110,
"nameEn": "energy",
"type": "充能",
"count": 3
}
]
}
]
},
{
"id": 1401,
"nameEn": "fischl",
@@ -3927,7 +4073,7 @@
"nameEn": "iansan",
"type": "character",
"name": "伊安珊",
"hp": 12,
"hp": 11,
"energy": 2,
"element": "雷元素",
"weapon": "长柄武器",
@@ -8690,6 +8836,83 @@
}
]
},
{
"id": 2604,
"nameEn": "black_serpent_knight_rockbreaker_ax",
"type": "character",
"name": "黑蛇骑士·摧岩之钺",
"hp": 12,
"energy": 2,
"element": "岩元素",
"weapon": "其他武器",
"skills": [
{
"nameEn": "supreme_strike",
"name": "顶位迅斩",
"skillTag": [
"普通攻击"
],
"cost": [
{
"id": 1106,
"nameEn": "geo",
"type": "岩元素",
"count": 1
},
{
"id": 1109,
"nameEn": "unaligned_element",
"type": "无色元素",
"count": 2
}
]
},
{
"nameEn": "axe_and_aegis",
"name": "斧盾震击",
"skillTag": [
"元素战技"
],
"cost": [
{
"id": 1106,
"nameEn": "geo",
"type": "岩元素",
"count": 3
}
]
},
{
"nameEn": "stone_stance",
"name": "坚岩姿态",
"skillTag": [
"元素爆发"
],
"cost": [
{
"id": 1106,
"nameEn": "geo",
"type": "岩元素",
"count": 3
},
{
"id": 1110,
"nameEn": "energy",
"type": "充能",
"count": 2
}
]
},
{
"nameEn": "attacking_momentum",
"name": "攻阵气势",
"skillTag": [
"被动技能"
],
"cost": []
}
]
},
{
"id": 2701,
"nameEn": "jadeplume_terrorshroom",
@@ -35,6 +35,13 @@ public class UseGadgetHandler : IActionHandler
}
else
{
double maxWaitSeconds = 100;
if (waypointForTrack != null
&& !string.IsNullOrEmpty(waypointForTrack.ActionParams))
{
double.TryParse(waypointForTrack.ActionParams, out maxWaitSeconds); // 最大等待时间,单位秒
}
var screen = CaptureToRectArea();
var cd = GetCurrentCd(screen);
if (cd > 100)
@@ -46,7 +53,17 @@ public class UseGadgetHandler : IActionHandler
{
Logger.LogInformation("小道具正在CD中,等待CD结束 :{Cd}秒", cd);
// 等待小道具CD结束
var waitTime = (int)(cd * 1000) + 100; // 等待CD结束后再继续
int waitTime; // 等待CD结束后再继续
if (cd > maxWaitSeconds)
{
waitTime = (int)(maxWaitSeconds * 1000);
Logger.LogInformation("CD过长,使用最大CD:{Max}秒", maxWaitSeconds);
}
else
{
waitTime = (int)(cd * 1000) + 100; // 等待CD结束后再继续
}
await Delay(waitTime, ct);
Simulation.SendInput.SimulateAction(GIActions.QuickUseGadget);
}
@@ -55,6 +72,7 @@ public class UseGadgetHandler : IActionHandler
Simulation.SendInput.SimulateAction(GIActions.QuickUseGadget);
}
}
Logger.LogInformation("使用小道具");
await Delay(300, ct);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

@@ -16,6 +16,8 @@ public class AutoPickAssets : BaseAssets<AutoPickAssets>
public RecognitionObject FRo;
public RecognitionObject ChatIconRo;
public RecognitionObject SettingsIconRo;
public RecognitionObject LRo;
public User32.VK PickVk = User32.VK.VK_F;
public RecognitionObject PickRo;
@@ -51,6 +53,18 @@ public class AutoPickAssets : BaseAssets<AutoPickAssets>
DrawOnWindow = false,
DrawOnWindowPen = new Pen(Color.Chocolate, 2)
}.InitTemplate();
LRo = new RecognitionObject
{
Name = "L",
RecognitionType = RecognitionTypes.TemplateMatch,
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoPick", "L.png"),
RegionOfInterest = new Rect(CaptureRect.Width-(int)(110 * AssetScale),
(int)(550 * AssetScale),
(int)(70 * AssetScale),
(int)(100 * AssetScale)),
}.InitTemplate();
PickRo = FRo;
var keyName = TaskContext.Instance().Config.AutoPickConfig.PickKey;
@@ -194,13 +194,20 @@ public partial class AutoPickTrigger : ITaskTrigger
var scale = TaskContext.Instance().SystemInfo.AssetScale;
var config = TaskContext.Instance().Config.AutoPickConfig;
// 存在 L 键位是千星奇遇,无需拾取
using var lKeyRa = content.CaptureRectArea.Find(_autoPickAssets.LRo);
if (lKeyRa.IsExist())
{
return;
}
// 识别到拾取键,开始识别物品图标
var isExcludeIcon = false;
_autoPickAssets.ChatIconRo.RegionOfInterest = new Rect(
foundRectArea.X + (int)(config.ItemIconLeftOffset * scale), foundRectArea.Y,
(int)((config.ItemTextLeftOffset - config.ItemIconLeftOffset) * scale), foundRectArea.Height);
var chatIconRa = content.CaptureRectArea.Find(_autoPickAssets.ChatIconRo);
using var chatIconRa = content.CaptureRectArea.Find(_autoPickAssets.ChatIconRo);
speedTimer.Record("识别聊天图标");
if (!chatIconRa.IsEmpty())
{
@@ -210,7 +217,7 @@ public partial class AutoPickTrigger : ITaskTrigger
else
{
_autoPickAssets.SettingsIconRo.RegionOfInterest = _autoPickAssets.ChatIconRo.RegionOfInterest;
var settingsIconRa = content.CaptureRectArea.Find(_autoPickAssets.SettingsIconRo);
using var settingsIconRa = content.CaptureRectArea.Find(_autoPickAssets.SettingsIconRo);
speedTimer.Record("识别设置图标");
if (!settingsIconRa.IsEmpty())
{
@@ -255,8 +262,7 @@ public partial class AutoPickTrigger : ITaskTrigger
return;
}
// var textMat = new Mat(content.CaptureRectArea.SrcGreyMat, textRect);
var gradMat = new Mat(content.CaptureRectArea.CacheGreyMat,
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)
@@ -273,13 +279,14 @@ public partial class AutoPickTrigger : ITaskTrigger
}
else
{
var textMat = new Mat(content.CaptureRectArea.SrcMat, textRect);
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)
{
// 截取只包含文字的区域
var textOnlyMat = new Mat(textMat, new Rect(0, 0,
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);
@@ -62,6 +62,12 @@ public partial class AutoSkipConfig : ObservableObject
/// </summary>
[ObservableProperty]
private string _clickChatOption = "优先选择第一个选项";
/// <summary>
/// 自定义优先选项文本,每行一个或用分号分隔
/// </summary>
[ObservableProperty]
private string _customPriorityOptions = "";
/// <summary>
/// 自动邀约启用
@@ -96,7 +102,10 @@ public partial class AutoSkipConfig : ObservableObject
{
return ClickChatOption == "随机选择选项";
}
public bool IsClickCustomPriorityOption()
{
return ClickChatOption == "自定义优先选项";
}
public bool IsClickNoneChatOption()
{
return ClickChatOption == "不选择选项";
@@ -544,7 +544,28 @@ public partial class AutoSkipTrigger : ITaskTrigger
if (rs.Count > 0)
{
// 用户自定义关键词 匹配
// 自定义优先选项匹配
if (_config.IsClickCustomPriorityOption() && !string.IsNullOrEmpty(_config.CustomPriorityOptions))
{
var customOptions = _config.CustomPriorityOptions
.Split(new[] { '\r', '\n', ';', ';' }, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim())
.Where(s => !string.IsNullOrEmpty(s))
.ToList();
foreach (var item in rs)
{
foreach (var customOption in customOptions)
{
if (item.Text.Contains(customOption))
{
ClickOcrRegion(item);
return true;
}
}
}
}
// 内置关键词 匹配
foreach (var item in rs)
{
// 选择关键词
@@ -570,6 +591,16 @@ public partial class AutoSkipTrigger : ITaskTrigger
if (_config.AutoGetDailyRewardsEnabled && (item.Text.Contains("每日") || item.Text.Contains("委托")))
{
ClickOcrRegion(item, "每日委托");
TaskControl.Sleep(800);
// 6.2 每日提示确认
var ra1 = TaskControl.CaptureToRectArea();
if (Bv.ClickBlackConfirmButton(ra1))
{
_logger.LogInformation("存在提示并确认");
}
ra1.Dispose();
_prevGetDailyRewardsTime = DateTime.Now; // 记录领取时间
}
else if (_config.AutoReExploreEnabled && (item.Text.Contains("探索") || item.Text.Contains("派遣")))
@@ -629,6 +660,16 @@ public partial class AutoSkipTrigger : ITaskTrigger
return true;
}
else
{
// 没有气泡的时候识别 F 选项
using var pickRa = region.Find(AutoPickAssets.Instance.ChatPickRo);
if (pickRa.IsExist())
{
_postMessageSimulator?.KeyPressBackground(AutoPickAssets.Instance.PickVk);
AutoSkipLog("无气泡图标,但存在交互键,直接按下交互键");
}
}
return false;
}
@@ -549,4 +549,4 @@ public partial class AutoWoodTask : ISoloTask
throw new RetryException("未检测进入游戏界面");
}
}
}
}
@@ -8,6 +8,7 @@ using System.Threading;
using BetterGenshinImpact.GameTask.Model.Area;
using Vanara.PInvoke;
using static BetterGenshinImpact.GameTask.Common.TaskControl;
using BetterGenshinImpact.GameTask;
namespace BetterGenshinImpact.GameTask.AutoWood.Utils;
@@ -107,9 +108,10 @@ internal sealed class Login3rdParty
var (loginWindow, windowType) = GetBiliLoginWindow(process);
if (loginWindow != IntPtr.Zero)
{
var dpiScale = TaskContext.Instance().DpiScale;
if (windowType.Contains("协议"))
{
GameCaptureRegion.GameRegion1080PPosClick(1030, 615);
GameCaptureRegion.GameRegion1080PPosClick(960 + 70 * dpiScale, 540 + 75 * dpiScale);
// 检查窗口是否还存在
var (remainingWindow, remainingType) = GetBiliLoginWindow(process);
@@ -124,7 +126,7 @@ internal sealed class Login3rdParty
if (windowType.Contains("登录"))
{
Thread.Sleep(2000);
GameCaptureRegion.GameRegion1080PPosClick(960, 630);
GameCaptureRegion.GameRegion1080PPosClick(960, 540 + 90 * dpiScale);
Thread.Sleep(2000);
// 检查窗口是否还存在
@@ -6,6 +6,7 @@ using BetterGenshinImpact.GameTask.Model.Area;
using Fischless.WindowsInput;
using OpenCvSharp;
using System.Text.RegularExpressions;
using System.Threading;
namespace BetterGenshinImpact.GameTask.Common.BgiVision;
@@ -17,53 +18,47 @@ namespace BetterGenshinImpact.GameTask.Common.BgiVision;
/// </summary>
public static partial class Bv
{
/// <summary>
/// 通用方法:查找识别对象,如果存在则点击
/// </summary>
/// <param name="captureRa">截图区域</param>
/// <param name="ro">识别对象</param>
/// <returns>是否找到并点击</returns>
public static bool FindAndClick(ImageRegion captureRa, RecognitionObject ro)
{
var ra = captureRa.Find(ro);
if (ra.IsExist())
{
Thread.Sleep(500);
ra.Click();
return true;
}
return false;
}
/// <summary>
/// 点击减少按钮
/// </summary>
/// <param name="captureRa"></param>
/// <returns></returns>
public static bool ClickReduceButton(ImageRegion captureRa)
{
var ra = captureRa.Find(ElementAssets.Instance.Keyreduce);
if (ra.IsExist())
{
ra.Click();
return true;
}
return false;
}
=> FindAndClick(captureRa, ElementAssets.Instance.Keyreduce);
/// <summary>
/// 点击增加按钮
/// </summary>
/// <param name="captureRa"></param>
/// <returns></returns>
public static bool ClickAddButton(ImageRegion captureRa)
{
var ra = captureRa.Find(ElementAssets.Instance.Keyincrease);
if (ra.IsExist())
{
ra.Click();
return true;
}
return false;
}
=> FindAndClick(captureRa, ElementAssets.Instance.Keyincrease);
/// <summary>
/// 点击白色确认按钮
/// </summary>
/// <param name="captureRa"></param>
/// <returns></returns>
public static bool ClickWhiteConfirmButton(ImageRegion captureRa)
{
var ra = captureRa.Find(ElementAssets.Instance.BtnWhiteConfirm);
if (ra.IsExist())
{
ra.Click();
return true;
}
return false;
}
=> FindAndClick(captureRa, ElementAssets.Instance.BtnWhiteConfirm);
/// <summary>
/// 点击白色取消按钮
@@ -71,16 +66,7 @@ public static partial class Bv
/// <param name="captureRa"></param>
/// <returns></returns>
public static bool ClickWhiteCancelButton(ImageRegion captureRa)
{
var ra = captureRa.Find(ElementAssets.Instance.BtnWhiteCancel);
if (ra.IsExist())
{
ra.Click();
return true;
}
return false;
}
=> FindAndClick(captureRa, ElementAssets.Instance.BtnWhiteCancel);
/// <summary>
/// 点击黑色确认按钮
@@ -88,16 +74,7 @@ public static partial class Bv
/// <param name="captureRa"></param>
/// <returns></returns>
public static bool ClickBlackConfirmButton(ImageRegion captureRa)
{
var ra = captureRa.Find(ElementAssets.Instance.BtnBlackConfirm);
if (ra.IsExist())
{
ra.Click();
return true;
}
return false;
}
=> FindAndClick(captureRa, ElementAssets.Instance.BtnBlackConfirm);
/// <summary>
/// 点击黑色取消按钮
@@ -105,16 +82,7 @@ public static partial class Bv
/// <param name="captureRa"></param>
/// <returns></returns>
public static bool ClickBlackCancelButton(ImageRegion captureRa)
{
var ra = captureRa.Find(ElementAssets.Instance.BtnBlackCancel);
if (ra.IsExist())
{
ra.Click();
return true;
}
return false;
}
=> FindAndClick(captureRa, ElementAssets.Instance.BtnBlackCancel);
/// <summary>
/// 点击联机确认按钮
@@ -122,16 +90,7 @@ public static partial class Bv
/// <param name="captureRa"></param>
/// <returns></returns>
public static bool ClickOnlineYesButton(ImageRegion captureRa)
{
var ra = captureRa.Find(ElementAssets.Instance.BtnOnlineYes);
if (ra.IsExist())
{
ra.Click();
return true;
}
return false;
}
=> FindAndClick(captureRa, ElementAssets.Instance.BtnOnlineYes);
/// <summary>
/// 点击联机取消按钮
@@ -139,16 +98,7 @@ public static partial class Bv
/// <param name="captureRa"></param>
/// <returns></returns>
public static bool ClickOnlineNoButton(ImageRegion captureRa)
{
var ra = captureRa.Find(ElementAssets.Instance.BtnOnlineNo);
if (ra.IsExist())
{
ra.Click();
return true;
}
return false;
}
=> FindAndClick(captureRa, ElementAssets.Instance.BtnOnlineNo);
/// <summary>
/// 点击确认按钮(优先点击白色背景的确认按钮)
@@ -157,7 +157,7 @@ public partial class ChooseTalkOptionTask
// 通过最下面的气泡框来文字识别
var lowest = chatOptionResultList[0];
var ocrRect = new Rect((int)(lowest.X + lowest.Width + 8 * assetScale), region.Height / 12,
var ocrRect = new Rect((int)(lowest.X + lowest.Width + 8 * assetScale), region.Height / 8,
(int)(535 * assetScale), (int)(lowest.Y + lowest.Height + 30 * assetScale - region.Height / 12d));
var ocrResList = region.FindMulti(RecognitionObject.Ocr(ocrRect));
@@ -91,7 +91,16 @@ public class GoToAdventurersGuildTask
if (res == TalkOptionRes.FoundAndClick)
{
Logger.LogInformation("▶ {Text}", "领取『每日委托』奖励!");
await Delay(500, ct);
await Delay(800, ct);
// 6.2 每日提示确认
var ra1 = CaptureToRectArea();
if (Bv.ClickBlackConfirmButton(ra1))
{
Logger.LogInformation("存在提示并确认");
}
ra1.Dispose();
await _chooseTalkOptionTask.SelectLastOptionUntilEnd(ct, null, 3); // 点几下
await Bv.WaitUntilFound(ElementAssets.Instance.PaimonMenuRo, ct);
await Delay(500, ct);
@@ -138,7 +138,7 @@ public class SwitchPartyTask
// 点击到最上方
await Task.Delay(50, ct);
GameCaptureRegion.GameRegion1080PPosClick(700, 120);
GameCaptureRegion.GameRegion1080PPosClick(700, 125);
await Task.Delay(50, ct);
Simulation.SendInput.Mouse.LeftButtonDown();
await Task.Delay(450, ct);
@@ -316,15 +316,16 @@ public class GameLoadingTrigger : ITaskTrigger
if (process != null && loginWindow != IntPtr.Zero)
{
var dpiScale = TaskContext.Instance().DpiScale;
if (windowType.Contains("协议"))
{
GameCaptureRegion.GameRegion1080PPosClick(1030, 615);
GameCaptureRegion.GameRegion1080PPosClick(960 + 70 * dpiScale, 540 + 75 * dpiScale);
}
if (windowType.Contains("登录"))
{
Thread.Sleep(2000);
GameCaptureRegion.GameRegion1080PPosClick(960, 630);
GameCaptureRegion.GameRegion1080PPosClick(960, 540 + 90 * dpiScale);
Thread.Sleep(2000);
// 检查窗口是否还存在
@@ -111,7 +111,7 @@ namespace BetterGenshinImpact.GameTask.Model.GameUI
count++;
}
}
avgColSpacing = count == 0 ? 0 : Math.Round(((double)sum) / count, MidpointRounding.AwayFromZero);
avgColSpacing = count == 0 ? 0 : ((double)sum) / count;
}
{
int count = 0;
@@ -130,11 +130,11 @@ namespace BetterGenshinImpact.GameTask.Model.GameUI
count++;
}
}
avgRowSpace = count == 0 ? 0 : Math.Round(((double)sum) / count, MidpointRounding.AwayFromZero);
avgRowSpace = count == 0 ? 0 : ((double)sum) / count;
}
int avgLeft = (int)Math.Round(cells.Average(c => c.Rect.X - (avgWidth + avgColSpacing) * c.ColNum), MidpointRounding.AwayFromZero);
int avgTop = (int)Math.Round(cells.Average(c => c.Rect.Y - (avgHeight + avgRowSpace) * c.RowNum), MidpointRounding.AwayFromZero);
double avgLeft = cells.Average(c => c.Rect.X - (avgWidth + avgColSpacing) * c.ColNum);
double avgTop = cells.Average(c => c.Rect.Y - (avgHeight + avgRowSpace) * c.RowNum);
for (int i = 0; i < cells.Max(r => r.ColNum) + 1; i++)
{
@@ -57,8 +57,8 @@ public class ScriptObjectConverter
/// <summary>
/// <para>适用集合的重载</para>
/// 如果<paramref name="propertyName"/>解析失败,默认返回一个空集合;
/// 如果集合元素解析失败,将跳过该元素
/// 如果<paramref name="propertyName"/>解析失败,返回null;
/// 如果集合元素解析失败,将跳过该元素,因此有可能返回空集合
/// <para>仅支持一层集合,<typeparamref name="T"/>不能再是集合</para>
/// <para>避开反射,享受健康生活</para>
/// </summary>
@@ -66,7 +66,7 @@ public class ScriptObjectConverter
/// <param name="source"></param>
/// <param name="propertyName"></param>
/// <returns></returns>
public static IEnumerable<T> GetValue<T>(ScriptObject source, string propertyName)
public static IEnumerable<T>? GetValue<T>(ScriptObject source, string propertyName)
{
if (source[propertyName] is not Undefined && source[propertyName] != null)
{
@@ -74,7 +74,7 @@ public class ScriptObjectConverter
return TryMap<T>(v8Value);
}
return new T[0];
return null;
}
/// <summary>
+6 -4
View File
@@ -22,10 +22,11 @@ public class SettingItem
{
var list = new List<UIElement>();
var label = new Label
var label = new TextBlock
{
Content = Label,
Margin = new Thickness(0, 0, 0, 5)
Text = Label,
Margin = new Thickness(0, 0, 0, 5),
TextWrapping = TextWrapping.Wrap
};
list.Add(label);
@@ -40,7 +41,8 @@ public class SettingItem
var textBox = new TextBox
{
Name = Name,
Margin = new Thickness(0, 0, 0, 10)
Margin = new Thickness(0, 0, 0, 10),
TextWrapping = TextWrapping.Wrap
};
if (Default != null)
{
+1 -1
View File
@@ -583,7 +583,7 @@ public partial class ScriptService : IScriptService
continue;
}
var content = TaskControl.CaptureToRectArea();
using var content = TaskControl.CaptureToRectArea();
if (Bv.IsInMainUi(content) || Bv.IsInAnyClosableUi(content) || Bv.IsInDomain(content))
{
return;
@@ -205,6 +205,10 @@ public partial class MaskWindow : Window
private void LogTextBoxTextChanged(object sender, TextChangedEventArgs e)
{
if (LogTextBox.Document.Blocks.FirstBlock is Paragraph p && p.Inlines.Count > 100)
{
(p.Inlines as System.Collections.IList).RemoveAt(0);
}
var textRange = new TextRange(LogTextBox.Document.ContentStart, LogTextBox.Document.ContentEnd);
if (textRange.Text.Length > 10000)
{
+27 -33
View File
@@ -399,47 +399,41 @@
</Grid>
<Separator Margin="-18,0" BorderThickness="0,1,0,0" />
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
TextWrapping="Wrap">
<ui:TextBlock.Inlines>
<Run Text="启动参数" />
<ui:HyperlinkButton Grid.Row="1"
Margin="0,0,0,0"
Padding="0"
Command="{Binding OpenGameCommandLineDocumentCommand}"
Cursor="Hand">
<ui:HyperlinkButton.Content>
<TextBlock FontSize="11" Text="打开文档" />
</ui:HyperlinkButton.Content>
</ui:HyperlinkButton>
</ui:TextBlock.Inlines>
</ui:TextBlock>
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="如果你不知道什么是启动参数请不要填写。"
TextWrapping="Wrap" />
<StackPanel Grid.Column="0" VerticalAlignment="Top">
<ui:TextBlock FontTypography="Body" TextWrapping="Wrap">
<ui:TextBlock.Inlines>
<Run Text="启动参数" />
<ui:HyperlinkButton Margin="4,0,0,0"
Padding="0"
Command="{Binding OpenGameCommandLineDocumentCommand}"
Cursor="Hand">
<ui:HyperlinkButton.Content>
<TextBlock FontSize="11" Text="打开文档" />
</ui:HyperlinkButton.Content>
</ui:HyperlinkButton>
</ui:TextBlock.Inlines>
</ui:TextBlock>
<ui:TextBlock Margin="0,4,0,0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="如果你不知道什么是启动参数请不要填写。"
TextWrapping="Wrap" />
</StackPanel>
<!-- 常见启动参数:无边框 -popupwindow 指定分辨率 -screen-width 1920 -screen-height 1080 -->
<ui:TextBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
MinWidth="300"
MaxWidth="800"
<ui:TextBox Grid.Column="1"
Width="300"
Margin="0,0,36,0"
VerticalAlignment="Top"
PlaceholderText="示例:-screen-width 1920"
Text="{Binding Config.GenshinStartConfig.GenshinStartArgs, Mode=TwoWay}"
TextWrapping="Wrap" />
TextWrapping="Wrap"
AcceptsReturn="True" />
</Grid>
<Separator Margin="-18,0" BorderThickness="0,1,0,0" />
<Grid Margin="16">
@@ -328,7 +328,7 @@
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="优先选择第一个选项、选择最后一个选项、不选择选项"
Text="进入对话后,对话选项的选择方式"
TextWrapping="Wrap" />
<ComboBox Grid.Row="0"
Grid.RowSpan="2"
@@ -337,6 +337,47 @@
ItemsSource="{Binding ClickChatOptionNames}"
SelectedItem="{Binding Config.AutoSkipConfig.ClickChatOption, Mode=TwoWay}" />
</Grid>
<Grid Margin="16" x:Name="CustomPriorityOptionsGrid">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Config.AutoSkipConfig.ClickChatOption}" Value="自定义优先选项">
<Setter Property="Visibility" Value="Visible"/>
</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="自定义优先选项(后台模式无效)"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Margin="0,-10,0,0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="多个选项用分号(中英文)分隔,或者换行"
TextWrapping="Wrap" />
<ui:TextBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
MinWidth="250"
MinHeight="60"
Margin="0,0,24,0"
AcceptsReturn="True"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto"
Text="{Binding Config.AutoSkipConfig.CustomPriorityOptions, Mode=TwoWay}" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -21,9 +21,10 @@
<BooleanToVisibilityConverter x:Key="BoolToVisConverter"/>
</UserControl.Resources>
<Grid>
<StackPanel>
<ScrollViewer MaxHeight="350" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="0,0,20,0">
<!--<TextBlock Margin="0,0,0,10" Text="执行周期" />
<!--<TextBlock Margin="0,0,0,10" Text="执行周期" />
<ComboBox Margin="0,0,0,20"
DisplayMemberPath="Value"
ItemsSource="{Binding Source={StaticResource ScheduleDescriptionsProvider}}"
@@ -33,64 +34,65 @@
<TextBlock Margin="0,0,0,10" Text="执行次数" />
<TextBox Margin="0,0,0,20" Text="{Binding RunNum, Mode=TwoWay}" />-->
<TextBlock Margin="0,0,0,10" Text="状态" />
<ComboBox DisplayMemberPath="Value"
ItemsSource="{Binding Source={StaticResource StatusDescriptionsProvider}}"
SelectedValue="{Binding Status, Mode=TwoWay}"
SelectedValuePath="Key" />
<TextBlock Margin="0,10,0,5" Text="JS 通知权限"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}"/>
<ComboBox Margin="0,0,0,10"
ItemsSource="{Binding JsNotificationOptions}"
DisplayMemberPath="Value"
SelectedValuePath="Key"
IsEnabled="{Binding GlobalJsNotificationEnabled}"
ToolTip="{Binding JsNotificationToolTip}"
SelectedValue="{Binding AllowJsNotification, Mode=TwoWay}"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}">
</ComboBox>
<TextBlock Margin="0,10,0,5" Text="JS HTTP权限"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}"/>
<TextBlock Margin="0,0,0,5"
Text="允许脚本发送HTTP请求,可能会带来安全风险,请谨慎开启。"
Foreground="Orange"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}"/>
<TextBlock Margin="0,0,0,5"
Text="注意:脚本更新http_allowed_urls后,需手动重新启用权限。"
Foreground="Orange"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}"/>
<ItemsControl Margin="0,0,0,0" ItemsSource="{Binding JsHTTPInfoText}"
<TextBlock Margin="0,0,0,10" Text="状态" />
<ComboBox DisplayMemberPath="Value"
ItemsSource="{Binding Source={StaticResource StatusDescriptionsProvider}}"
SelectedValue="{Binding Status, Mode=TwoWay}"
SelectedValuePath="Key" />
<TextBlock Margin="0,10,0,5" Text="JS 通知权限"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}"/>
<ComboBox Margin="0,0,0,10"
ItemsSource="{Binding JsNotificationOptions}"
DisplayMemberPath="Value"
SelectedValuePath="Key"
IsEnabled="{Binding GlobalJsNotificationEnabled}"
ToolTip="{Binding JsNotificationToolTip}"
SelectedValue="{Binding AllowJsNotification, Mode=TwoWay}"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}"
Foreground="{Binding Color}"
FontSize="11"
TextWrapping="NoWrap"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl Margin="0,0,0,10" ItemsSource="{Binding JsHTTPInfo}"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding Text}"
IsReadOnly="True"
Foreground="{Binding Color}"
FontSize="11"
FontFamily="Consolas"
TextWrapping="NoWrap"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ComboBox DisplayMemberPath="Value"
ItemsSource="{Binding JsNotificationOptions}"
SelectedValue="{Binding AllowJsHTTP, Mode=TwoWay}"
SelectedValuePath="Key"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}">
</ComboBox>
</ComboBox>
</StackPanel>
<TextBlock Margin="0,10,0,5" Text="JS HTTP权限"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}"/>
<TextBlock Margin="0,0,0,5"
Text="允许脚本发送HTTP请求,可能会带来安全风险,请谨慎开启。"
Foreground="Orange"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}"/>
<TextBlock Margin="0,0,0,5"
Text="注意:脚本更新http_allowed_urls后,需手动重新启用权限。"
Foreground="Orange"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}"/>
<ItemsControl Margin="0,0,0,0" ItemsSource="{Binding JsHTTPInfoText}"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}"
Foreground="{Binding Color}"
FontSize="11"
TextWrapping="NoWrap"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl Margin="0,0,0,10" ItemsSource="{Binding JsHTTPInfo}"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding Text}"
IsReadOnly="True"
Foreground="{Binding Color}"
FontSize="11"
FontFamily="Consolas"
TextWrapping="NoWrap"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ComboBox DisplayMemberPath="Value"
ItemsSource="{Binding JsNotificationOptions}"
SelectedValue="{Binding AllowJsHTTP, Mode=TwoWay}"
SelectedValuePath="Key"
Visibility="{Binding IsJsScript, Converter={StaticResource BoolToVisConverter}}">
</ComboBox>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
@@ -510,8 +510,11 @@ public partial class HomePageViewModel : ViewModel
{
Title = "硬件加速设置",
Content = new HardwareAccelerationView(new HardwareAccelerationViewModel()),
SizeToContent = SizeToContent.WidthAndHeight,
ResizeMode = ResizeMode.NoResize,
Width = 800,
Height = 600,
MinWidth = 800,
MaxWidth = 800,
MinHeight = 600,
Owner = Application.Current.MainWindow,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
ExtendsContentIntoTitleBar = true,
@@ -633,7 +633,7 @@ public partial class TaskSettingsPageViewModel : ViewModel
[RelayCommand]
private async Task OnGoToGetGridIconsUrlAsync()
{
await Launcher.LaunchUriAsync(new Uri("https://bettergi.com/feats/task/getGridIcons.html"));
await Launcher.LaunchUriAsync(new Uri("https://bettergi.com/dev/getGridIcons.html"));
}
[RelayCommand]
@@ -21,7 +21,7 @@ namespace BetterGenshinImpact.ViewModel.Pages;
public partial class TriggerSettingsPageViewModel : ViewModel
{
[ObservableProperty] private string[] _clickChatOptionNames = ["优先选择第一个选项", "随机选择选项", "优先选择最后一个选项", "不选择选项"];
[ObservableProperty] private string[] _clickChatOptionNames = ["优先选择第一个选项", "随机选择选项","自定义优先选项", "优先选择最后一个选项", "不选择选项"];
[ObservableProperty] private string[] _selectChatOptionTypeNames = [SelectChatOptionTypes.UseMouse, SelectChatOptionTypes.UseInteractionKey];
@@ -125,6 +125,20 @@ public class ScriptGroupProjectEditorViewModel : ObservableObject
public ScriptGroupProjectEditorViewModel(ScriptGroupProject project)
{
_project = project ?? throw new ArgumentNullException(nameof(project));
// 如果是JS脚本,每次打开配置窗口时强制重新加载项目信息,以读取最新的manifest.json
if (_project.Type == "Javascript")
{
try
{
_project.BuildScriptProjectRelation();
}
catch
{
// 忽略加载失败,避免无法打开窗口,界面上会显示相关错误或为空
}
}
_globalNotificationConfig = TaskContext.Instance().Config.NotificationConfig;
// 监听全局配置变更
_project.PropertyChanged += (s, e) =>
@@ -1,4 +1,5 @@
using BetterGenshinImpact.Core.Recognition.OpenCv;
using BetterGenshinImpact.GameTask.AutoFight.Model;
using OpenCvSharp;
namespace BetterGenshinImpact.Test.Cv;
@@ -16,4 +17,13 @@ public class ImageDifferenceDetectorTest
Console.WriteLine($"差异最大的图片索引是: {i}");
}
public static void Test2()
{
Console.WriteLine($"1: {PartyAvatarSideIndexHelper.CalculateWhiteEdgePixelsRatio(Cv2.ImRead(@"E:\1.png", ImreadModes.Grayscale))}");
Console.WriteLine($"2: {PartyAvatarSideIndexHelper.CalculateWhiteEdgePixelsRatio(Cv2.ImRead(@"E:\2.png", ImreadModes.Grayscale))}");
Console.WriteLine($"3: {PartyAvatarSideIndexHelper.CalculateWhiteEdgePixelsRatio(Cv2.ImRead(@"E:\3.png", ImreadModes.Grayscale))}");
Console.WriteLine($"4: {PartyAvatarSideIndexHelper.CalculateWhiteEdgePixelsRatio(Cv2.ImRead(@"E:\4.png", ImreadModes.Grayscale))}");
}
}