Add size limitation for hit object numbers

This commit is contained in:
Salman Ahmed 2023-09-19 04:37:51 +03:00
parent ab5226832a
commit 922f6f36f2
2 changed files with 12 additions and 4 deletions

View File

@ -139,7 +139,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
if (!this.HasFont(LegacyFont.HitCircle))
return null;
return new LegacySpriteText(LegacyFont.HitCircle)
return new LegacySpriteText(LegacyFont.HitCircle, new Vector2(OsuHitObject.OBJECT_RADIUS * 2))
{
// stable applies a blanket 0.8x scale to hitcircle fonts
Scale = new Vector2(0.8f),

View File

@ -13,6 +13,7 @@ namespace osu.Game.Skinning
public sealed partial class LegacySpriteText : OsuSpriteText
{
private readonly LegacyFont font;
private readonly Vector2? maxSize;
private LegacyGlyphStore glyphStore = null!;
@ -20,9 +21,11 @@ namespace osu.Game.Skinning
protected override char[] FixedWidthExcludeCharacters => new[] { ',', '.', '%', 'x' };
public LegacySpriteText(LegacyFont font)
public LegacySpriteText(LegacyFont font, Vector2? maxSize = null)
{
this.font = font;
this.maxSize = maxSize;
Shadow = false;
UseFullGlyphHeight = false;
}
@ -33,7 +36,7 @@ namespace osu.Game.Skinning
Font = new FontUsage(skin.GetFontPrefix(font), 1, fixedWidth: true);
Spacing = new Vector2(-skin.GetFontOverlap(font), 0);
glyphStore = new LegacyGlyphStore(skin);
glyphStore = new LegacyGlyphStore(skin, maxSize);
}
protected override TextBuilder CreateTextBuilder(ITexturedGlyphLookupStore store) => base.CreateTextBuilder(glyphStore);
@ -41,10 +44,12 @@ namespace osu.Game.Skinning
private class LegacyGlyphStore : ITexturedGlyphLookupStore
{
private readonly ISkin skin;
private readonly Vector2? maxSize;
public LegacyGlyphStore(ISkin skin)
public LegacyGlyphStore(ISkin skin, Vector2? maxSize)
{
this.skin = skin;
this.maxSize = maxSize;
}
public ITexturedCharacterGlyph? Get(string fontName, char character)
@ -56,6 +61,9 @@ namespace osu.Game.Skinning
if (texture == null)
return null;
if (maxSize != null)
texture = texture.WithMaximumSize(maxSize.Value);
return new TexturedCharacterGlyph(new CharacterGlyph(character, 0, 0, texture.Width, texture.Height, null), texture, 1f / texture.ScaleAdjust);
}