mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 22:22:59 +08:00
Changes according to review + Refactor
This commit is contained in:
parent
53cd698b3a
commit
6bd3eaf37d
@ -12,6 +12,10 @@ using OpenTK;
|
|||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.GameModes.Play.Catch;
|
||||||
|
using osu.Game.GameModes.Play.Mania;
|
||||||
|
using osu.Game.GameModes.Play.Osu;
|
||||||
|
using osu.Game.GameModes.Play.Taiko;
|
||||||
|
|
||||||
namespace osu.Desktop.Tests
|
namespace osu.Desktop.Tests
|
||||||
{
|
{
|
||||||
@ -25,6 +29,8 @@ namespace osu.Desktop.Tests
|
|||||||
{
|
{
|
||||||
base.Reset();
|
base.Reset();
|
||||||
|
|
||||||
|
int numerator = 0, denominator = 0;
|
||||||
|
|
||||||
ScoreCounter score = new ScoreCounter(7)
|
ScoreCounter score = new ScoreCounter(7)
|
||||||
{
|
{
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
@ -35,7 +41,7 @@ namespace osu.Desktop.Tests
|
|||||||
};
|
};
|
||||||
Add(score);
|
Add(score);
|
||||||
|
|
||||||
StandardComboCounter standardCombo = new StandardComboCounter
|
ComboCounter standardCombo = new OsuComboCounter
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
@ -55,18 +61,28 @@ namespace osu.Desktop.Tests
|
|||||||
};
|
};
|
||||||
Add(catchCombo);
|
Add(catchCombo);
|
||||||
|
|
||||||
AlternativeComboCounter alternativeCombo = new AlternativeComboCounter
|
ComboCounter taikoCombo = new TaikoComboCounter
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomCentre,
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.Centre,
|
||||||
Position = new Vector2(20, 80),
|
Position = new Vector2(0, -160),
|
||||||
Count = 0,
|
Count = 0,
|
||||||
TextSize = 40,
|
TextSize = 40,
|
||||||
};
|
};
|
||||||
Add(alternativeCombo);
|
Add(taikoCombo);
|
||||||
|
|
||||||
|
ComboCounter maniaCombo = new ManiaComboCounter
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Position = new Vector2(0, -80),
|
||||||
|
Count = 0,
|
||||||
|
TextSize = 40,
|
||||||
|
};
|
||||||
|
Add(maniaCombo);
|
||||||
|
|
||||||
|
|
||||||
AccuracyCounter accuracyCombo = new AccuracyCounter
|
PercentageCounter accuracyCombo = new PercentageCounter
|
||||||
{
|
{
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
@ -95,9 +111,10 @@ namespace osu.Desktop.Tests
|
|||||||
{
|
{
|
||||||
score.Count = 0;
|
score.Count = 0;
|
||||||
standardCombo.Count = 0;
|
standardCombo.Count = 0;
|
||||||
alternativeCombo.Count = 0;
|
maniaCombo.Count = 0;
|
||||||
catchCombo.Count = 0;
|
catchCombo.Count = 0;
|
||||||
accuracyCombo.SetCount(0, 0);
|
numerator = denominator = 0;
|
||||||
|
accuracyCombo.SetFraction(0, 0);
|
||||||
stars.Count = 0;
|
stars.Count = 0;
|
||||||
starsLabel.Text = stars.Count.ToString("0.00");
|
starsLabel.Text = stars.Count.ToString("0.00");
|
||||||
});
|
});
|
||||||
@ -106,23 +123,26 @@ namespace osu.Desktop.Tests
|
|||||||
{
|
{
|
||||||
score.Count += 300 + (ulong)(300.0 * (standardCombo.Count > 0 ? standardCombo.Count - 1 : 0) / 25.0);
|
score.Count += 300 + (ulong)(300.0 * (standardCombo.Count > 0 ? standardCombo.Count - 1 : 0) / 25.0);
|
||||||
standardCombo.Count++;
|
standardCombo.Count++;
|
||||||
alternativeCombo.Count++;
|
taikoCombo.Count++;
|
||||||
|
maniaCombo.Count++;
|
||||||
catchCombo.CatchFruit(new Color4(
|
catchCombo.CatchFruit(new Color4(
|
||||||
Math.Max(0.5f, RNG.NextSingle()),
|
Math.Max(0.5f, RNG.NextSingle()),
|
||||||
Math.Max(0.5f, RNG.NextSingle()),
|
Math.Max(0.5f, RNG.NextSingle()),
|
||||||
Math.Max(0.5f, RNG.NextSingle()),
|
Math.Max(0.5f, RNG.NextSingle()),
|
||||||
1)
|
1)
|
||||||
);
|
);
|
||||||
accuracyCombo.Numerator++;
|
numerator++; denominator++;
|
||||||
accuracyCombo.Denominator++;
|
accuracyCombo.SetFraction(numerator, denominator);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddButton(@"miss...", delegate
|
AddButton(@"miss...", delegate
|
||||||
{
|
{
|
||||||
standardCombo.Roll();
|
standardCombo.Roll();
|
||||||
alternativeCombo.Roll();
|
taikoCombo.Roll();
|
||||||
|
maniaCombo.Roll();
|
||||||
catchCombo.Roll();
|
catchCombo.Roll();
|
||||||
accuracyCombo.Denominator++;
|
denominator++;
|
||||||
|
accuracyCombo.SetFraction(numerator, denominator);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddButton(@"Alter stars", delegate
|
AddButton(@"Alter stars", delegate
|
||||||
@ -136,7 +156,8 @@ namespace osu.Desktop.Tests
|
|||||||
score.StopRolling();
|
score.StopRolling();
|
||||||
standardCombo.StopRolling();
|
standardCombo.StopRolling();
|
||||||
catchCombo.StopRolling();
|
catchCombo.StopRolling();
|
||||||
alternativeCombo.StopRolling();
|
taikoCombo.StopRolling();
|
||||||
|
maniaCombo.StopRolling();
|
||||||
accuracyCombo.StopRolling();
|
accuracyCombo.StopRolling();
|
||||||
stars.StopAnimation();
|
stars.StopAnimation();
|
||||||
});
|
});
|
||||||
|
@ -2,32 +2,30 @@
|
|||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Game.GameModes.Play.Osu;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.GameModes.Play.Catch
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Similar to Standard, but without the 'x' and has tinted pop-ups. Used in osu!catch.
|
/// Similar to Standard, but without the 'x' and has tinted pop-ups. Used in osu!catch.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CatchComboCounter : StandardComboCounter
|
public class CatchComboCounter : OsuComboCounter
|
||||||
{
|
{
|
||||||
public CatchComboCounter()
|
protected override bool CanPopOutWhenBackwards => true;
|
||||||
{
|
|
||||||
CanPopOutWhenBackwards = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override string formatCount(ulong count)
|
protected override string FormatCount(ulong count)
|
||||||
{
|
{
|
||||||
return count.ToString("#,0");
|
return count.ToString("#,0");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Roll(ulong newValue = 0)
|
public override void Roll(ulong newValue = 0)
|
||||||
{
|
{
|
||||||
popOutSpriteText.Colour = countSpriteText.Colour;
|
PopOutSpriteText.Colour = CountSpriteText.Colour;
|
||||||
|
|
||||||
base.Roll(newValue);
|
base.Roll(newValue);
|
||||||
}
|
}
|
||||||
@ -38,7 +36,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// <param name="colour">Last grabbed fruit colour.</param>
|
/// <param name="colour">Last grabbed fruit colour.</param>
|
||||||
public void CatchFruit(Color4 colour)
|
public void CatchFruit(Color4 colour)
|
||||||
{
|
{
|
||||||
popOutSpriteText.Colour = colour;
|
PopOutSpriteText.Colour = colour;
|
||||||
Count++;
|
Count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
61
osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs
Normal file
61
osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.GameModes.Play.Taiko;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace osu.Game.GameModes.Play.Mania
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Allows tint and vertical scaling animation. Used in osu!taiko and osu!mania.
|
||||||
|
/// </summary>
|
||||||
|
public class ManiaComboCounter : TaikoComboCounter
|
||||||
|
{
|
||||||
|
protected Color4 OriginalColour;
|
||||||
|
|
||||||
|
protected Color4 TintColour => Color4.OrangeRed;
|
||||||
|
protected Color4 PopOutColor => Color4.Red;
|
||||||
|
protected override float PopOutInitialAlpha => 1.0f;
|
||||||
|
protected override ulong PopOutDuration => 300;
|
||||||
|
|
||||||
|
public override void Load(BaseGame game)
|
||||||
|
{
|
||||||
|
base.Load(game);
|
||||||
|
|
||||||
|
PopOutSpriteText.Anchor = Anchor.BottomCentre;
|
||||||
|
PopOutSpriteText.Origin = Anchor.Centre;
|
||||||
|
PopOutSpriteText.FadeColour(PopOutColor, 0);
|
||||||
|
OriginalColour = Colour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Roll(ulong newValue = 0)
|
||||||
|
{
|
||||||
|
if (!IsRolling)
|
||||||
|
{
|
||||||
|
PopOutSpriteText.Text = FormatCount(VisibleCount);
|
||||||
|
|
||||||
|
PopOutSpriteText.FadeTo(PopOutInitialAlpha);
|
||||||
|
PopOutSpriteText.ScaleTo(1.0f);
|
||||||
|
|
||||||
|
PopOutSpriteText.FadeOut(PopOutDuration, PopOutEasing);
|
||||||
|
PopOutSpriteText.ScaleTo(PopOutScale, PopOutDuration, PopOutEasing);
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Roll(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void transformAnimate(ulong newValue)
|
||||||
|
{
|
||||||
|
base.transformAnimate(newValue);
|
||||||
|
CountSpriteText.FadeColour(TintColour, 0);
|
||||||
|
CountSpriteText.FadeColour(OriginalColour, AnimationDuration, AnimationEasing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
124
osu.Game/GameModes/Play/Osu/OsuComboCounter.cs
Normal file
124
osu.Game/GameModes/Play/Osu/OsuComboCounter.cs
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using OpenTK;
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace osu.Game.GameModes.Play.Osu
|
||||||
|
{
|
||||||
|
/// <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;
|
||||||
|
protected virtual bool CanPopOutWhenBackwards => false;
|
||||||
|
|
||||||
|
|
||||||
|
public Vector2 InnerCountPosition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return CountSpriteText.Position;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
CountSpriteText.Position = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Load(BaseGame game)
|
||||||
|
{
|
||||||
|
base.Load(game);
|
||||||
|
|
||||||
|
PopOutSpriteText.Origin = this.Origin;
|
||||||
|
PopOutSpriteText.Anchor = this.Anchor;
|
||||||
|
|
||||||
|
Add(PopOutSpriteText);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string FormatCount(ulong count)
|
||||||
|
{
|
||||||
|
return count.ToString("#,0") + "x";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void transformPopOut(ulong currentValue, ulong newValue)
|
||||||
|
{
|
||||||
|
PopOutSpriteText.Text = FormatCount(newValue);
|
||||||
|
CountSpriteText.Text = FormatCount(currentValue);
|
||||||
|
|
||||||
|
PopOutSpriteText.ScaleTo(PopOutScale);
|
||||||
|
PopOutSpriteText.FadeTo(PopOutInitialAlpha);
|
||||||
|
PopOutSpriteText.MoveTo(Vector2.Zero);
|
||||||
|
|
||||||
|
PopOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
||||||
|
PopOutSpriteText.FadeOut(PopOutDuration, PopOutEasing);
|
||||||
|
PopOutSpriteText.MoveTo(CountSpriteText.Position, PopOutDuration, PopOutEasing);
|
||||||
|
|
||||||
|
ScheduledPopOutCurrentId++;
|
||||||
|
uint newTaskId = ScheduledPopOutCurrentId;
|
||||||
|
Scheduler.AddDelayed(delegate
|
||||||
|
{
|
||||||
|
scheduledPopOutSmall(newTaskId, newValue);
|
||||||
|
}, PopOutDuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void transformNoPopOut(ulong newValue)
|
||||||
|
{
|
||||||
|
ScheduledPopOutCurrentId++;
|
||||||
|
CountSpriteText.Text = FormatCount(newValue);
|
||||||
|
CountSpriteText.ScaleTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void transformPopOutSmall(ulong newValue)
|
||||||
|
{
|
||||||
|
CountSpriteText.Text = FormatCount(newValue);
|
||||||
|
CountSpriteText.ScaleTo(PopOutSmallScale);
|
||||||
|
CountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void scheduledPopOutSmall(uint id, ulong newValue)
|
||||||
|
{
|
||||||
|
// Too late; scheduled task invalidated
|
||||||
|
if (id != ScheduledPopOutCurrentId)
|
||||||
|
return;
|
||||||
|
|
||||||
|
transformPopOutSmall(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnCountRolling(ulong currentValue, ulong newValue)
|
||||||
|
{
|
||||||
|
if (newValue == 0)
|
||||||
|
CountSpriteText.FadeOut(PopOutDuration);
|
||||||
|
else
|
||||||
|
CountSpriteText.Show();
|
||||||
|
|
||||||
|
if (CanPopOutWhenBackwards)
|
||||||
|
transformPopOut(currentValue, newValue);
|
||||||
|
else
|
||||||
|
transformNoPopOut(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnCountChange(ulong newValue)
|
||||||
|
{
|
||||||
|
CountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
||||||
|
|
||||||
|
transformNoPopOut(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnCountIncrement(ulong newValue)
|
||||||
|
{
|
||||||
|
CountSpriteText.Show();
|
||||||
|
|
||||||
|
transformPopOut(newValue - 1, newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
65
osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs
Normal file
65
osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using OpenTK;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace osu.Game.GameModes.Play.Taiko
|
||||||
|
{
|
||||||
|
public class TaikoComboCounter : ComboCounter
|
||||||
|
{
|
||||||
|
protected virtual int AnimationDuration => 300;
|
||||||
|
protected virtual float ScaleFactor => 2;
|
||||||
|
protected virtual EasingTypes AnimationEasing => EasingTypes.None;
|
||||||
|
protected virtual bool CanAnimateWhenBackwards => false;
|
||||||
|
|
||||||
|
public TaikoComboCounter()
|
||||||
|
{
|
||||||
|
CountSpriteText.Origin = Framework.Graphics.Anchor.BottomCentre;
|
||||||
|
CountSpriteText.Anchor = Framework.Graphics.Anchor.BottomCentre;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void transformAnimate(ulong newValue)
|
||||||
|
{
|
||||||
|
CountSpriteText.Text = FormatCount(newValue);
|
||||||
|
CountSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
|
||||||
|
CountSpriteText.ScaleTo(new Vector2(1, 1), AnimationDuration, AnimationEasing);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void transformNotAnimate(ulong newValue)
|
||||||
|
{
|
||||||
|
CountSpriteText.Text = FormatCount(newValue);
|
||||||
|
CountSpriteText.ScaleTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnCountRolling(ulong currentValue, ulong newValue)
|
||||||
|
{
|
||||||
|
if (newValue == 0)
|
||||||
|
CountSpriteText.FadeOut(AnimationDuration);
|
||||||
|
else
|
||||||
|
CountSpriteText.Show();
|
||||||
|
|
||||||
|
transformNotAnimate(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnCountChange(ulong newValue)
|
||||||
|
{
|
||||||
|
CountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
||||||
|
|
||||||
|
transformNotAnimate(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnCountIncrement(ulong newValue)
|
||||||
|
{
|
||||||
|
CountSpriteText.Show();
|
||||||
|
|
||||||
|
transformAnimate(newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,109 +0,0 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using osu.Framework;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Transformations;
|
|
||||||
using osu.Framework.Timing;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Used as an accuracy counter. Represented visually as a percentage, internally as a fraction.
|
|
||||||
/// </summary>
|
|
||||||
public class AccuracyCounter : RollingCounter<float>
|
|
||||||
{
|
|
||||||
protected override Type transformType => typeof(TransformAccuracy);
|
|
||||||
|
|
||||||
private long numerator = 0;
|
|
||||||
public long Numerator
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return numerator;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
numerator = value;
|
|
||||||
updateCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ulong denominator = 0;
|
|
||||||
public ulong Denominator
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return denominator;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
denominator = value;
|
|
||||||
updateCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public AccuracyCounter()
|
|
||||||
{
|
|
||||||
RollingDuration = 500;
|
|
||||||
RollingEasing = EasingTypes.Out;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
|
||||||
{
|
|
||||||
base.Load(game);
|
|
||||||
|
|
||||||
updateCount();
|
|
||||||
StopRolling();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetCount(long num, ulong den)
|
|
||||||
{
|
|
||||||
numerator = num;
|
|
||||||
denominator = den;
|
|
||||||
updateCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateCount()
|
|
||||||
{
|
|
||||||
Count = Denominator == 0 ? 100.0f : (Numerator * 100.0f) / Denominator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ResetCount()
|
|
||||||
{
|
|
||||||
numerator = 0;
|
|
||||||
denominator = 0;
|
|
||||||
updateCount();
|
|
||||||
StopRolling();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override string formatCount(float count)
|
|
||||||
{
|
|
||||||
return count.ToString("0.00") + "%";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override double getProportionalDuration(float currentValue, float newValue)
|
|
||||||
{
|
|
||||||
return Math.Abs(currentValue - newValue) * RollingDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected class TransformAccuracy : TransformFloat
|
|
||||||
{
|
|
||||||
public override void Apply(Drawable d)
|
|
||||||
{
|
|
||||||
base.Apply(d);
|
|
||||||
(d as AccuracyCounter).VisibleCount = CurrentValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransformAccuracy(IClock clock)
|
|
||||||
: base(clock)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework;
|
|
||||||
using osu.Framework.Graphics.Transformations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Allows tint and vertical scaling animation. Used in osu!taiko and osu!mania.
|
|
||||||
/// </summary>
|
|
||||||
public class AlternativeComboCounter : ComboCounter
|
|
||||||
{
|
|
||||||
public Color4 OriginalColour;
|
|
||||||
public Color4 TintColour = Color4.OrangeRed;
|
|
||||||
public int TintDuration = 300;
|
|
||||||
public float ScaleFactor = 2;
|
|
||||||
public EasingTypes TintEasing = EasingTypes.None;
|
|
||||||
public bool CanAnimateWhenBackwards = false;
|
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
|
||||||
{
|
|
||||||
base.Load(game);
|
|
||||||
|
|
||||||
OriginalColour = Colour;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override double getProportionalDuration(ulong currentValue, ulong newValue)
|
|
||||||
{
|
|
||||||
double difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue;
|
|
||||||
return difference * RollingDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void transformAnimate(ulong newValue)
|
|
||||||
{
|
|
||||||
countSpriteText.FadeColour(TintColour, 0);
|
|
||||||
countSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
|
|
||||||
countSpriteText.FadeColour(OriginalColour, TintDuration, TintEasing);
|
|
||||||
countSpriteText.ScaleTo(new Vector2(1, 1), TintDuration, TintEasing);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void transformVisibleCount(ulong currentValue, ulong newValue)
|
|
||||||
{
|
|
||||||
countSpriteText.Text = formatCount(newValue);
|
|
||||||
|
|
||||||
if (newValue == 0)
|
|
||||||
countSpriteText.FadeOut(TintDuration);
|
|
||||||
else
|
|
||||||
countSpriteText.Show();
|
|
||||||
|
|
||||||
if (newValue > currentValue || CanAnimateWhenBackwards)
|
|
||||||
transformAnimate(newValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,28 +17,37 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public abstract class ComboCounter : AutoSizeContainer
|
public abstract class ComboCounter : Container
|
||||||
{
|
{
|
||||||
protected Type transformType => typeof(TransformCombo);
|
protected Type transformType => typeof(TransformCombo);
|
||||||
|
|
||||||
|
protected bool IsRolling = false;
|
||||||
|
|
||||||
|
protected SpriteText PopOutSpriteText;
|
||||||
|
|
||||||
|
protected virtual ulong PopOutDuration => 150;
|
||||||
|
protected virtual float PopOutScale => 2.0f;
|
||||||
|
protected virtual EasingTypes PopOutEasing => EasingTypes.None;
|
||||||
|
protected virtual float PopOutInitialAlpha => 0.75f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true, the roll-down duration will be proportional to the counter.
|
/// If true, the roll-down duration will be proportional to the counter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsRollingProportional = true;
|
protected virtual bool IsRollingProportional => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each
|
/// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each
|
||||||
/// element; else duration in milliseconds for the counter roll-up animation in total.
|
/// element; else duration in milliseconds for the counter roll-up animation in total.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double RollingDuration = 20;
|
protected virtual double RollingDuration => 20;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Easing for the counter rollover animation.
|
/// Easing for the counter rollover animation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EasingTypes RollingEasing = EasingTypes.None;
|
protected EasingTypes RollingEasing => EasingTypes.None;
|
||||||
|
|
||||||
protected ulong prevVisibleCount;
|
private ulong prevVisibleCount;
|
||||||
protected ulong visibleCount;
|
private ulong visibleCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Value shown at the current moment.
|
/// Value shown at the current moment.
|
||||||
@ -55,11 +64,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
return;
|
return;
|
||||||
prevVisibleCount = visibleCount;
|
prevVisibleCount = visibleCount;
|
||||||
visibleCount = value;
|
visibleCount = value;
|
||||||
transformVisibleCount(prevVisibleCount, visibleCount);
|
transformVisibleCount(prevVisibleCount, visibleCount, IsRolling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ulong prevPrevCount;
|
|
||||||
protected ulong prevCount;
|
protected ulong prevCount;
|
||||||
protected ulong count;
|
protected ulong count;
|
||||||
|
|
||||||
@ -80,25 +88,25 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
private void setCount(ulong value, bool rolling = false)
|
private void setCount(ulong value, bool rolling = false)
|
||||||
{
|
{
|
||||||
prevPrevCount = prevCount;
|
|
||||||
prevCount = count;
|
prevCount = count;
|
||||||
count = value;
|
count = value;
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
{
|
{
|
||||||
transformCount(VisibleCount, prevPrevCount, prevCount, value, rolling);
|
transformCount(VisibleCount, prevCount, value, rolling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SpriteText countSpriteText;
|
protected SpriteText CountSpriteText;
|
||||||
|
|
||||||
protected float textSize = 20.0f;
|
private float textSize = 20.0f;
|
||||||
public float TextSize
|
public float TextSize
|
||||||
{
|
{
|
||||||
get { return textSize; }
|
get { return textSize; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
textSize = value;
|
textSize = value;
|
||||||
updateTextSize();
|
CountSpriteText.TextSize = TextSize;
|
||||||
|
PopOutSpriteText.TextSize = TextSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,12 +117,16 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
countSpriteText = new SpriteText
|
CountSpriteText = new SpriteText
|
||||||
{
|
{
|
||||||
Anchor = this.Anchor,
|
Anchor = this.Anchor,
|
||||||
Origin = this.Origin,
|
Origin = this.Origin,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
},
|
},
|
||||||
|
PopOutSpriteText = new SpriteText
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +134,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
base.Load(game);
|
base.Load(game);
|
||||||
|
|
||||||
countSpriteText.Anchor = this.Anchor;
|
CountSpriteText.Anchor = this.Anchor;
|
||||||
countSpriteText.Origin = this.Origin;
|
CountSpriteText.Origin = this.Origin;
|
||||||
|
|
||||||
StopRolling();
|
StopRolling();
|
||||||
}
|
}
|
||||||
@ -133,7 +145,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void StopRolling()
|
public virtual void StopRolling()
|
||||||
{
|
{
|
||||||
removeComboTransforms();
|
Flush(false, typeof(TransformCombo));
|
||||||
VisibleCount = Count;
|
VisibleCount = Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,62 +166,55 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Count = default(ulong);
|
Count = default(ulong);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual double getProportionalDuration(ulong currentValue, ulong newValue)
|
protected double GetProportionalDuration(ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
double difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue;
|
||||||
|
return difference * RollingDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void transformVisibleCount(ulong currentValue, ulong newValue);
|
protected virtual string FormatCount(ulong count)
|
||||||
|
|
||||||
protected virtual string formatCount(ulong count)
|
|
||||||
{
|
{
|
||||||
return count.ToString();
|
return count.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateComboTransforms()
|
protected abstract void OnCountRolling(ulong currentValue, ulong newValue);
|
||||||
|
protected abstract void OnCountIncrement(ulong newValue);
|
||||||
|
protected abstract void OnCountChange(ulong newValue);
|
||||||
|
|
||||||
|
private void transformVisibleCount(ulong currentValue, ulong newValue, bool rolling)
|
||||||
{
|
{
|
||||||
foreach (ITransform t in Transforms.AliveItems)
|
if (rolling)
|
||||||
if (t.GetType() == typeof(TransformCombo))
|
OnCountRolling(currentValue, newValue);
|
||||||
t.Apply(this);
|
else if (currentValue + 1 == newValue)
|
||||||
|
OnCountIncrement(newValue);
|
||||||
|
else
|
||||||
|
OnCountChange(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeComboTransforms()
|
private void transformCount(
|
||||||
{
|
|
||||||
Transforms.RemoveAll(t => t.GetType() == typeof(TransformCombo));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void transformCount(
|
|
||||||
ulong visibleValue,
|
ulong visibleValue,
|
||||||
ulong prevValue,
|
|
||||||
ulong currentValue,
|
ulong currentValue,
|
||||||
ulong newValue,
|
ulong newValue,
|
||||||
bool rolling)
|
bool rolling)
|
||||||
{
|
{
|
||||||
if (!rolling)
|
if (!rolling)
|
||||||
{
|
{
|
||||||
updateComboTransforms();
|
Flush(false, typeof(TransformCombo));
|
||||||
removeComboTransforms();
|
IsRolling = false;
|
||||||
|
|
||||||
// If was decreasing, stops roll before increasing
|
|
||||||
if (currentValue < prevValue)
|
|
||||||
VisibleCount = currentValue;
|
VisibleCount = currentValue;
|
||||||
|
|
||||||
VisibleCount = newValue;
|
VisibleCount = newValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
transformCount(new TransformCombo(Clock), visibleValue, newValue);
|
IsRolling = true;
|
||||||
|
transformRoll(new TransformCombo(Clock), visibleValue, newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void transformRoll(TransformCombo transform, ulong currentValue, ulong newValue)
|
||||||
/// Intended to be used by transformCount().
|
|
||||||
/// </summary>
|
|
||||||
/// <see cref="transformCount"/>
|
|
||||||
protected void transformCount(TransformCombo transform, ulong currentValue, ulong newValue)
|
|
||||||
{
|
{
|
||||||
updateComboTransforms();
|
Flush(false, typeof(TransformCombo));
|
||||||
removeComboTransforms();
|
|
||||||
|
|
||||||
if (Clock == null)
|
if (Clock == null)
|
||||||
return;
|
return;
|
||||||
@ -222,7 +227,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
double rollingTotalDuration =
|
double rollingTotalDuration =
|
||||||
IsRollingProportional
|
IsRollingProportional
|
||||||
? getProportionalDuration(currentValue, newValue)
|
? GetProportionalDuration(currentValue, newValue)
|
||||||
: RollingDuration;
|
: RollingDuration;
|
||||||
|
|
||||||
transform.StartTime = Time;
|
transform.StartTime = Time;
|
||||||
@ -234,11 +239,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Transforms.Add(transform);
|
Transforms.Add(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void updateTextSize()
|
|
||||||
{
|
|
||||||
countSpriteText.TextSize = TextSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected class TransformCombo : Transform<ulong>
|
protected class TransformCombo : Transform<ulong>
|
||||||
{
|
{
|
||||||
public override ulong CurrentValue
|
public override ulong CurrentValue
|
||||||
|
62
osu.Game/Graphics/UserInterface/PercentageCounter.cs
Normal file
62
osu.Game/Graphics/UserInterface/PercentageCounter.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Used as an accuracy counter. Represented visually as a percentage.
|
||||||
|
/// </summary>
|
||||||
|
public class PercentageCounter : RollingCounter<float>
|
||||||
|
{
|
||||||
|
protected override Type TransformType => typeof(TransformAccuracy);
|
||||||
|
|
||||||
|
public override double RollingDuration => 500;
|
||||||
|
public override EasingTypes RollingEasing => EasingTypes.Out;
|
||||||
|
|
||||||
|
private float epsilon => 1e-10f;
|
||||||
|
|
||||||
|
public void SetFraction(float numerator, float denominator)
|
||||||
|
{
|
||||||
|
Count = Math.Abs(denominator) < epsilon ? 1.0f : numerator / denominator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PercentageCounter()
|
||||||
|
{
|
||||||
|
Count = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string FormatCount(float count)
|
||||||
|
{
|
||||||
|
return $@"{count:P2}";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override double GetProportionalDuration(float currentValue, float newValue)
|
||||||
|
{
|
||||||
|
return Math.Abs(currentValue - newValue) * RollingDuration * 100.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class TransformAccuracy : TransformFloat
|
||||||
|
{
|
||||||
|
public override void Apply(Drawable d)
|
||||||
|
{
|
||||||
|
base.Apply(d);
|
||||||
|
(d as PercentageCounter).VisibleCount = CurrentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransformAccuracy(IClock clock)
|
||||||
|
: base(clock)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,9 +23,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Must be a subclass of Transform<T>
|
/// Must be a subclass of Transform<T>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected virtual Type transformType => typeof(Transform<T>);
|
protected virtual Type TransformType => typeof(Transform<T>);
|
||||||
|
|
||||||
protected SpriteText countSpriteText;
|
protected SpriteText CountSpriteText;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true, the roll-up duration will be proportional to change in value.
|
/// If true, the roll-up duration will be proportional to change in value.
|
||||||
@ -36,15 +36,15 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each
|
/// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each
|
||||||
/// element; else duration in milliseconds for the counter roll-up animation in total.
|
/// element; else duration in milliseconds for the counter roll-up animation in total.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double RollingDuration = 0;
|
public virtual double RollingDuration => 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Easing for the counter rollover animation.
|
/// Easing for the counter rollover animation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EasingTypes RollingEasing = EasingTypes.None;
|
public virtual EasingTypes RollingEasing => EasingTypes.None;
|
||||||
|
|
||||||
protected T prevVisibleCount;
|
private T prevVisibleCount;
|
||||||
protected T visibleCount;
|
private T visibleCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Value shown at the current moment.
|
/// Value shown at the current moment.
|
||||||
@ -60,7 +60,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (visibleCount.Equals(value))
|
if (visibleCount.Equals(value))
|
||||||
return;
|
return;
|
||||||
visibleCount = value;
|
visibleCount = value;
|
||||||
countSpriteText.Text = formatCount(value);
|
CountSpriteText.Text = FormatCount(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
count = value;
|
count = value;
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
{
|
{
|
||||||
transformCount(visibleCount, count);
|
TransformCount(visibleCount, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
textSize = value;
|
textSize = value;
|
||||||
countSpriteText.TextSize = value;
|
CountSpriteText.TextSize = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,13 +105,13 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected RollingCounter()
|
protected RollingCounter()
|
||||||
{
|
{
|
||||||
Debug.Assert(
|
Debug.Assert(
|
||||||
transformType.IsSubclassOf(typeof(Transform<T>)) || transformType == typeof(Transform<T>),
|
TransformType.IsSubclassOf(typeof(Transform<T>)) || TransformType == typeof(Transform<T>),
|
||||||
@"transformType should be a subclass of Transform<T>."
|
@"transformType should be a subclass of Transform<T>."
|
||||||
);
|
);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
countSpriteText = new SpriteText
|
CountSpriteText = new SpriteText
|
||||||
{
|
{
|
||||||
Anchor = this.Anchor,
|
Anchor = this.Anchor,
|
||||||
Origin = this.Origin,
|
Origin = this.Origin,
|
||||||
@ -123,13 +123,13 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
base.Load(game);
|
base.Load(game);
|
||||||
|
|
||||||
removeTransforms(transformType);
|
Flush(false, TransformType);
|
||||||
|
|
||||||
VisibleCount = Count;
|
VisibleCount = Count;
|
||||||
|
|
||||||
countSpriteText.Text = formatCount(count);
|
CountSpriteText.Text = FormatCount(count);
|
||||||
countSpriteText.Anchor = this.Anchor;
|
CountSpriteText.Anchor = this.Anchor;
|
||||||
countSpriteText.Origin = this.Origin;
|
CountSpriteText.Origin = this.Origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -147,7 +147,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void StopRolling()
|
public virtual void StopRolling()
|
||||||
{
|
{
|
||||||
removeTransforms(transformType);
|
Flush(false, TransformType);
|
||||||
VisibleCount = Count;
|
VisibleCount = Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// <param name="currentValue">Current visible value.</param>
|
/// <param name="currentValue">Current visible value.</param>
|
||||||
/// <param name="newValue">New final value.</param>
|
/// <param name="newValue">New final value.</param>
|
||||||
/// <returns>Calculated rollover duration in milliseconds.</returns>
|
/// <returns>Calculated rollover duration in milliseconds.</returns>
|
||||||
protected virtual double getProportionalDuration(T currentValue, T newValue)
|
protected virtual double GetProportionalDuration(T currentValue, T newValue)
|
||||||
{
|
{
|
||||||
return RollingDuration;
|
return RollingDuration;
|
||||||
}
|
}
|
||||||
@ -180,46 +180,32 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="count">Count to format.</param>
|
/// <param name="count">Count to format.</param>
|
||||||
/// <returns>Count formatted as a string.</returns>
|
/// <returns>Count formatted as a string.</returns>
|
||||||
protected virtual string formatCount(T count)
|
protected virtual string FormatCount(T count)
|
||||||
{
|
{
|
||||||
return count.ToString();
|
return count.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateTransforms(Type type)
|
|
||||||
{
|
|
||||||
foreach (ITransform t in Transforms.AliveItems)
|
|
||||||
if (t.GetType() == type)
|
|
||||||
t.Apply(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void removeTransforms(Type type)
|
|
||||||
{
|
|
||||||
Transforms.RemoveAll(t => t.GetType() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the count is updated to add a transformer that changes the value of the visible count (i.e.
|
/// Called when the count is updated to add a transformer that changes the value of the visible count (i.e.
|
||||||
/// implement the rollover animation).
|
/// implement the rollover animation).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="currentValue">Count value before modification.</param>
|
/// <param name="currentValue">Count value before modification.</param>
|
||||||
/// <param name="newValue">Expected count value after modification-</param>
|
/// <param name="newValue">Expected count value after modification-</param>
|
||||||
/// <seealso cref="transformType"/>
|
/// <seealso cref="TransformType"/>
|
||||||
protected virtual void transformCount(T currentValue, T newValue)
|
protected virtual void TransformCount(T currentValue, T newValue)
|
||||||
{
|
{
|
||||||
object[] parameters = { Clock };
|
object[] parameters = { Clock };
|
||||||
transformCount((Transform<T>)Activator.CreateInstance(transformType, parameters), currentValue, newValue);
|
TransformCount((Transform<T>)Activator.CreateInstance(TransformType, parameters), currentValue, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Intended to be used by transformCount().
|
/// Intended to be used by TransformCount(T currentValue, T newValue).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <see cref="transformCount"/>
|
protected void TransformCount(Transform<T> transform, T currentValue, T newValue)
|
||||||
protected void transformCount(Transform<T> transform, T currentValue, T newValue)
|
|
||||||
{
|
{
|
||||||
Type type = transform.GetType();
|
Type type = transform.GetType();
|
||||||
|
|
||||||
updateTransforms(type);
|
Flush(false, type);
|
||||||
removeTransforms(type);
|
|
||||||
|
|
||||||
if (Clock == null)
|
if (Clock == null)
|
||||||
return;
|
return;
|
||||||
@ -232,7 +218,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
double rollingTotalDuration =
|
double rollingTotalDuration =
|
||||||
IsRollingProportional
|
IsRollingProportional
|
||||||
? getProportionalDuration(currentValue, newValue)
|
? GetProportionalDuration(currentValue, newValue)
|
||||||
: RollingDuration;
|
: RollingDuration;
|
||||||
|
|
||||||
transform.StartTime = Time;
|
transform.StartTime = Time;
|
||||||
|
@ -16,7 +16,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
public class ScoreCounter : RollingCounter<ulong>
|
public class ScoreCounter : RollingCounter<ulong>
|
||||||
{
|
{
|
||||||
protected override Type transformType => typeof(TransformScore);
|
protected override Type TransformType => typeof(TransformScore);
|
||||||
|
|
||||||
|
public override double RollingDuration => 1000;
|
||||||
|
public override EasingTypes RollingEasing => EasingTypes.Out;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How many leading zeroes the counter has.
|
/// How many leading zeroes the counter has.
|
||||||
@ -33,11 +36,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
||||||
public ScoreCounter(uint leading = 0)
|
public ScoreCounter(uint leading = 0)
|
||||||
{
|
{
|
||||||
countSpriteText.FixedWidth = true;
|
CountSpriteText.FixedWidth = true;
|
||||||
LeadingZeroes = leading;
|
LeadingZeroes = leading;
|
||||||
|
|
||||||
RollingDuration = 1000;
|
|
||||||
RollingEasing = EasingTypes.Out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
public override void Load(BaseGame game)
|
||||||
@ -45,12 +45,12 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
base.Load(game);
|
base.Load(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override double getProportionalDuration(ulong currentValue, ulong newValue)
|
protected override double GetProportionalDuration(ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string formatCount(ulong count)
|
protected override string FormatCount(ulong count)
|
||||||
{
|
{
|
||||||
return count.ToString("D" + LeadingZeroes);
|
return count.ToString("D" + LeadingZeroes);
|
||||||
}
|
}
|
||||||
|
@ -1,142 +0,0 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using OpenTK;
|
|
||||||
using osu.Framework;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.Transformations;
|
|
||||||
using osu.Framework.Timing;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Uses the 'x' symbol and has a pop-out effect while rolling over. Used in osu! standard.
|
|
||||||
/// </summary>
|
|
||||||
public class StandardComboCounter : ComboCounter
|
|
||||||
{
|
|
||||||
protected SpriteText popOutSpriteText;
|
|
||||||
|
|
||||||
protected uint scheduledPopOutCurrentId = 0;
|
|
||||||
|
|
||||||
public ulong PopOutDuration = 150;
|
|
||||||
public float PopOutBigScale = 2.0f;
|
|
||||||
public float PopOutSmallScale = 1.1f;
|
|
||||||
public EasingTypes PopOutEasing = EasingTypes.None;
|
|
||||||
public bool CanPopOutWhenBackwards = false;
|
|
||||||
public float PopOutInitialAlpha = 0.75f;
|
|
||||||
|
|
||||||
public Vector2 InnerCountPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return countSpriteText.Position;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
countSpriteText.Position = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public StandardComboCounter()
|
|
||||||
{
|
|
||||||
popOutSpriteText = new SpriteText
|
|
||||||
{
|
|
||||||
Origin = this.Origin,
|
|
||||||
Anchor = this.Anchor,
|
|
||||||
TextSize = this.TextSize,
|
|
||||||
Alpha = 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
|
||||||
{
|
|
||||||
base.Load(game);
|
|
||||||
|
|
||||||
popOutSpriteText.Origin = this.Origin;
|
|
||||||
popOutSpriteText.Anchor = this.Anchor;
|
|
||||||
|
|
||||||
Add(popOutSpriteText);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override double getProportionalDuration(ulong currentValue, ulong newValue)
|
|
||||||
{
|
|
||||||
double difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue;
|
|
||||||
return difference * RollingDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override string formatCount(ulong count)
|
|
||||||
{
|
|
||||||
return count.ToString("#,0") + "x";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void transformPopOut(ulong currentValue, ulong newValue)
|
|
||||||
{
|
|
||||||
popOutSpriteText.Text = formatCount(newValue);
|
|
||||||
countSpriteText.Text = formatCount(currentValue);
|
|
||||||
|
|
||||||
popOutSpriteText.ScaleTo(PopOutBigScale);
|
|
||||||
popOutSpriteText.FadeTo(PopOutInitialAlpha);
|
|
||||||
popOutSpriteText.MoveTo(Vector2.Zero);
|
|
||||||
|
|
||||||
popOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
|
||||||
popOutSpriteText.FadeOut(PopOutDuration, PopOutEasing);
|
|
||||||
popOutSpriteText.MoveTo(countSpriteText.Position, PopOutDuration, PopOutEasing);
|
|
||||||
|
|
||||||
scheduledPopOutCurrentId++;
|
|
||||||
uint newTaskId = scheduledPopOutCurrentId;
|
|
||||||
Scheduler.AddDelayed(delegate
|
|
||||||
{
|
|
||||||
scheduledPopOutSmall(newTaskId, newValue);
|
|
||||||
}, PopOutDuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void transformNoPopOut(ulong newValue)
|
|
||||||
{
|
|
||||||
scheduledPopOutCurrentId++;
|
|
||||||
countSpriteText.Text = formatCount(newValue);
|
|
||||||
countSpriteText.ScaleTo(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void transformPopOutSmall(ulong newValue)
|
|
||||||
{
|
|
||||||
countSpriteText.Text = formatCount(newValue);
|
|
||||||
countSpriteText.ScaleTo(PopOutSmallScale);
|
|
||||||
countSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void scheduledPopOutSmall(uint id, ulong newValue)
|
|
||||||
{
|
|
||||||
// Too late; scheduled task invalidated
|
|
||||||
if (id != scheduledPopOutCurrentId)
|
|
||||||
return;
|
|
||||||
|
|
||||||
transformPopOutSmall(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void transformVisibleCount(ulong currentValue, ulong newValue)
|
|
||||||
{
|
|
||||||
if (newValue == 0)
|
|
||||||
countSpriteText.FadeOut(PopOutDuration);
|
|
||||||
else
|
|
||||||
countSpriteText.Show();
|
|
||||||
|
|
||||||
if (newValue > currentValue || CanPopOutWhenBackwards)
|
|
||||||
transformPopOut(currentValue, newValue);
|
|
||||||
else
|
|
||||||
transformNoPopOut(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void updateTextSize()
|
|
||||||
{
|
|
||||||
base.updateTextSize();
|
|
||||||
|
|
||||||
popOutSpriteText.TextSize = this.TextSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Transformations;
|
using osu.Framework.Graphics.Transformations;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Framework.Timing;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -35,14 +34,14 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected set;
|
protected set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double AnimationDelay = 150;
|
private double animationDelay => 150;
|
||||||
|
|
||||||
public double ScalingDuration = 500;
|
private double scalingDuration => 500;
|
||||||
public EasingTypes ScalingEasing = EasingTypes.OutElasticHalf;
|
private EasingTypes scalingEasing => EasingTypes.OutElasticHalf;
|
||||||
public float MinStarScale = 0.3f;
|
private float minStarScale => 0.3f;
|
||||||
|
|
||||||
public double FadingDuration = 100;
|
private double fadingDuration => 100;
|
||||||
public float MinStarAlpha = 0.5f;
|
private float minStarAlpha => 0.5f;
|
||||||
|
|
||||||
public float StarSize = 20;
|
public float StarSize = 20;
|
||||||
public float StarSpacing = 4;
|
public float StarSpacing = 4;
|
||||||
@ -52,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
double elapsedTime = Time - transformStartTime;
|
double elapsedTime = Time - transformStartTime;
|
||||||
double expectedElapsedTime = Math.Abs(prevCount - count) * AnimationDelay;
|
double expectedElapsedTime = Math.Abs(prevCount - count) * animationDelay;
|
||||||
if (elapsedTime >= expectedElapsedTime)
|
if (elapsedTime >= expectedElapsedTime)
|
||||||
return count;
|
return count;
|
||||||
return Interpolation.ValueAt(elapsedTime, prevCount, count, 0, expectedElapsedTime);
|
return Interpolation.ValueAt(elapsedTime, prevCount, count, 0, expectedElapsedTime);
|
||||||
@ -147,21 +146,21 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private float getStarScale(int i, float value)
|
private float getStarScale(int i, float value)
|
||||||
{
|
{
|
||||||
if (value <= i)
|
if (value <= i)
|
||||||
return MinStarScale;
|
return minStarScale;
|
||||||
if (i + 1 <= value)
|
if (i + 1 <= value)
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
return Interpolation.ValueAt(value, MinStarScale, 1.0f, i, i + 1);
|
return Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformStar(int i, float value)
|
private void transformStar(int i, float value)
|
||||||
{
|
{
|
||||||
stars[i].FadeTo(i < value ? 1.0f : MinStarAlpha, FadingDuration);
|
stars[i].FadeTo(i < value ? 1.0f : minStarAlpha, fadingDuration);
|
||||||
stars[i].ScaleTo(getStarScale(i, value), ScalingDuration, ScalingEasing);
|
stars[i].ScaleTo(getStarScale(i, value), scalingDuration, scalingEasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformStarQuick(int i, float value)
|
private void transformStarQuick(int i, float value)
|
||||||
{
|
{
|
||||||
stars[i].FadeTo(i < value ? 1.0f : MinStarAlpha);
|
stars[i].FadeTo(i < value ? 1.0f : minStarAlpha);
|
||||||
stars[i].ScaleTo(getStarScale(i, value));
|
stars[i].ScaleTo(getStarScale(i, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,9 +171,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
stars[i].DelayReset();
|
stars[i].DelayReset();
|
||||||
stars[i].ClearTransformations();
|
stars[i].ClearTransformations();
|
||||||
if (currentValue <= newValue)
|
if (currentValue <= newValue)
|
||||||
stars[i].Delay(Math.Max(i - currentValue, 0) * AnimationDelay);
|
stars[i].Delay(Math.Max(i - currentValue, 0) * animationDelay);
|
||||||
else
|
else
|
||||||
stars[i].Delay(Math.Max(currentValue - 1 - i, 0) * AnimationDelay);
|
stars[i].Delay(Math.Max(currentValue - 1 - i, 0) * animationDelay);
|
||||||
transformStar(i, newValue);
|
transformStar(i, newValue);
|
||||||
}
|
}
|
||||||
transformStartTime = Time;
|
transformStartTime = Time;
|
||||||
|
@ -132,21 +132,22 @@
|
|||||||
<Compile Include="GameModes\Edit\EditSongSelect.cs" />
|
<Compile Include="GameModes\Edit\EditSongSelect.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\ComboCounter.cs" />
|
<Compile Include="Graphics\UserInterface\ComboCounter.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\RollingCounter.cs" />
|
<Compile Include="Graphics\UserInterface\RollingCounter.cs" />
|
||||||
|
<Compile Include="GameModes\Play\Taiko\TaikoComboCounter.cs" />
|
||||||
<Compile Include="Input\GlobalHotkeys.cs" />
|
<Compile Include="Input\GlobalHotkeys.cs" />
|
||||||
<Compile Include="Graphics\Background\Background.cs" />
|
<Compile Include="Graphics\Background\Background.cs" />
|
||||||
<Compile Include="Graphics\Containers\ParallaxContainer.cs" />
|
<Compile Include="Graphics\Containers\ParallaxContainer.cs" />
|
||||||
<Compile Include="Graphics\Cursor\OsuCursorContainer.cs" />
|
<Compile Include="Graphics\Cursor\OsuCursorContainer.cs" />
|
||||||
<Compile Include="Graphics\Processing\RatioAdjust.cs" />
|
<Compile Include="Graphics\Processing\RatioAdjust.cs" />
|
||||||
<Compile Include="Graphics\TextAwesome.cs" />
|
<Compile Include="Graphics\TextAwesome.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\AlternativeComboCounter.cs" />
|
<Compile Include="GameModes\Play\Mania\ManiaComboCounter.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\KeyCounter.cs" />
|
<Compile Include="Graphics\UserInterface\KeyCounter.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\KeyCounterKeyboard.cs" />
|
<Compile Include="Graphics\UserInterface\KeyCounterKeyboard.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\KeyCounterCollection.cs" />
|
<Compile Include="Graphics\UserInterface\KeyCounterCollection.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\KeyCounterMouse.cs" />
|
<Compile Include="Graphics\UserInterface\KeyCounterMouse.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\AccuracyCounter.cs" />
|
<Compile Include="Graphics\UserInterface\PercentageCounter.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\ScoreCounter.cs" />
|
<Compile Include="Graphics\UserInterface\ScoreCounter.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\CatchComboCounter.cs" />
|
<Compile Include="GameModes\Play\Catch\CatchComboCounter.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\StandardComboCounter.cs" />
|
<Compile Include="GameModes\Play\Osu\OsuComboCounter.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\StarCounter.cs" />
|
<Compile Include="Graphics\UserInterface\StarCounter.cs" />
|
||||||
<Compile Include="Online\API\APIAccess.cs" />
|
<Compile Include="Online\API\APIAccess.cs" />
|
||||||
<Compile Include="Online\API\APIRequest.cs" />
|
<Compile Include="Online\API\APIRequest.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user