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