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

Implement UserSortTabControl component

This commit is contained in:
Andrei Zavatski 2020-02-24 05:47:21 +03:00
parent 66317f9fcd
commit 0cfe1ac823
4 changed files with 66 additions and 1 deletions

View File

@ -0,0 +1,41 @@
// 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.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Overlays.Home.Friends;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneUserSortTabControl : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(UserSortTabControl),
typeof(OverlaySortTabControl<>),
};
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
public TestSceneUserSortTabControl()
{
UserSortTabControl control;
OsuSpriteText current;
Add(control = new UserSortTabControl
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
Add(current = new OsuSpriteText());
control.Current.BindValueChanged(criteria => current.Text = $"Criteria: {criteria.NewValue}", true);
}
}
}

View File

@ -11,6 +11,8 @@ using osu.Framework.Graphics.Sprites;
using osuTK;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Sprites;
using System.ComponentModel;
using Container = osu.Framework.Graphics.Containers.Container;
namespace osu.Game.Overlays.Comments
{
@ -109,6 +111,7 @@ namespace osu.Game.Overlays.Comments
public enum CommentsSortCriteria
{
[Description(@"Recent")]
New,
Old,
Top

View File

@ -0,0 +1,19 @@
// 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.ComponentModel;
namespace osu.Game.Overlays.Home.Friends
{
public class UserSortTabControl : OverlaySortTabControl<UserSortCriteria>
{
}
public enum UserSortCriteria
{
[Description(@"Recently Active")]
LastVisit,
Rank,
Username
}
}

View File

@ -15,6 +15,8 @@ using osu.Game.Graphics.Sprites;
using osuTK.Graphics;
using osu.Game.Overlays.Comments;
using JetBrains.Annotations;
using System;
using osu.Framework.Extensions;
namespace osu.Game.Overlays
{
@ -132,7 +134,7 @@ namespace osu.Game.Overlays
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 12),
Text = value.ToString()
Text = (value as Enum)?.GetDescription() ?? value.ToString()
}
}
});