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

Change "hold for menu" button to only show for touch by default #29508

Merged
merged 4 commits into from
Aug 20, 2024
Merged
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
2 changes: 2 additions & 0 deletions osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public void TestHoldForMenuDoesWorkWhenHidden()
holdForMenu.Action += () => activated = true;
});

AddStep("set hold button always visible", () => localConfig.SetValue(OsuSetting.AlwaysShowHoldForMenuButton, true));
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddUntilStep("hidetarget is hidden", () => hideTarget.Alpha, () => Is.LessThanOrEqualTo(0));

Expand Down Expand Up @@ -214,6 +215,7 @@ public void TestInputDoesntWorkWhenHUDHidden()
progress.ChildrenOfType<ArgonSongProgressBar>().Single().OnSeek += _ => seeked = true;
});

AddStep("set hold button always visible", () => localConfig.SetValue(OsuSetting.AlwaysShowHoldForMenuButton, true));
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddUntilStep("hidetarget is hidden", () => hideTarget.Alpha, () => Is.LessThanOrEqualTo(0));

Expand Down
14 changes: 11 additions & 3 deletions osu.Game.Tests/Visual/Gameplay/TestSceneHoldForMenuButton.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Screens.Play.HUD;
using osuTK;
using osuTK.Input;
Expand All @@ -21,11 +21,19 @@ public partial class TestSceneHoldForMenuButton : OsuManualInputManagerTestScene

protected override double TimePerAction => 100; // required for the early exit test, since hold-to-confirm delay is 200ms

private HoldForMenuButton holdForMenuButton;
private HoldForMenuButton holdForMenuButton = null!;

[Resolved]
private OsuConfigManager config { get; set; } = null!;

[SetUpSteps]
public void SetUpSteps()
{
AddStep("set button always on", () =>
{
config.SetValue(OsuSetting.AlwaysShowHoldForMenuButton, true);
});

AddStep("create button", () =>
{
exitAction = false;
Expand Down
2 changes: 2 additions & 0 deletions osu.Game.Tests/Visual/Gameplay/TestScenePause.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ public void TestQuickExitFromGameplay()
[Test]
public void TestExitViaHoldToExit()
{
AddStep("set hold button always visible", () => LocalConfig.SetValue(OsuSetting.AlwaysShowHoldForMenuButton, true));

AddStep("exit", () =>
{
InputManager.MoveMouseTo(Player.HUDOverlay.HoldToQuit.First(c => c is HoldToConfirmContainer));
Expand Down
3 changes: 3 additions & 0 deletions osu.Game/Configuration/OsuConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ protected override void InitialiseDefaults()

SetDefault(OsuSetting.EditorTimelineShowTimingChanges, true);
SetDefault(OsuSetting.EditorTimelineShowTicks, true);

SetDefault(OsuSetting.AlwaysShowHoldForMenuButton, false);
}

protected override bool CheckLookupContainsPrivateInformation(OsuSetting lookup)
Expand Down Expand Up @@ -429,5 +431,6 @@ public enum OsuSetting
HideCountryFlags,
EditorTimelineShowTimingChanges,
EditorTimelineShowTicks,
AlwaysShowHoldForMenuButton
}
}
5 changes: 5 additions & 0 deletions osu.Game/Localisation/GameplaySettingsStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public static class GameplaySettingsStrings
/// </summary>
public static LocalisableString AlwaysShowGameplayLeaderboard => new TranslatableString(getKey(@"gameplay_leaderboard"), @"Always show gameplay leaderboard");

/// <summary>
/// "Always show hold for menu button"
/// </summary>
public static LocalisableString AlwaysShowHoldForMenuButton => new TranslatableString(getKey(@"always_show_hold_for_menu_button"), @"Always show hold for menu button");

/// <summary>
/// "Always play first combo break sound"
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ private void load(OsuConfigManager config)
Current = config.GetBindable<bool>(OsuSetting.GameplayLeaderboard),
},
new SettingsCheckbox
{
LabelText = GameplaySettingsStrings.AlwaysShowHoldForMenuButton,
Current = config.GetBindable<bool>(OsuSetting.AlwaysShowHoldForMenuButton),
},
new SettingsCheckbox
{
ClassicDefault = false,
LabelText = GameplaySettingsStrings.ShowHealthDisplayWhenCantFail,
Expand Down
17 changes: 15 additions & 2 deletions osu.Game/Screens/Play/HUD/HoldForMenuButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public partial class HoldForMenuButton : FillFlowContainer
{
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;

public override bool PropagatePositionalInputSubTree => alwaysShow.Value || touchActive.Value;

public readonly Bindable<bool> IsPaused = new Bindable<bool>();

public readonly Bindable<bool> ReplayLoaded = new Bindable<bool>();
Expand All @@ -40,6 +42,8 @@ public partial class HoldForMenuButton : FillFlowContainer

private OsuSpriteText text;

private Bindable<bool> alwaysShow;

public HoldForMenuButton()
{
Direction = FillDirection.Horizontal;
Expand All @@ -50,7 +54,7 @@ public HoldForMenuButton()
}

[BackgroundDependencyLoader(true)]
private void load(Player player)
private void load(Player player, OsuConfigManager config)
{
Children = new Drawable[]
{
Expand All @@ -71,6 +75,8 @@ private void load(Player player)
};

AutoSizeAxes = Axes.Both;

alwaysShow = config.GetBindable<bool>(OsuSetting.AlwaysShowHoldForMenuButton);
}

[Resolved]
Expand Down Expand Up @@ -117,16 +123,23 @@ protected override void Update()
{
base.Update();

// While the button is hovered or still animating, keep fully visible.
if (text.Alpha > 0 || button.Progress.Value > 0 || button.IsHovered)
Alpha = 1;
else
// When touch input is detected, keep visible at a constant opacity.
else if (touchActive.Value)
Alpha = 0.5f;
// Otherwise, if the user chooses, show it when the mouse is nearby.
else if (alwaysShow.Value)
{
float minAlpha = touchActive.Value ? .08f : 0;

Alpha = Interpolation.ValueAt(
Math.Clamp(Clock.ElapsedFrameTime, 0, 200),
Alpha, Math.Clamp(1 - positionalAdjust, minAlpha, 1), 0, 200, Easing.OutQuint);
}
else
Alpha = 0;
}

private partial class HoldButton : HoldToConfirmContainer, IKeyBindingHandler<GlobalAction>
Expand Down
Loading