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.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-03-10 06:58:14 +08:00
|
|
|
|
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;
|
2021-06-26 01:10:04 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2019-03-10 06:58:14 +08:00
|
|
|
|
using osu.Game.Online.API;
|
2021-11-04 17:02:44 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2019-03-10 06:58:14 +08:00
|
|
|
|
using osu.Game.Online.Chat;
|
2021-07-17 21:18:45 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-03-10 06:58:14 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
|
2019-04-26 12:49:44 +08:00
|
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
2019-03-10 06:58:14 +08:00
|
|
|
|
{
|
2019-04-26 12:49:44 +08:00
|
|
|
|
public class MessageUserButton : ProfileHeaderButton
|
2019-03-10 06:58:14 +08:00
|
|
|
|
{
|
2021-11-04 17:02:44 +08:00
|
|
|
|
public readonly Bindable<APIUser> User = new Bindable<APIUser>();
|
2019-03-10 06:58:14 +08:00
|
|
|
|
|
2021-07-17 21:18:45 +08:00
|
|
|
|
public override LocalisableString TooltipText => UsersStrings.CardSendMessage;
|
2019-04-26 12:29:58 +08:00
|
|
|
|
|
2019-03-10 06:58:14 +08:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
|
private ChannelManager channelManager { get; set; }
|
|
|
|
|
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
|
private UserProfileOverlay userOverlay { get; set; }
|
|
|
|
|
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
2022-05-30 16:54:09 +08:00
|
|
|
|
private ChatOverlay chatOverlay { get; set; }
|
2019-03-10 06:58:14 +08:00
|
|
|
|
|
|
|
|
|
[Resolved]
|
2019-04-04 06:24:42 +08:00
|
|
|
|
private IAPIProvider apiProvider { get; set; }
|
2019-03-10 06:58:14 +08:00
|
|
|
|
|
2019-04-26 12:49:44 +08:00
|
|
|
|
public MessageUserButton()
|
2019-03-10 06:58:14 +08:00
|
|
|
|
{
|
|
|
|
|
Content.Alpha = 0;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|