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

69 lines
2.2 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
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-03-06 12:59:11 +08:00
using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Drawables;
2017-03-07 14:43:44 +08:00
using OpenTK;
2016-11-14 17:54:24 +08:00
namespace osu.Game.Modes.UI
{
2017-03-06 12:59:11 +08:00
public abstract class Playfield<T> : Container
where T : HitObject
{
2017-03-06 12:59:11 +08:00
public HitObjectContainer<DrawableHitObject<T>> HitObjects;
public virtual void Add(DrawableHitObject<T> h) => HitObjects.Add(h);
internal Container<Drawable> ScaledContent;
public override bool Contains(Vector2 screenSpacePos) => true;
2017-03-07 09:59:19 +08:00
protected override Container<Drawable> Content { get; }
2017-03-07 14:43:44 +08:00
/// <summary>
/// A container for keeping track of DrawableHitObjects.
/// </summary>
/// <param name="customWidth">Whether we want our internal coordinate system to be scaled to a specified width.</param>
protected Playfield(float? customWidth = null)
{
AddInternal(ScaledContent = new ScaledContainer
{
2017-03-07 14:43:44 +08:00
CustomWidth = customWidth,
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,
}
}
});
2017-03-06 12:59:11 +08:00
Add(HitObjects = new HitObjectContainer<DrawableHitObject<T>>
{
RelativeSizeAxes = Axes.Both,
});
}
2017-02-10 13:16:23 +08:00
public virtual void PostProcess()
{
}
2017-03-07 14:43:44 +08:00
private class ScaledContainer : Container
{
2017-03-07 14:43:44 +08:00
public float? CustomWidth;
protected override Vector2 DrawScale => CustomWidth.HasValue ? new Vector2(DrawSize.X / CustomWidth.Value) : base.DrawScale;
public override bool Contains(Vector2 screenSpacePos) => true;
}
2017-03-07 14:43:44 +08:00
public class HitObjectContainer<U> : Container<U> where U : Drawable
{
public override bool Contains(Vector2 screenSpacePos) => true;
}
}
}