1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 11:42:54 +08:00

Move maxSizePerGlyph optional ctor param to init-only property

I'm doing this as I'm about to add more similar properties to
`LegacySpriteText` and I don't want to create a twenty-argument
constructor monstrosity.
This commit is contained in:
Bartłomiej Dach 2023-10-27 19:48:10 +02:00
parent 7a5f3b856f
commit c9cb0561f7
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View File

@ -145,10 +145,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
return null;
const float hitcircle_text_scale = 0.8f;
return new LegacySpriteText(LegacyFont.HitCircle, OsuHitObject.OBJECT_DIMENSIONS * 2 / hitcircle_text_scale)
return new LegacySpriteText(LegacyFont.HitCircle)
{
// stable applies a blanket 0.8x scale to hitcircle fonts
Scale = new Vector2(hitcircle_text_scale),
MaxSizePerGlyph = OsuHitObject.OBJECT_DIMENSIONS * 2 / hitcircle_text_scale,
};
case OsuSkinComponents.SpinnerBody:

View File

@ -12,8 +12,9 @@ namespace osu.Game.Skinning
{
public sealed partial class LegacySpriteText : OsuSpriteText
{
public Vector2? MaxSizePerGlyph { get; init; }
private readonly LegacyFont font;
private readonly Vector2? maxSizePerGlyph;
private LegacyGlyphStore glyphStore = null!;
@ -21,10 +22,9 @@ namespace osu.Game.Skinning
protected override char[] FixedWidthExcludeCharacters => new[] { ',', '.', '%', 'x' };
public LegacySpriteText(LegacyFont font, Vector2? maxSizePerGlyph = null)
public LegacySpriteText(LegacyFont font)
{
this.font = font;
this.maxSizePerGlyph = maxSizePerGlyph;
Shadow = false;
UseFullGlyphHeight = false;
@ -36,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, maxSizePerGlyph);
glyphStore = new LegacyGlyphStore(skin, MaxSizePerGlyph);
}
protected override TextBuilder CreateTextBuilder(ITexturedGlyphLookupStore store) => base.CreateTextBuilder(glyphStore);