From c2880676dbe9c877b5602cff14a4ecf753935bb2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 18 May 2017 16:15:49 -0300 Subject: [PATCH] Added displaying sets --- .../Tests/TestCaseDirect.cs | 41 +++++++++ osu.Game/Overlays/Direct/FilterControl.cs | 5 ++ osu.Game/Overlays/Direct/Header.cs | 4 +- osu.Game/Overlays/DirectOverlay.cs | 89 +++++++++---------- 4 files changed, 90 insertions(+), 49 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index 8e2e88dd00..2fd8dc84b8 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -1,8 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Testing; +using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Overlays; using osu.Game.Overlays.Dialog; @@ -14,14 +17,52 @@ namespace osu.Desktop.VisualTests.Tests public override string Description => @"osu!direct overlay"; private DirectOverlay direct; + private RulesetDatabase rulesets; public override void Reset() { base.Reset(); Add(direct = new DirectOverlay()); + newBeatmaps(); AddStep(@"Toggle", direct.ToggleVisibility); } + + [BackgroundDependencyLoader] + private void load(RulesetDatabase rulesets) + { + this.rulesets = rulesets; + } + + private void newBeatmaps() + { + var setInfo = new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"Platina", + Artist = @"Maaya Sakamoto", + Author = @"TicClick", + Source = @"Cardcaptor Sakura", + }, + Beatmaps = new List(), + }; + + for (int i = 0; i < 4; i++) + { + setInfo.Beatmaps.Add(new BeatmapInfo + { + Ruleset = rulesets.GetRuleset(i), + StarDifficulty = i + 1, + }); + } + + var s = new List(); + for (int i = 0; i < 10; i++) + s.Add(setInfo); + + direct.BeatmapSets = s; + } } } diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index d4b643c272..0ea1953634 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -22,6 +22,11 @@ namespace osu.Game.Overlays.Direct { public class FilterControl : Container { + /// + /// The height of the content below the filter control (tab strip + result count text). + /// + public static readonly float LOWER_HEIGHT = 21; + private readonly Box tabStrip; private readonly FillFlowContainer modeButtons; private FillFlowContainer resultCounts; diff --git a/osu.Game/Overlays/Direct/Header.cs b/osu.Game/Overlays/Direct/Header.cs index 3e3bfe98d8..d4d8902b11 100644 --- a/osu.Game/Overlays/Direct/Header.cs +++ b/osu.Game/Overlays/Direct/Header.cs @@ -20,13 +20,15 @@ namespace osu.Game.Overlays.Direct { public class Header : Container { + public static readonly float HEIGHT = 90; + private readonly Box tabStrip; public readonly OsuTabControl Tabs; public Header() { - Height = 90; + Height = HEIGHT; Children = new Drawable[] { diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 338ce2bd2d..0b22506d5c 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -16,9 +17,24 @@ namespace osu.Game.Overlays public class DirectOverlay : WaveOverlayContainer { public static readonly int WIDTH_PADDING = 80; + private readonly float panel_padding = 10f; private readonly Box background; private readonly FilterControl filter; + private readonly FillFlowContainer panels; + + public IEnumerable BeatmapSets + { + set + { + var p = new List(); + + foreach (BeatmapSetInfo b in value) + p.Add(new DirectGridPanel(b) { Width = 407 }); + + panels.Children = p; + } + } public DirectOverlay() { @@ -53,67 +69,44 @@ namespace osu.Game.Overlays }, }, }, - new FillFlowContainer + new ScrollContainer { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Both, + ScrollDraggerVisible = false, + Padding = new MarginPadding { Top = Header.HEIGHT }, Children = new Drawable[] { - new Header - { - RelativeSizeAxes = Axes.X, - }, - filter = new FilterControl + new FillFlowContainer { RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + filter = new FilterControl + { + RelativeSizeAxes = Axes.X, + }, + panels = new FillFlowContainer + { + 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), + }, + }, }, }, }, + new Header + { + RelativeSizeAxes = Axes.X, + }, }; filter.Search.Exit = Hide; } - [BackgroundDependencyLoader] - private void load(RulesetDatabase rulesets) - { - var setInfo = new BeatmapSetInfo - { - Metadata = new BeatmapMetadata - { - Title = @"Platina", - Artist = @"Maaya Sakamoto", - Author = @"TicClick", - Source = @"Cardcaptor Sakura", - }, - Beatmaps = new List(), - }; - - for (int i = 0; i< 4; i++) - { - setInfo.Beatmaps.Add(new BeatmapInfo { - Ruleset = rulesets.GetRuleset(i), - StarDifficulty = i + 1, - }); - } - - Add(new Drawable[] - { - new DirectGridPanel(setInfo) - { - Anchor = Anchor.Centre, - Origin = Anchor.BottomCentre, - Width = 300, - }, - new DirectListPanel(setInfo) - { - Anchor = Anchor.Centre, - Origin = Anchor.TopCentre, - Width = 0.8f, - }, - }); - } - protected override void PopIn() { base.PopIn();