2021-03-03 02:49:38 +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.
|
|
|
|
|
2021-03-26 18:09:44 +08:00
|
|
|
using System;
|
2021-03-15 16:05:29 +08:00
|
|
|
using System.Globalization;
|
2021-03-03 02:49:38 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|
|
|
{
|
2021-03-12 07:38:40 +08:00
|
|
|
public partial class DefaultSpinner : CompositeDrawable
|
2021-03-03 02:49:38 +08:00
|
|
|
{
|
2022-11-09 12:36:52 +08:00
|
|
|
private DrawableSpinner drawableSpinner = null!;
|
2021-03-03 02:49:38 +08:00
|
|
|
|
2022-11-09 12:36:52 +08:00
|
|
|
private OsuSpriteText bonusCounter = null!;
|
2021-03-12 07:38:40 +08:00
|
|
|
|
2022-11-09 12:36:52 +08:00
|
|
|
private Container spmContainer = null!;
|
|
|
|
private OsuSpriteText spmCounter = null!;
|
2021-03-26 18:09:44 +08:00
|
|
|
|
2023-10-20 15:11:09 +08:00
|
|
|
[Resolved]
|
|
|
|
private OsuColour colours { get; set; } = null!;
|
|
|
|
|
2021-03-12 07:38:40 +08:00
|
|
|
public DefaultSpinner()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
}
|
2021-03-03 02:49:38 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(DrawableHitObject drawableHitObject)
|
|
|
|
{
|
|
|
|
drawableSpinner = (DrawableSpinner)drawableHitObject;
|
|
|
|
|
2021-03-12 07:38:40 +08:00
|
|
|
AddRangeInternal(new Drawable[]
|
2021-03-03 02:49:38 +08:00
|
|
|
{
|
2021-03-12 07:38:40 +08:00
|
|
|
new DefaultSpinnerDisc
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
|
|
|
bonusCounter = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Alpha = 0,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Font = OsuFont.Numeric.With(size: 24),
|
|
|
|
Y = -120,
|
2021-03-26 18:09:44 +08:00
|
|
|
},
|
|
|
|
spmContainer = new Container
|
|
|
|
{
|
|
|
|
Alpha = 0f,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Y = 120,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
spmCounter = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Text = @"0",
|
|
|
|
Font = OsuFont.Numeric.With(size: 24)
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Text = @"SPINS PER MINUTE",
|
|
|
|
Font = OsuFont.Numeric.With(size: 12),
|
|
|
|
Y = 30
|
|
|
|
}
|
|
|
|
}
|
2021-03-12 07:38:40 +08:00
|
|
|
}
|
|
|
|
});
|
2021-03-03 02:49:38 +08:00
|
|
|
}
|
|
|
|
|
2023-10-20 14:37:51 +08:00
|
|
|
private IBindable<int> completedSpins = null!;
|
2022-11-09 12:36:52 +08:00
|
|
|
private IBindable<double> spinsPerMinute = null!;
|
2021-03-12 07:38:40 +08:00
|
|
|
|
2021-03-03 02:49:38 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2023-10-20 14:37:51 +08:00
|
|
|
completedSpins = drawableSpinner.CompletedFullSpins.GetBoundCopy();
|
|
|
|
completedSpins.BindValueChanged(bonus =>
|
2021-03-03 02:49:38 +08:00
|
|
|
{
|
2023-10-20 15:11:09 +08:00
|
|
|
if (drawableSpinner.CurrentBonusScore <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (drawableSpinner.CurrentBonusScore == drawableSpinner.MaximumBonusScore)
|
|
|
|
{
|
|
|
|
bonusCounter.Text = "MAX";
|
|
|
|
bonusCounter.ScaleTo(1.5f).Then().ScaleTo(2.8f, 1000, Easing.OutQuint);
|
|
|
|
|
|
|
|
bonusCounter.FlashColour(colours.YellowLight, 400);
|
|
|
|
bonusCounter.FadeOutFromOne(500);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bonusCounter.Text = drawableSpinner.CurrentBonusScore.ToString(NumberFormatInfo.InvariantInfo);
|
|
|
|
bonusCounter.FadeOutFromOne(1500);
|
|
|
|
bonusCounter.ScaleTo(1.5f).Then().ScaleTo(1f, 1000, Easing.OutQuint);
|
|
|
|
}
|
2021-03-03 02:49:38 +08:00
|
|
|
});
|
2021-03-26 18:09:44 +08:00
|
|
|
|
|
|
|
spinsPerMinute = drawableSpinner.SpinsPerMinute.GetBoundCopy();
|
|
|
|
spinsPerMinute.BindValueChanged(spm =>
|
|
|
|
{
|
|
|
|
spmCounter.Text = Math.Truncate(spm.NewValue).ToString(@"#0");
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
2024-02-24 22:09:21 +08:00
|
|
|
updateSpmAlpha();
|
2021-03-26 18:09:44 +08:00
|
|
|
}
|
|
|
|
|
2024-02-24 22:09:21 +08:00
|
|
|
private void updateSpmAlpha()
|
2021-03-26 18:09:44 +08:00
|
|
|
{
|
|
|
|
if (drawableSpinner.Result?.TimeStarted is double startTime)
|
2024-02-25 00:12:20 +08:00
|
|
|
spmContainer.Alpha = (float)Math.Clamp((Clock.CurrentTime - startTime) / drawableSpinner.HitObject.TimeFadeIn, 0, 1);
|
2024-02-24 22:09:21 +08:00
|
|
|
else
|
|
|
|
spmContainer.Alpha = 0;
|
2021-06-09 11:31:30 +08:00
|
|
|
}
|
2021-03-03 02:49:38 +08:00
|
|
|
}
|
|
|
|
}
|