Use a better method of link compilation

Adds word wrap back, simplifies a lot.
This commit is contained in:
Dean Herbert
2018-01-09 20:22:23 +09:00
parent 1be0569743
commit 72624aea18
11 changed files with 172 additions and 269 deletions

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays;
@ -11,28 +10,12 @@ namespace osu.Game.Tests.Visual
[Description("Testing chat api and overlay")]
public class TestCaseChatDisplay : OsuTestCase
{
private readonly BeatmapSetOverlay beatmapSetOverlay;
private readonly ChatOverlay chat;
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
public TestCaseChatDisplay()
{
Add(chat = new ChatOverlay
Add(new ChatOverlay
{
State = Visibility.Visible
});
Add(beatmapSetOverlay = new BeatmapSetOverlay());
}
[BackgroundDependencyLoader]
private void load()
{
dependencies.Cache(chat);
dependencies.Cache(beatmapSetOverlay);
}
}
}

View File

@ -14,6 +14,7 @@ using osu.Game.Overlays.Chat;
using osu.Game.Users;
using System;
using System.Linq;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Tests.Visual
{
@ -57,7 +58,7 @@ namespace osu.Game.Tests.Visual
AddAssert($"msg #{textContainer.Count} is " + (isAction ? "italic" : "not italic"), () => newLine.ContentFlow.Any() && isAction == isItalic(newLine.ContentFlow));
AddAssert($"msg #{textContainer.Count} shows link(s)", isShowingLinks);
bool isItalic(ChatFlowContainer c) => c.Cast<ChatLink>().All(sprite => sprite.Font == @"Exo2.0-MediumItalic");
bool isItalic(LinkFlowContainer c) => c.Cast<OsuSpriteText>().All(sprite => sprite.Font == @"Exo2.0-MediumItalic");
bool isShowingLinks()
{
@ -68,11 +69,11 @@ namespace osu.Game.Tests.Visual
textColour = OsuColour.FromHex(newLine.Message.Sender.Colour);
return newLine.ContentFlow
.Cast<ChatLink>()
.All(sprite => sprite.HandleInput && !sprite.TextColour.Equals(textColour)
|| !sprite.HandleInput && sprite.TextColour.Equals(textColour)
.Cast<OsuSpriteText>()
.All(sprite => sprite.HandleInput && !sprite.Colour.Equals(textColour)
|| !sprite.HandleInput && sprite.Colour.Equals(textColour)
// if someone with a background uses /me with a link, the usual link colour is overridden
|| isAction && hasBackground && sprite.HandleInput && !sprite.TextColour.Equals((ColourInfo)Color4.White));
|| isAction && hasBackground && sprite.HandleInput && !sprite.Colour.Equals((ColourInfo)Color4.White));
}
}