2023-10-26 13:59:04 +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.
|
|
|
|
|
2023-11-10 14:26:37 +08:00
|
|
|
using System;
|
2023-10-26 13:59:04 +08:00
|
|
|
using osu.Framework.Allocation;
|
2023-11-07 06:59:00 +08:00
|
|
|
using osu.Framework.Bindables;
|
2023-10-26 13:59:04 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Localisation;
|
2023-11-07 06:59:00 +08:00
|
|
|
using osu.Game.Configuration;
|
2023-10-26 13:59:04 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2023-11-10 14:06:07 +08:00
|
|
|
using osuTK;
|
2023-11-10 14:26:37 +08:00
|
|
|
using osuTK.Graphics;
|
2023-10-26 13:59:04 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
|
|
|
public partial class ArgonComboCounter : ComboCounter
|
|
|
|
{
|
2023-11-10 14:26:37 +08:00
|
|
|
private ArgonCounterTextComponent text = null!;
|
|
|
|
|
2023-11-10 14:06:07 +08:00
|
|
|
protected override double RollingDuration => 500;
|
|
|
|
protected override Easing RollingEasing => Easing.OutQuint;
|
|
|
|
|
2023-11-07 06:59:00 +08:00
|
|
|
[SettingSource("Wireframe opacity", "Controls the opacity of the wire frames behind the digits.")]
|
2023-11-10 14:39:17 +08:00
|
|
|
public BindableFloat WireframeOpacity { get; } = new BindableFloat(0.25f)
|
2023-11-07 06:59:00 +08:00
|
|
|
{
|
|
|
|
Precision = 0.01f,
|
|
|
|
MinValue = 0,
|
|
|
|
MaxValue = 1,
|
|
|
|
};
|
|
|
|
|
2023-10-26 13:59:04 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(ScoreProcessor scoreProcessor)
|
|
|
|
{
|
|
|
|
Current.BindTo(scoreProcessor.Combo);
|
2023-11-10 14:06:07 +08:00
|
|
|
Current.BindValueChanged(combo =>
|
|
|
|
{
|
|
|
|
bool wasIncrease = combo.NewValue > combo.OldValue;
|
2023-11-10 14:26:37 +08:00
|
|
|
bool wasMiss = combo.OldValue > 1 && combo.NewValue == 0;
|
|
|
|
|
|
|
|
float newScale = Math.Clamp(text.NumberContainer.Scale.X * (wasIncrease ? 1.1f : 0.8f), 0.6f, 1.4f);
|
|
|
|
|
|
|
|
float duration = wasMiss ? 2000 : 300;
|
|
|
|
|
|
|
|
text.NumberContainer
|
|
|
|
.ScaleTo(new Vector2(newScale))
|
|
|
|
.ScaleTo(Vector2.One, duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
if (wasMiss)
|
|
|
|
text.FlashColour(Color4.Red, duration, Easing.OutQuint);
|
2023-11-10 14:06:07 +08:00
|
|
|
});
|
2023-10-26 13:59:04 +08:00
|
|
|
}
|
|
|
|
|
2023-11-07 06:59:00 +08:00
|
|
|
protected override LocalisableString FormatCount(int count) => $@"{count}x";
|
2023-10-26 13:59:04 +08:00
|
|
|
|
2023-11-10 14:26:37 +08:00
|
|
|
protected override IHasText CreateText() => text = new ArgonCounterTextComponent(Anchor.TopLeft, "COMBO")
|
2023-10-26 13:59:04 +08:00
|
|
|
{
|
2023-11-07 06:59:00 +08:00
|
|
|
WireframeOpacity = { BindTarget = WireframeOpacity },
|
|
|
|
};
|
2023-10-26 13:59:04 +08:00
|
|
|
}
|
|
|
|
}
|