1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 22:22:59 +08:00

Only allow selecting beatmaps within 30s length

This commit is contained in:
Dan Balasescu 2024-12-24 17:57:59 +09:00
parent 638d959c5c
commit 7777c44775
No known key found for this signature in database
2 changed files with 22 additions and 4 deletions

View File

@ -517,7 +517,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
{ {
AllowReordering = false, AllowReordering = false,
AllowEditing = true, AllowEditing = true,
RequestEdit = openStyleSelection RequestEdit = _ => openStyleSelection()
}; };
} }
@ -541,12 +541,12 @@ namespace osu.Game.Screens.OnlinePlay.Match
return selectedItemWithOverride; return selectedItemWithOverride;
} }
private void openStyleSelection(PlaylistItem item) private void openStyleSelection()
{ {
if (!this.IsCurrentScreen()) if (SelectedItem.Value == null || !this.IsCurrentScreen())
return; 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) if (SelectedItem.Value?.BeatmapSetId == null || SelectedItem.Value.BeatmapSetId != beatmap.BeatmapSet?.OnlineID)
return; return;

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
@ -67,16 +68,33 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
private partial class DifficultySelectFilterControl : FilterControl private partial class DifficultySelectFilterControl : FilterControl
{ {
private readonly PlaylistItem item; private readonly PlaylistItem item;
private double itemLength;
public DifficultySelectFilterControl(PlaylistItem item) public DifficultySelectFilterControl(PlaylistItem item)
{ {
this.item = 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() public override FilterCriteria CreateCriteria()
{ {
var criteria = base.CreateCriteria(); var criteria = base.CreateCriteria();
// Must be from the same set as the playlist item.
criteria.BeatmapSetId = item.BeatmapSetId; 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; return criteria;
} }
} }