From 5b36da4e6eca0f5581df7a4852b7335d647a07fb Mon Sep 17 00:00:00 2001
From: uye <2396806385@qq.com>
Date: Sun, 29 Jan 2023 18:16:10 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E7=BD=AE?=
=?UTF-8?q?=E5=AF=BC=E8=88=AA=E4=B8=8E=E5=AE=9E=E6=97=B6=E8=AE=BE=E7=BD=AE?=
=?UTF-8?q?=E5=85=B3=E5=8D=A1=E7=9A=84=E5=86=B2=E7=AA=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/MaaWpfGui/Helper/StageManager.cs | 5 ++
src/MaaWpfGui/Main/TaskQueueViewModel.cs | 69 +++++++++++++-----------
2 files changed, 43 insertions(+), 31 deletions(-)
diff --git a/src/MaaWpfGui/Helper/StageManager.cs b/src/MaaWpfGui/Helper/StageManager.cs
index a87b9e21f3..564f822adc 100644
--- a/src/MaaWpfGui/Helper/StageManager.cs
+++ b/src/MaaWpfGui/Helper/StageManager.cs
@@ -214,6 +214,11 @@ namespace MaaWpfGui
/// Whether stage is open
public bool IsStageOpen(string stage, DayOfWeek dayOfWeek)
{
+ if (stage == null)
+ {
+ return false;
+ }
+
return GetStageInfo(stage)?.IsStageOpen(dayOfWeek) == true;
}
diff --git a/src/MaaWpfGui/Main/TaskQueueViewModel.cs b/src/MaaWpfGui/Main/TaskQueueViewModel.cs
index 948b8ac48b..a969a5af25 100644
--- a/src/MaaWpfGui/Main/TaskQueueViewModel.cs
+++ b/src/MaaWpfGui/Main/TaskQueueViewModel.cs
@@ -279,13 +279,13 @@ namespace MaaWpfGui
if (settingsModel.HideUnavailableStage)
{
// update available stage list
- var stage1 = Stage1;
+ var stage1 = Stage1 ??= string.Empty;
StageList = new ObservableCollection(_stageManager.GetStageList(_curDayOfWeek));
// reset closed stage1 to "Last/Current"
if (!CustomStageCode)
{
- Stage1 = (stage1 != null && _stageManager.IsStageOpen(stage1, _curDayOfWeek)) ? stage1 : string.Empty;
+ Stage1 = _stageManager.IsStageOpen(stage1, _curDayOfWeek) ? stage1 : string.Empty;
}
}
else
@@ -293,23 +293,25 @@ namespace MaaWpfGui
// initializing or settings changing, update stage list forcely
if (forceUpdate)
{
- var stage1 = Stage1;
- var stage2 = Stage2;
- var stage3 = Stage3;
+ var stage1 = Stage1 ??= string.Empty;
+ var stage2 = Stage2 ??= string.Empty;
+ var stage3 = Stage3 ??= string.Empty;
StageList = new ObservableCollection(_stageManager.GetStageList());
// reset closed stages to "Last/Current"
if (!CustomStageCode)
{
+ EnableSetFightParams = false;
Stage1 = StageList.Any(x => x.Value == stage1) ? stage1 : string.Empty;
Stage2 = StageList.Any(x => x.Value == stage2) ? stage2 : string.Empty;
Stage3 = StageList.Any(x => x.Value == stage3) ? stage3 : string.Empty;
+ EnableSetFightParams = true;
}
}
}
- var rss = RemainingSanityStage;
+ var rss = RemainingSanityStage ??= string.Empty;
RemainingSanityStageList = new ObservableCollection(_stageManager.GetStageList())
{
[0] = new CombData { Display = Localization.GetString("NoUse"), Value = string.Empty },
@@ -774,49 +776,54 @@ namespace MaaWpfGui
return asstProxy.AsstAppendFight(RemainingSanityStage, 0, 0, int.MaxValue, string.Empty, 0, false);
}
+ public bool EnableSetFightParams { get; set; } = true;
+
///
/// Sets parameters.
///
public void SetFightParams()
{
- int medicine = 0;
- if (UseMedicine)
+ if (EnableSetFightParams)
{
- if (!int.TryParse(MedicineNumber, out medicine))
+ int medicine = 0;
+ if (UseMedicine)
{
- medicine = 0;
+ if (!int.TryParse(MedicineNumber, out medicine))
+ {
+ medicine = 0;
+ }
}
- }
- int stone = 0;
- if (UseStone)
- {
- if (!int.TryParse(StoneNumber, out stone))
+ int stone = 0;
+ if (UseStone)
{
- stone = 0;
+ if (!int.TryParse(StoneNumber, out stone))
+ {
+ stone = 0;
+ }
}
- }
- int times = int.MaxValue;
- if (HasTimesLimited)
- {
- if (!int.TryParse(MaxTimes, out times))
+ int times = int.MaxValue;
+ if (HasTimesLimited)
{
- times = 0;
+ if (!int.TryParse(MaxTimes, out times))
+ {
+ times = 0;
+ }
}
- }
- int drops_quantity = 0;
- if (IsSpecifiedDrops)
- {
- if (!int.TryParse(DropsQuantity, out drops_quantity))
+ int drops_quantity = 0;
+ if (IsSpecifiedDrops)
{
- drops_quantity = 0;
+ if (!int.TryParse(DropsQuantity, out drops_quantity))
+ {
+ drops_quantity = 0;
+ }
}
- }
- var asstProxy = _container.Get();
- asstProxy.AsstSetFightTaskParams(Stage, medicine, stone, times, DropsItemId, drops_quantity);
+ var asstProxy = _container.Get();
+ asstProxy.AsstSetFightTaskParams(Stage, medicine, stone, times, DropsItemId, drops_quantity);
+ }
}
public void SetFightRemainingSanityParams()