mirror of
https://github.com/ppy/osu
synced 2024-12-27 09:23:15 +00:00
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 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(SPRITE_SCALE),
|
||||
Y = SPINNER_TOP_OFFSET + 299,
|
||||
}.With(s => s.Font = s.Font.With(fixedWidth: false)),
|
||||
},
|
||||
spmBackground = new Sprite
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -102,7 +102,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
Origin = Anchor.TopRight,
|
||||
Scale = new Vector2(SPRITE_SCALE * 0.9f),
|
||||
Position = new Vector2(80, 448 + spm_hide_offset),
|
||||
}.With(s => s.Font = s.Font.With(fixedWidth: false)),
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
FixedWidth = true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
FixedWidth = true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -13,6 +14,7 @@ namespace osu.Game.Skinning
|
||||
public sealed partial class LegacySpriteText : OsuSpriteText
|
||||
{
|
||||
public Vector2? MaxSizePerGlyph { get; init; }
|
||||
public bool FixedWidth { get; init; }
|
||||
|
||||
private readonly LegacyFont font;
|
||||
|
||||
@ -22,6 +24,15 @@ namespace osu.Game.Skinning
|
||||
|
||||
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)
|
||||
{
|
||||
this.font = font;
|
||||
@ -33,7 +44,7 @@ namespace osu.Game.Skinning
|
||||
[BackgroundDependencyLoader]
|
||||
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);
|
||||
|
||||
glyphStore = new LegacyGlyphStore(skin, MaxSizePerGlyph);
|
||||
|
Loading…
Reference in New Issue
Block a user