diff --git a/osu.Game/Screens/Select/Filter/GroupMode.cs b/osu.Game/Screens/Select/Filter/GroupMode.cs index a0e343b164..5b7a1c332e 100644 --- a/osu.Game/Screens/Select/Filter/GroupMode.cs +++ b/osu.Game/Screens/Select/Filter/GroupMode.cs @@ -7,7 +7,6 @@ namespace osu.Game.Screens.Select.Filter { public enum GroupMode { - None = 0, [Description("All")] All, [Description("Artist")] diff --git a/osu.Game/Screens/Select/Filter/SortMode.cs b/osu.Game/Screens/Select/Filter/SortMode.cs index d0b7f3e614..2a7d62a623 100644 --- a/osu.Game/Screens/Select/Filter/SortMode.cs +++ b/osu.Game/Screens/Select/Filter/SortMode.cs @@ -7,7 +7,6 @@ namespace osu.Game.Screens.Select.Filter { public enum SortMode { - None = 0, [Description("Artist")] Artist, [Description("Author")] diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 3ab65f3d42..c8e85e4992 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -2,9 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Allocation; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; @@ -36,6 +36,23 @@ namespace osu.Game.Screens.Select } } + private GroupMode group = GroupMode.All; + public GroupMode Group { + get { return group; } + set + { + if (group != value) + { + group = value; + FilterChanged?.Invoke(); + } + } + } + + private TabControl groupTabs; + private TabControl sortTabs; + private OsuSpriteText spriteText; + public Action Exit; private SearchTextBox searchTextBox; @@ -72,10 +89,61 @@ namespace osu.Game.Screens.Select }, Exit = () => Exit?.Invoke(), }, - new GroupSortTabs() + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Colour = OsuColour.Gray(80), + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Position = new Vector2(0, 23) + }, + groupTabs = new FilterTabControl + { + Width = 230, + AutoSort = true + }, + new Container + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Children = new Drawable[] + { + spriteText = new OsuSpriteText + { + Font = @"Exo2.0-Bold", + Text = "Sort results by", + TextSize = 14, + Margin = new MarginPadding + { + Top = 5, + Bottom = 5 + }, + }, + sortTabs = new FilterTabControl(87) + { + Width = 191, + AutoSort = true + } + } + } + } + } } } }; + + groupTabs.PinTab(GroupMode.All); + groupTabs.PinTab(GroupMode.RecentlyPlayed); + groupTabs.ValueChanged += (sender, value) => Group = value; + sortTabs.ValueChanged += (sender, value) => Sort = value; } public void Deactivate() @@ -89,66 +157,10 @@ namespace osu.Game.Screens.Select searchTextBox.HoldFocus = true; } - private class GroupSortTabs : Container + [BackgroundDependencyLoader] + private void load(OsuColour colours) { - private TabControl groupTabs; - private TabControl sortTabs; - private OsuSpriteText spriteText; - - public GroupSortTabs() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.X, - Height = 1, - Colour = OsuColour.Gray(80), - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Position = new Vector2(0, 23) - }, - groupTabs = new FilterTabControl - { - Width = 230, - AutoSort = true - }, - new Container - { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Children = new Drawable[] - { - spriteText = new OsuSpriteText - { - Font = @"Exo2.0-Bold", - Text = "Sort results by", - TextSize = 14, - Margin = new MarginPadding - { - Top = 5, - Bottom = 5 - }, - }, - sortTabs = new FilterTabControl(87) - { - Width = 191, - AutoSort = true - } - } - } - }; - groupTabs.PinTab(GroupMode.All); - groupTabs.PinTab(GroupMode.RecentlyPlayed); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) { - spriteText.Colour = colours.GreenLight; - } + spriteText.Colour = colours.GreenLight; } } } \ No newline at end of file diff --git a/osu.Game/Screens/Select/Tab/FilterTabControl.cs b/osu.Game/Screens/Select/Tab/FilterTabControl.cs index 5dd0c24ba1..3f2e0d9a8e 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabControl.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabControl.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Graphics.UserInterface.Tab; namespace osu.Game.Screens.Select.Tab @@ -13,6 +14,11 @@ namespace osu.Game.Screens.Select.Tab public FilterTabControl(float offset = 0) : base(offset) { + if (!typeof(T).IsEnum) + throw new InvalidOperationException("FilterTabControl only supports enums as the generic type argument"); + + foreach (var val in (T[])Enum.GetValues(typeof(T))) + AddTab(val); } } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs index df96711e0c..5f56a8aa8b 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs @@ -34,19 +34,6 @@ namespace osu.Game.Screens.Select.Tab ContentBackground.Colour = Color4.Black.Opacity(0.9f); ScrollContainer.ScrollDraggerVisible = false; DropDownItemsContainer.Padding = new MarginPadding { Left = 5, Bottom = 7, Right = 5, Top = 7 }; - - if (!typeof(T).IsEnum) - throw new InvalidOperationException("TabControl only supports enums as the generic type argument"); - - List> items = new List>(); - foreach (var val in (T[])Enum.GetValues(typeof(T))) - { - if (!val.Equals(default(T))) - items.Add(new KeyValuePair((val as Enum)?.GetDescription(), val)); - } - - Items = items; - // TODO: ValueChanged Handling } protected override void AnimateOpen()