Skip to content

Commit

Permalink
Change catcher origin position logic to 1:1 match stable on legacy skin
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Oct 4, 2023
1 parent 63b525a commit 3e264ca
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
8 changes: 8 additions & 0 deletions osu.Game.Rulesets.Catch/Skinning/Argon/ArgonCatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Catch.UI;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Catch.Skinning.Argon
Expand All @@ -15,6 +16,7 @@ public partial class ArgonCatcher : CompositeDrawable
[BackgroundDependencyLoader]
private void load()
{
Anchor = Anchor.TopCentre;
RelativeSizeAxes = Axes.Both;

InternalChildren = new Drawable[]
Expand Down Expand Up @@ -81,5 +83,11 @@ private void load()
},
};
}

protected override void Update()
{
base.Update();
OriginPosition = new Vector2(DrawWidth / 2, Catcher.BASE_SIZE * 0.06f);
}
}
}
11 changes: 11 additions & 0 deletions osu.Game.Rulesets.Catch/Skinning/Default/DefaultCatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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
{
Expand All @@ -22,6 +23,7 @@ public partial class DefaultCatcher : CompositeDrawable

public DefaultCatcher()
{
Anchor = Anchor.TopCentre;
RelativeSizeAxes = Axes.Both;
InternalChild = sprite = new Sprite
{
Expand All @@ -32,6 +34,15 @@ public DefaultCatcher()
};
}

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<CatcherAnimationState> currentState)
{
Expand Down
9 changes: 9 additions & 0 deletions osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyCatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,14 @@ protected LegacyCatcher()
// and also a constant 0.7x factor for catcher sprites specifically.
Scale = new Vector2(0.5f * 0.7f);
}

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,
// (note that this is is applied pre-scale, i.e. 16px are acted upon in relation to the sprite's original @1x dimensions).
OriginPosition = new Vector2(DrawWidth / 2, 16f);
}
}
}
4 changes: 1 addition & 3 deletions osu.Game.Rulesets.Catch/UI/SkinnableCatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using osu.Framework.Graphics;
using osu.Game.Rulesets.Catch.Skinning.Default;
using osu.Game.Skinning;
using osuTK;

namespace osu.Game.Rulesets.Catch.UI
{
Expand All @@ -26,8 +25,7 @@ public SkinnableCatcher()
: base(new CatchSkinComponentLookup(CatchSkinComponents.Catcher), _ => new DefaultCatcher())
{
Anchor = Anchor.TopCentre;
// Sets the origin to the top of the catcher's plate to allow for correct scaling.
OriginPosition = new Vector2(0.5f, 0.0525f) * Catcher.BASE_SIZE;
Origin = Anchor.TopCentre;
CentreComponent = false;
}
}
Expand Down

0 comments on commit 3e264ca

Please sign in to comment.