mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 11:43:22 +08:00
Only allow selecting beatmaps within 30s length
This commit is contained in:
parent
638d959c5c
commit
7777c44775
@ -517,7 +517,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
AllowReordering = false,
|
||||
AllowEditing = true,
|
||||
RequestEdit = openStyleSelection
|
||||
RequestEdit = _ => openStyleSelection()
|
||||
};
|
||||
}
|
||||
|
||||
@ -541,12 +541,12 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
return selectedItemWithOverride;
|
||||
}
|
||||
|
||||
private void openStyleSelection(PlaylistItem item)
|
||||
private void openStyleSelection()
|
||||
{
|
||||
if (!this.IsCurrentScreen())
|
||||
if (SelectedItem.Value == null || !this.IsCurrentScreen())
|
||||
return;
|
||||
|
||||
this.Push(new MultiplayerMatchStyleSelect(Room, item, (beatmap, ruleset) =>
|
||||
this.Push(new MultiplayerMatchStyleSelect(Room, SelectedItem.Value, (beatmap, ruleset) =>
|
||||
{
|
||||
if (SelectedItem.Value?.BeatmapSetId == null || SelectedItem.Value.BeatmapSetId != beatmap.BeatmapSet?.OnlineID)
|
||||
return;
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Select;
|
||||
@ -67,16 +68,33 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
private partial class DifficultySelectFilterControl : FilterControl
|
||||
{
|
||||
private readonly PlaylistItem item;
|
||||
private double itemLength;
|
||||
|
||||
public DifficultySelectFilterControl(PlaylistItem item)
|
||||
{
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RealmAccess realm)
|
||||
{
|
||||
int beatmapId = item.Beatmap.OnlineID;
|
||||
itemLength = realm.Run(r => r.All<BeatmapInfo>().FirstOrDefault(b => b.OnlineID == beatmapId)?.Length ?? 0);
|
||||
}
|
||||
|
||||
public override FilterCriteria CreateCriteria()
|
||||
{
|
||||
var criteria = base.CreateCriteria();
|
||||
|
||||
// Must be from the same set as the playlist item.
|
||||
criteria.BeatmapSetId = item.BeatmapSetId;
|
||||
|
||||
// Must be within 30s of the playlist item.
|
||||
criteria.Length.Min = itemLength - 30000;
|
||||
criteria.Length.Max = itemLength + 30000;
|
||||
criteria.Length.IsLowerInclusive = true;
|
||||
criteria.Length.IsUpperInclusive = true;
|
||||
|
||||
return criteria;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user