From 6a76e335c726b5d4753d4fb250dc0b6e22073167 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 20 Dec 2018 20:03:39 +0900 Subject: [PATCH] Linkify everything --- .../Screens/Multi/Components/BeatmapTitle.cs | 56 ++++++++++++------- .../Multi/Components/BeatmapTypeInfo.cs | 26 +++++---- .../Multi/Lounge/Components/DrawableRoom.cs | 1 - .../Multi/Match/Components/HostInfo.cs | 2 +- 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs index 02ec598f82..67d414a080 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs @@ -6,36 +6,38 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Localisation; using osu.Game.Beatmaps; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Online.Chat; namespace osu.Game.Screens.Multi.Components { public class BeatmapTitle : CompositeDrawable { - private readonly OsuSpriteText beatmapTitle, beatmapDash, beatmapArtist; + private float textSize = OsuSpriteText.FONT_SIZE; public float TextSize { - set { beatmapTitle.TextSize = beatmapDash.TextSize = beatmapArtist.TextSize = value; } + get => textSize; + set + { + if (textSize == value) + return; + textSize = value; + + updateText(); + } } public readonly IBindable Beatmap = new Bindable(); + private readonly LinkFlowContainer textFlow; + public BeatmapTitle() { AutoSizeAxes = Axes.Both; - InternalChild = new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] - { - beatmapTitle = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", }, - beatmapDash = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", }, - beatmapArtist = new OsuSpriteText { Font = @"Exo2.0-RegularItalic", }, - } - }; + InternalChild = textFlow = new LinkFlowContainer { AutoSizeAxes = Axes.Both }; Beatmap.BindValueChanged(v => updateText()); } @@ -51,16 +53,30 @@ namespace osu.Game.Screens.Multi.Components if (!IsLoaded) return; + textFlow.Clear(); + if (Beatmap.Value == null) - { - beatmapTitle.Text = "Changing map"; - beatmapDash.Text = beatmapArtist.Text = string.Empty; - } + textFlow.AddText("Changing map", s => s.TextSize = TextSize); else { - beatmapTitle.Text = new LocalisedString((Beatmap.Value.Metadata.TitleUnicode, Beatmap.Value.Metadata.Title)); - beatmapDash.Text = @" - "; - beatmapArtist.Text = new LocalisedString((Beatmap.Value.Metadata.ArtistUnicode, Beatmap.Value.Metadata.Artist)); + textFlow.AddLink(new[] + { + new OsuSpriteText + { + Text = new LocalisedString((Beatmap.Value.Metadata.ArtistUnicode, Beatmap.Value.Metadata.Artist)), + TextSize = TextSize, + }, + new OsuSpriteText + { + Text = " - ", + TextSize = TextSize, + }, + new OsuSpriteText + { + Text = new LocalisedString((Beatmap.Value.Metadata.TitleUnicode, Beatmap.Value.Metadata.Title)), + TextSize = TextSize, + } + }, null, LinkAction.OpenBeatmap, Beatmap.Value.OnlineBeatmapID.ToString(), "Open beatmap"); } } } diff --git a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs index 90319de40f..a06eaa35dc 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs @@ -1,13 +1,13 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.Containers; +using osu.Game.Online.Chat; using osu.Game.Online.Multiplayer; using osuTK; @@ -15,8 +15,6 @@ namespace osu.Game.Screens.Multi.Components { public class BeatmapTypeInfo : CompositeDrawable { - private readonly OsuSpriteText beatmapAuthor; - public readonly IBindable Beatmap = new Bindable(); public readonly IBindable Type = new Bindable(); @@ -27,6 +25,7 @@ namespace osu.Game.Screens.Multi.Components BeatmapTitle beatmapTitle; ModeTypeInfo modeTypeInfo; + LinkFlowContainer beatmapAuthor; InternalChild = new FillFlowContainer { @@ -45,11 +44,11 @@ namespace osu.Game.Screens.Multi.Components Children = new Drawable[] { beatmapTitle = new BeatmapTitle(), - beatmapAuthor = new OsuSpriteText + beatmapAuthor = new LinkFlowContainer(s => s.TextSize = 14) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - TextSize = 14, + AutoSizeAxes = Axes.Both }, }, }, @@ -61,13 +60,16 @@ namespace osu.Game.Screens.Multi.Components beatmapTitle.Beatmap.BindTo(Beatmap); - Beatmap.BindValueChanged(v => beatmapAuthor.Text = v == null ? string.Empty : $"mapped by {v.Metadata.Author}"); - } + Beatmap.BindValueChanged(v => + { + beatmapAuthor.Clear(); - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - beatmapAuthor.Colour = colours.GrayC; + if (v != null) + { + beatmapAuthor.AddText("mapped by ", s => s.Colour = OsuColour.Gray(0.8f)); + beatmapAuthor.AddLink(v.Metadata.Author.Username, null, LinkAction.OpenUserProfile, v.Metadata.Author.Id.ToString(), "View Profile"); + } + }); } } } diff --git a/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs index c1a9dd3b1d..f4e304d0a8 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs @@ -205,7 +205,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components beatmapTitle = new BeatmapTitle { TextSize = 14, - Colour = colours.Gray9 }, } } diff --git a/osu.Game/Screens/Multi/Match/Components/HostInfo.cs b/osu.Game/Screens/Multi/Match/Components/HostInfo.cs index 830d720bd4..883f88b056 100644 --- a/osu.Game/Screens/Multi/Match/Components/HostInfo.cs +++ b/osu.Game/Screens/Multi/Match/Components/HostInfo.cs @@ -45,7 +45,7 @@ namespace osu.Game.Screens.Multi.Match.Components linkContainer.AddText("hosted by"); linkContainer.NewLine(); - linkContainer.AddLink(room.Host.Value.Username,null, LinkAction.OpenUserProfile, room.Host.Value.Id.ToString(), "Open profile", s => s.Font = "Exo2.0-BoldItalic"); + linkContainer.AddLink(room.Host.Value.Username, null, LinkAction.OpenUserProfile, room.Host.Value.Id.ToString(), "View Profile", s => s.Font = "Exo2.0-BoldItalic"); } } }