Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add software rendering #1956

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Bloxstrap/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ protected override async void OnStartup(StartupEventArgs e)
FastFlags.Load();
}

if (LaunchSettings.ChangeRenderingMode)
{
Settings.Prop.SoftwareRenderingEnabled = !Settings.Prop.SoftwareRenderingEnabled;

if (!LaunchSettings.IsQuiet)
{
string renderingMode = Settings.Prop.SoftwareRenderingEnabled ?
Bloxstrap.Resources.Strings.Bootstrapper_ChangedRenderingMode_Software :
Bloxstrap.Resources.Strings.Bootstrapper_ChangedRenderingMode_Hardware;
string message = string.Format(Bloxstrap.Resources.Strings.Bootstrapper_ChangedRenderingMode, renderingMode);

Frontend.ShowMessageBox(message, MessageBoxImage.Information, MessageBoxButton.OK);
}
}

HttpClient.Timeout = TimeSpan.FromSeconds(30);
HttpClient.DefaultRequestHeaders.Add("User-Agent", ProjectRepository);

Expand Down
3 changes: 3 additions & 0 deletions Bloxstrap/LaunchSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class LaunchSettings
[LaunchFlag("-upgrade")]
public bool IsUpgrade { get; private set; } = false;

[LaunchFlag("-changerenderingmode")]
public bool ChangeRenderingMode { get; private set; } = false;

public LaunchMode RobloxLaunchMode { get; private set; } = LaunchMode.Player;

public string RobloxLaunchArgs { get; private set; } = "--app";
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Settings
public Theme Theme { get; set; } = Theme.Default;
public bool CheckForUpdates { get; set; } = true;
public bool CreateDesktopIcon { get; set; } = true;
public bool SoftwareRenderingEnabled { get; set; } = false;

// channel configuration
public string Channel { get; set; } = RobloxDeployment.DefaultChannel;
Expand Down
29 changes: 28 additions & 1 deletion Bloxstrap/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Bloxstrap/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@
<data name="Bootstrapper.AutoUpdateFailed" xml:space="preserve">
<value>Bloxstrap was unable to auto-update to {0}. Please update it manually by downloading and running the latest release from the GitHub page.</value>
</data>
<data name="Bootstrapper.ChangedRenderingMode" xml:space="preserve">
<value>Now using {0} rendering!</value>
</data>
<data name="Bootstrapper.ChangedRenderingMode.Hardware" xml:space="preserve">
<value>hardware</value>
</data>
<data name="Bootstrapper.ChangedRenderingMode.Software" xml:space="preserve">
<value>software</value>
</data>
<data name="Bootstrapper.Connectivity.Preventing" xml:space="preserve">
<value>It's possible that something is preventing Bloxstrap from connecting to the internet. Please check and try again.</value>
</data>
Expand Down
21 changes: 15 additions & 6 deletions Bloxstrap/UI/Elements/Base/WpfUiWindow.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,6 +11,19 @@ public class WpfUiWindow : UiWindow
{
private readonly IThemeService _themeService = new ThemeService();

protected override void OnSourceInitialized(EventArgs e)
{
if (App.Settings.Prop.SoftwareRenderingEnabled)
{
var hwndSource = PresentationSource.FromVisual(this) as HwndSource;

if (hwndSource != null)
hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly;
}

base.OnSourceInitialized(e);
}

public void ApplyTheme()
{
_themeService.SetTheme(App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Dark ? ThemeType.Dark : ThemeType.Light);
Expand Down
21 changes: 21 additions & 0 deletions Bloxstrap/UI/Elements/Base/WpfWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Windows;
using System.Windows.Interop;

namespace Bloxstrap.UI.Elements.Base
{
public class WpfWindow : Window
{
protected override void OnSourceInitialized(EventArgs e)
{
if (App.Settings.Prop.SoftwareRenderingEnabled)
{
var hwndSource = PresentationSource.FromVisual(this) as HwndSource;

if (hwndSource != null)
hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly;
}

base.OnSourceInitialized(e);
}
}
}
5 changes: 3 additions & 2 deletions Bloxstrap/UI/Elements/Bootstrapper/ByfronDialog.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Window x:Class="Bloxstrap.UI.Elements.Bootstrapper.ByfronDialog"
<base:WpfWindow x:Class="Bloxstrap.UI.Elements.Bootstrapper.ByfronDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
mc:Ignorable="d"
Width="600"
Height="400"
Expand Down Expand Up @@ -42,4 +43,4 @@
</Grid>
</Grid>
</Border>
</Window>
</base:WpfWindow>
5 changes: 3 additions & 2 deletions Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<ui:UiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.AddFastFlagDialog"
<base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.AddFastFlagDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs"
xmlns:resources="clr-namespace:Bloxstrap.Resources"
xmlns:converters="clr-namespace:Bloxstrap.UI.Converters"
Expand Down Expand Up @@ -96,4 +97,4 @@
</StackPanel>
</Border>
</Grid>
</ui:UiWindow>
</base:WpfUiWindow>
5 changes: 3 additions & 2 deletions Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<ui:UiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.ConnectivityDialog"
<base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.ConnectivityDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs"
xmlns:resources="clr-namespace:Bloxstrap.Resources"
mc:Ignorable="d"
Expand Down Expand Up @@ -42,4 +43,4 @@
</StackPanel>
</Border>
</Grid>
</ui:UiWindow>
</base:WpfUiWindow>
5 changes: 3 additions & 2 deletions Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<ui:UiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.ExceptionDialog"
<base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.ExceptionDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs"
xmlns:resources="clr-namespace:Bloxstrap.Resources"
mc:Ignorable="d"
Expand Down Expand Up @@ -48,4 +49,4 @@
</StackPanel>
</Border>
</Grid>
</ui:UiWindow>
</base:WpfUiWindow>
5 changes: 3 additions & 2 deletions Bloxstrap/UI/Elements/Dialogs/FluentMessageBox.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<ui:UiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.FluentMessageBox"
<base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.FluentMessageBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs"
mc:Ignorable="d"
Title="Bloxstrap"
Expand Down Expand Up @@ -43,4 +44,4 @@
</StackPanel>
</Border>
</Grid>
</ui:UiWindow>
</base:WpfUiWindow>