add OverlayActivation enum

+ fix Toolbar being toggleable when it shouldn't be able to
+ allow opening overlays in MenuState.Initial again
This commit is contained in:
Aergwyn
2018-05-28 13:43:47 +02:00
parent 1572635fc8
commit 2b3a630270
9 changed files with 89 additions and 44 deletions

View File

@ -0,0 +1,12 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Overlays
{
public enum OverlayActivation
{
Disabled,
//UserTriggered, // currently there is no way to discern user action
All
}
}

View File

@ -10,6 +10,8 @@ using osu.Framework.Input;
using osu.Game.Graphics;
using OpenTK;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
namespace osu.Game.Overlays.Toolbar
{
@ -29,6 +31,11 @@ namespace osu.Game.Overlays.Toolbar
private const float alpha_hovering = 0.8f;
private const float alpha_normal = 0.6f;
/// <summary>
/// Defaults to <see cref="OverlayActivation.All"/> so that the overlay works even if BDL couldn't pass an <see cref="OsuGame"/>.
/// </summary>
private readonly Bindable<OverlayActivation> allowOverlays = new Bindable<OverlayActivation>(OverlayActivation.All);
public Toolbar()
{
Children = new Drawable[]
@ -76,6 +83,19 @@ namespace osu.Game.Overlays.Toolbar
Size = new Vector2(1, HEIGHT);
}
[BackgroundDependencyLoader(true)]
private void load(OsuGame osuGame)
{
if (osuGame != null)
allowOverlays.BindTo(osuGame.AllowOverlays);
StateChanged += visibility =>
{
if (allowOverlays == OverlayActivation.Disabled)
State = Visibility.Hidden;
};
}
public class ToolbarBackground : Container
{
private readonly Box solidBackground;