Instantiate ruleset criteria

This commit is contained in:
Bartłomiej Dach 2021-03-02 20:10:03 +01:00
parent 14e249a134
commit c375be6b07
2 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Diagnostics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -34,8 +35,13 @@ namespace osu.Game.Screens.Select
private Bindable<GroupMode> groupMode; private Bindable<GroupMode> groupMode;
[Resolved]
private RulesetStore rulesets { get; set; }
public FilterCriteria CreateCriteria() public FilterCriteria CreateCriteria()
{ {
Debug.Assert(ruleset.Value.ID != null);
var query = searchTextBox.Text; var query = searchTextBox.Text;
var criteria = new FilterCriteria var criteria = new FilterCriteria
@ -53,6 +59,8 @@ namespace osu.Game.Screens.Select
if (!maximumStars.IsDefault) if (!maximumStars.IsDefault)
criteria.UserStarDifficulty.Max = maximumStars.Value; criteria.UserStarDifficulty.Max = maximumStars.Value;
criteria.RulesetCriteria = rulesets.GetRuleset(ruleset.Value.ID.Value).CreateInstance().CreateRulesetFilterCriteria();
FilterQueryParser.ApplyQueries(criteria, query); FilterQueryParser.ApplyQueries(criteria, query);
return criteria; return criteria;
} }

View File

@ -8,6 +8,7 @@ using JetBrains.Annotations;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Collections; using osu.Game.Collections;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Filter;
using osu.Game.Screens.Select.Filter; using osu.Game.Screens.Select.Filter;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
@ -69,6 +70,9 @@ namespace osu.Game.Screens.Select
[CanBeNull] [CanBeNull]
public BeatmapCollection Collection; public BeatmapCollection Collection;
[CanBeNull]
public IRulesetFilterCriteria RulesetCriteria { get; set; }
public struct OptionalRange<T> : IEquatable<OptionalRange<T>> public struct OptionalRange<T> : IEquatable<OptionalRange<T>>
where T : struct where T : struct
{ {