From a5fa7e1a7d1cf407773cbbb21dc796beae065b6d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 18 May 2017 17:43:39 -0300 Subject: [PATCH] Result counts displaying --- .../Tests/TestCaseDirect.cs | 6 ++- .../Graphics/UserInterface/OsuDropdown.cs | 2 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 1 - osu.Game/Overlays/Direct/FilterControl.cs | 48 +++++++++++++++++-- osu.Game/Overlays/Direct/Header.cs | 1 - osu.Game/Overlays/DirectOverlay.cs | 9 +++- 6 files changed, 55 insertions(+), 12 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index 2fd8dc84b8..c7fa97952e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -9,6 +9,7 @@ using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Overlays; using osu.Game.Overlays.Dialog; +using osu.Game.Overlays.Direct; namespace osu.Desktop.VisualTests.Tests { @@ -25,12 +26,13 @@ namespace osu.Desktop.VisualTests.Tests Add(direct = new DirectOverlay()); newBeatmaps(); + direct.ResultCounts = new ResultCounts(1, 432, 3); AddStep(@"Toggle", direct.ToggleVisibility); } - [BackgroundDependencyLoader] - private void load(RulesetDatabase rulesets) + [BackgroundDependencyLoader] + private void load(RulesetDatabase rulesets) { this.rulesets = rulesets; } diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index dbd50c2fe0..9c1799c04c 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -136,7 +136,7 @@ namespace osu.Game.Graphics.UserInterface } public OsuDropdownHeader() - { + { Foreground.Padding = new MarginPadding(4); AutoSizeAxes = Axes.None; diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index b5146dbbe3..8de2121c0b 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -3,7 +3,6 @@ using OpenTK; using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 5a2d552209..91372d7543 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -29,12 +29,20 @@ namespace osu.Game.Overlays.Direct private readonly Box tabStrip; private readonly FillFlowContainer modeButtons; - private FillFlowContainer resultCounts; + private FillFlowContainer resultCountsContainer; + private OsuSpriteText resultCountsText; public readonly SearchTextBox Search; public readonly SortTabControl SortTabs; public readonly OsuEnumDropdown RankStatusDropdown; + private ResultCounts resultCounts; + public ResultCounts ResultCounts + { + get { return resultCounts; } + set { resultCounts = value; updateResultCounts(); } + } + public FilterControl() { RelativeSizeAxes = Axes.X; @@ -87,7 +95,7 @@ namespace osu.Game.Overlays.Direct Margin = new MarginPadding { Bottom = 5, Right = DirectOverlay.WIDTH_PADDING }, Width = 160f, }, - resultCounts = new FillFlowContainer + resultCountsContainer = new FillFlowContainer { Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, @@ -101,9 +109,8 @@ namespace osu.Game.Overlays.Direct Text = @"Found ", TextSize = 15, }, - new OsuSpriteText + resultCountsText = new OsuSpriteText { - Text = @"1 Artist, 432 Songs, 3 Tags", TextSize = 15, Font = @"Exo2.0-Bold", }, @@ -115,13 +122,15 @@ namespace osu.Game.Overlays.Direct RankStatusDropdown.Current.Value = RankStatus.RankedApproved; SortTabs.Current.Value = SortCriteria.Title; SortTabs.Current.TriggerChange(); + + updateResultCounts(); } [BackgroundDependencyLoader(true)] private void load(OsuGame game, RulesetDatabase rulesets, OsuColour colours) { tabStrip.Colour = colours.Yellow; - resultCounts.Colour = colours.Yellow; + resultCountsContainer.Colour = colours.Yellow; RankStatusDropdown.AccentColour = colours.BlueDark; foreach (var r in rulesets.AllRulesets) @@ -130,6 +139,21 @@ namespace osu.Game.Overlays.Direct } } + private void updateResultCounts() + { + resultCountsContainer.FadeTo(ResultCounts == null ? 0 : 1, 200, EasingTypes.Out); + if (resultCounts == null) return; + + resultCountsText.Text = pluralize(@"Artist", ResultCounts.Artists) + ", " + + pluralize(@"Song", ResultCounts.Songs) + ", " + + pluralize(@"Tag", ResultCounts.Tags); + } + + private string pluralize(string prefix, int value) + { + return $@"{value} {prefix}" + (value == 1 ? @"" : @"s"); + } + private class DirectSearchTextBox : SearchTextBox { protected override Color4 BackgroundUnfocused => backgroundColour; @@ -241,4 +265,18 @@ namespace osu.Game.Overlays.Direct [Description("My Maps")] MyMaps, } + + public class ResultCounts + { + public readonly int Artists; + public readonly int Songs; + public readonly int Tags; + + public ResultCounts(int artists, int songs, int tags) + { + Artists = artists; + Songs = songs; + Tags = tags; + } + } } diff --git a/osu.Game/Overlays/Direct/Header.cs b/osu.Game/Overlays/Direct/Header.cs index d4d8902b11..af1dfb4b53 100644 --- a/osu.Game/Overlays/Direct/Header.cs +++ b/osu.Game/Overlays/Direct/Header.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.ComponentModel; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 0b22506d5c..7e167bd2c1 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using OpenTK; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -30,12 +29,18 @@ namespace osu.Game.Overlays var p = new List(); foreach (BeatmapSetInfo b in value) - p.Add(new DirectGridPanel(b) { Width = 407 }); + p.Add(new DirectGridPanel(b) { Width = 400 }); panels.Children = p; } } + public ResultCounts ResultCounts + { + get { return filter.ResultCounts; } + set { filter.ResultCounts = value; } + } + public DirectOverlay() { RelativeSizeAxes = Axes.Both;