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
This commit is contained in:
pizzaboxer 2023-04-12 00:28:54 +02:00
parent 7281cbf54a
commit aeeb89445e
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
5 changed files with 42 additions and 15 deletions

View File

@ -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}...");

View File

@ -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<T>(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)

View File

@ -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<string, string> 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)
{

View File

@ -99,9 +99,19 @@
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ui:CardControl Grid.Row="0" Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl.Header>
<StackPanel>
<TextBlock FontSize="14" Text="Framerate limit" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="By default, it's 60FPS. Use a really high number like 99999 for no limit." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
</ui:CardControl.Header>
<ui:TextBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" Text="{Binding FramerateLimit, Mode=TwoWay}" PreviewTextInput="ValidateInt32" />
</ui:CardControl>
<ui:CardControl Grid.Row="1" Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl.Header>
<StackPanel>
<TextBlock FontSize="14" Text="Rendering mode" />
@ -110,7 +120,7 @@
</ui:CardControl.Header>
<ComboBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" ItemsSource="{Binding RenderingModes.Keys, Mode=OneTime}" Text="{Binding SelectedRenderingMode, Mode=TwoWay}" />
</ui:CardControl>
<ui:CardControl Grid.Row="1" Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl Grid.Row="2" Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl.Header>
<StackPanel>
<TextBlock FontSize="14" Text="Use exclusive fullscreen" />

View File

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