From 5581776313462d75e81e422bddce09cd25fe2e91 Mon Sep 17 00:00:00 2001
From: status102 <102887808+status102@users.noreply.github.com>
Date: Tue, 27 Feb 2024 11:09:01 +0800
Subject: [PATCH] =?UTF-8?q?perf(WpfGui):=20=E7=A2=8E=E7=9F=B3=E6=97=B6?=
=?UTF-8?q?=E9=94=81=E5=AE=9A=E7=90=86=E6=99=BA=E8=8D=AF=E4=BD=BF=E7=94=A8?=
=?UTF-8?q?=E9=87=8F=E4=B8=BA9999?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs | 14 +++++---------
.../UserControl/FightSettingsUserControl.xaml | 4 +++-
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
index fc830e9752..5845844839 100644
--- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
@@ -2868,8 +2868,6 @@ namespace MaaWpfGui.ViewModels.UI
SetAndNotify(ref _medicineNumber, value);
- // If the amount of medicine is 0, the stone is not used.
- UseStone = UseStone;
SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.UseMedicineQuantity, MedicineNumber);
}
@@ -2885,18 +2883,15 @@ namespace MaaWpfGui.ViewModels.UI
get => _useStoneWithNull;
set
{
- // If the amount of medicine is 0, the stone is not used.
- if (!int.TryParse(MedicineNumber, out int result) || result == 0)
- {
- value = false;
- }
-
SetAndNotify(ref _useStoneWithNull, value);
if (value != false && !UseMedicine)
{
UseMedicineWithNull = null;
}
+ MedicineNumber = "9999";
+ NotifyOfPropertyChange(nameof(UseStone));
+
SetFightParams();
}
}
@@ -2904,7 +2899,8 @@ namespace MaaWpfGui.ViewModels.UI
///
/// Gets or sets a value indicating whether to use originiums.
///
- private bool UseStone
+ // ReSharper disable once MemberCanBePrivate.Global
+ public bool UseStone
{
get => UseStoneWithNull != false;
set => UseStoneWithNull = value;
diff --git a/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml
index e80aff17c5..ec8cbcd9e2 100644
--- a/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml
+++ b/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml
@@ -38,6 +38,7 @@
VerticalContentAlignment="Center"
Content="{DynamicResource UseSanityPotion}"
IsChecked="{Binding UseMedicineWithNull}"
+ IsEnabled="{c:Binding !UseStone}"
MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
Target={x:Type helper:CheckBoxHelper}}"
ToolTip="{DynamicResource CheckBoxesNotSavedAsNull}" />
@@ -70,6 +71,7 @@
HorizontalAlignment="Left"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
+ IsEnabled="{c:Binding !UseStone}"
Maximum="9999"
Minimum="0"
ValueChanged="NumericUpDown_ValueChanged"
@@ -173,7 +175,7 @@
VerticalContentAlignment="Center"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
ItemsSource="{Binding SeriesList}"
- SelectedValue="{Binding Series}"/>
+ SelectedValue="{Binding Series}" />