Update legacy sprite text constructor

This commit is contained in:
Salman Ahmed 2021-03-07 02:28:08 +03:00
parent 64d1cb5193
commit 2a2ee3fa5e
2 changed files with 10 additions and 20 deletions

View File

@ -4,7 +4,6 @@
using System; using System;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -14,9 +13,7 @@ namespace osu.Game.Skinning
public class LegacyRollingCounter : RollingCounter<int> public class LegacyRollingCounter : RollingCounter<int>
{ {
private readonly ISkin skin; private readonly ISkin skin;
private readonly LegacyFont font;
private readonly string fontName;
private readonly float fontOverlap;
protected override bool IsRollingProportional => true; protected override bool IsRollingProportional => true;
@ -24,17 +21,11 @@ namespace osu.Game.Skinning
/// Creates a new <see cref="LegacyRollingCounter"/>. /// Creates a new <see cref="LegacyRollingCounter"/>.
/// </summary> /// </summary>
/// <param name="skin">The <see cref="ISkin"/> from which to get counter number sprites.</param> /// <param name="skin">The <see cref="ISkin"/> from which to get counter number sprites.</param>
/// <param name="fontName">The name of the legacy font to use.</param> /// <param name="font">The legacy font to use for the counter.</param>
/// <param name="fontOverlap"> public LegacyRollingCounter(ISkin skin, LegacyFont font)
/// The numeric overlap of number sprites to use.
/// A positive number will bring the number sprites closer together, while a negative number
/// will split them apart more.
/// </param>
public LegacyRollingCounter(ISkin skin, string fontName, float fontOverlap)
{ {
this.skin = skin; this.skin = skin;
this.fontName = fontName; this.font = font;
this.fontOverlap = fontOverlap;
} }
protected override double GetProportionalDuration(int currentValue, int newValue) protected override double GetProportionalDuration(int currentValue, int newValue)
@ -42,10 +33,6 @@ namespace osu.Game.Skinning
return Math.Abs(newValue - currentValue) * 75.0; return Math.Abs(newValue - currentValue) * 75.0;
} }
protected sealed override OsuSpriteText CreateSpriteText() => protected sealed override OsuSpriteText CreateSpriteText() => new LegacySpriteText(skin, font);
new LegacySpriteText(skin, fontName)
{
Spacing = new Vector2(-fontOverlap, 0f)
};
} }
} }

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Text; using osu.Framework.Text;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -16,12 +17,14 @@ namespace osu.Game.Skinning
protected override char[] FixedWidthExcludeCharacters => new[] { ',', '.', '%', 'x' }; protected override char[] FixedWidthExcludeCharacters => new[] { ',', '.', '%', 'x' };
public LegacySpriteText(ISkin skin, string font = "score") public LegacySpriteText(ISkin skin, LegacyFont font)
{ {
Shadow = false; Shadow = false;
UseFullGlyphHeight = false; UseFullGlyphHeight = false;
Font = new FontUsage(font, 1, fixedWidth: true); Font = new FontUsage(skin.GetFontPrefix(font), 1, fixedWidth: true);
Spacing = new Vector2(-skin.GetFontOverlap(font), 0);
glyphStore = new LegacyGlyphStore(skin); glyphStore = new LegacyGlyphStore(skin);
} }