mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 18:42:56 +08:00
Use CurrentChannel == null
to show the channel selector
This commit is contained in:
parent
cced8609f6
commit
db371ab068
@ -6,7 +6,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -19,11 +18,9 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
{
|
||||
public class ChannelList : Container
|
||||
{
|
||||
public Action<Channel>? OnRequestSelect;
|
||||
public Action<Channel?>? OnRequestSelect;
|
||||
public Action<Channel>? OnRequestLeave;
|
||||
|
||||
public readonly BindableBool SelectorActive = new BindableBool();
|
||||
|
||||
private readonly Dictionary<Channel, ChannelListItem> channelMap = new Dictionary<Channel, ChannelListItem>();
|
||||
|
||||
private ChannelListItemFlow publicChannelFlow = null!;
|
||||
@ -56,7 +53,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
new ChannelListSelector
|
||||
{
|
||||
Margin = new MarginPadding { Bottom = 10 },
|
||||
SelectorActive = { BindTarget = SelectorActive },
|
||||
Action = () => OnRequestSelect?.Invoke(null),
|
||||
},
|
||||
privateChannelFlow = new ChannelListItemFlow("DIRECT MESSAGES"),
|
||||
},
|
||||
@ -73,7 +70,6 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
ChannelListItem item = new ChannelListItem(channel);
|
||||
item.OnRequestSelect += chan => OnRequestSelect?.Invoke(chan);
|
||||
item.OnRequestLeave += chan => OnRequestLeave?.Invoke(chan);
|
||||
item.SelectorActive.BindTarget = SelectorActive;
|
||||
|
||||
ChannelListItemFlow flow = getFlowForChannel(channel);
|
||||
channelMap.Add(channel, item);
|
||||
|
@ -31,8 +31,6 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
|
||||
public readonly BindableBool Unread = new BindableBool();
|
||||
|
||||
public readonly BindableBool SelectorActive = new BindableBool();
|
||||
|
||||
private Box hoverBox = null!;
|
||||
private Box selectBox = null!;
|
||||
private OsuSpriteText text = null!;
|
||||
@ -127,7 +125,6 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
base.LoadComplete();
|
||||
|
||||
selectedChannel.BindValueChanged(_ => updateState(), true);
|
||||
SelectorActive.BindValueChanged(_ => updateState(), true);
|
||||
Unread.BindValueChanged(_ => updateState(), true);
|
||||
}
|
||||
|
||||
@ -163,7 +160,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
bool selected = selectedChannel.Value == Channel && !SelectorActive.Value;
|
||||
bool selected = selectedChannel.Value == Channel;
|
||||
|
||||
if (selected)
|
||||
selectBox.FadeIn(300, Easing.OutQuint);
|
||||
|
@ -12,17 +12,19 @@ using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Chat;
|
||||
|
||||
namespace osu.Game.Overlays.Chat.ChannelList
|
||||
{
|
||||
public class ChannelListSelector : OsuClickableContainer
|
||||
{
|
||||
public readonly BindableBool SelectorActive = new BindableBool();
|
||||
|
||||
private Box hoverBox = null!;
|
||||
private Box selectBox = null!;
|
||||
private OsuSpriteText text = null!;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Channel> currentChannel { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
@ -69,9 +71,9 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
SelectorActive.BindValueChanged(selector =>
|
||||
currentChannel.BindValueChanged(channel =>
|
||||
{
|
||||
if (selector.NewValue)
|
||||
if (channel.NewValue == null)
|
||||
{
|
||||
text.FadeColour(colourProvider.Content1, 300, Easing.OutQuint);
|
||||
selectBox.FadeIn(300, Easing.OutQuint);
|
||||
@ -82,8 +84,6 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
selectBox.FadeOut(200, Easing.OutQuint);
|
||||
}
|
||||
}, true);
|
||||
|
||||
Action = () => SelectorActive.Value = true;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
|
@ -100,7 +100,6 @@ namespace osu.Game.Overlays
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = side_bar_width,
|
||||
Padding = new MarginPadding { Top = top_bar_height },
|
||||
SelectorActive = { BindTarget = selectorActive },
|
||||
},
|
||||
new Container
|
||||
{
|
||||
@ -157,20 +156,10 @@ namespace osu.Game.Overlays
|
||||
channelManager.JoinedChannels.BindCollectionChanged(joinedChannelsChanged, true);
|
||||
channelManager.AvailableChannels.BindCollectionChanged(availableChannelsChanged, true);
|
||||
|
||||
channelList.OnRequestSelect += channel =>
|
||||
{
|
||||
// Manually selecting a channel should dismiss the selector
|
||||
selectorActive.Value = false;
|
||||
channelManager.CurrentChannel.Value = channel;
|
||||
};
|
||||
channelList.OnRequestSelect += channel => channelManager.CurrentChannel.Value = channel;
|
||||
channelList.OnRequestLeave += channel => channelManager.LeaveChannel(channel);
|
||||
|
||||
channelListing.OnRequestJoin += channel =>
|
||||
{
|
||||
channelManager.JoinChannel(channel);
|
||||
// Manually joining a channel should keep the selector open
|
||||
selectorActive.Value = true;
|
||||
};
|
||||
channelListing.OnRequestJoin += channel => channelManager.JoinChannel(channel, false);
|
||||
channelListing.OnRequestLeave += channel => channelManager.LeaveChannel(channel);
|
||||
|
||||
textBar.OnSearchTermsChanged += searchTerms => channelListing.SearchTerm = searchTerms;
|
||||
@ -257,21 +246,9 @@ namespace osu.Game.Overlays
|
||||
|
||||
loading.Show();
|
||||
|
||||
// Channel is null when leaving the currently selected channel
|
||||
if (newChannel == null)
|
||||
{
|
||||
// Don't need to autoswitch if the selector is visible
|
||||
if (selectorActive.Value)
|
||||
return;
|
||||
|
||||
// Find another channel to switch to
|
||||
newChannel = channelManager.JoinedChannels.FirstOrDefault(c => c != channel.OldValue);
|
||||
|
||||
if (newChannel == null)
|
||||
selectorActive.Value = true;
|
||||
else
|
||||
currentChannel.Value = newChannel;
|
||||
|
||||
selectorActive.Value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user