From 0fb7895a52c8b3fd9cd374e34c603afa4b7396ec Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 23 Sep 2023 23:39:12 +0300 Subject: [PATCH] Adjust catcher origin position to match 1:1 with stable Change catcher origin position logic to 1:1 match stable on legacy skin --- .../Skinning/Argon/ArgonCatcher.cs | 6 ++++- .../Skinning/Default/DefaultCatcher.cs | 11 ++++++++ .../Skinning/Legacy/LegacyCatcher.cs | 27 +++++++++++++++++++ .../UI/SkinnableCatcher.cs | 5 ++-- 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyCatcher.cs diff --git a/osu.Game.Rulesets.Catch/Skinning/Argon/ArgonCatcher.cs b/osu.Game.Rulesets.Catch/Skinning/Argon/ArgonCatcher.cs index 82374085c8..5a788a26fb 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Argon/ArgonCatcher.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Argon/ArgonCatcher.cs @@ -15,7 +15,11 @@ namespace osu.Game.Rulesets.Catch.Skinning.Argon [BackgroundDependencyLoader] private void load() { - RelativeSizeAxes = Axes.Both; + Anchor = Anchor.TopCentre; + Origin = Anchor.Centre; + + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; InternalChildren = new Drawable[] { diff --git a/osu.Game.Rulesets.Catch/Skinning/Default/DefaultCatcher.cs b/osu.Game.Rulesets.Catch/Skinning/Default/DefaultCatcher.cs index 72208b763b..bcd4c73f04 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Default/DefaultCatcher.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Default/DefaultCatcher.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Rulesets.Catch.UI; +using osuTK; namespace osu.Game.Rulesets.Catch.Skinning.Default { @@ -22,6 +23,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default public DefaultCatcher() { + Anchor = Anchor.TopCentre; RelativeSizeAxes = Axes.Both; InternalChild = sprite = new Sprite { @@ -32,6 +34,15 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default }; } + protected override void Update() + { + base.Update(); + + // matches stable's origin position since we're using the same catcher sprite. + // see LegacyCatcher for more information. + OriginPosition = new Vector2(DrawWidth / 2, 16f); + } + [BackgroundDependencyLoader] private void load(TextureStore store, Bindable currentState) { diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyCatcher.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyCatcher.cs new file mode 100644 index 0000000000..cba2c671b0 --- /dev/null +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyCatcher.cs @@ -0,0 +1,27 @@ +// Copyright (c) ppy Pty Ltd . 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.Skinning.Legacy +{ + public abstract partial class LegacyCatcher : CompositeDrawable + { + protected LegacyCatcher() + { + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + RelativeSizeAxes = Axes.Both; + } + + protected override void Update() + { + base.Update(); + + // stable sets the Y origin position of the catcher to 16px in order for the catching range and OD scaling to align with the top of the catcher's plate in the default skin. + OriginPosition = new Vector2(DrawWidth / 2, 16f); + } + } +} diff --git a/osu.Game.Rulesets.Catch/UI/SkinnableCatcher.cs b/osu.Game.Rulesets.Catch/UI/SkinnableCatcher.cs index bcc59a5e4f..107b79c88e 100644 --- a/osu.Game.Rulesets.Catch/UI/SkinnableCatcher.cs +++ b/osu.Game.Rulesets.Catch/UI/SkinnableCatcher.cs @@ -6,7 +6,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Catch.Skinning.Default; using osu.Game.Skinning; -using osuTK; namespace osu.Game.Rulesets.Catch.UI { @@ -26,8 +25,8 @@ namespace osu.Game.Rulesets.Catch.UI : base(new CatchSkinComponentLookup(CatchSkinComponents.Catcher), _ => new DefaultCatcher()) { Anchor = Anchor.TopCentre; - // Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling. - OriginPosition = new Vector2(0.5f, 0.06f) * Catcher.BASE_SIZE; + Origin = Anchor.TopCentre; + CentreComponent = false; } } }