mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:42:55 +08:00
Merge pull request #18442 from jai-x/new-chat-announce-channel
Display Announce type channels separately in new chat overlay
This commit is contained in:
commit
9e678101cf
@ -87,7 +87,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
leaveText.Text = $"OnRequestLeave: {channel.Name}";
|
leaveText.Text = $"OnRequestLeave: {channel.Name}";
|
||||||
leaveText.FadeOutFromOne(1000, Easing.InQuint);
|
leaveText.FadeOutFromOne(1000, Easing.InQuint);
|
||||||
selected.Value = null;
|
selected.Value = channelList.ChannelListingChannel;
|
||||||
channelList.RemoveChannel(channel);
|
channelList.RemoveChannel(channel);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -112,6 +112,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
channelList.AddChannel(createRandomPrivateChannel());
|
channelList.AddChannel(createRandomPrivateChannel());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddStep("Add Announce Channels", () =>
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
channelList.AddChannel(createRandomAnnounceChannel());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -170,5 +176,16 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Username = $"test user {id}",
|
Username = $"test user {id}",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Channel createRandomAnnounceChannel()
|
||||||
|
{
|
||||||
|
int id = RNG.Next(0, 10000);
|
||||||
|
return new Channel
|
||||||
|
{
|
||||||
|
Name = $"Announce {id}",
|
||||||
|
Type = ChannelType.Announce,
|
||||||
|
Id = id,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,6 +455,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestKeyboardNextChannel()
|
public void TestKeyboardNextChannel()
|
||||||
{
|
{
|
||||||
|
Channel announceChannel = createAnnounceChannel();
|
||||||
Channel pmChannel1 = createPrivateChannel();
|
Channel pmChannel1 = createPrivateChannel();
|
||||||
Channel pmChannel2 = createPrivateChannel();
|
Channel pmChannel2 = createPrivateChannel();
|
||||||
|
|
||||||
@ -464,6 +465,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
channelManager.JoinChannel(testChannel2);
|
channelManager.JoinChannel(testChannel2);
|
||||||
channelManager.JoinChannel(pmChannel1);
|
channelManager.JoinChannel(pmChannel1);
|
||||||
channelManager.JoinChannel(pmChannel2);
|
channelManager.JoinChannel(pmChannel2);
|
||||||
|
channelManager.JoinChannel(announceChannel);
|
||||||
chatOverlay.Show();
|
chatOverlay.Show();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -477,6 +479,9 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
|
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
|
||||||
AddUntilStep("PM Channel 2 displayed", () => channelIsVisible && currentDrawableChannel?.Channel == pmChannel2);
|
AddUntilStep("PM Channel 2 displayed", () => channelIsVisible && currentDrawableChannel?.Channel == pmChannel2);
|
||||||
|
|
||||||
|
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
|
||||||
|
AddUntilStep("Announce channel displayed", () => channelIsVisible && currentDrawableChannel?.Channel == announceChannel);
|
||||||
|
|
||||||
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
|
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
|
||||||
waitForChannel1Visible();
|
waitForChannel1Visible();
|
||||||
}
|
}
|
||||||
@ -548,6 +553,17 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Channel createAnnounceChannel()
|
||||||
|
{
|
||||||
|
int id = RNG.Next(0, 10000);
|
||||||
|
return new Channel
|
||||||
|
{
|
||||||
|
Name = $"Announce {id}",
|
||||||
|
Type = ChannelType.Announce,
|
||||||
|
Id = id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private class TestChatOverlayV2 : ChatOverlayV2
|
private class TestChatOverlayV2 : ChatOverlayV2
|
||||||
{
|
{
|
||||||
public bool SlowLoading { get; set; }
|
public bool SlowLoading { get; set; }
|
||||||
|
@ -26,15 +26,20 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
public Action<Channel>? OnRequestSelect;
|
public Action<Channel>? OnRequestSelect;
|
||||||
public Action<Channel>? OnRequestLeave;
|
public Action<Channel>? OnRequestLeave;
|
||||||
|
|
||||||
public IEnumerable<Channel> Channels => publicChannelFlow.Channels.Concat(privateChannelFlow.Channels);
|
public IEnumerable<Channel> Channels => groupFlow.Children
|
||||||
|
.OfType<ChannelGroup>()
|
||||||
|
.SelectMany(channelGroup => channelGroup.ItemFlow)
|
||||||
|
.Select(item => item.Channel);
|
||||||
|
|
||||||
public readonly ChannelListing.ChannelListingChannel ChannelListingChannel = new ChannelListing.ChannelListingChannel();
|
public readonly ChannelListing.ChannelListingChannel ChannelListingChannel = new ChannelListing.ChannelListingChannel();
|
||||||
|
|
||||||
private readonly Dictionary<Channel, ChannelListItem> channelMap = new Dictionary<Channel, ChannelListItem>();
|
private readonly Dictionary<Channel, ChannelListItem> channelMap = new Dictionary<Channel, ChannelListItem>();
|
||||||
|
|
||||||
private OsuScrollContainer scroll = null!;
|
private OsuScrollContainer scroll = null!;
|
||||||
private ChannelListItemFlow publicChannelFlow = null!;
|
private FillFlowContainer groupFlow = null!;
|
||||||
private ChannelListItemFlow privateChannelFlow = null!;
|
private ChannelGroup announceChannelGroup = null!;
|
||||||
|
private ChannelGroup publicChannelGroup = null!;
|
||||||
|
private ChannelGroup privateChannelGroup = null!;
|
||||||
private ChannelListItem selector = null!;
|
private ChannelListItem selector = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -49,25 +54,20 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
},
|
},
|
||||||
scroll = new OsuScrollContainer
|
scroll = new OsuScrollContainer
|
||||||
{
|
{
|
||||||
Padding = new MarginPadding { Vertical = 7 },
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ScrollbarAnchor = Anchor.TopRight,
|
ScrollbarAnchor = Anchor.TopRight,
|
||||||
ScrollDistance = 35f,
|
ScrollDistance = 35f,
|
||||||
Child = new FillFlowContainer
|
Child = groupFlow = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new ChannelListLabel(ChatStrings.ChannelsListTitlePUBLIC.ToUpper()),
|
announceChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitleANNOUNCE.ToUpper()),
|
||||||
publicChannelFlow = new ChannelListItemFlow(),
|
publicChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitlePUBLIC.ToUpper()),
|
||||||
selector = new ChannelListItem(ChannelListingChannel)
|
selector = new ChannelListItem(ChannelListingChannel),
|
||||||
{
|
privateChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitlePM.ToUpper()),
|
||||||
Margin = new MarginPadding { Bottom = 10 },
|
|
||||||
},
|
|
||||||
new ChannelListLabel(ChatStrings.ChannelsListTitlePM.ToUpper()),
|
|
||||||
privateChannelFlow = new ChannelListItemFlow(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -85,9 +85,11 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
item.OnRequestSelect += chan => OnRequestSelect?.Invoke(chan);
|
item.OnRequestSelect += chan => OnRequestSelect?.Invoke(chan);
|
||||||
item.OnRequestLeave += chan => OnRequestLeave?.Invoke(chan);
|
item.OnRequestLeave += chan => OnRequestLeave?.Invoke(chan);
|
||||||
|
|
||||||
ChannelListItemFlow flow = getFlowForChannel(channel);
|
FillFlowContainer<ChannelListItem> flow = getFlowForChannel(channel);
|
||||||
channelMap.Add(channel, item);
|
channelMap.Add(channel, item);
|
||||||
flow.Add(item);
|
flow.Add(item);
|
||||||
|
|
||||||
|
updateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveChannel(Channel channel)
|
public void RemoveChannel(Channel channel)
|
||||||
@ -96,10 +98,12 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ChannelListItem item = channelMap[channel];
|
ChannelListItem item = channelMap[channel];
|
||||||
ChannelListItemFlow flow = getFlowForChannel(channel);
|
FillFlowContainer<ChannelListItem> flow = getFlowForChannel(channel);
|
||||||
|
|
||||||
channelMap.Remove(channel);
|
channelMap.Remove(channel);
|
||||||
flow.Remove(item);
|
flow.Remove(item);
|
||||||
|
|
||||||
|
updateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChannelListItem GetItem(Channel channel)
|
public ChannelListItem GetItem(Channel channel)
|
||||||
@ -112,40 +116,58 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
|
|
||||||
public void ScrollChannelIntoView(Channel channel) => scroll.ScrollIntoView(GetItem(channel));
|
public void ScrollChannelIntoView(Channel channel) => scroll.ScrollIntoView(GetItem(channel));
|
||||||
|
|
||||||
private ChannelListItemFlow getFlowForChannel(Channel channel)
|
private FillFlowContainer<ChannelListItem> getFlowForChannel(Channel channel)
|
||||||
{
|
{
|
||||||
switch (channel.Type)
|
switch (channel.Type)
|
||||||
{
|
{
|
||||||
case ChannelType.Public:
|
case ChannelType.Public:
|
||||||
return publicChannelFlow;
|
return publicChannelGroup.ItemFlow;
|
||||||
|
|
||||||
case ChannelType.PM:
|
case ChannelType.PM:
|
||||||
return privateChannelFlow;
|
return privateChannelGroup.ItemFlow;
|
||||||
|
|
||||||
|
case ChannelType.Announce:
|
||||||
|
return announceChannelGroup.ItemFlow;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return publicChannelFlow;
|
return publicChannelGroup.ItemFlow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChannelListLabel : OsuSpriteText
|
private void updateVisibility()
|
||||||
{
|
{
|
||||||
public ChannelListLabel(LocalisableString label)
|
if (announceChannelGroup.ItemFlow.Children.Count == 0)
|
||||||
{
|
announceChannelGroup.Hide();
|
||||||
Text = label;
|
else
|
||||||
Margin = new MarginPadding { Left = 18, Bottom = 5 };
|
announceChannelGroup.Show();
|
||||||
Font = OsuFont.Torus.With(size: 12, weight: FontWeight.SemiBold);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChannelListItemFlow : FillFlowContainer<ChannelListItem>
|
private class ChannelGroup : FillFlowContainer
|
||||||
{
|
{
|
||||||
public IEnumerable<Channel> Channels => Children.Select(c => c.Channel);
|
public readonly FillFlowContainer<ChannelListItem> ItemFlow;
|
||||||
|
|
||||||
public ChannelListItemFlow()
|
public ChannelGroup(LocalisableString label)
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Vertical;
|
Direction = FillDirection.Vertical;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
Padding = new MarginPadding { Top = 8 };
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = label,
|
||||||
|
Margin = new MarginPadding { Left = 18, Bottom = 5 },
|
||||||
|
Font = OsuFont.Torus.With(size: 12, weight: FontWeight.SemiBold),
|
||||||
|
},
|
||||||
|
ItemFlow = new FillFlowContainer<ChannelListItem>
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,8 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
switch (newChannel?.Type)
|
switch (newChannel?.Type)
|
||||||
{
|
{
|
||||||
case ChannelType.Public:
|
case null:
|
||||||
chattingText.Text = ChatStrings.TalkingIn(newChannel.Name);
|
chattingText.Text = string.Empty;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ChannelType.PM:
|
case ChannelType.PM:
|
||||||
@ -150,7 +150,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
chattingText.Text = string.Empty;
|
chattingText.Text = ChatStrings.TalkingIn(newChannel.Name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user