mirror of https://github.com/ppy/osu
Fix legacy sprite texts not matching stable with respect to fixed width
stable's `pSpriteText` has a `TextConstantSpacing` flag, that is selectively enabled for some usages. In particular, these are: - mania combo counter (not yet implemented) - taiko combo counter (not yet implemented) - score counter - accuracy counter - scoreboard entries (not yet implemented) Everything else uses non-fixed-width fonts. Hilariously, `LegacySpinner` _tried_ to account for this by changing `Font` to have `fixedWidth: false` specified, only to fail to notice that `LegacySpriteText` changes `Font` in its BDL, making the property set do precisely nothing. For this reason, attempting to set `Font` on a `LegacySpriteText` will now throw.
This commit is contained in:
parent
c9cb0561f7
commit
99e590c8dd
|
@ -87,7 +87,7 @@ private void load(DrawableHitObject drawableHitObject, ISkinSource source)
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Scale = new Vector2(SPRITE_SCALE),
|
Scale = new Vector2(SPRITE_SCALE),
|
||||||
Y = SPINNER_TOP_OFFSET + 299,
|
Y = SPINNER_TOP_OFFSET + 299,
|
||||||
}.With(s => s.Font = s.Font.With(fixedWidth: false)),
|
},
|
||||||
spmBackground = new Sprite
|
spmBackground = new Sprite
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
|
@ -102,7 +102,7 @@ private void load(DrawableHitObject drawableHitObject, ISkinSource source)
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Scale = new Vector2(SPRITE_SCALE * 0.9f),
|
Scale = new Vector2(SPRITE_SCALE * 0.9f),
|
||||||
Position = new Vector2(80, 448 + spm_hide_offset),
|
Position = new Vector2(80, 448 + spm_hide_offset),
|
||||||
}.With(s => s.Font = s.Font.With(fixedWidth: false)),
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ public LegacyAccuracyCounter()
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
|
FixedWidth = true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ public LegacyScoreCounter()
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
|
FixedWidth = true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
@ -13,6 +14,7 @@ namespace osu.Game.Skinning
|
||||||
public sealed partial class LegacySpriteText : OsuSpriteText
|
public sealed partial class LegacySpriteText : OsuSpriteText
|
||||||
{
|
{
|
||||||
public Vector2? MaxSizePerGlyph { get; init; }
|
public Vector2? MaxSizePerGlyph { get; init; }
|
||||||
|
public bool FixedWidth { get; init; }
|
||||||
|
|
||||||
private readonly LegacyFont font;
|
private readonly LegacyFont font;
|
||||||
|
|
||||||
|
@ -22,6 +24,15 @@ public sealed partial class LegacySpriteText : OsuSpriteText
|
||||||
|
|
||||||
protected override char[] FixedWidthExcludeCharacters => new[] { ',', '.', '%', 'x' };
|
protected override char[] FixedWidthExcludeCharacters => new[] { ',', '.', '%', 'x' };
|
||||||
|
|
||||||
|
// ReSharper disable once UnusedMember.Global
|
||||||
|
// being unused is the point here
|
||||||
|
public new FontUsage Font
|
||||||
|
{
|
||||||
|
get => base.Font;
|
||||||
|
set => throw new InvalidOperationException(@"Attempting to use this setter will not work correctly. "
|
||||||
|
+ $@"Use specific init-only properties exposed by {nameof(LegacySpriteText)} instead.");
|
||||||
|
}
|
||||||
|
|
||||||
public LegacySpriteText(LegacyFont font)
|
public LegacySpriteText(LegacyFont font)
|
||||||
{
|
{
|
||||||
this.font = font;
|
this.font = font;
|
||||||
|
@ -33,7 +44,7 @@ public LegacySpriteText(LegacyFont font)
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin)
|
private void load(ISkinSource skin)
|
||||||
{
|
{
|
||||||
Font = new FontUsage(skin.GetFontPrefix(font), 1, fixedWidth: true);
|
base.Font = new FontUsage(skin.GetFontPrefix(font), 1, fixedWidth: FixedWidth);
|
||||||
Spacing = new Vector2(-skin.GetFontOverlap(font), 0);
|
Spacing = new Vector2(-skin.GetFontOverlap(font), 0);
|
||||||
|
|
||||||
glyphStore = new LegacyGlyphStore(skin, MaxSizePerGlyph);
|
glyphStore = new LegacyGlyphStore(skin, MaxSizePerGlyph);
|
||||||
|
|
Loading…
Reference in New Issue