From 670790a0236624144c808c7514d77b752f1d954e Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Mon, 26 Jun 2023 21:36:07 +0100 Subject: [PATCH] Enable D3D exclusive fullscreen by default --- Bloxstrap/Singletons/FastFlagManager.cs | 51 +++++++------------ .../UI/Menu/ViewModels/FastFlagsViewModel.cs | 33 +++++------- .../UI/Menu/Views/Pages/FastFlagsPage.xaml | 9 ---- 3 files changed, 32 insertions(+), 61 deletions(-) diff --git a/Bloxstrap/Singletons/FastFlagManager.cs b/Bloxstrap/Singletons/FastFlagManager.cs index 788f90c..f0ee4d0 100644 --- a/Bloxstrap/Singletons/FastFlagManager.cs +++ b/Bloxstrap/Singletons/FastFlagManager.cs @@ -22,9 +22,9 @@ namespace Bloxstrap.Singletons public static IReadOnlyDictionary RenderingModes => new Dictionary { { "Automatic", "" }, + { "Vulkan", "FFlagDebugGraphicsPreferVulkan" }, { "Direct3D 11", "FFlagDebugGraphicsPreferD3D11" }, { "Direct3D 10", "FFlagDebugGraphicsPreferD3D11FL10" }, - { "Vulkan", "FFlagDebugGraphicsPreferVulkan" }, { "OpenGL", "FFlagDebugGraphicsPreferOpenGL" } }; @@ -101,6 +101,22 @@ namespace Bloxstrap.Singletons } } + // this will set the flag to the corresponding value if the condition is true + // if the condition is not true, the flag will be erased + public void SetValueIf(bool condition, string key, object? value) + { + if (condition) + SetValue(key, value); + else if (GetValue(key) is not null) + SetValue(key, null); + } + + public void SetValueOnce(string key, object? value) + { + if (GetValue(key) is null) + SetValue(key, value); + } + // this returns null if the fflag doesn't exist public string? GetValue(string key) { @@ -114,42 +130,13 @@ namespace Bloxstrap.Singletons return null; } - public void SetRenderingMode(string value) - { - foreach (var mode in RenderingModes) - { - if (mode.Key != "Automatic") - SetValue(mode.Value, null); - } - - if (value != "Automatic") - SetValue(RenderingModes[value], "True"); - - if (value == "Vulkan") - SetValue("FFlagRenderVulkanFixMinimizeWindow", "True"); - else if (GetValue("FFlagRenderVulkanFixMinimizeWindow") is not null) - SetValue("FFlagRenderVulkanFixMinimizeWindow", null); - } - public override void Load() { base.Load(); // set to 9999 by default if it doesnt already exist - if (GetValue("DFIntTaskSchedulerTargetFps") is null) - SetValue("DFIntTaskSchedulerTargetFps", 9999); - - if (GetValue("FFlagDebugGraphicsPreferVulkan") == "True" && GetValue("FFlagRenderVulkanFixMinimizeWindow") is null) - SetValue("FFlagRenderVulkanFixMinimizeWindow", "True"); - - // exclusive fullscreen requires direct3d 10/11 to work - if (App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") == "False") - { - if (!(App.FastFlags.GetValue("FFlagDebugGraphicsPreferD3D11") == "True" || App.FastFlags.GetValue("FFlagDebugGraphicsPreferD3D11FL10") == "True")) - { - SetRenderingMode("Direct3D 11"); - } - } + SetValueOnce("DFIntTaskSchedulerTargetFps", 9999); + SetValueOnce("FFlagHandleAltEnterFullscreenManually", "False"); } public override void Save() diff --git a/Bloxstrap/UI/Menu/ViewModels/FastFlagsViewModel.cs b/Bloxstrap/UI/Menu/ViewModels/FastFlagsViewModel.cs index d5ccc5e..ce1e301 100644 --- a/Bloxstrap/UI/Menu/ViewModels/FastFlagsViewModel.cs +++ b/Bloxstrap/UI/Menu/ViewModels/FastFlagsViewModel.cs @@ -40,26 +40,19 @@ namespace Bloxstrap.UI.Menu.ViewModels 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) - { - if (!(App.FastFlags.GetValue("FFlagDebugGraphicsPreferD3D11") == "True" || App.FastFlags.GetValue("FFlagDebugGraphicsPreferD3D11FL10") == "True")) - { - App.FastFlags.SetRenderingMode("Direct3D 11"); - } - - OnPropertyChanged(nameof(SelectedRenderingMode)); - } + set + { + foreach (var mode in RenderingModes) + { + if (mode.Key != "Automatic") + App.FastFlags.SetValue(mode.Value, null); + } + + if (value == "Automatic") + return; + + App.FastFlags.SetValue(RenderingModes[value], "True"); + App.FastFlags.SetValueIf(value == "Vulkan", "FFlagRenderVulkanFixMinimizeWindow", "True"); } } diff --git a/Bloxstrap/UI/Menu/Views/Pages/FastFlagsPage.xaml b/Bloxstrap/UI/Menu/Views/Pages/FastFlagsPage.xaml index 5977714..d7a130e 100644 --- a/Bloxstrap/UI/Menu/Views/Pages/FastFlagsPage.xaml +++ b/Bloxstrap/UI/Menu/Views/Pages/FastFlagsPage.xaml @@ -98,15 +98,6 @@ - - - - - - - - -