1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:47:26 +08:00

Merge branch 'master' into decouple-api-room-scoreinfo

This commit is contained in:
Dan Balasescu 2019-12-05 12:43:43 +09:00 committed by GitHub
commit 36c734c4c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 19 deletions

View File

@ -113,11 +113,11 @@ namespace osu.Game.Tests.Visual.Gameplay
}
[Test]
[Ignore("Will be resolved with merge of https://github.com/ppy/osu/pull/6992")]
public void TestExitTooSoon()
{
pauseAndConfirm();
AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
pauseAndConfirm();
resume();
AddStep("exit too soon", () => Player.Exit());
@ -177,7 +177,9 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestExitFromGameplay()
{
AddStep("exit", () => Player.Exit());
confirmPaused();
AddStep("exit", () => Player.Exit());
confirmExited();
}
@ -213,9 +215,10 @@ namespace osu.Game.Tests.Visual.Gameplay
}
[Test]
[Ignore("Will be resolved with merge of https://github.com/ppy/osu/pull/6992")]
public void TestRestartAfterResume()
{
AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
pauseAndConfirm();
resumeAndConfirm();
restart();

View File

@ -536,6 +536,12 @@ namespace osu.Game.Screens.Play
return true;
}
if (canPause)
{
Pause();
return true;
}
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
// as we are no longer the current screen, we cannot guarantee the track is still usable.
GameplayClockContainer.StopUsingBeatmapClock();

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Screens.Select.Filter;
@ -29,28 +30,29 @@ namespace osu.Game.Screens.Select.Carousel
Beatmap.RulesetID == criteria.Ruleset.ID ||
(Beatmap.RulesetID == 0 && criteria.Ruleset.ID > 0 && criteria.AllowConvertedBeatmaps);
match &= criteria.StarDifficulty.IsInRange(Beatmap.StarDifficulty);
match &= criteria.ApproachRate.IsInRange(Beatmap.BaseDifficulty.ApproachRate);
match &= criteria.DrainRate.IsInRange(Beatmap.BaseDifficulty.DrainRate);
match &= criteria.CircleSize.IsInRange(Beatmap.BaseDifficulty.CircleSize);
match &= criteria.Length.IsInRange(Beatmap.Length);
match &= criteria.BPM.IsInRange(Beatmap.BPM);
match &= !criteria.StarDifficulty.HasFilter || criteria.StarDifficulty.IsInRange(Beatmap.StarDifficulty);
match &= !criteria.ApproachRate.HasFilter || criteria.ApproachRate.IsInRange(Beatmap.BaseDifficulty.ApproachRate);
match &= !criteria.DrainRate.HasFilter || criteria.DrainRate.IsInRange(Beatmap.BaseDifficulty.DrainRate);
match &= !criteria.CircleSize.HasFilter || criteria.CircleSize.IsInRange(Beatmap.BaseDifficulty.CircleSize);
match &= !criteria.Length.HasFilter || criteria.Length.IsInRange(Beatmap.Length);
match &= !criteria.BPM.HasFilter || criteria.BPM.IsInRange(Beatmap.BPM);
match &= criteria.BeatDivisor.IsInRange(Beatmap.BeatDivisor);
match &= criteria.OnlineStatus.IsInRange(Beatmap.Status);
match &= !criteria.BeatDivisor.HasFilter || criteria.BeatDivisor.IsInRange(Beatmap.BeatDivisor);
match &= !criteria.OnlineStatus.HasFilter || criteria.OnlineStatus.IsInRange(Beatmap.Status);
match &= criteria.Creator.Matches(Beatmap.Metadata.AuthorString);
match &= criteria.Artist.Matches(Beatmap.Metadata.Artist) ||
match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(Beatmap.Metadata.AuthorString);
match &= !criteria.Artist.HasFilter || criteria.Artist.Matches(Beatmap.Metadata.Artist) ||
criteria.Artist.Matches(Beatmap.Metadata.ArtistUnicode);
if (match)
{
var terms = new List<string>();
terms.AddRange(Beatmap.Metadata.SearchableTerms);
terms.Add(Beatmap.Version);
foreach (var criteriaTerm in criteria.SearchTerms)
{
match &=
Beatmap.Metadata.SearchableTerms.Any(term => term.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0) ||
Beatmap.Version.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0;
}
match &= terms.Any(term => term.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0);
}
Filtered.Value = !match;

View File

@ -46,6 +46,8 @@ namespace osu.Game.Screens.Select
public struct OptionalRange<T> : IEquatable<OptionalRange<T>>
where T : struct, IComparable
{
public bool HasFilter => Max != null || Min != null;
public bool IsInRange(T value)
{
if (Min != null)
@ -87,9 +89,11 @@ namespace osu.Game.Screens.Select
public struct OptionalTextFilter : IEquatable<OptionalTextFilter>
{
public bool HasFilter => !string.IsNullOrEmpty(SearchTerm);
public bool Matches(string value)
{
if (string.IsNullOrEmpty(SearchTerm))
if (!HasFilter)
return true;
// search term is guaranteed to be non-empty, so if the string we're comparing is empty, it's not matching