mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 12:53:11 +08:00
Merge pull request #18945 from goodtrailer/separate-ball-followcircle
Separate slider ball and followcircle skinnables into default/legacy classes
This commit is contained in:
commit
cdc4caa8c4
@ -14,7 +14,6 @@ using osu.Game.Rulesets.Objects;
|
|||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Osu.Skinning.Default;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -93,10 +92,10 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddStep("set accent white", () => dho.AccentColour.Value = Color4.White);
|
AddStep("set accent white", () => dho.AccentColour.Value = Color4.White);
|
||||||
AddAssert("ball is white", () => dho.ChildrenOfType<SliderBall>().Single().AccentColour == Color4.White);
|
AddAssert("ball is white", () => dho.ChildrenOfType<DrawableSliderBall>().Single().AccentColour == Color4.White);
|
||||||
|
|
||||||
AddStep("set accent red", () => dho.AccentColour.Value = Color4.Red);
|
AddStep("set accent red", () => dho.AccentColour.Value = Color4.Red);
|
||||||
AddAssert("ball is red", () => dho.ChildrenOfType<SliderBall>().Single().AccentColour == Color4.Red);
|
AddAssert("ball is red", () => dho.ChildrenOfType<DrawableSliderBall>().Single().AccentColour == Color4.Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Slider prepareObject(Slider slider)
|
private Slider prepareObject(Slider slider)
|
||||||
|
@ -29,7 +29,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
public DrawableSliderHead HeadCircle => headContainer.Child;
|
public DrawableSliderHead HeadCircle => headContainer.Child;
|
||||||
public DrawableSliderTail TailCircle => tailContainer.Child;
|
public DrawableSliderTail TailCircle => tailContainer.Child;
|
||||||
|
|
||||||
public SliderBall Ball { get; private set; }
|
[Cached]
|
||||||
|
public DrawableSliderBall Ball { get; private set; }
|
||||||
|
|
||||||
public SkinnableDrawable Body { get; private set; }
|
public SkinnableDrawable Body { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -60,6 +62,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
public DrawableSlider([CanBeNull] Slider s = null)
|
public DrawableSlider([CanBeNull] Slider s = null)
|
||||||
: base(s)
|
: base(s)
|
||||||
{
|
{
|
||||||
|
Ball = new DrawableSliderBall
|
||||||
|
{
|
||||||
|
GetInitialHitAction = () => HeadCircle.HitAction,
|
||||||
|
BypassAutoSizeAxes = Axes.Both,
|
||||||
|
AlwaysPresent = true,
|
||||||
|
Alpha = 0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -73,13 +82,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
repeatContainer = new Container<DrawableSliderRepeat> { RelativeSizeAxes = Axes.Both },
|
repeatContainer = new Container<DrawableSliderRepeat> { RelativeSizeAxes = Axes.Both },
|
||||||
headContainer = new Container<DrawableSliderHead> { RelativeSizeAxes = Axes.Both },
|
headContainer = new Container<DrawableSliderHead> { RelativeSizeAxes = Axes.Both },
|
||||||
OverlayElementContainer = new Container { RelativeSizeAxes = Axes.Both, },
|
OverlayElementContainer = new Container { RelativeSizeAxes = Axes.Both, },
|
||||||
Ball = new SliderBall(this)
|
Ball,
|
||||||
{
|
|
||||||
GetInitialHitAction = () => HeadCircle.HitAction,
|
|
||||||
BypassAutoSizeAxes = Axes.Both,
|
|
||||||
AlwaysPresent = true,
|
|
||||||
Alpha = 0
|
|
||||||
},
|
|
||||||
slidingSample = new PausableSkinnableSound { Looping = true }
|
slidingSample = new PausableSkinnableSound { Looping = true }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,24 +7,21 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||||
{
|
{
|
||||||
public class SliderBall : CircularContainer, ISliderProgress, IRequireHighFrequencyMousePosition, IHasAccentColour
|
public class DrawableSliderBall : CircularContainer, ISliderProgress, IRequireHighFrequencyMousePosition, IHasAccentColour
|
||||||
{
|
{
|
||||||
public Func<OsuAction?> GetInitialHitAction;
|
public Func<OsuAction?> GetInitialHitAction;
|
||||||
|
|
||||||
@ -34,14 +31,15 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
set => ball.Colour = value;
|
set => ball.Colour = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Drawable followCircle;
|
private Drawable followCircle;
|
||||||
private readonly Drawable fullSizeFollowCircle;
|
private Drawable followCircleReceptor;
|
||||||
private readonly DrawableSlider drawableSlider;
|
private DrawableSlider drawableSlider;
|
||||||
private readonly Drawable ball;
|
private Drawable ball;
|
||||||
|
|
||||||
public SliderBall(DrawableSlider drawableSlider)
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(DrawableHitObject drawableSlider)
|
||||||
{
|
{
|
||||||
this.drawableSlider = drawableSlider;
|
this.drawableSlider = (DrawableSlider)drawableSlider;
|
||||||
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
@ -49,15 +47,14 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
|
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
followCircle = new FollowCircleContainer
|
followCircle = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderFollowCircle), _ => new DefaultFollowCircle())
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderFollowCircle), _ => new DefaultFollowCircle()),
|
|
||||||
},
|
},
|
||||||
fullSizeFollowCircle = new CircularContainer
|
followCircleReceptor = new CircularContainer
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -106,7 +103,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
|
|
||||||
tracking = value;
|
tracking = value;
|
||||||
|
|
||||||
fullSizeFollowCircle.Scale = new Vector2(tracking ? 2.4f : 1f);
|
followCircleReceptor.Scale = new Vector2(tracking ? 2.4f : 1f);
|
||||||
|
|
||||||
followCircle.ScaleTo(tracking ? 2.4f : 1f, 300, Easing.OutQuint);
|
followCircle.ScaleTo(tracking ? 2.4f : 1f, 300, Easing.OutQuint);
|
||||||
followCircle.FadeTo(tracking ? 1f : 0, 300, Easing.OutQuint);
|
followCircle.FadeTo(tracking ? 1f : 0, 300, Easing.OutQuint);
|
||||||
@ -167,7 +164,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
// in valid time range
|
// in valid time range
|
||||||
Time.Current >= drawableSlider.HitObject.StartTime && Time.Current < drawableSlider.HitObject.EndTime &&
|
Time.Current >= drawableSlider.HitObject.StartTime && Time.Current < drawableSlider.HitObject.EndTime &&
|
||||||
// in valid position range
|
// in valid position range
|
||||||
lastScreenSpaceMousePosition.HasValue && fullSizeFollowCircle.ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value) &&
|
lastScreenSpaceMousePosition.HasValue && followCircleReceptor.ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value) &&
|
||||||
// valid action
|
// valid action
|
||||||
(actions?.Any(isValidTrackingAction) ?? false);
|
(actions?.Any(isValidTrackingAction) ?? false);
|
||||||
|
|
||||||
@ -205,74 +202,5 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
ball.Rotation = -90 + (float)(-Math.Atan2(diff.X, diff.Y) * 180 / Math.PI);
|
ball.Rotation = -90 + (float)(-Math.Atan2(diff.X, diff.Y) * 180 / Math.PI);
|
||||||
lastPosition = Position;
|
lastPosition = Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FollowCircleContainer : CircularContainer
|
|
||||||
{
|
|
||||||
public override bool HandlePositionalInput => true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DefaultFollowCircle : CompositeDrawable
|
|
||||||
{
|
|
||||||
public DefaultFollowCircle()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
InternalChild = new CircularContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Masking = true,
|
|
||||||
BorderThickness = 5,
|
|
||||||
BorderColour = Color4.Orange,
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
Child = new Box
|
|
||||||
{
|
|
||||||
Colour = Color4.Orange,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Alpha = 0.2f,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DefaultSliderBall : CompositeDrawable
|
|
||||||
{
|
|
||||||
private Box box;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(DrawableHitObject drawableObject, ISkinSource skin)
|
|
||||||
{
|
|
||||||
var slider = (DrawableSlider)drawableObject;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
float radius = skin.GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.SliderPathRadius)?.Value ?? OsuHitObject.OBJECT_RADIUS;
|
|
||||||
|
|
||||||
InternalChild = new CircularContainer
|
|
||||||
{
|
|
||||||
Masking = true,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Scale = new Vector2(radius / OsuHitObject.OBJECT_RADIUS),
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
BorderThickness = 10,
|
|
||||||
BorderColour = Color4.White,
|
|
||||||
Alpha = 1,
|
|
||||||
Child = box = new Box
|
|
||||||
{
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.White,
|
|
||||||
AlwaysPresent = true,
|
|
||||||
Alpha = 0
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
slider.Tracking.BindValueChanged(trackingChanged, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void trackingChanged(ValueChangedEvent<bool> tracking) =>
|
|
||||||
box.FadeTo(tracking.NewValue ? 0.3f : 0.05f, 200, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||||
|
{
|
||||||
|
public class DefaultFollowCircle : CompositeDrawable
|
||||||
|
{
|
||||||
|
public DefaultFollowCircle()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChild = new CircularContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
BorderThickness = 5,
|
||||||
|
BorderColour = Color4.Orange,
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
Child = new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.Orange,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0.2f,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
osu.Game.Rulesets.Osu/Skinning/Default/DefaultSliderBall.cs
Normal file
60
osu.Game.Rulesets.Osu/Skinning/Default/DefaultSliderBall.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||||
|
{
|
||||||
|
public class DefaultSliderBall : CompositeDrawable
|
||||||
|
{
|
||||||
|
private Box box;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(DrawableHitObject drawableObject, ISkinSource skin)
|
||||||
|
{
|
||||||
|
var slider = (DrawableSlider)drawableObject;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
float radius = skin.GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.SliderPathRadius)?.Value ?? OsuHitObject.OBJECT_RADIUS;
|
||||||
|
|
||||||
|
InternalChild = new CircularContainer
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Scale = new Vector2(radius / OsuHitObject.OBJECT_RADIUS),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
BorderThickness = 10,
|
||||||
|
BorderColour = Color4.White,
|
||||||
|
Alpha = 1,
|
||||||
|
Child = box = new Box
|
||||||
|
{
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.White,
|
||||||
|
AlwaysPresent = true,
|
||||||
|
Alpha = 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
slider.Tracking.BindValueChanged(trackingChanged, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void trackingChanged(ValueChangedEvent<bool> tracking) =>
|
||||||
|
box.FadeTo(tracking.NewValue ? 0.3f : 0.05f, 200, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
22
osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyFollowCircle.cs
Normal file
22
osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyFollowCircle.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||||
|
{
|
||||||
|
public class LegacyFollowCircle : CompositeDrawable
|
||||||
|
{
|
||||||
|
public LegacyFollowCircle(Drawable animationContent)
|
||||||
|
{
|
||||||
|
// follow circles are 2x the hitcircle resolution in legacy skins (since they are scaled down from >1x
|
||||||
|
animationContent.Scale *= 0.5f;
|
||||||
|
animationContent.Anchor = Anchor.Centre;
|
||||||
|
animationContent.Origin = Anchor.Centre;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
InternalChild = animationContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -41,11 +41,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
return this.GetAnimation(component.LookupName, false, false);
|
return this.GetAnimation(component.LookupName, false, false);
|
||||||
|
|
||||||
case OsuSkinComponents.SliderFollowCircle:
|
case OsuSkinComponents.SliderFollowCircle:
|
||||||
var followCircle = this.GetAnimation("sliderfollowcircle", true, true, true);
|
var followCircleContent = this.GetAnimation("sliderfollowcircle", true, true, true);
|
||||||
if (followCircle != null)
|
if (followCircleContent != null)
|
||||||
// follow circles are 2x the hitcircle resolution in legacy skins (since they are scaled down from >1x
|
return new LegacyFollowCircle(followCircleContent);
|
||||||
followCircle.Scale *= 0.5f;
|
|
||||||
return followCircle;
|
return null;
|
||||||
|
|
||||||
case OsuSkinComponents.SliderBall:
|
case OsuSkinComponents.SliderBall:
|
||||||
var sliderBallContent = this.GetAnimation("sliderb", true, true, animationSeparator: "");
|
var sliderBallContent = this.GetAnimation("sliderb", true, true, animationSeparator: "");
|
||||||
|
Loading…
Reference in New Issue
Block a user