2017-05-21 08:38:36 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
2017-05-21 05:06:25 +08:00
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2017-05-21 08:26:39 +08:00
|
|
|
using System;
|
2017-05-21 06:30:40 +08:00
|
|
|
using System.Collections.Generic;
|
2017-05-21 05:06:25 +08:00
|
|
|
using OpenTK;
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-06-01 09:39:03 +08:00
|
|
|
using osu.Framework.Input;
|
2017-05-21 05:06:25 +08:00
|
|
|
using osu.Game.Graphics;
|
2017-05-21 06:30:40 +08:00
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2017-05-21 05:06:25 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2017-05-21 08:26:39 +08:00
|
|
|
using osu.Game.Online.Chat;
|
2017-06-29 01:18:12 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2017-05-21 05:06:25 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Chat
|
|
|
|
{
|
2017-06-29 01:18:12 +08:00
|
|
|
public class ChannelSelectionOverlay : OsuFocusedOverlayContainer
|
2017-05-21 05:06:25 +08:00
|
|
|
{
|
|
|
|
public static readonly float WIDTH_PADDING = 170;
|
|
|
|
|
2017-06-01 17:10:26 +08:00
|
|
|
private const float transition_duration = 500;
|
|
|
|
|
2017-05-21 05:06:25 +08:00
|
|
|
private readonly Box bg;
|
2017-05-21 06:30:40 +08:00
|
|
|
private readonly Triangles triangles;
|
2017-05-21 05:06:25 +08:00
|
|
|
private readonly Box headerBg;
|
|
|
|
private readonly SearchTextBox search;
|
2017-05-21 07:22:55 +08:00
|
|
|
private readonly SearchContainer<ChannelSection> sectionsFlow;
|
2017-05-21 06:30:40 +08:00
|
|
|
|
2017-05-21 08:26:39 +08:00
|
|
|
public Action<Channel> OnRequestJoin;
|
2017-05-26 14:56:10 +08:00
|
|
|
public Action<Channel> OnRequestLeave;
|
2017-05-21 08:26:39 +08:00
|
|
|
|
2017-05-21 06:30:40 +08:00
|
|
|
public IEnumerable<ChannelSection> Sections
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
2017-06-24 18:56:35 +08:00
|
|
|
sectionsFlow.ChildrenEnumerable = value;
|
2017-05-21 08:26:39 +08:00
|
|
|
|
|
|
|
foreach (ChannelSection s in sectionsFlow.Children)
|
|
|
|
{
|
|
|
|
foreach (ChannelListItem c in s.ChannelFlow.Children)
|
|
|
|
{
|
|
|
|
c.OnRequestJoin = channel => { OnRequestJoin?.Invoke(channel); };
|
2017-05-26 14:56:10 +08:00
|
|
|
c.OnRequestLeave = channel => { OnRequestLeave?.Invoke(channel); };
|
2017-05-21 08:26:39 +08:00
|
|
|
}
|
|
|
|
}
|
2017-05-21 06:30:40 +08:00
|
|
|
}
|
|
|
|
}
|
2017-05-21 05:06:25 +08:00
|
|
|
|
|
|
|
public ChannelSelectionOverlay()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2017-05-21 07:05:28 +08:00
|
|
|
|
2017-05-21 05:06:25 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
2017-05-21 06:30:40 +08:00
|
|
|
Children = new Drawable[]
|
2017-05-21 05:06:25 +08:00
|
|
|
{
|
|
|
|
bg = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2017-05-21 06:30:40 +08:00
|
|
|
triangles = new Triangles
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
TriangleScale = 5,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-05-23 09:37:25 +08:00
|
|
|
new Container
|
2017-05-21 06:30:40 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-05-30 09:00:15 +08:00
|
|
|
Padding = new MarginPadding { Top = 85, Right = WIDTH_PADDING },
|
2017-05-21 06:30:40 +08:00
|
|
|
Children = new[]
|
|
|
|
{
|
2017-05-23 09:37:25 +08:00
|
|
|
new ScrollContainer
|
2017-05-21 06:30:40 +08:00
|
|
|
{
|
2017-05-23 09:37:25 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
sectionsFlow = new SearchContainer<ChannelSection>
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
LayoutDuration = 200,
|
|
|
|
LayoutEasing = EasingTypes.OutQuint,
|
|
|
|
Spacing = new Vector2(0f, 20f),
|
2017-05-30 09:00:15 +08:00
|
|
|
Padding = new MarginPadding { Vertical = 20, Left = WIDTH_PADDING },
|
2017-05-23 09:37:25 +08:00
|
|
|
},
|
|
|
|
},
|
2017-05-21 06:30:40 +08:00
|
|
|
},
|
2017-05-21 05:06:25 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
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",
|
|
|
|
TextSize = 20,
|
2017-05-21 08:38:36 +08:00
|
|
|
Shadow = false,
|
2017-05-21 05:06:25 +08:00
|
|
|
},
|
|
|
|
search = new HeaderSearchTextBox
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
PlaceholderText = @"Search",
|
2017-05-21 06:30:40 +08:00
|
|
|
Exit = Hide,
|
2017-05-21 05:06:25 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2017-05-21 07:22:55 +08:00
|
|
|
|
|
|
|
search.Current.ValueChanged += newValue => sectionsFlow.SearchTerm = newValue;
|
2017-05-21 05:06:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
bg.Colour = colours.Gray3;
|
2017-05-21 06:30:40 +08:00
|
|
|
triangles.ColourDark = colours.Gray3;
|
|
|
|
triangles.ColourLight = OsuColour.FromHex(@"353535");
|
|
|
|
|
2017-05-21 05:06:25 +08:00
|
|
|
headerBg.Colour = colours.Gray2.Opacity(0.75f);
|
|
|
|
}
|
|
|
|
|
2017-06-01 09:39:03 +08:00
|
|
|
protected override void OnFocus(InputState state)
|
2017-05-21 05:06:25 +08:00
|
|
|
{
|
2017-06-01 09:39:03 +08:00
|
|
|
InputManager.ChangeFocus(search);
|
|
|
|
base.OnFocus(state);
|
|
|
|
}
|
2017-05-21 07:05:28 +08:00
|
|
|
|
2017-06-01 09:39:03 +08:00
|
|
|
protected override void PopIn()
|
|
|
|
{
|
2017-06-01 16:41:21 +08:00
|
|
|
if (Alpha == 0) MoveToY(DrawHeight);
|
2017-06-01 16:26:01 +08:00
|
|
|
|
2017-06-01 17:10:26 +08:00
|
|
|
FadeIn(transition_duration, EasingTypes.OutQuint);
|
|
|
|
MoveToY(0, transition_duration, EasingTypes.OutQuint);
|
2017-06-01 09:39:03 +08:00
|
|
|
|
|
|
|
search.HoldFocus = true;
|
|
|
|
base.PopIn();
|
2017-05-21 05:06:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
{
|
2017-06-01 17:10:26 +08:00
|
|
|
FadeOut(transition_duration, EasingTypes.InSine);
|
|
|
|
MoveToY(DrawHeight, transition_duration, EasingTypes.InSine);
|
2017-06-01 09:39:03 +08:00
|
|
|
|
|
|
|
search.HoldFocus = false;
|
|
|
|
base.PopOut();
|
2017-05-21 05:06:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private class HeaderSearchTextBox : SearchTextBox
|
|
|
|
{
|
|
|
|
protected override Color4 BackgroundFocused => Color4.Black.Opacity(0.2f);
|
|
|
|
protected override Color4 BackgroundUnfocused => Color4.Black.Opacity(0.2f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|