2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-03-10 11:26:46 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
2017-07-15 00:18:12 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-03-10 11:26:46 +08:00
|
|
|
|
|
2017-05-05 12:00:05 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Uses the 'x' symbol and has a pop-out effect while rolling over.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class StandardComboCounter : ComboCounter
|
|
|
|
|
{
|
|
|
|
|
protected uint ScheduledPopOutCurrentId;
|
|
|
|
|
|
|
|
|
|
protected virtual float PopOutSmallScale => 1.1f;
|
|
|
|
|
protected virtual bool CanPopOutWhileRolling => false;
|
|
|
|
|
|
|
|
|
|
public new Vector2 PopOutScale = new Vector2(1.6f);
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
PopOutCount.Origin = Origin;
|
|
|
|
|
PopOutCount.Anchor = Anchor;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected override string FormatCount(int count)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
return $@"{count}x";
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected virtual void TransformPopOut(int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
PopOutCount.Text = FormatCount(newValue);
|
|
|
|
|
|
|
|
|
|
PopOutCount.ScaleTo(PopOutScale);
|
|
|
|
|
PopOutCount.FadeTo(PopOutInitialAlpha);
|
|
|
|
|
PopOutCount.MoveTo(Vector2.Zero);
|
|
|
|
|
|
|
|
|
|
PopOutCount.ScaleTo(1, PopOutDuration, PopOutEasing);
|
|
|
|
|
PopOutCount.FadeOut(PopOutDuration, PopOutEasing);
|
|
|
|
|
PopOutCount.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected virtual void TransformPopOutRolling(int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
TransformPopOut(newValue);
|
|
|
|
|
TransformPopOutSmall(newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected virtual void TransformNoPopOut(int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
|
|
|
|
DisplayedCountSpriteText.ScaleTo(1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected virtual void TransformPopOutSmall(int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
|
|
|
|
DisplayedCountSpriteText.ScaleTo(PopOutSmallScale);
|
|
|
|
|
DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void ScheduledPopOutSmall(uint id)
|
|
|
|
|
{
|
|
|
|
|
// Too late; scheduled task invalidated
|
|
|
|
|
if (id != ScheduledPopOutCurrentId)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DisplayedCount++;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected override void OnCountRolling(int currentValue, int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
ScheduledPopOutCurrentId++;
|
|
|
|
|
|
|
|
|
|
// Hides displayed count if was increasing from 0 to 1 but didn't finish
|
|
|
|
|
if (currentValue == 0 && newValue == 0)
|
|
|
|
|
DisplayedCountSpriteText.FadeOut(FadeOutDuration);
|
|
|
|
|
|
|
|
|
|
base.OnCountRolling(currentValue, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected override void OnCountIncrement(int currentValue, int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
ScheduledPopOutCurrentId++;
|
|
|
|
|
|
|
|
|
|
if (DisplayedCount < currentValue)
|
|
|
|
|
DisplayedCount++;
|
|
|
|
|
|
|
|
|
|
DisplayedCountSpriteText.Show();
|
|
|
|
|
|
|
|
|
|
TransformPopOut(newValue);
|
|
|
|
|
|
|
|
|
|
uint newTaskId = ScheduledPopOutCurrentId;
|
|
|
|
|
Scheduler.AddDelayed(delegate
|
|
|
|
|
{
|
|
|
|
|
ScheduledPopOutSmall(newTaskId);
|
|
|
|
|
}, PopOutDuration);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected override void OnCountChange(int currentValue, int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
ScheduledPopOutCurrentId++;
|
|
|
|
|
|
|
|
|
|
if (newValue == 0)
|
|
|
|
|
DisplayedCountSpriteText.FadeOut();
|
|
|
|
|
|
|
|
|
|
base.OnCountChange(currentValue, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected override void OnDisplayedCountRolling(int currentValue, int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
if (newValue == 0)
|
|
|
|
|
DisplayedCountSpriteText.FadeOut(FadeOutDuration);
|
|
|
|
|
else
|
|
|
|
|
DisplayedCountSpriteText.Show();
|
|
|
|
|
|
|
|
|
|
if (CanPopOutWhileRolling)
|
|
|
|
|
TransformPopOutRolling(newValue);
|
|
|
|
|
else
|
|
|
|
|
TransformNoPopOut(newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected override void OnDisplayedCountChange(int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
|
|
|
|
|
|
|
|
|
TransformNoPopOut(newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 15:05:05 +08:00
|
|
|
|
protected override void OnDisplayedCountIncrement(int newValue)
|
2017-03-10 11:26:46 +08:00
|
|
|
|
{
|
|
|
|
|
DisplayedCountSpriteText.Show();
|
|
|
|
|
|
|
|
|
|
TransformPopOutSmall(newValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|