2019-01-24 16:43:03 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-10-02 11:02:47 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Online.Chat;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
2018-07-10 01:42:57 +08:00
|
|
|
namespace osu.Game.Overlays.Chat.Selection
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-12-19 08:44:31 +08:00
|
|
|
public class ChannelSelectionOverlay : WaveOverlayContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
public static readonly float WIDTH_PADDING = 170;
|
|
|
|
|
|
|
|
private const float transition_duration = 500;
|
|
|
|
|
|
|
|
private readonly Box bg;
|
|
|
|
private readonly Triangles triangles;
|
|
|
|
private readonly Box headerBg;
|
|
|
|
private readonly SearchTextBox search;
|
|
|
|
private readonly SearchContainer<ChannelSection> sectionsFlow;
|
|
|
|
|
|
|
|
public Action<Channel> OnRequestJoin;
|
|
|
|
public Action<Channel> OnRequestLeave;
|
|
|
|
|
|
|
|
public ChannelSelectionOverlay()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
2018-12-19 08:44:31 +08:00
|
|
|
Waves.FirstWaveColour = OsuColour.FromHex("353535");
|
|
|
|
Waves.SecondWaveColour = OsuColour.FromHex("434343");
|
|
|
|
Waves.ThirdWaveColour = OsuColour.FromHex("515151");
|
|
|
|
Waves.FourthWaveColour = OsuColour.FromHex("595959");
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
bg = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
triangles = new Triangles
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
TriangleScale = 5,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Top = 85, Right = WIDTH_PADDING },
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
new OsuScrollContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
sectionsFlow = new SearchContainer<ChannelSection>
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
LayoutDuration = 200,
|
|
|
|
LayoutEasing = Easing.OutQuint,
|
|
|
|
Spacing = new Vector2(0f, 20f),
|
|
|
|
Padding = new MarginPadding { Vertical = 20, Left = WIDTH_PADDING },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
headerBg = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(0f, 10f),
|
|
|
|
Padding = new MarginPadding { Top = 10f, Bottom = 10f, Left = WIDTH_PADDING, Right = WIDTH_PADDING },
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = @"Chat Channels",
|
2019-02-12 12:04:46 +08:00
|
|
|
Font = OsuFont.GetFont(size: 20),
|
2018-04-13 17:19:50 +08:00
|
|
|
Shadow = false,
|
|
|
|
},
|
|
|
|
search = new HeaderSearchTextBox
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
PlaceholderText = @"Search",
|
|
|
|
Exit = Hide,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-02-22 16:51:39 +08:00
|
|
|
search.Current.ValueChanged += term => sectionsFlow.SearchTerm = term.NewValue;
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2018-07-10 02:13:34 +08:00
|
|
|
public void UpdateAvailableChannels(IEnumerable<Channel> channels)
|
|
|
|
{
|
2018-07-24 10:56:34 +08:00
|
|
|
Scheduler.Add(() =>
|
2018-07-10 02:13:34 +08:00
|
|
|
{
|
2018-07-24 10:56:34 +08:00
|
|
|
sectionsFlow.ChildrenEnumerable = new[]
|
2018-07-10 02:13:34 +08:00
|
|
|
{
|
2018-07-24 10:56:34 +08:00
|
|
|
new ChannelSection
|
|
|
|
{
|
|
|
|
Header = "All Channels",
|
|
|
|
Channels = channels,
|
|
|
|
},
|
|
|
|
};
|
2018-07-10 02:13:34 +08:00
|
|
|
|
2018-07-24 10:56:34 +08:00
|
|
|
foreach (ChannelSection s in sectionsFlow.Children)
|
2018-07-10 02:13:34 +08:00
|
|
|
{
|
2018-07-24 10:56:34 +08:00
|
|
|
foreach (ChannelListItem c in s.ChannelFlow.Children)
|
|
|
|
{
|
|
|
|
c.OnRequestJoin = channel => { OnRequestJoin?.Invoke(channel); };
|
|
|
|
c.OnRequestLeave = channel => { OnRequestLeave?.Invoke(channel); };
|
|
|
|
}
|
2018-07-10 02:13:34 +08:00
|
|
|
}
|
2018-07-24 10:56:34 +08:00
|
|
|
});
|
2018-07-10 02:13:34 +08:00
|
|
|
}
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
bg.Colour = colours.Gray3;
|
|
|
|
triangles.ColourDark = colours.Gray3;
|
|
|
|
triangles.ColourLight = OsuColour.FromHex(@"353535");
|
|
|
|
|
|
|
|
headerBg.Colour = colours.Gray2.Opacity(0.75f);
|
|
|
|
}
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
protected override void OnFocus(FocusEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-25 18:20:08 +08:00
|
|
|
search.TakeFocus();
|
2018-10-02 11:02:47 +08:00
|
|
|
base.OnFocus(e);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
{
|
|
|
|
if (Alpha == 0) this.MoveToY(DrawHeight);
|
|
|
|
|
|
|
|
this.FadeIn(transition_duration, Easing.OutQuint);
|
|
|
|
this.MoveToY(0, transition_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
search.HoldFocus = true;
|
|
|
|
base.PopIn();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
{
|
|
|
|
this.FadeOut(transition_duration, Easing.InSine);
|
|
|
|
this.MoveToY(DrawHeight, transition_duration, Easing.InSine);
|
|
|
|
|
|
|
|
search.HoldFocus = false;
|
|
|
|
base.PopOut();
|
|
|
|
}
|
|
|
|
|
|
|
|
private class HeaderSearchTextBox : SearchTextBox
|
|
|
|
{
|
2019-03-23 00:44:05 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
BackgroundFocused = Color4.Black.Opacity(0.2f);
|
|
|
|
BackgroundUnfocused = Color4.Black.Opacity(0.2f);
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|