2019-01-24 08:43:03 +00:00
|
|
|
// 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.
|
2018-09-21 05:02:32 +00:00
|
|
|
|
2018-09-21 06:53:06 +00:00
|
|
|
using osu.Framework.Graphics;
|
2018-09-21 05:02:32 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-03-26 04:31:49 +00:00
|
|
|
using osu.Game.Rulesets.UI;
|
2018-11-20 07:51:59 +00:00
|
|
|
using osuTK;
|
2018-09-21 05:02:32 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.UI
|
|
|
|
{
|
2019-03-26 04:31:49 +00:00
|
|
|
public class CatchPlayfieldAdjustmentContainer : PlayfieldAdjustmentContainer
|
2018-09-21 05:02:32 +00:00
|
|
|
{
|
2018-09-21 06:53:06 +00:00
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
private readonly Container content;
|
|
|
|
|
2019-03-26 04:31:49 +00:00
|
|
|
public CatchPlayfieldAdjustmentContainer()
|
2018-09-21 06:53:06 +00:00
|
|
|
{
|
2019-03-26 04:31:49 +00:00
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
Origin = Anchor.TopCentre;
|
|
|
|
|
|
|
|
Size = new Vector2(0.86f); // matches stable's vertical offset for catcher plate
|
|
|
|
|
2018-09-21 06:53:06 +00:00
|
|
|
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 05:02:32 +00:00
|
|
|
{
|
2018-09-21 06:53:06 +00:00
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
2018-09-21 05:02:32 +00:00
|
|
|
|
2018-09-21 06:53:06 +00:00
|
|
|
Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.BASE_WIDTH);
|
|
|
|
Size = Vector2.Divide(Vector2.One, Scale);
|
|
|
|
}
|
2018-09-21 05:02:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|