mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:23:20 +08:00
Allow controlling back button visibility state from screens
This commit is contained in:
parent
354bc424a3
commit
2420793466
@ -1581,12 +1581,20 @@ namespace osu.Game
|
||||
|
||||
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();
|
||||
|
||||
OverlayActivationMode.BindTo(newOsuScreen.OverlayActivationMode);
|
||||
API.Activity.BindTo(newOsuScreen.Activity);
|
||||
|
||||
@ -1597,11 +1605,6 @@ namespace osu.Game
|
||||
else
|
||||
Toolbar.Show();
|
||||
|
||||
if (newOsuScreen.AllowBackButton)
|
||||
BackButton.Show();
|
||||
else
|
||||
BackButton.Hide();
|
||||
|
||||
if (newOsuScreen.ShowFooter)
|
||||
{
|
||||
BackButton.Hide();
|
||||
|
@ -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;
|
||||
@ -59,6 +62,15 @@ namespace osu.Game.Screens
|
||||
/// </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>
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Audio;
|
||||
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;
|
||||
@ -56,6 +57,10 @@ namespace osu.Game.Screens
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user