mirror of
https://github.com/ppy/osu.git
synced 2025-03-11 01:07:23 +08:00
Merge pull request #32079 from bdach/team-chat-channels
Add support for team chat channels
This commit is contained in:
commit
fa02d734da
@ -115,6 +115,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
channelList.AddChannel(createRandomPrivateChannel());
|
||||
});
|
||||
|
||||
AddStep("Add Team Channel", () => channelList.AddChannel(createRandomTeamChannel()));
|
||||
|
||||
AddStep("Add Announce Channels", () =>
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
@ -189,5 +191,16 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Id = id,
|
||||
};
|
||||
}
|
||||
|
||||
private Channel createRandomTeamChannel()
|
||||
{
|
||||
int id = TestResources.GetNextTestID();
|
||||
return new Channel
|
||||
{
|
||||
Name = $"Team {id}",
|
||||
Type = ChannelType.Team,
|
||||
Id = id,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,6 @@ namespace osu.Game.Online.Chat
|
||||
Group,
|
||||
System,
|
||||
Announce,
|
||||
Team,
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Testing;
|
||||
@ -39,6 +40,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
|
||||
public ChannelGroup AnnounceChannelGroup { get; private set; } = null!;
|
||||
public ChannelGroup PublicChannelGroup { get; private set; } = null!;
|
||||
public ChannelGroup TeamChannelGroup { get; private set; } = null!;
|
||||
public ChannelGroup PrivateChannelGroup { get; private set; } = null!;
|
||||
|
||||
private OsuScrollContainer scroll = null!;
|
||||
@ -79,10 +81,12 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
RelativeSizeAxes = Axes.X,
|
||||
}
|
||||
},
|
||||
AnnounceChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitleANNOUNCE.ToUpper(), false),
|
||||
PublicChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitlePUBLIC.ToUpper(), false),
|
||||
// cross-reference for icons: https://github.com/ppy/osu-web/blob/3c9e99eaf4bd9e73d2712f60d67f5bc95f9dfe2b/resources/js/chat/conversation-list.tsx#L13-L19
|
||||
AnnounceChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitleANNOUNCE.ToUpper(), FontAwesome.Solid.Bullhorn, false),
|
||||
PublicChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitlePUBLIC.ToUpper(), FontAwesome.Solid.Comments, false),
|
||||
selector = new ChannelListItem(ChannelListingChannel),
|
||||
PrivateChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitlePM.ToUpper(), true),
|
||||
TeamChannelGroup = new ChannelGroup("TEAM", FontAwesome.Solid.Users, false), // TODO: replace with osu-web localisable string once available
|
||||
PrivateChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitlePM.ToUpper(), FontAwesome.Solid.Envelope, true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -102,6 +106,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
};
|
||||
|
||||
selector.OnRequestSelect += chan => OnRequestSelect?.Invoke(chan);
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
public void AddChannel(Channel channel)
|
||||
@ -109,8 +114,12 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
if (channelMap.ContainsKey(channel))
|
||||
return;
|
||||
|
||||
ChannelListItem item = new ChannelListItem(channel);
|
||||
ChannelListItem item = new ChannelListItem(channel)
|
||||
{
|
||||
CanLeave = channel.Type != ChannelType.Team
|
||||
};
|
||||
item.OnRequestSelect += chan => OnRequestSelect?.Invoke(chan);
|
||||
if (item.CanLeave)
|
||||
item.OnRequestLeave += chan => OnRequestLeave?.Invoke(chan);
|
||||
|
||||
ChannelGroup group = getGroupFromChannel(channel);
|
||||
@ -156,6 +165,9 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
case ChannelType.Announce:
|
||||
return AnnounceChannelGroup;
|
||||
|
||||
case ChannelType.Team:
|
||||
return TeamChannelGroup;
|
||||
|
||||
default:
|
||||
return PublicChannelGroup;
|
||||
}
|
||||
@ -163,10 +175,8 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
|
||||
private void updateVisibility()
|
||||
{
|
||||
if (AnnounceChannelGroup.ItemFlow.Children.Count == 0)
|
||||
AnnounceChannelGroup.Hide();
|
||||
else
|
||||
AnnounceChannelGroup.Show();
|
||||
AnnounceChannelGroup.Alpha = AnnounceChannelGroup.ItemFlow.Any() ? 1 : 0;
|
||||
TeamChannelGroup.Alpha = TeamChannelGroup.ItemFlow.Any() ? 1 : 0;
|
||||
}
|
||||
|
||||
public partial class ChannelGroup : FillFlowContainer
|
||||
@ -174,7 +184,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
private readonly bool sortByRecent;
|
||||
public readonly ChannelListItemFlow ItemFlow;
|
||||
|
||||
public ChannelGroup(LocalisableString label, bool sortByRecent)
|
||||
public ChannelGroup(LocalisableString label, IconUsage icon, bool sortByRecent)
|
||||
{
|
||||
this.sortByRecent = sortByRecent;
|
||||
Direction = FillDirection.Vertical;
|
||||
@ -182,6 +192,14 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Padding = new MarginPadding { Top = 8 };
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
@ -190,6 +208,13 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
Margin = new MarginPadding { Left = 18, Bottom = 5 },
|
||||
Font = OsuFont.Torus.With(size: 12, weight: FontWeight.SemiBold),
|
||||
},
|
||||
new SpriteIcon
|
||||
{
|
||||
Icon = icon,
|
||||
Size = new Vector2(12),
|
||||
},
|
||||
}
|
||||
},
|
||||
ItemFlow = new ChannelListItemFlow(sortByRecent)
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
|
@ -24,6 +24,8 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
public partial class ChannelListItem : OsuClickableContainer, IFilterable
|
||||
{
|
||||
public event Action<Channel>? OnRequestSelect;
|
||||
|
||||
public bool CanLeave { get; init; } = true;
|
||||
public event Action<Channel>? OnRequestLeave;
|
||||
|
||||
public readonly Channel Channel;
|
||||
@ -160,7 +162,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
|
||||
private ChannelListItemCloseButton? createCloseButton()
|
||||
{
|
||||
if (isSelector)
|
||||
if (isSelector || !CanLeave)
|
||||
return null;
|
||||
|
||||
return new ChannelListItemCloseButton
|
||||
|
Loading…
x
Reference in New Issue
Block a user