Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8fba493c1 | ||
|
|
96f523d4b8 | ||
|
|
f8e231c235 | ||
|
|
58bceffe0e | ||
|
|
4c6232fdb3 | ||
|
|
1eb483b639 | ||
|
|
796bda0af3 | ||
|
|
6d8bbc18fc | ||
|
|
753c595625 | ||
|
|
88bd60ab93 | ||
|
|
36669b89ef | ||
|
|
70b3f6dd99 |
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyName>BetterGI</AssemblyName>
|
||||
<Version>0.60.2-alpha.4</Version>
|
||||
<Version>0.61.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.19" />
|
||||
<PackageReference Include="BetterGI.Assets.Model" Version="1.0.22" />
|
||||
<PackageReference Include="BetterGI.Assets.Model" Version="1.0.23" />
|
||||
<PackageReference Include="BetterGI.Assets.Other" Version="1.0.15" />
|
||||
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
|
||||
@@ -21,10 +21,12 @@ public class BvLocator
|
||||
{
|
||||
private static readonly ILogger Logger = App.GetLogger<BvLocator>();
|
||||
private readonly CancellationToken _cancellationToken;
|
||||
private int? _timeout;
|
||||
private int? _retryInterval;
|
||||
|
||||
public RecognitionObject RecognitionObject { get; }
|
||||
|
||||
public Action<List<Region>>? RetryAction { get; set; }
|
||||
public Func<List<Region>, Task>? RetryAction { get; set; }
|
||||
|
||||
public static int DefaultTimeout { get; set; } = 10000;
|
||||
|
||||
@@ -98,17 +100,21 @@ public class BvLocator
|
||||
|
||||
public async Task<List<Region>> WaitFor(int? timeout = null)
|
||||
{
|
||||
var actualTimeout = timeout ?? DefaultTimeout;
|
||||
var retryCount = actualTimeout / DefaultRetryInterval;
|
||||
var actualTimeout = timeout ?? _timeout ?? DefaultTimeout;
|
||||
var actualRetryInterval = _retryInterval ?? DefaultRetryInterval;
|
||||
var retryCount = Math.Max(1, actualTimeout / actualRetryInterval);
|
||||
|
||||
List<Region> results = [];
|
||||
var retryRes = await NewRetry.WaitForAction(() =>
|
||||
var retryRes = await NewRetry.WaitForAction(async () =>
|
||||
{
|
||||
results = FindAll();
|
||||
var b = results.Count > 0;
|
||||
RetryAction?.Invoke(results);
|
||||
if (!b && RetryAction != null)
|
||||
{
|
||||
await RetryAction(results);
|
||||
}
|
||||
return b;
|
||||
}, _cancellationToken, retryCount, DefaultRetryInterval);
|
||||
}, _cancellationToken, retryCount, actualRetryInterval);
|
||||
|
||||
if (retryRes)
|
||||
{
|
||||
@@ -150,20 +156,21 @@ public class BvLocator
|
||||
|
||||
public async Task WaitForDisappear(int? timeout = null)
|
||||
{
|
||||
var actualTimeout = timeout ?? DefaultTimeout;
|
||||
var retryCount = actualTimeout / DefaultRetryInterval;
|
||||
var actualTimeout = timeout ?? _timeout ?? DefaultTimeout;
|
||||
var actualRetryInterval = _retryInterval ?? DefaultRetryInterval;
|
||||
var retryCount = Math.Max(1, actualTimeout / actualRetryInterval);
|
||||
|
||||
var retryRes = await NewRetry.WaitForAction(() =>
|
||||
var retryRes = await NewRetry.WaitForAction(async () =>
|
||||
{
|
||||
var results = FindAll();
|
||||
var b = results.Count == 0;
|
||||
if (!b)
|
||||
if (!b && RetryAction != null)
|
||||
{
|
||||
RetryAction?.Invoke(results);
|
||||
await RetryAction(results);
|
||||
}
|
||||
|
||||
return b;
|
||||
}, _cancellationToken, retryCount, DefaultRetryInterval);
|
||||
}, _cancellationToken, retryCount, actualRetryInterval);
|
||||
|
||||
if (!retryRes)
|
||||
{
|
||||
@@ -205,19 +212,77 @@ public class BvLocator
|
||||
|
||||
public BvLocator WithRetryAction(Action<List<Region>>? action)
|
||||
{
|
||||
RetryAction = action;
|
||||
if (action == null)
|
||||
{
|
||||
RetryAction = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
RetryAction = (results) =>
|
||||
{
|
||||
action(results);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置超时时间(毫秒)
|
||||
/// </summary>
|
||||
/// <param name="timeout">超时时间(毫秒)</param>
|
||||
/// <returns></returns>
|
||||
public BvLocator WithTimeout(int timeout)
|
||||
{
|
||||
if (timeout <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(timeout), "timeout 必须大于 0");
|
||||
}
|
||||
_timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置重试间隔(毫秒)
|
||||
/// </summary>
|
||||
/// <param name="retryInterval">重试间隔(毫秒)</param>
|
||||
/// <returns></returns>
|
||||
public BvLocator WithRetryInterval(int retryInterval)
|
||||
{
|
||||
if (retryInterval <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(retryInterval), "retryInterval 必须大于 0");
|
||||
}
|
||||
_retryInterval = retryInterval;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为 JavaScript 提供的动态参数重载
|
||||
/// 解决 ClearScript 无法将 JS 函数隐式转换为 Action 委托的问题
|
||||
/// 支持同步和异步 JS 函数
|
||||
/// </summary>
|
||||
/// <param name="action">JS 回调函数</param>
|
||||
/// <returns></returns>
|
||||
public BvLocator WithRetryAction(dynamic action)
|
||||
{
|
||||
RetryAction = (results) => action(results);
|
||||
if (action == null)
|
||||
{
|
||||
RetryAction = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
RetryAction = async (results) =>
|
||||
{
|
||||
var taskResult = action(results);
|
||||
// 如果 JS 返回的是 Promise/Task,等待其完成
|
||||
if (taskResult is Task task)
|
||||
{
|
||||
await task;
|
||||
}
|
||||
};
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -145,6 +145,35 @@ public class HtmlMask : IDisposable
|
||||
/// </summary>
|
||||
public bool Exists(string id) => HtmlMaskWindow.Exists(id);
|
||||
|
||||
/// <summary>
|
||||
/// 设置窗口的点击穿透模式
|
||||
/// </summary>
|
||||
/// <param name="windowId">窗口ID</param>
|
||||
/// <param name="enabled">true=点击穿透,false=可交互</param>
|
||||
public void SetClickThrough(string windowId, bool enabled)
|
||||
{
|
||||
HtmlMaskWindow.SetClickThrough(windowId, enabled);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取窗口的点击穿透状态
|
||||
/// </summary>
|
||||
/// <param name="windowId">窗口ID</param>
|
||||
/// <returns>true=点击穿透,false=可交互</returns>
|
||||
public bool GetClickThrough(string windowId)
|
||||
{
|
||||
return HtmlMaskWindow.GetClickThrough(windowId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换窗口的点击穿透模式
|
||||
/// </summary>
|
||||
/// <param name="windowId">窗口ID</param>
|
||||
public void ToggleClickThrough(string windowId)
|
||||
{
|
||||
HtmlMaskWindow.ToggleClickThrough(windowId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息通信
|
||||
|
||||
@@ -96,7 +96,7 @@ public class EngineExtend
|
||||
// 导入 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;
|
||||
engine.DocumentSettings.AccessFlags = DocumentAccessFlags.AllowCategoryMismatch;
|
||||
if (searchPaths != null)
|
||||
{
|
||||
var normalizedPaths = new List<string>();
|
||||
|
||||
@@ -9,7 +9,7 @@ using Microsoft.ClearScript.JavaScript;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script
|
||||
{
|
||||
public class PackageDocumentLoader : DocumentLoader
|
||||
public class PackageDocumentLoader : DefaultDocumentLoader
|
||||
{
|
||||
private readonly string _scriptRootPath;
|
||||
|
||||
@@ -22,21 +22,42 @@ namespace BetterGenshinImpact.Core.Script
|
||||
{
|
||||
string? targetPath = ResolvePhysicalPath(settings, sourceInfo, specifier);
|
||||
|
||||
// ResolvePhysicalPath 可能因 sourceInfo 为空而失败,直接从脚本根目录兜底
|
||||
if (targetPath == null || !File.Exists(targetPath))
|
||||
{
|
||||
return await Default.LoadDocumentAsync(settings, sourceInfo, specifier, category, contextCallback);
|
||||
var stripped = Regex.Replace(specifier, @"^(?:\.\.?/)+", "");
|
||||
if (!Path.IsPathRooted(stripped))
|
||||
{
|
||||
var fullPath = Path.GetFullPath(Path.Combine(_scriptRootPath, stripped));
|
||||
if (fullPath.StartsWith(_scriptRootPath, StringComparison.OrdinalIgnoreCase)
|
||||
&& File.Exists(fullPath))
|
||||
{
|
||||
targetPath = fullPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetPath == null || !File.Exists(targetPath))
|
||||
{
|
||||
throw new FileNotFoundException($"无法解析模块导入路径: '{specifier}'", specifier);
|
||||
}
|
||||
|
||||
// 处理 JS 文件的重写
|
||||
if (Path.GetExtension(targetPath).ToLower() == ".js")
|
||||
{
|
||||
var uri = new Uri(targetPath);
|
||||
|
||||
// 检查缓存
|
||||
var cached = GetCachedDocument(uri);
|
||||
if (cached != null) return cached;
|
||||
|
||||
string content = await File.ReadAllTextAsync(targetPath);
|
||||
string processedCode = RewriteScriptCode(content, targetPath);
|
||||
var documentInfo = new DocumentInfo(new Uri(targetPath)) { Category = ModuleCategory.Standard };
|
||||
return new StringDocument(documentInfo, processedCode);
|
||||
var documentInfo = new DocumentInfo(uri) { Category = ModuleCategory.Standard };
|
||||
return CacheDocument(new StringDocument(documentInfo, processedCode), false);
|
||||
}
|
||||
|
||||
return await Default.LoadDocumentAsync(settings, sourceInfo, specifier, category, contextCallback);
|
||||
throw new FileNotFoundException($"不支持的模块导入类型: '{specifier}' (仅支持 .js 文件)", specifier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -54,11 +75,9 @@ namespace BetterGenshinImpact.Core.Script
|
||||
{
|
||||
string importPart = match.Groups[1].Value.Trim();
|
||||
string quote = match.Groups[2].Value;
|
||||
string rawPath = match.Groups[3].Value;
|
||||
|
||||
string path = rawPath.Replace("../../../packages", "packages");
|
||||
string path = match.Groups[3].Value.Replace("../../../packages", "packages");
|
||||
string? resourceFullPath = ResolvePathInternal(null, currentFilePath, path);
|
||||
|
||||
|
||||
if (resourceFullPath != null && File.Exists(resourceFullPath))
|
||||
{
|
||||
string normalizedPath = Path.GetRelativePath(_scriptRootPath, resourceFullPath).Replace("\\", "/");
|
||||
@@ -88,7 +107,24 @@ namespace BetterGenshinImpact.Core.Script
|
||||
|
||||
private string? ResolvePhysicalPath(DocumentSettings settings, DocumentInfo? sourceInfo, string specifier)
|
||||
{
|
||||
return ResolvePathInternal(settings.SearchPath, sourceInfo?.Name, specifier);
|
||||
string? referrer = null;
|
||||
if (sourceInfo.HasValue)
|
||||
{
|
||||
var sourceUri = sourceInfo.Value.Uri;
|
||||
if (sourceUri != null && sourceUri.IsAbsoluteUri && sourceUri.IsFile)
|
||||
{
|
||||
referrer = sourceUri.LocalPath;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(sourceInfo.Value.Name))
|
||||
{
|
||||
if (Uri.TryCreate(sourceInfo.Value.Name, UriKind.Absolute, out var nameUri) && nameUri.IsFile)
|
||||
{
|
||||
referrer = nameUri.LocalPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ResolvePathInternal(settings.SearchPath, referrer, specifier);
|
||||
}
|
||||
|
||||
private string? ResolvePathInternal(string? searchPath, string? referrer, string specifier)
|
||||
@@ -98,6 +134,12 @@ namespace BetterGenshinImpact.Core.Script
|
||||
return ProbeFile(Path.Combine(_scriptRootPath, specifier));
|
||||
}
|
||||
|
||||
var packagesMatch = Regex.Match(specifier, @"^(?:\.\.\/)+(packages/.*)$");
|
||||
if (packagesMatch.Success)
|
||||
{
|
||||
return ProbeFile(Path.Combine(_scriptRootPath, packagesMatch.Groups[1].Value));
|
||||
}
|
||||
|
||||
if (specifier.StartsWith("."))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(referrer))
|
||||
@@ -128,8 +170,9 @@ namespace BetterGenshinImpact.Core.Script
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(path)) return path;
|
||||
if (File.Exists(path + ".js")) return path + ".js";
|
||||
var normalized = Path.GetFullPath(path);
|
||||
if (File.Exists(normalized)) return normalized;
|
||||
if (File.Exists(normalized + ".js")) return normalized + ".js";
|
||||
}
|
||||
catch { }
|
||||
return null;
|
||||
|
||||
@@ -2075,5 +2075,41 @@
|
||||
"nameEn": "Linnea",
|
||||
"skillCD": 18,
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [
|
||||
"洛恩",
|
||||
"Lohen"
|
||||
],
|
||||
"burstCD": 15,
|
||||
"id": "10000129",
|
||||
"name": "洛恩",
|
||||
"nameEn": "Lohen",
|
||||
"skillCD": 18,
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [
|
||||
"尼可",
|
||||
"Nicole"
|
||||
],
|
||||
"burstCD": 15,
|
||||
"id": "10000131",
|
||||
"name": "尼可",
|
||||
"nameEn": "Nicole",
|
||||
"skillCD": 16,
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [
|
||||
"布伦妮",
|
||||
"Prune"
|
||||
],
|
||||
"burstCD": 18,
|
||||
"id": "10000132",
|
||||
"name": "布伦妮",
|
||||
"nameEn": "Prune",
|
||||
"skillCD": 15,
|
||||
"weapon": "10"
|
||||
}
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Script;
|
||||
using BetterGenshinImpact.Model;
|
||||
@@ -74,6 +75,7 @@ public class OneKeyFightTask : Singleton<OneKeyFightTask>
|
||||
else
|
||||
{
|
||||
_cts.Cancel();
|
||||
Simulation.ReleaseAllKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,6 +91,7 @@ public class OneKeyFightTask : Singleton<OneKeyFightTask>
|
||||
if (IsHoldOnMode())
|
||||
{
|
||||
_cts?.Cancel();
|
||||
Simulation.ReleaseAllKey();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,9 +182,9 @@ public class OneKeyFightTask : Singleton<OneKeyFightTask>
|
||||
// 通用化战斗策略
|
||||
foreach (var command in combatCommands)
|
||||
{
|
||||
if (ct.IsCancellationRequested) break;
|
||||
if (command.ActivatingRound != null && command.ActivatingRound.Count > 0 && !command.ActivatingRound.Contains(round))
|
||||
{
|
||||
// 跳过强制首轮指令
|
||||
continue;
|
||||
}
|
||||
command.Execute(activeAvatar);
|
||||
|
||||
@@ -717,7 +717,7 @@
|
||||
"nameEn": "wriothesley",
|
||||
"type": "character",
|
||||
"name": "莱欧斯利",
|
||||
"hp": 10,
|
||||
"hp": 11,
|
||||
"energy": 3,
|
||||
"element": "冰元素",
|
||||
"weapon": "法器",
|
||||
@@ -4670,6 +4670,83 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1418,
|
||||
"nameEn": "flins",
|
||||
"type": "character",
|
||||
"name": "菲林斯",
|
||||
"hp": 10,
|
||||
"energy": 4,
|
||||
"element": "雷元素",
|
||||
"weapon": "长柄武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "pocztowy_demonspear",
|
||||
"name": "扈圣魔枪",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "ancient_rite_arcane_light",
|
||||
"name": "古律·孤灯遗秘",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "ancient_ritual_cometh_the_night",
|
||||
"name": "旧仪·夜客致访",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 4
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "moonsign_benediction_old_world_secrets",
|
||||
"name": "月兆祝赐·旧世潜藏",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1501,
|
||||
"nameEn": "sucrose",
|
||||
@@ -5296,7 +5373,7 @@
|
||||
"nameEn": "xianyun",
|
||||
"type": "character",
|
||||
"name": "闲云",
|
||||
"hp": 10,
|
||||
"hp": 11,
|
||||
"energy": 2,
|
||||
"element": "风元素",
|
||||
"weapon": "法器",
|
||||
@@ -7224,6 +7301,83 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1711,
|
||||
"nameEn": "lauma",
|
||||
"type": "character",
|
||||
"name": "菈乌玛",
|
||||
"hp": 11,
|
||||
"energy": 2,
|
||||
"element": "草元素",
|
||||
"weapon": "法器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "peregrination_of_linnunrata",
|
||||
"name": "林麓旅踏",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "runo_dawnless_rest_of_karsikko",
|
||||
"name": "圣言述咏·终宵永眠",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "runo_all_hearts_become_the_beating_moon",
|
||||
"name": "圣言述咏·众心为月",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "moonsign_benediction_natures_chorus",
|
||||
"name": "月兆祝赐·千籁恩宠",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2101,
|
||||
"nameEn": "fatui_cryo_cicin_mage",
|
||||
@@ -9515,6 +9669,75 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2605,
|
||||
"nameEn": "experimental_field_generator",
|
||||
"type": "character",
|
||||
"name": "实验性场力发生装置",
|
||||
"hp": 11,
|
||||
"energy": 2,
|
||||
"element": "岩元素",
|
||||
"weapon": "其他武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "gravity_application_crush",
|
||||
"name": "重力应用程式·砸击",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "gravity_application_point_null",
|
||||
"name": "重力应用程式·点状抵消",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "gravity_application_field_reduction",
|
||||
"name": "重力应用程式·削减场域",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2701,
|
||||
"nameEn": "jadeplume_terrorshroom",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"language": "CHS",
|
||||
"version": "56882a11588d5e79a1b6b51739f9fb27e9952fd7",
|
||||
"version": "cffc7f010f1a4bf4a0bdfb0865d0737d4aec6b7a",
|
||||
"data": [
|
||||
{
|
||||
"sceneId": 3,
|
||||
@@ -14224,6 +14224,29 @@
|
||||
9669.12
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2003,
|
||||
"type": "BlessDomain",
|
||||
"name": "山风的荆冕",
|
||||
"country": "蒙德",
|
||||
"areas": [
|
||||
"风息山"
|
||||
],
|
||||
"position": [
|
||||
3266.666,
|
||||
290.28,
|
||||
47.39246
|
||||
],
|
||||
"tranPosition": [
|
||||
3258.3,
|
||||
289.17,
|
||||
47.8
|
||||
],
|
||||
"rewards": [
|
||||
"天之美赐",
|
||||
"影中沉凝的幻灭"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2009,
|
||||
"type": "TeleportWaypoint",
|
||||
@@ -14318,6 +14341,31 @@
|
||||
347.94803,
|
||||
-217.91002
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2053,
|
||||
"type": "TrounceDomain",
|
||||
"name": "万有涅槃缚境",
|
||||
"country": "须弥",
|
||||
"areas": [
|
||||
"护世森",
|
||||
"茸蕈窟"
|
||||
],
|
||||
"position": [
|
||||
221.1095,
|
||||
270.9658,
|
||||
2915.052
|
||||
],
|
||||
"tranPosition": [
|
||||
217.3052,
|
||||
268.16556,
|
||||
2917.7302
|
||||
],
|
||||
"rewards": [
|
||||
"亵渎的新芽",
|
||||
"扭曲的枯枝",
|
||||
"赝作的树脂"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -16234,4 +16282,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -89,6 +89,28 @@ public static class NewRetry
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重试执行异步 action,直到返回 true 或达到最大重试次数。
|
||||
/// </summary>
|
||||
/// <param name="action">判断条件(异步)</param>
|
||||
/// <param name="ct">取消令牌</param>
|
||||
/// <param name="retryTimes">最大重试次数</param>
|
||||
/// <param name="delayMs">每次重试间隔(毫秒)</param>
|
||||
/// <returns>是否成功</returns>
|
||||
public static async Task<bool> WaitForAction(Func<Task<bool>> action, CancellationToken ct, int retryTimes = 10, int delayMs = 1000)
|
||||
{
|
||||
for (var i = 0; i < retryTimes; i++)
|
||||
{
|
||||
await TaskControl.Delay(delayMs, ct);
|
||||
if (await action())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重试直到某个元素出现,可执行键盘或鼠标操作。
|
||||
/// </summary>
|
||||
|
||||
@@ -190,6 +190,7 @@ public class TaskRunner
|
||||
TaskTriggerDispatcher.Instance().SetTriggers(GameTaskManager.LoadInitialTriggers());
|
||||
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
HtmlMaskWindow.CloseAll();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,9 @@
|
||||
WindowStartupLocation="Manual"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True">
|
||||
<Grid>
|
||||
<wv2:WebView2 x:Name="WebView" DefaultBackgroundColor="Transparent"/>
|
||||
</Grid>
|
||||
<Border x:Name="ClickThroughBorder" Background="Transparent">
|
||||
<Grid>
|
||||
<wv2:WebView2 x:Name="WebView" DefaultBackgroundColor="Transparent"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
@@ -17,7 +17,7 @@ using Microsoft.Web.WebView2.Core;
|
||||
namespace BetterGenshinImpact.View;
|
||||
|
||||
/// <summary>
|
||||
/// HTML遮罩窗口 - 仅用于显示,不可交互(点击穿透)
|
||||
/// HTML遮罩窗口
|
||||
/// </summary>
|
||||
public partial class HtmlMaskWindow : Window
|
||||
{
|
||||
@@ -29,12 +29,21 @@ public partial class HtmlMaskWindow : Window
|
||||
private readonly string _webView2DataPath;
|
||||
private readonly string _pageUrl;
|
||||
private bool _navigationCompleted;
|
||||
private bool _styleCaptured;
|
||||
private int _originalStyle;
|
||||
private volatile bool _isClickThrough = true;
|
||||
private readonly System.Windows.Media.SolidColorBrush _backgroundBrush = new();
|
||||
|
||||
/// <summary>
|
||||
/// 窗口唯一标识
|
||||
/// </summary>
|
||||
public string MaskId => _id;
|
||||
|
||||
/// <summary>
|
||||
/// 当前是否处于点击穿透模式
|
||||
/// </summary>
|
||||
public bool IsClickThrough => _isClickThrough;
|
||||
|
||||
private HtmlMaskWindow(string url, string? id, string workDir)
|
||||
{
|
||||
_id = id ?? Guid.NewGuid().ToString("N");
|
||||
@@ -42,6 +51,7 @@ public partial class HtmlMaskWindow : Window
|
||||
_webView2DataPath = Path.Combine(workDir, "WebView2Data");
|
||||
_pageUrl = url;
|
||||
InitializeComponent();
|
||||
ClickThroughBorder.Background = _backgroundBrush;
|
||||
Loaded += OnLoaded;
|
||||
InitializeAsync(url);
|
||||
}
|
||||
@@ -156,6 +166,47 @@ public partial class HtmlMaskWindow : Window
|
||||
return _windows.ContainsKey(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取窗口实例,不存在则抛出异常
|
||||
/// </summary>
|
||||
/// <param name="windowId">窗口ID</param>
|
||||
/// <returns>窗口实例</returns>
|
||||
private static HtmlMaskWindow GetWindowOrThrow(string windowId)
|
||||
{
|
||||
if (_windows.TryGetValue(windowId, out var window))
|
||||
return window;
|
||||
throw new InvalidOperationException($"HTML遮罩窗口不存在或已关闭: {windowId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定窗口的点击穿透模式
|
||||
/// </summary>
|
||||
/// <param name="windowId">窗口ID</param>
|
||||
/// <param name="enabled">true=点击穿透,false=可交互</param>
|
||||
public static void SetClickThrough(string windowId, bool enabled)
|
||||
{
|
||||
GetWindowOrThrow(windowId).SetClickThroughMode(enabled);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定窗口的点击穿透状态
|
||||
/// </summary>
|
||||
/// <param name="windowId">窗口ID</param>
|
||||
/// <returns>点击穿透状态</returns>
|
||||
public static bool GetClickThrough(string windowId)
|
||||
{
|
||||
return GetWindowOrThrow(windowId).IsClickThrough;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 原子切换指定窗口的点击穿透模式
|
||||
/// </summary>
|
||||
/// <param name="windowId">窗口ID</param>
|
||||
public static void ToggleClickThrough(string windowId)
|
||||
{
|
||||
GetWindowOrThrow(windowId).ToggleClickThroughCore();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通知窗口刷新待推送的消息
|
||||
/// </summary>
|
||||
@@ -164,13 +215,24 @@ public partial class HtmlMaskWindow : Window
|
||||
if (!_windows.TryGetValue(windowId, out var window)) return;
|
||||
window.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
// 页面还没加载完,消息留在队列中由 NavigationCompleted 统一推送
|
||||
if (!window._navigationCompleted) return;
|
||||
if (window.WebView.CoreWebView2 == null) return;
|
||||
HtmlMask.FlushPendingMessages(windowId, json =>
|
||||
try
|
||||
{
|
||||
window.WebView.CoreWebView2.PostWebMessageAsString(json);
|
||||
});
|
||||
// 页面还没加载完,消息留在队列中由 NavigationCompleted 统一推送
|
||||
if (!window._navigationCompleted) return;
|
||||
if (window.WebView.CoreWebView2 == null) return;
|
||||
HtmlMask.FlushPendingMessages(windowId, json =>
|
||||
{
|
||||
window.WebView.CoreWebView2.PostWebMessageAsString(json);
|
||||
});
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// WebView 已被释放,忽略此消息推送
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskControl.Logger.LogDebug(ex, "HTML遮罩窗口消息推送异常");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -178,7 +240,7 @@ public partial class HtmlMaskWindow : Window
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetClickThrough();
|
||||
SetClickThrough(true);
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
@@ -387,14 +449,87 @@ public partial class HtmlMaskWindow : Window
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置点击穿透
|
||||
/// 设置点击穿透模式
|
||||
/// </summary>
|
||||
private void SetClickThrough()
|
||||
/// <param name="enabled">true=点击穿透,false=可交互</param>
|
||||
private void SetClickThrough(bool enabled)
|
||||
{
|
||||
var hwnd = new WindowInteropHelper(this).Handle;
|
||||
var style = (int)GetWindowLong(hwnd, WindowLongFlags.GWL_EXSTYLE);
|
||||
User32.SetWindowLong(hwnd, WindowLongFlags.GWL_EXSTYLE,
|
||||
(IntPtr)(style | (int)User32.WindowStylesEx.WS_EX_TRANSPARENT));
|
||||
if (hwnd == IntPtr.Zero) return;
|
||||
|
||||
if (!_styleCaptured)
|
||||
{
|
||||
_originalStyle = (int)GetWindowLong(hwnd, WindowLongFlags.GWL_EXSTYLE);
|
||||
_styleCaptured = true;
|
||||
}
|
||||
|
||||
int newStyle = enabled
|
||||
? (_originalStyle | (int)User32.WindowStylesEx.WS_EX_TRANSPARENT | (int)User32.WindowStylesEx.WS_EX_LAYERED)
|
||||
: _originalStyle;
|
||||
|
||||
User32.SetWindowLong(hwnd, WindowLongFlags.GWL_EXSTYLE, (IntPtr)newStyle);
|
||||
_isClickThrough = enabled;
|
||||
|
||||
SetBackgroundOpacity(!enabled);
|
||||
|
||||
if (!enabled)
|
||||
{
|
||||
// 禁用穿透:激活遮罩窗口,确保获得键盘和鼠标焦点
|
||||
try
|
||||
{
|
||||
User32.SetForegroundWindow(hwnd);
|
||||
User32.BringWindowToTop(hwnd);
|
||||
Dispatcher.Invoke(() => Activate());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskControl.Logger.LogDebug(ex, "HTML遮罩窗口激活失败");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 开启穿透:将焦点还给游戏窗口
|
||||
try
|
||||
{
|
||||
var gameHandle = TaskContext.Instance().GameHandle;
|
||||
if (gameHandle != IntPtr.Zero)
|
||||
{
|
||||
SystemControl.FocusWindow(gameHandle);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskControl.Logger.LogDebug(ex, "HTML遮罩恢复游戏焦点失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置背景透明度
|
||||
/// </summary>
|
||||
/// <param name="isInteractive">是否处于交互模式</param>
|
||||
private void SetBackgroundOpacity(bool isInteractive)
|
||||
{
|
||||
_backgroundBrush.Color = isInteractive
|
||||
? System.Windows.Media.Color.FromArgb(1, 0, 0, 0)
|
||||
: System.Windows.Media.Color.FromArgb(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置点击穿透模式
|
||||
/// </summary>
|
||||
/// <param name="enabled">true=点击穿透,false=可交互</param>
|
||||
public void SetClickThroughMode(bool enabled)
|
||||
{
|
||||
Dispatcher.Invoke(() => SetClickThrough(enabled));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换点击穿透模式
|
||||
/// </summary>
|
||||
private void ToggleClickThroughCore()
|
||||
{
|
||||
Dispatcher.Invoke(() => SetClickThrough(!_isClickThrough));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -640,6 +640,18 @@ public partial class ScriptControlViewModel : ViewModel
|
||||
if (newScriptGroup != null)
|
||||
{
|
||||
newScriptGroup.Name = str;
|
||||
ScriptGroup.ResetGroupInfo(newScriptGroup);
|
||||
foreach (var project in newScriptGroup.Projects)
|
||||
{
|
||||
try
|
||||
{
|
||||
project.BuildScriptProjectRelation();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
ScriptGroups.Add(newScriptGroup);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user