make menu saving non-destructive (#825)

This commit is contained in:
pizzaboxer 2024-05-12 22:16:02 +01:00
parent d97af69306
commit 75096e5908
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
4 changed files with 42 additions and 6 deletions

View File

@ -134,7 +134,7 @@ namespace Bloxstrap.Resources {
}
/// <summary>
/// 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..
/// </summary>
public static string Bootstrapper_EmojiPresetFetchFailed {
get {
@ -2799,6 +2799,24 @@ namespace Bloxstrap.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Changes will take effect the next time you launch Roblox..
/// </summary>
public static string Menu_SettingsSaved_Message {
get {
return ResourceManager.GetString("Menu.SettingsSaved.Message", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settings saved!.
/// </summary>
public static string Menu_SettingsSaved_Title {
get {
return ResourceManager.GetString("Menu.SettingsSaved.Title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Bloxstrap Menu.
/// </summary>

View File

@ -1045,6 +1045,12 @@ Selecting 'No' will ignore this warning and continue installation.</value>
<data name="Menu.Save" xml:space="preserve">
<value>Save</value>
</data>
<data name="Menu.SettingsSaved.Message" xml:space="preserve">
<value>Changes will take effect the next time you launch Roblox.</value>
</data>
<data name="Menu.SettingsSaved.Title" xml:space="preserve">
<value>Settings saved!</value>
</data>
<data name="Menu.Title" xml:space="preserve">
<value>Bloxstrap Menu</value>
</data>

View File

@ -30,6 +30,12 @@
Message="{x:Static resources:Strings.Menu_AlreadyRunning_Caption}"
Icon="Info20" Timeout="10000" Margin="200,0,200,20" Grid.RowSpan="10" Panel.ZIndex="10" />
<ui:Snackbar
x:Name="SettingsSavedSnackbar"
Title="{x:Static resources:Strings.Menu_SettingsSaved_Title}"
Message="{x:Static resources:Strings.Menu_SettingsSaved_Message}"
Appearance="Primary" Icon="CheckmarkCircle32" Timeout="3000" Margin="200,0,200,20" Grid.RowSpan="10" Panel.ZIndex="9" />
<ui:TitleBar Padding="8" x:Name="RootTitleBar" Grid.Row="0" ForceShutdown="False" MinimizeToTray="False" ShowHelp="True" HelpClicked="OpenWiki" UseSnapLayout="True" Title="{x:Static resources:Strings.Menu_Title}" Icon="pack://application:,,,/Bloxstrap.ico" />
<Grid x:Name="RootGrid" Grid.Row="1" Margin="12,12,0,0" Visibility="Visible">
@ -85,7 +91,7 @@
<ui:Button Content="{Binding ConfirmButtonText, Mode=OneTime}" Appearance="Primary" Command="{Binding ConfirmSettingsCommand, Mode=OneWay}" IsEnabled="{Binding ConfirmButtonEnabled, Mode=OneWay}" />
</StatusBarItem>
<StatusBarItem Grid.Column="2" Padding="4,0,0,0">
<ui:Button Content="{x:Static resources:Strings.Common_Cancel}" Command="{Binding CloseWindowCommand, Mode=OneWay}" />
<ui:Button Content="{Binding CloseButtonText, Mode=OneTime}" Command="{Binding CloseWindowCommand, Mode=OneWay}" />
</StatusBarItem>
</StatusBar>
</Grid>

View File

@ -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;
}