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
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
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
|
|
|
|
{
|
2022-11-24 05:32:20 +00:00
|
|
|
public partial class CatchPlayfieldAdjustmentContainer : PlayfieldAdjustmentContainer
|
2018-09-21 05:02:32 +00:00
|
|
|
{
|
2020-08-20 09:15:06 +00:00
|
|
|
private const float playfield_size_adjust = 0.8f;
|
|
|
|
|
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
|
|
|
{
|
2020-08-20 10:12:37 +00:00
|
|
|
// because we are using centre anchor/origin, we will need to limit visibility in the future
|
|
|
|
// to ensure tall windows do not get a readability advantage.
|
|
|
|
// it may be possible to bake the catch-specific offsets (-100..340 mentioned below) into new values
|
|
|
|
// which are compatible with TopCentre alignment.
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
2019-03-26 04:31:49 +00:00
|
|
|
|
2020-08-20 09:15:06 +00:00
|
|
|
Size = new Vector2(playfield_size_adjust);
|
2019-03-26 04:31:49 +00:00
|
|
|
|
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,
|
2020-08-20 10:12:37 +00:00
|
|
|
Child = content = new ScalingContainer { RelativeSizeAxes = Axes.Both, }
|
2018-09-21 06:53:06 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A <see cref="Container"/> which scales its content relative to a target width.
|
|
|
|
/// </summary>
|
2022-11-24 05:32:20 +00:00
|
|
|
private partial 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
|
|
|
|
2020-08-20 10:12:37 +00: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 15:21:45 +00:00
|
|
|
Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.WIDTH);
|
2020-08-20 10:12:37 +00: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 06:53:06 +00:00
|
|
|
}
|
2018-09-21 05:02:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|