mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 06:03:22 +08:00
Merge pull request #22924 from peppy/add-renderer-selection
Add ability to select renderer
This commit is contained in:
commit
6751f78304
@ -19,6 +19,11 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString RendererHeader => new TranslatableString(getKey(@"renderer_header"), @"Renderer");
|
public static LocalisableString RendererHeader => new TranslatableString(getKey(@"renderer_header"), @"Renderer");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Renderer"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString Renderer => new TranslatableString(getKey(@"renderer"), @"Renderer");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "Frame limiter"
|
/// "Frame limiter"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -144,6 +149,12 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString Png => new TranslatableString(getKey(@"png_lossless"), @"PNG (lossless)");
|
public static LocalisableString Png => new TranslatableString(getKey(@"png_lossless"), @"PNG (lossless)");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "In order to change the renderer, the game will close. Please open it again."
|
||||||
|
/// </summary>
|
||||||
|
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}";
|
private static string getKey(string key) => $"{prefix}:{key}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// 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.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
|
using osu.Game.Overlays.Dialog;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||||
{
|
{
|
||||||
@ -17,12 +20,25 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
|||||||
{
|
{
|
||||||
protected override LocalisableString Header => GraphicsSettingsStrings.RendererHeader;
|
protected override LocalisableString Header => GraphicsSettingsStrings.RendererHeader;
|
||||||
|
|
||||||
|
private bool automaticRendererInUse;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[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<RendererType>(FrameworkSetting.Renderer);
|
||||||
|
automaticRendererInUse = renderer.Value == RendererType.Automatic;
|
||||||
|
|
||||||
|
SettingsEnumDropdown<RendererType> rendererDropdown;
|
||||||
|
|
||||||
Children = new Drawable[]
|
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
|
// TODO: this needs to be a custom dropdown at some point
|
||||||
new SettingsEnumDropdown<FrameSync>
|
new SettingsEnumDropdown<FrameSync>
|
||||||
{
|
{
|
||||||
@ -41,6 +57,55 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
|||||||
Current = osuConfig.GetBindable<bool>(OsuSetting.ShowFpsDisplay)
|
Current = osuConfig.GetBindable<bool>(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<RendererType>
|
||||||
|
{
|
||||||
|
protected override OsuDropdown<RendererType> 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<RendererType>(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user