mirror of
https://github.com/ppy/osu.git
synced 2025-01-16 00:13:12 +08:00
Added searching
This commit is contained in:
parent
47dfc0d7bc
commit
2e1d01a268
@ -12,7 +12,7 @@ using osu.Game.Online.Chat;
|
||||
|
||||
namespace osu.Game.Overlays.Chat
|
||||
{
|
||||
public class ChannelListItem : ClickableContainer
|
||||
public class ChannelListItem : ClickableContainer, IFilterable
|
||||
{
|
||||
private const float width_padding = 5;
|
||||
private const float channel_width = 150;
|
||||
@ -27,6 +27,15 @@ namespace osu.Game.Overlays.Chat
|
||||
private Color4? joinedColour;
|
||||
private Color4? topicColour;
|
||||
|
||||
public string[] FilterTerms => new[] { Channel.Name };
|
||||
public bool MatchingCurrentFilter
|
||||
{
|
||||
set
|
||||
{
|
||||
FadeTo(value ? 1f : 0f, 100);
|
||||
}
|
||||
}
|
||||
|
||||
private Channel channel;
|
||||
public Channel Channel
|
||||
{
|
||||
|
@ -11,25 +11,30 @@ using osu.Game.Online.Chat;
|
||||
|
||||
namespace osu.Game.Overlays.Chat
|
||||
{
|
||||
public class ChannelSection : Container
|
||||
public class ChannelSection : Container, IHasFilterableChildren
|
||||
{
|
||||
private readonly FillFlowContainer<ChannelListItem> items;
|
||||
private readonly OsuSpriteText header;
|
||||
|
||||
public IEnumerable<IFilterable> FilterableChildren => items.Children.OfType<IFilterable>();
|
||||
public string[] FilterTerms => new[] { Header };
|
||||
public bool MatchingCurrentFilter
|
||||
{
|
||||
set
|
||||
{
|
||||
FadeTo(value ? 1f : 0f, 100);
|
||||
}
|
||||
}
|
||||
|
||||
public string Header
|
||||
{
|
||||
set
|
||||
{
|
||||
header.Text = value;
|
||||
}
|
||||
get { return header.Text; }
|
||||
set { header.Text = value; }
|
||||
}
|
||||
|
||||
public IEnumerable<Channel> Channels
|
||||
{
|
||||
set
|
||||
{
|
||||
items.Children = value.Select(c => new ChannelListItem { Channel = c });
|
||||
}
|
||||
set { items.Children = value.Select(c => new ChannelListItem { Channel = c }); }
|
||||
}
|
||||
|
||||
public ChannelSection()
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Chat
|
||||
private readonly Triangles triangles;
|
||||
private readonly Box headerBg;
|
||||
private readonly SearchTextBox search;
|
||||
private readonly FillFlowContainer<ChannelSection> sectionsFlow;
|
||||
private readonly SearchContainer<ChannelSection> sectionsFlow;
|
||||
|
||||
public IEnumerable<ChannelSection> Sections
|
||||
{
|
||||
@ -67,11 +67,13 @@ namespace osu.Game.Overlays.Chat
|
||||
Padding = new MarginPadding { Top = 85 },
|
||||
Children = new[]
|
||||
{
|
||||
sectionsFlow = new FillFlowContainer<ChannelSection>
|
||||
sectionsFlow = new SearchContainer<ChannelSection>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
LayoutDuration = 200,
|
||||
LayoutEasing = EasingTypes.OutQuint,
|
||||
Spacing = new Vector2(0f, 20f),
|
||||
Padding = new MarginPadding { Top = 20, Left = WIDTH_PADDING, Right = WIDTH_PADDING },
|
||||
},
|
||||
@ -116,6 +118,8 @@ namespace osu.Game.Overlays.Chat
|
||||
Margin = new MarginPadding { Top = 160 },
|
||||
},
|
||||
};
|
||||
|
||||
search.Current.ValueChanged += newValue => sectionsFlow.SearchTerm = newValue;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
Loading…
Reference in New Issue
Block a user