From 3f336b8e61aad47b03bedeaef7045a2166fc8f48 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Sun, 3 Dec 2017 21:02:05 +0100 Subject: [PATCH] Made the style a bit better, fixed a bug or two --- osu.Game/Graphics/Sprites/OsuLinkSpriteText.cs | 9 +++++---- osu.Game/Overlays/Chat/ChatLine.cs | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Sprites/OsuLinkSpriteText.cs b/osu.Game/Graphics/Sprites/OsuLinkSpriteText.cs index 2105008ef3..080f1c1f83 100644 --- a/osu.Game/Graphics/Sprites/OsuLinkSpriteText.cs +++ b/osu.Game/Graphics/Sprites/OsuLinkSpriteText.cs @@ -81,17 +81,18 @@ namespace osu.Game.Graphics.Sprites if (firstPath == "chan/") { var nextSlashIndex = url.IndexOf('/'); - var channelName = url.Substring(0, nextSlashIndex != -1 ? nextSlashIndex - 1 : url.Length - 1); + var channelName = nextSlashIndex != -1 ? url.Remove(nextSlashIndex) : url; var foundChannel = chat.AvailableChannels.Find(channel => channel.Name == channelName); if (foundChannel != null) - chat.OpenChannel(foundChannel); + content.Action = () => chat.OpenChannel(foundChannel); } else if (firstPath == "edit/") { // Open editor here, then goto specified time // how to push new screen from here? we'll see + content.Action = () => new Framework.Screens.Screen().Push(new Screens.Edit.Editor()); } else throw new ArgumentException($"Unknown osu:// link at {nameof(OsuLinkSpriteText)} ({firstPath})."); @@ -121,14 +122,14 @@ namespace osu.Game.Graphics.Sprites // Remove possible trailing slash if (lastSlashIndex == url.Length) { - url = url.Substring(0, url.Length - 1); + url = url.Remove(url.Length - 1); lastSlashIndex = url.LastIndexOf('/'); } var lastQuestionMarkIndex = url.LastIndexOf('?'); // Filter out possible queries like mode specifications (e.g. /b/252238?m=0) if (lastQuestionMarkIndex > lastSlashIndex) - url = url.Substring(0, lastQuestionMarkIndex); + url = url.Remove(lastQuestionMarkIndex); return int.Parse(url.Substring(lastSlashIndex + 1)); } diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index bf5855c45b..fda23ca679 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -236,6 +236,8 @@ namespace osu.Game.Overlays.Chat { if (message.IsAction) sprite.Font = @"Exo2.0-MediumItalic"; + + // TODO: Somehow check (if channel link) that this is a real channel sprite.Colour = urlColour; // We want to use something that is unique to every formatted link, so I just use the position of the link ((ChatLinkSpriteText)sprite).LinkId = link.Index;