Skip to content

Commit 4c851a3

Browse files
authored
Merge pull request #31880 from peppy/team-logo-support
Add basic display support for team logos
2 parents ff81096 + ef2f482 commit 4c851a3

File tree

20 files changed

+297
-39
lines changed

20 files changed

+297
-39
lines changed
Binary file not shown.

osu.Game.Tests/Skins/SkinDeserialisationTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public class SkinDeserialisationTest
7373
"Archives/modified-default-20241207.osk",
7474
// Covers skinnable spectator list
7575
"Archives/modified-argon-20250116.osk",
76+
// Covers player team flag
77+
"Archives/modified-argon-20250214.osk",
7678
};
7779

7880
/// <summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using Newtonsoft.Json;
5+
6+
namespace osu.Game.Online.API.Requests.Responses
7+
{
8+
[JsonObject(MemberSerialization.OptIn)]
9+
public class APITeam
10+
{
11+
[JsonProperty(@"id")]
12+
public int Id { get; set; } = 1;
13+
14+
[JsonProperty(@"name")]
15+
public string Name { get; set; } = string.Empty;
16+
17+
[JsonProperty(@"short_name")]
18+
public string ShortName { get; set; } = string.Empty;
19+
20+
[JsonProperty(@"flag_url")]
21+
public string FlagUrl = string.Empty;
22+
}
23+
}

osu.Game/Online/API/Requests/Responses/APIUser.cs

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public CountryCode CountryCode
5555
set => countryCodeString = value.ToString();
5656
}
5757

58+
[JsonProperty(@"team")]
59+
[CanBeNull]
60+
public APITeam Team { get; set; }
61+
5862
[JsonProperty(@"profile_colour")]
5963
public string Colour;
6064

osu.Game/Online/Leaderboards/LeaderboardScore.cs

+36-17
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ private void load(IAPIProvider api, OsuColour colour)
180180
Height = 28,
181181
Direction = FillDirection.Horizontal,
182182
Spacing = new Vector2(10f, 0f),
183+
Margin = new MarginPadding { Bottom = -2 },
183184
Children = new Drawable[]
184185
{
185186
flagBadgeAndDateContainer = new FillFlowContainer
@@ -189,7 +190,7 @@ private void load(IAPIProvider api, OsuColour colour)
189190
RelativeSizeAxes = Axes.Y,
190191
Direction = FillDirection.Horizontal,
191192
Spacing = new Vector2(5f, 0f),
192-
Width = 87f,
193+
Width = 114f,
193194
Masking = true,
194195
Children = new Drawable[]
195196
{
@@ -199,22 +200,19 @@ private void load(IAPIProvider api, OsuColour colour)
199200
Origin = Anchor.CentreLeft,
200201
Size = new Vector2(28, 20),
201202
},
203+
new UpdateableTeamFlag(user.Team)
204+
{
205+
Anchor = Anchor.CentreLeft,
206+
Origin = Anchor.CentreLeft,
207+
Size = new Vector2(40, 20),
208+
},
202209
new DateLabel(Score.Date)
203210
{
204211
Anchor = Anchor.CentreLeft,
205212
Origin = Anchor.CentreLeft,
206213
},
207214
},
208215
},
209-
new FillFlowContainer
210-
{
211-
Origin = Anchor.CentreLeft,
212-
Anchor = Anchor.CentreLeft,
213-
AutoSizeAxes = Axes.Both,
214-
Direction = FillDirection.Horizontal,
215-
Margin = new MarginPadding { Left = edge_margin },
216-
Children = statisticsLabels
217-
},
218216
},
219217
},
220218
},
@@ -234,6 +232,7 @@ private void load(IAPIProvider api, OsuColour colour)
234232
GlowColour = Color4Extensions.FromHex(@"83ccfa"),
235233
Current = scoreManager.GetBindableTotalScoreString(Score),
236234
Font = OsuFont.Numeric.With(size: 23),
235+
Margin = new MarginPadding { Top = 1 },
237236
},
238237
RankContainer = new Container
239238
{
@@ -250,13 +249,32 @@ private void load(IAPIProvider api, OsuColour colour)
250249
},
251250
},
252251
},
253-
modsContainer = new FillFlowContainer<ModIcon>
252+
new FillFlowContainer
254253
{
254+
AutoSizeAxes = Axes.Both,
255255
Anchor = Anchor.BottomRight,
256256
Origin = Anchor.BottomRight,
257-
AutoSizeAxes = Axes.Both,
258257
Direction = FillDirection.Horizontal,
259-
ChildrenEnumerable = Score.Mods.AsOrdered().Select(mod => new ModIcon(mod) { Scale = new Vector2(0.375f) })
258+
Children = new Drawable[]
259+
{
260+
new FillFlowContainer
261+
{
262+
Anchor = Anchor.CentreRight,
263+
Origin = Anchor.CentreRight,
264+
AutoSizeAxes = Axes.Both,
265+
Direction = FillDirection.Horizontal,
266+
Margin = new MarginPadding { Left = edge_margin },
267+
Children = statisticsLabels
268+
},
269+
modsContainer = new FillFlowContainer<ModIcon>
270+
{
271+
Anchor = Anchor.CentreRight,
272+
Origin = Anchor.CentreRight,
273+
AutoSizeAxes = Axes.Both,
274+
Direction = FillDirection.Horizontal,
275+
ChildrenEnumerable = Score.Mods.AsOrdered().Select(mod => new ModIcon(mod) { Scale = new Vector2(0.34f) })
276+
},
277+
}
260278
},
261279
},
262280
},
@@ -324,7 +342,7 @@ protected override void OnHoverLost(HoverLostEvent e)
324342

325343
private partial class ScoreComponentLabel : Container, IHasTooltip
326344
{
327-
private const float icon_size = 20;
345+
private const float icon_size = 16;
328346
private readonly FillFlowContainer content;
329347

330348
public override bool Contains(Vector2 screenSpacePos) => content.Contains(screenSpacePos);
@@ -340,7 +358,7 @@ public ScoreComponentLabel(LeaderboardScoreStatistic statistic)
340358
{
341359
AutoSizeAxes = Axes.Both,
342360
Direction = FillDirection.Horizontal,
343-
Padding = new MarginPadding { Right = 10 },
361+
Padding = new MarginPadding { Right = 5 },
344362
Children = new Drawable[]
345363
{
346364
new Container
@@ -375,7 +393,8 @@ public ScoreComponentLabel(LeaderboardScoreStatistic statistic)
375393
Anchor = Anchor.CentreLeft,
376394
Origin = Anchor.CentreLeft,
377395
Text = statistic.Value,
378-
Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold, fixedWidth: true)
396+
Spacing = new Vector2(-1, 0),
397+
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, fixedWidth: true)
379398
},
380399
},
381400
};
@@ -406,7 +425,7 @@ private partial class DateLabel : DrawableDate
406425
public DateLabel(DateTimeOffset date)
407426
: base(date)
408427
{
409-
Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold, italics: true);
428+
Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold, italics: true);
410429
}
411430

412431
protected override string Format() => Date.ToShortRelativeTime(TimeSpan.FromSeconds(30));

osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,20 @@ private Drawable[] createContent(int index, ScoreInfo score)
160160
{
161161
Size = new Vector2(19, 14),
162162
},
163-
username,
163+
new FillFlowContainer
164+
{
165+
AutoSizeAxes = Axes.Both,
166+
Direction = FillDirection.Horizontal,
167+
Spacing = new Vector2(4),
168+
Children = new Drawable[]
169+
{
170+
new UpdateableTeamFlag(score.User.Team)
171+
{
172+
Size = new Vector2(28, 14),
173+
},
174+
username,
175+
}
176+
},
164177
#pragma warning disable 618
165178
new StatisticText(score.MaxCombo, score.BeatmapInfo!.MaxCombo, @"0\x"),
166179
#pragma warning restore 618

osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs

+24-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ public partial class TopScoreUserSection : CompositeDrawable
2727
private readonly UpdateableAvatar avatar;
2828
private readonly LinkFlowContainer usernameText;
2929
private readonly DrawableDate achievedOn;
30+
3031
private readonly UpdateableFlag flag;
32+
private readonly UpdateableTeamFlag teamFlag;
3133

3234
public TopScoreUserSection()
3335
{
@@ -112,12 +114,30 @@ public TopScoreUserSection()
112114
},
113115
}
114116
},
115-
flag = new UpdateableFlag
117+
new FillFlowContainer
116118
{
119+
AutoSizeAxes = Axes.Both,
117120
Anchor = Anchor.CentreLeft,
118121
Origin = Anchor.CentreLeft,
119-
Size = new Vector2(19, 14),
120-
Margin = new MarginPadding { Top = 3 }, // makes spacing look more even
122+
Direction = FillDirection.Horizontal,
123+
Spacing = new Vector2(4),
124+
Children = new Drawable[]
125+
{
126+
flag = new UpdateableFlag
127+
{
128+
Anchor = Anchor.CentreLeft,
129+
Origin = Anchor.CentreLeft,
130+
Size = new Vector2(19, 14),
131+
Margin = new MarginPadding { Top = 3 }, // makes spacing look more even
132+
},
133+
teamFlag = new UpdateableTeamFlag
134+
{
135+
Anchor = Anchor.CentreLeft,
136+
Origin = Anchor.CentreLeft,
137+
Size = new Vector2(28, 14),
138+
Margin = new MarginPadding { Top = 3 }, // makes spacing look more even
139+
},
140+
}
121141
},
122142
}
123143
}
@@ -139,6 +159,7 @@ public ScoreInfo Score
139159
{
140160
avatar.User = value.User;
141161
flag.CountryCode = value.User.CountryCode;
162+
teamFlag.Team = value.User.Team;
142163
achievedOn.Date = value.Date;
143164

144165
usernameText.Clear();

osu.Game/Overlays/KudosuTable.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected override Drawable[] CreateAdditionalContent(APIUser item)
8080

8181
protected override CountryCode GetCountryCode(APIUser item) => item.CountryCode;
8282

83-
protected override Drawable CreateFlagContent(APIUser item)
83+
protected override Drawable[] CreateFlagContent(APIUser item)
8484
{
8585
var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE, italics: true))
8686
{
@@ -89,7 +89,7 @@ protected override Drawable CreateFlagContent(APIUser item)
8989
TextAnchor = Anchor.CentreLeft
9090
};
9191
username.AddUserLink(item);
92-
return username;
92+
return [username];
9393
}
9494
}
9595
}

osu.Game/Overlays/Profile/Header/TopHeaderContainer.cs

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public partial class TopHeaderContainer : CompositeDrawable
4242
private ExternalLinkButton openUserExternally = null!;
4343
private OsuSpriteText titleText = null!;
4444
private UpdateableFlag userFlag = null!;
45+
private UpdateableTeamFlag teamFlag = null!;
4546
private OsuHoverContainer userCountryContainer = null!;
4647
private OsuSpriteText userCountryText = null!;
4748
private GroupBadgeFlow groupBadgeFlow = null!;
@@ -166,6 +167,10 @@ private void load(OverlayColourProvider colourProvider, OsuConfigManager configM
166167
{
167168
Size = new Vector2(28, 20),
168169
},
170+
teamFlag = new UpdateableTeamFlag
171+
{
172+
Size = new Vector2(40, 20),
173+
},
169174
userCountryContainer = new OsuHoverContainer
170175
{
171176
AutoSizeAxes = Axes.Both,
@@ -215,6 +220,7 @@ private void updateUser(UserProfileData? data)
215220
usernameText.Text = user?.Username ?? string.Empty;
216221
openUserExternally.Link = $@"{api.Endpoints.WebsiteUrl}/users/{user?.Id ?? 0}";
217222
userFlag.CountryCode = user?.CountryCode ?? default;
223+
teamFlag.Team = user?.Team;
218224
userCountryText.Text = (user?.CountryCode ?? default).GetDescription();
219225
userCountryContainer.Action = () => rankingsOverlay?.ShowCountry(user?.CountryCode ?? default);
220226
supporterTag.SupportLevel = user?.SupportLevel ?? 0;

osu.Game/Overlays/Rankings/Tables/CountriesTable.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected override RankingsTableColumn[] CreateAdditionalHeaders() => new[]
3434

3535
protected override CountryCode GetCountryCode(CountryStatistics item) => item.Code;
3636

37-
protected override Drawable CreateFlagContent(CountryStatistics item) => new CountryName(item.Code);
37+
protected override Drawable[] CreateFlagContent(CountryStatistics item) => [new CountryName(item.Code)];
3838

3939
protected override Drawable[] CreateAdditionalContent(CountryStatistics item) => new Drawable[]
4040
{

osu.Game/Overlays/Rankings/Tables/RankingsTable.cs

+7-10
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected sealed override Drawable CreateHeader(int index, TableColumn column)
8080

8181
protected abstract CountryCode GetCountryCode(TModel item);
8282

83-
protected abstract Drawable CreateFlagContent(TModel item);
83+
protected abstract Drawable[] CreateFlagContent(TModel item);
8484

8585
private OsuSpriteText createIndexDrawable(int index) => new RowText
8686
{
@@ -92,16 +92,13 @@ protected sealed override Drawable CreateHeader(int index, TableColumn column)
9292
{
9393
AutoSizeAxes = Axes.Both,
9494
Direction = FillDirection.Horizontal,
95-
Spacing = new Vector2(10, 0),
95+
Spacing = new Vector2(5, 0),
9696
Margin = new MarginPadding { Bottom = row_spacing },
97-
Children = new[]
98-
{
99-
new UpdateableFlag(GetCountryCode(item))
100-
{
101-
Size = new Vector2(28, 20),
102-
},
103-
CreateFlagContent(item)
104-
}
97+
Children =
98+
[
99+
new UpdateableFlag(GetCountryCode(item)) { Size = new Vector2(28, 20) },
100+
..CreateFlagContent(item)
101+
]
105102
};
106103

107104
protected class RankingsTableColumn : TableColumn

osu.Game/Overlays/Rankings/Tables/UserBasedTable.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
using osu.Game.Scoring;
1515
using osu.Framework.Localisation;
1616
using osu.Game.Resources.Localisation.Web;
17+
using osu.Game.Users.Drawables;
18+
using osuTK;
1719

1820
namespace osu.Game.Overlays.Rankings.Tables
1921
{
@@ -61,7 +63,7 @@ protected override RankingsTableColumn[] CreateAdditionalHeaders() => new[]
6163

6264
protected sealed override CountryCode GetCountryCode(UserStatistics item) => item.User.CountryCode;
6365

64-
protected sealed override Drawable CreateFlagContent(UserStatistics item)
66+
protected sealed override Drawable[] CreateFlagContent(UserStatistics item)
6567
{
6668
var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE, italics: true))
6769
{
@@ -70,7 +72,7 @@ protected sealed override Drawable CreateFlagContent(UserStatistics item)
7072
TextAnchor = Anchor.CentreLeft
7173
};
7274
username.AddUserLink(item.User);
73-
return username;
75+
return [new UpdateableTeamFlag(item.User.Team) { Size = new Vector2(40, 20) }, username];
7476
}
7577

7678
protected sealed override Drawable[] CreateAdditionalContent(UserStatistics item) => new[]

osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs

+6
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ private void load()
140140
Size = new Vector2(28, 20),
141141
CountryCode = user?.CountryCode ?? default
142142
},
143+
new UpdateableTeamFlag(user?.Team)
144+
{
145+
Anchor = Anchor.CentreLeft,
146+
Origin = Anchor.CentreLeft,
147+
Size = new Vector2(40, 20),
148+
},
143149
new OsuSpriteText
144150
{
145151
Anchor = Anchor.CentreLeft,

0 commit comments

Comments
 (0)