Add ability to send pm via context menu

This commit is contained in:
Andrei Zavatski 2020-03-04 12:42:21 +03:00
parent 15e47d8432
commit 8a437e1b54
2 changed files with 70 additions and 54 deletions

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterfaceV2.Users; using osu.Game.Graphics.UserInterfaceV2.Users;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Users; using osu.Game.Users;
@ -27,62 +28,66 @@ namespace osu.Game.Tests.Visual.UserInterface
public TestSceneUserCard() public TestSceneUserCard()
{ {
Add(new FillFlowContainer Add(new OsuContextMenuContainer
{ {
Anchor = Anchor.Centre, RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre, Child = new FillFlowContainer
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Spacing = new Vector2(0, 10),
Children = new Drawable[]
{ {
new FillFlowContainer Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Spacing = new Vector2(0, 10),
Children = new Drawable[]
{ {
AutoSizeAxes = Axes.Both, new FillFlowContainer
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10),
Children = new Drawable[]
{ {
new UserGridCard(new User AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10),
Children = new Drawable[]
{ {
Username = @"flyte", new UserGridCard(new User
Id = 3103765, {
Country = new Country { FlagName = @"JP" }, Username = @"flyte",
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg", Id = 3103765,
IsOnline = true, Country = new Country { FlagName = @"JP" },
IsSupporter = true, CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg",
SupportLevel = 3, IsOnline = true,
}), IsSupporter = true,
new UserGridCard(new User SupportLevel = 3,
{ }),
Username = @"Evast", new UserGridCard(new User
Id = 8195163, {
Country = new Country { FlagName = @"BY" }, Username = @"Evast",
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg", Id = 8195163,
IsOnline = false, Country = new Country { FlagName = @"BY" },
LastVisit = DateTimeOffset.Now CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
}) IsOnline = false,
} LastVisit = DateTimeOffset.Now
}, })
new UserListCard(new User }
{ },
Username = @"peppy", new UserListCard(new User
Id = 2, {
Country = new Country { FlagName = @"AU" }, Username = @"peppy",
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", Id = 2,
IsSupporter = true, Country = new Country { FlagName = @"AU" },
SupportLevel = 3, CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
IsOnline = false, IsSupporter = true,
LastVisit = DateTimeOffset.Now SupportLevel = 3,
}), IsOnline = false,
new UserListCard(new User LastVisit = DateTimeOffset.Now
{ }),
Username = @"chocomint", new UserListCard(new User
Id = 124493, {
Country = new Country { FlagName = @"KR" }, Username = @"chocomint",
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c5.jpg", Id = 124493,
IsOnline = true, Country = new Country { FlagName = @"KR" },
}), CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c5.jpg",
IsOnline = true,
}),
}
} }
}); });
} }

View File

@ -18,9 +18,9 @@ using JetBrains.Annotations;
using osu.Game.Users.Drawables; using osu.Game.Users.Drawables;
using osuTK; using osuTK;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Profile.Header.Components;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Game.Online.Chat;
namespace osu.Game.Graphics.UserInterfaceV2.Users namespace osu.Game.Graphics.UserInterfaceV2.Users
{ {
@ -32,7 +32,7 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
protected DelayedLoadUnloadWrapper Background; protected DelayedLoadUnloadWrapper Background;
public UserCard(User user) protected UserCard(User user)
{ {
if (user == null) if (user == null)
throw new ArgumentNullException(nameof(user)); throw new ArgumentNullException(nameof(user));
@ -43,6 +43,12 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private UserProfileOverlay profileOverlay { get; set; } private UserProfileOverlay profileOverlay { get; set; }
[Resolved(canBeNull: true)]
private ChannelManager channelManager { get; set; }
[Resolved(canBeNull: true)]
private ChatOverlay chatOverlay { get; set; }
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; }
@ -54,7 +60,7 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
Masking = true; Masking = true;
BorderColour = colours.GreyVioletLighter; BorderColour = colours.GreyVioletLighter;
AddRange(new Drawable[] AddRange(new[]
{ {
new Box new Box
{ {
@ -152,6 +158,11 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
public MenuItem[] ContextMenuItems => new MenuItem[] public MenuItem[] ContextMenuItems => new MenuItem[]
{ {
new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action), new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action),
new OsuMenuItem("Send message", MenuItemType.Standard, () =>
{
channelManager?.OpenPrivateChannel(User);
chatOverlay?.Show();
})
}; };
} }
} }