Remove usage of ValueTuple to allow for dynamic recompilation

This commit is contained in:
Dean Herbert 2018-01-29 17:45:23 +09:00
parent 2b14438fe4
commit df221b6786
2 changed files with 34 additions and 10 deletions

View File

@ -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<Type> RequiredTypes => new[]
{
typeof(ChatLine),
typeof(Message),
typeof(LinkFlowContainer),
typeof(DummyEchoMessage),
typeof(LocalEchoMessage),
typeof(MessageFormatter)
};
public TestCaseChatLink()
{
Add(textContainer = new TestChatLineContainer

View File

@ -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