1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +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.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;
}

View File

@ -136,7 +136,7 @@ namespace osu.Game.Graphics.UserInterface
}
public OsuDropdownHeader()
{
{
Foreground.Padding = new MarginPadding(4);
AutoSizeAxes = Axes.None;

View File

@ -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;

View File

@ -29,12 +29,20 @@ namespace osu.Game.Overlays.Direct
private readonly Box tabStrip;
private readonly FillFlowContainer<RulesetToggleButton> modeButtons;
private FillFlowContainer resultCounts;
private FillFlowContainer resultCountsContainer;
private OsuSpriteText resultCountsText;
public readonly SearchTextBox Search;
public readonly SortTabControl SortTabs;
public readonly OsuEnumDropdown<RankStatus> 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;
}
}
}

View File

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

View File

@ -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<DirectPanel>();
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;