Merge pull request #9926 from peppy/catch-playfield-width-adjust

Fix osu!catch playfield bounds not matching expectations
This commit is contained in:
Dean Herbert 2020-08-20 23:42:17 +09:00 committed by GitHub
commit 75db762553
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 5 deletions

View File

@ -10,15 +10,21 @@ namespace osu.Game.Rulesets.Catch.UI
{ {
public class CatchPlayfieldAdjustmentContainer : PlayfieldAdjustmentContainer public class CatchPlayfieldAdjustmentContainer : PlayfieldAdjustmentContainer
{ {
private const float playfield_size_adjust = 0.8f;
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
private readonly Container content; private readonly Container content;
public CatchPlayfieldAdjustmentContainer() public CatchPlayfieldAdjustmentContainer()
{ {
Anchor = Anchor.TopCentre; // because we are using centre anchor/origin, we will need to limit visibility in the future
Origin = Anchor.TopCentre; // 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;
Size = new Vector2(0.86f); // matches stable's vertical offset for catcher plate Size = new Vector2(playfield_size_adjust);
InternalChild = new Container InternalChild = new Container
{ {
@ -27,7 +33,7 @@ public CatchPlayfieldAdjustmentContainer()
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit, FillMode = FillMode.Fit,
FillAspectRatio = 4f / 3, FillAspectRatio = 4f / 3,
Child = content = new ScalingContainer { RelativeSizeAxes = Axes.Both } Child = content = new ScalingContainer { RelativeSizeAxes = Axes.Both, }
}; };
} }
@ -40,8 +46,14 @@ protected override void Update()
{ {
base.Update(); base.Update();
// 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;
Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.WIDTH); Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.WIDTH);
Size = Vector2.Divide(Vector2.One, Scale); Position = new Vector2(0, -100 * stable_v_offset_ratio + Scale.X);
Size = Vector2.Divide(new Vector2(1, stable_v_offset_ratio), Scale);
} }
} }
} }