1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 08:42:56 +08:00
osu-lazer/osu.Game/Overlays/Profile/Header/ProfileMessageButton.cs

58 lines
1.7 KiB
C#
Raw Normal View History

2019-03-10 06:58:14 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
2019-04-04 06:24:42 +08:00
using osu.Framework.Graphics.Sprites;
2019-03-10 06:58:14 +08:00
using osu.Game.Online.API;
using osu.Game.Online.Chat;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Overlays.Profile.Header
{
public class ProfileMessageButton : ProfileHeaderButton
{
public readonly Bindable<User> User = new Bindable<User>();
[Resolved(CanBeNull = true)]
private ChannelManager channelManager { get; set; }
[Resolved(CanBeNull = true)]
private UserProfileOverlay userOverlay { get; set; }
[Resolved(CanBeNull = true)]
private ChatOverlay chatOverlay { get; set; }
[Resolved]
2019-04-04 06:24:42 +08:00
private IAPIProvider apiProvider { get; set; }
2019-03-10 06:58:14 +08:00
public ProfileMessageButton()
{
Content.Alpha = 0;
RelativeSizeAxes = Axes.Y;
Child = new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
2019-04-04 06:24:42 +08:00
Icon = FontAwesome.Solid.Envelope,
2019-03-10 06:58:14 +08:00
FillMode = FillMode.Fit,
Size = new Vector2(50, 14)
};
Action = () =>
{
if (!Content.IsPresent) return;
channelManager?.OpenPrivateChannel(User.Value);
userOverlay?.Hide();
chatOverlay?.Show();
};
2019-04-04 06:24:42 +08:00
User.ValueChanged += e => Content.Alpha = !e.NewValue.PMFriendsOnly && apiProvider.LocalUser.Value.Id != e.NewValue.Id ? 1 : 0;
2019-03-10 06:58:14 +08:00
}
}
}