mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Use a better method of link compilation
Adds word wrap back, simplifies a lot.
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user