From 328e5db7653d6b850a86d6587affe616595dbef2 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Sun, 21 Jul 2024 22:48:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=8D=A2?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=8F=AD=E6=AC=A1=E6=95=B0=E7=9A=84=E5=9F=BA?= =?UTF-8?q?=E5=BB=BA=E6=8E=92=E7=8F=AD=E8=A1=A8=E5=8F=AF=E8=83=BD=E9=81=87?= =?UTF-8?q?=E5=88=B0=E7=9A=84=E6=95=B0=E7=BB=84=E8=B6=8A=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #9779 --- .../ViewModels/UI/SettingsViewModel.cs | 7 ++--- .../ViewModels/UI/TaskQueueViewModel.cs | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index bbde75b2e2..fcaad2549b 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -1615,14 +1615,11 @@ namespace MaaWpfGui.ViewModels.UI Instances.TaskQueueViewModel.RefreshCustomInfrastPlan(); // SetAndNotify 在值没有变化时不会触发 PropertyChanged 事件,所以这里手动触发一下 - var index = Instances.TaskQueueViewModel.CustomInfrastPlanIndex; - var count = Instances.TaskQueueViewModel.CustomInfrastPlanList.Count; Instances.TaskQueueViewModel.NeedAddCustomInfrastPlanInfo = false; { - Instances.TaskQueueViewModel.CustomInfrastPlanIndex = (index + 1) % count; - Instances.TaskQueueViewModel.CustomInfrastPlanIndex = index; + Instances.TaskQueueViewModel.CustomInfrastPlanIndex--; + Instances.TaskQueueViewModel.CustomInfrastPlanIndex++; } - Instances.TaskQueueViewModel.NeedAddCustomInfrastPlanInfo = true; } } diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index e0b4f667df..e66efed781 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -2643,9 +2643,24 @@ namespace MaaWpfGui.ViewModels.UI public int CustomInfrastPlanIndex { - get => _customInfrastPlanIndex; + get + { + if (_customInfrastPlanIndex >= CustomInfrastPlanInfoList.Count || _customInfrastPlanIndex < 0) + { + CustomInfrastPlanIndex = _customInfrastPlanIndex; + } + + return _customInfrastPlanIndex; + } set { + if (value >= CustomInfrastPlanInfoList.Count || value < 0) + { + var count = CustomInfrastPlanInfoList.Count; + value = (value % count + count) % count; + _logger.Warning($"CustomInfrastPlanIndex out of range, reset to Index % Count: {value}"); + } + if (value != _customInfrastPlanIndex && NeedAddCustomInfrastPlanInfo) { var plan = CustomInfrastPlanInfoList[value]; @@ -2855,14 +2870,7 @@ namespace MaaWpfGui.ViewModels.UI AddLog(prePlanPostDesc); } - if (CustomInfrastPlanIndex >= CustomInfrastPlanList.Count - 1) - { - CustomInfrastPlanIndex = 0; - } - else - { - ++CustomInfrastPlanIndex; - } + ++CustomInfrastPlanIndex; } ///