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
|
|
|
|
|
|
|
|
|
using System;
|
2018-11-16 04:37:21 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2020-08-19 12:44:45 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-10-14 16:21:56 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2020-08-19 12:44:45 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2020-10-14 16:21:56 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-05-03 15:47:47 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2021-04-30 11:42:32 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2020-10-14 16:21:56 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-10-14 16:21:56 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-05-07 15:20:24 +08:00
|
|
|
|
public class DefaultComboCounter : RollingCounter<int>, ISkinnableComponent
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-10-14 16:21:56 +08:00
|
|
|
|
private readonly Vector2 offset = new Vector2(20, 5);
|
|
|
|
|
|
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private HUDOverlay hud { get; set; }
|
|
|
|
|
|
|
|
|
|
public DefaultComboCounter()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Current.Value = DisplayedCount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-16 04:37:21 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2021-05-03 15:47:47 +08:00
|
|
|
|
private void load(OsuColour colours, ScoreProcessor scoreProcessor)
|
|
|
|
|
{
|
|
|
|
|
Colour = colours.BlueLighter;
|
|
|
|
|
Current.BindTo(scoreProcessor.Combo);
|
|
|
|
|
}
|
2018-11-16 04:37:21 +08:00
|
|
|
|
|
2020-10-14 16:21:56 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
2020-10-15 15:55:47 +08:00
|
|
|
|
if (hud?.ScoreCounter.Drawable is DefaultScoreCounter score)
|
2020-10-14 16:21:56 +08:00
|
|
|
|
{
|
|
|
|
|
// for now align with the score counter. eventually this will be user customisable.
|
2020-10-15 16:30:29 +08:00
|
|
|
|
Position = Parent.ToLocalSpace(score.ScreenSpaceDrawQuad.TopRight) + offset;
|
2020-10-14 16:21:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
protected override string FormatCount(int count)
|
|
|
|
|
{
|
|
|
|
|
return $@"{count}x";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override double GetProportionalDuration(int currentValue, int newValue)
|
|
|
|
|
{
|
|
|
|
|
return Math.Abs(currentValue - newValue) * RollingDuration * 100.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-19 12:44:45 +08:00
|
|
|
|
protected override OsuSpriteText CreateSpriteText()
|
|
|
|
|
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(size: 20f));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|