2018-04-12 02:31:16 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-04-12 00:23:09 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Game.Online.Chat;
|
|
|
|
|
using osu.Game.Overlays.Chat;
|
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
|
|
|
|
public class TestCaseChatTabControl : OsuTestCase
|
|
|
|
|
{
|
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(ChatTabControl),
|
|
|
|
|
typeof(ChannelTabControl),
|
|
|
|
|
typeof(UserTabControl),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private readonly ChatTabControl chatTabControl;
|
|
|
|
|
private readonly SpriteText currentText;
|
|
|
|
|
|
|
|
|
|
public TestCaseChatTabControl()
|
|
|
|
|
{
|
|
|
|
|
Add(new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
chatTabControl = new ChatTabControl
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Height = 50
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0.1f),
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 50,
|
|
|
|
|
Depth = -1,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Add(new Container()
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
currentText = new SpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = "Currently selected chat: "
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
chatTabControl.OnRequestLeave += chat => chatTabControl.RemoveItem(chat);
|
|
|
|
|
chatTabControl.Current.ValueChanged += chat => currentText.Text = "Currently selected chat: " + chat.ToString();
|
|
|
|
|
|
|
|
|
|
AddStep("Add random user", () => addUser(RNG.Next(100000), RNG.Next().ToString()));
|
|
|
|
|
AddRepeatStep("3 random users", () => addUser(RNG.Next(100000), RNG.Next().ToString()), 3);
|
|
|
|
|
AddStep("Add random channel", () => addChannel(RNG.Next().ToString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addUser(long id, string name)
|
|
|
|
|
{
|
2018-04-12 02:01:57 +08:00
|
|
|
|
chatTabControl.AddItem(new Channel(new User
|
2018-04-12 00:23:09 +08:00
|
|
|
|
{
|
|
|
|
|
Id = id,
|
|
|
|
|
Username = name
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addChannel(string name)
|
|
|
|
|
{
|
2018-04-12 02:01:57 +08:00
|
|
|
|
this.chatTabControl.AddItem(new Channel
|
2018-04-12 00:23:09 +08:00
|
|
|
|
{
|
|
|
|
|
Name = name
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|