Show restart notice when changing renderer

This commit is contained in:
Dean Herbert 2023-03-17 20:28:26 +09:00
parent 13be709718
commit 956fabb445
2 changed files with 27 additions and 4 deletions

View File

@ -19,6 +19,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString RendererHeader => new TranslatableString(getKey(@"renderer_header"), @"Renderer");
/// <summary>
/// "Renderer"
/// </summary>
public static LocalisableString Renderer => new TranslatableString(getKey(@"renderer"), @"Renderer");
/// <summary>
/// "Frame limiter"
/// </summary>
@ -144,6 +149,12 @@ namespace osu.Game.Localisation
/// </summary>
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}";
}
}

View File

@ -2,13 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Configuration;
using osu.Game.Localisation;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Overlays.Settings.Sections.Graphics
{
@ -17,15 +17,16 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
protected override LocalisableString Header => GraphicsSettingsStrings.RendererHeader;
[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);
Children = new Drawable[]
{
new SettingsEnumDropdown<RendererType>
{
LabelText = GraphicsSettingsStrings.Renderer,
Current = config.GetBindable<RendererType>(FrameworkSetting.Renderer),
Current = renderer,
Keywords = new[] { @"compatibility", @"directx" },
},
// TODO: this needs to be a custom dropdown at some point
@ -46,6 +47,17 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
Current = osuConfig.GetBindable<bool>(OsuSetting.ShowFpsDisplay)
},
};
renderer.BindValueChanged(r =>
{
if (r.NewValue == host.ResolvedRenderer)
return;
dialogOverlay.Push(new ConfirmDialog(GraphicsSettingsStrings.ChangeRendererConfirmation, game.AttemptExit, () =>
{
renderer.SetDefault();
}));
});
}
}
}