From 7adee7121877bf64a9fcb2d1b9f7baa4942ce907 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 20:26:37 +0000 Subject: [PATCH] Use Apply & Save for boolean and enum values too Per tester feedback: clicking ON/Off, or picking an enum label, now only stages the value; Apply & Save writes it, the same as for text values. This is more consistent, and leaves time to choose the Save To files first. Fill with default now works for boolean and enum values too. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KaEsnLMDyw72GZ8a6ZxAGq --- src/BmsConfig/MainWindow.xaml.cs | 57 ++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/src/BmsConfig/MainWindow.xaml.cs b/src/BmsConfig/MainWindow.xaml.cs index ec019ec..aefdbd6 100644 --- a/src/BmsConfig/MainWindow.xaml.cs +++ b/src/BmsConfig/MainWindow.xaml.cs @@ -536,7 +536,7 @@ void ShowDetail(ParamItem item) } _suppressEvents = false; - FillDefaultButton.IsEnabled = entry.BmsValue != null && !isBool && !isEnum; + FillDefaultButton.IsEnabled = entry.BmsValue != null; SaveFeedback.Text = ""; UpdateButtons(); } @@ -562,10 +562,9 @@ void UpdateButtons() { ParamEntry entry = SelectedEntry; bool hasTargets = SaveTargets.Any(); - bool textValid = TextEditor.Visibility != Visibility.Visible || EditorError.Text.Length == 0; + bool inputValid = EditorInput != null && EditorError.Text.Length == 0; - ApplyButton.IsEnabled = entry != null && hasTargets && textValid; - ApplyButton.Visibility = TextEditor.Visibility; // bool & enum edits are applied immediately + ApplyButton.IsEnabled = entry != null && hasTargets && inputValid; RevertButton.IsEnabled = entry != null && !entry.IsFeatureFlag && hasTargets && ((SaveToUser.IsChecked == true && entry.UserValue != null && !entry.UserValueFromLauncher) || (SaveToVr.IsChecked == true && entry.VrValue != null)); @@ -602,28 +601,58 @@ void OnTextEditorKeyDown(object sender, KeyEventArgs e) } } - void OnApplyClick(object sender, RoutedEventArgs e) { ApplyInput(TextEditor.Text); } + /// The new value in whichever editor is showing, or null if none is chosen yet. + string EditorInput + { + get + { + if (BoolEditor.Visibility == Visibility.Visible) + return BoolOn.IsChecked == true ? "1" : BoolOff.IsChecked == true ? "0" : null; + if (EnumEditor.Visibility == Visibility.Visible) + return EnumEditor.SelectedIndex >= 0 ? EnumEditor.SelectedIndex.ToString() : null; + return TextEditor.Text; + } + } - void OnBoolClick(object sender, RoutedEventArgs e) + void OnApplyClick(object sender, RoutedEventArgs e) { - if (!_suppressEvents) - ApplyInput(BoolOn.IsChecked == true ? "1" : "0"); + string input = EditorInput; + if (input != null) + ApplyInput(input); } - void OnEnumChanged(object sender, SelectionChangedEventArgs e) + // ON/Off and enum choices are only staged here; they're saved by Apply & Save, like text values. + void OnBoolClick(object sender, RoutedEventArgs e) { OnEditorChoiceChanged(); } + void OnEnumChanged(object sender, SelectionChangedEventArgs e) { OnEditorChoiceChanged(); } + + void OnEditorChoiceChanged() { - if (_suppressEvents || EnumEditor.SelectedIndex < 0) + if (_suppressEvents) return; - // Deferred: applying reloads the detail pane, which resets this combo's items. - string input = EnumEditor.SelectedIndex.ToString(); - Dispatcher.BeginInvoke(new Action(() => ApplyInput(input))); + SaveFeedback.Text = ""; + UpdateButtons(); } void OnFillDefaultClick(object sender, RoutedEventArgs e) { ParamEntry entry = SelectedEntry; - if (entry != null && entry.BmsValue != null) + if (entry == null || entry.BmsValue == null) + return; + + if (BoolEditor.Visibility == Visibility.Visible) + { + bool? b = ValueConverter.ParseCfgBool(entry.BmsValue); + BoolOn.IsChecked = b == true; + BoolOff.IsChecked = b == false; + OnEditorChoiceChanged(); + } + else if (EnumEditor.Visibility == Visibility.Visible) + { + long? n = ValueConverter.ParseCfgInt(entry.BmsValue); + EnumEditor.SelectedIndex = (n.HasValue && n.Value >= 0 && n.Value < EnumEditor.Items.Count) ? (int)n.Value : -1; + } + else { TextEditor.Text = ValueConverter.ToEditText(entry.Type, entry.BmsValue); TextEditor.Focus();