diff --git a/osu.Game/Localisation/GraphicsSettingsStrings.cs b/osu.Game/Localisation/GraphicsSettingsStrings.cs
index 6e05929d81..422704514f 100644
--- a/osu.Game/Localisation/GraphicsSettingsStrings.cs
+++ b/osu.Game/Localisation/GraphicsSettingsStrings.cs
@@ -19,6 +19,11 @@ namespace osu.Game.Localisation
///
public static LocalisableString RendererHeader => new TranslatableString(getKey(@"renderer_header"), @"Renderer");
+ ///
+ /// "Renderer"
+ ///
+ public static LocalisableString Renderer => new TranslatableString(getKey(@"renderer"), @"Renderer");
+
///
/// "Frame limiter"
///
@@ -144,6 +149,12 @@ namespace osu.Game.Localisation
///
public static LocalisableString Png => new TranslatableString(getKey(@"png_lossless"), @"PNG (lossless)");
+ ///
+ /// "In order to change the renderer, the game will close. Please open it again."
+ ///
+ public static LocalisableString ChangeRendererConfirmation =>
+ new TranslatableString(getKey(@"change_renderer_configuration"), @"In order to change the renderer, the game will close. Please open it again.");
+
private static string getKey(string key) => $"{prefix}:{key}";
}
}
diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs
index a5fdfdc105..a4b0feb8bf 100644
--- a/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs
+++ b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs
@@ -1,15 +1,18 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
+using System.Linq;
+using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
+using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Configuration;
+using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
+using osu.Game.Overlays.Dialog;
namespace osu.Game.Overlays.Settings.Sections.Graphics
{
@@ -17,12 +20,25 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
{
protected override LocalisableString Header => GraphicsSettingsStrings.RendererHeader;
+ private bool automaticRendererInUse;
+
[BackgroundDependencyLoader]
- private void load(FrameworkConfigManager config, OsuConfigManager osuConfig)
+ private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, IDialogOverlay? dialogOverlay, OsuGame? game, GameHost host)
{
- // NOTE: Compatability mode omitted
+ var renderer = config.GetBindable(FrameworkSetting.Renderer);
+ automaticRendererInUse = renderer.Value == RendererType.Automatic;
+
+ SettingsEnumDropdown rendererDropdown;
+
Children = new Drawable[]
{
+ rendererDropdown = new RendererSettingsDropdown
+ {
+ LabelText = GraphicsSettingsStrings.Renderer,
+ Current = renderer,
+ Items = host.GetPreferredRenderersForCurrentPlatform().OrderBy(t => t),
+ Keywords = new[] { @"compatibility", @"directx" },
+ },
// TODO: this needs to be a custom dropdown at some point
new SettingsEnumDropdown
{
@@ -41,6 +57,55 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
Current = osuConfig.GetBindable(OsuSetting.ShowFpsDisplay)
},
};
+
+ renderer.BindValueChanged(r =>
+ {
+ if (r.NewValue == host.ResolvedRenderer)
+ return;
+
+ // Need to check startup renderer for the "automatic" case, as ResolvedRenderer above will track the final resolved renderer instead.
+ if (r.NewValue == RendererType.Automatic && automaticRendererInUse)
+ return;
+
+ dialogOverlay?.Push(new ConfirmDialog(GraphicsSettingsStrings.ChangeRendererConfirmation, () => game?.AttemptExit(), () =>
+ {
+ renderer.Value = automaticRendererInUse ? RendererType.Automatic : host.ResolvedRenderer;
+ }));
+ });
+
+ // TODO: remove this once we support SDL+android.
+ if (RuntimeInfo.OS == RuntimeInfo.Platform.Android)
+ {
+ rendererDropdown.Items = new[] { RendererType.Automatic, RendererType.OpenGLLegacy };
+ rendererDropdown.SetNoticeText("New renderer support for android is coming soon!", true);
+ }
+ }
+
+ private partial class RendererSettingsDropdown : SettingsEnumDropdown
+ {
+ protected override OsuDropdown CreateDropdown() => new RendererDropdown();
+
+ protected partial class RendererDropdown : DropdownControl
+ {
+ private RendererType hostResolvedRenderer;
+ private bool automaticRendererInUse;
+
+ [BackgroundDependencyLoader]
+ private void load(FrameworkConfigManager config, GameHost host)
+ {
+ var renderer = config.GetBindable(FrameworkSetting.Renderer);
+ automaticRendererInUse = renderer.Value == RendererType.Automatic;
+ hostResolvedRenderer = host.ResolvedRenderer;
+ }
+
+ protected override LocalisableString GenerateItemText(RendererType item)
+ {
+ if (item == RendererType.Automatic && automaticRendererInUse)
+ return LocalisableString.Interpolate($"{base.GenerateItemText(item)} ({hostResolvedRenderer.GetDescription()})");
+
+ return base.GenerateItemText(item);
+ }
+ }
}
}
}