diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs
index 49adfc4..ec39653 100644
--- a/Bloxstrap/Resources/Strings.Designer.cs
+++ b/Bloxstrap/Resources/Strings.Designer.cs
@@ -2614,6 +2614,15 @@ namespace Bloxstrap.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Reset everything to defaults.
+ ///
+ public static string Menu_FastFlags_Reset_Title {
+ get {
+ return ResourceManager.GetString("Menu.FastFlags.Reset.Title", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Fast Flags.
///
diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx
index 8827778..a892671 100644
--- a/Bloxstrap/Resources/Strings.resx
+++ b/Bloxstrap/Resources/Strings.resx
@@ -1231,4 +1231,7 @@ Please manually delete Bloxstrap.exe from the install location or try restarting
Analytics
+
+ Reset everything to defaults
+
\ No newline at end of file
diff --git a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagsPage.xaml b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagsPage.xaml
index 9af9ff0..20a1d98 100644
--- a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagsPage.xaml
+++ b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagsPage.xaml
@@ -165,7 +165,13 @@
-
+
+
+
+
+
diff --git a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagsPage.xaml.cs b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagsPage.xaml.cs
index 4000faa..63b3ada 100644
--- a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagsPage.xaml.cs
+++ b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagsPage.xaml.cs
@@ -2,6 +2,7 @@
using System.Windows.Input;
using Bloxstrap.UI.ViewModels.Settings;
+using Wpf.Ui.Mvvm.Contracts;
namespace Bloxstrap.UI.Elements.Settings.Pages
{
@@ -10,14 +11,37 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
///
public partial class FastFlagsPage
{
- bool _initialLoad = false;
+ private bool _initialLoad = false;
+
+ private FastFlagsViewModel _viewModel = null!;
public FastFlagsPage()
{
- DataContext = new FastFlagsViewModel(this);
+ SetupViewModel();
InitializeComponent();
}
+ private void SetupViewModel()
+ {
+ _viewModel = new FastFlagsViewModel();
+
+ _viewModel.OpenFlagEditorEvent += OpenFlagEditor;
+ _viewModel.RequestPageReloadEvent += (_, _) => SetupViewModel();
+
+ DataContext = _viewModel;
+ }
+
+ private void OpenFlagEditor(object? sender, EventArgs e)
+ {
+ if (Window.GetWindow(this) is INavigationWindow window)
+ {
+ if (App.State.Prop.ShowFFlagEditorWarning)
+ window.Navigate(typeof(FastFlagEditorWarningPage));
+ else
+ window.Navigate(typeof(FastFlagEditorPage));
+ }
+ }
+
private void Page_Loaded(object sender, RoutedEventArgs e)
{
// refresh datacontext on page load to synchronize with editor page
@@ -28,7 +52,7 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
return;
}
- DataContext = new FastFlagsViewModel(this);
+ SetupViewModel();
}
private void ValidateInt32(object sender, TextCompositionEventArgs e) => e.Handled = e.Text != "-" && !Int32.TryParse(e.Text, out int _);
diff --git a/Bloxstrap/UI/ViewModels/Settings/FastFlagsViewModel.cs b/Bloxstrap/UI/ViewModels/Settings/FastFlagsViewModel.cs
index 1fc04e0..537520b 100644
--- a/Bloxstrap/UI/ViewModels/Settings/FastFlagsViewModel.cs
+++ b/Bloxstrap/UI/ViewModels/Settings/FastFlagsViewModel.cs
@@ -1,38 +1,24 @@
using System.Windows;
-using System.Windows.Controls;
using System.Windows.Input;
-using Wpf.Ui.Mvvm.Contracts;
-
using CommunityToolkit.Mvvm.Input;
-using Bloxstrap.UI.Elements.Settings.Pages;
using Bloxstrap.Enums.FlagPresets;
namespace Bloxstrap.UI.ViewModels.Settings
{
public class FastFlagsViewModel : NotifyPropertyChangedViewModel
{
- private readonly Page _page;
+ private Dictionary? _preResetFlags;
- public FastFlagsViewModel(Page page)
- {
- _page = page;
- }
+ public event EventHandler? RequestPageReloadEvent;
+
+ public event EventHandler? OpenFlagEditorEvent;
- private void OpenFastFlagEditor()
- {
- if (Window.GetWindow(_page) is INavigationWindow window)
- {
- if (App.State.Prop.ShowFFlagEditorWarning)
- window.Navigate(typeof(FastFlagEditorWarningPage));
- else
- window.Navigate(typeof(FastFlagEditorPage));
- }
- }
+ private void OpenFastFlagEditor() => OpenFlagEditorEvent?.Invoke(this, EventArgs.Empty);
public ICommand OpenFastFlagEditorCommand => new RelayCommand(OpenFastFlagEditor);
-
+
#if DEBUG
public Visibility ShowDebugFlags => Visibility.Visible;
#else
@@ -192,5 +178,27 @@ namespace Bloxstrap.UI.ViewModels.Settings
get => App.FastFlags.GetPreset("Rendering.TerrainTextureQuality") == "0";
set => App.FastFlags.SetPreset("Rendering.TerrainTextureQuality", value ? "0" : null);
}
+
+
+ public bool ResetConfiguration
+ {
+ get => _preResetFlags is not null;
+
+ set
+ {
+ if (value)
+ {
+ _preResetFlags = new(App.FastFlags.Prop);
+ App.FastFlags.Prop.Clear();
+ }
+ else
+ {
+ App.FastFlags.Prop = _preResetFlags!;
+ _preResetFlags = null;
+ }
+
+ RequestPageReloadEvent?.Invoke(this, EventArgs.Empty);
+ }
+ }
}
}