-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathBeatmapLeaderboardScore.cs
More file actions
699 lines (621 loc) · 34.1 KB
/
BeatmapLeaderboardScore.cs
File metadata and controls
699 lines (621 loc) · 34.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Online.API;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Users;
using osu.Game.Users.Drawables;
using osu.Game.Utils;
using osuTK;
using osuTK.Graphics;
using CommonStrings = osu.Game.Localisation.CommonStrings;
namespace osu.Game.Screens.Select
{
public sealed partial class BeatmapLeaderboardScore : OsuClickableContainer, IHasContextMenu, IHasCustomTooltip<ScoreInfo>
{
public const int HEIGHT = 50;
public readonly ScoreInfo Score;
public Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>();
/// <summary>
/// A function determining whether each mod in the score can be selected.
/// A return value of <see langword="true"/> means that the mod can be selected in the current context.
/// A return value of <see langword="false"/> means that the mod cannot be selected in the current context.
/// </summary>
public Func<Mod, bool> IsValidMod { get; set; } = _ => true;
public int? Rank { get; init; }
public HighlightType? Highlight { get; init; }
public Action<ScoreInfo>? ShowReplay { get; init; }
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved]
private IDialogOverlay? dialogOverlay { get; set; }
[Resolved]
private ScoreManager scoreManager { get; set; } = null!;
[Resolved]
private OsuConfigManager config { get; set; } = null!;
[Resolved]
private OsuGame? game { get; set; }
[Resolved]
private IAPIProvider api { get; set; } = null!;
private const float expanded_right_content_width = 200;
private const float grade_width = 35;
private const float username_min_width = 120;
private const float statistics_regular_min_width = 165;
private const float statistics_compact_min_width = 90;
private const float rank_label_width = 40;
private const int corner_radius = 10;
private const int transition_duration = 200;
private static readonly Color4 personal_best_gradient_left = Color4Extensions.FromHex("#66FFCC");
private static readonly Color4 personal_best_gradient_right = Color4Extensions.FromHex("#51A388");
private Colour4 foregroundColour;
private Colour4 backgroundColour;
private ColourInfo totalScoreBackgroundGradient;
private IBindable<ScoringMode> scoringMode { get; set; } = null!;
private Box background = null!;
private Box foreground = null!;
private ClickableAvatar innerAvatar = null!;
private Container centreContent = null!;
private Container rightContent = null!;
private FillFlowContainer<Drawable> modsContainer = null!;
private Box totalScoreBackground = null!;
private FillFlowContainer statisticsContainer = null!;
private Container highlightGradient = null!;
private Container rankLabelStandalone = null!;
private Container rankLabelOverlay = null!;
private readonly bool sheared;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
{
var inputRectangle = DrawRectangle;
inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapLeaderboardWedge.SPACING_BETWEEN_SCORES / 2 });
return inputRectangle.Contains(ToLocalSpace(screenSpacePos));
}
public BeatmapLeaderboardScore(ScoreInfo score, bool sheared = true)
{
Score = score;
this.sheared = sheared;
Shear = sheared ? OsuGame.SHEAR : Vector2.Zero;
RelativeSizeAxes = Axes.X;
Height = HEIGHT;
}
[BackgroundDependencyLoader]
private void load()
{
foregroundColour = colourProvider.Background5;
backgroundColour = colourProvider.Background3;
totalScoreBackgroundGradient = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0), backgroundColour);
Child = new Container
{
Masking = true,
CornerRadius = corner_radius,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
background = new Box
{
Alpha = 0.4f,
RelativeSizeAxes = Axes.Both,
Colour = backgroundColour
},
rankLabelStandalone = new Container
{
Width = rank_label_width,
RelativeSizeAxes = Axes.Y,
Children = new Drawable[]
{
highlightGradient = new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Right = -10f },
Alpha = Highlight != null ? 1 : 0,
Colour = getHighlightColour(Highlight),
Child = new Box { RelativeSizeAxes = Axes.Both },
},
new RankLabel(Rank, sheared, darkText: Highlight == HighlightType.Own)
{
RelativeSizeAxes = Axes.Both,
}
},
},
centreContent = new Container
{
Name = @"Centre container",
RelativeSizeAxes = Axes.Both,
Child = new Container
{
Masking = true,
CornerRadius = corner_radius,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
foreground = new Box
{
Alpha = 0.4f,
RelativeSizeAxes = Axes.Both,
Colour = foregroundColour
},
new UserCoverBackground
{
RelativeSizeAxes = Axes.Both,
User = Score.User,
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Colour = ColourInfo.GradientHorizontal(Colour4.White.Opacity(0.5f), Colour4.FromHex(@"222A27").Opacity(1)),
},
new GridContainer
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension(),
new Dimension(GridSizeMode.AutoSize),
},
Content = new[]
{
new Drawable[]
{
new Container
{
AutoSizeAxes = Axes.Both,
CornerRadius = corner_radius,
Masking = true,
Children = new Drawable[]
{
new DelayedLoadWrapper(innerAvatar = new ClickableAvatar(Score.User)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(1.1f),
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
RelativeSizeAxes = Axes.Both,
})
{
RelativeSizeAxes = Axes.None,
Size = new Vector2(HEIGHT)
},
rankLabelOverlay = new Container
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Colour4.Black.Opacity(0.5f),
},
new RankLabel(Rank, sheared, false)
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
}
},
},
new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Padding = new MarginPadding { Horizontal = corner_radius },
Children = new Drawable[]
{
new FillFlowContainer
{
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
AutoSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
{
new UpdateableFlag(Score.User.CountryCode)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(20, 14),
},
new UpdateableTeamFlag(Score.User.Team)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(30, 15),
},
new DateLabel(Score.Date)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Colour = colourProvider.Content2,
UseFullGlyphHeight = false,
}
}
},
new TruncatingSpriteText
{
RelativeSizeAxes = Axes.X,
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
Text = Score.User.Username,
Font = OsuFont.Style.Heading2,
}
}
},
new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Child = statisticsContainer = new FillFlowContainer
{
Name = @"Statistics container",
Padding = new MarginPadding { Right = 10 },
Spacing = new Vector2(20, 0),
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new LeaderboardStatistic(BeatmapsetsStrings.ShowScoreboardHeadersCombo.ToUpper(), $"{Score.MaxCombo.ToString()}x",
Score.MaxCombo == Score.GetMaximumAchievableCombo(), 60),
new LeaderboardStatistic(BeatmapsetsStrings.ShowScoreboardHeadersAccuracy.ToUpper(), Score.DisplayAccuracy, Score.Accuracy == 1,
55),
},
Alpha = 0,
}
}
}
}
},
},
},
},
rightContent = new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Name = @"Right content",
RelativeSizeAxes = Axes.Y,
Child = new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Right = grade_width },
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0), OsuColour.ForRank(Score.Rank)),
},
},
new Box
{
RelativeSizeAxes = Axes.Y,
Width = grade_width,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Colour = OsuColour.ForRank(Score.Rank),
},
new TrianglesV2
{
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
SpawnRatio = 2,
Velocity = 0.7f,
Colour = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0), OsuColour.ForRank(Score.Rank).Darken(0.2f)),
},
new Container
{
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
RelativeSizeAxes = Axes.Y,
Width = grade_width,
Child = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Spacing = new Vector2(-2),
Colour = DrawableRank.GetRankLetterColour(Score.Rank),
Font = OsuFont.Numeric.With(size: 14),
Text = DrawableRank.GetRankLetter(Score.Rank),
ShadowColour = Color4.Black.Opacity(0.3f),
ShadowOffset = new Vector2(0, 0.08f),
Shadow = true,
UseFullGlyphHeight = false,
},
},
new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Padding = new MarginPadding { Right = grade_width },
Child = new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = corner_radius,
Children = new Drawable[]
{
totalScoreBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = totalScoreBackgroundGradient,
},
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0), OsuColour.ForRank(Score.Rank).Opacity(0.5f)),
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Direction = FillDirection.Vertical,
Padding = new MarginPadding { Horizontal = corner_radius },
Spacing = new Vector2(0f, -2f),
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
UseFullGlyphHeight = false,
Current = scoreManager.GetBindableTotalScoreString(Score),
Spacing = new Vector2(-1.5f),
Font = OsuFont.Style.Subtitle.With(weight: FontWeight.Light, fixedWidth: true),
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
},
modsContainer = new FillFlowContainer<Drawable>
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(-10, 0),
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
},
}
}
}
}
}
}
},
}
}
};
innerAvatar.OnLoadComplete += d => d.FadeInFromZero(200);
}
private ColourInfo getHighlightColour(HighlightType? highlightType, float lightenAmount = 0)
{
switch (highlightType)
{
case HighlightType.Own:
return ColourInfo.GradientHorizontal(personal_best_gradient_left.Lighten(lightenAmount), personal_best_gradient_right.Lighten(lightenAmount));
case HighlightType.Friend:
return ColourInfo.GradientHorizontal(colours.Pink1.Lighten(lightenAmount), colours.Pink3.Lighten(lightenAmount));
default:
return Colour4.White;
}
}
protected override void LoadComplete()
{
base.LoadComplete();
scoringMode = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode);
scoringMode.BindValueChanged(s =>
{
switch (s.NewValue)
{
case ScoringMode.Standardised:
rightContent.Width = 170;
break;
case ScoringMode.Classic:
rightContent.Width = expanded_right_content_width;
break;
}
updateModDisplay();
}, true);
}
private void updateModDisplay()
{
if (Score.Mods.Length > 0)
{
modsContainer.Padding = new MarginPadding { Top = 4f };
modsContainer.ChildrenEnumerable = Score.Mods.AsOrdered().Select(mod => new ModIcon(mod)
{
Scale = new Vector2(0.3f),
// trim mod icon height down to its true height for alignment purposes.
Height = ModIcon.MOD_ICON_SIZE.Y * 3 / 4f,
});
}
}
private (CaseTransformableString, LocalisableString DisplayAccuracy)[] getStatistics(ScoreInfo model) => new[]
{
(BeatmapsetsStrings.ShowScoreboardHeadersCombo.ToUpper(), model.MaxCombo.ToString().Insert(model.MaxCombo.ToString().Length, "x")),
(BeatmapsetsStrings.ShowScoreboardHeadersAccuracy.ToUpper(), model.DisplayAccuracy),
};
protected override bool OnHover(HoverEvent e)
{
updateState();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
updateState();
base.OnHoverLost(e);
}
private void updateState()
{
var lightenedGradient = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0).Lighten(0.2f), backgroundColour.Lighten(0.2f));
foreground.FadeColour(IsHovered ? foregroundColour.Lighten(0.2f) : foregroundColour, transition_duration, Easing.OutQuint);
background.FadeColour(IsHovered ? backgroundColour.Lighten(0.2f) : backgroundColour, transition_duration, Easing.OutQuint);
totalScoreBackground.FadeColour(IsHovered ? lightenedGradient : totalScoreBackgroundGradient, transition_duration, Easing.OutQuint);
highlightGradient.FadeColour(getHighlightColour(Highlight, IsHovered ? 0.2f : 0), transition_duration, Easing.OutQuint);
if (IsHovered && currentMode != DisplayMode.Full)
rankLabelOverlay.FadeIn(transition_duration, Easing.OutQuint);
else
rankLabelOverlay.FadeOut(transition_duration, Easing.OutQuint);
}
private DisplayMode? currentMode;
protected override void Update()
{
base.Update();
DisplayMode mode = getCurrentDisplayMode();
if (currentMode != mode)
updateDisplayMode(mode);
centreContent.Padding = new MarginPadding
{
Left = rankLabelStandalone.DrawWidth,
Right = rightContent.DrawWidth,
};
}
private void updateDisplayMode(DisplayMode mode)
{
double duration = currentMode == null ? 0 : transition_duration;
if (mode >= DisplayMode.Full)
rankLabelStandalone.FadeIn(duration, Easing.OutQuint).ResizeWidthTo(rank_label_width, duration, Easing.OutQuint);
else
rankLabelStandalone.FadeOut(duration, Easing.OutQuint).ResizeWidthTo(0, duration, Easing.OutQuint);
if (mode >= DisplayMode.Regular)
{
statisticsContainer.FadeIn(duration, Easing.OutQuint).MoveToX(0, duration, Easing.OutQuint);
statisticsContainer.Direction = FillDirection.Horizontal;
statisticsContainer.ScaleTo(1, duration, Easing.OutQuint);
}
else if (mode >= DisplayMode.Compact)
{
statisticsContainer.FadeIn(duration, Easing.OutQuint).MoveToX(0, duration, Easing.OutQuint);
statisticsContainer.Direction = FillDirection.Vertical;
statisticsContainer.ScaleTo(0.8f, duration, Easing.OutQuint);
}
else
statisticsContainer.FadeOut(duration, Easing.OutQuint).MoveToX(statisticsContainer.DrawWidth, duration, Easing.OutQuint);
currentMode = mode;
}
private DisplayMode getCurrentDisplayMode()
{
if (DrawWidth >= username_min_width + statistics_regular_min_width + expanded_right_content_width + rank_label_width)
return DisplayMode.Full;
if (DrawWidth >= username_min_width + statistics_regular_min_width + expanded_right_content_width)
return DisplayMode.Regular;
if (DrawWidth >= username_min_width + statistics_compact_min_width + expanded_right_content_width)
return DisplayMode.Compact;
return DisplayMode.Minimal;
}
ITooltip<ScoreInfo> IHasCustomTooltip<ScoreInfo>.GetCustomTooltip() => new LeaderboardScoreTooltip(colourProvider);
ScoreInfo IHasCustomTooltip<ScoreInfo>.TooltipContent => Score;
MenuItem[] IHasContextMenu.ContextMenuItems
{
get
{
List<MenuItem> items = new List<MenuItem>();
// system mods should never be copied across regardless of anything.
var copyableMods = Score.Mods.Where(m => IsValidMod.Invoke(m) && m.Type != ModType.System).ToArray();
if (copyableMods.Length > 0)
items.Add(new OsuMenuItem(SongSelectStrings.UseTheseMods, MenuItemType.Highlighted, () => SelectedMods.Value = copyableMods));
if (Score.OnlineID > 0)
items.Add(new OsuMenuItem(CommonStrings.CopyLink, MenuItemType.Standard, () => game?.CopyToClipboard($@"{api.Endpoints.WebsiteUrl}/scores/{Score.OnlineID}")));
if (Score.Files.Count <= 0) return items.ToArray();
if (items.Count > 0)
items.Add(new OsuMenuItemSpacer());
if (ShowReplay != null)
items.Add(new OsuMenuItem(SongSelectStrings.WatchReplay, MenuItemType.Standard, () => ShowReplay.Invoke(Score)));
items.Add(new OsuMenuItem(CommonStrings.Export, MenuItemType.Standard, () => scoreManager.Export(Score)));
items.Add(new OsuMenuItem(Resources.Localisation.Web.CommonStrings.ButtonsDelete, MenuItemType.Destructive, () => dialogOverlay?.Push(new LocalScoreDeleteDialog(Score))));
return items.ToArray();
}
}
private enum DisplayMode
{
Minimal,
Compact,
Regular,
Full
}
private partial class DateLabel : DrawableDate
{
public DateLabel(DateTimeOffset date)
: base(date)
{
Font = OsuFont.Style.Caption1.With(weight: FontWeight.SemiBold);
}
protected override LocalisableString Format() => Date.ToShortRelativeTime(TimeSpan.FromSeconds(30));
}
private partial class RankLabel : Container, IHasTooltip
{
private readonly bool darkText;
private readonly OsuSpriteText text;
public RankLabel(int? rank, bool sheared, bool darkText)
{
this.darkText = darkText;
if (rank >= 1000)
TooltipText = $"#{rank:N0}";
Child = text = new OsuSpriteText
{
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.Style.Heading2,
Text = rank?.FormatRank().Insert(0, "#") ?? "-",
Shadow = !darkText,
};
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
text.Colour = darkText ? colourProvider.Background3 : colourProvider.Content1;
}
public LocalisableString TooltipText { get; }
}
public enum HighlightType
{
Own,
Friend,
}
}
}