Use OverlayContainer in framework.

This commit is contained in:
Huo Yaoyuan 2016-10-16 17:14:17 +08:00
parent 5e9d555309
commit f4c381f745
5 changed files with 4 additions and 57 deletions

View File

@ -20,7 +20,7 @@
namespace osu.Game.Overlays
{
public class ChatConsole : Overlay
public class ChatConsole : OverlayContainer
{
private ChannelDisplay channelDisplay;

View File

@ -6,13 +6,14 @@
using OpenTK.Input;
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
namespace osu.Game.Overlays
{
public class Options : Overlay
public class Options : OverlayContainer
{
private const float width = 300;

View File

@ -1,53 +0,0 @@
using osu.Framework;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Overlays
{
/// <summary>
/// An element which starts hidden and can be toggled to visible.
/// </summary>
public abstract class Overlay : Container, IStateful<Visibility>
{
public override void Load(BaseGame game)
{
base.Load(game);
//TODO: init code using Alpha or IsVisible override to ensure we don't call Load on children before we first get unhidden.
PopOut();
Flush();
}
private Visibility state;
public Visibility State
{
get { return state; }
set
{
if (value == state) return;
state = value;
switch (value)
{
case Visibility.Hidden:
PopOut();
break;
case Visibility.Visible:
PopIn();
break;
}
}
}
protected abstract void PopIn();
protected abstract void PopOut();
public void ToggleVisibility() => State = (State == Visibility.Visible ? Visibility.Hidden : Visibility.Visible);
}
public enum Visibility
{
Hidden,
Visible
}
}

View File

@ -15,7 +15,7 @@
namespace osu.Game.Overlays
{
public class Toolbar : Overlay
public class Toolbar : OverlayContainer
{
private const float height = 50;

View File

@ -156,7 +156,6 @@
<Compile Include="OsuGameBase.cs" />
<Compile Include="Overlays\ChatConsole.cs" />
<Compile Include="Overlays\Options.cs" />
<Compile Include="Overlays\Overlay.cs" />
<Compile Include="Overlays\Toolbar.cs" />
<Compile Include="Overlays\ToolbarButton.cs" />
<Compile Include="Overlays\ToolbarModeButton.cs" />