1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-07 00:17:21 +08:00

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.9 KiB
C#
Raw Normal View History

2019-03-09 23:58:14 +01: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 00:24:42 +02:00
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
2019-03-09 23:58:14 +01:00
using osu.Game.Online.API;
using osu.Game.Online.Chat;
2021-07-17 15:18:45 +02:00
using osu.Game.Resources.Localisation.Web;
2019-03-09 23:58:14 +01:00
using osuTK;
2019-04-26 13:49:44 +09:00
namespace osu.Game.Overlays.Profile.Header.Components
2019-03-09 23:58:14 +01:00
{
2019-04-26 13:49:44 +09:00
public partial class MessageUserButton : ProfileHeaderButton
2019-03-09 23:58:14 +01:00
{
2023-01-10 19:24:54 +01:00
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
2019-03-09 23:58:14 +01:00
2021-07-17 15:18:45 +02:00
public override LocalisableString TooltipText => UsersStrings.CardSendMessage;
2019-04-26 13:29:58 +09:00
2022-12-30 13:17:59 +01:00
[Resolved]
private ChannelManager? channelManager { get; set; }
2019-03-09 23:58:14 +01:00
2022-12-30 13:17:59 +01:00
[Resolved]
private UserProfileOverlay? userOverlay { get; set; }
2019-03-09 23:58:14 +01:00
2022-12-30 13:17:59 +01:00
[Resolved]
private ChatOverlay? chatOverlay { get; set; }
2019-03-09 23:58:14 +01:00
[Resolved]
2022-12-30 13:17:59 +01:00
private IAPIProvider apiProvider { get; set; } = null!;
2019-03-09 23:58:14 +01:00
2019-04-26 13:49:44 +09:00
public MessageUserButton()
2019-03-09 23:58:14 +01:00
{
Content.Alpha = 0;
Child = new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
2019-04-04 00:24:42 +02:00
Icon = FontAwesome.Solid.Envelope,
2019-03-09 23:58:14 +01:00
FillMode = FillMode.Fit,
Size = new Vector2(50, 14)
};
Action = () =>
{
if (!Content.IsPresent) return;
2023-01-10 19:24:54 +01:00
channelManager?.OpenPrivateChannel(User.Value?.User);
2019-03-09 23:58:14 +01:00
userOverlay?.Hide();
chatOverlay?.Show();
};
2023-01-10 19:24:54 +01:00
User.ValueChanged += e =>
{
var user = e.NewValue?.User;
Content.Alpha = user != null && !user.PMFriendsOnly && apiProvider.LocalUser.Value.Id != user.Id ? 1 : 0;
};
2019-03-09 23:58:14 +01:00
}
}
}