mirror of
https://github.com/ppy/osu.git
synced 2025-01-23 22:53:04 +08:00
Rename AllowBackButton
to AllowUserExit
and rewrite visibility flow structure
Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
parent
ae9119eef0
commit
3e1b4f4ac5
@ -175,6 +175,11 @@ namespace osu.Game
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly IBindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
|
public readonly IBindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the back button is currently displayed.
|
||||||
|
/// </summary>
|
||||||
|
public readonly IBindable<bool> BackButtonVisibility = new Bindable<bool>();
|
||||||
|
|
||||||
IBindable<LocalUserPlayingState> ILocalUserPlayInfo.PlayingState => playingState;
|
IBindable<LocalUserPlayingState> ILocalUserPlayInfo.PlayingState => playingState;
|
||||||
|
|
||||||
private readonly Bindable<LocalUserPlayingState> playingState = new Bindable<LocalUserPlayingState>();
|
private readonly Bindable<LocalUserPlayingState> playingState = new Bindable<LocalUserPlayingState>();
|
||||||
@ -1019,7 +1024,7 @@ namespace osu.Game
|
|||||||
if (!(ScreenStack.CurrentScreen is IOsuScreen currentScreen))
|
if (!(ScreenStack.CurrentScreen is IOsuScreen currentScreen))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!((Drawable)currentScreen).IsLoaded || (currentScreen.AllowBackButton && !currentScreen.OnBackButton()))
|
if (!((Drawable)currentScreen).IsLoaded || (currentScreen.AllowUserExit && !currentScreen.OnBackButton()))
|
||||||
ScreenStack.Exit();
|
ScreenStack.Exit();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1189,6 +1194,14 @@ namespace osu.Game
|
|||||||
if (mode.NewValue != OverlayActivation.All) CloseAllOverlays();
|
if (mode.NewValue != OverlayActivation.All) CloseAllOverlays();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BackButtonVisibility.ValueChanged += visible =>
|
||||||
|
{
|
||||||
|
if (visible.NewValue)
|
||||||
|
BackButton.Show();
|
||||||
|
else
|
||||||
|
BackButton.Hide();
|
||||||
|
};
|
||||||
|
|
||||||
// Importantly, this should be run after binding PostNotification to the import handlers so they can present the import after game startup.
|
// Importantly, this should be run after binding PostNotification to the import handlers so they can present the import after game startup.
|
||||||
handleStartupImport();
|
handleStartupImport();
|
||||||
}
|
}
|
||||||
@ -1581,20 +1594,14 @@ namespace osu.Game
|
|||||||
|
|
||||||
if (current is IOsuScreen currentOsuScreen)
|
if (current is IOsuScreen currentOsuScreen)
|
||||||
{
|
{
|
||||||
if (currentOsuScreen.AllowBackButton)
|
BackButtonVisibility.UnbindFrom(currentOsuScreen.BackButtonVisibility);
|
||||||
BackButton.State.UnbindFrom(currentOsuScreen.BackButtonState);
|
|
||||||
|
|
||||||
OverlayActivationMode.UnbindFrom(currentOsuScreen.OverlayActivationMode);
|
OverlayActivationMode.UnbindFrom(currentOsuScreen.OverlayActivationMode);
|
||||||
API.Activity.UnbindFrom(currentOsuScreen.Activity);
|
API.Activity.UnbindFrom(currentOsuScreen.Activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newScreen is IOsuScreen newOsuScreen)
|
if (newScreen is IOsuScreen newOsuScreen)
|
||||||
{
|
{
|
||||||
if (newOsuScreen.AllowBackButton)
|
BackButtonVisibility.BindTo(newOsuScreen.BackButtonVisibility);
|
||||||
((IBindable<Visibility>)BackButton.State).BindTo(newOsuScreen.BackButtonState);
|
|
||||||
else
|
|
||||||
BackButton.Hide();
|
|
||||||
|
|
||||||
OverlayActivationMode.BindTo(newOsuScreen.OverlayActivationMode);
|
OverlayActivationMode.BindTo(newOsuScreen.OverlayActivationMode);
|
||||||
API.Activity.BindTo(newOsuScreen.Activity);
|
API.Activity.BindTo(newOsuScreen.Activity);
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private OsuGame game { get; set; }
|
private OsuGame game { get; set; }
|
||||||
|
|
||||||
public override bool AllowBackButton => false;
|
public override bool AllowUserExit => false;
|
||||||
|
|
||||||
public override bool AllowExternalScreenChange => false;
|
public override bool AllowExternalScreenChange => false;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public override float BackgroundParallaxAmount => 0.1f;
|
public override float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
public override bool AllowBackButton => false;
|
public override bool AllowUserExit => false;
|
||||||
|
|
||||||
public override bool HideOverlaysOnEnter => true;
|
public override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public override float BackgroundParallaxAmount => 0.1f;
|
public override float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
public override bool AllowBackButton => false;
|
public override bool AllowUserExit => false;
|
||||||
|
|
||||||
public override bool HideOverlaysOnEnter => true;
|
public override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
|
@ -3,10 +3,8 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -24,15 +22,20 @@ namespace osu.Game.Screens
|
|||||||
bool DisallowExternalBeatmapRulesetChanges { get; }
|
bool DisallowExternalBeatmapRulesetChanges { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the user can exit this <see cref="IOsuScreen"/> by pressing the back button.
|
/// Whether the user can exit this <see cref="IOsuScreen"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool AllowBackButton { get; }
|
/// <remarks>
|
||||||
|
/// When overriden to <c>false</c>,
|
||||||
|
/// the user is blocked from exiting the screen via the <see cref="GlobalAction.Back"/> action,
|
||||||
|
/// and the back button is hidden from this screen by the initial state of <see cref="BackButtonVisibility"/> being set to hidden.
|
||||||
|
/// </remarks>
|
||||||
|
bool AllowUserExit { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether a footer (and a back button) should be displayed underneath the screen.
|
/// Whether a footer (and a back button) should be displayed underneath the screen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Temporarily, the back button is shown regardless of whether <see cref="AllowBackButton"/> is true.
|
/// Temporarily, the back button is shown regardless of whether <see cref="AllowUserExit"/> is true.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
bool ShowFooter { get; }
|
bool ShowFooter { get; }
|
||||||
|
|
||||||
@ -63,13 +66,9 @@ namespace osu.Game.Screens
|
|||||||
IBindable<OverlayActivation> OverlayActivationMode { get; }
|
IBindable<OverlayActivation> OverlayActivationMode { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controls the visibility state of <see cref="BackButton"/> to better work with screen-specific transitions (i.e. quick restart in player).
|
/// Whether the back button should be displayed in this screen.
|
||||||
/// The back button can still be triggered by the <see cref="GlobalAction.Back"/> action even while hidden.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
IBindable<bool> BackButtonVisibility { get; }
|
||||||
/// This is ignored when <see cref="AllowBackButton"/> is set to false.
|
|
||||||
/// </remarks>
|
|
||||||
IBindable<Visibility> BackButtonState { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current <see cref="UserActivity"/> for this screen.
|
/// The current <see cref="UserActivity"/> for this screen.
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
public override bool HideOverlaysOnEnter => Buttons == null || Buttons.State == ButtonSystemState.Initial;
|
public override bool HideOverlaysOnEnter => Buttons == null || Buttons.State == ButtonSystemState.Initial;
|
||||||
|
|
||||||
public override bool AllowBackButton => false;
|
public override bool AllowUserExit => false;
|
||||||
|
|
||||||
public override bool AllowExternalScreenChange => true;
|
public override bool AllowExternalScreenChange => true;
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
if (!(screenStack.CurrentScreen is IOnlinePlaySubScreen onlineSubScreen))
|
if (!(screenStack.CurrentScreen is IOnlinePlaySubScreen onlineSubScreen))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (((Drawable)onlineSubScreen).IsLoaded && onlineSubScreen.AllowBackButton && onlineSubScreen.OnBackButton())
|
if (((Drawable)onlineSubScreen).IsLoaded && onlineSubScreen.AllowUserExit && onlineSubScreen.OnBackButton())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (screenStack.CurrentScreen != null && !(screenStack.CurrentScreen is LoungeSubScreen))
|
if (screenStack.CurrentScreen != null && !(screenStack.CurrentScreen is LoungeSubScreen))
|
||||||
|
@ -11,7 +11,6 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -38,7 +37,7 @@ namespace osu.Game.Screens
|
|||||||
|
|
||||||
public string Description => Title;
|
public string Description => Title;
|
||||||
|
|
||||||
public virtual bool AllowBackButton => true;
|
public virtual bool AllowUserExit => true;
|
||||||
|
|
||||||
public virtual bool ShowFooter => false;
|
public virtual bool ShowFooter => false;
|
||||||
|
|
||||||
@ -57,9 +56,14 @@ namespace osu.Game.Screens
|
|||||||
|
|
||||||
IBindable<OverlayActivation> IOsuScreen.OverlayActivationMode => OverlayActivationMode;
|
IBindable<OverlayActivation> IOsuScreen.OverlayActivationMode => OverlayActivationMode;
|
||||||
|
|
||||||
public readonly Bindable<Visibility> BackButtonState = new Bindable<Visibility>(Visibility.Visible);
|
/// <summary>
|
||||||
|
/// The initial visibility state of the back button when this screen is entered for the first time.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual bool InitialBackButtonVisibility => AllowUserExit;
|
||||||
|
|
||||||
IBindable<Visibility> IOsuScreen.BackButtonState => BackButtonState;
|
public readonly Bindable<bool> BackButtonVisibility;
|
||||||
|
|
||||||
|
IBindable<bool> IOsuScreen.BackButtonVisibility => BackButtonVisibility;
|
||||||
|
|
||||||
public virtual bool CursorVisible => true;
|
public virtual bool CursorVisible => true;
|
||||||
|
|
||||||
@ -159,6 +163,7 @@ namespace osu.Game.Screens
|
|||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
OverlayActivationMode = new Bindable<OverlayActivation>(InitialOverlayActivationMode);
|
OverlayActivationMode = new Bindable<OverlayActivation>(InitialOverlayActivationMode);
|
||||||
|
BackButtonVisibility = new Bindable<bool>(InitialBackButtonVisibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action OnGameplayStarted;
|
public event Action OnGameplayStarted;
|
||||||
|
|
||||||
public override bool AllowBackButton => false; // handled by HoldForMenuButton
|
public override bool AllowUserExit => false; // handled by HoldForMenuButton
|
||||||
|
|
||||||
protected override bool PlayExitSound => !isRestarting;
|
protected override bool PlayExitSound => !isRestarting;
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
if (quickRestart)
|
if (quickRestart)
|
||||||
{
|
{
|
||||||
BackButtonState.Value = Visibility.Hidden;
|
BackButtonVisibility.Value = false;
|
||||||
|
|
||||||
// A quick restart starts by triggering a fade to black
|
// A quick restart starts by triggering a fade to black
|
||||||
AddInternal(quickRestartBlackLayer = new Box
|
AddInternal(quickRestartBlackLayer = new Box
|
||||||
@ -499,7 +499,7 @@ namespace osu.Game.Screens.Play
|
|||||||
.ScaleTo(1)
|
.ScaleTo(1)
|
||||||
.FadeInFromZero(500, Easing.OutQuint);
|
.FadeInFromZero(500, Easing.OutQuint);
|
||||||
|
|
||||||
this.Delay(quick_restart_initial_delay).Schedule(() => BackButtonState.Value = Visibility.Visible);
|
this.Delay(quick_restart_initial_delay).Schedule(() => BackButtonVisibility.Value = true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace osu.Game.Screens
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract partial class StartupScreen : OsuScreen
|
public abstract partial class StartupScreen : OsuScreen
|
||||||
{
|
{
|
||||||
public override bool AllowBackButton => false;
|
public override bool AllowUserExit => false;
|
||||||
|
|
||||||
public override bool HideOverlaysOnEnter => true;
|
public override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user