1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 20:47:25 +08:00
osu-lazer/osu.Game/Modes/UI/Playfield.cs

80 lines
2.3 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-02-28 19:14:48 +08:00
using osu.Framework.Allocation;
2017-02-10 13:16:23 +08:00
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-02-28 19:14:48 +08:00
using osu.Framework.Input;
using osu.Game.Modes.Objects.Drawables;
2016-11-14 17:54:24 +08:00
namespace osu.Game.Modes.UI
{
public abstract class Playfield : Container
{
public HitObjectContainer HitObjects;
2017-02-28 19:14:48 +08:00
private Container<Drawable> scaledContent;
public virtual void Add(DrawableHitObject h) => HitObjects.Add(h);
public override bool Contains(Vector2 screenSpacePos) => true;
protected override Container<Drawable> Content => content;
2017-02-28 19:14:48 +08:00
private Container content;
public Playfield()
{
2017-02-28 19:14:48 +08:00
AddInternal(scaledContent = new ScaledContainer
{
RelativeSizeAxes = Axes.Both,
2017-02-28 19:14:48 +08:00
Children = new[]
{
content = new Container
{
RelativeSizeAxes = Axes.Both,
}
}
});
Add(HitObjects = new HitObjectContainer
{
RelativeSizeAxes = Axes.Both,
});
}
2017-02-28 19:14:48 +08:00
/// <summary>
/// An optional inputManager to provide interactivity etc.
/// </summary>
public InputManager InputManager;
[BackgroundDependencyLoader]
private void load()
{
if (InputManager != null)
{
//if we've been provided an InputManager, we want it to sit inside the scaledcontainer
scaledContent.Remove(content);
scaledContent.Add(InputManager);
InputManager.Add(content);
}
}
2017-02-10 13:16:23 +08:00
public virtual void PostProcess()
{
}
public class ScaledContainer : Container
{
protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512);
public override bool Contains(Vector2 screenSpacePos) => true;
}
public class HitObjectContainer : Container<DrawableHitObject>
{
public override bool Contains(Vector2 screenSpacePos) => true;
}
}
}