Skip to content

Commit 16f1c8e

Browse files
committed
Fix potential text overflow in circular visualizer
1 parent 615d81c commit 16f1c8e

File tree

1 file changed

+24
-45
lines changed

1 file changed

+24
-45
lines changed

osu.Game.Rulesets.Sandbox/Screens/Visualizer/Components/Layouts/TypeA/UpdateableBeatmapBackground.cs

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using osuTK.Graphics;
88
using osu.Framework.Extensions.Color4Extensions;
99
using osu.Framework.Graphics.Effects;
10-
using osu.Framework.Graphics.Sprites;
1110
using osu.Framework.Allocation;
1211
using osu.Game.Rulesets.Sandbox.Screens.Visualizer.Components.MusicHelpers;
1312
using osu.Game.Graphics.Backgrounds;
@@ -81,7 +80,7 @@ protected override void OnBeatmapChanged(ValueChangedEvent<WorkingBeatmap> beatm
8180
Anchor = Anchor.Centre,
8281
Origin = Anchor.Centre,
8382
Alpha = 0,
84-
Colour = Color4.LightGray
83+
Colour = Color4.DarkGray
8584
}, newBackground =>
8685
{
8786
background?.FadeOut(animation_duration, Easing.OutQuint);
@@ -120,8 +119,8 @@ private class BeatmapName : CompositeDrawable
120119
private readonly Bindable<string> colour = new Bindable<string>("#ffffff");
121120

122121
private readonly WorkingBeatmap beatmap;
123-
private SpriteText artist;
124-
private SpriteText title;
122+
private TextFlowContainer artist;
123+
private TextFlowContainer title;
125124

126125
public BeatmapName(WorkingBeatmap beatmap = null)
127126
{
@@ -131,8 +130,10 @@ public BeatmapName(WorkingBeatmap beatmap = null)
131130
[BackgroundDependencyLoader]
132131
private void load()
133132
{
134-
AutoSizeAxes = Axes.Both;
133+
AutoSizeAxes = Axes.Y;
134+
RelativeSizeAxes = Axes.X;
135135
RelativePositionAxes = Axes.Y;
136+
Padding = new MarginPadding { Horizontal = 30 };
136137

137138
if (beatmap == null)
138139
return;
@@ -141,29 +142,40 @@ private void load()
141142
{
142143
Anchor = Anchor.Centre,
143144
Origin = Anchor.Centre,
144-
AutoSizeAxes = Axes.Both,
145+
AutoSizeAxes = Axes.Y,
146+
RelativeSizeAxes = Axes.X,
145147
Direction = FillDirection.Vertical,
146148
Spacing = new Vector2(0, 10),
147149
Children = new Drawable[]
148150
{
149-
artist = new SpriteText
151+
artist = new TextFlowContainer(t =>
152+
{
153+
t.Font = OsuFont.GetFont(size: 28, weight: FontWeight.Bold);
154+
})
150155
{
151156
Anchor = Anchor.Centre,
152157
Origin = Anchor.Centre,
153-
Font = OsuFont.GetFont(size: 26, weight: FontWeight.SemiBold),
158+
TextAnchor = Anchor.Centre,
159+
RelativeSizeAxes = Axes.X,
160+
AutoSizeAxes = Axes.Y,
154161
Text = beatmap.Metadata.Artist
155162
},
156-
title = new SpriteText
163+
title = new TextFlowContainer(t =>
164+
{
165+
t.Font = OsuFont.GetFont(size: 22, weight: FontWeight.SemiBold);
166+
})
157167
{
158168
Anchor = Anchor.Centre,
159169
Origin = Anchor.Centre,
160-
Font = OsuFont.GetFont(size: 20, weight: FontWeight.SemiBold),
161-
Text = getShortTitle(beatmap.Metadata.Title)
170+
TextAnchor = Anchor.Centre,
171+
RelativeSizeAxes = Axes.X,
172+
AutoSizeAxes = Axes.Y,
173+
Text = beatmap.Metadata.Title
162174
}
163175
}
164176
}.WithEffect(new BlurEffect
165177
{
166-
Colour = Color4.Black.Opacity(0.8f),
178+
Colour = Color4.Black.Opacity(0.7f),
167179
DrawOriginal = true,
168180
PadExtent = true,
169181
Sigma = new Vector2(5)
@@ -185,39 +197,6 @@ protected override void LoadComplete()
185197

186198
colour.BindValueChanged(c => artist.Colour = title.Colour = Colour4.FromHex(c.NewValue), true);
187199
}
188-
189-
/// <summary>
190-
/// Trims additional info in brackets in beatmap title (if exists).
191-
/// </summary>
192-
/// <param name="longTitle">The title to trim.</param>
193-
/// <returns></returns>
194-
private static string getShortTitle(string longTitle)
195-
{
196-
var newTitle = longTitle;
197-
198-
for (int i = 0; i < title_chars.Length; i++)
199-
{
200-
if (newTitle.Contains(title_chars[i]))
201-
{
202-
var charIndex = newTitle.IndexOf(title_chars[i]);
203-
204-
if (charIndex != 0)
205-
newTitle = newTitle.Substring(0, charIndex);
206-
}
207-
}
208-
209-
if (newTitle.EndsWith(" "))
210-
newTitle = newTitle[0..^1];
211-
212-
return newTitle;
213-
}
214-
215-
private static readonly char[] title_chars = new[]
216-
{
217-
'(',
218-
'-',
219-
'~'
220-
};
221200
}
222201
}
223202
}

0 commit comments

Comments
 (0)