fix: 修复重置导航与实时设置关卡的冲突

This commit is contained in:
uye
2023-01-29 18:16:10 +08:00
parent fa83225836
commit 5b36da4e6e
2 changed files with 43 additions and 31 deletions

View File

@@ -214,6 +214,11 @@ namespace MaaWpfGui
/// <returns>Whether stage is open</returns>
public bool IsStageOpen(string stage, DayOfWeek dayOfWeek)
{
if (stage == null)
{
return false;
}
return GetStageInfo(stage)?.IsStageOpen(dayOfWeek) == true;
}

View File

@@ -279,13 +279,13 @@ namespace MaaWpfGui
if (settingsModel.HideUnavailableStage)
{
// update available stage list
var stage1 = Stage1;
var stage1 = Stage1 ??= string.Empty;
StageList = new ObservableCollection<CombData>(_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<CombData>(_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<CombData>(_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;
/// <summary>
/// Sets parameters.
/// </summary>
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>();
asstProxy.AsstSetFightTaskParams(Stage, medicine, stone, times, DropsItemId, drops_quantity);
var asstProxy = _container.Get<AsstProxy>();
asstProxy.AsstSetFightTaskParams(Stage, medicine, stone, times, DropsItemId, drops_quantity);
}
}
public void SetFightRemainingSanityParams()