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

Disable frame limiter dropdown when deemed appropriate #30481

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 19 additions & 0 deletions osu.Game/Localisation/RendererSettingsStrings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Localisation;

namespace osu.Game.Localisation
{
public static class RendererSettingsStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.RendererSettings";

/// <summary>
/// "Frame limiters are unavailable in this combination of renderer and threading mode."
/// </summary>
public static LocalisableString FrameLimitersUnavailableTooltip => new TranslatableString(getKey(@"frame_limiters_unavailable_tooltip"), @"Frame limiters are unavailable in this combination of renderer and threading mode.");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
36 changes: 34 additions & 2 deletions osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
Expand All @@ -21,12 +22,21 @@

private bool automaticRendererInUse;

private Bindable<FrameSync> configFrameSync = null!;
private SettingsEnumDropdown<FrameSync> frameSyncDropdown = null!;

private IBindable<bool> allowConfiguringFrameLimiter = null!;

[BackgroundDependencyLoader]
private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, IDialogOverlay? dialogOverlay, OsuGame? game, GameHost host)
{
var renderer = config.GetBindable<RendererType>(FrameworkSetting.Renderer);
automaticRendererInUse = renderer.Value == RendererType.Automatic;

configFrameSync = config.GetBindable<FrameSync>(FrameworkSetting.FrameSync);

allowConfiguringFrameLimiter = host.AllowConfiguringFrameSync.GetBoundCopy();

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'GameHost' does not contain a definition for 'AllowConfiguringFrameSync' and no accessible extension method 'AllowConfiguringFrameSync' accepting a first argument of type 'GameHost' could be found (are you missing a using directive or an assembly reference?)

Children = new Drawable[]
{
new RendererSettingsDropdown
Expand All @@ -40,10 +50,10 @@
Keywords = new[] { @"compatibility", @"directx" },
},
// TODO: this needs to be a custom dropdown at some point
new SettingsEnumDropdown<FrameSync>
frameSyncDropdown = new SettingsEnumDropdown<FrameSync>
{
LabelText = GraphicsSettingsStrings.FrameLimiter,
Current = config.GetBindable<FrameSync>(FrameworkSetting.FrameSync),
Current = configFrameSync.GetUnboundCopy(),
Keywords = new[] { @"fps" },
},
new SettingsEnumDropdown<ExecutionMode>
Expand Down Expand Up @@ -81,6 +91,28 @@
});
}

protected override void LoadComplete()
{
base.LoadComplete();

allowConfiguringFrameLimiter.BindValueChanged(v =>
{
frameSyncDropdown.Current.Disabled = !v.NewValue;
frameSyncDropdown.TooltipText = v.NewValue ? string.Empty : RendererSettingsStrings.FrameLimitersUnavailableTooltip;
}, true);

configFrameSync.BindValueChanged(val =>
{
bool disabled = frameSyncDropdown.Current.Disabled;

frameSyncDropdown.Current.Disabled = false;
frameSyncDropdown.Current.Value = val.NewValue;
frameSyncDropdown.Current.Disabled = disabled;
}, true);

frameSyncDropdown.Current.BindValueChanged(val => configFrameSync.Value = val.NewValue);
}

private partial class RendererSettingsDropdown : SettingsEnumDropdown<RendererType>
{
protected override OsuDropdown<RendererType> CreateDropdown() => new RendererDropdown();
Expand Down
Loading