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