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:
parent
638d959c5c
commit
7777c44775
@ -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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user