mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:42:54 +08:00
Make Multiplayer not an OsuScreen
This commit is contained in:
parent
e1e7759e0f
commit
95e6785968
@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
@ -24,11 +25,18 @@ using osuTK;
|
|||||||
namespace osu.Game.Screens.Multi
|
namespace osu.Game.Screens.Multi
|
||||||
{
|
{
|
||||||
[Cached]
|
[Cached]
|
||||||
public class Multiplayer : OsuScreen, IOnlineComponent
|
public class Multiplayer : CompositeDrawable, IOsuScreen, IOnlineComponent
|
||||||
{
|
{
|
||||||
private readonly MultiplayerWaveContainer waves;
|
public bool AllowBeatmapRulesetChange => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowBeatmapRulesetChange ?? true;
|
||||||
|
public bool AllowExternalScreenChange => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowExternalScreenChange ?? true;
|
||||||
|
public bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowExternalScreenChange ?? true;
|
||||||
|
|
||||||
public override bool AllowBeatmapRulesetChange => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowBeatmapRulesetChange ?? base.AllowBeatmapRulesetChange;
|
public bool ValidForResume { get; set; } = true;
|
||||||
|
public bool ValidForPush { get; set; } = true;
|
||||||
|
|
||||||
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
|
private readonly MultiplayerWaveContainer waves;
|
||||||
|
|
||||||
private readonly OsuButton createButton;
|
private readonly OsuButton createButton;
|
||||||
private readonly LoungeSubScreen loungeSubScreen;
|
private readonly LoungeSubScreen loungeSubScreen;
|
||||||
@ -37,11 +45,22 @@ namespace osu.Game.Screens.Multi
|
|||||||
[Cached(Type = typeof(IRoomManager))]
|
[Cached(Type = typeof(IRoomManager))]
|
||||||
private RoomManager roomManager;
|
private RoomManager roomManager;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindableBeatmap beatmap { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuGameBase game { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private APIAccess api { get; set; }
|
private APIAccess api { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuLogo logo { get; set; }
|
||||||
|
|
||||||
public Multiplayer()
|
public Multiplayer()
|
||||||
{
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
InternalChild = waves = new MultiplayerWaveContainer
|
InternalChild = waves = new MultiplayerWaveContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -143,15 +162,14 @@ namespace osu.Game.Screens.Multi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEntering(IScreen last)
|
public void OnEntering(IScreen last)
|
||||||
{
|
{
|
||||||
this.FadeIn();
|
this.FadeIn();
|
||||||
|
|
||||||
base.OnEntering(last);
|
|
||||||
waves.Show();
|
waves.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
waves.Hide();
|
waves.Hide();
|
||||||
|
|
||||||
@ -161,44 +179,39 @@ namespace osu.Game.Screens.Multi
|
|||||||
loungeSubScreen.MakeCurrent();
|
loungeSubScreen.MakeCurrent();
|
||||||
updatePollingRate(isIdle.Value);
|
updatePollingRate(isIdle.Value);
|
||||||
|
|
||||||
return base.OnExiting(next);
|
logo?.AppendAnimatingAction(() =>
|
||||||
|
{
|
||||||
|
// the wave overlay transition takes longer than expected to run.
|
||||||
|
logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnResuming(IScreen last)
|
public void OnResuming(IScreen last)
|
||||||
{
|
{
|
||||||
base.OnResuming(last);
|
|
||||||
|
|
||||||
this.FadeIn(250);
|
this.FadeIn(250);
|
||||||
this.ScaleTo(1, 250, Easing.OutSine);
|
this.ScaleTo(1, 250, Easing.OutSine);
|
||||||
|
|
||||||
updatePollingRate(isIdle.Value);
|
updatePollingRate(isIdle.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSuspending(IScreen next)
|
public void OnSuspending(IScreen next)
|
||||||
{
|
{
|
||||||
this.ScaleTo(1.1f, 250, Easing.InSine);
|
this.ScaleTo(1.1f, 250, Easing.InSine);
|
||||||
this.FadeOut(250);
|
this.FadeOut(250);
|
||||||
|
|
||||||
cancelLooping();
|
cancelLooping();
|
||||||
roomManager.TimeBetweenPolls = 0;
|
roomManager.TimeBetweenPolls = 0;
|
||||||
|
|
||||||
base.OnSuspending(next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelLooping()
|
private void cancelLooping()
|
||||||
{
|
{
|
||||||
var track = Beatmap.Value.Track;
|
var track = beatmap.Value.Track;
|
||||||
if (track != null)
|
if (track != null)
|
||||||
track.Looping = false;
|
track.Looping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LogoExiting(OsuLogo logo)
|
|
||||||
{
|
|
||||||
// the wave overlay transition takes longer than expected to run.
|
|
||||||
logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut();
|
|
||||||
base.LogoExiting(logo);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -207,15 +220,15 @@ namespace osu.Game.Screens.Multi
|
|||||||
|
|
||||||
if (screenStack.CurrentScreen is MatchSubScreen)
|
if (screenStack.CurrentScreen is MatchSubScreen)
|
||||||
{
|
{
|
||||||
var track = Beatmap.Value.Track;
|
var track = beatmap.Value.Track;
|
||||||
if (track != null)
|
if (track != null)
|
||||||
{
|
{
|
||||||
track.Looping = true;
|
track.Looping = true;
|
||||||
|
|
||||||
if (!track.IsRunning)
|
if (!track.IsRunning)
|
||||||
{
|
{
|
||||||
Game.Audio.AddItemToList(track);
|
game.Audio.AddItemToList(track);
|
||||||
track.Seek(Beatmap.Value.Metadata.PreviewTime);
|
track.Seek(beatmap.Value.Metadata.PreviewTime);
|
||||||
track.Start();
|
track.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,6 +248,9 @@ namespace osu.Game.Screens.Multi
|
|||||||
cancelLooping();
|
cancelLooping();
|
||||||
|
|
||||||
updatePollingRate(isIdle.Value);
|
updatePollingRate(isIdle.Value);
|
||||||
|
|
||||||
|
if (screenStack.CurrentScreen == null)
|
||||||
|
this.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
Loading…
Reference in New Issue
Block a user