From 7a305c6bd24a911d053d6581cf2e70c0e7a428fc Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Tue, 11 Apr 2023 23:54:03 +0200 Subject: [PATCH] Write all FastFlag values strictly as strings this is how roblox does it, and it just makes things easier --- Bloxstrap/Helpers/FastFlagManager.cs | 25 ++++++++++++++++----- Bloxstrap/ViewModels/ModsViewModel.cs | 32 +++++++++++++-------------- Bloxstrap/Views/Pages/ModsPage.xaml | 20 ++++++++--------- 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/Bloxstrap/Helpers/FastFlagManager.cs b/Bloxstrap/Helpers/FastFlagManager.cs index 3fb2da5..b23b8a6 100644 --- a/Bloxstrap/Helpers/FastFlagManager.cs +++ b/Bloxstrap/Helpers/FastFlagManager.cs @@ -23,10 +23,23 @@ namespace Bloxstrap.Helpers { "Vulkan", "FFlagDebugGraphicsPreferVulkan" } }; + // all fflags are stored as strings + // to delete a flag, set the value as null + public void SetValue(string key, object? value) + { + if (value == null) + { + Changes[key] = null; + App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending"); + } + else + { + Changes[key] = value.ToString(); + App.Logger.WriteLine($"[FastFlagManager::SetValue] Value change for '{key}' to '{value}' is pending"); + } + } + // this returns null if the fflag doesn't exist - // this also returns as a string because deserializing an object doesn't - // deserialize back into the original object type, it instead deserializes - // as a "JsonElement" which is annoying public string? GetValue(string key) { // check if we have an updated change for it pushed first @@ -44,11 +57,11 @@ namespace Bloxstrap.Helpers foreach (var mode in RenderingModes) { if (mode.Key != "Automatic") - App.FastFlags.Changes[mode.Value] = null; + SetValue(mode.Value, null); } if (value != "Automatic") - App.FastFlags.Changes[RenderingModes[value]] = true; + SetValue(RenderingModes[value], "True"); } public override void Save() @@ -73,7 +86,7 @@ namespace Bloxstrap.Helpers continue; } - App.Logger.WriteLine($"[FastFlagManager::Save] Setting '{change.Key}' to {change.Value}"); + App.Logger.WriteLine($"[FastFlagManager::Save] Setting '{change.Key}' to '{change.Value}'"); Prop[change.Key] = change.Value; } diff --git a/Bloxstrap/ViewModels/ModsViewModel.cs b/Bloxstrap/ViewModels/ModsViewModel.cs index 7467c80..c756ef8 100644 --- a/Bloxstrap/ViewModels/ModsViewModel.cs +++ b/Bloxstrap/ViewModels/ModsViewModel.cs @@ -39,22 +39,6 @@ namespace Bloxstrap.ViewModels public IReadOnlyDictionary RenderingModes => FastFlagManager.RenderingModes; - // this flag has to be set to false to work, weirdly enough - public bool ExclusiveFullscreenEnabled - { - get => App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") == "False"; - set - { - App.FastFlags.Changes["FFlagHandleAltEnterFullscreenManually"] = value ? false : null; - - if (value) - { - App.FastFlags.SetRenderingMode("Direct3D 11"); - OnPropertyChanged(nameof(SelectedRenderingMode)); - } - } - } - public string SelectedRenderingMode { get @@ -71,6 +55,22 @@ namespace Bloxstrap.ViewModels 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.Changes["FFlagHandleAltEnterFullscreenManually"] = value ? false : null; + + if (value) + { + App.FastFlags.SetRenderingMode("Direct3D 11"); + OnPropertyChanged(nameof(SelectedRenderingMode)); + } + } + } + public bool DisableFullscreenOptimizationsEnabled { get => App.Settings.Prop.DisableFullscreenOptimizations; diff --git a/Bloxstrap/Views/Pages/ModsPage.xaml b/Bloxstrap/Views/Pages/ModsPage.xaml index cf1610b..37619c6 100644 --- a/Bloxstrap/Views/Pages/ModsPage.xaml +++ b/Bloxstrap/Views/Pages/ModsPage.xaml @@ -6,7 +6,7 @@ xmlns:models="clr-namespace:Bloxstrap.ViewModels" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800" + d:DesignHeight="800" d:DesignWidth="800" Title="ModsPage" Scrollable="True"> @@ -102,15 +102,6 @@ - - - - - - - - - @@ -119,6 +110,15 @@ + + + + + + + + +