From 0cfe1ac823e2e9414637405e97024f5cbd57f2ec Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 24 Feb 2020 05:47:21 +0300 Subject: [PATCH] Implement UserSortTabControl component --- .../TestSceneUserSortTabControl.cs | 41 +++++++++++++++++++ osu.Game/Overlays/Comments/CommentsHeader.cs | 3 ++ .../Home/Friends/UserSortTabControl.cs | 19 +++++++++ osu.Game/Overlays/OverlaySortTabControl.cs | 4 +- 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneUserSortTabControl.cs create mode 100644 osu.Game/Overlays/Home/Friends/UserSortTabControl.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneUserSortTabControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneUserSortTabControl.cs new file mode 100644 index 0000000000..de7a78d355 --- /dev/null +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneUserSortTabControl.cs @@ -0,0 +1,41 @@ +// Copyright (c) ppy Pty Ltd . 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 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); + } + } +} diff --git a/osu.Game/Overlays/Comments/CommentsHeader.cs b/osu.Game/Overlays/Comments/CommentsHeader.cs index 1aa40201f1..ff5602e289 100644 --- a/osu.Game/Overlays/Comments/CommentsHeader.cs +++ b/osu.Game/Overlays/Comments/CommentsHeader.cs @@ -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 diff --git a/osu.Game/Overlays/Home/Friends/UserSortTabControl.cs b/osu.Game/Overlays/Home/Friends/UserSortTabControl.cs new file mode 100644 index 0000000000..2479fa4638 --- /dev/null +++ b/osu.Game/Overlays/Home/Friends/UserSortTabControl.cs @@ -0,0 +1,19 @@ +// Copyright (c) ppy Pty Ltd . 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 + { + } + + public enum UserSortCriteria + { + [Description(@"Recently Active")] + LastVisit, + Rank, + Username + } +} diff --git a/osu.Game/Overlays/OverlaySortTabControl.cs b/osu.Game/Overlays/OverlaySortTabControl.cs index 5a713ab08e..395f3aec4c 100644 --- a/osu.Game/Overlays/OverlaySortTabControl.cs +++ b/osu.Game/Overlays/OverlaySortTabControl.cs @@ -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() } } });