1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 20:47:25 +08:00
osu-lazer/osu.Game/Screens/Multi/MultiplayerSubScreen.cs

109 lines
3.5 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2019-01-25 18:32:37 +08:00
using osu.Framework.Allocation;
2019-02-01 14:42:15 +08:00
using osu.Framework.Configuration;
2019-01-25 18:32:37 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
2019-02-01 14:42:15 +08:00
using osu.Game.Rulesets;
2019-01-25 18:32:37 +08:00
namespace osu.Game.Screens.Multi
{
public abstract class MultiplayerSubScreen : CompositeDrawable, IMultiplayerSubScreen, IKeyBindingHandler<GlobalAction>
{
2019-02-01 14:42:15 +08:00
public virtual bool DisallowExternalBeatmapRulesetChanges => false;
2019-01-25 18:32:37 +08:00
public bool CursorVisible => true;
public bool HideOverlaysOnEnter => false;
public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public float BackgroundParallaxAmount => 1;
2019-01-25 18:32:37 +08:00
public bool ValidForResume { get; set; } = true;
public bool ValidForPush { get; set; } = true;
public override bool RemoveWhenNotAlive => false;
public abstract string Title { get; }
public virtual string ShortTitle => Title;
2019-02-02 16:11:25 +08:00
public Bindable<WorkingBeatmap> Beatmap { get; set; }
2019-02-01 14:42:15 +08:00
2019-02-02 16:11:25 +08:00
public Bindable<RulesetInfo> Ruleset { get; set; }
2019-02-01 14:42:15 +08:00
2019-02-02 16:11:25 +08:00
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent));
Beatmap = deps.Beatmap;
Ruleset = deps.Ruleset;
2019-02-01 14:42:15 +08:00
2019-02-02 16:11:25 +08:00
return deps;
}
2019-01-25 18:32:37 +08:00
[Resolved(CanBeNull = true)]
protected OsuGame Game { get; private set; }
[Resolved(CanBeNull = true)]
protected IRoomManager Manager { get; private set; }
protected MultiplayerSubScreen()
{
2019-01-25 19:47:31 +08:00
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
2019-01-25 18:32:37 +08:00
RelativeSizeAxes = Axes.Both;
}
public virtual void OnEntering(IScreen last)
{
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
}
public virtual bool OnExiting(IScreen next)
{
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
return false;
}
public virtual void OnResuming(IScreen last)
{
this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
}
public virtual void OnSuspending(IScreen next)
{
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
}
public virtual bool OnPressed(GlobalAction action)
{
if (!this.IsCurrentScreen()) return false;
if (action == GlobalAction.Back)
{
this.Exit();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
public override string ToString() => Title;
}
}