1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +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(NewsOverlay),
typeof(ChannelManager),
typeof(ChatOverlayV2),
typeof(ChatOverlay),
typeof(SettingsOverlay),
typeof(UserProfileOverlay),
typeof(BeatmapSetOverlay),

View File

@ -86,9 +86,9 @@ namespace osu.Game.Tests.Visual.Navigation
[Test]
public void TestOverlaysAlwaysClosed()
{
ChatOverlayV2 chat = null;
ChatOverlay chat = null;
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));

View File

@ -87,7 +87,7 @@ namespace osu.Game.Tests.Visual.Online
{
leaveText.Text = $"OnRequestLeave: {channel.Name}";
leaveText.FadeOutFromOne(1000, Easing.InQuint);
selected.Value = null;
selected.Value = channelList.ChannelListingChannel;
channelList.RemoveChannel(channel);
};
@ -112,6 +112,12 @@ namespace osu.Game.Tests.Visual.Online
for (int i = 0; i < 10; i++)
channelList.AddChannel(createRandomPrivateChannel());
});
AddStep("Add Announce Channels", () =>
{
for (int i = 0; i < 2; i++)
channelList.AddChannel(createRandomAnnounceChannel());
});
}
[Test]
@ -170,5 +176,16 @@ namespace osu.Game.Tests.Visual.Online
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
{
[TestFixture]
public class TestSceneChatOverlayV2 : OsuManualInputManagerTestScene
public class TestSceneChatOverlay : OsuManualInputManagerTestScene
{
private TestChatOverlayV2 chatOverlay;
private TestChatOverlay chatOverlay;
private ChannelManager channelManager;
private APIUser testUser;
@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
Children = new Drawable[]
{
channelManager,
chatOverlay = new TestChatOverlayV2(),
chatOverlay = new TestChatOverlay(),
},
};
});
@ -455,6 +455,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestKeyboardNextChannel()
{
Channel announceChannel = createAnnounceChannel();
Channel pmChannel1 = createPrivateChannel();
Channel pmChannel2 = createPrivateChannel();
@ -464,6 +465,7 @@ namespace osu.Game.Tests.Visual.Online
channelManager.JoinChannel(testChannel2);
channelManager.JoinChannel(pmChannel1);
channelManager.JoinChannel(pmChannel2);
channelManager.JoinChannel(announceChannel);
chatOverlay.Show();
});
@ -477,6 +479,9 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
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));
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; }

View File

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

View File

@ -46,7 +46,7 @@ namespace osu.Game.Configuration
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);

View File

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

View File

@ -75,7 +75,7 @@ namespace osu.Game
public Toolbar Toolbar;
private ChatOverlayV2 chatOverlay;
private ChatOverlay chatOverlay;
private ChannelManager channelManager;
@ -848,7 +848,7 @@ namespace osu.Game
loadComponentSingleFile(news = new NewsOverlay(), overlayContent.Add, true);
var rankingsOverlay = loadComponentSingleFile(new RankingsOverlay(), overlayContent.Add, 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(Settings = new SettingsOverlay(), leftFloatingOverlayContent.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>? 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();
private readonly Dictionary<Channel, ChannelListItem> channelMap = new Dictionary<Channel, ChannelListItem>();
private OsuScrollContainer scroll = null!;
private ChannelListItemFlow publicChannelFlow = null!;
private ChannelListItemFlow privateChannelFlow = null!;
private FillFlowContainer groupFlow = null!;
private ChannelGroup announceChannelGroup = null!;
private ChannelGroup publicChannelGroup = null!;
private ChannelGroup privateChannelGroup = null!;
private ChannelListItem selector = null!;
[BackgroundDependencyLoader]
@ -49,25 +54,20 @@ namespace osu.Game.Overlays.Chat.ChannelList
},
scroll = new OsuScrollContainer
{
Padding = new MarginPadding { Vertical = 7 },
RelativeSizeAxes = Axes.Both,
ScrollbarAnchor = Anchor.TopRight,
ScrollDistance = 35f,
Child = new FillFlowContainer
Child = groupFlow = new FillFlowContainer
{
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new ChannelListLabel(ChatStrings.ChannelsListTitlePUBLIC.ToUpper()),
publicChannelFlow = new ChannelListItemFlow(),
selector = new ChannelListItem(ChannelListingChannel)
{
Margin = new MarginPadding { Bottom = 10 },
},
new ChannelListLabel(ChatStrings.ChannelsListTitlePM.ToUpper()),
privateChannelFlow = new ChannelListItemFlow(),
announceChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitleANNOUNCE.ToUpper()),
publicChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitlePUBLIC.ToUpper()),
selector = new ChannelListItem(ChannelListingChannel),
privateChannelGroup = new ChannelGroup(ChatStrings.ChannelsListTitlePM.ToUpper()),
},
},
},
@ -85,9 +85,11 @@ namespace osu.Game.Overlays.Chat.ChannelList
item.OnRequestSelect += chan => OnRequestSelect?.Invoke(chan);
item.OnRequestLeave += chan => OnRequestLeave?.Invoke(chan);
ChannelListItemFlow flow = getFlowForChannel(channel);
FillFlowContainer<ChannelListItem> flow = getFlowForChannel(channel);
channelMap.Add(channel, item);
flow.Add(item);
updateVisibility();
}
public void RemoveChannel(Channel channel)
@ -96,10 +98,12 @@ namespace osu.Game.Overlays.Chat.ChannelList
return;
ChannelListItem item = channelMap[channel];
ChannelListItemFlow flow = getFlowForChannel(channel);
FillFlowContainer<ChannelListItem> flow = getFlowForChannel(channel);
channelMap.Remove(channel);
flow.Remove(item);
updateVisibility();
}
public ChannelListItem GetItem(Channel channel)
@ -112,40 +116,58 @@ namespace osu.Game.Overlays.Chat.ChannelList
public void ScrollChannelIntoView(Channel channel) => scroll.ScrollIntoView(GetItem(channel));
private ChannelListItemFlow getFlowForChannel(Channel channel)
private FillFlowContainer<ChannelListItem> getFlowForChannel(Channel channel)
{
switch (channel.Type)
{
case ChannelType.Public:
return publicChannelFlow;
return publicChannelGroup.ItemFlow;
case ChannelType.PM:
return privateChannelFlow;
return privateChannelGroup.ItemFlow;
case ChannelType.Announce:
return announceChannelGroup.ItemFlow;
default:
return publicChannelFlow;
return publicChannelGroup.ItemFlow;
}
}
private class ChannelListLabel : OsuSpriteText
private void updateVisibility()
{
public ChannelListLabel(LocalisableString label)
{
Text = label;
Margin = new MarginPadding { Left = 18, Bottom = 5 };
Font = OsuFont.Torus.With(size: 12, weight: FontWeight.SemiBold);
}
if (announceChannelGroup.ItemFlow.Children.Count == 0)
announceChannelGroup.Hide();
else
announceChannelGroup.Show();
}
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;
RelativeSizeAxes = Axes.X;
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)
{
case ChannelType.Public:
chattingText.Text = ChatStrings.TalkingIn(newChannel.Name);
case null:
chattingText.Text = string.Empty;
break;
case ChannelType.PM:
@ -150,7 +150,7 @@ namespace osu.Game.Overlays.Chat
break;
default:
chattingText.Text = string.Empty;
chattingText.Text = ChatStrings.TalkingIn(newChannel.Name);
break;
}
}, true);

View File

@ -27,7 +27,7 @@ using osu.Game.Overlays.Chat.Listing;
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 LocalisableString Title => ChatStrings.HeaderTitle;
@ -70,7 +70,7 @@ namespace osu.Game.Overlays
private readonly IBindableList<Channel> availableChannels = new BindableList<Channel>();
private readonly IBindableList<Channel> joinedChannels = new BindableList<Channel>();
public ChatOverlayV2()
public ChatOverlay()
{
Height = DEFAULT_HEIGHT;

View File

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

View File

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