mirror of https://github.com/ppy/osu
Add flow to allow MatchSubScreen to handle beatmap presentation locally
This commit is contained in:
parent
6e75ebbb06
commit
36e1fb6da8
|
@ -381,9 +381,16 @@ public void PresentBeatmap(BeatmapSetInfo beatmap, Predicate<BeatmapInfo> diffic
|
|||
?? beatmaps.FirstOrDefault(b => b.Ruleset.Equals(Ruleset.Value))
|
||||
?? beatmaps.First();
|
||||
|
||||
Ruleset.Value = selection.Ruleset;
|
||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(selection);
|
||||
}, validScreens: new[] { typeof(SongSelect) });
|
||||
if (screen is IHandlePresentBeatmap presentableScreen)
|
||||
{
|
||||
presentableScreen.PresentBeatmap(BeatmapManager.GetWorkingBeatmap(selection), selection.Ruleset);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ruleset.Value = selection.Ruleset;
|
||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(selection);
|
||||
}
|
||||
}, validScreens: new[] { typeof(SongSelect), typeof(IHandlePresentBeatmap) });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
|
@ -30,9 +28,6 @@ internal class PerformFromMenuRunner : Component
|
|||
[Resolved]
|
||||
private DialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private OsuGame game { get; set; }
|
||||
|
||||
|
@ -90,7 +85,7 @@ private bool findValidTarget(IScreen current)
|
|||
var type = current.GetType();
|
||||
|
||||
// check if we are already at a valid target screen.
|
||||
if (validScreens.Any(t => t.IsAssignableFrom(type)) && !beatmap.Disabled)
|
||||
if (validScreens.Any(t => t.IsAssignableFrom(type)))
|
||||
{
|
||||
finalAction(current);
|
||||
Cancel();
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Select;
|
||||
|
||||
|
@ -19,6 +21,23 @@ public class MultiplayerMatchSongSelect : OnlinePlaySongSelect
|
|||
|
||||
private LoadingLayer loadingLayer;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new instance of multiplayer song select.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">An optional initial beatmap selection to perform.</param>
|
||||
/// <param name="ruleset">An optional initial ruleset selection to perform.</param>
|
||||
public MultiplayerMatchSongSelect(WorkingBeatmap beatmap = null, RulesetInfo ruleset = null)
|
||||
{
|
||||
if (beatmap != null || ruleset != null)
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
if (beatmap != null) Beatmap.Value = beatmap;
|
||||
if (ruleset != null) Ruleset.Value = ruleset;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
|
|
|
@ -12,9 +12,11 @@
|
|||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Match;
|
||||
|
@ -29,7 +31,7 @@
|
|||
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
{
|
||||
[Cached]
|
||||
public class MultiplayerMatchSubScreen : RoomSubScreen
|
||||
public class MultiplayerMatchSubScreen : RoomSubScreen, IHandlePresentBeatmap
|
||||
{
|
||||
public override string Title { get; }
|
||||
|
||||
|
@ -394,5 +396,13 @@ protected override void Dispose(bool isDisposing)
|
|||
|
||||
modSettingChangeTracker?.Dispose();
|
||||
}
|
||||
|
||||
public void PresentBeatmap(WorkingBeatmap beatmap, RulesetInfo ruleset)
|
||||
{
|
||||
if (!this.IsCurrentScreen())
|
||||
return;
|
||||
|
||||
this.Push(new MultiplayerMatchSongSelect(beatmap, ruleset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue