mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 08:42:55 +08:00
Merge pull request #27601 from bdach/fix-bold-mod-select
Fix first word bold not applying correctly after first language change
This commit is contained in:
commit
a900ae87bb
@ -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.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -8,9 +9,11 @@ using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using System.Linq;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -181,17 +184,15 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
headerText.Clear();
|
||||
|
||||
int wordIndex = 0;
|
||||
ITextPart part = headerText.AddText(text);
|
||||
part.DrawablePartsRecreated += applySemiBoldToFirstWord;
|
||||
applySemiBoldToFirstWord(part.Drawables);
|
||||
|
||||
ITextPart part = headerText.AddText(text, t =>
|
||||
void applySemiBoldToFirstWord(IEnumerable<Drawable> d)
|
||||
{
|
||||
if (wordIndex == 0)
|
||||
t.Font = t.Font.With(weight: FontWeight.SemiBold);
|
||||
wordIndex += 1;
|
||||
});
|
||||
|
||||
// Reset the index so that if the parts are refreshed (e.g. through changes in localisation) the correct word is re-emboldened.
|
||||
part.DrawablePartsRecreated += _ => wordIndex = 0;
|
||||
if (d.FirstOrDefault() is OsuSpriteText firstWord)
|
||||
firstWord.Font = firstWord.Font.With(weight: FontWeight.SemiBold);
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
Loading…
Reference in New Issue
Block a user