1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-13 20:33:35 +08:00

Merge pull request #32551 from smoogipoo/basic-freestyle-validation

Validate freestyle selection post-selection
This commit is contained in:
Bartłomiej Dach
2025-03-24 14:08:20 +01:00
committed by GitHub
Unverified
3 changed files with 40 additions and 5 deletions
@@ -60,6 +60,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
return false;
}
if (!base.OnStart())
return false;
selectionOperation = operationTracker.BeginOperation();
client.ChangeUserStyle(Beatmap.Value.BeatmapInfo.OnlineID, Ruleset.Value.OnlineID)
@@ -7,6 +7,7 @@ using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.Rooms;
@@ -43,6 +44,40 @@ namespace osu.Game.Screens.OnlinePlay
LeftArea.Padding = new MarginPadding { Top = Header.HEIGHT };
}
protected override bool OnStart()
{
FilterCriteria criteria = FilterControl.CreateCriteria();
// Beatmaps with too different of a duration are filtered away; this is just a final safety.
if (!criteria.Length.IsInRange(Beatmap.Value.BeatmapInfo.Length))
{
Logger.Log("The selected beatmap's duration differs too much from the host's selection.", level: LogLevel.Error);
return false;
}
// Beatmaps without a valid online ID are filtered away; this is just a final safety.
if (Beatmap.Value.BeatmapInfo.OnlineID < 0)
{
Logger.Log("The selected beatmap is not available online.", level: LogLevel.Error);
return false;
}
// Beatmaps from different sets are filtered away; this is just a final safety.
if (Beatmap.Value.BeatmapSetInfo.OnlineID != criteria.BeatmapSetId)
{
Logger.Log("The selected beatmap is from a different beatmap set.", level: LogLevel.Error);
return false;
}
if (Ruleset.Value.OnlineID < 0)
{
Logger.Log("The selected ruleset is not available online.", level: LogLevel.Error);
return false;
}
return true;
}
protected override FilterControl CreateFilterControl() => new DifficultySelectFilterControl(item);
protected override IEnumerable<(FooterButton button, OverlayContainer? overlay)> CreateSongSelectFooterButtons()
@@ -21,15 +21,12 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
protected override bool OnStart()
{
// Beatmaps without a valid online ID are filtered away; this is just a final safety.
if (base.Beatmap.Value.BeatmapInfo.OnlineID < 0)
return false;
if (base.Ruleset.Value.OnlineID < 0)
if (!base.OnStart())
return false;
Beatmap.Value = base.Beatmap.Value.BeatmapInfo;
Ruleset.Value = base.Ruleset.Value;
this.Exit();
return true;
}