1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 12:02:54 +08:00

Merge branch 'rename-chat-overlay' into fix-dummmy-api-request-firing-2

This commit is contained in:
Dean Herbert 2022-05-30 17:56:12 +09:00
commit dcc53fbd47
13 changed files with 105 additions and 50 deletions

View File

@ -40,7 +40,7 @@ namespace osu.Game.Tests.Visual.Navigation
typeof(DashboardOverlay), typeof(DashboardOverlay),
typeof(NewsOverlay), typeof(NewsOverlay),
typeof(ChannelManager), typeof(ChannelManager),
typeof(ChatOverlayV2), typeof(ChatOverlay),
typeof(SettingsOverlay), typeof(SettingsOverlay),
typeof(UserProfileOverlay), typeof(UserProfileOverlay),
typeof(BeatmapSetOverlay), typeof(BeatmapSetOverlay),

View File

@ -86,9 +86,9 @@ namespace osu.Game.Tests.Visual.Navigation
[Test] [Test]
public void TestOverlaysAlwaysClosed() public void TestOverlaysAlwaysClosed()
{ {
ChatOverlayV2 chat = null; ChatOverlay chat = null;
AddUntilStep("is at menu", () => Game.ScreenStack.CurrentScreen is MainMenu); AddUntilStep("is at menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
AddUntilStep("wait for chat load", () => (chat = Game.ChildrenOfType<ChatOverlayV2>().SingleOrDefault()) != null); AddUntilStep("wait for chat load", () => (chat = Game.ChildrenOfType<ChatOverlay>().SingleOrDefault()) != null);
AddStep("show chat", () => InputManager.Key(Key.F8)); AddStep("show chat", () => InputManager.Key(Key.F8));

View File

@ -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,
};
}
} }
} }

View File

@ -32,9 +32,9 @@ using osuTK.Input;
namespace osu.Game.Tests.Visual.Online namespace osu.Game.Tests.Visual.Online
{ {
[TestFixture] [TestFixture]
public class TestSceneChatOverlayV2 : OsuManualInputManagerTestScene public class TestSceneChatOverlay : OsuManualInputManagerTestScene
{ {
private TestChatOverlayV2 chatOverlay; private TestChatOverlay chatOverlay;
private ChannelManager channelManager; private ChannelManager channelManager;
private APIUser testUser; private APIUser testUser;
@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
Children = new Drawable[] Children = new Drawable[]
{ {
channelManager, channelManager,
chatOverlay = new TestChatOverlayV2(), chatOverlay = new TestChatOverlay(),
}, },
}; };
}); });
@ -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,7 +553,18 @@ namespace osu.Game.Tests.Visual.Online
}); });
} }
private class TestChatOverlayV2 : ChatOverlayV2 private Channel createAnnounceChannel()
{
int id = RNG.Next(0, 10000);
return new Channel
{
Name = $"Announce {id}",
Type = ChannelType.Announce,
Id = id,
};
}
private class TestChatOverlay : ChatOverlay
{ {
public bool SlowLoading { get; set; } public bool SlowLoading { get; set; }

View File

@ -208,7 +208,7 @@ namespace osu.Game.Tests.Visual.Online
}; };
[Cached] [Cached]
public ChatOverlayV2 ChatOverlay { get; } = new ChatOverlayV2(); public ChatOverlay ChatOverlay { get; } = new ChatOverlay();
private readonly MessageNotifier messageNotifier = new MessageNotifier(); private readonly MessageNotifier messageNotifier = new MessageNotifier();

View File

@ -46,7 +46,7 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.RandomSelectAlgorithm, RandomSelectAlgorithm.RandomPermutation); SetDefault(OsuSetting.RandomSelectAlgorithm, RandomSelectAlgorithm.RandomPermutation);
SetDefault(OsuSetting.ChatDisplayHeight, ChatOverlayV2.DEFAULT_HEIGHT, 0.2f, 1f); SetDefault(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2f, 1f);
SetDefault(OsuSetting.BeatmapListingCardSize, BeatmapCardSize.Normal); SetDefault(OsuSetting.BeatmapListingCardSize, BeatmapCardSize.Normal);

View File

@ -27,7 +27,7 @@ namespace osu.Game.Online.Chat
private INotificationOverlay notifications { get; set; } private INotificationOverlay notifications { get; set; }
[Resolved] [Resolved]
private ChatOverlayV2 chatOverlay { get; set; } private ChatOverlay chatOverlay { get; set; }
[Resolved] [Resolved]
private ChannelManager channelManager { get; set; } private ChannelManager channelManager { get; set; }
@ -170,7 +170,7 @@ namespace osu.Game.Online.Chat
public override bool IsImportant => false; public override bool IsImportant => false;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, ChatOverlayV2 chatOverlay, INotificationOverlay notificationOverlay) private void load(OsuColour colours, ChatOverlay chatOverlay, INotificationOverlay notificationOverlay)
{ {
IconBackground.Colour = colours.PurpleDark; IconBackground.Colour = colours.PurpleDark;

View File

@ -75,7 +75,7 @@ namespace osu.Game
public Toolbar Toolbar; public Toolbar Toolbar;
private ChatOverlayV2 chatOverlay; private ChatOverlay chatOverlay;
private ChannelManager channelManager; private ChannelManager channelManager;
@ -848,7 +848,7 @@ namespace osu.Game
loadComponentSingleFile(news = new NewsOverlay(), overlayContent.Add, true); loadComponentSingleFile(news = new NewsOverlay(), overlayContent.Add, true);
var rankingsOverlay = loadComponentSingleFile(new RankingsOverlay(), overlayContent.Add, true); var rankingsOverlay = loadComponentSingleFile(new RankingsOverlay(), overlayContent.Add, true);
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true); loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
loadComponentSingleFile(chatOverlay = new ChatOverlayV2(), overlayContent.Add, true); loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
loadComponentSingleFile(new MessageNotifier(), AddInternal, true); loadComponentSingleFile(new MessageNotifier(), AddInternal, true);
loadComponentSingleFile(Settings = new SettingsOverlay(), leftFloatingOverlayContent.Add, true); loadComponentSingleFile(Settings = new SettingsOverlay(), leftFloatingOverlayContent.Add, true);
loadComponentSingleFile(changelogOverlay = new ChangelogOverlay(), overlayContent.Add, true); loadComponentSingleFile(changelogOverlay = new ChangelogOverlay(), overlayContent.Add, true);

View File

@ -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,
},
};
} }
} }
} }

View File

@ -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);

View File

@ -27,7 +27,7 @@ using osu.Game.Overlays.Chat.Listing;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class ChatOverlayV2 : OsuFocusedOverlayContainer, INamedOverlayComponent, IKeyBindingHandler<PlatformAction> public class ChatOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent, IKeyBindingHandler<PlatformAction>
{ {
public string IconTexture => "Icons/Hexacons/messaging"; public string IconTexture => "Icons/Hexacons/messaging";
public LocalisableString Title => ChatStrings.HeaderTitle; public LocalisableString Title => ChatStrings.HeaderTitle;
@ -70,7 +70,7 @@ namespace osu.Game.Overlays
private readonly IBindableList<Channel> availableChannels = new BindableList<Channel>(); private readonly IBindableList<Channel> availableChannels = new BindableList<Channel>();
private readonly IBindableList<Channel> joinedChannels = new BindableList<Channel>(); private readonly IBindableList<Channel> joinedChannels = new BindableList<Channel>();
public ChatOverlayV2() public ChatOverlay()
{ {
Height = DEFAULT_HEIGHT; Height = DEFAULT_HEIGHT;

View File

@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
private UserProfileOverlay userOverlay { get; set; } private UserProfileOverlay userOverlay { get; set; }
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private ChatOverlayV2 chatOverlay { get; set; } private ChatOverlay chatOverlay { get; set; }
[Resolved] [Resolved]
private IAPIProvider apiProvider { get; set; } private IAPIProvider apiProvider { get; set; }

View File

@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Toolbar
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(ChatOverlayV2 chat) private void load(ChatOverlay chat)
{ {
StateContainer = chat; StateContainer = chat;
} }