1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-09 09:37:42 +08:00
osu-lazer/osu.Game.Rulesets.Catch/UI/PlayfieldAdjustmentContainer.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2018-09-21 13:02:32 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
2018-09-21 13:02:32 +08:00
using osu.Framework.Graphics.Containers;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-09-21 13:02:32 +08:00
namespace osu.Game.Rulesets.Catch.UI
{
public class PlayfieldAdjustmentContainer : Container
2018-09-21 13:02:32 +08:00
{
protected override Container<Drawable> Content => content;
private readonly Container content;
public PlayfieldAdjustmentContainer()
{
InternalChild = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
FillAspectRatio = 4f / 3,
Child = content = new ScalingContainer { RelativeSizeAxes = Axes.Both }
};
}
/// <summary>
/// A <see cref="Container"/> which scales its content relative to a target width.
/// </summary>
private class ScalingContainer : Container
2018-09-21 13:02:32 +08:00
{
protected override void Update()
{
base.Update();
2018-09-21 13:02:32 +08:00
Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.BASE_WIDTH);
Size = Vector2.Divide(Vector2.One, Scale);
}
2018-09-21 13:02:32 +08:00
}
}
}