1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 10:47:25 +08:00

Result counts displaying

This commit is contained in:
DrabWeb 2017-05-18 17:43:39 -03:00
parent 1d1375c4d4
commit a5fa7e1a7d
6 changed files with 55 additions and 12 deletions

View File

@ -9,6 +9,7 @@ using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Dialog; using osu.Game.Overlays.Dialog;
using osu.Game.Overlays.Direct;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
@ -25,6 +26,7 @@ namespace osu.Desktop.VisualTests.Tests
Add(direct = new DirectOverlay()); Add(direct = new DirectOverlay());
newBeatmaps(); newBeatmaps();
direct.ResultCounts = new ResultCounts(1, 432, 3);
AddStep(@"Toggle", direct.ToggleVisibility); AddStep(@"Toggle", direct.ToggleVisibility);
} }

View File

@ -3,7 +3,6 @@
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;

View File

@ -29,12 +29,20 @@ namespace osu.Game.Overlays.Direct
private readonly Box tabStrip; private readonly Box tabStrip;
private readonly FillFlowContainer<RulesetToggleButton> modeButtons; private readonly FillFlowContainer<RulesetToggleButton> modeButtons;
private FillFlowContainer resultCounts; private FillFlowContainer resultCountsContainer;
private OsuSpriteText resultCountsText;
public readonly SearchTextBox Search; public readonly SearchTextBox Search;
public readonly SortTabControl SortTabs; public readonly SortTabControl SortTabs;
public readonly OsuEnumDropdown<RankStatus> RankStatusDropdown; public readonly OsuEnumDropdown<RankStatus> RankStatusDropdown;
private ResultCounts resultCounts;
public ResultCounts ResultCounts
{
get { return resultCounts; }
set { resultCounts = value; updateResultCounts(); }
}
public FilterControl() public FilterControl()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -87,7 +95,7 @@ namespace osu.Game.Overlays.Direct
Margin = new MarginPadding { Bottom = 5, Right = DirectOverlay.WIDTH_PADDING }, Margin = new MarginPadding { Bottom = 5, Right = DirectOverlay.WIDTH_PADDING },
Width = 160f, Width = 160f,
}, },
resultCounts = new FillFlowContainer resultCountsContainer = new FillFlowContainer
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft, Origin = Anchor.TopLeft,
@ -101,9 +109,8 @@ namespace osu.Game.Overlays.Direct
Text = @"Found ", Text = @"Found ",
TextSize = 15, TextSize = 15,
}, },
new OsuSpriteText resultCountsText = new OsuSpriteText
{ {
Text = @"1 Artist, 432 Songs, 3 Tags",
TextSize = 15, TextSize = 15,
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
}, },
@ -115,13 +122,15 @@ namespace osu.Game.Overlays.Direct
RankStatusDropdown.Current.Value = RankStatus.RankedApproved; RankStatusDropdown.Current.Value = RankStatus.RankedApproved;
SortTabs.Current.Value = SortCriteria.Title; SortTabs.Current.Value = SortCriteria.Title;
SortTabs.Current.TriggerChange(); SortTabs.Current.TriggerChange();
updateResultCounts();
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(OsuGame game, RulesetDatabase rulesets, OsuColour colours) private void load(OsuGame game, RulesetDatabase rulesets, OsuColour colours)
{ {
tabStrip.Colour = colours.Yellow; tabStrip.Colour = colours.Yellow;
resultCounts.Colour = colours.Yellow; resultCountsContainer.Colour = colours.Yellow;
RankStatusDropdown.AccentColour = colours.BlueDark; RankStatusDropdown.AccentColour = colours.BlueDark;
foreach (var r in rulesets.AllRulesets) 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 private class DirectSearchTextBox : SearchTextBox
{ {
protected override Color4 BackgroundUnfocused => backgroundColour; protected override Color4 BackgroundUnfocused => backgroundColour;
@ -241,4 +265,18 @@ namespace osu.Game.Overlays.Direct
[Description("My Maps")] [Description("My Maps")]
MyMaps, 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;
}
}
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.ComponentModel; using System.ComponentModel;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;

View File

@ -3,7 +3,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using OpenTK; using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -30,12 +29,18 @@ namespace osu.Game.Overlays
var p = new List<DirectPanel>(); var p = new List<DirectPanel>();
foreach (BeatmapSetInfo b in value) foreach (BeatmapSetInfo b in value)
p.Add(new DirectGridPanel(b) { Width = 407 }); p.Add(new DirectGridPanel(b) { Width = 400 });
panels.Children = p; panels.Children = p;
} }
} }
public ResultCounts ResultCounts
{
get { return filter.ResultCounts; }
set { filter.ResultCounts = value; }
}
public DirectOverlay() public DirectOverlay()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;