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

Delay back button appearance when performing a quick restart #30863

Merged
merged 6 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 8 additions & 5 deletions osu.Game/OsuGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,12 +1581,20 @@ private void screenChanged(IScreen current, IScreen newScreen)

if (current is IOsuScreen currentOsuScreen)
{
if (currentOsuScreen.AllowBackButton)
BackButton.State.UnbindFrom(currentOsuScreen.BackButtonState);

OverlayActivationMode.UnbindFrom(currentOsuScreen.OverlayActivationMode);
API.Activity.UnbindFrom(currentOsuScreen.Activity);
}

if (newScreen is IOsuScreen newOsuScreen)
{
if (newOsuScreen.AllowBackButton)
((IBindable<Visibility>)BackButton.State).BindTo(newOsuScreen.BackButtonState);
else
BackButton.Hide();
frenzibyte marked this conversation as resolved.
Show resolved Hide resolved

OverlayActivationMode.BindTo(newOsuScreen.OverlayActivationMode);
API.Activity.BindTo(newOsuScreen.Activity);

Expand All @@ -1597,11 +1605,6 @@ private void screenChanged(IScreen current, IScreen newScreen)
else
Toolbar.Show();

if (newOsuScreen.AllowBackButton)
BackButton.Show();
else
BackButton.Hide();

if (newOsuScreen.ShowFooter)
{
BackButton.Hide();
Expand Down
12 changes: 12 additions & 0 deletions osu.Game/Screens/IOsuScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

using System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Screens.Footer;
Expand Down Expand Up @@ -59,6 +62,15 @@ public interface IOsuScreen : IScreen
/// </summary>
IBindable<OverlayActivation> OverlayActivationMode { get; }

/// <summary>
/// Controls the visibility state of <see cref="BackButton"/> to better work with screen-specific transitions (i.e. quick restart in player).
/// The back button can still be triggered by the <see cref="GlobalAction.Back"/> action even while hidden.
/// </summary>
/// <remarks>
/// This is ignored when <see cref="AllowBackButton"/> is set to false.
/// </remarks>
IBindable<Visibility> BackButtonState { get; }

/// <summary>
/// The current <see cref="UserActivity"/> for this screen.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions osu.Game/Screens/OsuScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Overlays;
Expand Down Expand Up @@ -56,6 +57,10 @@ public abstract partial class OsuScreen : Screen, IOsuScreen, IHasDescription

IBindable<OverlayActivation> IOsuScreen.OverlayActivationMode => OverlayActivationMode;

public readonly Bindable<Visibility> BackButtonState = new Bindable<Visibility>(Visibility.Visible);

IBindable<Visibility> IOsuScreen.BackButtonState => BackButtonState;

public virtual bool CursorVisible => true;

protected new OsuGameBase Game => base.Game as OsuGameBase;
Expand Down
4 changes: 4 additions & 0 deletions osu.Game/Screens/Play/PlayerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ private void contentIn(double delayBeforeSideDisplays = 0)

if (quickRestart)
{
BackButtonState.Value = Visibility.Hidden;

// A quick restart starts by triggering a fade to black
AddInternal(quickRestartBlackLayer = new Box
{
Expand All @@ -496,6 +498,8 @@ private void contentIn(double delayBeforeSideDisplays = 0)
.Delay(quick_restart_initial_delay)
.ScaleTo(1)
.FadeInFromZero(500, Easing.OutQuint);

this.Delay(quick_restart_initial_delay).Schedule(() => BackButtonState.Value = Visibility.Visible);
}
else
{
Expand Down
Loading