From 5a0149fca82e4a37e42602f3979d380005ccd8be Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Fri, 27 Sep 2024 22:29:11 +0100 Subject: [PATCH] Implement WPF software rendering --- Bloxstrap/LaunchSettings.cs | 2 ++ Bloxstrap/Models/Persistable/Settings.cs | 1 + Bloxstrap/UI/Elements/Base/WpfUiWindow.cs | 19 +++++++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Bloxstrap/LaunchSettings.cs b/Bloxstrap/LaunchSettings.cs index 05ba45d9..4bd10b19 100644 --- a/Bloxstrap/LaunchSettings.cs +++ b/Bloxstrap/LaunchSettings.cs @@ -22,6 +22,8 @@ public class LaunchSettings public LaunchFlag NoLaunchFlag { get; } = new("nolaunch"); + public LaunchFlag NoGPUFlag { get; } = new("nogpu"); + public LaunchFlag UpgradeFlag { get; } = new("upgrade"); public LaunchFlag PlayerFlag { get; } = new("player"); diff --git a/Bloxstrap/Models/Persistable/Settings.cs b/Bloxstrap/Models/Persistable/Settings.cs index d4018ce1..bbfc2850 100644 --- a/Bloxstrap/Models/Persistable/Settings.cs +++ b/Bloxstrap/Models/Persistable/Settings.cs @@ -15,6 +15,7 @@ public class Settings public string Locale { get; set; } = "nil"; public bool ForceRobloxLanguage { get; set; } = false; public bool UseFastFlagManager { get; set; } = true; + public bool WPFSoftwareRender { get; set; } = false; // integration configuration public bool EnableActivityTracking { get; set; } = true; diff --git a/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs b/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs index 6291d03a..ad2135f3 100644 --- a/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs +++ b/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - +using System.Windows; +using System.Windows.Interop; using Wpf.Ui.Appearance; using Wpf.Ui.Controls; using Wpf.Ui.Mvvm.Contracts; @@ -25,5 +21,16 @@ public void ApplyTheme() _themeService.SetTheme(App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Dark ? ThemeType.Dark : ThemeType.Light); _themeService.SetSystemAccent(); } + + protected override void OnSourceInitialized(EventArgs e) + { + if (App.Settings.Prop.WPFSoftwareRender || App.LaunchSettings.NoGPUFlag.Active) + { + if (PresentationSource.FromVisual(this) is HwndSource hwndSource) + hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly; + } + + base.OnSourceInitialized(e); + } } }