Merge branch 'babalae:main' into main

This commit is contained in:
mfkvfhpdx 2024-12-29 21:01:27 +08:00 committed by GitHub
commit f4f9f22977
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 638 additions and 119 deletions

View File

@ -170,7 +170,7 @@ public class MouseKeyMonitor
private void GlobalHookMouseWheelExt(object? sender, MouseEventExtArgs e)
{
Debug.WriteLine("MouseMove: {0}; \t Location: {1};\t Delta: {2};\t System Timestamp: {3}", e.Button, e.Location, e.Delta, e.Timestamp);
// Debug.WriteLine("MouseMove: {0}; \t Location: {1};\t Delta: {2};\t System Timestamp: {3}", e.Button, e.Location, e.Delta, e.Timestamp);
GlobalKeyMouseRecord.Instance.GlobalHookMouseWheel(e);
}

View File

@ -60,7 +60,7 @@ public class KeyMouseMacroPlayer
var timeToWait = e.Time - (Kernel32.GetTickCount() - startTime);
if (timeToWait < 0)
{
TaskControl.Logger.LogWarning("无法原速重放事件{Event},落后{TimeToWait}ms", e.Type.ToString(), -timeToWait);
TaskControl.Logger.LogDebug("无法原速重放事件{Event},落后{TimeToWait}ms", e.Type.ToString(), (-timeToWait).ToString("F0"));
}
else
{

View File

@ -35,6 +35,11 @@ public class KeyMouseRecorder
public string ToJsonMacro()
{
// MacroEvents 需要以实际时间进行排序
MacroEvents.Sort((a, b) => a.Time.CompareTo(b.Time));
// 删除为负数的时间
MacroEvents.RemoveAll(m => m.Time < 0);
var rect = TaskContext.Instance().SystemInfo.CaptureAreaRect;
// 合并鼠标移动事件
var mergedMacroEvents = new List<MacroEvent>();
@ -189,7 +194,7 @@ public class KeyMouseRecorder
Type = MacroEventType.MouseMoveBy,
MouseX = state.X,
MouseY = state.Y,
Time = time - 5,
Time = time - 5 - StartTime,
CameraOrientation = cao,
});
}

View File

@ -22,7 +22,7 @@ public partial class AutoDomainConfig : ObservableObject
/// 寻找古树时,短距离移动,用于识别速度过慢的计算机使用
/// </summary>
[ObservableProperty]
private bool _walkToF = false;
private bool _walkToF = true;
/// <summary>
/// 寻找古树时,短距离移动的次数

View File

@ -75,6 +75,41 @@ public class AutoDomainTask : ISoloTask
Init();
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Started().Build()); // TODO: 通知后续需要删除迁移
// 3次复活重试
for (int i = 0; i < 3; i++)
{
try
{
await DoDomain();
// 其他场景不重试
break;
}
catch (Exception e)
{
if (e.Message.Contains("复活") && !string.IsNullOrEmpty(_taskParam.DomainName))
{
Logger.LogWarning("自动秘境:{Text}", "复活后重试秘境...");
await Delay(2000, ct);
continue;
}
else
{
throw;
}
}
}
await Delay(2000, ct);
await Bv.WaitForMainUi(_ct, 30);
await Delay(2000, ct);
await ArtifactSalvage();
}
private async Task DoDomain()
{
// 传送到秘境
await TpDomain();
// 切换队伍
@ -133,12 +168,6 @@ public class AutoDomainTask : ISoloTask
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Progress().Build());
}
await Delay(2000, ct);
await Bv.WaitForMainUi(_ct, 30);
await Delay(2000, ct);
await ArtifactSalvage();
}
private void Init()
@ -336,7 +365,7 @@ public class AutoDomainTask : ISoloTask
Simulation.SendInput.Keyboard.KeyUp(VK.VK_SHIFT);
}
}
}));
}), _ct);
}
private Task StartFight(CombatScenes combatScenes, List<CombatCommand> combatCommands)

View File

@ -282,6 +282,7 @@ public class AutoFightTask : ISoloTask
{
Debug.WriteLine(e.Message);
Debug.WriteLine(e.StackTrace);
throw;
}
}, cts2.Token);

View File

@ -163,7 +163,7 @@ public class CombatScenes : IDisposable
if (result.TopClass.Name.Name.StartsWith("Qin") || result.TopClass.Name.Name.Contains("Costume"))
{
// 降低琴和衣装角色的识别率要求
if (result.TopClass.Confidence < 0.6)
if (result.TopClass.Confidence < 0.51)
{
Cv2.ImWrite(@"log\avatar_side_classify_error.png", src.ToMat());
throw new Exception($"无法识别第{index}位角色,置信度{result.TopClass.Confidence},结果:{result.TopClass.Name.Name}");

View File

@ -202,7 +202,11 @@ public class PathExecutor
catch (NormalEndException normalEndException)
{
Logger.LogInformation(normalEndException.Message);
break;
throw;
}
catch (TaskCanceledException e)
{
throw;
}
catch (RetryException retryException)
{
@ -216,7 +220,6 @@ public class PathExecutor
StartSkipOtherOperations();
Logger.LogWarning(retryException.Message);
}
finally
{
// 不管咋样,松开所有按键

View File

@ -5457,5 +5457,450 @@
0,
9019.80
]
},
{
"country": "纳塔",
"type": "Statue",
"description": "奥奇卡纳塔",
"mapIndex": 0,
"version": "5.2",
"position": [
-619.27,
0,
9758.57
]
},
{
"country": "纳塔",
"type": "Reputation",
"description": "我在「烟谜主」的声望",
"mapIndex": 0,
"version": "5.2",
"position": [
-1653.83,
0,
9713.33
]
},
{
"country": "纳塔",
"type": "Reputation",
"description": "我在「花羽会」的声望",
"mapIndex": 0,
"version": "5.2",
"position": [
-1205.22,
0,
9485.59
]
},
{
"country": "纳塔",
"type": "Statue",
"description": "花羽会神像",
"mapIndex": 0,
"version": "5.2",
"position": [
-1288.47,
0,
9847.33
]
},
{
"country": "纳塔",
"type": "Statue",
"description": "烟谜主神像",
"mapIndex": 0,
"version": "5.2",
"position": [
-1782.06,
0,
9533.38
]
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1733.95,
0,
9229.58
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1806.69,
0,
9393.26
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1669.50,
0,
9469.82
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1857.84,
0,
9642.35
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1768.67,
0,
9782.39
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1624.28,
0,
9691.16
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1552.21,
0,
9711.72
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1604.83,
0,
9969.99
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1422.04,
0,
9306.38
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1286.57,
0,
9588.86
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-1113.75,
0,
9543.89
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-847.87,
0,
9716.26
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-640.28,
0,
10033.22
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-399.07,
0,
10163.81
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-203.70,
0,
10275.98
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-133.31,
0,
10119.13
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-208.18,
0,
10076.43
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-215.86,
0,
9954.87
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-337.91,
0,
10009.56
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
21.09,
0,
10073.35
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
257.03,
0,
9967.33
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
166.88,
0,
9673.21
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
56.56,
0,
9702.95
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"position": [
-354.76,
0,
9427.51
],
"version": "5.2",
"mapIndex": 0
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-404.72,
0,
9865.10
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-378.93,
0,
9816.65
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-314.75,
0,
9929.66
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-389.51,
0,
9688.61
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-169.13,
0,
10030.32
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-158.47,
0,
10074.34
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-1345.35,
0,
9342.99
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-1511.23,
0,
9383.95
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-1380.37,
0,
10733.42
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-577.64,
0,
9190.05
]
},
{
"country": "纳塔",
"type": "Waypoint",
"mapIndex": 0,
"version": "5.2",
"position": [
-31.92,
0,
9183.47
]
}
]

View File

@ -41,6 +41,7 @@ public class TpTask(CancellationToken ct)
/// <param name="tpX"></param>
/// <param name="tpY"></param>
/// <param name="force">强制以当前的tpX,tpY坐标进行自动传送</param>
/// <param name="initialZoomLevel">地图缩放等级</param>
public async Task<(double, double)> TpOnce(double tpX, double tpY, bool force = false, int initialZoomLevel = 4)
{
var (x, y) = (tpX, tpY);
@ -62,7 +63,7 @@ public class TpTask(CancellationToken ct)
{
await AdjustMapZoomLevel(true);
currentZoomLevel--;
Logger.LogInformation($"缩放等级过大,调整为{currentZoomLevel}。");
Logger.LogInformation("当前缩放等级过大,调整为{currentZoomLevel}。", currentZoomLevel);
}
while (!IsPointInBigMapWindow(bigMapInAllMapRect, x, y) || currentZoomLevel > 2.5) // 左上角 350x400也属于禁止点击区域
{
@ -159,10 +160,16 @@ public class TpTask(CancellationToken ct)
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_M);
await Delay(1000, ct);
ra1 = CaptureToRectArea();
for (int i = 0; i < 3; i++)
{
if (!Bv.IsInBigMapUi(ra1))
{
await Delay(500, ct);
ra1 = CaptureToRectArea();
}
}
}
currentZoomLevel = GetBigMapZoomLevel(ra1);
Logger.LogInformation($"当前缩放等级为{currentZoomLevel},地图移动过程中不要操作鼠标中键。");
for (var i = 0; i < 3; i++)
{
try

View File

@ -68,6 +68,21 @@ public class TaskRunner
{
_logger.LogInformation("任务中断:{Msg}", e.Message);
SendNotification();
if (RunnerContext.Instance.IsContinuousRunGroup)
{
// 连续执行时,抛出异常,终止执行
throw;
}
}
catch (TaskCanceledException e)
{
_logger.LogInformation("任务中断:{Msg}", "任务被取消");
SendNotification();
if (RunnerContext.Instance.IsContinuousRunGroup)
{
// 连续执行时,抛出异常,终止执行
throw;
}
}
catch (Exception e)
{

View File

@ -12,4 +12,6 @@ public partial class KeyMouseScriptItem : ObservableObject
private string _createTimeStr = string.Empty;
public DateTime CreateTime { get; set; }
public string Path { get; set; } = string.Empty;
}

View File

@ -12,6 +12,7 @@ using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
using BetterGenshinImpact.GameTask.Common;
using BetterGenshinImpact.GameTask.Common.BgiVision;
@ -45,60 +46,71 @@ public partial class ScriptService : IScriptService
{
_logger.LogInformation("配置组 {Name} 包含实时任务操作调用", groupName);
}
_logger.LogInformation("配置组 {Name} 加载完成,共{Cnt}个脚本,开始执行", groupName, list.Count);
}
var timerOperation = hasTimer ? DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty : DispatcherTimerOperationEnum.UseSelfCaptureImage;
await new TaskRunner(timerOperation)
.RunThreadAsync(async () =>
{
var stopwatch = new Stopwatch();
.RunThreadAsync(async () =>
{
var stopwatch = new Stopwatch();
foreach (var project in list)
{
if (project.Status != "Enabled")
{
_logger.LogInformation("脚本 {Name} 状态为禁用,跳过执行", project.Name);
continue;
}
if (CancellationContext.Instance.Cts.IsCancellationRequested)
{
_logger.LogInformation("执行被取消");
break;
}
foreach (var project in list)
{
if (project.Status != "Enabled")
{
_logger.LogInformation("脚本 {Name} 状态为禁用,跳过执行", project.Name);
continue;
}
for (var i = 0; i < project.RunNum; i++)
{
try
{
if (hasTimer)
{
TaskTriggerDispatcher.Instance().ClearTriggers();
}
if (CancellationContext.Instance.Cts.IsCancellationRequested)
{
_logger.LogInformation("执行被取消");
break;
}
_logger.LogInformation("------------------------------");
for (var i = 0; i < project.RunNum; i++)
{
try
{
if (hasTimer)
{
TaskTriggerDispatcher.Instance().ClearTriggers();
}
stopwatch.Reset();
stopwatch.Start();
await ExecuteProject(project);
}
catch (Exception e)
{
_logger.LogDebug(e, "执行脚本时发生异常");
_logger.LogError("执行脚本时发生异常: {Msg}", e.Message);
}
finally
{
stopwatch.Stop();
_logger.LogInformation("→ 脚本执行结束: {Name}, 耗时: {ElapsedMilliseconds} 毫秒", project.Name, stopwatch.ElapsedMilliseconds);
_logger.LogInformation("------------------------------");
}
_logger.LogInformation("------------------------------");
await Task.Delay(2000);
}
}
});
stopwatch.Reset();
stopwatch.Start();
await ExecuteProject(project);
}
catch (NormalEndException e)
{
throw;
}
catch (TaskCanceledException e)
{
_logger.LogInformation("取消执行配置组: {Msg}", e.Message);
throw;
}
catch (Exception e)
{
_logger.LogDebug(e, "执行脚本时发生异常");
_logger.LogError("执行脚本时发生异常: {Msg}", e.Message);
}
finally
{
stopwatch.Stop();
_logger.LogInformation("→ 脚本执行结束: {Name}, 耗时: {ElapsedMilliseconds} 毫秒", project.Name, stopwatch.ElapsedMilliseconds);
_logger.LogInformation("------------------------------");
}
await Task.Delay(2000);
}
}
});
if (!string.IsNullOrEmpty(groupName))
{
@ -131,6 +143,7 @@ public partial class ScriptService : IScriptService
hasTimer = true;
}
}
return list;
}
@ -153,6 +166,7 @@ public partial class ScriptService : IScriptService
jsProjects.Add(project.Project);
}
}
return jsProjects;
}
@ -199,8 +213,8 @@ public partial class ScriptService : IScriptService
[GeneratedRegex(@"^(?!\s*\/\/)\s*dispatcher\.\s*addTimer", RegexOptions.Multiline)]
private static partial Regex DispatcherAddTimerRegex();
public static async Task StartGameTask()
{
// 没启动时候,启动截图器
@ -234,4 +248,4 @@ public partial class ScriptService : IScriptService
});
}
}
}
}

View File

@ -274,7 +274,7 @@
</Grid>
<Grid Margin="16">
<!--<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@ -298,7 +298,7 @@
Grid.Column="1"
Margin="0,0,36,0"
IsChecked="{Binding Config.MaskWindowConfig.UseSubform, Mode=TwoWay}" />
</Grid>
</Grid>-->
</StackPanel>
</ui:CardExpander>

View File

@ -106,7 +106,7 @@
<DataTemplate>
<StackPanel Orientation="Horizontal">
<ui:Button Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:KeyMouseRecordPage}}, Path=DataContext.StartPlayCommand}"
CommandParameter="{Binding Name}"
CommandParameter="{Binding Path}"
Content="播放脚本"
Icon="{ui:SymbolIcon Play24}" />
</StackPanel>

View File

@ -43,7 +43,7 @@
Margin="0,0,0,8"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
TextWrapping="Wrap">
可以实现自动采集、自动挖矿(开发中)、自动锄地(开发中)等功能。请在调度器中使用!<Hyperlink Command="{Binding GoToPathingUrlCommand}" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
可以实现自动采集、自动挖矿、自动锄地等功能。请在调度器中使用!<Hyperlink Command="{Binding GoToPathingUrlCommand}" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
点击查看地图追踪与录制使用教程
</Hyperlink>
</ui:TextBlock>

View File

@ -1099,7 +1099,7 @@
</StackPanel>
</ui:CardExpander>
<ui:CardExpander Margin="0,0,0,12"
<!--<ui:CardExpander Margin="0,0,0,12"
ContentPadding="0"
Visibility="{markup:Converter Value={x:Static helpers:RuntimeHelper.IsDebuggerAttached},
Converter={StaticResource BooleanToVisibilityConverter}}">
@ -1171,13 +1171,11 @@
TextWrapping="Wrap" />
</Grid>
</StackPanel>
</ui:CardExpander>
</ui:CardExpander>-->
<!-- 活动音游(限时,已失效) -->
<ui:CardControl Margin="0,0,0,12"
Icon="{ui:SymbolIcon MusicNote224}"
Visibility="{markup:Converter Value={x:Static helpers:RuntimeHelper.IsDebuggerAttached},
Converter={StaticResource BooleanToVisibilityConverter}}">
Icon="{ui:SymbolIcon MusicNote224}">
<ui:CardControl.Header>
<Grid>
<Grid.RowDefinitions>
@ -1187,7 +1185,7 @@
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="活动音游(限时,已失效)"
Text="自动音游"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
@ -1201,9 +1199,12 @@
</ui:TextBlock>
</Grid>
</ui:CardControl.Header>
<ui:Button Margin="0,0,36,0"
Command="{Binding SwitchAutoMusicGameCommand}"
Content="{Binding SwitchAutoMusicGameButtonText}" />
<controls:TwoStateButton Margin="0,0,36,0"
DisableCommand="{Binding StopSoloTaskCommand}"
DisableContent="停止"
EnableCommand="{Binding SwitchAutoMusicGameCommand}"
EnableContent="{Binding SwitchAutoMusicGameButtonText}"
IsChecked="{Binding SwitchAutoMusicGameEnabled}" />
</ui:CardControl>

View File

@ -45,15 +45,16 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
private void InitScriptListViewData()
{
_scriptItems.Clear();
ScriptItems.Clear();
var fileInfos = LoadScriptFiles(scriptPath)
.OrderByDescending(f => f.CreationTime)
.ToList();
foreach (var f in fileInfos)
{
_scriptItems.Add(new KeyMouseScriptItem
ScriptItems.Add(new KeyMouseScriptItem
{
Name = f.Name,
Path = f.FullName,
CreateTime = f.CreationTime,
CreateTimeStr = f.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")
});
@ -67,7 +68,7 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
Directory.CreateDirectory(folder);
}
var files = Directory.GetFiles(folder, "*.*",
var files = Directory.GetFiles(folder, "*.json",
SearchOption.AllDirectories);
return files.Select(file => new FileInfo(file)).ToList();
@ -120,12 +121,13 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
}
[RelayCommand]
public async Task OnStartPlay(string name)
public async Task OnStartPlay(string path)
{
string name = Path.GetFileName(path);
_logger.LogInformation("重放开始:{Name}", name);
try
{
var s = await File.ReadAllTextAsync(Path.Combine(scriptPath, name));
var s = await File.ReadAllTextAsync(path);
await new TaskRunner(DispatcherTimerOperationEnum.UseSelfCaptureImage)
.RunAsync(async () => await KeyMouseMacroPlayer.PlayMacro(s, CancellationContext.Instance.Cts.Token));
@ -159,11 +161,11 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
if (!string.IsNullOrEmpty(str))
{
// 检查原始文件是否存在
var originalFilePath = Path.Combine(scriptPath, item.Name);
var originalFilePath = item.Path;
if (File.Exists(originalFilePath))
{
// 重命名文件
File.Move(originalFilePath, Path.Combine(scriptPath, str + ".json"));
File.Move(originalFilePath, Path.Combine(Path.GetDirectoryName(originalFilePath)!, str + ".json"));
_snackbarService.Show(
"修改名称成功",
$"脚本名称 {item.Name} 修改为 {str}",
@ -199,7 +201,7 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
}
try
{
File.Delete(Path.Combine(scriptPath, item.Name));
File.Delete(item.Path);
_snackbarService.Show(
"删除成功",
$"{item.Name} 已经被删除",

View File

@ -13,6 +13,7 @@ using Microsoft.Extensions.Logging;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using BetterGenshinImpact.Core.Script;
using BetterGenshinImpact.ViewModel.Message;
using CommunityToolkit.Mvvm.Messaging;
@ -105,7 +106,7 @@ public partial class MapPathingViewModel : ObservableObject, INavigationAware, I
}
[RelayCommand]
public async void OnStart()
public async Task OnStart()
{
var item = SelectNode;
if (item == null)

View File

@ -97,19 +97,21 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
}
}
}
[RelayCommand]
private void ClearTasks()
{
SelectedScriptGroup.Projects.Clear();
WriteScriptGroup(SelectedScriptGroup);
}
private void UpdateTasks()
{
//PromptDialog.Prompt
// SelectedScriptGroup.Projects.Clear();
// WriteScriptGroup(SelectedScriptGroup);
// SelectedScriptGroup.Projects.Clear();
// WriteScriptGroup(SelectedScriptGroup);
}
[RelayCommand]
public void OnRenameScriptGroup(ScriptGroup? item)
{
@ -867,14 +869,23 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
_logger.LogInformation("开始连续执行选中配置组:{Names}", string.Join(",", selectedGroups.Select(x => x.Name)));
RunnerContext.Instance.IsContinuousRunGroup = true;
foreach (var scriptGroup in selectedGroups)
try
{
await _scriptService.RunMulti(GetNextProjects(scriptGroup), scriptGroup.Name);
await Task.Delay(2000);
RunnerContext.Instance.IsContinuousRunGroup = true;
foreach (var scriptGroup in selectedGroups)
{
await _scriptService.RunMulti(GetNextProjects(scriptGroup), scriptGroup.Name);
await Task.Delay(2000);
}
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
finally
{
RunnerContext.Instance.Reset();
}
RunnerContext.Instance.Reset();
}
}
}

View File

@ -83,6 +83,9 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
[ObservableProperty]
private string _switchAutoTrackPathButtonText = "启动";
[ObservableProperty]
private bool _switchAutoMusicGameEnabled;
[ObservableProperty]
private string _switchAutoMusicGameButtonText = "启动";
@ -111,29 +114,6 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
}
private string[] LoadCustomScript(string folder)
{
var files = Directory.GetFiles(folder, "*.*",
SearchOption.AllDirectories);
var strategyList = new string[files.Length];
for (var i = 0; i < files.Length; i++)
{
if (files[i].EndsWith(".txt"))
{
var strategyName = files[i].Replace(folder, "").Replace(".txt", "");
if (strategyName.StartsWith('\\'))
{
strategyName = strategyName[1..];
}
strategyList[i] = strategyName;
}
}
return strategyList;
}
[RelayCommand]
private async Task OnStopSoloTask()
{
@ -142,6 +122,7 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
SwitchAutoWoodEnabled = false;
SwitchAutoDomainEnabled = false;
SwitchAutoFightEnabled = false;
SwitchAutoMusicGameEnabled = false;
await Task.Delay(800);
}
@ -283,7 +264,7 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
[RelayCommand]
public void OnOpenFightFolder()
{
_autoFightViewModel.OnOpenFightFolder();
_autoFightViewModel?.OnOpenFightFolder();
}
[Obsolete]
@ -359,8 +340,10 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
[RelayCommand]
public async Task OnSwitchAutoMusicGame()
{
SwitchAutoMusicGameEnabled = true;
await new TaskRunner(DispatcherTimerOperationEnum.UseSelfCaptureImage)
.RunSoloTaskAsync(new AutoMusicGameTask(new AutoMusicGameParam()));
SwitchAutoMusicGameEnabled = false;
}
[RelayCommand]