1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 09:23:06 +08:00

Move toolbar showing and overlay activation to OsuGame

Now exposed through IOsuScreen.
This commit is contained in:
smoogipoo 2019-01-28 15:41:54 +09:00
parent 117703374e
commit 7b1c1f3728
13 changed files with 56 additions and 37 deletions

View File

@ -747,6 +747,16 @@ namespace osu.Game
menuScreen = menu;
break;
}
if (newScreen is IOsuScreen newOsuScreen)
{
OverlayActivationMode.Value = newOsuScreen.InitialOverlayActivationMode;
if (newOsuScreen.HideOverlaysOnEnter)
CloseAllOverlays();
else
Toolbar.State = Visibility.Visible;
}
}
private void screenPushed(IScreen lastScreen, IScreen newScreen)

View File

@ -28,7 +28,7 @@ namespace osu.Game.Screens.Edit
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
protected override bool HideOverlaysOnEnter => true;
public override bool HideOverlaysOnEnter => true;
public override bool AllowBeatmapRulesetChange => false;
private Box bottomBackground;

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Screens;
using osu.Game.Overlays;
namespace osu.Game.Screens
{
@ -19,5 +20,15 @@ namespace osu.Game.Screens
/// Whether this <see cref="OsuScreen"/> allows the cursor to be displayed.
/// </summary>
bool CursorVisible { get; }
/// <summary>
/// Whether all overlays should be hidden when this screen is entered or resumed.
/// </summary>
bool HideOverlaysOnEnter { get; }
/// <summary>
/// Whether overlays should be able to be opened once this screen is entered or resumed.
/// </summary>
OverlayActivation InitialOverlayActivationMode { get; }
}
}

View File

@ -17,9 +17,9 @@ namespace osu.Game.Screens
{
private bool showDisclaimer;
protected override bool HideOverlaysOnEnter => true;
public override bool HideOverlaysOnEnter => true;
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
protected override bool AllowBackButton => false;

View File

@ -23,8 +23,8 @@ namespace osu.Game.Screens.Menu
private Color4 iconColour;
private LinkFlowContainer textFlow;
protected override bool HideOverlaysOnEnter => true;
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override bool HideOverlaysOnEnter => true;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override bool CursorVisible => false;

View File

@ -34,8 +34,8 @@ namespace osu.Game.Screens.Menu
private SampleChannel welcome;
private SampleChannel seeya;
protected override bool HideOverlaysOnEnter => true;
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override bool HideOverlaysOnEnter => true;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
public override bool CursorVisible => false;

View File

@ -25,7 +25,7 @@ namespace osu.Game.Screens.Menu
{
private readonly ButtonSystem buttons;
protected override bool HideOverlaysOnEnter => buttons.State == ButtonSystemState.Initial;
public override bool HideOverlaysOnEnter => buttons.State == ButtonSystemState.Initial;
protected override bool AllowBackButton => buttons.State != ButtonSystemState.Initial;

View File

@ -16,6 +16,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Input;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapSet.Buttons;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Multi.Lounge;
@ -31,6 +32,9 @@ namespace osu.Game.Screens.Multi
public bool AllowExternalScreenChange => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowExternalScreenChange ?? true;
public bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowExternalScreenChange ?? true;
public bool HideOverlaysOnEnter => false;
public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public bool ValidForResume { get; set; } = true;
public bool ValidForPush { get; set; } = true;
@ -42,6 +46,8 @@ namespace osu.Game.Screens.Multi
private readonly LoungeSubScreen loungeSubScreen;
private readonly ScreenStack screenStack;
private readonly Bindable<OverlayActivation> overlayActivationMode = new Bindable<OverlayActivation>();
[Cached(Type = typeof(IRoomManager))]
private RoomManager roomManager;
@ -51,6 +57,9 @@ namespace osu.Game.Screens.Multi
[Resolved]
private OsuGameBase game { get; set; }
[Resolved]
private OsuGame osuGame { get; set; }
[Resolved]
private APIAccess api { get; set; }
@ -132,6 +141,9 @@ namespace osu.Game.Screens.Multi
if (idleTracker != null)
isIdle.BindTo(idleTracker.IsIdle);
if (osuGame != null)
overlayActivationMode.BindTo(osuGame.OverlayActivationMode);
}
protected override void LoadComplete()
@ -168,6 +180,8 @@ namespace osu.Game.Screens.Multi
{
this.FadeIn();
osuGame.Toolbar.State = Visibility.Visible;
waves.Show();
}
@ -194,6 +208,9 @@ namespace osu.Game.Screens.Multi
logo?.AppendAnimatingAction(() => OsuScreen.ApplyLogoArrivingDefaults(logo), true);
overlayActivationMode.Value = OverlayActivation.All;
osuGame.Toolbar.State = Visibility.Visible;
updatePollingRate(isIdle.Value);
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
namespace osu.Game.Screens.Multi
{
@ -18,6 +19,9 @@ namespace osu.Game.Screens.Multi
public bool AllowExternalScreenChange => true;
public bool CursorVisible => true;
public bool HideOverlaysOnEnter => false;
public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public bool ValidForResume { get; set; } = true;
public bool ValidForPush { get; set; } = true;

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using Microsoft.EntityFrameworkCore.Internal;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -15,7 +14,6 @@ using osu.Game.Input.Bindings;
using osu.Game.Rulesets;
using osu.Game.Screens.Menu;
using osu.Game.Overlays;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Screens
{
@ -32,19 +30,15 @@ namespace osu.Game.Screens
public virtual bool AllowExternalScreenChange => false;
private Action updateOverlayStates;
/// <summary>
/// Whether all overlays should be hidden when this screen is entered or resumed.
/// </summary>
protected virtual bool HideOverlaysOnEnter => false;
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
public virtual bool HideOverlaysOnEnter => false;
/// <summary>
/// Whether overlays should be able to be opened once this screen is entered or resumed.
/// </summary>
protected virtual OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public virtual OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public virtual bool CursorVisible => true;
@ -82,19 +76,6 @@ namespace osu.Game.Screens
Beatmap.BindTo(beatmap);
Ruleset.BindTo(ruleset);
if (osu != null)
{
OverlayActivationMode.BindTo(osu.OverlayActivationMode);
updateOverlayStates = () =>
{
if (HideOverlaysOnEnter)
osu.CloseAllOverlays();
else
osu.Toolbar.State = Visibility.Visible;
};
}
sampleExit = audio.Sample.Get(@"UI/screen-back");
}
@ -166,10 +147,6 @@ namespace osu.Game.Screens
}, true);
backgroundStack.ParallaxAmount = BackgroundParallaxAmount;
OverlayActivationMode.Value = InitialOverlayActivationMode;
updateOverlayStates?.Invoke();
}
/// <summary>

View File

@ -42,9 +42,9 @@ namespace osu.Game.Screens.Play
public override float BackgroundParallaxAmount => 0.1f;
protected override bool HideOverlaysOnEnter => true;
public override bool HideOverlaysOnEnter => true;
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered;
public Action RestartRequested;

View File

@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play
private BeatmapMetadataDisplay info;
private bool hideOverlays;
protected override bool HideOverlaysOnEnter => hideOverlays;
public override bool HideOverlaysOnEnter => hideOverlays;
private Task loadTask;

View File

@ -30,7 +30,7 @@ namespace osu.Game.Screens.Tournament
{
private const string results_filename = "drawings_results.txt";
protected override bool HideOverlaysOnEnter => true;
public override bool HideOverlaysOnEnter => true;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();