|
| 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 osu.Framework.Allocation; |
| 5 | +using osu.Framework.Graphics; |
| 6 | +using osu.Framework.Graphics.Containers; |
| 7 | +using osu.Framework.Graphics.Shapes; |
| 8 | +using osu.Framework.Graphics.Sprites; |
| 9 | +using osu.Framework.Localisation; |
| 10 | +using osu.Game.Graphics; |
| 11 | +using osu.Game.Graphics.Containers; |
| 12 | +using osu.Game.Online.API; |
| 13 | +using osu.Game.Online.Chat; |
| 14 | +using osu.Game.Resources.Localisation.Web; |
| 15 | + |
| 16 | +namespace osu.Game.Overlays.Profile |
| 17 | +{ |
| 18 | + public partial class ProfileProcessingNotice : CompositeDrawable |
| 19 | + { |
| 20 | + private ILocalisedBindableString noticeText = null!; |
| 21 | + |
| 22 | + [BackgroundDependencyLoader] |
| 23 | + private void load(IAPIProvider? api, OverlayColourProvider colourProvider, OsuColour colours, LocalisationManager localisation) |
| 24 | + { |
| 25 | + if (string.IsNullOrEmpty(api?.ScoreProcessingNoticeUrl)) |
| 26 | + return; |
| 27 | + |
| 28 | + RelativeSizeAxes = Axes.X; |
| 29 | + AutoSizeAxes = Axes.Y; |
| 30 | + |
| 31 | + LinkFlowContainer flow; |
| 32 | + |
| 33 | + InternalChildren = new Drawable[] |
| 34 | + { |
| 35 | + new Box |
| 36 | + { |
| 37 | + RelativeSizeAxes = Axes.Both, |
| 38 | + Colour = colourProvider.Background5 |
| 39 | + }, |
| 40 | + new Container |
| 41 | + { |
| 42 | + RelativeSizeAxes = Axes.X, |
| 43 | + AutoSizeAxes = Axes.Y, |
| 44 | + Padding = new MarginPadding { Vertical = 10, Horizontal = 50 }, |
| 45 | + Children = new Drawable[] |
| 46 | + { |
| 47 | + new Container |
| 48 | + { |
| 49 | + RelativeSizeAxes = Axes.X, |
| 50 | + AutoSizeAxes = Axes.Y, |
| 51 | + CornerRadius = 5, |
| 52 | + Masking = true, |
| 53 | + Children = new Drawable[] |
| 54 | + { |
| 55 | + new Box |
| 56 | + { |
| 57 | + Colour = colourProvider.Background4, |
| 58 | + RelativeSizeAxes = Axes.Both, |
| 59 | + }, |
| 60 | + flow = new LinkFlowContainer(cp => |
| 61 | + { |
| 62 | + cp.Colour = colours.Orange1; |
| 63 | + cp.Font = OsuFont.Style.Body; |
| 64 | + }) |
| 65 | + { |
| 66 | + RelativeSizeAxes = Axes.X, |
| 67 | + AutoSizeAxes = Axes.Y, |
| 68 | + Padding = new MarginPadding(10), |
| 69 | + } |
| 70 | + } |
| 71 | + }, |
| 72 | + } |
| 73 | + }, |
| 74 | + }; |
| 75 | + |
| 76 | + var noticeLink = LocalisableString.Interpolate($@"[{UsersStrings.ShowScoreProcessingTitleLink}]({api.ScoreProcessingNoticeUrl})"); |
| 77 | + var noticeString = LocalisableString.Interpolate($@"{UsersStrings.ShowScoreProcessingTitle(noticeLink)} {UsersStrings.ShowScoreProcessingMessage}"); |
| 78 | + noticeText = localisation.GetLocalisedBindableString(noticeString); |
| 79 | + noticeText.BindValueChanged(t => |
| 80 | + { |
| 81 | + flow.Clear(); |
| 82 | + flow.AddIcon(FontAwesome.Solid.InfoCircle, cp => cp.Padding = new MarginPadding { Right = 5 }); |
| 83 | + var result = MessageFormatter.FormatText(t.NewValue); |
| 84 | + flow.AddLinks(result.Text, result.Links); |
| 85 | + }, true); |
| 86 | + } |
| 87 | + } |
| 88 | +} |
0 commit comments