mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 20:07:25 +08:00
59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
//Copyright (c) 2007-2016 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;
|
|
using OpenTK;
|
|
using osu.Framework;
|
|
using osu.Framework.Graphics.Sprites;
|
|
using OpenTK.Graphics;
|
|
|
|
namespace osu.Game.GameModes.Play.Osu
|
|
{
|
|
public class OsuPlayfield : Playfield
|
|
{
|
|
protected override Container<Drawable> Content => hitObjectContainer;
|
|
|
|
private Container hitObjectContainer;
|
|
|
|
public override Vector2 Size
|
|
{
|
|
get
|
|
{
|
|
var parentSize = Parent.DrawSize;
|
|
var aspectSize = parentSize.X * 0.75f < parentSize.Y ? new Vector2(parentSize.X, parentSize.X * 0.75f) : new Vector2(parentSize.Y * 4f / 3f, parentSize.Y);
|
|
|
|
return new Vector2(aspectSize.X / parentSize.X, aspectSize.Y / parentSize.Y) * base.Size;
|
|
}
|
|
}
|
|
|
|
public OsuPlayfield()
|
|
{
|
|
Anchor = Anchor.Centre;
|
|
Origin = Anchor.Centre;
|
|
RelativeSizeAxes = Axes.Both;
|
|
Size = new Vector2(0.75f);
|
|
|
|
AddInternal(new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Colour = Color4.Black,
|
|
Alpha = 0.5f,
|
|
});
|
|
|
|
AddInternal(hitObjectContainer = new HitObjectContainer
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
});
|
|
}
|
|
|
|
class HitObjectContainer : Container
|
|
{
|
|
public override Vector2 ChildScale => new Vector2(0.625f);
|
|
}
|
|
}
|
|
} |