1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 13:22:57 +08:00

Implement RankingsScopeSelector

This commit is contained in:
Andrei Zavatski 2019-09-10 04:20:32 +03:00
parent 65869c7ebb
commit 03bd7ca8e7
4 changed files with 107 additions and 26 deletions

View File

@ -0,0 +1,53 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Game.Overlays;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Framework.Extensions.Color4Extensions;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsScopeSelector : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(RankingsScopeSelector),
};
private readonly Box background;
public TestSceneRankingsScopeSelector()
{
Bindable<RankingsScope> scope = new Bindable<RankingsScope>();
Add(background = new Box
{
RelativeSizeAxes = Axes.Both
});
Add(new RankingsScopeSelector
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Current = { BindTarget = scope }
});
AddStep(@"Select country", () => scope.Value = RankingsScope.Country);
AddStep(@"Select performance", () => scope.Value = RankingsScope.Performance);
AddStep(@"Select score", () => scope.Value = RankingsScope.Score);
AddStep(@"Select spotlights", () => scope.Value = RankingsScope.Spotlights);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.Yellow.Opacity(50);
}
}
}

View File

@ -8,7 +8,6 @@ using osuTK;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Input.Events;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
@ -18,8 +17,6 @@ namespace osu.Game.Graphics.UserInterface
{
protected override Dropdown<TModel> CreateDropdown() => null;
protected override TabItem<TModel> CreateTabItem(TModel value) => new ScopeSelectorTabItem(value);
protected Color4 LineColour
{
get => line.MainColour.Value;
@ -49,29 +46,6 @@ namespace osu.Game.Graphics.UserInterface
Spacing = new Vector2(20, 0),
};
private class ScopeSelectorTabItem : PageTabItem
{
public ScopeSelectorTabItem(TModel value)
: base(value)
{
Text.Font = OsuFont.GetFont(size: 16);
}
protected override bool OnHover(HoverEvent e)
{
Text.FadeColour(AccentColour);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
Text.FadeColour(Color4.White);
}
}
private class GradientLine : GridContainer
{
public readonly Bindable<Color4> MainColour = new Bindable<Color4>();

View File

@ -6,6 +6,9 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using osuTK.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Graphics;
namespace osu.Game.Overlays.BeatmapSet
{
@ -13,6 +16,8 @@ namespace osu.Game.Overlays.BeatmapSet
{
protected override bool AddEnumEntriesAutomatically => false;
protected override TabItem<BeatmapLeaderboardScope> CreateTabItem(BeatmapLeaderboardScope value) => new ScopeSelectorTabItem(value);
public LeaderboardScopeSelector()
{
AddItem(BeatmapLeaderboardScope.Global);
@ -26,5 +31,28 @@ namespace osu.Game.Overlays.BeatmapSet
AccentColour = colours.Blue;
LineColour = Color4.Gray;
}
private class ScopeSelectorTabItem : PageTabItem
{
public ScopeSelectorTabItem(BeatmapLeaderboardScope value)
: base(value)
{
Text.Font = OsuFont.GetFont(size: 16);
}
protected override bool OnHover(HoverEvent e)
{
Text.FadeColour(AccentColour);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
Text.FadeColour(Color4.White);
}
}
}
}

View File

@ -0,0 +1,26 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Graphics.UserInterface;
using osu.Framework.Allocation;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
public class RankingsScopeSelector : GradientLineTabControl<RankingsScope>
{
[BackgroundDependencyLoader]
private void load()
{
AccentColour = LineColour = Color4.Black;
}
}
public enum RankingsScope
{
Performance,
Spotlights,
Score,
Country
}
}