Compare commits
46
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d4c755b4d | ||
|
|
f182e345c2 | ||
|
|
5a0f7226ed | ||
|
|
8bb1d728ff | ||
|
|
38e05830a2 | ||
|
|
8e44643a51 | ||
|
|
7afbbee3e1 | ||
|
|
b445cbf42f | ||
|
|
19e7c9d02e | ||
|
|
d3f0f89da1 | ||
|
|
70b1ed88bb | ||
|
|
1a4682bf29 | ||
|
|
19fbcc48ab | ||
|
|
c63ac6947a | ||
|
|
98da4e072c | ||
|
|
a2adfe5b6f | ||
|
|
9cc91b4568 | ||
|
|
068cbd6e20 | ||
|
|
f713847df2 | ||
|
|
c39a882272 | ||
|
|
5f9ca6b399 | ||
|
|
bfe6b69edd | ||
|
|
8dbdf0840c | ||
|
|
4cba618722 | ||
|
|
4cc4aa27f0 | ||
|
|
3e69e6c3ac | ||
|
|
6414210095 | ||
|
|
83e6798439 | ||
|
|
89e92d57b2 | ||
|
|
779fbaad86 | ||
|
|
962d47722d | ||
|
|
89079f74d8 | ||
|
|
8dc074e987 | ||
|
|
12d4c60f7a | ||
|
|
fae49c4c3b | ||
|
|
a4e55ab164 | ||
|
|
dc8c1e063e | ||
|
|
1d9168d96e | ||
|
|
2d4a6192f2 | ||
|
|
7b51c018a7 | ||
|
|
121bfbaa8e | ||
|
|
8d2b36d5fd | ||
|
|
c83d3e336f | ||
|
|
5f76749be7 | ||
|
|
57d2257283 | ||
|
|
1657beb9a8 |
No files matched your search
@@ -157,8 +157,11 @@ public class MapPuzzle
|
||||
Debug.WriteLine("");
|
||||
}
|
||||
|
||||
// 地图图片块
|
||||
SaveImagesAs1024X1024(arr, imageLocations, @"E:\HuiTask\更好的原神\地图匹配\有用的素材\5.0\地图块", minRow, minCol);
|
||||
|
||||
// 保存大图
|
||||
Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\map_50_2048.png", largeImage);
|
||||
// Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\map_50_2048.png", largeImage);
|
||||
// Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\combined_image_sd4x.png", largeImage.Resize(new Size(largeImage.Width / 4, largeImage.Height / 4), 0, 0, InterpolationFlags.Cubic));
|
||||
// Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\combined_image_small.png", largeImage.Resize(new Size(1400, 1300), 0, 0, InterpolationFlags.Cubic));
|
||||
|
||||
@@ -170,6 +173,36 @@ public class MapPuzzle
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveImagesAs1024X1024(int[,] arr, Dictionary<(int row, int col), ImgInfo> imageLocations, string outputFolder, int minRow, int minCol)
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
{
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
}
|
||||
|
||||
for (int row = 0; row < arr.GetLength(0); row++)
|
||||
{
|
||||
for (int col = 0; col < arr.GetLength(1); col++)
|
||||
{
|
||||
if (arr[row, col] == 1)
|
||||
{
|
||||
var key = (row + minRow, col + minCol);
|
||||
if (imageLocations.TryGetValue(key, out var imgInfo))
|
||||
{
|
||||
var img = imgInfo.Img;
|
||||
if (img.Width != 1204 || img.Height != 1204)
|
||||
{
|
||||
img = imgInfo.Img.Resize(new Size(1024, 1024), 0, 0, InterpolationFlags.Nearest);
|
||||
}
|
||||
var outputPath = Path.Combine(outputFolder, $"{row}_{col}.png");
|
||||
Cv2.ImWrite(outputPath, img);
|
||||
img.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ImgInfo
|
||||
{
|
||||
public Mat Img { get; set; }
|
||||
|
||||
@@ -13,11 +13,11 @@ public class MapTeleportPointDraw
|
||||
{
|
||||
public static void Draw()
|
||||
{
|
||||
var pList = LoadTeleportPoint(@"E:\HuiTask\更好的原神\地图匹配\地图点位\5.0");
|
||||
pList.AddRange(MapAssets.Instance.TpPositions);
|
||||
// var pList = LoadTeleportPoint(@"E:\HuiTask\更好的原神\地图匹配\地图点位\5.0");
|
||||
// pList.AddRange(MapAssets.Instance.TpPositions);
|
||||
var map = new Mat(@"E:\HuiTask\更好的原神\地图匹配\有用的素材\5.0\mainMap1024BlockColor.png");
|
||||
DrawTeleportPoint(map, pList);
|
||||
Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\有用的素材\5.0\mainMap1024BlockColor_传送点.png", map);
|
||||
DrawTeleportPoint(map, MapAssets.Instance.TpPositions);
|
||||
Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\有用的素材\5.0\传送点_1024_0.34.3.png", map);
|
||||
}
|
||||
|
||||
public static void DrawTeleportPoint(Mat map, List<GiWorldPosition> points)
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact;
|
||||
|
||||
@@ -240,7 +241,23 @@ public partial class App : Application
|
||||
e = e.InnerException;
|
||||
}
|
||||
|
||||
MessageBox.Error("程序异常:" + e.Source + "\r\n--" + Environment.NewLine + e.StackTrace + "\r\n---" + Environment.NewLine + e.Message);
|
||||
try
|
||||
{
|
||||
ExceptionReport.Show(e);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Fallback.
|
||||
System.Windows.Forms.MessageBox.Show(
|
||||
$"""
|
||||
程序异常:{e.Source}
|
||||
--
|
||||
{e.StackTrace}
|
||||
--
|
||||
{e.Message}
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
// log
|
||||
GetLogger<App>().LogDebug(e, "UnHandle Exception");
|
||||
|
||||
Binary file not shown.
@@ -10,6 +10,7 @@
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ApplicationIcon>Assets\logo.ico</ApplicationIcon>
|
||||
<AssemblyName>BetterGI</AssemblyName>
|
||||
<AssemblyVersion>0.34.4</AssemblyVersion>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -20,6 +21,7 @@
|
||||
<None Remove="Assets\Fonts\*.ttf" />
|
||||
<None Remove="Assets\Highlighting\*.xshd" />
|
||||
<None Remove="Assets\Strings\*.html" />
|
||||
<None Remove="Assets\Audios\*.mp3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -29,6 +31,7 @@
|
||||
<Resource Include="Assets\Fonts\*.ttf" />
|
||||
<Resource Include="Assets\Highlighting\*.xshd" />
|
||||
<Resource Include="Assets\Strings\*.html" />
|
||||
<Resource Include="Assets\Audios\*.mp3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -61,7 +64,7 @@
|
||||
<PackageReference Include="Vanara.PInvoke.User32" Version="4.0.2" />
|
||||
<PackageReference Include="WPF-UI" Version="3.0.5" />
|
||||
<PackageReference Include="WPF-UI.Tray" Version="3.0.5" />
|
||||
<PackageReference Include="WPF-UI.Violeta" Version="3.0.5.3" />
|
||||
<PackageReference Include="WPF-UI.Violeta" Version="3.0.5.12" />
|
||||
<PackageReference Include="YoloV8" Version="4.1.7" />
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@@ -7,7 +8,7 @@ namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
public class Global
|
||||
{
|
||||
public static string Version { get; } = "0.34.1";
|
||||
public static string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version!.ToString(3);
|
||||
|
||||
public static string StartUpPath { get; set; } = AppContext.BaseDirectory;
|
||||
|
||||
|
||||
@@ -172,10 +172,10 @@ public partial class HotKeyConfig : ObservableObject
|
||||
|
||||
// 路径记录开始
|
||||
[ObservableProperty]
|
||||
private string _getBigMapPosHotkey = "";
|
||||
private string _recBigMapPosHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _getBigMapPosHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
private string _recBigMapPosHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 路径记录开始
|
||||
[ObservableProperty]
|
||||
|
||||
@@ -51,6 +51,11 @@ public class KeyMouseMacroPlayer
|
||||
var startTime = DateTime.UtcNow;
|
||||
foreach (var e in macroEvents)
|
||||
{
|
||||
if (ct.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var timeToWait = (int)(e.Time - (DateTime.UtcNow - startTime).TotalMilliseconds);
|
||||
if (timeToWait < 0)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,11 @@ public class Dispatcher
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加实时任务
|
||||
/// </summary>
|
||||
/// <param name="timer">实时任务触发器</param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public void AddTimer(RealtimeTimer timer)
|
||||
{
|
||||
var realtimeTimer = timer;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence.Model;
|
||||
|
||||
/// <summary>
|
||||
/// 实时任务计时器
|
||||
/// 实时任务触发器
|
||||
/// </summary>
|
||||
public class RealtimeTimer
|
||||
{
|
||||
|
||||
@@ -20,8 +20,18 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
[ObservableProperty]
|
||||
private int _index;
|
||||
|
||||
/// <summary>
|
||||
/// 理论上是文件名
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 理论上是当前类型脚本根目录到脚本文件所在目录的相对路径
|
||||
/// 但是:
|
||||
/// 1. JS 脚本的文件名是内部的名称,文件夹名脚本所在文件夹,这个也是唯一标识
|
||||
/// 2. KeyMouse 脚本的文件名和文件夹名相同,文件夹名暂时无意义
|
||||
/// 3. Pathing 文件名就是实际脚本的文件名,文件夹名是脚本所在的相对目录
|
||||
/// </summary>
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace BetterGenshinImpact.GameTask.AutoDomain;
|
||||
[Serializable]
|
||||
public partial class AutoDomainConfig : ObservableObject
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 战斗结束后延迟几秒再开始寻找石化古树,秒
|
||||
/// </summary>
|
||||
@@ -26,4 +25,10 @@ public partial class AutoDomainConfig : ObservableObject
|
||||
/// 寻找古树时,短距离移动的次数
|
||||
/// </summary>
|
||||
[ObservableProperty] private int _leftRightMoveTimes = 3;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动吃药
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _autoEat = false;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public class AutoDomainParam : BaseTaskParam
|
||||
|
||||
public string CombatStrategyPath { get; set; }
|
||||
|
||||
public AutoDomainParam(CancellationTokenSource cts, int domainRoundNum, string path) : base(cts)
|
||||
public AutoDomainParam(int domainRoundNum, string path)
|
||||
{
|
||||
DomainRoundNum = domainRoundNum;
|
||||
if (domainRoundNum == 0)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
@@ -10,11 +11,9 @@ using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoPick.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Compunet.YoloV8;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
@@ -25,12 +24,14 @@ using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using static Vanara.PInvoke.Gdi32;
|
||||
using static Vanara.PInvoke.User32;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoDomain;
|
||||
|
||||
public class AutoDomainTask
|
||||
public class AutoDomainTask : ISoloTask
|
||||
{
|
||||
private readonly AutoDomainParam _taskParam;
|
||||
|
||||
@@ -42,6 +43,8 @@ public class AutoDomainTask
|
||||
|
||||
private readonly CombatScriptBag _combatScriptBag;
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
public AutoDomainTask(AutoDomainParam taskParam)
|
||||
{
|
||||
_taskParam = taskParam;
|
||||
@@ -57,96 +60,64 @@ public class AutoDomainTask
|
||||
_combatScriptBag = CombatScriptParser.ReadAndParse(_taskParam.CombatStrategyPath);
|
||||
}
|
||||
|
||||
public async void Start()
|
||||
public async Task Start(CancellationTokenSource cts)
|
||||
{
|
||||
var hasLock = false;
|
||||
try
|
||||
_cts = cts;
|
||||
|
||||
AutoFightAssets.DestroyInstance();
|
||||
Init();
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Started().Build()); // TODO: 通知后续需要删除迁移
|
||||
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
|
||||
// 前置进入秘境
|
||||
EnterDomain();
|
||||
|
||||
for (var i = 0; i < _taskParam.DomainRoundNum; i++)
|
||||
{
|
||||
AutoFightAssets.DestroyInstance();
|
||||
hasLock = await TaskSemaphore.WaitAsync(0);
|
||||
if (!hasLock)
|
||||
// 0. 关闭秘境提示
|
||||
Logger.LogDebug("0. 关闭秘境提示");
|
||||
CloseDomainTip();
|
||||
|
||||
// 队伍没初始化成功则重试
|
||||
RetryTeamInit(combatScenes);
|
||||
|
||||
// 0. 切换到第一个角色
|
||||
var combatCommands = FindCombatScriptAndSwitchAvatar(combatScenes);
|
||||
|
||||
// 1. 走到钥匙处启动
|
||||
Logger.LogInformation("自动秘境:{Text}", "1. 走到钥匙处启动");
|
||||
await WalkToPressF();
|
||||
|
||||
// 2. 执行战斗(战斗线程、视角线程、检测战斗完成线程)
|
||||
Logger.LogInformation("自动秘境:{Text}", "2. 执行战斗策略");
|
||||
await StartFight(combatScenes, combatCommands);
|
||||
EndFightWait();
|
||||
|
||||
// 3. 寻找石化古树 并左右移动直到石化古树位于屏幕中心
|
||||
Logger.LogInformation("自动秘境:{Text}", "3. 寻找石化古树");
|
||||
await FindPetrifiedTree();
|
||||
|
||||
// 4. 走到石化古树处
|
||||
Logger.LogInformation("自动秘境:{Text}", "4. 走到石化古树处");
|
||||
await WalkToPressF();
|
||||
|
||||
// 5. 快速领取奖励并判断是否有下一轮
|
||||
Logger.LogInformation("自动秘境:{Text}", "5. 领取奖励");
|
||||
if (!GettingTreasure(_taskParam.DomainRoundNum == 9999, i == _taskParam.DomainRoundNum - 1))
|
||||
{
|
||||
Logger.LogError("启动自动秘境功能失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
return;
|
||||
}
|
||||
|
||||
Init();
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Started().Build());
|
||||
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
|
||||
// 前置进入秘境
|
||||
EnterDomain();
|
||||
|
||||
for (var i = 0; i < _taskParam.DomainRoundNum; i++)
|
||||
{
|
||||
// 0. 关闭秘境提示
|
||||
Logger.LogDebug("0. 关闭秘境提示");
|
||||
CloseDomainTip();
|
||||
|
||||
// 队伍没初始化成功则重试
|
||||
RetryTeamInit(combatScenes);
|
||||
|
||||
// 0. 切换到第一个角色
|
||||
var combatCommands = FindCombatScriptAndSwitchAvatar(combatScenes);
|
||||
|
||||
// 1. 走到钥匙处启动
|
||||
Logger.LogInformation("自动秘境:{Text}", "1. 走到钥匙处启动");
|
||||
await WalkToPressF();
|
||||
|
||||
// 2. 执行战斗(战斗线程、视角线程、检测战斗完成线程)
|
||||
Logger.LogInformation("自动秘境:{Text}", "2. 执行战斗策略");
|
||||
await StartFight(combatScenes, combatCommands);
|
||||
EndFightWait();
|
||||
|
||||
// 3. 寻找石化古树 并左右移动直到石化古树位于屏幕中心
|
||||
Logger.LogInformation("自动秘境:{Text}", "3. 寻找石化古树");
|
||||
await FindPetrifiedTree();
|
||||
|
||||
// 4. 走到石化古树处
|
||||
Logger.LogInformation("自动秘境:{Text}", "4. 走到石化古树处");
|
||||
await WalkToPressF();
|
||||
|
||||
// 5. 快速领取奖励并判断是否有下一轮
|
||||
Logger.LogInformation("自动秘境:{Text}", "5. 领取奖励");
|
||||
if (!GettingTreasure(_taskParam.DomainRoundNum == 9999, i == _taskParam.DomainRoundNum - 1))
|
||||
if (i == _taskParam.DomainRoundNum - 1)
|
||||
{
|
||||
if (i == _taskParam.DomainRoundNum - 1)
|
||||
{
|
||||
Logger.LogInformation("配置的{Cnt}轮秘境已经完成,结束自动秘境", _taskParam.DomainRoundNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("体力已经耗尽,结束自动秘境");
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Success().Build());
|
||||
break;
|
||||
Logger.LogInformation("配置的{Cnt}轮秘境已经完成,结束自动秘境", _taskParam.DomainRoundNum);
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Progress().Build());
|
||||
}
|
||||
}
|
||||
catch (NormalEndException e)
|
||||
{
|
||||
Logger.LogInformation("自动秘境中断:" + e.Message);
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Cancelled().Build());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e.Message);
|
||||
Logger.LogDebug(e.StackTrace);
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Failure().Build());
|
||||
}
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.NormalTrigger);
|
||||
TaskSettingsPageViewModel.SetSwitchAutoDomainButtonText(false);
|
||||
Logger.LogInformation("→ {Text}", "自动秘境结束");
|
||||
|
||||
if (hasLock)
|
||||
{
|
||||
TaskSemaphore.Release();
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("体力已经耗尽,结束自动秘境");
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Success().Build());
|
||||
break;
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Progress().Build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,16 +126,12 @@ public class AutoDomainTask
|
||||
LogScreenResolution();
|
||||
if (_taskParam.DomainRoundNum == 9999)
|
||||
{
|
||||
Logger.LogInformation("→ {Text} 用尽所有体力后结束", "自动秘境,启动!");
|
||||
Logger.LogInformation("→ {Text} 用尽所有体力后结束", "自动秘境,");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("→ {Text} 设置总次数:{Cnt}", "自动秘境,启动!", _taskParam.DomainRoundNum);
|
||||
Logger.LogInformation("→ {Text} 设置总次数:{Cnt}", "自动秘境,", _taskParam.DomainRoundNum);
|
||||
}
|
||||
|
||||
SystemControl.ActivateWindow();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.OnlyCacheCapture);
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 5, _taskParam.Cts); // 等待缓存图像
|
||||
}
|
||||
|
||||
private void LogScreenResolution()
|
||||
@@ -202,7 +169,7 @@ public class AutoDomainTask
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_F);
|
||||
Logger.LogInformation("自动秘境:{Text}", "进入秘境");
|
||||
// 秘境开门动画 5s
|
||||
Sleep(5000, _taskParam.Cts);
|
||||
Sleep(5000, _cts);
|
||||
}
|
||||
|
||||
int retryTimes = 0, clickCount = 0;
|
||||
@@ -216,11 +183,11 @@ public class AutoDomainTask
|
||||
clickCount++;
|
||||
}
|
||||
|
||||
Sleep(1500, _taskParam.Cts);
|
||||
Sleep(1500, _cts);
|
||||
}
|
||||
|
||||
// 载入动画
|
||||
Sleep(3000, _taskParam.Cts);
|
||||
Sleep(3000, _cts);
|
||||
}
|
||||
|
||||
private void CloseDomainTip()
|
||||
@@ -233,16 +200,16 @@ public class AutoDomainTask
|
||||
using var cactRectArea = CaptureToRectArea().Find(AutoFightContext.Instance.FightAssets.ClickAnyCloseTipRa);
|
||||
if (!cactRectArea.IsEmpty())
|
||||
{
|
||||
Sleep(1000, _taskParam.Cts);
|
||||
Sleep(1000, _cts);
|
||||
cactRectArea.Click();
|
||||
break;
|
||||
}
|
||||
|
||||
// todo 添加小地图角标位置检测 防止有人手点了
|
||||
Sleep(1000, _taskParam.Cts);
|
||||
Sleep(1000, _cts);
|
||||
}
|
||||
|
||||
Sleep(1500, _taskParam.Cts);
|
||||
Sleep(1500, _cts);
|
||||
}
|
||||
|
||||
private List<CombatCommand> FindCombatScriptAndSwitchAvatar(CombatScenes combatScenes)
|
||||
@@ -259,7 +226,7 @@ public class AutoDomainTask
|
||||
/// </summary>
|
||||
private async Task WalkToPressF()
|
||||
{
|
||||
if (_taskParam.Cts.Token.IsCancellationRequested)
|
||||
if (_cts.Token.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -276,12 +243,12 @@ public class AutoDomainTask
|
||||
|
||||
try
|
||||
{
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested)
|
||||
while (!_cts.Token.IsCancellationRequested)
|
||||
{
|
||||
using var fRectArea = Common.TaskControl.CaptureToRectArea().Find(AutoPickAssets.Instance.FRo);
|
||||
if (fRectArea.IsEmpty())
|
||||
{
|
||||
Sleep(100, _taskParam.Cts);
|
||||
Sleep(100, _cts);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -306,7 +273,7 @@ public class AutoDomainTask
|
||||
private Task StartFight(CombatScenes combatScenes, List<CombatCommand> combatCommands)
|
||||
{
|
||||
CancellationTokenSource cts = new();
|
||||
_taskParam.Cts.Token.Register(cts.Cancel);
|
||||
_cts.Token.Register(cts.Cancel);
|
||||
combatScenes.BeforeTask(cts);
|
||||
// 战斗操作
|
||||
var combatTask = new Task(() =>
|
||||
@@ -337,20 +304,19 @@ public class AutoDomainTask
|
||||
}
|
||||
}, cts.Token);
|
||||
|
||||
// 视角操作
|
||||
|
||||
// 对局结束检测
|
||||
var domainEndTask = DomainEndDetectionTask(cts);
|
||||
|
||||
// 自动吃药
|
||||
var autoEatRecoveryHpTask = AutoEatRecoveryHpTask(cts);
|
||||
combatTask.Start();
|
||||
domainEndTask.Start();
|
||||
|
||||
return Task.WhenAll(combatTask, domainEndTask);
|
||||
autoEatRecoveryHpTask.Start();
|
||||
return Task.WhenAll(combatTask, domainEndTask, autoEatRecoveryHpTask);
|
||||
}
|
||||
|
||||
private void EndFightWait()
|
||||
{
|
||||
if (_taskParam.Cts.Token.IsCancellationRequested)
|
||||
if (_cts.Token.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -359,7 +325,7 @@ public class AutoDomainTask
|
||||
if (s > 0)
|
||||
{
|
||||
Logger.LogInformation("战斗结束后等待 {Second} 秒", s);
|
||||
Sleep((int)(s * 1000), _taskParam.Cts);
|
||||
Sleep((int)(s * 1000), _cts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,19 +334,25 @@ public class AutoDomainTask
|
||||
/// </summary>
|
||||
private Task DomainEndDetectionTask(CancellationTokenSource cts)
|
||||
{
|
||||
return new Task(() =>
|
||||
return new Task(async () =>
|
||||
{
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested)
|
||||
try
|
||||
{
|
||||
if (IsDomainEnd())
|
||||
while (!_cts.Token.IsCancellationRequested)
|
||||
{
|
||||
cts.Cancel();
|
||||
break;
|
||||
}
|
||||
if (IsDomainEnd())
|
||||
{
|
||||
await cts.CancelAsync();
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(1000);
|
||||
await Delay(1000, cts);
|
||||
}
|
||||
}
|
||||
});
|
||||
catch
|
||||
{
|
||||
}
|
||||
}, cts.Token);
|
||||
}
|
||||
|
||||
private bool IsDomainEnd()
|
||||
@@ -406,16 +378,58 @@ public class AutoDomainTask
|
||||
return false;
|
||||
}
|
||||
|
||||
private Task AutoEatRecoveryHpTask(CancellationTokenSource cts)
|
||||
{
|
||||
return new Task(async () =>
|
||||
{
|
||||
if (!_config.AutoEat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
while (!_cts.Token.IsCancellationRequested)
|
||||
{
|
||||
if (IsLowHealth())
|
||||
{
|
||||
// 模拟按键 "Z"
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_Z);
|
||||
Logger.LogInformation("检测到红血,按Z吃药");
|
||||
// TODO 吃饱了会一直吃
|
||||
}
|
||||
|
||||
await Delay(500, cts);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}, cts.Token);
|
||||
}
|
||||
|
||||
private bool IsLowHealth()
|
||||
{
|
||||
// 获取图像
|
||||
using var ra = CaptureToRectArea();
|
||||
|
||||
// 获取 (808, 1010) 位置的像素颜色
|
||||
var pixelColor = ra.SrcMat.At<Vec3b>(1010, 808);
|
||||
|
||||
// 判断颜色是否是 (255, 90, 90)
|
||||
return pixelColor is { Item2: 255, Item1: 90, Item0: 90 };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 旋转视角后寻找石化古树
|
||||
/// </summary>
|
||||
private Task FindPetrifiedTree()
|
||||
{
|
||||
CancellationTokenSource treeCts = new();
|
||||
_taskParam.Cts.Token.Register(treeCts.Cancel);
|
||||
_cts.Token.Register(treeCts.Cancel);
|
||||
// 中键回正视角
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
Sleep(900, _taskParam.Cts);
|
||||
Sleep(900, _cts);
|
||||
|
||||
// 左右移动直到石化古树位于屏幕中心任务
|
||||
var moveAvatarTask = MoveAvatarHorizontallyTask(treeCts);
|
||||
@@ -437,7 +451,7 @@ public class AutoDomainTask
|
||||
var noDetectCount = 0;
|
||||
var prevKey = VK.VK_A;
|
||||
var backwardsAndForwardsCount = 0;
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested)
|
||||
while (!_cts.Token.IsCancellationRequested)
|
||||
{
|
||||
var treeRect = DetectTree(CaptureToRectArea());
|
||||
if (treeRect != Rect.Empty)
|
||||
@@ -520,7 +534,7 @@ public class AutoDomainTask
|
||||
else
|
||||
{
|
||||
_simulator.KeyPress(VK.VK_W, 60);
|
||||
Sleep(500, _taskParam.Cts);
|
||||
Sleep(500, _cts);
|
||||
treeCts.Cancel();
|
||||
break;
|
||||
}
|
||||
@@ -565,12 +579,12 @@ public class AutoDomainTask
|
||||
{
|
||||
// 左右移动5次说明已经在树中心了
|
||||
_simulator.KeyPress(VK.VK_W, 60);
|
||||
Sleep(500, _taskParam.Cts);
|
||||
Sleep(500, _cts);
|
||||
treeCts.Cancel();
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(60, _taskParam.Cts);
|
||||
Sleep(60, _cts);
|
||||
}
|
||||
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
@@ -618,7 +632,7 @@ public class AutoDomainTask
|
||||
continuousCount++;
|
||||
}
|
||||
|
||||
if (angle < 180)
|
||||
if (angle <= 180)
|
||||
{
|
||||
// 左移视角
|
||||
var moveAngle = angle;
|
||||
@@ -671,7 +685,7 @@ public class AutoDomainTask
|
||||
private bool GettingTreasure(bool recognizeResin, bool isLastTurn)
|
||||
{
|
||||
// 等待窗口弹出
|
||||
Sleep(1500, _taskParam.Cts);
|
||||
Sleep(1500, _cts);
|
||||
|
||||
// 优先使用浓缩树脂
|
||||
var retryTimes = 0;
|
||||
@@ -690,22 +704,22 @@ public class AutoDomainTask
|
||||
useCondensedResinRa.Click();
|
||||
// 点两下 #224 #218
|
||||
// 解决水龙王按下左键后没松开,然后后续点击按下就没反应了
|
||||
Sleep(400, _taskParam.Cts);
|
||||
Sleep(400, _cts);
|
||||
useCondensedResinRa.Click();
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(800, _taskParam.Cts);
|
||||
Sleep(800, _cts);
|
||||
}
|
||||
|
||||
Sleep(1000, _taskParam.Cts);
|
||||
Sleep(1000, _cts);
|
||||
|
||||
var captureArea = TaskContext.Instance().SystemInfo.CaptureAreaRect;
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
// 跳过领取动画
|
||||
GameCaptureRegion.GameRegionClick((size, scale) => (size.Width - 140 * scale, 53 * scale));
|
||||
Sleep(200, _taskParam.Cts);
|
||||
Sleep(200, _cts);
|
||||
GameCaptureRegion.GameRegionClick((size, scale) => (size.Width - 140 * scale, 53 * scale));
|
||||
|
||||
// 优先点击继续
|
||||
@@ -749,7 +763,7 @@ public class AutoDomainTask
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(300, _taskParam.Cts);
|
||||
Sleep(300, _cts);
|
||||
}
|
||||
|
||||
throw new NormalEndException("未检测到秘境结束,可能是背包物品已满。");
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
using BetterGenshinImpact.GameTask.Model;
|
||||
using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
public class AutoFightParam : BaseTaskParam
|
||||
public class AutoFightParam(string path) : BaseTaskParam
|
||||
{
|
||||
public string CombatStrategyPath { get; set; }
|
||||
|
||||
public AutoFightParam(CancellationTokenSource cts, string path) : base(cts)
|
||||
{
|
||||
CombatStrategyPath = path;
|
||||
}
|
||||
public string CombatStrategyPath { get; set; } = path;
|
||||
}
|
||||
@@ -1,107 +1,66 @@
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Script;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
public class AutoFightTask
|
||||
public class AutoFightTask : ISoloTask
|
||||
{
|
||||
private readonly AutoFightParam _taskParam;
|
||||
|
||||
private readonly CombatScriptBag _combatScriptBag;
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
public AutoFightTask(AutoFightParam taskParam)
|
||||
{
|
||||
_taskParam = taskParam;
|
||||
_combatScriptBag = CombatScriptParser.ReadAndParse(_taskParam.CombatStrategyPath);
|
||||
}
|
||||
|
||||
public async void Start()
|
||||
public Task Start(CancellationTokenSource cts)
|
||||
{
|
||||
var hasLock = false;
|
||||
_cts = cts;
|
||||
|
||||
LogScreenResolution();
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
if (!combatScenes.CheckTeamInitialized())
|
||||
{
|
||||
throw new Exception("识别队伍角色失败");
|
||||
}
|
||||
var combatCommands = _combatScriptBag.FindCombatScript(combatScenes.Avatars);
|
||||
|
||||
combatScenes.BeforeTask(_cts);
|
||||
|
||||
// 战斗操作
|
||||
try
|
||||
{
|
||||
AutoFightAssets.DestroyInstance();
|
||||
hasLock = await TaskSemaphore.WaitAsync(0);
|
||||
if (!hasLock)
|
||||
while (!_cts.Token.IsCancellationRequested)
|
||||
{
|
||||
Logger.LogError("启动自动战斗功能失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
return;
|
||||
// 通用化战斗策略
|
||||
foreach (var command in combatCommands)
|
||||
{
|
||||
command.Execute(combatScenes);
|
||||
}
|
||||
}
|
||||
|
||||
Init();
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
if (!combatScenes.CheckTeamInitialized())
|
||||
{
|
||||
throw new Exception("识别队伍角色失败");
|
||||
}
|
||||
var combatCommands = _combatScriptBag.FindCombatScript(combatScenes.Avatars);
|
||||
|
||||
combatScenes.BeforeTask(_taskParam.Cts);
|
||||
|
||||
// 战斗操作
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested)
|
||||
{
|
||||
// 通用化战斗策略
|
||||
foreach (var command in combatCommands)
|
||||
{
|
||||
command.Execute(combatScenes);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NormalEndException)
|
||||
{
|
||||
Logger.LogInformation("战斗操作结束");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogWarning(e.Message);
|
||||
throw;
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (NormalEndException)
|
||||
{
|
||||
Logger.LogInformation("手动中断自动战斗");
|
||||
Logger.LogInformation("战斗操作结束");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e.Message);
|
||||
Logger.LogDebug(e.StackTrace);
|
||||
Logger.LogWarning(e.Message);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.NormalTrigger);
|
||||
TaskSettingsPageViewModel.SetSwitchAutoFightButtonText(false);
|
||||
Logger.LogInformation("→ {Text}", "自动战斗结束");
|
||||
|
||||
if (hasLock)
|
||||
{
|
||||
TaskSemaphore.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
LogScreenResolution();
|
||||
Logger.LogInformation("→ {Text}", "自动战斗,启动!");
|
||||
SystemControl.ActivateWindow();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.CacheCaptureWithTrigger);
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 5, _taskParam.Cts); // 等待缓存图像
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void LogScreenResolution()
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using BetterGenshinImpact.Helpers.Extensions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
|
||||
public class AutoGeniusInvokationTask
|
||||
public class AutoGeniusInvokationTask(GeniusInvokationTaskParam taskParam) : ISoloTask
|
||||
{
|
||||
public static void Start(GeniusInvokationTaskParam taskParam)
|
||||
public Task Start(CancellationTokenSource cts)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().StopTimer();
|
||||
// 读取策略信息
|
||||
var duel = ScriptParser.Parse(taskParam.StrategyContent);
|
||||
SystemControl.ActivateWindow();
|
||||
duel.RunAsync(taskParam).SafeForget();
|
||||
duel.Run(cts);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,9 +67,9 @@ public class GeniusInvokationControl
|
||||
|
||||
// private IGameCapture? _gameCapture;
|
||||
|
||||
public void Init(GeniusInvokationTaskParam taskParam)
|
||||
public void Init(CancellationTokenSource cts)
|
||||
{
|
||||
_cts = taskParam.Cts;
|
||||
_cts = cts;
|
||||
// _gameCapture = taskParam.Dispatcher.GameCapture;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
|
||||
public class GeniusInvokationTaskParam(CancellationTokenSource cts, string strategyContent) : BaseTaskParam(cts)
|
||||
public class GeniusInvokationTaskParam(string strategyContent) : BaseTaskParam
|
||||
{
|
||||
public string StrategyContent { get; set; } = strategyContent;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using BetterGenshinImpact.Core.Recognition.OpenCv;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Assets;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
@@ -53,31 +54,21 @@ public class Duel
|
||||
|
||||
private int _keqingECount = 0;
|
||||
|
||||
public async Task RunAsync(GeniusInvokationTaskParam taskParam)
|
||||
public async Task RunAsync(CancellationTokenSource cts)
|
||||
{
|
||||
await Task.Run(() => { Run(taskParam); });
|
||||
await Task.Run(() => { Run(cts); });
|
||||
}
|
||||
|
||||
public void Run(GeniusInvokationTaskParam taskParam)
|
||||
public void Run(CancellationTokenSource cts)
|
||||
{
|
||||
var hasLock = false;
|
||||
Cts = taskParam.Cts;
|
||||
Cts = cts;
|
||||
try
|
||||
{
|
||||
AutoGeniusInvokationAssets.DestroyInstance();
|
||||
hasLock = TaskControl.TaskSemaphore.Wait(0);
|
||||
if (!hasLock)
|
||||
{
|
||||
_logger.LogError("启动自动七圣召唤功能失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
return;
|
||||
}
|
||||
|
||||
LogScreenResolution();
|
||||
_logger.LogInformation("========================================");
|
||||
_logger.LogInformation("→ {Text}", "全自动七圣召唤,启动!");
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Started().Build());
|
||||
GeniusInvokationControl.GetInstance().Init(taskParam);
|
||||
SystemControl.ActivateWindow();
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Started().Build()); // TODO 需要移动
|
||||
GeniusInvokationControl.GetInstance().Init(Cts);
|
||||
|
||||
// 对局准备 选择初始手牌
|
||||
GeniusInvokationControl.GetInstance().CommonDuelPrepare();
|
||||
@@ -302,36 +293,23 @@ public class Duel
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
_logger.LogInformation(ex.Message);
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Cancelled().Build());
|
||||
throw;
|
||||
}
|
||||
catch (NormalEndException ex)
|
||||
{
|
||||
_logger.LogInformation(ex.Message);
|
||||
_logger.LogInformation("对局结束");
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Success().Build());
|
||||
throw;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
_logger.LogDebug(ex.StackTrace);
|
||||
if (TaskContext.Instance().Config.DetailedErrorLogs)
|
||||
{
|
||||
_logger.LogError(ex.StackTrace);
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Failure().Build());
|
||||
}
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskSettingsPageViewModel.SetSwitchAutoGeniusInvokationButtonText(false);
|
||||
_logger.LogInformation("← {Text}", "退出全自动七圣召唤");
|
||||
TaskTriggerDispatcher.Instance().StartTimer();
|
||||
|
||||
if (hasLock)
|
||||
{
|
||||
TaskControl.TaskSemaphore.Release();
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@ using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoMusicGame;
|
||||
|
||||
public class AutoMusicGameParam(CancellationTokenSource cts) : BaseTaskParam(cts);
|
||||
public class AutoMusicGameParam : BaseTaskParam;
|
||||
@@ -1,7 +1,5 @@
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
@@ -14,7 +12,7 @@ using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoMusicGame;
|
||||
|
||||
public class AutoMusicGameTask(AutoMusicGameParam taskParam)
|
||||
public class AutoMusicGameTask(AutoMusicGameParam taskParam) : ISoloTask
|
||||
{
|
||||
private readonly ConcurrentDictionary<User32.VK, int> _keyX = new()
|
||||
{
|
||||
@@ -30,57 +28,26 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam)
|
||||
|
||||
private readonly IntPtr _hWnd = TaskContext.Instance().GameHandle;
|
||||
|
||||
public async void Start()
|
||||
public Task Start(CancellationTokenSource cts)
|
||||
{
|
||||
var hasLock = false;
|
||||
try
|
||||
Init();
|
||||
|
||||
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
var taskFactory = new TaskFactory();
|
||||
var taskList = new List<Task>();
|
||||
|
||||
// 计算按键位置
|
||||
var gameCaptureRegion = CaptureToRectArea();
|
||||
|
||||
foreach (var keyValuePair in _keyX)
|
||||
{
|
||||
hasLock = await TaskSemaphore.WaitAsync(0);
|
||||
if (!hasLock)
|
||||
{
|
||||
Logger.LogError("启动自动战斗功能失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
return;
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
var taskFactory = new TaskFactory();
|
||||
var taskList = new List<Task>();
|
||||
|
||||
// 计算按键位置
|
||||
var gameCaptureRegion = CaptureToRectArea();
|
||||
|
||||
foreach (var keyValuePair in _keyX)
|
||||
{
|
||||
var (x, y) = gameCaptureRegion.ConvertPositionToGameCaptureRegion((int)(keyValuePair.Value * assetScale), (int)(_keyY * assetScale));
|
||||
// 添加任务
|
||||
taskList.Add(taskFactory.StartNew(() => DoWhitePressWin32(taskParam.Cts, keyValuePair.Key, new Point(x, y))));
|
||||
}
|
||||
|
||||
Task.WaitAll([.. taskList]);
|
||||
var (x, y) = gameCaptureRegion.ConvertPositionToGameCaptureRegion((int)(keyValuePair.Value * assetScale), (int)(_keyY * assetScale));
|
||||
// 添加任务
|
||||
taskList.Add(taskFactory.StartNew(() => DoWhitePressWin32(cts, keyValuePair.Key, new Point(x, y))));
|
||||
}
|
||||
catch (NormalEndException)
|
||||
{
|
||||
Logger.LogInformation("手动中断自动活动音游");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e.Message);
|
||||
Logger.LogDebug(e.StackTrace);
|
||||
}
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskTriggerDispatcher.Instance().StartTimer();
|
||||
TaskSettingsPageViewModel.SetSwitchAutoFightButtonText(false);
|
||||
Logger.LogInformation("→ {Text}", "自动活动音游结束");
|
||||
|
||||
if (hasLock)
|
||||
{
|
||||
TaskSemaphore.Release();
|
||||
}
|
||||
}
|
||||
Task.WaitAll([.. taskList]);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void DoWhitePressWin32(CancellationTokenSource cts, User32.VK key, Point point)
|
||||
@@ -129,10 +96,6 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam)
|
||||
private void Init()
|
||||
{
|
||||
LogScreenResolution();
|
||||
Logger.LogInformation("→ {Text}", "活动音游,启动!");
|
||||
SystemControl.ActivateWindow();
|
||||
TaskTriggerDispatcher.Instance().StopTimer();
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 5, taskParam.Cts); // 等待缓存图像
|
||||
}
|
||||
|
||||
private void LogScreenResolution()
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
public class ActionFactory
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, IActionHandler> _handlers = new();
|
||||
|
||||
public static IActionHandler GetHandler(string handlerType)
|
||||
{
|
||||
return _handlers.GetOrAdd(handlerType, (key) =>
|
||||
{
|
||||
return key switch
|
||||
{
|
||||
"nahida_collect" => new NahidaCollectHandler(),
|
||||
"pick_around" => new PickAroundHandler(),
|
||||
_ => throw new ArgumentException("未知的 action 类型")
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
public interface IActionHandler
|
||||
{
|
||||
Task RunAsync(CancellationTokenSource cts);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 使用纳西妲长按E技能进行收集,360°球形无死角扫码,`type = target`的情况才有效
|
||||
/// </summary>
|
||||
public class NahidaCollectHandler : IActionHandler
|
||||
{
|
||||
private DateTime lastETime = DateTime.MinValue;
|
||||
|
||||
public async Task RunAsync(CancellationTokenSource cts)
|
||||
{
|
||||
var cd = DateTime.Now - lastETime;
|
||||
if (cd < TimeSpan.FromSeconds(10))
|
||||
{
|
||||
await Delay((int)((6 - cd.TotalSeconds + 0.5) * 1000), cts);
|
||||
}
|
||||
|
||||
var dpi = TaskContext.Instance().DpiScale;
|
||||
|
||||
int x = (int)(200 * dpi), y = (int)(-50 * dpi);
|
||||
int i = 80;
|
||||
// 视角拉到最下面
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(0, 10000);
|
||||
await Delay(200, cts);
|
||||
|
||||
// 按住E技能 无死角扫码
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_E);
|
||||
await Delay(200, cts);
|
||||
while (!cts.IsCancellationRequested && i > 0)
|
||||
{
|
||||
i--;
|
||||
if (i == 40)
|
||||
{
|
||||
y -= (int)(20 * dpi);
|
||||
}
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(x, y);
|
||||
await Delay(40, cts);
|
||||
}
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_E);
|
||||
|
||||
lastETime = DateTime.Now;
|
||||
|
||||
await Delay(1000, cts);
|
||||
|
||||
// 恢复视角
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
|
||||
await Delay(1000, cts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 采集任务到达点位后执行拾取操作
|
||||
/// 暂时不需要
|
||||
/// </summary>
|
||||
public class PickAroundHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationTokenSource cts)
|
||||
{
|
||||
await Task.Delay(1000, cts.Token);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 采集任务到达点位后执行拾取操作
|
||||
/// 暂时不需要
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public class PickHandler
|
||||
{
|
||||
}
|
||||
@@ -5,6 +5,10 @@ namespace BetterGenshinImpact.GameTask.AutoPathing.Model.Enum;
|
||||
public class ActionEnum(string code, string msg)
|
||||
{
|
||||
public static readonly ActionEnum StopFlying = new("stop_flying", "下落攻击");
|
||||
public static readonly ActionEnum ForceTp = new("force_tp", "当前点传送");
|
||||
public static readonly ActionEnum NahidaCollect = new("nahida_collect", "纳西妲长按E收集");
|
||||
public static readonly ActionEnum PickAround = new("pick_around", "尝试在周围拾取");
|
||||
|
||||
// 还有要加入的其他动作
|
||||
// 滚轮F
|
||||
// 触发自动战斗任务
|
||||
|
||||
@@ -23,6 +23,12 @@ public class Navigation
|
||||
TaskControl.Logger.LogInformation("地图特征点加载完成!");
|
||||
}
|
||||
_isWarmUp = true;
|
||||
Reset();
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
EntireMap.Instance.SetPrevPosition(-1, -1);
|
||||
}
|
||||
|
||||
public static Point2f GetPosition(ImageRegion imageRegion)
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
@@ -56,6 +57,8 @@ public class PathExecutor(CancellationTokenSource cts)
|
||||
if (waypoint.Type == WaypointType.Target.Code || !string.IsNullOrEmpty(waypoint.Action))
|
||||
{
|
||||
await MoveCloseTo(waypoint);
|
||||
// 到达点位后执行 action
|
||||
await AfterMoveToTarget(waypoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,7 +102,8 @@ public class PathExecutor(CancellationTokenSource cts)
|
||||
|
||||
private async Task HandleTeleportWaypoint(Waypoint waypoint)
|
||||
{
|
||||
var (tpX, tpY) = await new TpTask(cts).Tp(waypoint.X, waypoint.Y);
|
||||
var forceTp = waypoint.Action == ActionEnum.ForceTp.Code;
|
||||
var (tpX, tpY) = await new TpTask(cts).Tp(waypoint.X, waypoint.Y, forceTp);
|
||||
var (tprX, tprY) = MapCoordinate.GameToMain2048(tpX, tpY);
|
||||
EntireMap.Instance.SetPrevPosition((float)tprX, (float)tprY); // 通过上一个位置直接进行局部特征匹配
|
||||
}
|
||||
@@ -150,13 +154,13 @@ public class PathExecutor(CancellationTokenSource cts)
|
||||
{
|
||||
Logger.LogWarning("疑似卡死,尝试脱离并跳过路径点");
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
await Delay(500, cts);
|
||||
await Delay(1500, cts);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_X);
|
||||
await Delay(500, cts);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_S);
|
||||
await Delay(500, cts);
|
||||
await Delay(1500, cts);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_A);
|
||||
await Delay(500, cts);
|
||||
await Delay(1500, cts);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_D);
|
||||
await Delay(500, cts);
|
||||
return;
|
||||
@@ -304,4 +308,14 @@ public class PathExecutor(CancellationTokenSource cts)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AfterMoveToTarget(Waypoint waypoint)
|
||||
{
|
||||
if (waypoint.Action == ActionEnum.NahidaCollect.Code
|
||||
|| waypoint.Action == ActionEnum.PickAround.Code)
|
||||
{
|
||||
var handler = ActionFactory.GetHandler(waypoint.Action);
|
||||
await handler.RunAsync(cts);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,23 @@ using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model.Enum;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.View.Controls.Webview;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Windows;
|
||||
using BetterGenshinImpact.Model;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing;
|
||||
|
||||
public class PathRecorder
|
||||
public class PathRecorder : Singleton<PathRecorder>
|
||||
{
|
||||
private WebpageWindow? _webWindow;
|
||||
|
||||
public static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals,
|
||||
@@ -28,6 +34,7 @@ public class PathRecorder
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Navigation.WarmUp();
|
||||
_pathingTask = new PathingTask();
|
||||
TaskControl.Logger.LogInformation("开始路径点记录");
|
||||
var waypoint = new Waypoint();
|
||||
@@ -39,7 +46,15 @@ public class PathRecorder
|
||||
waypoint.Type = WaypointType.Teleport.Code;
|
||||
waypoint.MoveMode = MoveModeEnum.Walk.Code;
|
||||
_pathingTask.Positions.Add(waypoint);
|
||||
TaskControl.Logger.LogInformation("已创建初始路径点({x},{y})", waypoint.X, waypoint.Y);
|
||||
if (_webWindow == null)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("已创建初始路径点({x},{y})", waypoint.X, waypoint.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskControl.Logger.LogInformation("已添加途径点({x},{y})", waypoint.X, waypoint.Y);
|
||||
AddPosToEditor(waypoint.X, waypoint.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddWaypoint(string waypointType = "")
|
||||
@@ -51,27 +66,55 @@ public class PathRecorder
|
||||
waypoint.X = position.X;
|
||||
waypoint.Y = position.Y;
|
||||
waypoint.Type = string.IsNullOrEmpty(waypointType) ? WaypointType.Path.Code : waypointType;
|
||||
// var motionStatus = Bv.GetMotionStatus(screen);
|
||||
// switch (motionStatus)
|
||||
// {
|
||||
// case MotionStatus.Fly:
|
||||
// waypoint.MoveStatus = MoveStatusType.Fly.Code;
|
||||
// break;
|
||||
//
|
||||
// case MotionStatus.Climb:
|
||||
// waypoint.MoveStatus = MoveStatusType.Jump.Code;
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// waypoint.MoveStatus = MoveStatusType.Walk.Code;
|
||||
// break;
|
||||
// }
|
||||
_pathingTask.Positions.Add(waypoint);
|
||||
TaskControl.Logger.LogInformation("已添加途径点({x},{y})", waypoint.X, waypoint.Y);
|
||||
AddPosToEditor(waypoint.X, waypoint.Y);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_pathingTask.SaveToFile(Path.Combine(MapPathingViewModel.PathJsonPath, $@"{DateTime.Now:yyyy-MM-dd HH:mm:ss:ffff}.json"));
|
||||
if (_webWindow == null)
|
||||
{
|
||||
var name = $@"{DateTime.Now:yyyyMMdd_HHmmss}.json";
|
||||
_pathingTask.SaveToFile(Path.Combine(MapPathingViewModel.PathJsonPath, name));
|
||||
TaskControl.Logger.LogInformation("录制编辑器未打开,直接保存路径点记录:{Name}", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskControl.Logger.LogInformation("路径点记录结束,请在录制编辑器中查看并编辑结果");
|
||||
TaskControl.Logger.LogInformation("如果要重新录制新的路径,请在录制编辑器中删除已有路径或创建新的路径");
|
||||
TaskControl.Logger.LogInformation("修改完毕后请务必记得导出路径!");
|
||||
}
|
||||
}
|
||||
|
||||
public void AddPosToEditor(double x, double y)
|
||||
{
|
||||
if (_webWindow != null)
|
||||
{
|
||||
_webWindow.WebView.ExecuteScriptAsync($"addNewPoint({x},{y})");
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenEditorInWebView()
|
||||
{
|
||||
if (_webWindow is not { IsVisible: true })
|
||||
{
|
||||
_webWindow = new WebpageWindow
|
||||
{
|
||||
Title = "地图路径点编辑器",
|
||||
Width = 1366,
|
||||
Height = 768,
|
||||
// Owner = Application.Current.MainWindow,
|
||||
WindowState = WindowState.Maximized
|
||||
};
|
||||
_webWindow.Closed += (s, e) => _webWindow = null;
|
||||
_webWindow.Panel!.DownloadFolderPath = MapPathingViewModel.PathJsonPath;
|
||||
_webWindow.NavigateToFile(Global.Absolute(@"Assets\Map\Editor\index.html"));
|
||||
_webWindow.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
_webWindow.Activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Recognition.OpenCv;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoSkip.Model;
|
||||
@@ -19,6 +20,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
@@ -36,6 +38,8 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
/// </summary>
|
||||
private Rect _missionDistanceRect = Rect.Empty;
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
public async void Start()
|
||||
{
|
||||
var hasLock = false;
|
||||
@@ -52,6 +56,8 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
|
||||
Logger.LogInformation("→ {Text}", "自动追踪,启动!");
|
||||
|
||||
_cts = CancellationContext.Instance.Cts;
|
||||
|
||||
TrackMission();
|
||||
}
|
||||
catch (NormalEndException e)
|
||||
@@ -68,7 +74,6 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskSettingsPageViewModel.SetSwitchAutoTrackButtonText(false);
|
||||
Logger.LogInformation("→ {Text}", "自动追踪结束");
|
||||
|
||||
if (hasLock)
|
||||
@@ -85,20 +90,20 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
var paimonMenuRa = ra.Find(ElementAssets.Instance.PaimonMenuRo);
|
||||
if (!paimonMenuRa.IsExist())
|
||||
{
|
||||
Sleep(5000, param.Cts);
|
||||
Sleep(5000, _cts);
|
||||
return;
|
||||
}
|
||||
|
||||
// 任务文字有动效,等待2s重新截图
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(0, 7000);
|
||||
Sleep(2000, param.Cts);
|
||||
Sleep(2000, _cts);
|
||||
|
||||
// OCR 任务文字 在小地图下方
|
||||
var textRaList = OcrMissionTextRaList(paimonMenuRa);
|
||||
if (textRaList.Count == 0)
|
||||
{
|
||||
Logger.LogInformation("未找到任务文字");
|
||||
Sleep(5000, param.Cts);
|
||||
Sleep(5000, _cts);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,14 +115,14 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
// 距离大于150米,先传送到最近的传送点
|
||||
// J 打开任务 切换追踪打开地图 中心点就是任务点
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_J);
|
||||
Sleep(800, param.Cts);
|
||||
Sleep(800, _cts);
|
||||
// TODO 识别是否在任务界面
|
||||
// 切换追踪
|
||||
var btn = ra.Derive(CaptureRect.Width - 250, CaptureRect.Height - 60);
|
||||
btn.Click();
|
||||
Sleep(200, param.Cts);
|
||||
Sleep(200, _cts);
|
||||
btn.Click();
|
||||
Sleep(1500, param.Cts);
|
||||
Sleep(1500, _cts);
|
||||
|
||||
// 寻找所有传送点
|
||||
ra = CaptureToRectArea();
|
||||
@@ -141,7 +146,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
|
||||
ra.Derive(nearestRect).Click();
|
||||
// 等待自动传送完成
|
||||
Sleep(2000, param.Cts);
|
||||
Sleep(2000, _cts);
|
||||
|
||||
if (Bv.IsInBigMapUi(CaptureToRectArea()))
|
||||
{
|
||||
@@ -149,7 +154,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
}
|
||||
else
|
||||
{
|
||||
Sleep(500, param.Cts);
|
||||
Sleep(500, _cts);
|
||||
NewRetry.Do(() =>
|
||||
{
|
||||
if (!Bv.IsInMainUi(CaptureToRectArea()))
|
||||
@@ -176,7 +181,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
{
|
||||
// V键直接追踪
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_V);
|
||||
Sleep(3000, param.Cts);
|
||||
Sleep(3000, _cts);
|
||||
|
||||
var ra = CaptureToRectArea();
|
||||
var blueTrackPointRa = ra.Find(ElementAssets.Instance.BlueTrackPoint);
|
||||
@@ -199,7 +204,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
// {
|
||||
int prevMoveX = 0;
|
||||
bool wDown = false;
|
||||
while (!param.Cts.Token.IsCancellationRequested)
|
||||
while (!_cts.Token.IsCancellationRequested)
|
||||
{
|
||||
var ra = CaptureToRectArea();
|
||||
var blueTrackPointRa = ra.Find(ElementAssets.Instance.BlueTrackPoint);
|
||||
|
||||
@@ -5,7 +5,4 @@ namespace BetterGenshinImpact.GameTask.AutoSkip.Model;
|
||||
|
||||
public class AutoTrackParam : BaseTaskParam
|
||||
{
|
||||
public AutoTrackParam(CancellationTokenSource cts) : base(cts)
|
||||
{
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -5,7 +5,4 @@ namespace BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
|
||||
public class AutoTrackPathParam : BaseTaskParam
|
||||
{
|
||||
public AutoTrackPathParam(CancellationTokenSource cts) : base(cts)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath.Model;
|
||||
@@ -44,6 +45,8 @@ public class AutoTrackPathTask
|
||||
// 视角偏移移动单位
|
||||
private const int CharMovingUnit = 500;
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
public AutoTrackPathTask(AutoTrackPathParam taskParam)
|
||||
{
|
||||
_taskParam = taskParam;
|
||||
@@ -64,6 +67,8 @@ public class AutoTrackPathTask
|
||||
return;
|
||||
}
|
||||
|
||||
_cts = CancellationContext.Instance.Cts;
|
||||
|
||||
Init();
|
||||
|
||||
// Tp(_tpPositions[260].X, _tpPositions[260].Y);
|
||||
@@ -83,7 +88,6 @@ public class AutoTrackPathTask
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.NormalTrigger);
|
||||
TaskSettingsPageViewModel.SetSwitchAutoFightButtonText(false);
|
||||
Logger.LogInformation("→ {Text}", "自动路线结束");
|
||||
|
||||
if (hasLock)
|
||||
@@ -98,19 +102,19 @@ public class AutoTrackPathTask
|
||||
SystemControl.ActivateWindow();
|
||||
Logger.LogInformation("→ {Text}", "自动路线,启动!");
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.OnlyCacheCapture);
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 5, _taskParam.Cts); // 等待缓存图像
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 5, _cts); // 等待缓存图像
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_taskParam.Cts.Cancel();
|
||||
_cts.Cancel();
|
||||
}
|
||||
|
||||
public async Task DoTask()
|
||||
{
|
||||
// 1. 传送到最近的传送点
|
||||
var first = _way.WayPointList[0]; // 解析路线,第一个点为起点
|
||||
await new TpTask(_taskParam.Cts).Tp(first.Pt.X, first.Pt.Y);
|
||||
await new TpTask(_cts).Tp(first.Pt.X, first.Pt.Y);
|
||||
|
||||
// 2. 等待传送完成
|
||||
Sleep(1000);
|
||||
@@ -132,7 +136,7 @@ public class AutoTrackPathTask
|
||||
// 4. 针对点位进行直线追踪
|
||||
|
||||
var trackCts = new CancellationTokenSource();
|
||||
_taskParam.Cts.Token.Register(trackCts.Cancel);
|
||||
_cts.Token.Register(trackCts.Cancel);
|
||||
var trackTask = Track(_way.WayPointList, angleOffset, trackCts);
|
||||
trackTask.Start();
|
||||
var refreshStatusTask = RefreshStatus(trackCts);
|
||||
@@ -148,7 +152,7 @@ public class AutoTrackPathTask
|
||||
{
|
||||
return new Task(() =>
|
||||
{
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested && !trackCts.Token.IsCancellationRequested)
|
||||
while (!_cts.Token.IsCancellationRequested && !trackCts.Token.IsCancellationRequested)
|
||||
{
|
||||
if (_motionStatus == MotionStatus.Normal)
|
||||
{
|
||||
@@ -178,7 +182,7 @@ public class AutoTrackPathTask
|
||||
{
|
||||
return new Task(() =>
|
||||
{
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested && !trackCts.Token.IsCancellationRequested)
|
||||
while (!_cts.Token.IsCancellationRequested && !trackCts.Token.IsCancellationRequested)
|
||||
{
|
||||
using var ra = CaptureToRectArea();
|
||||
_motionStatus = Bv.GetMotionStatus(ra);
|
||||
@@ -206,7 +210,7 @@ public class AutoTrackPathTask
|
||||
return new Task(() =>
|
||||
{
|
||||
var currIndex = 0;
|
||||
while (!_taskParam.Cts.IsCancellationRequested)
|
||||
while (!_cts.IsCancellationRequested)
|
||||
{
|
||||
var ra = CaptureToRectArea();
|
||||
var miniMapMat = GetMiniMapMat(ra) ?? throw new InvalidOperationException("当前不在主界面");
|
||||
|
||||
@@ -33,11 +33,17 @@ public class TpTask(CancellationTokenSource cts)
|
||||
/// </summary>
|
||||
/// <param name="tpX"></param>
|
||||
/// <param name="tpY"></param>
|
||||
public async Task<(double, double)> Tp(double tpX, double tpY)
|
||||
/// <param name="force">强制以当前的tpX,tpY坐标进行自动传送</param>
|
||||
public async Task<(double, double)> TpOnce(double tpX, double tpY, bool force = false)
|
||||
{
|
||||
// 获取最近的传送点位置
|
||||
var (x, y) = GetRecentlyTpPoint(tpX, tpY);
|
||||
Logger.LogInformation("({TpX},{TpY}) 最近的传送点位置 ({X},{Y})", $"{tpX:F1}", $"{tpY:F1}", $"{x:F1}", $"{y:F1}");
|
||||
var (x, y) = (tpX, tpY);
|
||||
|
||||
if (!force)
|
||||
{
|
||||
// 获取最近的传送点位置
|
||||
(x, y) = GetRecentlyTpPoint(tpX, tpY);
|
||||
Logger.LogInformation("({TpX},{TpY}) 最近的传送点位置 ({X},{Y})", $"{tpX:F1}", $"{tpY:F1}", $"{x:F1}", $"{y:F1}");
|
||||
}
|
||||
|
||||
// M 打开地图识别当前位置,中心点为当前位置
|
||||
using var ra1 = CaptureToRectArea();
|
||||
@@ -52,7 +58,7 @@ public class TpTask(CancellationTokenSource cts)
|
||||
|
||||
// 计算坐标后点击
|
||||
var bigMapInAllMapRect = GetBigMapRect();
|
||||
while (!bigMapInAllMapRect.Contains(x, y))
|
||||
while (!bigMapInAllMapRect.Shrink(115).Contains(x, y))
|
||||
{
|
||||
Debug.WriteLine($"({x},{y}) 不在 {bigMapInAllMapRect} 内,继续移动");
|
||||
Logger.LogInformation("传送点不在当前大地图范围内,继续移动");
|
||||
@@ -91,6 +97,23 @@ public class TpTask(CancellationTokenSource cts)
|
||||
return (x, y);
|
||||
}
|
||||
|
||||
public async Task<(double, double)> Tp(double tpX, double tpY, bool force = false)
|
||||
{
|
||||
// 重试3次
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await TpOnce(tpX, tpY, force);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e, "传送失败,重试 {I} 次", i + 1);
|
||||
}
|
||||
}
|
||||
throw new InvalidOperationException("传送失败");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动地图到指定传送点位置
|
||||
/// 可能会移动不对,所以可以重试此方法
|
||||
@@ -179,6 +202,18 @@ public class TpTask(CancellationTokenSource cts)
|
||||
return GetBigMapCenterPoint();
|
||||
}
|
||||
|
||||
public Point2f? GetPositionFromBigMapNullable()
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetBigMapCenterPoint();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Rect GetBigMapRect()
|
||||
{
|
||||
var rect = new Rect();
|
||||
@@ -202,7 +237,7 @@ public class TpTask(CancellationTokenSource cts)
|
||||
{
|
||||
throw new RetryException("当前不在地图界面");
|
||||
}
|
||||
}, TimeSpan.FromMilliseconds(500), 10);
|
||||
}, TimeSpan.FromMilliseconds(500), 5);
|
||||
|
||||
if (rect == Rect.Empty)
|
||||
{
|
||||
@@ -272,10 +307,16 @@ public class TpTask(CancellationTokenSource cts)
|
||||
}
|
||||
|
||||
// 识别当前位置
|
||||
var bigMapCenterPoint = GetPositionFromBigMap();
|
||||
Logger.LogInformation("识别当前位置:{Pos}", bigMapCenterPoint);
|
||||
var minDistance = double.MaxValue;
|
||||
var bigMapCenterPointNullable = GetPositionFromBigMapNullable();
|
||||
|
||||
if (bigMapCenterPointNullable != null)
|
||||
{
|
||||
var bigMapCenterPoint = bigMapCenterPointNullable.Value;
|
||||
Logger.LogInformation("识别当前大地图位置:{Pos}", bigMapCenterPoint);
|
||||
minDistance = Math.Sqrt(Math.Pow(bigMapCenterPoint.X - x, 2) + Math.Pow(bigMapCenterPoint.Y - y, 2));
|
||||
}
|
||||
|
||||
var minDistance = Math.Sqrt(Math.Pow(bigMapCenterPoint.X - x, 2) + Math.Pow(bigMapCenterPoint.Y - y, 2));
|
||||
var minCountry = "当前位置";
|
||||
foreach (var (country, position) in MapAssets.Instance.CountryPositions)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoWood.Assets;
|
||||
@@ -15,6 +16,8 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using static Vanara.PInvoke.User32;
|
||||
@@ -25,7 +28,7 @@ namespace BetterGenshinImpact.GameTask.AutoWood;
|
||||
/// <summary>
|
||||
/// 自动伐木
|
||||
/// </summary>
|
||||
public partial class AutoWoodTask
|
||||
public partial class AutoWoodTask : ISoloTask
|
||||
{
|
||||
private readonly AutoWoodAssets _assets;
|
||||
|
||||
@@ -37,30 +40,29 @@ public partial class AutoWoodTask
|
||||
|
||||
private VK _zKey = VK.VK_Z;
|
||||
|
||||
public AutoWoodTask()
|
||||
private readonly WoodTaskParam _taskParam;
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
public AutoWoodTask(WoodTaskParam taskParam)
|
||||
{
|
||||
this._taskParam = taskParam;
|
||||
_login3rdParty = new();
|
||||
AutoWoodAssets.DestroyInstance();
|
||||
_assets = AutoWoodAssets.Instance;
|
||||
_printer = new WoodStatisticsPrinter(_assets);
|
||||
}
|
||||
|
||||
public void Start(WoodTaskParam taskParam)
|
||||
public Task Start(CancellationTokenSource cts)
|
||||
{
|
||||
var hasLock = false;
|
||||
var runTimeWatch = new Stopwatch();
|
||||
_cts = cts;
|
||||
_printer.Cts = _cts;
|
||||
|
||||
try
|
||||
{
|
||||
hasLock = TaskSemaphore.Wait(0);
|
||||
if (!hasLock)
|
||||
{
|
||||
Logger.LogError("启动自动伐木功能失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
return;
|
||||
}
|
||||
|
||||
TaskTriggerDispatcher.Instance().StopTimer();
|
||||
Kernel32.SetThreadExecutionState(Kernel32.EXECUTION_STATE.ES_CONTINUOUS | Kernel32.EXECUTION_STATE.ES_SYSTEM_REQUIRED | Kernel32.EXECUTION_STATE.ES_DISPLAY_REQUIRED);
|
||||
Logger.LogInformation("→ {Text} 设置伐木总次数:{Cnt},设置木材数量上限:{MaxCnt}", "自动伐木,启动!", taskParam.WoodRoundNum, taskParam.WoodDailyMaxCount);
|
||||
Logger.LogInformation("→ {Text} 设置伐木总次数:{Cnt},设置木材数量上限:{MaxCnt}", "自动伐木,启动!", _taskParam.WoodRoundNum, _taskParam.WoodDailyMaxCount);
|
||||
|
||||
_login3rdParty.RefreshAvailabled();
|
||||
if (_login3rdParty.Type == Login3rdParty.The3rdPartyType.Bilibili)
|
||||
@@ -86,7 +88,7 @@ public partial class AutoWoodTask
|
||||
SystemControl.ActivateWindow();
|
||||
// 伐木开始计时
|
||||
runTimeWatch.Start();
|
||||
for (var i = 0; i < taskParam.WoodRoundNum; i++)
|
||||
for (var i = 0; i < _taskParam.WoodRoundNum; i++)
|
||||
{
|
||||
if (TaskContext.Instance().Config.AutoWoodConfig.WoodCountOcrEnabled)
|
||||
{
|
||||
@@ -98,48 +100,31 @@ public partial class AutoWoodTask
|
||||
|
||||
if (_printer.ReachedWoodMaxCount)
|
||||
{
|
||||
Logger.LogInformation("{Names}已达到设置的上限:{MaxCnt}", _printer.WoodTotalDict.Keys, taskParam.WoodDailyMaxCount);
|
||||
Logger.LogInformation("{Names}已达到设置的上限:{MaxCnt}", _printer.WoodTotalDict.Keys, _taskParam.WoodDailyMaxCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.LogInformation("第{Cnt}次伐木", i + 1);
|
||||
if (taskParam.Cts.IsCancellationRequested)
|
||||
if (_cts.IsCancellationRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Felling(taskParam, i + 1 == taskParam.WoodRoundNum);
|
||||
Felling(_taskParam, i + 1 == _taskParam.WoodRoundNum);
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
Sleep(500, taskParam.Cts);
|
||||
Sleep(500, _cts);
|
||||
}
|
||||
}
|
||||
catch (NormalEndException e)
|
||||
{
|
||||
Logger.LogInformation(e.Message);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e.Message);
|
||||
Logger.LogDebug(e.StackTrace);
|
||||
MessageBox.Error("自动伐木时异常:" + e.Source + "\r\n--" + Environment.NewLine + e.StackTrace + "\r\n---" + Environment.NewLine + e.Message);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskSettingsPageViewModel.SetSwitchAutoWoodButtonText(false);
|
||||
// 伐木结束计时
|
||||
runTimeWatch.Stop();
|
||||
Kernel32.SetThreadExecutionState(Kernel32.EXECUTION_STATE.ES_CONTINUOUS);
|
||||
var elapsedTime = runTimeWatch.Elapsed;
|
||||
Logger.LogInformation(@"本次伐木总耗时:{Time:hh\:mm\:ss}", elapsedTime);
|
||||
Logger.LogInformation("← {Text}", "退出自动伐木");
|
||||
TaskTriggerDispatcher.Instance().StartTimer();
|
||||
|
||||
if (hasLock)
|
||||
{
|
||||
TaskSemaphore.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +146,8 @@ public partial class AutoWoodTask
|
||||
"杉木", "竹节", "却砂木", "松木", "萃华木", "桦木", "孔雀木", "梦见木", "御伽木"
|
||||
];
|
||||
|
||||
public CancellationTokenSource? Cts { get; set; }
|
||||
|
||||
[GeneratedRegex("([^\\d\\n]+)[×x](\\d+)")]
|
||||
private static partial Regex _parseWoodStatisticsRegex();
|
||||
|
||||
@@ -230,7 +217,7 @@ public partial class AutoWoodTask
|
||||
|
||||
private void SleepDurationBetweenOcrs(WoodTaskParam taskParam)
|
||||
{
|
||||
Sleep(_firstWoodOcr ? 300 : 100, taskParam.Cts);
|
||||
Sleep(_firstWoodOcr ? 300 : 100, Cts);
|
||||
}
|
||||
|
||||
private string WoodTextAreaOcr()
|
||||
@@ -446,7 +433,7 @@ public partial class AutoWoodTask
|
||||
{
|
||||
NewRetry.Do(() =>
|
||||
{
|
||||
Sleep(1, taskParam.Cts);
|
||||
Sleep(1, _cts);
|
||||
using var contentRegion = CaptureToRectArea();
|
||||
using var ra = contentRegion.Find(_assets.TheBoonOfTheElderTreeRo);
|
||||
if (ra.IsEmpty())
|
||||
@@ -460,12 +447,12 @@ public partial class AutoWoodTask
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyPress(_zKey);
|
||||
Debug.WriteLine("[AutoWood] Z");
|
||||
Sleep(500, taskParam.Cts);
|
||||
Sleep(500, _cts);
|
||||
}, TimeSpan.FromSeconds(1), 120);
|
||||
}
|
||||
|
||||
Sleep(300, taskParam.Cts);
|
||||
Sleep(TaskContext.Instance().Config.AutoWoodConfig.AfterZSleepDelay, taskParam.Cts);
|
||||
Sleep(300, _cts);
|
||||
Sleep(TaskContext.Instance().Config.AutoWoodConfig.AfterZSleepDelay, _cts);
|
||||
}
|
||||
|
||||
private void PressEsc(WoodTaskParam taskParam)
|
||||
@@ -474,17 +461,17 @@ public partial class AutoWoodTask
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_ESCAPE);
|
||||
// if (TaskContext.Instance().Config.AutoWoodConfig.PressTwoEscEnabled)
|
||||
// {
|
||||
// Sleep(1500, taskParam.Cts);
|
||||
// Sleep(1500, _cts);
|
||||
// Simulation.SendInput.Keyboard.KeyPress(VK.VK_ESCAPE);
|
||||
// }
|
||||
Debug.WriteLine("[AutoWood] Esc");
|
||||
Sleep(800, taskParam.Cts);
|
||||
Sleep(800, _cts);
|
||||
// 确认在菜单界面
|
||||
try
|
||||
{
|
||||
NewRetry.Do(() =>
|
||||
{
|
||||
Sleep(1, taskParam.Cts);
|
||||
Sleep(1, _cts);
|
||||
using var contentRegion = CaptureToRectArea();
|
||||
using var ra = contentRegion.Find(_assets.MenuBagRo);
|
||||
if (ra.IsEmpty())
|
||||
@@ -505,7 +492,7 @@ public partial class AutoWoodTask
|
||||
|
||||
Debug.WriteLine("[AutoWood] Click exit button");
|
||||
|
||||
Sleep(500, taskParam.Cts);
|
||||
Sleep(500, _cts);
|
||||
|
||||
// 点击确认
|
||||
using var contentRegion = CaptureToRectArea();
|
||||
@@ -521,14 +508,14 @@ public partial class AutoWoodTask
|
||||
{
|
||||
if (_login3rdParty.IsAvailabled)
|
||||
{
|
||||
Sleep(1, taskParam.Cts);
|
||||
_login3rdParty.Login(taskParam.Cts);
|
||||
Sleep(1, _cts);
|
||||
_login3rdParty.Login(_cts);
|
||||
}
|
||||
|
||||
var clickCnt = 0;
|
||||
for (var i = 0; i < 50; i++)
|
||||
{
|
||||
Sleep(1, taskParam.Cts);
|
||||
Sleep(1, _cts);
|
||||
|
||||
using var contentRegion = CaptureToRectArea();
|
||||
using var ra = contentRegion.Find(_assets.EnterGameRo);
|
||||
@@ -542,12 +529,12 @@ public partial class AutoWoodTask
|
||||
{
|
||||
if (clickCnt > 2)
|
||||
{
|
||||
Sleep(5000, taskParam.Cts);
|
||||
Sleep(5000, _cts);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(1000, taskParam.Cts);
|
||||
Sleep(1000, _cts);
|
||||
}
|
||||
|
||||
if (clickCnt == 0)
|
||||
|
||||
@@ -8,7 +8,7 @@ public class WoodTaskParam : BaseTaskParam
|
||||
public int WoodRoundNum { get; set; }
|
||||
public int WoodDailyMaxCount { get; set; }
|
||||
|
||||
public WoodTaskParam(CancellationTokenSource cts, int woodRoundNum, int woodDailyMaxCount) : base(cts)
|
||||
public WoodTaskParam(int woodRoundNum, int woodDailyMaxCount)
|
||||
{
|
||||
WoodRoundNum = woodRoundNum;
|
||||
if (woodRoundNum == 0)
|
||||
@@ -17,6 +17,6 @@ public class WoodTaskParam : BaseTaskParam
|
||||
}
|
||||
|
||||
WoodDailyMaxCount = woodDailyMaxCount;
|
||||
if (WoodDailyMaxCount is 0 or >= 2000) WoodDailyMaxCount = 2000;
|
||||
if (WoodDailyMaxCount is 0 or >= 9999) WoodDailyMaxCount = 9999;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask;
|
||||
|
||||
public interface ISoloTask
|
||||
{
|
||||
Task Start(CancellationTokenSource cts);
|
||||
}
|
||||
@@ -8,17 +8,4 @@ namespace BetterGenshinImpact.GameTask.Model;
|
||||
/// </summary>
|
||||
public class BaseTaskParam
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public CancellationTokenSource Cts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 针对实时触发器的操作
|
||||
/// </summary>
|
||||
public DispatcherTimerOperationEnum TriggerOperation { get; set; } = DispatcherTimerOperationEnum.None;
|
||||
|
||||
protected BaseTaskParam(CancellationTokenSource cts)
|
||||
{
|
||||
this.Cts = cts;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using BetterGenshinImpact.Core.Recorder;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask;
|
||||
|
||||
@@ -99,6 +100,11 @@ public class TaskRunner
|
||||
await Task.Run(() => RunAsync(action));
|
||||
}
|
||||
|
||||
public async Task RunSoloTaskAsync(ISoloTask soloTask)
|
||||
{
|
||||
await Task.Run(() => RunAsync(async () => await soloTask.Start(CancellationContext.Instance.Cts)));
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (!TaskContext.Instance().IsInitialized)
|
||||
|
||||
@@ -196,41 +196,41 @@ namespace BetterGenshinImpact.GameTask
|
||||
/// </summary>
|
||||
public void StartIndependentTask(IndependentTaskEnum taskType, BaseTaskParam param)
|
||||
{
|
||||
if (!_timer.Enabled)
|
||||
{
|
||||
throw new Exception("请先在启动页启动BetterGI,如果已经启动请重启");
|
||||
}
|
||||
|
||||
var maskWindow = MaskWindow.Instance();
|
||||
maskWindow.Invoke(() => { maskWindow.Show(); });
|
||||
if (taskType == IndependentTaskEnum.AutoGeniusInvokation)
|
||||
{
|
||||
AutoGeniusInvokationTask.Start((GeniusInvokationTaskParam)param);
|
||||
}
|
||||
else if (taskType == IndependentTaskEnum.AutoWood)
|
||||
{
|
||||
Task.Run(() => { new AutoWoodTask().Start((WoodTaskParam)param); });
|
||||
}
|
||||
else if (taskType == IndependentTaskEnum.AutoFight)
|
||||
{
|
||||
Task.Run(() => { new AutoFightTask((AutoFightParam)param).Start(); });
|
||||
}
|
||||
else if (taskType == IndependentTaskEnum.AutoDomain)
|
||||
{
|
||||
Task.Run(() => { new AutoDomainTask((AutoDomainParam)param).Start(); });
|
||||
}
|
||||
else if (taskType == IndependentTaskEnum.AutoTrack)
|
||||
{
|
||||
Task.Run(() => { new AutoTrackTask((AutoTrackParam)param).Start(); });
|
||||
}
|
||||
else if (taskType == IndependentTaskEnum.AutoTrackPath)
|
||||
{
|
||||
Task.Run(() => { new AutoTrackPathTask((AutoTrackPathParam)param).Start(); });
|
||||
}
|
||||
else if (taskType == IndependentTaskEnum.AutoMusicGame)
|
||||
{
|
||||
Task.Run(() => { new AutoMusicGameTask((AutoMusicGameParam)param).Start(); });
|
||||
}
|
||||
// if (!_timer.Enabled)
|
||||
// {
|
||||
// throw new Exception("请先在启动页启动BetterGI,如果已经启动请重启");
|
||||
// }
|
||||
//
|
||||
// var maskWindow = MaskWindow.Instance();
|
||||
// maskWindow.Invoke(() => { maskWindow.Show(); });
|
||||
// if (taskType == IndependentTaskEnum.AutoGeniusInvokation)
|
||||
// {
|
||||
// AutoGeniusInvokationTask.Start((GeniusInvokationTaskParam)param);
|
||||
// }
|
||||
// else if (taskType == IndependentTaskEnum.AutoWood)
|
||||
// {
|
||||
// Task.Run(() => { new AutoWoodTask().Start((WoodTaskParam)param); });
|
||||
// }
|
||||
// else if (taskType == IndependentTaskEnum.AutoFight)
|
||||
// {
|
||||
// Task.Run(() => { new AutoFightTask((AutoFightParam)param).Start(); });
|
||||
// }
|
||||
// else if (taskType == IndependentTaskEnum.AutoDomain)
|
||||
// {
|
||||
// Task.Run(() => { new AutoDomainTask((AutoDomainParam)param).Start(); });
|
||||
// }
|
||||
// else if (taskType == IndependentTaskEnum.AutoTrack)
|
||||
// {
|
||||
// Task.Run(() => { new AutoTrackTask((AutoTrackParam)param).Start(); });
|
||||
// }
|
||||
// else if (taskType == IndependentTaskEnum.AutoTrackPath)
|
||||
// {
|
||||
// Task.Run(() => { new AutoTrackPathTask((AutoTrackPathParam)param).Start(); });
|
||||
// }
|
||||
// else if (taskType == IndependentTaskEnum.AutoMusicGame)
|
||||
// {
|
||||
// Task.Run(() => { new AutoMusicGameTask((AutoMusicGameParam)param).Start(); });
|
||||
// }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -8,4 +8,14 @@ public static class RectExtension
|
||||
{
|
||||
return (rect.X <= x && rect.Y <= y && rect.X + rect.Width > x && rect.Y + rect.Height > y);
|
||||
}
|
||||
|
||||
public static Rect Shrink(this Rect rect, int shrinkAmount)
|
||||
{
|
||||
return new Rect(rect.X + shrinkAmount, rect.Y + shrinkAmount, rect.Width - 2 * shrinkAmount, rect.Height - 2 * shrinkAmount);
|
||||
}
|
||||
|
||||
public static Rect Shrink(this Rect rect, int shrinkWidth, int shrinkHeight)
|
||||
{
|
||||
return new Rect(rect.X + shrinkWidth, rect.Y + shrinkHeight, rect.Width - 2 * shrinkWidth, rect.Height - 2 * shrinkHeight);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using Wpf.Ui.Controls;
|
||||
using static Vanara.PInvoke.Gdi32;
|
||||
|
||||
namespace BetterGenshinImpact.Model;
|
||||
|
||||
public class FileTreeModel<T>(string rootPath) : ITreeModel where T : class
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public DirectoryInfo? Directory { get; set; }
|
||||
|
||||
public T? Data { get; set; }
|
||||
|
||||
public IEnumerable GetChildren(object? parent)
|
||||
{
|
||||
parent ??= new FileTreeModel<T>(rootPath)
|
||||
{
|
||||
Directory = new DirectoryInfo(rootPath)
|
||||
};
|
||||
|
||||
|
||||
if (parent is FileTreeModel<T> { Directory: not null } model)
|
||||
{
|
||||
// 返回子目录
|
||||
foreach (var dir in model.Directory.GetDirectories())
|
||||
{
|
||||
yield return new FileTreeModel<T>(rootPath)
|
||||
{
|
||||
Name = dir.Name,
|
||||
Directory = dir
|
||||
};
|
||||
}
|
||||
|
||||
// 返回文件
|
||||
foreach (var file in model.Directory.GetFiles())
|
||||
{
|
||||
var m = new FileTreeModel<T>(rootPath)
|
||||
{
|
||||
Name = file.Name,
|
||||
};
|
||||
if (typeof(T) == typeof(PathingTask))
|
||||
{
|
||||
m.Data = PathingTask.BuildFromFilePath(file.FullName) as T;
|
||||
}
|
||||
yield return m;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasChildren(object parent)
|
||||
{
|
||||
if (parent is FileTreeModel<T> { Directory: not null } model)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 检查是否有子目录或文件
|
||||
return model.Directory.GetDirectories().Any() || model.Directory.GetFiles().Any();
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
// 捕获没有权限的异常并返回 false
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 处理其他可能的异常
|
||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.Model;
|
||||
|
||||
[ObservableObject]
|
||||
public partial class PathingTaskTreeObject : TreeObject<PathingTaskTreeObject>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? _name;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isFolder;
|
||||
|
||||
[ObservableProperty]
|
||||
private PathingTask? _task;
|
||||
}
|
||||
@@ -6,7 +6,5 @@ namespace BetterGenshinImpact.Service.Interface;
|
||||
|
||||
public interface IScriptService
|
||||
{
|
||||
Task RunMultiJs(List<string> folderNameList, string? groupName = null);
|
||||
|
||||
Task RunMulti(IEnumerable<ScriptGroupProject> projectList, string? groupName = null);
|
||||
}
|
||||
@@ -18,71 +18,6 @@ public partial class ScriptService(HomePageViewModel homePageViewModel) : IScrip
|
||||
{
|
||||
private readonly ILogger<ScriptService> _logger = App.GetLogger<ScriptService>();
|
||||
|
||||
/// <summary>
|
||||
/// TODO 合并到 RunMulti
|
||||
/// </summary>
|
||||
/// <param name="folderNameList"></param>
|
||||
/// <param name="groupName"></param>
|
||||
/// <returns></returns>
|
||||
public async Task RunMultiJs(List<string> folderNameList, string? groupName = null)
|
||||
{
|
||||
// 重新加载脚本项目
|
||||
var projects = folderNameList.Select(name => new ScriptProject(name)).ToList();
|
||||
|
||||
var codeList = await ReadCodeList(projects);
|
||||
var hasTimer = HasTimerOperation(codeList);
|
||||
|
||||
// 没启动时候,启动截图器
|
||||
await homePageViewModel.OnStartTriggerAsync();
|
||||
|
||||
if (!string.IsNullOrEmpty(groupName))
|
||||
{
|
||||
if (hasTimer)
|
||||
{
|
||||
_logger.LogInformation("配置组 {Name} 包含实时任务操作调用", groupName);
|
||||
}
|
||||
|
||||
_logger.LogInformation("配置组 {Name} 加载完成,共{Cnt}个脚本,开始执行", groupName, projects.Count);
|
||||
}
|
||||
|
||||
// 循环执行所有脚本
|
||||
var timerOperation = hasTimer ? DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty : DispatcherTimerOperationEnum.UseSelfCaptureImage;
|
||||
await new TaskRunner(timerOperation)
|
||||
.RunThreadAsync(async () =>
|
||||
{
|
||||
foreach (var project in projects)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (hasTimer)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().ClearTriggers();
|
||||
}
|
||||
|
||||
_logger.LogInformation("------------------------------");
|
||||
_logger.LogInformation("→ 开始执行脚本: {Name}", project.Manifest.Name);
|
||||
await project.ExecuteAsync();
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogDebug(e, "执行脚本时发生异常");
|
||||
_logger.LogError("执行脚本时发生异常: {Msg}", e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_logger.LogInformation("→ 脚本执行结束: {Name}", project.Manifest.Name);
|
||||
_logger.LogInformation("------------------------------");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!string.IsNullOrEmpty(groupName))
|
||||
{
|
||||
_logger.LogInformation("配置组 {Name} 执行结束", groupName);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RunMulti(IEnumerable<ScriptGroupProject> projectList, string? groupName = null)
|
||||
{
|
||||
groupName ??= "默认";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Microsoft.Web.WebView2.Wpf;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
@@ -16,6 +17,10 @@ public class WebpagePanel : UserControl
|
||||
private WebView2 _webView = null!;
|
||||
private bool _initialized = false;
|
||||
|
||||
public WebView2 WebView => _webView;
|
||||
|
||||
public string? DownloadFolderPath { get; set; }
|
||||
|
||||
public WebpagePanel()
|
||||
{
|
||||
if (!IsWebView2Available())
|
||||
@@ -43,6 +48,10 @@ public class WebpagePanel : UserControl
|
||||
if (e.IsSuccess)
|
||||
{
|
||||
_initialized = true;
|
||||
if (!string.IsNullOrEmpty(DownloadFolderPath))
|
||||
{
|
||||
WebView.CoreWebView2.Profile.DefaultDownloadFolderPath = DownloadFolderPath;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Microsoft.Web.WebView2.Wpf;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.View.Controls.Webview;
|
||||
|
||||
public class WebpageWindow : Window
|
||||
{
|
||||
public WebpagePanel? Webview => Content as WebpagePanel;
|
||||
public WebpagePanel? Panel => Content as WebpagePanel;
|
||||
|
||||
public WebView2 WebView => Panel!.WebView;
|
||||
|
||||
public WebpageWindow()
|
||||
{
|
||||
@@ -43,11 +46,16 @@ public class WebpageWindow : Window
|
||||
|
||||
public void NavigateToUri(Uri uri)
|
||||
{
|
||||
Webview?.NavigateToUri(uri);
|
||||
Panel?.NavigateToUri(uri);
|
||||
}
|
||||
|
||||
public void NavigateToHtml(string html)
|
||||
{
|
||||
Webview?.NavigateToHtml(html);
|
||||
Panel?.NavigateToHtml(html);
|
||||
}
|
||||
|
||||
public void NavigateToFile(string path)
|
||||
{
|
||||
Panel?.NavigateToFile(path);
|
||||
}
|
||||
}
|
||||
@@ -72,8 +72,11 @@
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="在遮罩内显示日志窗口"
|
||||
TextWrapping="Wrap" />
|
||||
TextWrapping="Wrap">
|
||||
在遮罩内显示日志窗口,<Hyperlink Command="{Binding GoToLogFolderCommand}" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
|
||||
点击打开日志文件夹
|
||||
</Hyperlink>
|
||||
</ui:TextBlock>
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
|
||||
@@ -106,6 +106,9 @@
|
||||
<MenuItem Command="{Binding StartRunCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
||||
Header="执行脚本" />
|
||||
<MenuItem Command="{Binding RefreshCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
||||
Header="刷新" />
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
<ListView.Style>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
TextWrapping="Wrap">
|
||||
可以实现自动采集(尝鲜)、自动挖矿(开发中)、自动锄地(开发中)等功能。建议在调度器中使用!<Hyperlink Command="{Binding GoToPathingUrlCommand}" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
|
||||
点击查看地图追踪使用教程
|
||||
点击查看地图追踪与录制使用教程
|
||||
</Hyperlink>
|
||||
</ui:TextBlock>
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
<ui:Button Margin="10,0,0,0"
|
||||
Command="{Binding OpenMapViewerCommand}"
|
||||
Content="查看实时追踪地图" />
|
||||
<ui:Button Margin="10,0,0,0"
|
||||
Command="{Binding OpenMapEditorCommand}"
|
||||
Content="打开录制编辑器" />
|
||||
</StackPanel>
|
||||
|
||||
<Separator Grid.Row="3"
|
||||
@@ -64,14 +67,40 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<!-- <ColumnDefinition Width="100" /> -->
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="30" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid x:Name="Col1" Grid.Column="0" />
|
||||
<Grid x:Name="Col2" Grid.Column="1" />
|
||||
<Grid x:Name="Col3" Grid.Column="2" />
|
||||
<!-- <Grid x:Name="Col4" Grid.Column="3" /> -->
|
||||
</Grid>
|
||||
<ui:ListView Grid.Row="5"
|
||||
<ui:TreeListView Grid.Row="5" Model="{Binding FileItems}">
|
||||
<ui:GridView>
|
||||
<ui:GridView.Columns>
|
||||
<ui:GridViewColumn Width="{Binding ElementName=Col1, Path=ActualWidth}" Header="名称">
|
||||
<ui:GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ui:TreeRowExpander Content="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ui:GridViewColumn.CellTemplate>
|
||||
</ui:GridViewColumn>
|
||||
<ui:GridViewColumn Width="{Binding ElementName=Col2, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding Data.Info.TypeDesc}"
|
||||
Header="类型" />
|
||||
</ui:GridView.Columns>
|
||||
</ui:GridView>
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<!-- <MenuItem Command="{Binding StartCommand}" -->
|
||||
<!-- CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" -->
|
||||
<!-- Header="执行任务" /> -->
|
||||
<MenuItem Command="{Binding RefreshCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
||||
Header="刷新" />
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
</ui:TreeListView>
|
||||
<!--<ui:ListView Grid.Row="5"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ItemsSource="{Binding PathItems}"
|
||||
@@ -84,7 +113,7 @@
|
||||
<GridViewColumn Width="{Binding ElementName=Col2, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding Info.TypeDesc}"
|
||||
Header="类型" />
|
||||
<!--<GridViewColumn Width="{Binding ElementName=Col3, Path=ActualWidth}" Header="操作">
|
||||
~1~<GridViewColumn Width="{Binding ElementName=Col3, Path=ActualWidth}" Header="操作">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -95,7 +124,7 @@
|
||||
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>-->
|
||||
</GridViewColumn>@1@
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<ListBox.ContextMenu>
|
||||
@@ -103,6 +132,9 @@
|
||||
<MenuItem Command="{Binding StartCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
||||
Header="执行任务" />
|
||||
<MenuItem Command="{Binding RefreshCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
||||
Header="刷新" />
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
<ListView.Style>
|
||||
@@ -111,6 +143,6 @@
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</Style>
|
||||
</ListView.Style>
|
||||
</ui:ListView>
|
||||
</ui:ListView>-->
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -19,68 +19,41 @@
|
||||
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<!--<Grid Margin="42,16,42,12">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ui:TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="0,0,0,10"
|
||||
FontTypography="BodyStrong"
|
||||
Text="独立自动化任务设置与启动" />
|
||||
<Grid Grid.Row="1">
|
||||
<ui:Button
|
||||
Margin="0,0,8,0"
|
||||
Width="120"
|
||||
Height="32"
|
||||
Content="启动当前任务"
|
||||
Appearance="Primary"
|
||||
Command="{Binding AddTaskCommand}" />
|
||||
</Grid>
|
||||
<TabControl Margin="0,8,0,0" Grid.Row="2">
|
||||
<TabItem>
|
||||
<TabItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ui:SymbolIcon Margin="0,0,6,0" Symbol="PlayingCards20" />
|
||||
<TextBlock Text="自动七圣召唤" />
|
||||
</StackPanel>
|
||||
</TabItem.Header>
|
||||
<Grid>
|
||||
<TextBlock Margin="12" Text="World" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem IsSelected="True">
|
||||
<TabItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ui:SymbolIcon Margin="0,0,6,0" Symbol="StoreMicrosoft16" />
|
||||
<TextBlock Text="自动伐木" />
|
||||
</StackPanel>
|
||||
</TabItem.Header>
|
||||
<Grid>
|
||||
<TextBlock Margin="12" Text="Is a lie." />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem IsSelected="True">
|
||||
<TabItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ui:SymbolIcon Margin="0,0,6,0" Symbol="StoreMicrosoft16" />
|
||||
<TextBlock Text="自动前进" />
|
||||
</StackPanel>
|
||||
</TabItem.Header>
|
||||
<Grid>
|
||||
<TextBlock Margin="12" Text="Is a lie." />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>-->
|
||||
|
||||
|
||||
<StackPanel Margin="42,16,42,12">
|
||||
<ui:TextBlock Margin="0,0,0,8"
|
||||
FontTypography="BodyStrong"
|
||||
Text="独立任务设置" />
|
||||
<!-- 停止任务 -->
|
||||
<ui:CardControl Margin="0,0,0,12"
|
||||
Icon="{ui:SymbolIcon DismissCircle24}"
|
||||
Visibility="{markup:Converter Value={x:Static helpers:RuntimeHelper.IsDebuggerAttached},
|
||||
Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<ui:CardControl.Header>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="停止任务"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
TextWrapping="Wrap">
|
||||
停止下方独立任务的运行
|
||||
</ui:TextBlock>
|
||||
</Grid>
|
||||
</ui:CardControl.Header>
|
||||
<ui:Button Margin="0,0,36,0"
|
||||
Command="{Binding StopSoloTaskCommand}"
|
||||
Content="停止任务"
|
||||
Icon="{ui:SymbolIcon Dismiss24}" />
|
||||
</ui:CardControl>
|
||||
|
||||
|
||||
<ui:CardExpander Margin="0,0,0,12" ContentPadding="0">
|
||||
<ui:CardExpander.Icon>
|
||||
<ui:FontIcon Glyph="" Style="{StaticResource FaFontIconStyle}" />
|
||||
@@ -663,6 +636,31 @@
|
||||
Margin="0,0,36,0"
|
||||
Text="{Binding Config.AutoDomainConfig.LeftRightMoveTimes, 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="自动吃药"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="请先装备 “便携营养袋” ,在红血时候后自动按Z键吃药"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.AutoDomainConfig.AutoEat, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
||||
@@ -598,9 +598,7 @@
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
TextWrapping="Wrap">
|
||||
基于 YOLOv8 的鱼类识别。帮助进行AI训练 Q群:<Hyperlink Command="{Binding GoToQGroupUrlCommand}" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
|
||||
863012276
|
||||
</Hyperlink>
|
||||
基于 YOLOv8 的鱼类识别
|
||||
</ui:TextBlock>
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
|
||||
@@ -84,4 +84,4 @@ namespace BetterGenshinImpact.View
|
||||
public string Name { get; set; }
|
||||
public IntPtr Handle { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
FontFamily="{DynamicResource TextThemeFontFamily}"
|
||||
Tag="JsonMonoDialog"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
mc:Ignorable="d">
|
||||
<Window.Resources>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using BetterGenshinImpact.ViewModel.Windows;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.View.Windows;
|
||||
@@ -19,28 +17,6 @@ public partial class JsonMonoDialog : FluentWindow
|
||||
JsonCodeBox.TextChanged += (_, _) => ViewModel.JsonText = JsonCodeBox.Text;
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
TryApplySystemBackdrop();
|
||||
}
|
||||
|
||||
private void TryApplySystemBackdrop()
|
||||
{
|
||||
if (WindowBackdrop.IsSupported(WindowBackdropType.Mica))
|
||||
{
|
||||
Background = new SolidColorBrush(Colors.Transparent);
|
||||
WindowBackdrop.ApplyBackdrop(this, WindowBackdropType.Mica);
|
||||
return;
|
||||
}
|
||||
|
||||
if (WindowBackdrop.IsSupported(WindowBackdropType.Tabbed))
|
||||
{
|
||||
Background = new SolidColorBrush(Colors.Transparent);
|
||||
WindowBackdrop.ApplyBackdrop(this, WindowBackdropType.Tabbed);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Show(string path)
|
||||
{
|
||||
JsonMonoDialog dialog = new(path)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
FontFamily="{DynamicResource TextThemeFontFamily}"
|
||||
ResizeMode="CanMinimize"
|
||||
Topmost="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
WindowStyle="SingleBorderWindow"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -70,4 +70,16 @@ public partial class CommonSettingsPageViewModel : ObservableObject, INavigation
|
||||
|
||||
Process.Start("explorer.exe", path);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnGoToLogFolder()
|
||||
{
|
||||
var path = Global.Absolute(@"log");
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
Process.Start("explorer.exe", path);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,8 @@ using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using Vanara.PInvoke;
|
||||
using static Vanara.PInvoke.User32;
|
||||
using HotKeySettingModel = BetterGenshinImpact.Model.HotKeySettingModel;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace BetterGenshinImpact.ViewModel.Pages;
|
||||
|
||||
@@ -279,7 +281,10 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
nameof(Config.HotKeyConfig.AutoGeniusInvokationHotkey),
|
||||
Config.HotKeyConfig.AutoGeniusInvokationHotkey,
|
||||
Config.HotKeyConfig.AutoGeniusInvokationHotkeyType,
|
||||
(_, _) => { _taskSettingsPageViewModel.OnSwitchAutoGeniusInvokation(); }
|
||||
(_, _) =>
|
||||
{
|
||||
SwitchSoloTask(_taskSettingsPageViewModel.SwitchAutoGeniusInvokationCommand);
|
||||
}
|
||||
));
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
@@ -287,7 +292,10 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
nameof(Config.HotKeyConfig.AutoWoodHotkey),
|
||||
Config.HotKeyConfig.AutoWoodHotkey,
|
||||
Config.HotKeyConfig.AutoWoodHotkeyType,
|
||||
(_, _) => { _taskSettingsPageViewModel.OnSwitchAutoWood(); }
|
||||
(_, _) =>
|
||||
{
|
||||
SwitchSoloTask(_taskSettingsPageViewModel.SwitchAutoWoodCommand);
|
||||
}
|
||||
));
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
@@ -295,7 +303,10 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
nameof(Config.HotKeyConfig.AutoFightHotkey),
|
||||
Config.HotKeyConfig.AutoFightHotkey,
|
||||
Config.HotKeyConfig.AutoFightHotkeyType,
|
||||
(_, _) => { _taskSettingsPageViewModel.OnSwitchAutoFight(); }
|
||||
(_, _) =>
|
||||
{
|
||||
SwitchSoloTask(_taskSettingsPageViewModel.SwitchAutoFightCommand);
|
||||
}
|
||||
));
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
@@ -303,7 +314,10 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
nameof(Config.HotKeyConfig.AutoDomainHotkey),
|
||||
Config.HotKeyConfig.AutoDomainHotkey,
|
||||
Config.HotKeyConfig.AutoDomainHotkeyType,
|
||||
(_, _) => { _taskSettingsPageViewModel.OnSwitchAutoDomain(); }
|
||||
(_, _) =>
|
||||
{
|
||||
SwitchSoloTask(_taskSettingsPageViewModel.SwitchAutoDomainCommand);
|
||||
}
|
||||
));
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
@@ -382,9 +396,9 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
"(开发)获取当前大地图中心点位置",
|
||||
nameof(Config.HotKeyConfig.Test1Hotkey),
|
||||
Config.HotKeyConfig.GetBigMapPosHotkey,
|
||||
Config.HotKeyConfig.GetBigMapPosHotkeyType,
|
||||
nameof(Config.HotKeyConfig.RecBigMapPosHotkey),
|
||||
Config.HotKeyConfig.RecBigMapPosHotkey,
|
||||
Config.HotKeyConfig.RecBigMapPosHotkeyType,
|
||||
(_, _) =>
|
||||
{
|
||||
var p = new TpTask(new CancellationTokenSource()).GetPositionFromBigMap();
|
||||
@@ -392,7 +406,7 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
}
|
||||
));
|
||||
|
||||
var pathRecorder = new PathRecorder();
|
||||
var pathRecorder = PathRecorder.Instance;
|
||||
var pathRecording = false;
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
@@ -435,32 +449,40 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
nameof(Config.HotKeyConfig.AutoMusicGameHotkey),
|
||||
Config.HotKeyConfig.AutoMusicGameHotkey,
|
||||
Config.HotKeyConfig.AutoMusicGameHotkeyType,
|
||||
(_, _) => { _taskSettingsPageViewModel.OnSwitchAutoMusicGame(); }
|
||||
));
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
"(测试)启动/停止自动追踪",
|
||||
nameof(Config.HotKeyConfig.AutoTrackHotkey),
|
||||
Config.HotKeyConfig.AutoTrackHotkey,
|
||||
Config.HotKeyConfig.AutoTrackHotkeyType,
|
||||
(_, _) => { _taskSettingsPageViewModel.OnSwitchAutoTrack(); }
|
||||
));
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
"(测试)地图路线录制",
|
||||
nameof(Config.HotKeyConfig.MapPosRecordHotkey),
|
||||
Config.HotKeyConfig.MapPosRecordHotkey,
|
||||
Config.HotKeyConfig.MapPosRecordHotkeyType,
|
||||
(_, _) =>
|
||||
{
|
||||
PathPointRecorder.Instance.Switch();
|
||||
}));
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
"(测试)自动寻路",
|
||||
nameof(Config.HotKeyConfig.AutoTrackPathHotkey),
|
||||
Config.HotKeyConfig.AutoTrackPathHotkey,
|
||||
Config.HotKeyConfig.AutoTrackPathHotkeyType,
|
||||
(_, _) => { _taskSettingsPageViewModel.OnSwitchAutoTrackPath(); }
|
||||
SwitchSoloTask(_taskSettingsPageViewModel.SwitchAutoMusicGameCommand);
|
||||
}
|
||||
));
|
||||
|
||||
// HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
// "(测试)启动/停止自动追踪",
|
||||
// nameof(Config.HotKeyConfig.AutoTrackHotkey),
|
||||
// Config.HotKeyConfig.AutoTrackHotkey,
|
||||
// Config.HotKeyConfig.AutoTrackHotkeyType,
|
||||
// (_, _) =>
|
||||
// {
|
||||
// // _taskSettingsPageViewModel.OnSwitchAutoTrack();
|
||||
// }
|
||||
// ));
|
||||
// HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
// "(测试)地图路线录制",
|
||||
// nameof(Config.HotKeyConfig.MapPosRecordHotkey),
|
||||
// Config.HotKeyConfig.MapPosRecordHotkey,
|
||||
// Config.HotKeyConfig.MapPosRecordHotkeyType,
|
||||
// (_, _) =>
|
||||
// {
|
||||
// PathPointRecorder.Instance.Switch();
|
||||
// }));
|
||||
// HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
// "(测试)自动寻路",
|
||||
// nameof(Config.HotKeyConfig.AutoTrackPathHotkey),
|
||||
// Config.HotKeyConfig.AutoTrackPathHotkey,
|
||||
// Config.HotKeyConfig.AutoTrackPathHotkeyType,
|
||||
// (_, _) =>
|
||||
// {
|
||||
// // _taskSettingsPageViewModel.OnSwitchAutoTrackPath();
|
||||
// }
|
||||
// ));
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
"(测试)测试",
|
||||
nameof(Config.HotKeyConfig.Test1Hotkey),
|
||||
@@ -468,11 +490,10 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
Config.HotKeyConfig.Test1HotkeyType,
|
||||
(_, _) =>
|
||||
{
|
||||
var p = new TpTask(new CancellationTokenSource()).GetPositionFromBigMap();
|
||||
_logger.LogInformation("大地图位置:{Position}", p);
|
||||
NahidaCollectHandler handler = new NahidaCollectHandler();
|
||||
handler.RunAsync(new CancellationTokenSource());
|
||||
}
|
||||
));
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
"(测试)测试2",
|
||||
nameof(Config.HotKeyConfig.Test2Hotkey),
|
||||
@@ -502,6 +523,18 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchSoloTask(IAsyncRelayCommand asyncRelayCommand)
|
||||
{
|
||||
if (asyncRelayCommand.IsRunning)
|
||||
{
|
||||
CancellationContext.Instance.Cancel();
|
||||
}
|
||||
else
|
||||
{
|
||||
asyncRelayCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
private string ToChinese(bool enabled)
|
||||
{
|
||||
return enabled.ToChinese();
|
||||
|
||||
@@ -10,9 +10,11 @@ using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Script.Group;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Controls;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
|
||||
namespace BetterGenshinImpact.ViewModel.Pages;
|
||||
|
||||
@@ -80,11 +82,7 @@ public partial class JsListViewModel : ObservableObject, INavigationAware, IView
|
||||
[RelayCommand]
|
||||
public void OnOpenScriptProjectFolder(ScriptProject? item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Process.Start("explorer.exe", item.ProjectPath);
|
||||
Process.Start("explorer.exe", item == null ? scriptPath : item.ProjectPath);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -94,6 +92,12 @@ public partial class JsListViewModel : ObservableObject, INavigationAware, IView
|
||||
{
|
||||
return;
|
||||
}
|
||||
await _scriptService.RunMultiJs([item.FolderName]);
|
||||
await _scriptService.RunMulti([new ScriptGroupProject(item)]);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnRefresh(ScriptProject? item)
|
||||
{
|
||||
InitScriptListViewData();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,16 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.Core.Script.Group;
|
||||
using BetterGenshinImpact.Core.Script.Project;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.Model;
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using BetterGenshinImpact.View.Windows;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Wpf.Ui.Controls;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.ViewModel.Pages;
|
||||
|
||||
@@ -28,43 +20,56 @@ public partial class MapPathingViewModel(IScriptService scriptService) : Observa
|
||||
public static readonly string PathJsonPath = Global.Absolute(@"User\AutoPathing");
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<PathingTask> _pathItems = [];
|
||||
private TreeCollection<PathingTaskTreeObject> _pathItems = Load();
|
||||
|
||||
[ObservableProperty]
|
||||
private FileTreeModel<PathingTask> _fileItems = new(PathJsonPath);
|
||||
|
||||
private MapViewer? _mapViewer;
|
||||
|
||||
private void InitScriptListViewData()
|
||||
{
|
||||
_pathItems.Clear();
|
||||
var fileInfos = LoadScriptFolder(PathJsonPath);
|
||||
foreach (var f in fileInfos)
|
||||
{
|
||||
try
|
||||
{
|
||||
_pathItems.Add(PathingTask.BuildFromFilePath(f.FullName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Toast.Warning($"地图追踪任务 {f.Name} 载入失败:{e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
_pathItems.Root.Name = PathJsonPath;
|
||||
_pathItems.Root.IsFolder = true;
|
||||
LoadFolderRecursive(PathJsonPath, _pathItems.Root);
|
||||
}
|
||||
|
||||
private IEnumerable<FileInfo> LoadScriptFolder(string folder)
|
||||
private static TreeCollection<PathingTaskTreeObject> Load()
|
||||
{
|
||||
if (!Directory.Exists(folder))
|
||||
TreeCollection<PathingTaskTreeObject> tree = [];
|
||||
tree.Root.Name = PathJsonPath;
|
||||
tree.Root.IsFolder = true;
|
||||
LoadFolderRecursive(PathJsonPath, tree.Root);
|
||||
return tree;
|
||||
}
|
||||
|
||||
private static void LoadFolderRecursive(string folder, PathingTaskTreeObject parent)
|
||||
{
|
||||
var directoryInfo = new DirectoryInfo(folder);
|
||||
foreach (var dir in directoryInfo.GetDirectories())
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
var dirNode = new PathingTaskTreeObject { Name = dir.Name, IsFolder = true };
|
||||
parent.Children.Add(dirNode);
|
||||
LoadFolderRecursive(dir.FullName, dirNode);
|
||||
}
|
||||
|
||||
var files = Directory.GetFiles(folder, "*.*",
|
||||
SearchOption.AllDirectories);
|
||||
|
||||
return files.Select(file => new FileInfo(file)).ToList();
|
||||
foreach (var file in directoryInfo.GetFiles())
|
||||
{
|
||||
var fileNode = new PathingTaskTreeObject
|
||||
{
|
||||
Name = file.Name,
|
||||
IsFolder = false,
|
||||
Task = PathingTask.BuildFromFilePath(file.FullName)
|
||||
};
|
||||
parent.Children.Add(fileNode);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnNavigatedTo()
|
||||
{
|
||||
InitScriptListViewData();
|
||||
// InitScriptListViewData();
|
||||
}
|
||||
|
||||
public void OnNavigatedFrom()
|
||||
@@ -99,13 +104,6 @@ public partial class MapPathingViewModel(IScriptService scriptService) : Observa
|
||||
return;
|
||||
}
|
||||
|
||||
// new TaskRunner(DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty)
|
||||
// .FireAndForget(async () =>
|
||||
// {
|
||||
// TaskTriggerDispatcher.Instance().AddTrigger("AutoPick", null);
|
||||
// await new PathExecutor(CancellationContext.Instance.Cts).Pathing(item);
|
||||
// });
|
||||
|
||||
var fileInfo = new FileInfo(item.FullPath);
|
||||
var project = ScriptGroupProject.BuildPathingProject(fileInfo.Name, fileInfo.DirectoryName!);
|
||||
await scriptService.RunMulti([project]);
|
||||
@@ -114,8 +112,22 @@ public partial class MapPathingViewModel(IScriptService scriptService) : Observa
|
||||
[RelayCommand]
|
||||
public void OnOpenMapViewer()
|
||||
{
|
||||
_mapViewer ??= new MapViewer();
|
||||
_mapViewer.Show();
|
||||
if (_mapViewer == null || !_mapViewer.IsVisible)
|
||||
{
|
||||
_mapViewer = new MapViewer();
|
||||
_mapViewer.Closed += (s, e) => _mapViewer = null;
|
||||
_mapViewer.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapViewer.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnOpenMapEditor()
|
||||
{
|
||||
PathRecorder.Instance.OpenEditorInWebView();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -123,4 +135,10 @@ public partial class MapPathingViewModel(IScriptService scriptService) : Observa
|
||||
{
|
||||
Process.Start(new ProcessStartInfo("https://bgi.huiyadan.com/autos/pathing.html") { UseShellExecute = true });
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnRefresh(object? item)
|
||||
{
|
||||
_fileItems = new(PathJsonPath);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ using System.Windows.Controls;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Controls;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
using StackPanel = Wpf.Ui.Controls.StackPanel;
|
||||
|
||||
namespace BetterGenshinImpact.ViewModel.Pages;
|
||||
|
||||
@@ -233,7 +234,7 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
if (grandChild is CheckBox checkBox && checkBox.IsChecked == true)
|
||||
{
|
||||
var fileInfo = (FileInfo)checkBox.Tag;
|
||||
SelectedScriptGroup?.Projects.Add(ScriptGroupProject.BuildPathingProject(fileInfo.Name, fileInfo.DirectoryName));
|
||||
SelectedScriptGroup?.Projects.Add(ScriptGroupProject.BuildPathingProject(fileInfo.Name, fileInfo.Directory!.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoDomain;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
@@ -18,6 +19,7 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.System;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Controls;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
@@ -82,6 +84,13 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
return strategyList;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task OnStopSoloTask()
|
||||
{
|
||||
CancellationContext.Instance.Cancel();
|
||||
await Task.Delay(800);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void OnStrategyDropDownOpened(string type)
|
||||
{
|
||||
@@ -112,46 +121,26 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnSwitchAutoGeniusInvokation()
|
||||
public async Task OnSwitchAutoGeniusInvokation()
|
||||
{
|
||||
try
|
||||
if (string.IsNullOrEmpty(Config.AutoGeniusInvokationConfig.StrategyName))
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (SwitchAutoGeniusInvokationButtonText == "启动")
|
||||
{
|
||||
if (string.IsNullOrEmpty(Config.AutoGeniusInvokationConfig.StrategyName))
|
||||
{
|
||||
Toast.Warning("请先选择策略");
|
||||
return;
|
||||
}
|
||||
|
||||
var path = Global.Absolute(@"User\AutoGeniusInvokation\" + Config.AutoGeniusInvokationConfig.StrategyName + ".txt");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Toast.Error("策略文件不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
var content = File.ReadAllText(path);
|
||||
_cts?.Cancel();
|
||||
_cts = new CancellationTokenSource();
|
||||
var param = new GeniusInvokationTaskParam(_cts, content);
|
||||
_taskDispatcher.StartIndependentTask(IndependentTaskEnum.AutoGeniusInvokation, param);
|
||||
SwitchAutoGeniusInvokationButtonText = "停止";
|
||||
}
|
||||
else
|
||||
{
|
||||
_cts?.Cancel();
|
||||
SwitchAutoGeniusInvokationButtonText = "启动";
|
||||
}
|
||||
}
|
||||
Toast.Warning("请先选择策略");
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
var path = Global.Absolute(@"User\AutoGeniusInvokation\" + Config.AutoGeniusInvokationConfig.StrategyName + ".txt");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
MessageBox.Error(ex.Message);
|
||||
Toast.Error("策略文件不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
var content = await File.ReadAllTextAsync(path);
|
||||
|
||||
await new TaskRunner(DispatcherTimerOperationEnum.UseSelfCaptureImage)
|
||||
.RunSoloTaskAsync(new AutoGeniusInvokationTask(new GeniusInvokationTaskParam(content)));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -161,31 +150,10 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnSwitchAutoWood()
|
||||
public async Task OnSwitchAutoWood()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (SwitchAutoWoodButtonText == "启动")
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_cts = new CancellationTokenSource();
|
||||
var param = new WoodTaskParam(_cts, AutoWoodRoundNum, AutoWoodDailyMaxCount);
|
||||
_taskDispatcher.StartIndependentTask(IndependentTaskEnum.AutoWood, param);
|
||||
SwitchAutoWoodButtonText = "停止";
|
||||
}
|
||||
else
|
||||
{
|
||||
_cts?.Cancel();
|
||||
SwitchAutoWoodButtonText = "启动";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Error(ex.Message);
|
||||
}
|
||||
await new TaskRunner(DispatcherTimerOperationEnum.UseSelfCaptureImage)
|
||||
.RunSoloTaskAsync(new AutoWoodTask(new WoodTaskParam(AutoWoodRoundNum, AutoWoodDailyMaxCount)));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -195,63 +163,14 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnSwitchAutoFight()
|
||||
public async Task OnSwitchAutoFight()
|
||||
{
|
||||
try
|
||||
if (GetFightStrategy(out var path))
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (SwitchAutoFightButtonText == "启动")
|
||||
{
|
||||
var path = Global.Absolute(@"User\AutoFight\" + Config.AutoFightConfig.StrategyName + ".txt");
|
||||
if ("根据队伍自动选择".Equals(Config.AutoFightConfig.StrategyName))
|
||||
{
|
||||
path = Global.Absolute(@"User\AutoFight\");
|
||||
}
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
{
|
||||
Toast.Error("战斗策略文件不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
_cts?.Cancel();
|
||||
_cts = new CancellationTokenSource();
|
||||
var param = new AutoFightParam(_cts, path);
|
||||
_taskDispatcher.StartIndependentTask(IndependentTaskEnum.AutoFight, param);
|
||||
SwitchAutoFightButtonText = "停止";
|
||||
}
|
||||
else
|
||||
{
|
||||
_cts?.Cancel();
|
||||
SwitchAutoFightButtonText = "启动";
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
private string? ReadFightStrategy(string strategyName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(strategyName))
|
||||
{
|
||||
Toast.Warning("请先选择战斗策略");
|
||||
return null;
|
||||
}
|
||||
|
||||
var path = Global.Absolute(@"User\AutoFight\" + strategyName + ".txt");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Toast.Error("战斗策略文件不存在");
|
||||
return null;
|
||||
}
|
||||
|
||||
var content = File.ReadAllText(path);
|
||||
return content;
|
||||
await new TaskRunner(DispatcherTimerOperationEnum.UseCacheImageWithTrigger)
|
||||
.RunSoloTaskAsync(new AutoFightTask(new AutoFightParam(path)));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -261,42 +180,30 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnSwitchAutoDomain()
|
||||
public async Task OnSwitchAutoDomain()
|
||||
{
|
||||
try
|
||||
if (GetFightStrategy(out var path))
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (SwitchAutoDomainButtonText == "启动")
|
||||
{
|
||||
var path = Global.Absolute(@"User\AutoFight\" + Config.AutoFightConfig.StrategyName + ".txt");
|
||||
if ("根据队伍自动选择".Equals(Config.AutoFightConfig.StrategyName))
|
||||
{
|
||||
path = Global.Absolute(@"User\AutoFight\");
|
||||
}
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
{
|
||||
Toast.Error("战斗策略文件不存在");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
await new TaskRunner(DispatcherTimerOperationEnum.UseCacheImage)
|
||||
.RunSoloTaskAsync(new AutoDomainTask(new AutoDomainParam(AutoDomainRoundNum, path)));
|
||||
}
|
||||
|
||||
_cts?.Cancel();
|
||||
_cts = new CancellationTokenSource();
|
||||
var param = new AutoDomainParam(_cts, AutoDomainRoundNum, path);
|
||||
_taskDispatcher.StartIndependentTask(IndependentTaskEnum.AutoDomain, param);
|
||||
SwitchAutoDomainButtonText = "停止";
|
||||
}
|
||||
else
|
||||
{
|
||||
_cts?.Cancel();
|
||||
SwitchAutoDomainButtonText = "启动";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
private bool GetFightStrategy(out string path)
|
||||
{
|
||||
path = Global.Absolute(@"User\AutoFight\" + Config.AutoFightConfig.StrategyName + ".txt");
|
||||
if ("根据队伍自动选择".Equals(Config.AutoFightConfig.StrategyName))
|
||||
{
|
||||
MessageBox.Error(ex.Message);
|
||||
path = Global.Absolute(@"User\AutoFight\");
|
||||
}
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
{
|
||||
Toast.Error("战斗策略文件不存在");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -311,32 +218,33 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
Process.Start("explorer.exe", Global.Absolute(@"User\AutoFight\"));
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
[RelayCommand]
|
||||
public void OnSwitchAutoTrack()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (SwitchAutoTrackButtonText == "启动")
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_cts = new CancellationTokenSource();
|
||||
var param = new AutoTrackParam(_cts);
|
||||
_taskDispatcher.StartIndependentTask(IndependentTaskEnum.AutoTrack, param);
|
||||
SwitchAutoTrackButtonText = "停止";
|
||||
}
|
||||
else
|
||||
{
|
||||
_cts?.Cancel();
|
||||
SwitchAutoTrackButtonText = "启动";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Error(ex.Message);
|
||||
}
|
||||
// try
|
||||
// {
|
||||
// lock (_locker)
|
||||
// {
|
||||
// if (SwitchAutoTrackButtonText == "启动")
|
||||
// {
|
||||
// _cts?.Cancel();
|
||||
// _cts = new CancellationTokenSource();
|
||||
// var param = new AutoTrackParam(_cts);
|
||||
// _taskDispatcher.StartIndependentTask(IndependentTaskEnum.AutoTrack, param);
|
||||
// SwitchAutoTrackButtonText = "停止";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _cts?.Cancel();
|
||||
// SwitchAutoTrackButtonText = "启动";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// MessageBox.Error(ex.Message);
|
||||
// }
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -345,32 +253,33 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
await Launcher.LaunchUriAsync(new Uri("https://bgi.huiyadan.com/feats/track.html"));
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
[RelayCommand]
|
||||
public void OnSwitchAutoTrackPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (SwitchAutoTrackPathButtonText == "启动")
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_cts = new CancellationTokenSource();
|
||||
var param = new AutoTrackPathParam(_cts);
|
||||
_taskDispatcher.StartIndependentTask(IndependentTaskEnum.AutoTrackPath, param);
|
||||
SwitchAutoTrackPathButtonText = "停止";
|
||||
}
|
||||
else
|
||||
{
|
||||
_cts?.Cancel();
|
||||
SwitchAutoTrackPathButtonText = "启动";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Error(ex.Message);
|
||||
}
|
||||
// try
|
||||
// {
|
||||
// lock (_locker)
|
||||
// {
|
||||
// if (SwitchAutoTrackPathButtonText == "启动")
|
||||
// {
|
||||
// _cts?.Cancel();
|
||||
// _cts = new CancellationTokenSource();
|
||||
// var param = new AutoTrackPathParam(_cts);
|
||||
// _taskDispatcher.StartIndependentTask(IndependentTaskEnum.AutoTrackPath, param);
|
||||
// SwitchAutoTrackPathButtonText = "停止";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _cts?.Cancel();
|
||||
// SwitchAutoTrackPathButtonText = "启动";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// MessageBox.Error(ex.Message);
|
||||
// }
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -380,31 +289,10 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnSwitchAutoMusicGame()
|
||||
public async Task OnSwitchAutoMusicGame()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (SwitchAutoMusicGameButtonText == "启动")
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_cts = new CancellationTokenSource();
|
||||
var param = new AutoMusicGameParam(_cts);
|
||||
_taskDispatcher.StartIndependentTask(IndependentTaskEnum.AutoMusicGame, param);
|
||||
SwitchAutoMusicGameButtonText = "停止";
|
||||
}
|
||||
else
|
||||
{
|
||||
_cts?.Cancel();
|
||||
SwitchAutoMusicGameButtonText = "启动";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Error(ex.Message);
|
||||
}
|
||||
await new TaskRunner(DispatcherTimerOperationEnum.UseSelfCaptureImage)
|
||||
.RunSoloTaskAsync(new AutoMusicGameTask(new AutoMusicGameParam()));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -412,59 +300,4 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
{
|
||||
await Launcher.LaunchUriAsync(new Uri("https://bgi.huiyadan.com/feats/music.html"));
|
||||
}
|
||||
|
||||
public static void SetSwitchAutoTrackButtonText(bool running)
|
||||
{
|
||||
var instance = App.GetService<TaskSettingsPageViewModel>();
|
||||
if (instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
instance.SwitchAutoTrackButtonText = running ? "停止" : "启动";
|
||||
}
|
||||
|
||||
public static void SetSwitchAutoGeniusInvokationButtonText(bool running)
|
||||
{
|
||||
var instance = App.GetService<TaskSettingsPageViewModel>();
|
||||
if (instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
instance.SwitchAutoGeniusInvokationButtonText = running ? "停止" : "启动";
|
||||
}
|
||||
|
||||
public static void SetSwitchAutoWoodButtonText(bool running)
|
||||
{
|
||||
var instance = App.GetService<TaskSettingsPageViewModel>();
|
||||
if (instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
instance.SwitchAutoWoodButtonText = running ? "停止" : "启动";
|
||||
}
|
||||
|
||||
public static void SetSwitchAutoDomainButtonText(bool running)
|
||||
{
|
||||
var instance = App.GetService<TaskSettingsPageViewModel>();
|
||||
if (instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
instance.SwitchAutoDomainButtonText = running ? "停止" : "启动";
|
||||
}
|
||||
|
||||
public static void SetSwitchAutoFightButtonText(bool running)
|
||||
{
|
||||
var instance = App.GetService<TaskSettingsPageViewModel>();
|
||||
if (instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
instance.SwitchAutoFightButtonText = running ? "停止" : "启动";
|
||||
}
|
||||
}
|
||||
+5
-10
@@ -6,16 +6,11 @@ mkdir dist\BetterGI
|
||||
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do set "path=%path%;%%i\MSBuild\Current\Bin;%%i\Common7\IDE"
|
||||
|
||||
@echo [prepare version]
|
||||
cd /d ..\BetterGenshinImpact\Core\Config
|
||||
set "script=Get-Content 'Global.cs' ^| Select-String -Pattern 'Version.*\"(.*)\"' ^| ForEach-Object { $_.Matches.Groups[1].Value }"
|
||||
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoLogo -NoProfile -Command ^"%script%^"`) do set version=%%i
|
||||
|
||||
echo currnet version is %version%
|
||||
|
||||
if "%b%"=="" (
|
||||
set "b=%version%"
|
||||
)
|
||||
cd /d ..\BetterGenshinImpact
|
||||
set "script=Get-Content 'BetterGenshinImpact.csproj' | Select-String -Pattern 'AssemblyVersion\>(.*)\<\/AssemblyVersion' | ForEach-Object { $_.Matches.Groups[1].Value }"
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoLogo -NoProfile -Command "%script%"`) do set version=%%i
|
||||
echo current version is %version%
|
||||
if "%b%"=="" ( set "b=%version%" )
|
||||
|
||||
set "tmpfolder=%~dp0dist\BetterGI"
|
||||
set "archiveFile=BetterGI_v%b%.7z"
|
||||
|
||||
@@ -6,16 +6,11 @@ mkdir dist\BetterGI
|
||||
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do set "path=%path%;%%i\MSBuild\Current\Bin;%%i\Common7\IDE"
|
||||
|
||||
@echo [prepare version]
|
||||
cd /d ..\BetterGenshinImpact\Core\Config
|
||||
set "script=Get-Content 'Global.cs' ^| Select-String -Pattern 'Version.*\"(.*)\"' ^| ForEach-Object { $_.Matches.Groups[1].Value }"
|
||||
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoLogo -NoProfile -Command ^"%script%^"`) do set version=%%i
|
||||
|
||||
echo currnet version is %version%
|
||||
|
||||
if "%b%"=="" (
|
||||
set "b=%version%"
|
||||
)
|
||||
cd /d ..\BetterGenshinImpact
|
||||
set "script=Get-Content 'BetterGenshinImpact.csproj' | Select-String -Pattern 'AssemblyVersion\>(.*)\<\/AssemblyVersion' | ForEach-Object { $_.Matches.Groups[1].Value }"
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoLogo -NoProfile -Command "%script%"`) do set version=%%i
|
||||
echo current version is %version%
|
||||
if "%b%"=="" ( set "b=%version%" )
|
||||
|
||||
set "tmpfolder=%~dp0dist\BetterGI"
|
||||
set "archiveFile=BetterGI_v%b%.7z"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
<br/>
|
||||
<a href="https://bgi.huiyadan.com/">BetterGI</a>
|
||||
</h1>
|
||||
<h5>🎁 𝑴𝒂𝒌𝒆 𝑮𝒆𝒏𝒔𝒉𝒊𝒏 𝑰𝒎𝒑𝒂𝒄𝒕 𝑮𝒓𝒆𝒂𝒕 𝑨𝒈𝒂𝒊𝒏 🥂</h5>
|
||||
<a href="https://trendshift.io/repositories/5269" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5269" alt="babalae%2Fbetter-genshin-impact | Trendshift" style="width: 200px; height: 46px;" width="250" height="46"/></a>
|
||||
</div>
|
||||
|
||||
@@ -44,7 +43,7 @@ BetterGI · 更好的原神, 一个基于计算机视觉技术,意图让原
|
||||
|
||||
## 截图
|
||||
|
||||
<img src="https://img.alicdn.com/imgextra/i2/2042484851/O1CN016wk5ZC1lhoEMzz04F_!!2042484851.gif"/>
|
||||
<img src="https://img.alicdn.com/imgextra/i3/2042484851/O1CN01yzhTp81lhoJ6DaG5K_!!2042484851.gif"/>
|
||||
|
||||
|
||||
## 下载
|
||||
@@ -54,7 +53,7 @@ BetterGI · 更好的原神, 一个基于计算机视觉技术,意图让原
|
||||
>
|
||||
> 不知道下载哪个?第一次使用?请看:[快速上手](https://bgi.huiyadan.com/quickstart.html) , 遇到问题请先看:[常见问题](https://bgi.huiyadan.com/faq.html)
|
||||
|
||||
最新编译版本可以从自动构建中获取: [](https://ci.appveyor.com/project/huiyadanli/better-genshin-impact/build/artifacts)
|
||||
最新编译版本(无地图特征数据)可以从自动构建中获取: [](https://ci.appveyor.com/project/huiyadanli/better-genshin-impact/build/artifacts)
|
||||
|
||||
## 使用方法
|
||||
由于图像识别比较吃性能,低配置电脑可能无法正常使用部分功能。
|
||||
|
||||
Reference in new issue
Block a user