1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Add back legacy implementations

This commit is contained in:
Dean Herbert 2020-07-29 22:31:18 +09:00
parent 023feaf438
commit 2b71ffa2ed
5 changed files with 151 additions and 24 deletions

View File

@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Scale = new Vector2(Spinner.Scale),
Children = new Drawable[]
{
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerDisc), _ => new DefaultSpinnerDisc()),
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinnerDisc()),
RotationTracker = new SpinnerRotationTracker(Spinner)
{
Anchor = Anchor.Centre,

View File

@ -17,8 +17,6 @@ namespace osu.Game.Rulesets.Osu
SliderFollowCircle,
SliderBall,
SliderBody,
SpinnerDisc,
SpinnerBackground,
SpinnerCentre
SpinnerBody
}
}

View File

@ -0,0 +1,80 @@
// 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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Osu.Skinning
{
public class LegacyNewStyleSpinner : CompositeDrawable
{
private Sprite discBottom;
private Sprite discTop;
private Sprite spinningMiddle;
private DrawableSpinner drawableSpinner;
[BackgroundDependencyLoader]
private void load(ISkinSource source, DrawableHitObject drawableObject)
{
drawableSpinner = (DrawableSpinner)drawableObject;
InternalChildren = new Drawable[]
{
discBottom = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-bottom")
},
discTop = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-top")
},
new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-middle")
},
spinningMiddle = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-middle2")
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
this.FadeOut();
drawableSpinner.State.BindValueChanged(updateStateTransforms, true);
}
private void updateStateTransforms(ValueChangedEvent<ArmedState> state)
{
var spinner = drawableSpinner.HitObject;
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt / 2, true))
this.FadeInFromZero(spinner.TimePreempt / 2);
}
protected override void Update()
{
base.Update();
spinningMiddle.Rotation = discTop.Rotation = drawableSpinner.RotationTracker.Rotation;
discBottom.Rotation = discTop.Rotation / 3;
}
}
}

View File

@ -0,0 +1,64 @@
// 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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Osu.Skinning
{
public class LegacyOldStyleSpinner : CompositeDrawable
{
private DrawableSpinner drawableSpinner;
private Sprite disc;
[BackgroundDependencyLoader]
private void load(ISkinSource source, DrawableHitObject drawableObject)
{
drawableSpinner = (DrawableSpinner)drawableObject;
InternalChildren = new Drawable[]
{
new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-background")
},
disc = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-circle")
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
this.FadeOut();
drawableSpinner.State.BindValueChanged(updateStateTransforms, true);
}
private void updateStateTransforms(ValueChangedEvent<ArmedState> state)
{
var spinner = drawableSpinner.HitObject;
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt / 2, true))
this.FadeInFromZero(spinner.TimePreempt / 2);
}
protected override void Update()
{
base.Update();
disc.Rotation = drawableSpinner.RotationTracker.Rotation;
}
}
}

View File

@ -4,7 +4,6 @@
using System;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Skinning;
using osuTK;
@ -104,25 +103,11 @@ namespace osu.Game.Rulesets.Osu.Skinning
Spacing = new Vector2(-overlap, 0)
};
case OsuSkinComponents.SpinnerDisc:
if (Source.GetTexture("spinner-background") != null)
return new Sprite { Texture = Source.GetTexture("spinner-circle") };
else if (Source.GetTexture("spinner-top") != null)
return new Sprite { Texture = Source.GetTexture("spinner-top") };
return null;
case OsuSkinComponents.SpinnerBackground:
if (Source.GetTexture("spinner-background") != null)
return new Sprite { Texture = Source.GetTexture("spinner-background") };
return null;
case OsuSkinComponents.SpinnerCentre:
if (Source.GetTexture("spinner-background") != null)
return Drawable.Empty();
else if (Source.GetTexture("spinner-top") != null)
return new Sprite { Texture = Source.GetTexture("spinner-middle2") };
case OsuSkinComponents.SpinnerBody:
if (Source.GetTexture("spinner-top") != null)
return new LegacyNewStyleSpinner();
else if (Source.GetTexture("spinner-background") != null)
return new LegacyOldStyleSpinner();
return null;
}