From df221b6786f04df96b57d35b0910b9ebfaa83309 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 Jan 2018 17:45:23 +0900 Subject: [PATCH] Remove usage of ValueTuple to allow for dynamic recompilation --- osu.Game.Tests/Visual/TestCaseChatLink.cs | 12 +++++++++ osu.Game/Online/Chat/MessageFormatter.cs | 32 ++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseChatLink.cs b/osu.Game.Tests/Visual/TestCaseChatLink.cs index 722e3c30f3..136a2fae89 100644 --- a/osu.Game.Tests/Visual/TestCaseChatLink.cs +++ b/osu.Game.Tests/Visual/TestCaseChatLink.cs @@ -10,7 +10,9 @@ using osu.Game.Online.Chat; using osu.Game.Overlays.Chat; using osu.Game.Users; using System; +using System.Collections.Generic; using System.Linq; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; namespace osu.Game.Tests.Visual @@ -20,6 +22,16 @@ namespace osu.Game.Tests.Visual private readonly TestChatLineContainer textContainer; private Color4 linkColour; + public override IReadOnlyList RequiredTypes => new[] + { + typeof(ChatLine), + typeof(Message), + typeof(LinkFlowContainer), + typeof(DummyEchoMessage), + typeof(LocalEchoMessage), + typeof(MessageFormatter) + }; + public TestCaseChatLink() { Add(textContainer = new TestChatLineContainer diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs index 3a396a04c0..2c15f48f95 100644 --- a/osu.Game/Online/Chat/MessageFormatter.cs +++ b/osu.Game/Online/Chat/MessageFormatter.cs @@ -67,7 +67,7 @@ namespace osu.Game.Online.Chat result.Links.ForEach(l => l.Index -= l.Index > index ? m.Length - displayText.Length : 0); var details = getLinkDetails(linkText); - result.Links.Add(new Link(linkText, index, displayText.Length, linkActionOverride ?? details.linkType, details.linkArgument)); + result.Links.Add(new Link(linkText, index, displayText.Length, linkActionOverride ?? details.Action, details.Argument)); //adjust the offset for processing the current matches group. captureOffset += m.Length - displayText.Length; @@ -95,11 +95,11 @@ namespace osu.Game.Online.Chat } var details = getLinkDetails(link); - result.Links.Add(new Link(link, index, indexLength, details.linkType, details.linkArgument)); + result.Links.Add(new Link(link, index, indexLength, details.Action, details.Argument)); } } - private static (LinkAction linkType, string linkArgument) getLinkDetails(string url) + private static LinkDetails getLinkDetails(string url) { var args = url.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); args[0] = args[0].TrimEnd(':'); @@ -115,19 +115,19 @@ namespace osu.Game.Online.Chat { case "b": case "beatmaps": - return (LinkAction.OpenBeatmap, args[3]); + return new LinkDetails(LinkAction.OpenBeatmap, args[3]); case "s": case "beatmapsets": case "d": - return (LinkAction.OpenBeatmapSet, args[3]); + return new LinkDetails(LinkAction.OpenBeatmapSet, args[3]); } } - return (LinkAction.External, null); + return new LinkDetails(LinkAction.External, null); case "osu": // every internal link also needs some kind of argument if (args.Length < 3) - return (LinkAction.External, null); + return new LinkDetails(LinkAction.External, null); LinkAction linkType; switch (args[1]) @@ -153,11 +153,11 @@ namespace osu.Game.Online.Chat break; } - return (linkType, args[2]); + return new LinkDetails(linkType, args[2]); case "osump": - return (LinkAction.JoinMultiplayerMatch, args[1]); + return new LinkDetails(LinkAction.JoinMultiplayerMatch, args[1]); default: - return (LinkAction.External, null); + return new LinkDetails(LinkAction.External, null); } } @@ -215,6 +215,18 @@ namespace osu.Game.Online.Chat OriginalText = Text = text; } } + + public class LinkDetails + { + public LinkAction Action; + public string Argument; + + public LinkDetails(LinkAction action, string argument) + { + Action = action; + Argument = argument; + } + } } public enum LinkAction