From 75096e5908192dc5a6e79411934b0326ee940445 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sun, 12 May 2024 22:16:02 +0100 Subject: [PATCH] make menu saving non-destructive (#825) --- Bloxstrap/Resources/Strings.Designer.cs | 20 ++++++++++++++++++- Bloxstrap/Resources/Strings.resx | 8 +++++++- Bloxstrap/UI/Elements/Menu/MainWindow.xaml | 8 +++++++- .../UI/ViewModels/Menu/MainWindowViewModel.cs | 12 ++++++++--- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 0403584..c5faa51 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -134,7 +134,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Failed to fetch the {0} emoji preset. Your preferred emoji type has been set back to default.. + /// Looks up a localized string similar to Could not apply the {0} emoji mod preset because of a network error. To try again, please reconfigure the option in the Bloxstrap Menu.. /// public static string Bootstrapper_EmojiPresetFetchFailed { get { @@ -2799,6 +2799,24 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Changes will take effect the next time you launch Roblox.. + /// + public static string Menu_SettingsSaved_Message { + get { + return ResourceManager.GetString("Menu.SettingsSaved.Message", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settings saved!. + /// + public static string Menu_SettingsSaved_Title { + get { + return ResourceManager.GetString("Menu.SettingsSaved.Title", resourceCulture); + } + } + /// /// Looks up a localized string similar to Bloxstrap Menu. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index ed83439..f1f8ae4 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -1045,6 +1045,12 @@ Selecting 'No' will ignore this warning and continue installation. Save + + Changes will take effect the next time you launch Roblox. + + + Settings saved! + Bloxstrap Menu @@ -1053,4 +1059,4 @@ Selecting 'No' will ignore this warning and continue installation. Would you like to switch your preferred channel to {0}? - + \ No newline at end of file diff --git a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml index 86a1ce1..cb3fd87 100644 --- a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml +++ b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml @@ -29,6 +29,12 @@ Title="{x:Static resources:Strings.Menu_AlreadyRunning_Title}" Message="{x:Static resources:Strings.Menu_AlreadyRunning_Caption}" Icon="Info20" Timeout="10000" Margin="200,0,200,20" Grid.RowSpan="10" Panel.ZIndex="10" /> + + @@ -85,7 +91,7 @@ - + diff --git a/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs index c51ae9a..41bafa3 100644 --- a/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs @@ -7,22 +7,24 @@ using CommunityToolkit.Mvvm.Input; using Wpf.Ui.Mvvm.Contracts; +using Bloxstrap.UI.Elements.Menu; using Bloxstrap.UI.Elements.Menu.Pages; namespace Bloxstrap.UI.ViewModels.Menu { public class MainWindowViewModel : NotifyPropertyChangedViewModel { - private readonly Window _window; + private readonly MainWindow _window; public ICommand CloseWindowCommand => new RelayCommand(CloseWindow); public ICommand ConfirmSettingsCommand => new RelayCommand(ConfirmSettings); public Visibility NavigationVisibility { get; set; } = Visibility.Visible; public string ConfirmButtonText => App.IsFirstRun ? Resources.Strings.Menu_Install : Resources.Strings.Menu_Save; + public string CloseButtonText => App.IsFirstRun ? Resources.Strings.Common_Cancel : Resources.Strings.Common_Close; public bool ConfirmButtonEnabled { get; set; } = true; - public MainWindowViewModel(Window window) + public MainWindowViewModel(MainWindow window) { _window = window; } @@ -34,8 +36,12 @@ namespace Bloxstrap.UI.ViewModels.Menu if (!App.IsFirstRun) { App.ShouldSaveConfigs = true; + App.Settings.Save(); + App.State.Save(); App.FastFlags.Save(); - CloseWindow(); + App.ShouldSaveConfigs = false; + + _window.SettingsSavedSnackbar.Show(); return; }