From c2c47cf6b7bdeb38b144fc692e1712919065dbd7 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:19:08 +0800 Subject: [PATCH] =?UTF-8?q?rft:=20WpfGui=E9=87=8D=E6=9E=84=20=E6=8B=86?= =?UTF-8?q?=E5=88=86`=E4=B8=80=E9=94=AE=E9=95=BF=E8=8D=89-=E5=88=B7?= =?UTF-8?q?=E7=90=86=E6=99=BA=E4=BB=BB=E5=8A=A1`=20(#11223)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Main/AsstProxy.cs | 12 +- .../RemoteControl/RemoteControlService.cs | 2 +- .../ViewModels/UI/SettingsViewModel.cs | 246 ++--- .../ViewModels/UI/TaskQueueViewModel.cs | 920 +++--------------- .../FightSettingsUserControlModel.cs | 780 +++++++++++++++ src/MaaWpfGui/Views/UI/TaskQueueView.xaml | 2 +- .../FightSettingsUserControl.xaml | 83 +- .../FightSettingsUserControl.xaml.cs | 2 +- .../RoguelikeSettingsUserControl.xaml | 2 +- 9 files changed, 1032 insertions(+), 1017 deletions(-) create mode 100644 src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs rename src/MaaWpfGui/Views/UserControl/{ => TaskQueue}/FightSettingsUserControl.xaml (84%) rename src/MaaWpfGui/Views/UserControl/{ => TaskQueue}/FightSettingsUserControl.xaml.cs (95%) diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index c0a369e24f..78a86c1b50 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -694,9 +694,9 @@ namespace MaaWpfGui.Main case AsstMsg.TaskChainError: { // 对剿灭的特殊处理,如果刷完了剿灭还选了剿灭会因为找不到入口报错 - if (taskChain == "Fight" && (Instances.TaskQueueViewModel.Stage == "Annihilation")) + if (taskChain == "Fight" && (SettingsViewModel.FightTask.Stage == "Annihilation")) { - if (Instances.TaskQueueViewModel.Stages.Any(stage => Instances.TaskQueueViewModel.IsStageOpen(stage) && (stage != "Annihilation"))) + if (SettingsViewModel.FightTask.Stages.Any(stage => Instances.TaskQueueViewModel.IsStageOpen(stage) && (stage != "Annihilation"))) { Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AnnihilationTaskFailed"), UiLogColor.Warning); } @@ -757,7 +757,7 @@ namespace MaaWpfGui.Main case "Mall": { - if (Instances.TaskQueueViewModel.Stage != string.Empty && SettingsViewModel.MallTask.CreditFightTaskEnabled) + if (SettingsViewModel.FightTask.Stage != string.Empty && SettingsViewModel.MallTask.CreditFightTaskEnabled) { SettingsViewModel.MallTask.LastCreditFightTaskTime = DateTime.UtcNow.ToYjDate().ToFormattedString(); Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("CompleteTask") + LocalizationHelper.GetString("CreditFight")); @@ -827,7 +827,7 @@ namespace MaaWpfGui.Main bool buyWine = _latestTaskId.ContainsKey(TaskType.Mall) && Instances.SettingsViewModel.DidYouBuyWine(); _latestTaskId.Clear(); - Instances.TaskQueueViewModel.ResetFightVariables(); + SettingsViewModel.FightTask.ResetFightVariables(); Instances.TaskQueueViewModel.ResetTaskSelection(); _runningState.SetIdle(true); @@ -2015,8 +2015,8 @@ namespace MaaWpfGui.Main taskParams["client_type"] = SettingsViewModel.GameSettings.ClientType; taskParams["penguin_id"] = Instances.SettingsViewModel.PenguinId; - taskParams["DrGrandet"] = Instances.SettingsViewModel.IsDrGrandet; - taskParams["expiring_medicine"] = isMainFight && Instances.SettingsViewModel.UseExpiringMedicine ? 9999 : 0; + taskParams["DrGrandet"] = SettingsViewModel.FightTask.IsDrGrandet; + taskParams["expiring_medicine"] = isMainFight && SettingsViewModel.FightTask.UseExpiringMedicine ? 9999 : 0; taskParams["server"] = Instances.SettingsViewModel.ServerType; return taskParams; } diff --git a/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs b/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs index 30b35ac0b1..ba0786c602 100644 --- a/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs +++ b/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs @@ -454,7 +454,7 @@ namespace MaaWpfGui.Services.RemoteControl case "Settings-Stage1": await Execute.OnUIThreadAsync(() => { - Instances.TaskQueueViewModel.Stage1 = data; + SettingsViewModel.FightTask.Stage1 = data; }); break; diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 0eb38de59b..b4caf4e17f 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -70,6 +70,11 @@ namespace MaaWpfGui.ViewModels.UI #region 长草任务Model + /// + /// Gets 战斗任务Model + /// + public static FightSettingsUserControlModel FightTask { get; } = new(); + /// /// Gets 信用及购物任务Model /// @@ -422,196 +427,6 @@ namespace MaaWpfGui.ViewModels.UI #endregion 开始唤醒 - #region 刷理智设置 - - private string _penguinId = ConfigurationHelper.GetValue(ConfigurationKeys.PenguinId, string.Empty); - - /// - /// Gets or sets the id of PenguinStats. - /// - public string PenguinId - { - get => _penguinId; - set - { - SetAndNotify(ref _penguinId, value); - ConfigurationHelper.SetValue(ConfigurationKeys.PenguinId, value); - } - } - - private bool _enablePenguin = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.EnablePenguin, bool.TrueString)); - - /// - /// Gets or sets a value indicating whether to enable penguin upload. - /// - public bool EnablePenguin - { - get => _enablePenguin; - set - { - SetAndNotify(ref _enablePenguin, value); - ConfigurationHelper.SetValue(ConfigurationKeys.EnablePenguin, value.ToString()); - } - } - - private bool _enableYituliu = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.EnableYituliu, bool.TrueString)); - - /// - /// Gets or sets a value indicating whether to enable yituliu upload. - /// - public bool EnableYituliu - { - get => _enableYituliu; - set - { - SetAndNotify(ref _enableYituliu, value); - ConfigurationHelper.SetValue(ConfigurationKeys.EnableYituliu, value.ToString()); - } - } - - private bool _isDrGrandet = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.IsDrGrandet, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether to use DrGrandet mode. - /// - public bool IsDrGrandet - { - get => _isDrGrandet; - set - { - SetAndNotify(ref _isDrGrandet, value); - ConfigurationHelper.SetValue(ConfigurationKeys.IsDrGrandet, value.ToString()); - } - } - - private bool _useAlternateStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseAlternateStage, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether to use alternate stage. - /// - public bool UseAlternateStage - { - get => _useAlternateStage; - set - { - SetAndNotify(ref _useAlternateStage, value); - ConfigurationHelper.SetValue(ConfigurationKeys.UseAlternateStage, value.ToString()); - if (value) - { - HideUnavailableStage = false; - } - } - } - - private bool _useRemainingSanityStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseRemainingSanityStage, bool.TrueString)); - - public bool UseRemainingSanityStage - { - get => _useRemainingSanityStage; - set - { - SetAndNotify(ref _useRemainingSanityStage, value); - Instances.TaskQueueViewModel.UseRemainingSanityStage = value; - ConfigurationHelper.SetValue(ConfigurationKeys.UseRemainingSanityStage, value.ToString()); - } - } - - private bool _allowUseStoneSave = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AllowUseStoneSave, bool.FalseString)); - - public bool AllowUseStoneSave - { - get => _allowUseStoneSave; - set - { - if (value) - { - var result = MessageBoxHelper.Show( - LocalizationHelper.GetString("AllowUseStoneSaveWarning"), - LocalizationHelper.GetString("Warning"), - MessageBoxButton.YesNo, - MessageBoxImage.Warning, - no: LocalizationHelper.GetString("Confirm"), - yes: LocalizationHelper.GetString("Cancel"), - iconBrushKey: "DangerBrush"); - if (result != MessageBoxResult.No) - { - return; - } - } - - SetAndNotify(ref _allowUseStoneSave, value); - ConfigurationHelper.SetValue(ConfigurationKeys.AllowUseStoneSave, value.ToString()); - } - } - - private bool _useExpiringMedicine = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseExpiringMedicine, bool.FalseString)); - - public bool UseExpiringMedicine - { - get => _useExpiringMedicine; - set - { - SetAndNotify(ref _useExpiringMedicine, value); - ConfigurationHelper.SetValue(ConfigurationKeys.UseExpiringMedicine, value.ToString()); - Instances.TaskQueueViewModel.SetFightParams(); - } - } - - private bool _hideUnavailableStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideUnavailableStage, bool.TrueString)); - - /// - /// Gets or sets a value indicating whether to hide unavailable stages. - /// - public bool HideUnavailableStage - { - get => _hideUnavailableStage; - set - { - SetAndNotify(ref _hideUnavailableStage, value); - ConfigurationHelper.SetValue(ConfigurationKeys.HideUnavailableStage, value.ToString()); - - if (value) - { - UseAlternateStage = false; - } - - Instances.TaskQueueViewModel.UpdateStageList(); - } - } - - private bool _hideSeries = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideSeries, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether to hide series. - /// - public bool HideSeries - { - get => _hideSeries; - set - { - SetAndNotify(ref _hideSeries, value); - ConfigurationHelper.SetValue(ConfigurationKeys.HideSeries, value.ToString()); - } - } - - private bool _customStageCode = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomStageCode, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether to use custom stage code. - /// - public bool CustomStageCode - { - get => _customStageCode; - set - { - SetAndNotify(ref _customStageCode, value); - ConfigurationHelper.SetValue(ConfigurationKeys.CustomStageCode, value.ToString()); - Instances.TaskQueueViewModel.CustomStageCode = value; - } - } - - #endregion 刷理智设置 - #region 自动公招设置 /// @@ -1124,6 +939,55 @@ namespace MaaWpfGui.ViewModels.UI #endregion SettingsGuide + #region 企鹅和一图流上报 + + private string _penguinId = ConfigurationHelper.GetValue(ConfigurationKeys.PenguinId, string.Empty); + + /// + /// Gets or sets the id of PenguinStats. + /// + public string PenguinId + { + get => _penguinId; + set + { + SetAndNotify(ref _penguinId, value); + ConfigurationHelper.SetValue(ConfigurationKeys.PenguinId, value); + } + } + + private bool _enablePenguin = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.EnablePenguin, bool.TrueString)); + + /// + /// Gets or sets a value indicating whether to enable penguin upload. + /// + public bool EnablePenguin + { + get => _enablePenguin; + set + { + SetAndNotify(ref _enablePenguin, value); + ConfigurationHelper.SetValue(ConfigurationKeys.EnablePenguin, value.ToString()); + } + } + + private bool _enableYituliu = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.EnableYituliu, bool.TrueString)); + + /// + /// Gets or sets a value indicating whether to enable yituliu upload. + /// + public bool EnableYituliu + { + get => _enableYituliu; + set + { + SetAndNotify(ref _enableYituliu, value); + ConfigurationHelper.SetValue(ConfigurationKeys.EnableYituliu, value.ToString()); + } + } + + #endregion 企鹅和一图流上报 + #region 设置页面列表和滚动视图联动绑定 private enum NotifyType @@ -1290,7 +1154,7 @@ namespace MaaWpfGui.ViewModels.UI // EventArgs 不能省略,否则会报错 // ReSharper disable once UnusedMember.Global // ReSharper disable once UnusedParameter.Global - public void MakeComboBoxSearchable(object sender, EventArgs e) + public static void MakeComboBoxSearchable(object sender, EventArgs e) { (sender as ComboBox)?.MakeComboBoxSearchable(); } diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index afee546655..8afe4ea507 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -24,6 +24,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Timers; using System.Windows; +using System.Windows.Forms; using MaaWpfGui.Constants; using MaaWpfGui.Extensions; using MaaWpfGui.Helper; @@ -39,8 +40,8 @@ using Newtonsoft.Json.Linq; using Serilog; using Stylet; using StyletIoC; +using static System.Windows.Forms.AxHost; using Application = System.Windows.Application; -using ComboBox = System.Windows.Controls.ComboBox; using Screen = Stylet.Screen; namespace MaaWpfGui.ViewModels.UI @@ -305,7 +306,7 @@ namespace MaaWpfGui.ViewModels.UI public bool Closing { get; set; } - private readonly Timer _timer = new(); + private readonly System.Timers.Timer _timer = new(); public bool ConfirmExit() { @@ -541,7 +542,7 @@ namespace MaaWpfGui.ViewModels.UI AddLog(LocalizationHelper.GetString("CloseArknightsFailed"), UiLogColor.Error); } - ResetFightVariables(); + SettingsViewModel.FightTask.ResetFightVariables(); ResetTaskSelection(); RefreshCustomInfrastPlanIndexByPeriod(); } @@ -646,7 +647,7 @@ namespace MaaWpfGui.ViewModels.UI TaskItemViewModels = new ObservableCollection(tempOrderList); TaskItemViewModels.CollectionChanged += TaskItemSelectionChanged; - InitDrops(); + SettingsViewModel.FightTask.InitDrops(); NeedToUpdateDatePrompt(); UpdateDatePromptAndStagesLocally(); RefreshCustomInfrastPlan(); @@ -659,25 +660,21 @@ namespace MaaWpfGui.ViewModels.UI private DayOfWeek _curDayOfWeek; + public DayOfWeek CurDayOfWeek => _curDayOfWeek; + /// /// Determine whether the specified stage is open /// /// stage name /// Whether the specified stage is open - public bool IsStageOpen(string name) - { - return _stageManager.IsStageOpen(name, _curDayOfWeek); - } + public bool IsStageOpen(string name) => _stageManager.IsStageOpen(name, _curDayOfWeek); /// /// Returns the valid stage if it is open, otherwise returns an empty string. /// /// The stage to check. /// The valid stage or an empty string. - public string GetValidStage(string stage) - { - return IsStageOpen(stage) ? stage : string.Empty; - } + public string GetValidStage(string stage) => IsStageOpen(stage) ? stage : string.Empty; /// /// 更新日期提示和关卡列表 @@ -698,94 +695,12 @@ namespace MaaWpfGui.ViewModels.UI UpdateDatePromptAndStagesLocally(); } - /// - /// Updates stage list. - /// 使用手动输入时,只更新关卡列表,不更新关卡选择 - /// 使用隐藏当日不开放时,更新关卡列表,关卡选择为未开放的关卡时清空 - /// 使用备选关卡时,更新关卡列表,关卡选择为未开放的关卡时在关卡列表中添加对应未开放关卡,避免清空导致进入上次关卡 - /// 啥都不选时,更新关卡列表,关卡选择为未开放的关卡时在关卡列表中添加对应未开放关卡,避免清空导致进入上次关卡 - /// 除手动输入外所有情况下,如果剩余理智为未开放的关卡,会被清空 - /// - // FIXME: 被注入对象只能在private函数内使用,只有Model显示之后才会被注入。如果Model还没有触发OnInitialActivate时调用函数会NullPointerException - // 这个函数被列为public可见,意味着他注入对象前被调用 - public void UpdateStageList() - { - Execute.OnUIThread(() => - { - var settings = Instances.SettingsViewModel; - var hideUnavailableStage = settings.HideUnavailableStage; - var useAlternateStage = settings.UseAlternateStage; - - EnableSetFightParams = false; - - var stage1 = Stage1 ?? string.Empty; - var stage2 = Stage2 ?? string.Empty; - var stage3 = Stage3 ?? string.Empty; - var rss = RemainingSanityStage ?? string.Empty; - - var tempStageList = hideUnavailableStage - ? _stageManager.GetStageList(_curDayOfWeek).ToList() - : _stageManager.GetStageList().ToList(); - - var tempRemainingSanityStageList = _stageManager.GetStageList().ToList(); - - if (CustomStageCode) - { - // 7% - // 使用自定义的时候不做处理 - } - else if (hideUnavailableStage) - { - // 15% - stage1 = GetValidStage(stage1); - stage2 = GetValidStage(stage2); - stage3 = GetValidStage(stage3); - } - else if (useAlternateStage) - { - // 11% - AddStagesIfNotExist([stage1, stage2, stage3], tempStageList); - } - else - { - // 啥都没选 - AddStageIfNotExist(stage1, tempStageList); - - // 避免关闭了使用备用关卡后,始终添加备用关卡中的未开放关卡 - stage2 = GetValidStage(stage2); - stage3 = GetValidStage(stage3); - } - - // rss 如果结束后还选择了不开放的关卡,刷理智任务会报错 - rss = IsStageOpen(rss) ? rss : string.Empty; - - if (tempRemainingSanityStageList.Any(item => item.Value == string.Empty)) - { - var itemToRemove = tempRemainingSanityStageList.First(item => item.Value == string.Empty); - tempRemainingSanityStageList.Remove(itemToRemove); - } - - tempRemainingSanityStageList.Insert(0, new CombinedData { Display = LocalizationHelper.GetString("NoUse"), Value = string.Empty }); - - UpdateObservableCollection(StageList, tempStageList); - UpdateObservableCollection(RemainingSanityStageList, tempRemainingSanityStageList); - - _stage1Fallback = stage1; - Stage1 = stage1; - Stage2 = stage2; - Stage3 = stage3; - RemainingSanityStage = rss; - - EnableSetFightParams = true; - }); - } - /// /// 更新 ObservableCollection,确保不替换原集合,而是增删项 /// /// 原始 ObservableCollection /// 新的列表 - private static void UpdateObservableCollection(ObservableCollection originalCollection, List newList) + public static void UpdateObservableCollection(ObservableCollection originalCollection, List newList) { originalCollection.Clear(); @@ -795,30 +710,6 @@ namespace MaaWpfGui.ViewModels.UI } } - private void AddStagesIfNotExist(IEnumerable stages, List stageList) - { - foreach (var stage in stages) - { - AddStageIfNotExist(stage, stageList); - } - } - - private void AddStageIfNotExist(string stage, List stageList) - { - if (stageList.Any(x => x.Value == stage)) - { - return; - } - - if (!_stageManager.IsStageInStageList(stage)) - { - _stageManager.AddUnOpenStage(stage); - } - - var stageInfo = _stageManager.GetStageInfo(stage); - stageList.Add(stageInfo); - } - private bool NeedToUpdateDatePrompt() { var now = DateTime.UtcNow.ToYjDateTime(); @@ -860,7 +751,7 @@ namespace MaaWpfGui.ViewModels.UI var builder = new StringBuilder(LocalizationHelper.GetString("TodaysStageTip") + "\n"); // Closed activity stages - foreach (var stage in Stages) + foreach (var stage in SettingsViewModel.FightTask.Stages) { if (stage == null || _stageManager.GetStageInfo(stage)?.IsActivityClosed() != true) { @@ -886,6 +777,105 @@ namespace MaaWpfGui.ViewModels.UI StagesOfToday = prompt; } + /// + /// Updates stage list. + /// 使用手动输入时,只更新关卡列表,不更新关卡选择 + /// 使用隐藏当日不开放时,更新关卡列表,关卡选择为未开放的关卡时清空 + /// 使用备选关卡时,更新关卡列表,关卡选择为未开放的关卡时在关卡列表中添加对应未开放关卡,避免清空导致进入上次关卡 + /// 啥都不选时,更新关卡列表,关卡选择为未开放的关卡时在关卡列表中添加对应未开放关卡,避免清空导致进入上次关卡 + /// 除手动输入外所有情况下,如果剩余理智为未开放的关卡,会被清空 + /// + // FIXME: 被注入对象只能在private函数内使用,只有Model显示之后才会被注入。如果Model还没有触发OnInitialActivate时调用函数会NullPointerException + // 这个函数被列为public可见,意味着他注入对象前被调用 + public void UpdateStageList() + { + Execute.OnUIThread(() => + { + var hideUnavailableStage = SettingsViewModel.FightTask.HideUnavailableStage; + + Instances.TaskQueueViewModel.EnableSetFightParams = false; + + var stage1 = SettingsViewModel.FightTask.Stage1 ?? string.Empty; + var stage2 = SettingsViewModel.FightTask.Stage2 ?? string.Empty; + var stage3 = SettingsViewModel.FightTask.Stage3 ?? string.Empty; + var rss = SettingsViewModel.FightTask.RemainingSanityStage ?? string.Empty; + + var tempStageList = hideUnavailableStage + ? _stageManager.GetStageList(Instances.TaskQueueViewModel.CurDayOfWeek).ToList() + : _stageManager.GetStageList().ToList(); + + var tempRemainingSanityStageList = _stageManager.GetStageList().ToList(); + + if (SettingsViewModel.FightTask.CustomStageCode) + { + // 7% + // 使用自定义的时候不做处理 + } + else if (hideUnavailableStage) + { + // 15% + stage1 = Instances.TaskQueueViewModel.GetValidStage(stage1); + stage2 = Instances.TaskQueueViewModel.GetValidStage(stage2); + stage3 = Instances.TaskQueueViewModel.GetValidStage(stage3); + } + else if (SettingsViewModel.FightTask.UseAlternateStage) + { + // 11% + AddStagesIfNotExist([stage1, stage2, stage3], tempStageList); + } + else + { + // 啥都没选 + AddStageIfNotExist(stage1, tempStageList); + + // 避免关闭了使用备用关卡后,始终添加备用关卡中的未开放关卡 + stage2 = Instances.TaskQueueViewModel.GetValidStage(stage2); + stage3 = Instances.TaskQueueViewModel.GetValidStage(stage3); + } + + // rss 如果结束后还选择了不开放的关卡,刷理智任务会报错 + rss = Instances.TaskQueueViewModel.IsStageOpen(rss) ? rss : string.Empty; + + if (tempRemainingSanityStageList.Any(item => item.Value == string.Empty)) + { + var itemToRemove = tempRemainingSanityStageList.First(item => item.Value == string.Empty); + tempRemainingSanityStageList.Remove(itemToRemove); + } + + tempRemainingSanityStageList.Insert(0, new CombinedData { Display = LocalizationHelper.GetString("NoUse"), Value = string.Empty }); + + UpdateObservableCollection(SettingsViewModel.FightTask.StageList, tempStageList); + UpdateObservableCollection(SettingsViewModel.FightTask.RemainingSanityStageList, tempRemainingSanityStageList); + + SettingsViewModel.FightTask._stage1Fallback = stage1; + SettingsViewModel.FightTask.Stage1 = stage1; + SettingsViewModel.FightTask.Stage2 = stage2; + SettingsViewModel.FightTask.Stage3 = stage3; + SettingsViewModel.FightTask.RemainingSanityStage = rss; + + Instances.TaskQueueViewModel.EnableSetFightParams = true; + }); + } + + private void AddStagesIfNotExist(IEnumerable stages, List stageList) + { + foreach (var stage in stages) + { + AddStageIfNotExist(stage, stageList); + } + } + + private void AddStageIfNotExist(string stage, List stageList) + { + if (stageList.Any(x => x.Value == stage)) + { + return; + } + + var stageInfo = _stageManager.GetStageInfo(stage); + stageList.Add(stageInfo); + } + private string _stagesOfToday = string.Empty; /// @@ -1498,49 +1488,49 @@ namespace MaaWpfGui.ViewModels.UI private bool AppendFight() { int medicine = 0; - if (UseMedicine) + if (SettingsViewModel.FightTask.UseMedicine) { - if (!int.TryParse(MedicineNumber, out medicine)) + if (!int.TryParse(SettingsViewModel.FightTask.MedicineNumber, out medicine)) { medicine = 0; } } int stone = 0; - if (UseStone) + if (SettingsViewModel.FightTask.UseStone) { - if (!int.TryParse(StoneNumber, out stone)) + if (!int.TryParse(SettingsViewModel.FightTask.StoneNumber, out stone)) { stone = 0; } } int times = int.MaxValue; - if (HasTimesLimited) + if (SettingsViewModel.FightTask.HasTimesLimited) { - if (!int.TryParse(MaxTimes, out times)) + if (!int.TryParse(SettingsViewModel.FightTask.MaxTimes, out times)) { times = 0; } } - if (!int.TryParse(Series, out var series)) + if (!int.TryParse(SettingsViewModel.FightTask.Series, out var series)) { series = 1; } int dropsQuantity = 0; - if (IsSpecifiedDrops) + if (SettingsViewModel.FightTask.IsSpecifiedDrops) { - if (!int.TryParse(DropsQuantity, out dropsQuantity)) + if (!int.TryParse(SettingsViewModel.FightTask.DropsQuantity, out dropsQuantity)) { dropsQuantity = 0; } } - string curStage = Stage; + string curStage = SettingsViewModel.FightTask.Stage; - bool mainFightRet = Instances.AsstProxy.AsstAppendFight(curStage, medicine, stone, times, series, DropsItemId, dropsQuantity); + bool mainFightRet = Instances.AsstProxy.AsstAppendFight(curStage, medicine, stone, times, series, SettingsViewModel.FightTask.DropsItemId, dropsQuantity); if (!mainFightRet) { @@ -1548,9 +1538,9 @@ namespace MaaWpfGui.ViewModels.UI return false; } - if ((curStage == "Annihilation") && Instances.SettingsViewModel.UseAlternateStage) + if ((curStage == "Annihilation") && SettingsViewModel.FightTask.UseAlternateStage) { - foreach (var stage in Stages) + foreach (var stage in SettingsViewModel.FightTask.Stages) { if (!IsStageOpen(stage) || (stage == curStage)) { @@ -1563,15 +1553,15 @@ namespace MaaWpfGui.ViewModels.UI } } - if (mainFightRet && UseRemainingSanityStage && !string.IsNullOrEmpty(RemainingSanityStage)) + if (mainFightRet && SettingsViewModel.FightTask.UseRemainingSanityStage && !string.IsNullOrEmpty(SettingsViewModel.FightTask.RemainingSanityStage)) { - return Instances.AsstProxy.AsstAppendFight(RemainingSanityStage, 0, 0, int.MaxValue, 1, string.Empty, 0, false); + return Instances.AsstProxy.AsstAppendFight(SettingsViewModel.FightTask.RemainingSanityStage, 0, 0, int.MaxValue, 1, string.Empty, 0, false); } return mainFightRet; } - private bool EnableSetFightParams { get; set; } = true; + public bool EnableSetFightParams { get; set; } = true; /// /// Sets parameters. @@ -1584,57 +1574,57 @@ namespace MaaWpfGui.ViewModels.UI } int medicine = 0; - if (UseMedicine) + if (SettingsViewModel.FightTask.UseMedicine) { - if (!int.TryParse(MedicineNumber, out medicine)) + if (!int.TryParse(SettingsViewModel.FightTask.MedicineNumber, out medicine)) { medicine = 0; } } int stone = 0; - if (UseStone) + if (SettingsViewModel.FightTask.UseStone) { - if (!int.TryParse(StoneNumber, out stone)) + if (!int.TryParse(SettingsViewModel.FightTask.StoneNumber, out stone)) { stone = 0; } } int times = int.MaxValue; - if (HasTimesLimited) + if (SettingsViewModel.FightTask.HasTimesLimited) { - if (!int.TryParse(MaxTimes, out times)) + if (!int.TryParse(SettingsViewModel.FightTask.MaxTimes, out times)) { times = 0; } } - if (!int.TryParse(Series, out var series)) + if (!int.TryParse(SettingsViewModel.FightTask.Series, out var series)) { series = 1; } int dropsQuantity = 0; - if (IsSpecifiedDrops) + if (SettingsViewModel.FightTask.IsSpecifiedDrops) { - if (!int.TryParse(DropsQuantity, out dropsQuantity)) + if (!int.TryParse(SettingsViewModel.FightTask.DropsQuantity, out dropsQuantity)) { dropsQuantity = 0; } } - Instances.AsstProxy.AsstSetFightTaskParams(Stage, medicine, stone, times, series, DropsItemId, dropsQuantity); + Instances.AsstProxy.AsstSetFightTaskParams(SettingsViewModel.FightTask.Stage, medicine, stone, times, series, SettingsViewModel.FightTask.DropsItemId, dropsQuantity); } - private void SetFightRemainingSanityParams() + public void SetFightRemainingSanityParams() { if (!Instances.AsstProxy.ContainsTask(AsstProxy.TaskType.FightRemainingSanity)) { return; } - Instances.AsstProxy.AsstSetFightTaskParams(RemainingSanityStage, 0, 0, int.MaxValue, 1, string.Empty, 0, false); + Instances.AsstProxy.AsstSetFightTaskParams(SettingsViewModel.FightTask.RemainingSanityStage, 0, 0, int.MaxValue, 1, string.Empty, 0, false); } private void SetInfrastParams() @@ -1702,7 +1692,7 @@ namespace MaaWpfGui.ViewModels.UI blackList = blackList.Union(_blackCharacterListMapping[SettingsViewModel.GameSettings.ClientType]); return Instances.AsstProxy.AsstAppendMall( - !string.IsNullOrEmpty(this.Stage) && SettingsViewModel.MallTask.CreditFightTaskEnabled, + !string.IsNullOrEmpty(SettingsViewModel.FightTask.Stage) && SettingsViewModel.MallTask.CreditFightTaskEnabled, SettingsViewModel.MallTask.CreditFightSelectFormation, SettingsViewModel.MallTask.CreditVisitFriendsEnabled, SettingsViewModel.MallTask.CreditShopping, @@ -2500,250 +2490,6 @@ namespace MaaWpfGui.ViewModels.UI } */ - /// - /// Gets or private sets the list of series. - /// - public List SeriesList { get; private set; } = ["1", "2", "3", "4", "5", "6"]; - - private ObservableCollection _stageList = []; - - /// - /// Gets or private sets the list of stages. - /// - public ObservableCollection StageList - { - get => _stageList; - private set => SetAndNotify(ref _stageList, value); - } - - private ObservableCollection _remainingSanityStageList = []; - - public ObservableCollection RemainingSanityStageList - { - get => _remainingSanityStageList; - private set => SetAndNotify(ref _remainingSanityStageList, value); - } - - /// - /// Gets the stage. - /// - public string Stage - { - get - { - Stage1 ??= _stage1Fallback; - - if (!Instances.SettingsViewModel.UseAlternateStage) - { - return Stage1; - } - - if (IsStageOpen(Stage1)) - { - return Stage1; - } - - if (IsStageOpen(Stage2)) - { - return Stage2; - } - - return IsStageOpen(Stage3) ? Stage3 : Stage1; - } - } - - private readonly Dictionary _stageDictionary = new() - { - { "AN", "Annihilation" }, - { "剿灭", "Annihilation" }, - { "CE", "CE-6" }, - { "龙门币", "CE-6" }, - { "LS", "LS-6" }, - { "经验", "LS-6" }, - { "狗粮", "LS-6" }, - { "CA", "CA-5" }, - { "技能", "CA-5" }, - { "AP", "AP-5" }, - { "红票", "AP-5" }, - { "SK", "SK-5" }, - { "碳", "SK-5" }, - { "炭", "SK-5" }, - }; - - private string ToUpperAndCheckStage(string value) - { - if (string.IsNullOrEmpty(value)) - { - return value; - } - - string upperValue = value.ToUpper(); - if (_stageDictionary.TryGetValue(upperValue, out var stage)) - { - return stage; - } - - if (StageList == null) - { - return value; - } - - foreach (var item in StageList) - { - if (upperValue == item.Value.ToUpper() || upperValue == item.Display.ToUpper()) - { - return item.Value; - } - } - - return value; - } - - public string[] Stages => [Stage1, Stage2, Stage3]; - - /// Try to fix: issues#5742. 关卡选择为 null 时的一个补丁,可能是 StageList 改变后,wpf binding 延迟更新的问题。 - private string _stage1Fallback = ConfigurationHelper.GetValue(ConfigurationKeys.Stage1, string.Empty) ?? string.Empty; - - private string _stage1 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage1, string.Empty) ?? string.Empty; - - /// - /// Gets or sets the stage1. - /// - public string Stage1 - { - get => _stage1; - set - { - if (_stage1 == value) - { - SetAndNotify(ref _stage1, value); - return; - } - - if (CustomStageCode) - { - // 从后往前删 - if (_stage1?.Length != 3 && value != null) - { - value = ToUpperAndCheckStage(value); - } - } - - SetAndNotify(ref _stage1, value); - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.Stage1, value); - UpdateDatePrompt(); - } - } - - private string _stage2 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage2, string.Empty) ?? string.Empty; - - /// - /// Gets or sets the stage2. - /// - public string Stage2 - { - get => _stage2; - set - { - if (_stage2 == value) - { - SetAndNotify(ref _stage2, value); - return; - } - - if (CustomStageCode) - { - if (_stage2?.Length != 3 && value != null) - { - value = ToUpperAndCheckStage(value); - } - } - - SetAndNotify(ref _stage2, value); - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.Stage2, value); - UpdateDatePrompt(); - } - } - - private string _stage3 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage3, string.Empty) ?? string.Empty; - - /// - /// Gets or sets the stage2. - /// - public string Stage3 - { - get => _stage3; - set - { - if (_stage3 == value) - { - SetAndNotify(ref _stage3, value); - return; - } - - if (CustomStageCode) - { - if (_stage3?.Length != 3 && value != null) - { - value = ToUpperAndCheckStage(value); - } - } - - SetAndNotify(ref _stage3, value); - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.Stage3, value); - UpdateDatePrompt(); - } - } - - private bool _useRemainingSanityStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseRemainingSanityStage, bool.TrueString)); - - public bool UseRemainingSanityStage - { - get => _useRemainingSanityStage; - set => SetAndNotify(ref _useRemainingSanityStage, value); - } - - private bool _customStageCode = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomStageCode, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether to use custom stage code. - /// - public bool CustomStageCode - { - get => _customStageCode; - set => SetAndNotify(ref _customStageCode, value); - } - - private string _remainingSanityStage = ConfigurationHelper.GetValue(ConfigurationKeys.RemainingSanityStage, string.Empty) ?? string.Empty; - - public string RemainingSanityStage - { - get => _remainingSanityStage; - set - { - if (_remainingSanityStage == value) - { - SetAndNotify(ref _remainingSanityStage, value); - return; - } - - if (CustomStageCode) - { - if (_remainingSanityStage?.Length != 3 && value != null) - { - value = ToUpperAndCheckStage(value); - } - } - - SetAndNotify(ref _remainingSanityStage, value); - SetFightRemainingSanityParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.RemainingSanityStage, value); - } - } - private bool _customInfrastEnabled = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastEnabled, bool.FalseString)); public bool CustomInfrastEnabled @@ -3002,393 +2748,5 @@ namespace MaaWpfGui.ViewModels.UI ++CustomInfrastPlanIndex; } - - /// - /// Reset unsaved battle parameters. - /// - public void ResetFightVariables() - { - if (UseStoneWithNull == null) - { - UseStone = false; - } - - if (UseMedicineWithNull == null) - { - UseMedicine = false; - } - - if (HasTimesLimitedWithNull == null) - { - HasTimesLimited = false; - } - - if (IsSpecifiedDropsWithNull == null) - { - IsSpecifiedDrops = false; - } - } - - private bool? _useMedicineWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether to use medicine with null. - /// - public bool? UseMedicineWithNull - { - get => _useMedicineWithNull; - set - { - SetAndNotify(ref _useMedicineWithNull, value); - if (value == false) - { - UseStone = false; - } - - SetFightParams(); - value ??= false; - ConfigurationHelper.SetValue(ConfigurationKeys.UseMedicine, value.ToString()); - } - } - - /// - /// Gets or sets a value indicating whether to use medicine. - /// - private bool UseMedicine - { - get => UseMedicineWithNull != false; - set => UseMedicineWithNull = value; - } - - private string _medicineNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicineQuantity, "999"); - - /// - /// Gets or sets the amount of medicine used. - /// - public string MedicineNumber - { - get => _medicineNumber; - set - { - if (_medicineNumber == value) - { - return; - } - - SetAndNotify(ref _medicineNumber, value); - - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.UseMedicineQuantity, MedicineNumber); - } - } - - public static string UseStoneString => LocalizationHelper.GetString("UseOriginitePrime"); - - private bool? _useStoneWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, bool.FalseString)) && - Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseStone, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether to use originiums with null. - /// - public bool? UseStoneWithNull - { - get => _useStoneWithNull; - set - { - if (!TaskSettingDataContext.AllowUseStoneSave && value == true) - { - value = null; - } - - SetAndNotify(ref _useStoneWithNull, value); - if (value != false) - { - MedicineNumber = "999"; - if (!UseMedicine) - { - UseMedicineWithNull = value; - } - } - - // IsEnabled="{c:Binding UseStone}" - NotifyOfPropertyChange(nameof(UseStone)); - - SetFightParams(); - if (TaskSettingDataContext.AllowUseStoneSave) - { - ConfigurationHelper.SetValue(ConfigurationKeys.UseStone, (value ?? false).ToString()); - } - } - } - - /// - /// Gets or sets a value indicating whether to use originiums. - /// - // ReSharper disable once MemberCanBePrivate.Global - public bool UseStone - { - get => UseStoneWithNull != false; - set => UseStoneWithNull = value; - } - - private string _stoneNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseStoneQuantity, "0"); - - /// - /// Gets or sets the amount of originiums used. - /// - public string StoneNumber - { - get => _stoneNumber; - set - { - if (_stoneNumber == value) - { - return; - } - - SetAndNotify(ref _stoneNumber, value); - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.UseStoneQuantity, StoneNumber); - } - } - - private bool? _hasTimesLimitedWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.TimesLimited, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether the number of times is limited with null. - /// - public bool? HasTimesLimitedWithNull - { - get => _hasTimesLimitedWithNull; - set - { - SetAndNotify(ref _hasTimesLimitedWithNull, value); - SetFightParams(); - value ??= false; - ConfigurationHelper.SetValue(ConfigurationKeys.TimesLimited, value.ToString()); - } - } - - /// - /// Gets or sets a value indicating whether the number of times is limited. - /// - private bool HasTimesLimited - { - get => HasTimesLimitedWithNull != false; - set => HasTimesLimitedWithNull = value; - } - - private string _maxTimes = ConfigurationHelper.GetValue(ConfigurationKeys.TimesLimitedQuantity, "5"); - - /// - /// Gets or sets the max number of times. - /// - public string MaxTimes - { - get => _maxTimes; - set - { - if (MaxTimes == value) - { - return; - } - - SetAndNotify(ref _maxTimes, value); - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.TimesLimitedQuantity, MaxTimes); - } - } - - private string _series = ConfigurationHelper.GetValue(ConfigurationKeys.SeriesQuantity, "1"); - - /// - /// Gets or sets the max number of times. - /// - // 所以为啥这玩意是 string 呢?改配置的时候把上面那些也都改成 int 吧 - public string Series - { - get => _series; - set - { - if (_series == value) - { - return; - } - - SetAndNotify(ref _series, value); - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.SeriesQuantity, value); - } - } - - #region Drops - - private bool? _isSpecifiedDropsWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.DropsEnable, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether the drops are specified. - /// - public bool? IsSpecifiedDropsWithNull - { - get => _isSpecifiedDropsWithNull; - set - { - SetAndNotify(ref _isSpecifiedDropsWithNull, value); - SetFightParams(); - value ??= false; - ConfigurationHelper.SetValue(ConfigurationKeys.DropsEnable, value.ToString()); - } - } - - /// - /// Gets or sets a value indicating whether the drops are specified. - /// - private bool IsSpecifiedDrops - { - get => IsSpecifiedDropsWithNull != false; - set => IsSpecifiedDropsWithNull = value; - } - - /// - /// Gets the list of all drops. - /// - private List AllDrops { get; } = new(); - - /// - /// 关卡不可掉落的材料 - /// - private static readonly HashSet _excludedValues = - [ - "3213", "3223", "3233", "3243", // 双芯片 - "3253", "3263", "3273", "3283", // 双芯片 - "7001", "7002", "7003", "7004", // 许可 - "4004", "4005", // 凭证 - "3105", "3131", "3132", "3233", // 龙骨/加固建材 - "6001", // 演习券 - "3141", "4002", // 源石 - "32001", // 芯片助剂 - "30115", // 聚合剂 - "30125", // 双极纳米片 - "30135", // D32钢 - "30145", // 晶体电子单元 - "30155", // 烧结核凝晶 - ]; - - private void InitDrops() - { - foreach (var (val, value) in ItemListHelper.ArkItems) - { - // 不是数字的东西都是正常关卡不会掉的(大概吧) - if (!int.TryParse(val, out _)) - { - continue; - } - - var dis = value.Name; - - if (_excludedValues.Contains(val)) - { - continue; - } - - AllDrops.Add(new CombinedData { Display = dis, Value = val }); - } - - AllDrops.Sort((a, b) => string.Compare(a.Value, b.Value, StringComparison.Ordinal)); - DropsList = new ObservableCollection(AllDrops); - } - - /// - /// Gets or private sets the list of drops. - /// - public ObservableCollection DropsList { get; private set; } - - private string _dropsItemId = ConfigurationHelper.GetValue(ConfigurationKeys.DropsItemId, string.Empty); - - /// - /// Gets or sets the item ID of drops. - /// - public string DropsItemId - { - get => _dropsItemId; - set - { - SetAndNotify(ref _dropsItemId, value); - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.DropsItemId, DropsItemId); - } - } - - private string _dropsItemName = ConfigurationHelper.GetValue(ConfigurationKeys.DropsItemName, LocalizationHelper.GetString("NotSelected")); - - /// - /// Gets or sets the item Name of drops. - /// - public string DropsItemName - { - get => _dropsItemName; - set - { - SetAndNotify(ref _dropsItemName, value); - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.DropsItemName, DropsItemName); - } - } - - // UI 绑定的方法 - // ReSharper disable once UnusedMember.Global - public void DropsListDropDownClosed() - { - foreach (var item in DropsList) - { - if (DropsItemName != item.Display) - { - continue; - } - - DropsItemId = item.Value; - - if (DropsItemName != item.Display || DropsItemId != item.Value) - { - DropsItemName = LocalizationHelper.GetString("NotSelected"); - } - - return; - } - - DropsItemName = LocalizationHelper.GetString("NotSelected"); - } - - private string _dropsQuantity = ConfigurationHelper.GetValue(ConfigurationKeys.DropsQuantity, "5"); - - /// - /// Gets or sets the quantity of drops. - /// - public string DropsQuantity - { - get => _dropsQuantity; - set - { - SetAndNotify(ref _dropsQuantity, value); - SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.DropsQuantity, DropsQuantity); - } - } - - /// - /// Make comboBox searchable - /// - /// Event sender - /// Event args - // UI 绑定的方法 - // EventArgs 不能省略,否则会报错 - // ReSharper disable once UnusedMember.Global - // ReSharper disable once UnusedParameter.Global - public void MakeComboBoxSearchable(object sender, EventArgs e) - { - (sender as ComboBox)?.MakeComboBoxSearchable(); - } - - #endregion Drops } } diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs new file mode 100644 index 0000000000..74d7494668 --- /dev/null +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs @@ -0,0 +1,780 @@ +// +// MaaWpfGui - A part of the MaaCoreArknights project +// Copyright (C) 2021 MistEO and Contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License v3.0 only as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY +// + +#nullable enable +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows; +using MaaWpfGui.Constants; +using MaaWpfGui.Helper; +using MaaWpfGui.Services; +using MaaWpfGui.Utilities.ValueType; +using MaaWpfGui.ViewModels.UI; +using Stylet; + +namespace MaaWpfGui.ViewModels.UserControl.TaskQueue; + +/// +/// 刷理智 +/// +public class FightSettingsUserControlModel : PropertyChangedBase +{ + + private ObservableCollection _stageList = []; + + /// + /// Gets or private sets the list of stages. + /// + public ObservableCollection StageList + { + get => _stageList; + private set => SetAndNotify(ref _stageList, value); + } + + private ObservableCollection _remainingSanityStageList = []; + + public ObservableCollection RemainingSanityStageList + { + get => _remainingSanityStageList; + private set => SetAndNotify(ref _remainingSanityStageList, value); + } + + /// + /// Gets the stage. + /// + public string Stage + { + get + { + Stage1 ??= _stage1Fallback; + + if (!SettingsViewModel.FightTask.UseAlternateStage) + { + return Stage1; + } + + if (Instances.TaskQueueViewModel.IsStageOpen(Stage1)) + { + return Stage1; + } + + if (Instances.TaskQueueViewModel.IsStageOpen(Stage2)) + { + return Stage2; + } + + return Instances.TaskQueueViewModel.IsStageOpen(Stage3) ? Stage3 : Stage1; + } + } + + private readonly Dictionary _stageDictionary = new() + { + { "AN", "Annihilation" }, + { "剿灭", "Annihilation" }, + { "CE", "CE-6" }, + { "龙门币", "CE-6" }, + { "LS", "LS-6" }, + { "经验", "LS-6" }, + { "狗粮", "LS-6" }, + { "CA", "CA-5" }, + { "技能", "CA-5" }, + { "AP", "AP-5" }, + { "红票", "AP-5" }, + { "SK", "SK-5" }, + { "碳", "SK-5" }, + { "炭", "SK-5" }, + }; + + /// + /// Gets or private sets the list of series. + /// + public List SeriesList { get; private set; } = ["1", "2", "3", "4", "5", "6"]; + + public string?[] Stages => [Stage1, Stage2, Stage3]; + + /// Try to fix: issues#5742. 关卡选择为 null 时的一个补丁,可能是 StageList 改变后,wpf binding 延迟更新的问题。 + public string _stage1Fallback = ConfigurationHelper.GetValue(ConfigurationKeys.Stage1, string.Empty) ?? string.Empty; + + private string? _stage1 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage1, string.Empty) ?? string.Empty; + + /// + /// Gets or sets the stage1. + /// + public string? Stage1 + { + get => _stage1; + set + { + if (_stage1 == value) + { + SetAndNotify(ref _stage1, value); + return; + } + + if (CustomStageCode) + { + // 从后往前删 + if (_stage1?.Length != 3 && value != null) + { + value = ToUpperAndCheckStage(value); + } + } + + SetAndNotify(ref _stage1, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.Stage1, value); + Instances.TaskQueueViewModel.UpdateDatePrompt(); + } + } + + private string _stage2 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage2, string.Empty) ?? string.Empty; + + /// + /// Gets or sets the stage2. + /// + public string Stage2 + { + get => _stage2; + set + { + if (_stage2 == value) + { + SetAndNotify(ref _stage2, value); + return; + } + + if (CustomStageCode) + { + if (_stage2?.Length != 3 && value != null) + { + value = ToUpperAndCheckStage(value); + } + } + + SetAndNotify(ref _stage2, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.Stage2, value); + Instances.TaskQueueViewModel.UpdateDatePrompt(); + } + } + + private string _stage3 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage3, string.Empty) ?? string.Empty; + + /// + /// Gets or sets the stage2. + /// + public string Stage3 + { + get => _stage3; + set + { + if (_stage3 == value) + { + SetAndNotify(ref _stage3, value); + return; + } + + if (CustomStageCode) + { + if (_stage3?.Length != 3 && value != null) + { + value = ToUpperAndCheckStage(value); + } + } + + SetAndNotify(ref _stage3, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.Stage3, value); + Instances.TaskQueueViewModel.UpdateDatePrompt(); + } + } + + private bool _useRemainingSanityStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseRemainingSanityStage, bool.TrueString)); + + public bool UseRemainingSanityStage + { + get => _useRemainingSanityStage; + set => SetAndNotify(ref _useRemainingSanityStage, value); + } + + private bool _customStageCode = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomStageCode, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to use custom stage code. + /// + public bool CustomStageCode + { + get => _customStageCode; + set => SetAndNotify(ref _customStageCode, value); + } + + private string _remainingSanityStage = ConfigurationHelper.GetValue(ConfigurationKeys.RemainingSanityStage, string.Empty) ?? string.Empty; + + public string RemainingSanityStage + { + get => _remainingSanityStage; + set + { + if (_remainingSanityStage == value) + { + SetAndNotify(ref _remainingSanityStage, value); + return; + } + + if (CustomStageCode) + { + if (_remainingSanityStage?.Length != 3 && value != null) + { + value = ToUpperAndCheckStage(value); + } + } + + SetAndNotify(ref _remainingSanityStage, value); + Instances.TaskQueueViewModel.SetFightRemainingSanityParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.RemainingSanityStage, value); + } + } + + /// + /// Reset unsaved battle parameters. + /// + public void ResetFightVariables() + { + if (UseStoneWithNull == null) + { + UseStone = false; + } + + if (UseMedicineWithNull == null) + { + UseMedicine = false; + } + + if (HasTimesLimitedWithNull == null) + { + HasTimesLimited = false; + } + + if (IsSpecifiedDropsWithNull == null) + { + IsSpecifiedDrops = false; + } + } + + private bool? _useMedicineWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to use medicine with null. + /// + public bool? UseMedicineWithNull + { + get => _useMedicineWithNull; + set + { + SetAndNotify(ref _useMedicineWithNull, value); + if (value == false) + { + UseStone = false; + } + + Instances.TaskQueueViewModel.SetFightParams(); + value ??= false; + ConfigurationHelper.SetValue(ConfigurationKeys.UseMedicine, value.ToString()); + } + } + + /// + /// Gets or sets a value indicating whether to use medicine. + /// + public bool UseMedicine + { + get => UseMedicineWithNull != false; + set => UseMedicineWithNull = value; + } + + private string _medicineNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicineQuantity, "999"); + + /// + /// Gets or sets the amount of medicine used. + /// + public string MedicineNumber + { + get => _medicineNumber; + set + { + if (_medicineNumber == value) + { + return; + } + + SetAndNotify(ref _medicineNumber, value); + + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.UseMedicineQuantity, MedicineNumber); + } + } + + public static string UseStoneString => LocalizationHelper.GetString("UseOriginitePrime"); + + private bool? _useStoneWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, bool.FalseString)) && + Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseStone, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to use originiums with null. + /// + public bool? UseStoneWithNull + { + get => _useStoneWithNull; + set + { + if (!SettingsViewModel.FightTask.AllowUseStoneSave && value == true) + { + value = null; + } + + SetAndNotify(ref _useStoneWithNull, value); + if (value != false) + { + MedicineNumber = "999"; + if (!UseMedicine) + { + UseMedicineWithNull = value; + } + } + + // IsEnabled="{c:Binding UseStone}" + NotifyOfPropertyChange(nameof(UseStone)); + + Instances.TaskQueueViewModel.SetFightParams(); + if (SettingsViewModel.FightTask.AllowUseStoneSave) + { + ConfigurationHelper.SetValue(ConfigurationKeys.UseStone, (value ?? false).ToString()); + } + } + } + + /// + /// Gets or sets a value indicating whether to use originiums. + /// + // ReSharper disable once MemberCanBePrivate.Global + public bool UseStone + { + get => UseStoneWithNull != false; + set => UseStoneWithNull = value; + } + + private string _stoneNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseStoneQuantity, "0"); + + /// + /// Gets or sets the amount of originiums used. + /// + public string StoneNumber + { + get => _stoneNumber; + set + { + if (_stoneNumber == value) + { + return; + } + + SetAndNotify(ref _stoneNumber, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.UseStoneQuantity, StoneNumber); + } + } + + private bool? _hasTimesLimitedWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.TimesLimited, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether the number of times is limited with null. + /// + public bool? HasTimesLimitedWithNull + { + get => _hasTimesLimitedWithNull; + set + { + SetAndNotify(ref _hasTimesLimitedWithNull, value); + Instances.TaskQueueViewModel.SetFightParams(); + value ??= false; + ConfigurationHelper.SetValue(ConfigurationKeys.TimesLimited, value.ToString()); + } + } + + /// + /// Gets or sets a value indicating whether the number of times is limited. + /// + public bool HasTimesLimited + { + get => HasTimesLimitedWithNull != false; + set => HasTimesLimitedWithNull = value; + } + + private string _maxTimes = ConfigurationHelper.GetValue(ConfigurationKeys.TimesLimitedQuantity, "5"); + + /// + /// Gets or sets the max number of times. + /// + public string MaxTimes + { + get => _maxTimes; + set + { + if (MaxTimes == value) + { + return; + } + + SetAndNotify(ref _maxTimes, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.TimesLimitedQuantity, MaxTimes); + } + } + + private string _series = ConfigurationHelper.GetValue(ConfigurationKeys.SeriesQuantity, "1"); + + /// + /// Gets or sets the max number of times. + /// + // 所以为啥这玩意是 string 呢?改配置的时候把上面那些也都改成 int 吧 + public string Series + { + get => _series; + set + { + if (_series == value) + { + return; + } + + SetAndNotify(ref _series, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.SeriesQuantity, value); + } + } + + #region Drops + + private bool? _isSpecifiedDropsWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.DropsEnable, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether the drops are specified. + /// + public bool? IsSpecifiedDropsWithNull + { + get => _isSpecifiedDropsWithNull; + set + { + SetAndNotify(ref _isSpecifiedDropsWithNull, value); + Instances.TaskQueueViewModel.SetFightParams(); + value ??= false; + ConfigurationHelper.SetValue(ConfigurationKeys.DropsEnable, value.ToString()); + } + } + + /// + /// Gets or sets a value indicating whether the drops are specified. + /// + public bool IsSpecifiedDrops + { + get => IsSpecifiedDropsWithNull != false; + set => IsSpecifiedDropsWithNull = value; + } + + /// + /// Gets the list of all drops. + /// + private List AllDrops { get; } = new(); + + /// + /// 关卡不可掉落的材料 + /// + private static readonly HashSet _excludedValues = + [ + "3213", "3223", "3233", "3243", // 双芯片 + "3253", "3263", "3273", "3283", // 双芯片 + "7001", "7002", "7003", "7004", // 许可 + "4004", "4005", // 凭证 + "3105", "3131", "3132", "3233", // 龙骨/加固建材 + "6001", // 演习券 + "3141", "4002", // 源石 + "32001", // 芯片助剂 + "30115", // 聚合剂 + "30125", // 双极纳米片 + "30135", // D32钢 + "30145", // 晶体电子单元 + "30155", // 烧结核凝晶 + ]; + + public void InitDrops() + { + foreach (var (val, value) in ItemListHelper.ArkItems) + { + // 不是数字的东西都是正常关卡不会掉的(大概吧) + if (!int.TryParse(val, out _)) + { + continue; + } + + var dis = value.Name; + + if (_excludedValues.Contains(val)) + { + continue; + } + + AllDrops.Add(new CombinedData { Display = dis, Value = val }); + } + + AllDrops.Sort((a, b) => string.Compare(a.Value, b.Value, StringComparison.Ordinal)); + DropsList = new ObservableCollection(AllDrops); + } + + /// + /// Gets or private sets the list of drops. + /// + public ObservableCollection DropsList { get; private set; } + + private string _dropsItemId = ConfigurationHelper.GetValue(ConfigurationKeys.DropsItemId, string.Empty); + + /// + /// Gets or sets the item ID of drops. + /// + public string DropsItemId + { + get => _dropsItemId; + set + { + SetAndNotify(ref _dropsItemId, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.DropsItemId, DropsItemId); + } + } + + private string _dropsItemName = ConfigurationHelper.GetValue(ConfigurationKeys.DropsItemName, LocalizationHelper.GetString("NotSelected")); + + /// + /// Gets or sets the item Name of drops. + /// + public string DropsItemName + { + get => _dropsItemName; + set + { + SetAndNotify(ref _dropsItemName, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.DropsItemName, DropsItemName); + } + } + + // UI 绑定的方法 + // ReSharper disable once UnusedMember.Global + public void DropsListDropDownClosed() + { + foreach (var item in DropsList) + { + if (DropsItemName != item.Display) + { + continue; + } + + DropsItemId = item.Value; + + if (DropsItemName != item.Display || DropsItemId != item.Value) + { + DropsItemName = LocalizationHelper.GetString("NotSelected"); + } + + return; + } + + DropsItemName = LocalizationHelper.GetString("NotSelected"); + } + + private string _dropsQuantity = ConfigurationHelper.GetValue(ConfigurationKeys.DropsQuantity, "5"); + + /// + /// Gets or sets the quantity of drops. + /// + public string DropsQuantity + { + get => _dropsQuantity; + set + { + SetAndNotify(ref _dropsQuantity, value); + Instances.TaskQueueViewModel.SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.DropsQuantity, DropsQuantity); + } + } + + #endregion Drops + + private bool _isDrGrandet = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.IsDrGrandet, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to use DrGrandet mode. + /// + public bool IsDrGrandet + { + get => _isDrGrandet; + set + { + SetAndNotify(ref _isDrGrandet, value); + ConfigurationHelper.SetValue(ConfigurationKeys.IsDrGrandet, value.ToString()); + } + } + + private bool _useAlternateStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseAlternateStage, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to use alternate stage. + /// + public bool UseAlternateStage + { + get => _useAlternateStage; + set + { + SetAndNotify(ref _useAlternateStage, value); + ConfigurationHelper.SetValue(ConfigurationKeys.UseAlternateStage, value.ToString()); + if (value) + { + HideUnavailableStage = false; + } + } + } + + private bool _allowUseStoneSave = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AllowUseStoneSave, bool.FalseString)); + + public bool AllowUseStoneSave + { + get => _allowUseStoneSave; + set + { + if (value) + { + var result = MessageBoxHelper.Show( + LocalizationHelper.GetString("AllowUseStoneSaveWarning"), + LocalizationHelper.GetString("Warning"), + MessageBoxButton.YesNo, + MessageBoxImage.Warning, + no: LocalizationHelper.GetString("Confirm"), + yes: LocalizationHelper.GetString("Cancel"), + iconBrushKey: "DangerBrush"); + if (result != MessageBoxResult.No) + { + return; + } + } + + SetAndNotify(ref _allowUseStoneSave, value); + ConfigurationHelper.SetValue(ConfigurationKeys.AllowUseStoneSave, value.ToString()); + } + } + + private bool _useExpiringMedicine = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseExpiringMedicine, bool.FalseString)); + + public bool UseExpiringMedicine + { + get => _useExpiringMedicine; + set + { + SetAndNotify(ref _useExpiringMedicine, value); + ConfigurationHelper.SetValue(ConfigurationKeys.UseExpiringMedicine, value.ToString()); + Instances.TaskQueueViewModel.SetFightParams(); + } + } + + private bool _hideUnavailableStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideUnavailableStage, bool.TrueString)); + + /// + /// Gets or sets a value indicating whether to hide unavailable stages. + /// + public bool HideUnavailableStage + { + get => _hideUnavailableStage; + set + { + SetAndNotify(ref _hideUnavailableStage, value); + ConfigurationHelper.SetValue(ConfigurationKeys.HideUnavailableStage, value.ToString()); + + if (value) + { + UseAlternateStage = false; + } + + Instances.TaskQueueViewModel.UpdateStageList(); + } + } + + private bool _hideSeries = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideSeries, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to hide series. + /// + public bool HideSeries + { + get => _hideSeries; + set + { + SetAndNotify(ref _hideSeries, value); + ConfigurationHelper.SetValue(ConfigurationKeys.HideSeries, value.ToString()); + } + } + + private string ToUpperAndCheckStage(string value) + { + if (string.IsNullOrEmpty(value)) + { + return value; + } + + string upperValue = value.ToUpper(); + if (_stageDictionary.TryGetValue(upperValue, out var stage)) + { + return stage; + } + + if (StageList == null) + { + return value; + } + + foreach (var item in StageList) + { + if (upperValue == item.Value.ToUpper() || upperValue == item.Display.ToUpper()) + { + return item.Value; + } + } + + return value; + } + + #region 双入口设置可见性 + + private bool _customInfrastPlanShowInFightSettings = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastPlanShowInFightSettings, bool.FalseString)); + + public bool CustomInfrastPlanShowInFightSettings + { + get => _customInfrastPlanShowInFightSettings; + set + { + SetAndNotify(ref _customInfrastPlanShowInFightSettings, value); + ConfigurationHelper.SetValue(ConfigurationKeys.CustomInfrastPlanShowInFightSettings, value.ToString()); + } + } + + #endregion +} diff --git a/src/MaaWpfGui/Views/UI/TaskQueueView.xaml b/src/MaaWpfGui/Views/UI/TaskQueueView.xaml index 544bf51f14..895f819662 100644 --- a/src/MaaWpfGui/Views/UI/TaskQueueView.xaml +++ b/src/MaaWpfGui/Views/UI/TaskQueueView.xaml @@ -240,7 +240,7 @@ PanningMode="Both" VerticalScrollBarVisibility="Auto"> - + - + @@ -42,7 +46,7 @@ Height="30" Margin="6" VerticalContentAlignment="Center" - Content="{c:Binding 'UseStoneString + (TaskSettingDataContext.AllowUseStoneSave ? "" : "*")'}" + Content="{c:Binding 'UseStoneString + (AllowUseStoneSave ? "" : "*")'}" IsChecked="{Binding UseStoneWithNull}" MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick, Target={x:Type helper:CheckBoxHelper}}" @@ -124,7 +128,8 @@ IsEditable="True" IsTextSearchEnabled="False" ItemsSource="{Binding DropsList}" - Loaded="{s:Action MakeComboBoxSearchable}" + Loaded="{s:Action MakeComboBoxSearchable, + Target={x:Type setting:SettingsViewModel}}" SelectedValue="{Binding DropsItemId}" SelectedValuePath="Value" Text="{Binding DropsItemName}" /> @@ -141,7 +146,7 @@ Value="{Binding DropsQuantity, UpdateSourceTrigger=PropertyChanged}" /> - + @@ -162,7 +167,8 @@ Height="30" Margin="6" VerticalContentAlignment="Center" - IsHitTestVisible="{c:Binding !FightTaskRunning}" + IsHitTestVisible="{c:Binding !FightTaskRunning, + Source={x:Static helper:Instances.TaskQueueViewModel}}" ItemsSource="{Binding SeriesList}" SelectedValue="{Binding Series}" /> @@ -182,7 +188,7 @@ TextAlignment="Center" TextWrapping="Wrap" /> - + - + + Visibility="{c:Binding UseAlternateStage}"> @@ -243,7 +251,8 @@ Margin="6" VerticalContentAlignment="Center" DisplayMemberPath="Display" - IsHitTestVisible="{c:Binding !FightTaskRunning}" + IsHitTestVisible="{c:Binding !FightTaskRunning, + Source={x:Static helper:Instances.TaskQueueViewModel}}" ItemsSource="{Binding StageList}" SelectedValue="{Binding Stage3}" SelectedValuePath="Value" /> @@ -254,7 +263,8 @@ VerticalContentAlignment="Center" DisplayMemberPath="Display" IsEnabled="{c:Binding UseRemainingSanityStage}" - IsHitTestVisible="{c:Binding !FightTaskRunning}" + IsHitTestVisible="{c:Binding !FightTaskRunning, + Source={x:Static helper:Instances.TaskQueueViewModel}}" ItemsSource="{Binding RemainingSanityStageList}" SelectedValue="{Binding RemainingSanityStage}" SelectedValuePath="Value" @@ -269,25 +279,28 @@ Height="30" Margin="6" VerticalContentAlignment="Center" - IsHitTestVisible="{c:Binding !FightTaskRunning}" + IsHitTestVisible="{c:Binding !FightTaskRunning, + Source={x:Static helper:Instances.TaskQueueViewModel}}" Text="{Binding Stage1, UpdateSourceTrigger=PropertyChanged}" ToolTip="{DynamicResource CustomStageCodeTip}" /> + Visibility="{c:Binding UseAlternateStage}"> @@ -296,14 +309,15 @@ Margin="6" VerticalContentAlignment="Center" IsEnabled="{c:Binding UseRemainingSanityStage}" - IsHitTestVisible="{c:Binding !FightTaskRunning}" + IsHitTestVisible="{c:Binding !FightTaskRunning, + Source={x:Static helper:Instances.TaskQueueViewModel}}" Text="{Binding RemainingSanityStage, UpdateSourceTrigger=PropertyChanged}" ToolTip="{DynamicResource UseRemainingSanityStageTip}" Visibility="{c:Binding UseRemainingSanityStage}" /> - + @@ -325,18 +339,16 @@ Margin="6" VerticalContentAlignment="Center" DisplayMemberPath="Display" - IsHitTestVisible="{c:Binding !InfrastTaskRunning}" - ItemsSource="{Binding CustomInfrastPlanList}" - SelectedValue="{Binding CustomInfrastPlanIndex}" + IsHitTestVisible="{c:Binding !InfrastTaskRunning, + Source={x:Static helper:Instances.TaskQueueViewModel}}" + ItemsSource="{Binding CustomInfrastPlanList, Source={x:Static helper:Instances.TaskQueueViewModel}}" + SelectedValue="{Binding CustomInfrastPlanIndex, Source={x:Static helper:Instances.TaskQueueViewModel}}" SelectedValuePath="Value" /> - + + IsChecked="{Binding CustomInfrastPlanShowInFightSettings, Source={x:Static setting:TaskQueueViewModel.TaskSettingVisibilities}}" /> - + + Text="{Binding PenguinId, Source={x:Static helper:Instances.SettingsViewModel}}" + Visibility="{c:Binding EnablePenguin, + Source={x:Static helper:Instances.SettingsViewModel}}" /> + IsChecked="{Binding EnableYituliu, Source={x:Static helper:Instances.SettingsViewModel}}" /> diff --git a/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml.cs b/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml.cs similarity index 95% rename from src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml.cs rename to src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml.cs index 18a471ef90..b9528f8ac2 100644 --- a/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml.cs +++ b/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml.cs @@ -16,7 +16,7 @@ using System.Windows; using System.Windows.Input; using MaaWpfGui.Helper; -namespace MaaWpfGui.Views.UserControl +namespace MaaWpfGui.Views.UserControl.TaskQueue { /// /// ParamSettingUserControl.xaml 的交互逻辑 diff --git a/src/MaaWpfGui/Views/UserControl/TaskQueue/RoguelikeSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/TaskQueue/RoguelikeSettingsUserControl.xaml index 471e71e72e..fd1478e523 100644 --- a/src/MaaWpfGui/Views/UserControl/TaskQueue/RoguelikeSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/TaskQueue/RoguelikeSettingsUserControl.xaml @@ -70,7 +70,7 @@ IsTextSearchEnabled="False" ItemsSource="{Binding RoguelikeCoreCharList}" Loaded="{s:Action MakeComboBoxSearchable, - Target={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}" + Target={x:Type setting:SettingsViewModel}}" ToolTip="{DynamicResource StartingCoreCharTip}">