2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-07-25 12:42:29 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-07-30 02:42:05 +08:00
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
2023-12-15 15:13:32 +08:00
|
|
|
|
public partial class DrawableSliderTick : DrawableOsuHitObject
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
2018-02-11 18:03:01 +08:00
|
|
|
|
public const double ANIM_DURATION = 150;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2024-01-25 18:14:04 +08:00
|
|
|
|
public const float DEFAULT_TICK_SIZE = 16;
|
2019-07-25 12:42:29 +08:00
|
|
|
|
|
2024-05-29 16:57:30 +08:00
|
|
|
|
protected DrawableSlider DrawableSlider => (DrawableSlider)ParentHitObject;
|
2020-12-03 19:03:39 +08:00
|
|
|
|
|
2020-11-05 12:51:46 +08:00
|
|
|
|
private SkinnableDrawable scaleContainer;
|
2019-07-25 12:42:29 +08:00
|
|
|
|
|
2020-11-12 14:59:48 +08:00
|
|
|
|
public DrawableSliderTick()
|
|
|
|
|
: base(null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 12:31:40 +08:00
|
|
|
|
public DrawableSliderTick(SliderTick sliderTick)
|
|
|
|
|
: base(sliderTick)
|
2020-11-05 12:51:46 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
2023-09-20 11:48:15 +08:00
|
|
|
|
Size = OsuHitObject.OBJECT_DIMENSIONS;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
Origin = Anchor.Centre;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-11-09 15:04:56 +08:00
|
|
|
|
AddInternal(scaleContainer = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.SliderScorePoint), _ => new CircularContainer
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
2019-07-25 12:42:29 +08:00
|
|
|
|
Masking = true,
|
|
|
|
|
Origin = Anchor.Centre,
|
2024-01-25 18:14:04 +08:00
|
|
|
|
Size = new Vector2(DEFAULT_TICK_SIZE),
|
|
|
|
|
BorderThickness = DEFAULT_TICK_SIZE / 4,
|
2019-07-25 12:42:29 +08:00
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
|
Child = new Box
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-07-25 12:42:29 +08:00
|
|
|
|
Colour = AccentColour.Value,
|
|
|
|
|
Alpha = 0.3f,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2022-09-22 13:46:37 +08:00
|
|
|
|
});
|
2019-07-25 12:42:29 +08:00
|
|
|
|
|
2020-11-12 14:59:48 +08:00
|
|
|
|
ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue));
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 18:46:42 +08:00
|
|
|
|
protected override void OnApply()
|
|
|
|
|
{
|
|
|
|
|
base.OnApply();
|
|
|
|
|
|
2020-12-03 19:03:39 +08:00
|
|
|
|
Position = HitObject.Position - DrawableSlider.HitObject.Position;
|
2019-07-25 12:42:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-15 15:13:32 +08:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset) => DrawableSlider.SliderInputManager.TryJudgeNestedObject(this, timeOffset);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-07-22 14:33:12 +08:00
|
|
|
|
protected override void UpdateInitialTransforms()
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
2018-03-06 16:33:42 +08:00
|
|
|
|
this.FadeOut().FadeIn(ANIM_DURATION);
|
|
|
|
|
this.ScaleTo(0.5f).ScaleTo(1f, ANIM_DURATION * 4, Easing.OutElasticHalf);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-04 15:19:07 +08:00
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
2020-11-04 15:19:07 +08:00
|
|
|
|
base.UpdateHitStateTransforms(state);
|
2019-09-13 17:49:21 +08:00
|
|
|
|
|
2017-02-13 03:38:05 +08:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
2018-01-25 17:52:03 +08:00
|
|
|
|
this.Delay(HitObject.TimePreempt).FadeOut();
|
2017-02-13 03:38:05 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2017-02-13 03:38:05 +08:00
|
|
|
|
case ArmedState.Miss:
|
2024-01-25 18:25:42 +08:00
|
|
|
|
this.FadeOut(ANIM_DURATION, Easing.OutQuint);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2017-02-13 03:38:05 +08:00
|
|
|
|
case ArmedState.Hit:
|
2018-03-06 16:33:42 +08:00
|
|
|
|
this.FadeOut(ANIM_DURATION, Easing.OutQuint);
|
|
|
|
|
this.ScaleTo(Scale * 1.5f, ANIM_DURATION, Easing.Out);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-27 16:37:38 +08:00
|
|
|
|
}
|