From bff6efe2c53fa5c1b101c8ec3a2fba8e0c9dbeb5 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Tue, 2 May 2023 00:05:33 +0100 Subject: [PATCH] Move FastFlag config to separate tab --- Bloxstrap/ViewModels/FastFlagsViewModel.cs | 136 ++++++++++++++++++++ Bloxstrap/ViewModels/ModsViewModel.cs | 128 +----------------- Bloxstrap/Views/MainWindow.xaml | 1 + Bloxstrap/Views/Pages/FastFlagsPage.xaml | 110 ++++++++++++++++ Bloxstrap/Views/Pages/FastFlagsPage.xaml.cs | 20 +++ Bloxstrap/Views/Pages/ModsPage.xaml | 96 +------------- Bloxstrap/Views/Pages/ModsPage.xaml.cs | 2 - 7 files changed, 271 insertions(+), 222 deletions(-) create mode 100644 Bloxstrap/ViewModels/FastFlagsViewModel.cs create mode 100644 Bloxstrap/Views/Pages/FastFlagsPage.xaml create mode 100644 Bloxstrap/Views/Pages/FastFlagsPage.xaml.cs diff --git a/Bloxstrap/ViewModels/FastFlagsViewModel.cs b/Bloxstrap/ViewModels/FastFlagsViewModel.cs new file mode 100644 index 0000000..a60c5a4 --- /dev/null +++ b/Bloxstrap/ViewModels/FastFlagsViewModel.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Windows.Input; + +using CommunityToolkit.Mvvm.Input; + +using Bloxstrap.Singletons; +using System.ComponentModel; + +namespace Bloxstrap.ViewModels +{ + public class FastFlagsViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler? PropertyChanged; + public void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + + public ICommand OpenClientSettingsCommand => new RelayCommand(OpenClientSettings); + + private void OpenClientSettings() => Utilities.OpenWebsite(Path.Combine(Directories.Modifications, "ClientSettings\\ClientAppSettings.json")); + + public int FramerateLimit + { + get => Int32.TryParse(App.FastFlags.GetValue("DFIntTaskSchedulerTargetFps"), out int x) ? x : 60; + set => App.FastFlags.SetValue("DFIntTaskSchedulerTargetFps", value); + } + + public IReadOnlyDictionary RenderingModes => FastFlagManager.RenderingModes; + + public string SelectedRenderingMode + { + get + { + foreach (var mode in RenderingModes) + { + if (App.FastFlags.GetValue(mode.Value) == "True") + return mode.Key; + } + + return "Automatic"; + } + + set => App.FastFlags.SetRenderingMode(value); + } + + // this flag has to be set to false to work, weirdly enough + public bool ExclusiveFullscreenEnabled + { + get => App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") == "False"; + set + { + App.FastFlags.SetValue("FFlagHandleAltEnterFullscreenManually", value ? "False" : null); + + if (value) + { + App.FastFlags.SetRenderingMode("Direct3D 11"); + OnPropertyChanged(nameof(SelectedRenderingMode)); + } + } + } + + public IReadOnlyDictionary> IGMenuVersions => FastFlagManager.IGMenuVersions; + + public string SelectedIGMenuVersion + { + get + { + // yeah this kinda sucks + foreach (var version in IGMenuVersions) + { + bool flagsMatch = true; + + foreach (var flag in version.Value) + { + if (App.FastFlags.GetValue(flag.Key) != flag.Value) + flagsMatch = false; + } + + if (flagsMatch) + return version.Key; + } + + return "Default"; + } + + set + { + foreach (var flag in IGMenuVersions[value]) + { + App.FastFlags.SetValue(flag.Key, flag.Value); + } + } + } + + public bool AlternateGraphicsSelectorEnabled + { + get => App.FastFlags.GetValue("FFlagFixGraphicsQuality") == "True"; + set => App.FastFlags.SetValue("FFlagFixGraphicsQuality", value ? "True" : null); + } + + public bool MobileLuaAppInterfaceEnabled + { + get => App.FastFlags.GetValue("FFlagLuaAppSystemBar") == "False"; + set => App.FastFlags.SetValue("FFlagLuaAppSystemBar", value ? "False" : null); + } + + public IReadOnlyDictionary LightingTechnologies => FastFlagManager.LightingTechnologies; + + // this is basically the same as the code for rendering selection, maybe this could be abstracted in some way? + public string SelectedLightingTechnology + { + get + { + foreach (var mode in LightingTechnologies) + { + if (App.FastFlags.GetValue(mode.Value) == "True") + return mode.Key; + } + + return "Automatic"; + } + + set + { + foreach (var mode in LightingTechnologies) + { + if (mode.Key != "Automatic") + App.FastFlags.SetValue(mode.Value, null); + } + + if (value != "Automatic") + App.FastFlags.SetValue(LightingTechnologies[value], "True"); + } + } + } +} diff --git a/Bloxstrap/ViewModels/ModsViewModel.cs b/Bloxstrap/ViewModels/ModsViewModel.cs index c9d3cd3..5ef9255 100644 --- a/Bloxstrap/ViewModels/ModsViewModel.cs +++ b/Bloxstrap/ViewModels/ModsViewModel.cs @@ -1,26 +1,16 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using System.Diagnostics; -using System.IO; using System.Windows.Input; using CommunityToolkit.Mvvm.Input; -using Bloxstrap.Singletons; - namespace Bloxstrap.ViewModels { - public class ModsViewModel : INotifyPropertyChanged + public class ModsViewModel { - public event PropertyChangedEventHandler? PropertyChanged; - public void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - public ICommand OpenModsFolderCommand => new RelayCommand(OpenModsFolder); - public ICommand OpenClientSettingsCommand => new RelayCommand(OpenClientSettings); private void OpenModsFolder() => Process.Start("explorer.exe", Directories.Modifications); - private void OpenClientSettings() => Utilities.OpenWebsite(Path.Combine(Directories.Modifications, "ClientSettings\\ClientAppSettings.json")); public bool OldDeathSoundEnabled { @@ -40,124 +30,10 @@ namespace Bloxstrap.ViewModels set => App.Settings.Prop.UseDisableAppPatch = value; } - public int FramerateLimit - { - get => Int32.TryParse(App.FastFlags.GetValue("DFIntTaskSchedulerTargetFps"), out int x) ? x : 60; - set => App.FastFlags.SetValue("DFIntTaskSchedulerTargetFps", value); - } - - public IReadOnlyDictionary RenderingModes => FastFlagManager.RenderingModes; - - public string SelectedRenderingMode - { - get - { - foreach (var mode in RenderingModes) - { - if (App.FastFlags.GetValue(mode.Value) == "True") - return mode.Key; - } - - return "Automatic"; - } - - set => App.FastFlags.SetRenderingMode(value); - } - - // this flag has to be set to false to work, weirdly enough - public bool ExclusiveFullscreenEnabled - { - get => App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") == "False"; - set - { - App.FastFlags.SetValue("FFlagHandleAltEnterFullscreenManually", value ? "False" : null); - - if (value) - { - App.FastFlags.SetRenderingMode("Direct3D 11"); - OnPropertyChanged(nameof(SelectedRenderingMode)); - } - } - } - - public IReadOnlyDictionary> IGMenuVersions => FastFlagManager.IGMenuVersions; - - public string SelectedIGMenuVersion - { - get - { - // yeah this kinda sucks - foreach (var version in IGMenuVersions) - { - bool flagsMatch = true; - - foreach (var flag in version.Value) - { - if (App.FastFlags.GetValue(flag.Key) != flag.Value) - flagsMatch = false; - } - - if (flagsMatch) - return version.Key; - } - - return "Default"; - } - - set - { - foreach (var flag in IGMenuVersions[value]) - { - App.FastFlags.SetValue(flag.Key, flag.Value); - } - } - } - - public bool AlternateGraphicsSelectorEnabled - { - get => App.FastFlags.GetValue("FFlagFixGraphicsQuality") == "True"; - set => App.FastFlags.SetValue("FFlagFixGraphicsQuality", value ? "True" : null); - } - - public bool MobileLuaAppInterfaceEnabled - { - get => App.FastFlags.GetValue("FFlagLuaAppSystemBar") == "False"; - set => App.FastFlags.SetValue("FFlagLuaAppSystemBar", value ? "False" : null); - } - public bool DisableFullscreenOptimizationsEnabled { get => App.Settings.Prop.DisableFullscreenOptimizations; set => App.Settings.Prop.DisableFullscreenOptimizations = value; } - - public IReadOnlyDictionary LightingTechnologies => FastFlagManager.LightingTechnologies; - - // this is basically the same as the code for rendering selection, maybe this could be abstracted in some way? - public string SelectedLightingTechnology - { - get - { - foreach (var mode in LightingTechnologies) - { - if (App.FastFlags.GetValue(mode.Value) == "True") - return mode.Key; - } - - return "Automatic"; - } - - set - { - foreach (var mode in LightingTechnologies) - { - if (mode.Key != "Automatic") - App.FastFlags.SetValue(mode.Value, null); - } - - if (value != "Automatic") - App.FastFlags.SetValue(LightingTechnologies[value], "True"); - } - } } } diff --git a/Bloxstrap/Views/MainWindow.xaml b/Bloxstrap/Views/MainWindow.xaml index 18b037b..05e841a 100644 --- a/Bloxstrap/Views/MainWindow.xaml +++ b/Bloxstrap/Views/MainWindow.xaml @@ -43,6 +43,7 @@ + diff --git a/Bloxstrap/Views/Pages/FastFlagsPage.xaml b/Bloxstrap/Views/Pages/FastFlagsPage.xaml new file mode 100644 index 0000000..047a531 --- /dev/null +++ b/Bloxstrap/Views/Pages/FastFlagsPage.xaml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Bloxstrap/Views/Pages/FastFlagsPage.xaml.cs b/Bloxstrap/Views/Pages/FastFlagsPage.xaml.cs new file mode 100644 index 0000000..de61991 --- /dev/null +++ b/Bloxstrap/Views/Pages/FastFlagsPage.xaml.cs @@ -0,0 +1,20 @@ +using Bloxstrap.ViewModels; +using System.Windows.Input; +using System; + +namespace Bloxstrap.Views.Pages +{ + /// + /// Interaction logic for FastFlagsPage.xaml + /// + public partial class FastFlagsPage + { + public FastFlagsPage() + { + DataContext = new FastFlagsViewModel(); + InitializeComponent(); + } + + private void ValidateInt32(object sender, TextCompositionEventArgs e) => e.Handled = !Int32.TryParse(e.Text, out int _); + } +} diff --git a/Bloxstrap/Views/Pages/ModsPage.xaml b/Bloxstrap/Views/Pages/ModsPage.xaml index 2946daf..ee88fb0 100644 --- a/Bloxstrap/Views/Pages/ModsPage.xaml +++ b/Bloxstrap/Views/Pages/ModsPage.xaml @@ -9,6 +9,7 @@ d:DesignHeight="800" d:DesignWidth="800" Title="ModsPage" Scrollable="True"> + @@ -49,40 +50,12 @@ - + - - - - - - - - - - - - - - - @@ -126,71 +99,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Bloxstrap/Views/Pages/ModsPage.xaml.cs b/Bloxstrap/Views/Pages/ModsPage.xaml.cs index e3c3b73..ba7be7a 100644 --- a/Bloxstrap/Views/Pages/ModsPage.xaml.cs +++ b/Bloxstrap/Views/Pages/ModsPage.xaml.cs @@ -20,7 +20,5 @@ namespace Bloxstrap.Views.Pages if (Environment.OSVersion.Version.Build < 17093) this.MiscellaneousOptions.Visibility = Visibility.Collapsed; } - - private void ValidateInt32(object sender, TextCompositionEventArgs e) => e.Handled = !Int32.TryParse(e.Text, out int _); } }