From 166be280e68d3c2c8c279379a1a58e172ec0b88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=93=E4=B8=B6=E6=A2=A6=E4=B8=B6=E4=BB=81?= <74444214+Daydreamer114@users.noreply.github.com> Date: Mon, 30 Jun 2025 22:41:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20wpfgui=20=E6=B7=BB=E5=8A=A0=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E5=A4=87=E9=80=89=E5=85=B3=E5=8D=A1=20(stage4)=20(#13?= =?UTF-8?q?106)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Constants/ConfigurationKeys.cs | 1 + .../ViewModels/UI/TaskQueueViewModel.cs | 6 ++- .../FightSettingsUserControlModel.cs | 42 +++++++++++++++++-- .../TaskQueue/FightSettingsUserControl.xaml | 29 +++++++++++++ 4 files changed, 74 insertions(+), 4 deletions(-) diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index 702392a8be..b1d451bbb8 100644 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -242,6 +242,7 @@ namespace MaaWpfGui.Constants public const string Stage1 = "MainFunction.Stage1"; public const string Stage2 = "MainFunction.Stage2"; public const string Stage3 = "MainFunction.Stage3"; + public const string Stage4 = "MainFunction.Stage4"; public const string UseMedicine = "MainFunction.UseMedicine"; public const string UseMedicineQuantity = "MainFunction.UseMedicine.Quantity"; public const string UseStone = "MainFunction.UseStone"; diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index ca21b50cdf..a98990c69a 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -871,6 +871,7 @@ namespace MaaWpfGui.ViewModels.UI var stage1 = FightTask.Stage1 ?? string.Empty; var stage2 = FightTask.Stage2 ?? string.Empty; var stage3 = FightTask.Stage3 ?? string.Empty; + var stage4 = FightTask.Stage4 ?? string.Empty; var rss = FightTask.RemainingSanityStage ?? string.Empty; var tempStageList = hideUnavailableStage @@ -890,11 +891,12 @@ namespace MaaWpfGui.ViewModels.UI stage1 = Instances.TaskQueueViewModel.GetValidStage(stage1); stage2 = Instances.TaskQueueViewModel.GetValidStage(stage2); stage3 = Instances.TaskQueueViewModel.GetValidStage(stage3); + stage4 = Instances.TaskQueueViewModel.GetValidStage(stage4); } else if (FightTask.UseAlternateStage) { // 11% - AddStagesIfNotExist([stage1, stage2, stage3], tempStageList); + AddStagesIfNotExist([stage1, stage2, stage3, stage4], tempStageList); } else { @@ -904,6 +906,7 @@ namespace MaaWpfGui.ViewModels.UI // 避免关闭了使用备用关卡后,始终添加备用关卡中的未开放关卡 stage2 = Instances.TaskQueueViewModel.GetValidStage(stage2); stage3 = Instances.TaskQueueViewModel.GetValidStage(stage3); + stage4 = Instances.TaskQueueViewModel.GetValidStage(stage4); } // rss 如果结束后还选择了不开放的关卡,刷理智任务会报错 @@ -924,6 +927,7 @@ namespace MaaWpfGui.ViewModels.UI FightTask.Stage1 = stage1; FightTask.Stage2 = stage2; FightTask.Stage3 = stage3; + FightTask.Stage4 = stage4; FightTask.RemainingSanityStage = rss; if (!FightTask.CustomStageCode) { diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs index 50360dd4dd..f1d4e7fed1 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs @@ -87,7 +87,12 @@ public class FightSettingsUserControlModel : TaskViewModel return Stage2; } - return Instances.TaskQueueViewModel.IsStageOpen(Stage3) ? Stage3 : Stage1; + if (Instances.TaskQueueViewModel.IsStageOpen(Stage3)) + { + return Stage3; + } + + return Instances.TaskQueueViewModel.IsStageOpen(Stage4) ? Stage4 : Stage1; } } @@ -109,7 +114,7 @@ public class FightSettingsUserControlModel : TaskViewModel { "炭", "SK-5" }, }; - public string?[] Stages => [Stage1, Stage2, Stage3]; + public string?[] Stages => [Stage1, Stage2, Stage3, Stage4]; /// Try to fix: issues#5742. 关卡选择为 null 时的一个补丁,可能是 StageList 改变后,wpf binding 延迟更新的问题。 public string _stage1Fallback = ConfigurationHelper.GetValue(ConfigurationKeys.Stage1, string.Empty) ?? string.Empty; @@ -178,7 +183,7 @@ public class FightSettingsUserControlModel : TaskViewModel private string _stage3 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage3, string.Empty) ?? string.Empty; /// - /// Gets or sets the stage2. + /// Gets or sets the stage3. /// public string Stage3 { @@ -205,6 +210,36 @@ public class FightSettingsUserControlModel : TaskViewModel } } + private string _stage4 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage4, string.Empty) ?? string.Empty; + + /// + /// Gets or sets the stage4. + /// + public string Stage4 + { + get => _stage4; + set + { + if (_stage4 == value) + { + return; + } + + if (CustomStageCode) + { + if (_stage4?.Length != 3 && value != null) + { + value = ToUpperAndCheckStage(value); + } + } + + SetAndNotify(ref _stage4, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.Stage4, value); + Instances.TaskQueueViewModel.UpdateDatePrompt(); + } + } + private bool _useRemainingSanityStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseRemainingSanityStage, bool.TrueString)); public bool UseRemainingSanityStage @@ -245,6 +280,7 @@ public class FightSettingsUserControlModel : TaskViewModel Stage1 = StageList.FirstOrDefault(x => x.Value == Stage1)?.Value ?? string.Empty; Stage2 = StageList.FirstOrDefault(x => x.Value == Stage2)?.Value ?? string.Empty; Stage3 = StageList.FirstOrDefault(x => x.Value == Stage3)?.Value ?? string.Empty; + Stage4 = StageList.FirstOrDefault(x => x.Value == Stage4)?.Value ?? string.Empty; RemainingSanityStage = RemainingSanityStageList.FirstOrDefault(x => x.Value == RemainingSanityStage)?.Value ?? string.Empty; } diff --git a/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml index e81bc910e8..fddd2c0802 100644 --- a/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml @@ -231,6 +231,16 @@ TextAlignment="Center" TextWrapping="Wrap" /> + + + + + +