mirror of
https://github.com/ppy/osu
synced 2025-01-29 01:03:01 +00:00
Merge pull request #5816 from Game4all/select-filters-persistence
Save user's group and sort filter choices Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
70a3183b73
@ -15,6 +15,7 @@ using osu.Framework.MathUtils;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@ -79,8 +80,12 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, defaultBeatmap = Beatmap.Default));
|
||||
|
||||
Beatmap.SetDefault();
|
||||
|
||||
Dependencies.Cache(config = new OsuConfigManager(LocalStorage));
|
||||
}
|
||||
|
||||
private OsuConfigManager config;
|
||||
|
||||
[SetUp]
|
||||
public virtual void SetUp() => Schedule(() =>
|
||||
{
|
||||
@ -111,13 +116,15 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
||||
|
||||
AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
|
||||
AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
|
||||
AddStep(@"Sort by Author", delegate { songSelect.FilterControl.Sort = SortMode.Author; });
|
||||
AddStep(@"Sort by DateAdded", delegate { songSelect.FilterControl.Sort = SortMode.DateAdded; });
|
||||
AddStep(@"Sort by BPM", delegate { songSelect.FilterControl.Sort = SortMode.BPM; });
|
||||
AddStep(@"Sort by Length", delegate { songSelect.FilterControl.Sort = SortMode.Length; });
|
||||
AddStep(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; });
|
||||
var sortMode = config.GetBindable<SortMode>(OsuSetting.SongSelectSortingMode);
|
||||
|
||||
AddStep(@"Sort by Artist", delegate { sortMode.Value = SortMode.Artist; });
|
||||
AddStep(@"Sort by Title", delegate { sortMode.Value = SortMode.Title; });
|
||||
AddStep(@"Sort by Author", delegate { sortMode.Value = SortMode.Author; });
|
||||
AddStep(@"Sort by DateAdded", delegate { sortMode.Value = SortMode.DateAdded; });
|
||||
AddStep(@"Sort by BPM", delegate { sortMode.Value = SortMode.BPM; });
|
||||
AddStep(@"Sort by Length", delegate { sortMode.Value = SortMode.Length; });
|
||||
AddStep(@"Sort by Difficulty", delegate { sortMode.Value = SortMode.Difficulty; });
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Platform;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
|
||||
namespace osu.Game.Configuration
|
||||
{
|
||||
@ -25,6 +26,9 @@ namespace osu.Game.Configuration
|
||||
Set(OsuSetting.DisplayStarsMinimum, 0.0, 0, 10, 0.1);
|
||||
Set(OsuSetting.DisplayStarsMaximum, 10.0, 0, 10, 0.1);
|
||||
|
||||
Set(OsuSetting.SongSelectGroupingMode, GroupMode.All);
|
||||
Set(OsuSetting.SongSelectSortingMode, SortMode.Title);
|
||||
|
||||
Set(OsuSetting.RandomSelectAlgorithm, RandomSelectAlgorithm.RandomPermutation);
|
||||
|
||||
Set(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2, 1);
|
||||
@ -150,6 +154,8 @@ namespace osu.Game.Configuration
|
||||
SaveUsername,
|
||||
DisplayStarsMinimum,
|
||||
DisplayStarsMaximum,
|
||||
SongSelectGroupingMode,
|
||||
SongSelectSortingMode,
|
||||
RandomSelectAlgorithm,
|
||||
ShowFpsDisplay,
|
||||
ChatDisplayHeight,
|
||||
|
@ -29,40 +29,14 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private readonly TabControl<GroupMode> groupTabs;
|
||||
|
||||
private SortMode sort = SortMode.Title;
|
||||
private Bindable<SortMode> sortMode;
|
||||
|
||||
public SortMode Sort
|
||||
{
|
||||
get => sort;
|
||||
set
|
||||
{
|
||||
if (sort != value)
|
||||
{
|
||||
sort = value;
|
||||
FilterChanged?.Invoke(CreateCriteria());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GroupMode group = GroupMode.All;
|
||||
|
||||
public GroupMode Group
|
||||
{
|
||||
get => group;
|
||||
set
|
||||
{
|
||||
if (group != value)
|
||||
{
|
||||
group = value;
|
||||
FilterChanged?.Invoke(CreateCriteria());
|
||||
}
|
||||
}
|
||||
}
|
||||
private Bindable<GroupMode> groupMode;
|
||||
|
||||
public FilterCriteria CreateCriteria() => new FilterCriteria
|
||||
{
|
||||
Group = group,
|
||||
Sort = sort,
|
||||
Group = groupMode.Value,
|
||||
Sort = sortMode.Value,
|
||||
SearchText = searchTextBox.Text,
|
||||
AllowConvertedBeatmaps = showConverted.Value,
|
||||
Ruleset = ruleset.Value
|
||||
@ -122,7 +96,6 @@ namespace osu.Game.Screens.Select
|
||||
Height = 24,
|
||||
Width = 0.5f,
|
||||
AutoSort = true,
|
||||
Current = { Value = GroupMode.Title }
|
||||
},
|
||||
//spriteText = new OsuSpriteText
|
||||
//{
|
||||
@ -141,7 +114,6 @@ namespace osu.Game.Screens.Select
|
||||
Width = 0.5f,
|
||||
Height = 24,
|
||||
AutoSort = true,
|
||||
Current = { Value = SortMode.Title }
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -153,8 +125,6 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
groupTabs.PinItem(GroupMode.All);
|
||||
groupTabs.PinItem(GroupMode.RecentlyPlayed);
|
||||
groupTabs.Current.ValueChanged += group => Group = group.NewValue;
|
||||
sortTabs.Current.ValueChanged += sort => Sort = sort.NewValue;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
@ -184,7 +154,18 @@ namespace osu.Game.Screens.Select
|
||||
showConverted.ValueChanged += _ => updateCriteria();
|
||||
|
||||
ruleset.BindTo(parentRuleset);
|
||||
ruleset.BindValueChanged(_ => updateCriteria(), true);
|
||||
ruleset.BindValueChanged(_ => updateCriteria());
|
||||
|
||||
sortMode = config.GetBindable<SortMode>(OsuSetting.SongSelectSortingMode);
|
||||
groupMode = config.GetBindable<GroupMode>(OsuSetting.SongSelectGroupingMode);
|
||||
|
||||
sortTabs.Current.BindTo(sortMode);
|
||||
groupTabs.Current.BindTo(groupMode);
|
||||
|
||||
groupMode.BindValueChanged(_ => updateCriteria());
|
||||
sortMode.BindValueChanged(_ => updateCriteria());
|
||||
|
||||
updateCriteria();
|
||||
}
|
||||
|
||||
private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria());
|
||||
|
Loading…
Reference in New Issue
Block a user