From bb7d84ffe32bf68ff42a2da679dd8c14ddc8a0d6 Mon Sep 17 00:00:00 2001 From: mfkvfhpdx Date: Fri, 27 Dec 2024 23:47:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97=E9=85=8D=E7=BD=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=B6=85=E6=97=B6=EF=BC=8C=E8=B0=83=E5=BA=A6=E5=99=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B8=85=E7=A9=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameTask/AutoFight/AutoFightConfig.cs | 6 +++++ .../GameTask/AutoFight/AutoFightParam.cs | 2 ++ .../GameTask/AutoFight/AutoFightTask.cs | 2 +- .../AutoPathing/Handler/AutoFightHandler.cs | 3 ++- .../View/Pages/ScriptControlPage.xaml | 4 +-- .../View/Pages/TaskSettingsPage.xaml | 25 +++++++++++++++++ .../Pages/View/ScriptGroupConfigView.xaml | 27 ++++++++++++++++++- .../Pages/TaskSettingsPageViewModel.cs | 3 ++- 8 files changed, 66 insertions(+), 6 deletions(-) diff --git a/BetterGenshinImpact/GameTask/AutoFight/AutoFightConfig.cs b/BetterGenshinImpact/GameTask/AutoFight/AutoFightConfig.cs index 585cbc37..f3c51cc9 100644 --- a/BetterGenshinImpact/GameTask/AutoFight/AutoFightConfig.cs +++ b/BetterGenshinImpact/GameTask/AutoFight/AutoFightConfig.cs @@ -27,4 +27,10 @@ public partial class AutoFightConfig : ObservableObject /// [ObservableProperty] private bool _pickDropsAfterFightEnabled = true; + + /// + /// 战斗超时,单位秒 + /// + [ObservableProperty] + private int _timeout = 120; } diff --git a/BetterGenshinImpact/GameTask/AutoFight/AutoFightParam.cs b/BetterGenshinImpact/GameTask/AutoFight/AutoFightParam.cs index 47da06ed..b5f08de8 100644 --- a/BetterGenshinImpact/GameTask/AutoFight/AutoFightParam.cs +++ b/BetterGenshinImpact/GameTask/AutoFight/AutoFightParam.cs @@ -9,4 +9,6 @@ public class AutoFightParam(string path) : BaseTaskParam public bool FightFinishDetectEnabled { get; set; } = false; public bool PickDropsAfterFightEnabled { get; set; } = false; + + public int Timeout { get; set; } = 120; } diff --git a/BetterGenshinImpact/GameTask/AutoFight/AutoFightTask.cs b/BetterGenshinImpact/GameTask/AutoFight/AutoFightTask.cs index d2d1f954..656020ed 100644 --- a/BetterGenshinImpact/GameTask/AutoFight/AutoFightTask.cs +++ b/BetterGenshinImpact/GameTask/AutoFight/AutoFightTask.cs @@ -64,7 +64,7 @@ public class AutoFightTask : ISoloTask ct.Register(cts2.Cancel); combatScenes.BeforeTask(cts2.Token); - TimeSpan fightTimeout = TimeSpan.FromSeconds(120); // 默认战斗超时时间 + TimeSpan fightTimeout = TimeSpan.FromSeconds(_taskParam.Timeout); // 默认战斗超时时间 Stopwatch stopwatch = Stopwatch.StartNew(); //战斗前检查,可做成配置 diff --git a/BetterGenshinImpact/GameTask/AutoPathing/Handler/AutoFightHandler.cs b/BetterGenshinImpact/GameTask/AutoPathing/Handler/AutoFightHandler.cs index 2566e77a..797043f6 100644 --- a/BetterGenshinImpact/GameTask/AutoPathing/Handler/AutoFightHandler.cs +++ b/BetterGenshinImpact/GameTask/AutoPathing/Handler/AutoFightHandler.cs @@ -44,7 +44,8 @@ internal class AutoFightHandler : IActionHandler AutoFightParam autoFightParam = new AutoFightParam(GetFightStrategy(config)) { FightFinishDetectEnabled = config.FightFinishDetectEnabled, - PickDropsAfterFightEnabled = config.PickDropsAfterFightEnabled + PickDropsAfterFightEnabled = config.PickDropsAfterFightEnabled, + Timeout = config.Timeout }; return autoFightParam; diff --git a/BetterGenshinImpact/View/Pages/ScriptControlPage.xaml b/BetterGenshinImpact/View/Pages/ScriptControlPage.xaml index 1d300b88..9d7e7cb9 100644 --- a/BetterGenshinImpact/View/Pages/ScriptControlPage.xaml +++ b/BetterGenshinImpact/View/Pages/ScriptControlPage.xaml @@ -207,11 +207,11 @@ - + - + diff --git a/BetterGenshinImpact/View/Pages/TaskSettingsPage.xaml b/BetterGenshinImpact/View/Pages/TaskSettingsPage.xaml index 73c7392a..124755d4 100644 --- a/BetterGenshinImpact/View/Pages/TaskSettingsPage.xaml +++ b/BetterGenshinImpact/View/Pages/TaskSettingsPage.xaml @@ -506,6 +506,31 @@ Margin="0,0,36,0" IsChecked="{Binding Config.AutoFightConfig.PickDropsAfterFightEnabled, Mode=TwoWay}" /> + + + + + + + + + + + + + diff --git a/BetterGenshinImpact/View/Pages/View/ScriptGroupConfigView.xaml b/BetterGenshinImpact/View/Pages/View/ScriptGroupConfigView.xaml index c8bf02a6..0d08eec3 100644 --- a/BetterGenshinImpact/View/Pages/View/ScriptGroupConfigView.xaml +++ b/BetterGenshinImpact/View/Pages/View/ScriptGroupConfigView.xaml @@ -13,7 +13,7 @@ d:DesignHeight="850" d:DesignWidth="800" mc:Ignorable="d"> - + + + + + + + + + + + + + + diff --git a/BetterGenshinImpact/ViewModel/Pages/TaskSettingsPageViewModel.cs b/BetterGenshinImpact/ViewModel/Pages/TaskSettingsPageViewModel.cs index 5f010e65..aaa9af98 100644 --- a/BetterGenshinImpact/ViewModel/Pages/TaskSettingsPageViewModel.cs +++ b/BetterGenshinImpact/ViewModel/Pages/TaskSettingsPageViewModel.cs @@ -232,7 +232,8 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw var param = new AutoFightParam(path) { FightFinishDetectEnabled = Config.AutoFightConfig.FightFinishDetectEnabled, - PickDropsAfterFightEnabled = Config.AutoFightConfig.PickDropsAfterFightEnabled + PickDropsAfterFightEnabled = Config.AutoFightConfig.PickDropsAfterFightEnabled, + Timeout = Config.AutoFightConfig.Timeout }; SwitchAutoFightEnabled = true;