mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Add option for resetting flag config to defaults
This commit is contained in:
parent
ed36e7f2dd
commit
5b9c035b16
9
Bloxstrap/Resources/Strings.Designer.cs
generated
9
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -2614,6 +2614,15 @@ namespace Bloxstrap.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Reset everything to defaults.
|
||||||
|
/// </summary>
|
||||||
|
public static string Menu_FastFlags_Reset_Title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Menu.FastFlags.Reset.Title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Fast Flags.
|
/// Looks up a localized string similar to Fast Flags.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1231,4 +1231,7 @@ Please manually delete Bloxstrap.exe from the install location or try restarting
|
|||||||
<data name="Common.Analytics" xml:space="preserve">
|
<data name="Common.Analytics" xml:space="preserve">
|
||||||
<value>Analytics</value>
|
<value>Analytics</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Menu.FastFlags.Reset.Title" xml:space="preserve">
|
||||||
|
<value>Reset everything to defaults</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -165,7 +165,13 @@
|
|||||||
</ComboBox>
|
</ComboBox>
|
||||||
</controls:OptionControl>
|
</controls:OptionControl>
|
||||||
|
|
||||||
<ui:CardAction Margin="0,24,0,0" Icon="EditSettings24" Command="{Binding OpenFastFlagEditorCommand}">
|
<controls:OptionControl
|
||||||
|
Margin="0,24,0,0"
|
||||||
|
Header="{x:Static resources:Strings.Menu_FastFlags_Reset_Title}">
|
||||||
|
<ui:ToggleSwitch IsChecked="{Binding ResetConfiguration, Mode=TwoWay}" />
|
||||||
|
</controls:OptionControl>
|
||||||
|
|
||||||
|
<ui:CardAction Margin="0,8,0,0" Icon="EditSettings24" Command="{Binding OpenFastFlagEditorCommand}">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock FontSize="14" Text="{x:Static resources:Strings.Menu_FastFlagEditor_Title}" />
|
<TextBlock FontSize="14" Text="{x:Static resources:Strings.Menu_FastFlagEditor_Title}" />
|
||||||
<TextBlock Margin="0,2,0,0" FontSize="12" Text="{x:Static resources:Strings.Menu_FastFlags_Editor_Description}" Padding="0,0,16,0" Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
<TextBlock Margin="0,2,0,0" FontSize="12" Text="{x:Static resources:Strings.Menu_FastFlags_Editor_Description}" Padding="0,0,16,0" Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
using Bloxstrap.UI.ViewModels.Settings;
|
using Bloxstrap.UI.ViewModels.Settings;
|
||||||
|
using Wpf.Ui.Mvvm.Contracts;
|
||||||
|
|
||||||
namespace Bloxstrap.UI.Elements.Settings.Pages
|
namespace Bloxstrap.UI.Elements.Settings.Pages
|
||||||
{
|
{
|
||||||
@ -10,14 +11,37 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FastFlagsPage
|
public partial class FastFlagsPage
|
||||||
{
|
{
|
||||||
bool _initialLoad = false;
|
private bool _initialLoad = false;
|
||||||
|
|
||||||
|
private FastFlagsViewModel _viewModel = null!;
|
||||||
|
|
||||||
public FastFlagsPage()
|
public FastFlagsPage()
|
||||||
{
|
{
|
||||||
DataContext = new FastFlagsViewModel(this);
|
SetupViewModel();
|
||||||
InitializeComponent();
|
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)
|
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// refresh datacontext on page load to synchronize with editor page
|
// refresh datacontext on page load to synchronize with editor page
|
||||||
@ -28,7 +52,7 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataContext = new FastFlagsViewModel(this);
|
SetupViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValidateInt32(object sender, TextCompositionEventArgs e) => e.Handled = e.Text != "-" && !Int32.TryParse(e.Text, out int _);
|
private void ValidateInt32(object sender, TextCompositionEventArgs e) => e.Handled = e.Text != "-" && !Int32.TryParse(e.Text, out int _);
|
||||||
|
@ -1,35 +1,21 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
using Wpf.Ui.Mvvm.Contracts;
|
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
|
||||||
using Bloxstrap.UI.Elements.Settings.Pages;
|
|
||||||
using Bloxstrap.Enums.FlagPresets;
|
using Bloxstrap.Enums.FlagPresets;
|
||||||
|
|
||||||
namespace Bloxstrap.UI.ViewModels.Settings
|
namespace Bloxstrap.UI.ViewModels.Settings
|
||||||
{
|
{
|
||||||
public class FastFlagsViewModel : NotifyPropertyChangedViewModel
|
public class FastFlagsViewModel : NotifyPropertyChangedViewModel
|
||||||
{
|
{
|
||||||
private readonly Page _page;
|
private Dictionary<string, object>? _preResetFlags;
|
||||||
|
|
||||||
public FastFlagsViewModel(Page page)
|
public event EventHandler? RequestPageReloadEvent;
|
||||||
{
|
|
||||||
_page = page;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OpenFastFlagEditor()
|
public event EventHandler? OpenFlagEditorEvent;
|
||||||
{
|
|
||||||
if (Window.GetWindow(_page) is INavigationWindow window)
|
private void OpenFastFlagEditor() => OpenFlagEditorEvent?.Invoke(this, EventArgs.Empty);
|
||||||
{
|
|
||||||
if (App.State.Prop.ShowFFlagEditorWarning)
|
|
||||||
window.Navigate(typeof(FastFlagEditorWarningPage));
|
|
||||||
else
|
|
||||||
window.Navigate(typeof(FastFlagEditorPage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICommand OpenFastFlagEditorCommand => new RelayCommand(OpenFastFlagEditor);
|
public ICommand OpenFastFlagEditorCommand => new RelayCommand(OpenFastFlagEditor);
|
||||||
|
|
||||||
@ -192,5 +178,27 @@ namespace Bloxstrap.UI.ViewModels.Settings
|
|||||||
get => App.FastFlags.GetPreset("Rendering.TerrainTextureQuality") == "0";
|
get => App.FastFlags.GetPreset("Rendering.TerrainTextureQuality") == "0";
|
||||||
set => App.FastFlags.SetPreset("Rendering.TerrainTextureQuality", value ? "0" : null);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user