mirror of
https://github.com/SK-la/Ez2Lazer.git
synced 2026-03-13 11:20:28 +00:00
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
// 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 System;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Sprites;
|
|
using osu.Framework.Localisation;
|
|
using osu.Game.Configuration;
|
|
using osu.Game.Localisation.SkinComponents;
|
|
using osu.Game.Resources.Localisation.Web;
|
|
using osu.Game.Rulesets.Scoring;
|
|
using osu.Game.Screens.Play.HUD;
|
|
using osuTK;
|
|
using osuTK.Graphics;
|
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning.Ez2.Ez2HUD
|
|
{
|
|
public partial class EzComComboText : ComboCounter
|
|
{
|
|
public EzComCounterText Text = null!;
|
|
|
|
protected override double RollingDuration => 250;
|
|
|
|
protected virtual bool DisplayXSymbol => true;
|
|
|
|
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.ShowLabel), nameof(SkinnableComponentStrings.ShowLabelDescription))]
|
|
public Bindable<bool> ShowLabel { get; } = new BindableBool(true);
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(ScoreProcessor scoreProcessor)
|
|
{
|
|
Current.BindTo(scoreProcessor.Combo);
|
|
Current.BindValueChanged(combo =>
|
|
{
|
|
bool wasIncrease = combo.NewValue > combo.OldValue;
|
|
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 ? 1000 : 100;
|
|
|
|
Text.NumberContainer
|
|
.ScaleTo(new Vector2(newScale))
|
|
.ScaleTo(Vector2.One, duration, Easing.OutQuint);
|
|
|
|
if (wasMiss)
|
|
Text.FlashColour(Color4.Red, duration, Easing.OutQuint);
|
|
});
|
|
}
|
|
|
|
protected override LocalisableString FormatCount(int count) => DisplayXSymbol ? @"Combo" : count.ToString();
|
|
|
|
protected override IHasText CreateText() => Text = new EzComCounterText(Anchor.TopLeft, MatchesStrings.MatchScoreStatsCombo.ToUpper())
|
|
{
|
|
ShowLabel = { BindTarget = ShowLabel },
|
|
};
|
|
}
|
|
}
|