2017-05-17 16:58:34 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-05-19 02:01:01 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-05-20 05:54:47 +08:00
|
|
|
|
using System.Linq;
|
2017-05-19 03:15:49 +08:00
|
|
|
|
using OpenTK;
|
2017-05-17 16:58:34 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-05-19 02:01:01 +08:00
|
|
|
|
using osu.Game.Database;
|
2017-05-17 16:58:34 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
|
|
|
|
using osu.Game.Overlays.Direct;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
|
|
|
|
public class DirectOverlay : WaveOverlayContainer
|
|
|
|
|
{
|
|
|
|
|
public static readonly int WIDTH_PADDING = 80;
|
2017-05-19 03:15:49 +08:00
|
|
|
|
private readonly float panel_padding = 10f;
|
2017-05-17 16:58:34 +08:00
|
|
|
|
|
|
|
|
|
private readonly Box background;
|
2017-05-20 06:13:07 +08:00
|
|
|
|
private readonly Header header;
|
2017-05-17 16:58:34 +08:00
|
|
|
|
private readonly FilterControl filter;
|
2017-05-19 03:15:49 +08:00
|
|
|
|
private readonly FillFlowContainer<DirectPanel> panels;
|
|
|
|
|
|
2017-05-20 04:52:34 +08:00
|
|
|
|
private IEnumerable<BeatmapSetInfo> beatmapSets;
|
2017-05-19 03:15:49 +08:00
|
|
|
|
public IEnumerable<BeatmapSetInfo> BeatmapSets
|
|
|
|
|
{
|
2017-05-20 04:52:34 +08:00
|
|
|
|
get { return beatmapSets; }
|
2017-05-19 03:15:49 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2017-05-20 04:52:34 +08:00
|
|
|
|
if (beatmapSets == value) return;
|
|
|
|
|
beatmapSets = value;
|
2017-05-19 03:15:49 +08:00
|
|
|
|
|
2017-05-20 04:52:34 +08:00
|
|
|
|
recreatePanels(filter.DisplayStyle.Value);
|
2017-05-19 03:15:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-17 16:58:34 +08:00
|
|
|
|
|
2017-05-19 04:43:39 +08:00
|
|
|
|
public ResultCounts ResultCounts
|
|
|
|
|
{
|
|
|
|
|
get { return filter.ResultCounts; }
|
|
|
|
|
set { filter.ResultCounts = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-17 16:58:34 +08:00
|
|
|
|
public DirectOverlay()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
// osu!direct colours are not part of the standard palette
|
|
|
|
|
|
|
|
|
|
FirstWaveColour = OsuColour.FromHex(@"19b0e2");
|
|
|
|
|
SecondWaveColour = OsuColour.FromHex(@"2280a2");
|
|
|
|
|
ThirdWaveColour = OsuColour.FromHex(@"005774");
|
|
|
|
|
FourthWaveColour = OsuColour.FromHex(@"003a4e");
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = OsuColour.FromHex(@"485e74"),
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new Triangles
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
TriangleScale = 5,
|
|
|
|
|
ColourLight = OsuColour.FromHex(@"465b71"),
|
|
|
|
|
ColourDark = OsuColour.FromHex(@"3f5265"),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-05-19 03:15:49 +08:00
|
|
|
|
new ScrollContainer
|
2017-05-17 16:58:34 +08:00
|
|
|
|
{
|
2017-05-19 03:15:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ScrollDraggerVisible = false,
|
|
|
|
|
Padding = new MarginPadding { Top = Header.HEIGHT },
|
2017-05-17 16:58:34 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-05-20 05:54:47 +08:00
|
|
|
|
new ContentFlow
|
2017-05-17 16:58:34 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-05-19 03:15:49 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
filter = new FilterControl
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
},
|
|
|
|
|
panels = new FillFlowContainer<DirectPanel>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Padding = new MarginPadding { Top = FilterControl.LOWER_HEIGHT + panel_padding, Bottom = panel_padding, Left = WIDTH_PADDING, Right = WIDTH_PADDING },
|
|
|
|
|
Spacing = new Vector2(panel_padding),
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-05-17 16:58:34 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-05-20 06:13:07 +08:00
|
|
|
|
header = new Header
|
2017-05-19 03:15:49 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-05-19 02:01:01 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2017-05-20 06:13:07 +08:00
|
|
|
|
header.Tabs.Current.ValueChanged += (tab) => { if (tab != DirectTab.Search) filter.Search.Current.Value = @""; };
|
|
|
|
|
|
2017-05-19 03:15:49 +08:00
|
|
|
|
filter.Search.Exit = Hide;
|
2017-05-20 06:13:07 +08:00
|
|
|
|
filter.Search.Current.ValueChanged += (s) => { if (s != @"") header.Tabs.Current.Value = DirectTab.Search; };
|
2017-05-20 04:52:34 +08:00
|
|
|
|
filter.DisplayStyle.ValueChanged += recreatePanels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void recreatePanels(PanelDisplayStyle displayStyle)
|
|
|
|
|
{
|
|
|
|
|
var p = new List<DirectPanel>();
|
|
|
|
|
|
|
|
|
|
foreach (BeatmapSetInfo b in BeatmapSets)
|
2017-05-20 05:54:47 +08:00
|
|
|
|
p.Add(displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)(new DirectGridPanel(b) { Width = 400 }) :
|
2017-05-20 04:52:34 +08:00
|
|
|
|
(DirectPanel)(new DirectListPanel(b)));
|
|
|
|
|
|
|
|
|
|
panels.Children = p;
|
2017-05-17 16:58:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
|
|
|
|
|
|
|
|
|
filter.Search.HoldFocus = true;
|
|
|
|
|
Schedule(() => filter.Search.TriggerFocus());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
|
|
|
|
|
|
|
|
|
filter.Search.HoldFocus = false;
|
|
|
|
|
}
|
2017-05-20 05:54:47 +08:00
|
|
|
|
|
2017-05-20 06:13:07 +08:00
|
|
|
|
private class ContentFlow : FillFlowContainer<Drawable>
|
2017-05-20 05:54:47 +08:00
|
|
|
|
{
|
2017-05-20 06:13:07 +08:00
|
|
|
|
protected override IComparer<Drawable> DepthComparer => new ReverseCreationOrderDepthComparer();
|
2017-05-20 05:54:47 +08:00
|
|
|
|
protected override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
|
|
|
|
|
|
|
|
|
public ContentFlow()
|
2017-05-20 06:13:07 +08:00
|
|
|
|
{
|
2017-05-20 05:54:47 +08:00
|
|
|
|
Direction = FillDirection.Vertical;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-17 16:58:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|