1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 06:42:56 +08:00

Proxy spinner approach circle before the spinner overlay components

This commit is contained in:
Salman Ahmed 2021-06-18 20:34:25 +03:00
parent 843c8bd7a4
commit d6b9436151
3 changed files with 55 additions and 4 deletions

View File

@ -0,0 +1,12 @@
// 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.
using osu.Framework.Graphics.Containers;
namespace osu.Game.Rulesets.Osu.Skinning
{
public interface IProxiesApproachCircle
{
Container ApproachCircleTarget { get; }
}
}

View File

@ -15,8 +15,10 @@ using osuTK;
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
public abstract class LegacySpinner : CompositeDrawable
public abstract class LegacySpinner : CompositeDrawable, IProxiesApproachCircle
{
public const float SPRITE_SCALE = 0.625f;
/// <remarks>
/// All constants are in osu!stable's gamefield space, which is shifted 16px downwards.
/// This offset is negated in both osu!stable and osu!lazer to bring all constants into window-space.
@ -26,12 +28,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
protected const float SPINNER_Y_CENTRE = SPINNER_TOP_OFFSET + 219f;
protected const float SPRITE_SCALE = 0.625f;
private const float spm_hide_offset = 50f;
protected DrawableSpinner DrawableSpinner { get; private set; }
public Container ApproachCircleTarget { get; private set; }
private Sprite spin;
private Sprite clear;
@ -58,8 +59,12 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
Depth = float.MinValue,
RelativeSizeAxes = Axes.Both,
Children = new[]
Children = new Drawable[]
{
ApproachCircleTarget = new Container
{
RelativeSizeAxes = Axes.Both,
},
spin = new Sprite
{
Anchor = Anchor.TopCentre,

View File

@ -0,0 +1,34 @@
// 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.
using System;
using osu.Framework.Graphics;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Osu.Skinning
{
/// <summary>
/// A skinnable drawable of the <see cref="OsuSkinComponents.SpinnerBody"/> component, with the approach circle exposed for modification.
/// </summary>
public class SkinnableSpinnerBody : SkinnableDrawable
{
private readonly Drawable approachCircleProxy;
public SkinnableSpinnerBody(Drawable approachCircleProxy, Func<ISkinComponent, Drawable> defaultImplementation = null)
: base(new OsuSkinComponent(OsuSkinComponents.SpinnerBody), defaultImplementation)
{
this.approachCircleProxy = approachCircleProxy;
}
protected override void SkinChanged(ISkinSource skin)
{
if (Drawable is IProxiesApproachCircle oldProxiesApproachCircle)
oldProxiesApproachCircle.ApproachCircleTarget.Remove(approachCircleProxy);
base.SkinChanged(skin);
if (Drawable is IProxiesApproachCircle newProxiesApproachCircle)
newProxiesApproachCircle.ApproachCircleTarget.Add(approachCircleProxy);
}
}
}