mirror of
https://github.com/ppy/osu.git
synced 2024-12-21 18:42:56 +08:00
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Rulesets.Catch.UI
|
|
{
|
|
public class PlayfieldAdjustmentContainer : Container
|
|
{
|
|
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
|
|
{
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
|
|
Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.BASE_WIDTH);
|
|
Size = Vector2.Divide(Vector2.One, Scale);
|
|
}
|
|
}
|
|
}
|
|
}
|