fix: 非自定义关卡名情况下,未能移除不显示的关卡

fix #12331
This commit is contained in:
status102
2025-04-12 22:34:15 +08:00
parent d85b69632f
commit 3d62daed59
2 changed files with 21 additions and 1 deletions

View File

@@ -915,6 +915,10 @@ namespace MaaWpfGui.ViewModels.UI
FightTask.Stage2 = stage2;
FightTask.Stage3 = stage3;
FightTask.RemainingSanityStage = rss;
if (!FightTask.CustomStageCode)
{
FightTask.RemoveNonExistStage();
}
Instances.TaskQueueViewModel.EnableSetFightParams = true;
});
@@ -1367,7 +1371,7 @@ namespace MaaWpfGui.ViewModels.UI
continue;
}
AddLog(item.OriginalName + "Error", UiLogColor.Error);
AddLog($"{LocalizationHelper.GetString(item.OriginalName)} task append error", UiLogColor.Error);
taskRet = true;
--count;
}

View File

@@ -229,11 +229,27 @@ public class FightSettingsUserControlModel : TaskViewModel
get => _customStageCode;
set
{
if (!value)
{
RemoveNonExistStage();
}
SetAndNotify(ref _customStageCode, value);
ConfigurationHelper.SetValue(ConfigurationKeys.CustomStageCode, value.ToString());
}
}
/// <summary>
/// 移除不在关卡列表中的关卡,关闭自定义和刷新关卡列表时调用
/// </summary>
public void RemoveNonExistStage()
{
Stage1 = StageList.Where(x => x.Value == Stage1).FirstOrDefault()?.Value ?? string.Empty;
Stage2 = StageList.Where(x => x.Value == Stage2).FirstOrDefault()?.Value ?? string.Empty;
Stage3 = StageList.Where(x => x.Value == Stage3).FirstOrDefault()?.Value ?? string.Empty;
RemainingSanityStage = RemainingSanityStageList.Where(x => x.Value == RemainingSanityStage).FirstOrDefault()?.Value ?? string.Empty;
}
private string _remainingSanityStage = ConfigurationHelper.GetValue(ConfigurationKeys.RemainingSanityStage, string.Empty) ?? string.Empty;
public string RemainingSanityStage