mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Simplify and rename filter methods
This commit is contained in:
parent
3c406662ed
commit
df7e795aa3
@ -67,7 +67,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
value.Select(createCarouselSet).Where(g => g != null).ForEach(newRoot.AddChild);
|
value.Select(createCarouselSet).Where(g => g != null).ForEach(newRoot.AddChild);
|
||||||
newRoot.Filter(criteria);
|
newRoot.Filter(activeCriteria);
|
||||||
}).ContinueWith(t =>
|
}).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
@ -149,7 +149,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
root.AddChild(newSet);
|
root.AddChild(newSet);
|
||||||
|
|
||||||
Filter(debounce: false);
|
applyActiveCriteria(false);
|
||||||
|
|
||||||
//check if we can/need to maintain our current selection.
|
//check if we can/need to maintain our current selection.
|
||||||
if (hadSelection)
|
if (hadSelection)
|
||||||
@ -158,7 +158,7 @@ namespace osu.Game.Screens.Select
|
|||||||
updateItems();
|
updateItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true)
|
public void SelectBeatmap(BeatmapInfo beatmap)
|
||||||
{
|
{
|
||||||
if (beatmap == null || beatmap.Hidden)
|
if (beatmap == null || beatmap.Hidden)
|
||||||
{
|
{
|
||||||
@ -212,14 +212,12 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<CarouselBeatmapSet> getVisibleSets() => beatmapSets.Where(select => !select.Filtered);
|
|
||||||
|
|
||||||
public void SelectNextRandom()
|
public void SelectNextRandom()
|
||||||
{
|
{
|
||||||
if (!beatmapSets.Any())
|
if (!beatmapSets.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var visible = getVisibleSets().ToList();
|
var visible = beatmapSets.Where(select => !select.Filtered).ToList();
|
||||||
if (!visible.Any())
|
if (!visible.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -269,28 +267,33 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FilterCriteria criteria = new FilterCriteria();
|
private FilterCriteria activeCriteria = new FilterCriteria();
|
||||||
|
|
||||||
protected ScheduledDelegate FilterTask;
|
protected ScheduledDelegate FilterTask;
|
||||||
|
|
||||||
public bool AllowSelection = true;
|
public bool AllowSelection = true;
|
||||||
|
|
||||||
public void FlushPendingFilters()
|
public void FlushPendingFilterOperations()
|
||||||
{
|
{
|
||||||
if (FilterTask?.Completed == false)
|
if (FilterTask?.Completed == false)
|
||||||
Filter(debounce: false);
|
applyActiveCriteria(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Filter(FilterCriteria newCriteria = null, bool debounce = true)
|
public void Filter(FilterCriteria newCriteria, bool debounce = true)
|
||||||
{
|
{
|
||||||
if (newCriteria != null)
|
if (newCriteria != null)
|
||||||
criteria = newCriteria;
|
activeCriteria = newCriteria;
|
||||||
|
|
||||||
|
applyActiveCriteria(debounce);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyActiveCriteria(bool debounce)
|
||||||
|
{
|
||||||
Action perform = delegate
|
Action perform = delegate
|
||||||
{
|
{
|
||||||
FilterTask = null;
|
FilterTask = null;
|
||||||
|
|
||||||
root.Filter(criteria);
|
root.Filter(activeCriteria);
|
||||||
updateItems();
|
updateItems();
|
||||||
|
|
||||||
ScrollToSelected(false);
|
ScrollToSelected(false);
|
||||||
|
@ -212,7 +212,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
// if we have a pending filter operation, we want to run it now.
|
// if we have a pending filter operation, we want to run it now.
|
||||||
// it could change selection (ie. if the ruleset has been changed).
|
// it could change selection (ie. if the ruleset has been changed).
|
||||||
carousel.FlushPendingFilters();
|
carousel.FlushPendingFilterOperations();
|
||||||
|
|
||||||
if (selectionChangedDebounce?.Completed == false)
|
if (selectionChangedDebounce?.Completed == false)
|
||||||
{
|
{
|
||||||
@ -447,7 +447,7 @@ namespace osu.Game.Screens.Select
|
|||||||
private void carouselBeatmapsLoaded()
|
private void carouselBeatmapsLoaded()
|
||||||
{
|
{
|
||||||
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
||||||
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false);
|
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
|
||||||
else
|
else
|
||||||
carousel.SelectNextRandom();
|
carousel.SelectNextRandom();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user