mirror of
https://github.com/osukey/osukey.git
synced 2025-05-19 04:27:35 +09:00
Sort on SortTabs ValueChanged
This commit is contained in:
parent
755fb260db
commit
20e2e7a8c8
@ -7,7 +7,6 @@ namespace osu.Game.Screens.Select.Filter
|
|||||||
{
|
{
|
||||||
public enum GroupMode
|
public enum GroupMode
|
||||||
{
|
{
|
||||||
None = 0,
|
|
||||||
[Description("All")]
|
[Description("All")]
|
||||||
All,
|
All,
|
||||||
[Description("Artist")]
|
[Description("Artist")]
|
||||||
|
@ -7,7 +7,6 @@ namespace osu.Game.Screens.Select.Filter
|
|||||||
{
|
{
|
||||||
public enum SortMode
|
public enum SortMode
|
||||||
{
|
{
|
||||||
None = 0,
|
|
||||||
[Description("Artist")]
|
[Description("Artist")]
|
||||||
Artist,
|
Artist,
|
||||||
[Description("Author")]
|
[Description("Author")]
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
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<GroupMode> groupTabs;
|
||||||
|
private TabControl<SortMode> sortTabs;
|
||||||
|
private OsuSpriteText spriteText;
|
||||||
|
|
||||||
public Action Exit;
|
public Action Exit;
|
||||||
|
|
||||||
private SearchTextBox searchTextBox;
|
private SearchTextBox searchTextBox;
|
||||||
@ -72,33 +89,10 @@ namespace osu.Game.Screens.Select
|
|||||||
},
|
},
|
||||||
Exit = () => Exit?.Invoke(),
|
Exit = () => Exit?.Invoke(),
|
||||||
},
|
},
|
||||||
new GroupSortTabs()
|
new Container
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Deactivate()
|
|
||||||
{
|
{
|
||||||
searchTextBox.HoldFocus = false;
|
RelativeSizeAxes = Axes.X,
|
||||||
searchTextBox.TriggerFocusLost();
|
AutoSizeAxes = Axes.Y,
|
||||||
}
|
|
||||||
|
|
||||||
public void Activate()
|
|
||||||
{
|
|
||||||
searchTextBox.HoldFocus = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class GroupSortTabs : Container
|
|
||||||
{
|
|
||||||
private TabControl<GroupMode> groupTabs;
|
|
||||||
private TabControl<SortMode> sortTabs;
|
|
||||||
private OsuSpriteText spriteText;
|
|
||||||
|
|
||||||
public GroupSortTabs()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
@ -140,15 +134,33 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
groupTabs.PinTab(GroupMode.All);
|
groupTabs.PinTab(GroupMode.All);
|
||||||
groupTabs.PinTab(GroupMode.RecentlyPlayed);
|
groupTabs.PinTab(GroupMode.RecentlyPlayed);
|
||||||
|
groupTabs.ValueChanged += (sender, value) => Group = value;
|
||||||
|
sortTabs.ValueChanged += (sender, value) => Sort = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Deactivate()
|
||||||
|
{
|
||||||
|
searchTextBox.HoldFocus = false;
|
||||||
|
searchTextBox.TriggerFocusLost();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Activate()
|
||||||
|
{
|
||||||
|
searchTextBox.HoldFocus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours) {
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
spriteText.Colour = colours.GreenLight;
|
spriteText.Colour = colours.GreenLight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Graphics.UserInterface.Tab;
|
using osu.Framework.Graphics.UserInterface.Tab;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Tab
|
namespace osu.Game.Screens.Select.Tab
|
||||||
@ -13,6 +14,11 @@ namespace osu.Game.Screens.Select.Tab
|
|||||||
|
|
||||||
public FilterTabControl(float offset = 0) : base(offset)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,19 +34,6 @@ namespace osu.Game.Screens.Select.Tab
|
|||||||
ContentBackground.Colour = Color4.Black.Opacity(0.9f);
|
ContentBackground.Colour = Color4.Black.Opacity(0.9f);
|
||||||
ScrollContainer.ScrollDraggerVisible = false;
|
ScrollContainer.ScrollDraggerVisible = false;
|
||||||
DropDownItemsContainer.Padding = new MarginPadding { Left = 5, Bottom = 7, Right = 5, Top = 7 };
|
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<KeyValuePair<string, T>> items = new List<KeyValuePair<string, T>>();
|
|
||||||
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
|
||||||
{
|
|
||||||
if (!val.Equals(default(T)))
|
|
||||||
items.Add(new KeyValuePair<string, T>((val as Enum)?.GetDescription(), val));
|
|
||||||
}
|
|
||||||
|
|
||||||
Items = items;
|
|
||||||
// TODO: ValueChanged Handling
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AnimateOpen()
|
protected override void AnimateOpen()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user