From eafce44bad3a59b20b1793ca72b579eca7b52edb Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Fri, 14 Apr 2023 23:18:24 +0100 Subject: [PATCH] Add FFlag mod preset for menu versions --- Bloxstrap/Helpers/FastFlagManager.cs | 44 +++++++++++++++++++++++++-- Bloxstrap/ViewModels/ModsViewModel.cs | 37 ++++++++++++++++++++-- Bloxstrap/Views/Pages/ModsPage.xaml | 10 ++++++ 3 files changed, 87 insertions(+), 4 deletions(-) diff --git a/Bloxstrap/Helpers/FastFlagManager.cs b/Bloxstrap/Helpers/FastFlagManager.cs index a4ab45f..ce87d3e 100644 --- a/Bloxstrap/Helpers/FastFlagManager.cs +++ b/Bloxstrap/Helpers/FastFlagManager.cs @@ -16,7 +16,7 @@ namespace Bloxstrap.Helpers public Dictionary Changes = new(); // only one missing here is Metal because lol - public static IReadOnlyDictionary RenderingModes { get; set; } = new Dictionary() + public static IReadOnlyDictionary RenderingModes => new Dictionary { { "Automatic", "" }, { "Direct3D 11", "FFlagDebugGraphicsPreferD3D11" }, @@ -24,11 +24,51 @@ namespace Bloxstrap.Helpers { "Vulkan", "FFlagDebugGraphicsPreferVulkan" } }; + // this is one hell of a variable definition lmao + public static IReadOnlyDictionary> IGMenuVersions => new Dictionary> + { + { + "Default", + new Dictionary + { + { "FFlagDisableNewIGMinDUA", null }, + { "FFlagEnableInGameMenuV3", null } + } + }, + + { + "Version 1 (2015)", + new Dictionary + { + { "FFlagDisableNewIGMinDUA", "True" }, + { "FFlagEnableInGameMenuV3", "False" } + } + }, + + { + "Version 2 (2020)", + new Dictionary + { + { "FFlagDisableNewIGMinDUA", "False" }, + { "FFlagEnableInGameMenuV3", "False" } + } + }, + + { + "Version 3 (2021)", + new Dictionary + { + { "FFlagDisableNewIGMinDUA", "False" }, + { "FFlagEnableInGameMenuV3", "True" } + } + } + }; + // 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) + if (value is null) { Changes[key] = null; App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending"); diff --git a/Bloxstrap/ViewModels/ModsViewModel.cs b/Bloxstrap/ViewModels/ModsViewModel.cs index c5a88b1..52d21e5 100644 --- a/Bloxstrap/ViewModels/ModsViewModel.cs +++ b/Bloxstrap/ViewModels/ModsViewModel.cs @@ -35,14 +35,14 @@ namespace Bloxstrap.ViewModels set => App.Settings.Prop.UseDisableAppPatch = value; } - public IReadOnlyDictionary RenderingModes => FastFlagManager.RenderingModes; - 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 @@ -75,6 +75,39 @@ namespace Bloxstrap.ViewModels } } + 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"; diff --git a/Bloxstrap/Views/Pages/ModsPage.xaml b/Bloxstrap/Views/Pages/ModsPage.xaml index 7e3b172..107515a 100644 --- a/Bloxstrap/Views/Pages/ModsPage.xaml +++ b/Bloxstrap/Views/Pages/ModsPage.xaml @@ -101,6 +101,7 @@ + @@ -139,6 +140,15 @@ + + + + + + + + +