2019-01-24 16:43:03 +08: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 13:02:32 +08:00
|
|
|
|
2018-09-21 14:53:06 +08:00
|
|
|
using osu.Framework.Graphics;
|
2018-09-21 13:02:32 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-03-26 12:31:49 +08:00
|
|
|
using osu.Game.Rulesets.UI;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
2018-09-21 13:02:32 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.UI
|
|
|
|
{
|
2019-03-26 12:31:49 +08:00
|
|
|
public partial class CatchPlayfieldAdjustmentContainer : PlayfieldAdjustmentContainer
|
2018-09-21 13:02:32 +08:00
|
|
|
{
|
2020-08-20 17:15:06 +08:00
|
|
|
private const float playfield_size_adjust = 0.8f;
|
|
|
|
|
2018-09-21 14:53:06 +08:00
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
private readonly Container content;
|
|
|
|
|
2019-03-26 12:31:49 +08:00
|
|
|
public CatchPlayfieldAdjustmentContainer()
|
2018-09-21 14:53:06 +08:00
|
|
|
{
|
2023-10-10 07:17:43 +08:00
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
Origin = Anchor.TopCentre;
|
|
|
|
|
|
|
|
// playfields in stable are positioned vertically at three fourths the difference between the playfield height and the window height in stable.
|
|
|
|
// we can match that in lazer by using relative coordinates for Y and considering window height to be 1, and playfield height to be 0.8.
|
|
|
|
RelativePositionAxes = Axes.Y;
|
|
|
|
Y = (1 - playfield_size_adjust) / 4 * 3;
|
2019-03-26 12:31:49 +08:00
|
|
|
|
2020-08-20 17:15:06 +08:00
|
|
|
Size = new Vector2(playfield_size_adjust);
|
2019-03-26 12:31:49 +08:00
|
|
|
|
2018-09-21 14:53:06 +08:00
|
|
|
InternalChild = new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
FillAspectRatio = 4f / 3,
|
2020-08-20 18:12:37 +08:00
|
|
|
Child = content = new ScalingContainer { RelativeSizeAxes = Axes.Both, }
|
2018-09-21 14:53:06 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A <see cref="Container"/> which scales its content relative to a target width.
|
|
|
|
/// </summary>
|
|
|
|
private partial class ScalingContainer : Container
|
2018-09-21 13:02:32 +08:00
|
|
|
{
|
2018-09-21 14:53:06 +08:00
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
2018-09-21 13:02:32 +08:00
|
|
|
|
2020-08-20 18:12:37 +08:00
|
|
|
// in stable, fruit fall vertically from -100 to 340.
|
|
|
|
// to emulate this, we want to make our playfield 440 gameplay pixels high.
|
|
|
|
// we then offset it -100 vertically in the position set below.
|
|
|
|
const float stable_v_offset_ratio = 440 / 384f;
|
|
|
|
|
2020-07-01 23:21:45 +08:00
|
|
|
Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.WIDTH);
|
2020-08-20 18:12:37 +08:00
|
|
|
Position = new Vector2(0, -100 * stable_v_offset_ratio + Scale.X);
|
|
|
|
Size = Vector2.Divide(new Vector2(1, stable_v_offset_ratio), Scale);
|
2018-09-21 14:53:06 +08:00
|
|
|
}
|
2018-09-21 13:02:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|