mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 02:52:54 +08:00
Merge branch 'master' into fix-room-song-select-stuck
This commit is contained in:
commit
e7a91b3dca
@ -9,6 +9,7 @@ using osu.Framework.Screens;
|
|||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Match
|
namespace osu.Game.Screens.Multi.Match
|
||||||
@ -23,6 +24,9 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
[Resolved(typeof(Room), nameof(Room.Playlist))]
|
[Resolved(typeof(Room), nameof(Room.Playlist))]
|
||||||
protected BindableList<PlaylistItem> Playlist { get; private set; }
|
protected BindableList<PlaylistItem> Playlist { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private MusicController music { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmapManager { get; set; }
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
|
|
||||||
@ -39,6 +43,34 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
managerUpdated.BindValueChanged(beatmapUpdated);
|
managerUpdated.BindValueChanged(beatmapUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnEntering(IScreen last)
|
||||||
|
{
|
||||||
|
base.OnEntering(last);
|
||||||
|
beginHandlingTrack();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnSuspending(IScreen next)
|
||||||
|
{
|
||||||
|
endHandlingTrack();
|
||||||
|
base.OnSuspending(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnResuming(IScreen last)
|
||||||
|
{
|
||||||
|
base.OnResuming(last);
|
||||||
|
beginHandlingTrack();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnExiting(IScreen next)
|
||||||
|
{
|
||||||
|
RoomManager?.PartRoom();
|
||||||
|
Mods.Value = Array.Empty<Mod>();
|
||||||
|
|
||||||
|
endHandlingTrack();
|
||||||
|
|
||||||
|
return base.OnExiting(next);
|
||||||
|
}
|
||||||
|
|
||||||
private void selectedItemChanged()
|
private void selectedItemChanged()
|
||||||
{
|
{
|
||||||
updateWorkingBeatmap();
|
updateWorkingBeatmap();
|
||||||
@ -63,12 +95,42 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
private void beginHandlingTrack()
|
||||||
{
|
{
|
||||||
RoomManager?.PartRoom();
|
Beatmap.BindValueChanged(applyLoopingToTrack, true);
|
||||||
Mods.Value = Array.Empty<Mod>();
|
}
|
||||||
|
|
||||||
return base.OnExiting(next);
|
private void endHandlingTrack()
|
||||||
|
{
|
||||||
|
Beatmap.ValueChanged -= applyLoopingToTrack;
|
||||||
|
cancelTrackLooping();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyLoopingToTrack(ValueChangedEvent<WorkingBeatmap> _ = null)
|
||||||
|
{
|
||||||
|
if (!this.IsCurrentScreen())
|
||||||
|
return;
|
||||||
|
|
||||||
|
var track = Beatmap.Value?.Track;
|
||||||
|
|
||||||
|
if (track != null)
|
||||||
|
{
|
||||||
|
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||||
|
track.Looping = true;
|
||||||
|
|
||||||
|
music?.EnsurePlayingSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelTrackLooping()
|
||||||
|
{
|
||||||
|
var track = Beatmap?.Value?.Track;
|
||||||
|
|
||||||
|
if (track != null)
|
||||||
|
{
|
||||||
|
track.Looping = false;
|
||||||
|
track.RestartPoint = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ using osu.Framework.Graphics.Colour;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -198,8 +197,6 @@ namespace osu.Game.Screens.Multi
|
|||||||
{
|
{
|
||||||
this.FadeIn();
|
this.FadeIn();
|
||||||
waves.Show();
|
waves.Show();
|
||||||
|
|
||||||
beginHandlingTrack();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnResuming(IScreen last)
|
public override void OnResuming(IScreen last)
|
||||||
@ -209,8 +206,6 @@ namespace osu.Game.Screens.Multi
|
|||||||
|
|
||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
|
|
||||||
beginHandlingTrack();
|
|
||||||
|
|
||||||
UpdatePollingRate(isIdle.Value);
|
UpdatePollingRate(isIdle.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,8 +214,6 @@ namespace osu.Game.Screens.Multi
|
|||||||
this.ScaleTo(1.1f, 250, Easing.InSine);
|
this.ScaleTo(1.1f, 250, Easing.InSine);
|
||||||
this.FadeOut(250);
|
this.FadeOut(250);
|
||||||
|
|
||||||
endHandlingTrack();
|
|
||||||
|
|
||||||
UpdatePollingRate(isIdle.Value);
|
UpdatePollingRate(isIdle.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,8 +228,6 @@ namespace osu.Game.Screens.Multi
|
|||||||
if (screenStack.CurrentScreen != null)
|
if (screenStack.CurrentScreen != null)
|
||||||
loungeSubScreen.MakeCurrent();
|
loungeSubScreen.MakeCurrent();
|
||||||
|
|
||||||
endHandlingTrack();
|
|
||||||
|
|
||||||
base.OnExiting(next);
|
base.OnExiting(next);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -275,17 +266,6 @@ namespace osu.Game.Screens.Multi
|
|||||||
/// <returns>The created <see cref="Room"/>.</returns>
|
/// <returns>The created <see cref="Room"/>.</returns>
|
||||||
protected virtual Room CreateNewRoom() => new Room { Name = { Value = $"{api.LocalUser}'s awesome room" } };
|
protected virtual Room CreateNewRoom() => new Room { Name = { Value = $"{api.LocalUser}'s awesome room" } };
|
||||||
|
|
||||||
private void beginHandlingTrack()
|
|
||||||
{
|
|
||||||
Beatmap.BindValueChanged(updateTrack, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void endHandlingTrack()
|
|
||||||
{
|
|
||||||
cancelLooping();
|
|
||||||
Beatmap.ValueChanged -= updateTrack;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void screenPushed(IScreen lastScreen, IScreen newScreen)
|
private void screenPushed(IScreen lastScreen, IScreen newScreen)
|
||||||
{
|
{
|
||||||
subScreenChanged(lastScreen, newScreen);
|
subScreenChanged(lastScreen, newScreen);
|
||||||
@ -322,43 +302,10 @@ namespace osu.Game.Screens.Multi
|
|||||||
|
|
||||||
UpdatePollingRate(isIdle.Value);
|
UpdatePollingRate(isIdle.Value);
|
||||||
createButton.FadeTo(newScreen is LoungeSubScreen ? 1 : 0, 200);
|
createButton.FadeTo(newScreen is LoungeSubScreen ? 1 : 0, 200);
|
||||||
|
|
||||||
updateTrack();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IScreen CurrentSubScreen => screenStack.CurrentScreen;
|
protected IScreen CurrentSubScreen => screenStack.CurrentScreen;
|
||||||
|
|
||||||
private void updateTrack(ValueChangedEvent<WorkingBeatmap> _ = null)
|
|
||||||
{
|
|
||||||
if (screenStack.CurrentScreen is RoomSubScreen)
|
|
||||||
{
|
|
||||||
var track = Beatmap.Value?.Track;
|
|
||||||
|
|
||||||
if (track != null)
|
|
||||||
{
|
|
||||||
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
|
||||||
track.Looping = true;
|
|
||||||
|
|
||||||
music?.EnsurePlayingSomething();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cancelLooping();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cancelLooping()
|
|
||||||
{
|
|
||||||
var track = Beatmap?.Value?.Track;
|
|
||||||
|
|
||||||
if (track != null)
|
|
||||||
{
|
|
||||||
track.Looping = false;
|
|
||||||
track.RestartPoint = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract RoomManager CreateRoomManager();
|
protected abstract RoomManager CreateRoomManager();
|
||||||
|
|
||||||
protected abstract LoungeSubScreen CreateLounge();
|
protected abstract LoungeSubScreen CreateLounge();
|
||||||
|
@ -86,7 +86,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
Logger.Log(message, LoggingTarget.Runtime, LogLevel.Important);
|
Logger.Log(message, LoggingTarget.Runtime, LogLevel.Important);
|
||||||
|
|
||||||
startedEvent.Set();
|
startedEvent.Set();
|
||||||
Schedule(PerformImmediateExit);
|
Schedule(() => PerformExit(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
@ -386,7 +386,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (!this.IsCurrentScreen()) return;
|
if (!this.IsCurrentScreen()) return;
|
||||||
|
|
||||||
fadeOut(true);
|
fadeOut(true);
|
||||||
PerformImmediateExit();
|
PerformExit(true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, },
|
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, },
|
||||||
@ -458,20 +458,30 @@ namespace osu.Game.Screens.Play
|
|||||||
return playable;
|
return playable;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void PerformImmediateExit()
|
/// <summary>
|
||||||
|
/// Exits the <see cref="Player"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userRequested">
|
||||||
|
/// Whether the exit is requested by the user, or a higher-level game component.
|
||||||
|
/// Pausing is allowed only in the former case.
|
||||||
|
/// </param>
|
||||||
|
protected void PerformExit(bool userRequested)
|
||||||
{
|
{
|
||||||
// if a restart has been requested, cancel any pending completion (user has shown intent to restart).
|
// if a restart has been requested, cancel any pending completion (user has shown intent to restart).
|
||||||
completionProgressDelegate?.Cancel();
|
completionProgressDelegate?.Cancel();
|
||||||
|
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
|
|
||||||
performUserRequestedExit();
|
if (!this.IsCurrentScreen()) return;
|
||||||
|
|
||||||
|
if (userRequested)
|
||||||
|
performUserRequestedExit();
|
||||||
|
else
|
||||||
|
this.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performUserRequestedExit()
|
private void performUserRequestedExit()
|
||||||
{
|
{
|
||||||
if (!this.IsCurrentScreen()) return;
|
|
||||||
|
|
||||||
if (ValidForResume && HasFailed && !FailOverlay.IsPresent)
|
if (ValidForResume && HasFailed && !FailOverlay.IsPresent)
|
||||||
{
|
{
|
||||||
failAnimation.FinishTransforms(true);
|
failAnimation.FinishTransforms(true);
|
||||||
@ -498,7 +508,7 @@ namespace osu.Game.Screens.Play
|
|||||||
RestartRequested?.Invoke();
|
RestartRequested?.Invoke();
|
||||||
|
|
||||||
if (this.IsCurrentScreen())
|
if (this.IsCurrentScreen())
|
||||||
PerformImmediateExit();
|
PerformExit(true);
|
||||||
else
|
else
|
||||||
this.MakeCurrent();
|
this.MakeCurrent();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user