From b60f8ffd00e9c1608d711d20f02617cd8ec0213e Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Thu, 7 Aug 2025 11:44:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20wpf=E5=88=B7=E7=90=86=E6=99=BAUI?= =?UTF-8?q?=E5=8F=98=E9=87=8Frename?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Main/AsstProxy.cs | 2 +- .../FightSettingsUserControlModel.cs | 59 ++++++++----------- .../TaskQueue/FightSettingsUserControl.xaml | 12 ++-- 3 files changed, 32 insertions(+), 41 deletions(-) diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 81bcac22d3..aeb676b880 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -1890,7 +1890,7 @@ namespace MaaWpfGui.Main AchievementTrackerHelper.Instance.SetProgress(AchievementIds.OverLimitAgent, FightTask.FightReport.TimesFinished); } - if (Instances.TaskQueueViewModel.FightTaskRunning && FightTask.Instance.HasTimesLimitedWithNull != false && FightTask.FightReport.TimesFinished + FightTask.FightReport.Series > FightTask.Instance.MaxTimes) + if (Instances.TaskQueueViewModel.FightTaskRunning && FightTask.Instance.HasTimesLimited != false && FightTask.FightReport.TimesFinished + FightTask.FightReport.Series > FightTask.Instance.MaxTimes) { Instances.TaskQueueViewModel.AddLog(string.Format(LocalizationHelper.GetString("FightTimesUnused"), FightTask.FightReport.TimesFinished, FightTask.FightReport.Series, FightTask.FightReport.TimesFinished + FightTask.FightReport.Series, FightTask.Instance.MaxTimes), UiLogColor.Error); } diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs index 483259fdeb..e6345b771e 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs @@ -316,10 +316,10 @@ public class FightSettingsUserControlModel : TaskViewModel /// public void ResetFightVariables() { - UseStoneWithNull ??= false; - UseMedicineWithNull ??= false; - HasTimesLimitedWithNull ??= false; - IsSpecifiedDropsWithNull ??= false; + UseStone ??= false; + UseMedicine ??= false; + HasTimesLimited ??= false; + IsSpecifiedDrops ??= false; } private bool? _useMedicine = ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, false); @@ -327,12 +327,12 @@ public class FightSettingsUserControlModel : TaskViewModel /// /// Gets or sets a value indicating whether to use medicine with null. /// - public bool? UseMedicineWithNull + public bool? UseMedicine { - get => _useMedicineWithNull; + get => _useMedicine; set { - SetAndNotify(ref _useMedicineWithNull, value); + SetAndNotify(ref _useMedicine, value); if (value == false) { UseStoneDisplay = false; @@ -366,15 +366,15 @@ public class FightSettingsUserControlModel : TaskViewModel public static string UseStoneString => LocalizationHelper.GetString("UseOriginitePrime"); - private bool? _useStoneWithNull = ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, false) && + private bool? _useStone = ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, false) && ConfigurationHelper.GetValue(ConfigurationKeys.UseStone, false); /// /// Gets or sets a value indicating whether to use originiums with null. /// - public bool? UseStoneWithNull + public bool? UseStone { - get => _useStoneWithNull; + get => _useStone; set { if (!AllowUseStoneSave && value == true) @@ -382,13 +382,13 @@ public class FightSettingsUserControlModel : TaskViewModel value = null; } - SetAndNotify(ref _useStoneWithNull, value); + SetAndNotify(ref _useStone, value); if (value != false) { MedicineNumber = 999; - if (UseMedicineWithNull == false) + if (UseMedicine == false) { - UseMedicineWithNull = value; + UseMedicine = value; } } @@ -409,8 +409,8 @@ public class FightSettingsUserControlModel : TaskViewModel // ReSharper disable once MemberCanBePrivate.Global public bool UseStoneDisplay { - get => UseStoneWithNull != false; - set => UseStoneWithNull = value; + get => UseStone != false; + set => UseStone = value; } private int _stoneNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseStoneQuantity, 0); @@ -438,12 +438,12 @@ public class FightSettingsUserControlModel : TaskViewModel /// /// Gets or sets a value indicating whether the number of times is limited with null. /// - public bool? HasTimesLimitedWithNull + public bool? HasTimesLimited { - get => _hasTimesLimitedWithNull; + get => _hasTimesLimited; set { - SetAndNotify(ref _hasTimesLimitedWithNull, value); + SetAndNotify(ref _hasTimesLimited, value); Instances.TaskQueueViewModel.SetFightParams(); value ??= false; ConfigurationHelper.SetValue(ConfigurationKeys.TimesLimited, value.ToString()); @@ -516,17 +516,17 @@ public class FightSettingsUserControlModel : TaskViewModel #region Drops - private bool? _isSpecifiedDropsWithNull = ConfigurationHelper.GetValue(ConfigurationKeys.DropsEnable, false); + private bool? _isSpecifiedDrops = ConfigurationHelper.GetValue(ConfigurationKeys.DropsEnable, false); /// /// Gets or sets a value indicating whether the drops are specified. /// - public bool? IsSpecifiedDropsWithNull + public bool? IsSpecifiedDrops { - get => _isSpecifiedDropsWithNull; + get => _isSpecifiedDrops; set { - if (!SetAndNotify(ref _isSpecifiedDropsWithNull, value)) + if (!SetAndNotify(ref _isSpecifiedDrops, value)) { return; } @@ -537,15 +537,6 @@ public class FightSettingsUserControlModel : TaskViewModel } } - /// - /// 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. /// @@ -854,10 +845,10 @@ public class FightSettingsUserControlModel : TaskViewModel var task = new AsstFightTask() { Stage = Stage, - Medicine = UseMedicineWithNull != false ? MedicineNumber : 0, + Medicine = UseMedicine != false ? MedicineNumber : 0, Stone = UseStoneDisplay ? StoneNumber : 0, Series = Series, - MaxTimes = HasTimesLimitedWithNull != false ? MaxTimes : int.MaxValue, + MaxTimes = HasTimesLimited != false ? MaxTimes : int.MaxValue, ExpiringMedicine = UseExpiringMedicine ? 9999 : 0, IsDrGrandet = IsDrGrandet, ReportToPenguin = SettingsViewModel.GameSettings.EnablePenguin, @@ -873,7 +864,7 @@ public class FightSettingsUserControlModel : TaskViewModel task.Stage = AnnihilationStage; } - if (IsSpecifiedDropsWithNull != false && !string.IsNullOrEmpty(DropsItemId)) + if (IsSpecifiedDrops != false && !string.IsNullOrEmpty(DropsItemId)) { task.Drops.Add(DropsItemId, DropsQuantity); } diff --git a/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml index c1beececce..79ef383096 100644 --- a/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml @@ -37,7 +37,7 @@ Margin="6" VerticalContentAlignment="Center" Content="{DynamicResource UseSanityPotion}" - IsChecked="{Binding UseMedicineWithNull}" + IsChecked="{Binding UseMedicine}" IsEnabled="{c:Binding !UseStoneDisplay}" MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick, Target={x:Type helper:CheckBoxHelper}}" @@ -47,7 +47,7 @@ Margin="6" VerticalContentAlignment="Center" Content="{c:Binding 'UseStoneString + (AllowUseStoneSave ? "" : "*")'}" - IsChecked="{Binding UseStoneWithNull}" + IsChecked="{Binding UseStone}" MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick, Target={x:Type helper:CheckBoxHelper}}" ToolTip="{DynamicResource CheckBoxesNotSaved}" /> @@ -56,7 +56,7 @@ Margin="6" VerticalContentAlignment="Center" Content="{DynamicResource PerformBattles}" - IsChecked="{Binding HasTimesLimitedWithNull}" + IsChecked="{Binding HasTimesLimited}" MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick, Target={x:Type helper:CheckBoxHelper}}" ToolTip="{DynamicResource CheckBoxesNotSavedAsNull}" /> @@ -106,7 +106,7 @@ Height="30" VerticalContentAlignment="Center" Content="{DynamicResource AssignedMaterial}" - IsChecked="{Binding IsSpecifiedDropsWithNull}" + IsChecked="{Binding IsSpecifiedDrops}" MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick, Target={x:Type helper:CheckBoxHelper}}" ToolTip="{DynamicResource CheckBoxesNotSavedAsNull}" /> @@ -116,7 +116,7 @@ NormalOpacity="0.25" TooltipText="{DynamicResource SpecifiedDropsTip}" /> - +