From aeeb89445ef16b75ff2e990edd15d53f47bdb8ef Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 12 Apr 2023 00:28:54 +0200 Subject: [PATCH] Add FFlag preset for setting framerate cap this will replace rbxfpsunlocker, and yeah having a default value of 99999 might be a bit weird lol --- Bloxstrap/Helpers/FastFlagManager.cs | 10 ++++++++++ Bloxstrap/Helpers/JsonManager.cs | 20 ++++++++------------ Bloxstrap/ViewModels/ModsViewModel.cs | 11 +++++++++-- Bloxstrap/Views/Pages/ModsPage.xaml | 12 +++++++++++- Bloxstrap/Views/Pages/ModsPage.xaml.cs | 4 ++++ 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/Bloxstrap/Helpers/FastFlagManager.cs b/Bloxstrap/Helpers/FastFlagManager.cs index b23b8a6..7558aa2 100644 --- a/Bloxstrap/Helpers/FastFlagManager.cs +++ b/Bloxstrap/Helpers/FastFlagManager.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.IO; using System.Text.Json; @@ -64,6 +65,15 @@ namespace Bloxstrap.Helpers SetValue(RenderingModes[value], "True"); } + public override void Load() + { + base.Load(); + + // set to 99999 by default if it doesnt immediately exist + if (GetValue("DFIntTaskSchedulerTargetFps") is null) + SetValue("DFIntTaskSchedulerTargetFps", 99999); + } + public override void Save() { App.Logger.WriteLine($"[FastFlagManager::Save] Attempting to save JSON to {FileLocation}..."); diff --git a/Bloxstrap/Helpers/JsonManager.cs b/Bloxstrap/Helpers/JsonManager.cs index fb59f7d..dde7851 100644 --- a/Bloxstrap/Helpers/JsonManager.cs +++ b/Bloxstrap/Helpers/JsonManager.cs @@ -1,15 +1,6 @@ -using Bloxstrap.Models; -using Bloxstrap.Properties; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Diagnostics; +using System; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Text.Json; -using System.Threading; namespace Bloxstrap.Helpers { @@ -19,14 +10,19 @@ namespace Bloxstrap.Helpers public virtual string FileLocation => AltFileLocation ?? Path.Combine(Directories.Base, $"{typeof(T).Name}.json"); public string? AltFileLocation { get; set; } - public void Load() + public virtual void Load() { App.Logger.WriteLine($"[JsonManager<{typeof(T).Name}>::Load] Loading JSON from {FileLocation}..."); try { T? settings = JsonSerializer.Deserialize(File.ReadAllText(FileLocation)); - Prop = settings ?? throw new ArgumentNullException("Deserialization returned null"); + + if (settings is null) + throw new ArgumentNullException("Deserialization returned null"); + + Prop = settings; + App.Logger.WriteLine($"[JsonManager<{typeof(T).Name}>::Load] JSON loaded successfully!"); } catch (Exception ex) diff --git a/Bloxstrap/ViewModels/ModsViewModel.cs b/Bloxstrap/ViewModels/ModsViewModel.cs index c756ef8..10f9b1a 100644 --- a/Bloxstrap/ViewModels/ModsViewModel.cs +++ b/Bloxstrap/ViewModels/ModsViewModel.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Windows.Input; @@ -39,6 +40,12 @@ namespace Bloxstrap.ViewModels public IReadOnlyDictionary RenderingModes => FastFlagManager.RenderingModes; + public int FramerateLimit + { + get => Int32.TryParse(App.FastFlags.GetValue("DFIntTaskSchedulerTargetFps"), out int x) ? x : 60; + set => App.FastFlags.Changes["DFIntTaskSchedulerTargetFps"] = value; + } + public string SelectedRenderingMode { get @@ -61,7 +68,7 @@ namespace Bloxstrap.ViewModels get => App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") == "False"; set { - App.FastFlags.Changes["FFlagHandleAltEnterFullscreenManually"] = value ? false : null; + App.FastFlags.SetValue("FFlagHandleAltEnterFullscreenManually", value ? false : null); if (value) { diff --git a/Bloxstrap/Views/Pages/ModsPage.xaml b/Bloxstrap/Views/Pages/ModsPage.xaml index 37619c6..29e0a25 100644 --- a/Bloxstrap/Views/Pages/ModsPage.xaml +++ b/Bloxstrap/Views/Pages/ModsPage.xaml @@ -99,9 +99,19 @@ + + + + + + + + + + @@ -110,7 +120,7 @@ - + diff --git a/Bloxstrap/Views/Pages/ModsPage.xaml.cs b/Bloxstrap/Views/Pages/ModsPage.xaml.cs index b5c7e43..76fd5c3 100644 --- a/Bloxstrap/Views/Pages/ModsPage.xaml.cs +++ b/Bloxstrap/Views/Pages/ModsPage.xaml.cs @@ -1,5 +1,7 @@ using System; using System.Windows; +using System.Windows.Input; + using Bloxstrap.ViewModels; namespace Bloxstrap.Views.Pages @@ -21,5 +23,7 @@ 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 _); } }