mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:02:54 +08:00
Fix background overflows
This commit is contained in:
parent
3d96da84e6
commit
258ba4674c
@ -11,6 +11,9 @@ namespace osu.Game.Screens
|
|||||||
{
|
{
|
||||||
public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen>
|
public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen>
|
||||||
{
|
{
|
||||||
|
protected const float TRANSITION_LENGTH = 500;
|
||||||
|
private const float x_movement_amount = 50;
|
||||||
|
|
||||||
private readonly bool animateOnEnter;
|
private readonly bool animateOnEnter;
|
||||||
|
|
||||||
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||||
@ -27,9 +30,6 @@ namespace osu.Game.Screens
|
|||||||
return other?.GetType() == GetType();
|
return other?.GetType() == GetType();
|
||||||
}
|
}
|
||||||
|
|
||||||
private const float transition_length = 500;
|
|
||||||
private const float x_movement_amount = 50;
|
|
||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
{
|
{
|
||||||
// we don't want to handle escape key.
|
// we don't want to handle escape key.
|
||||||
@ -55,8 +55,8 @@ namespace osu.Game.Screens
|
|||||||
this.FadeOut();
|
this.FadeOut();
|
||||||
this.MoveToX(x_movement_amount);
|
this.MoveToX(x_movement_amount);
|
||||||
|
|
||||||
this.FadeIn(transition_length, Easing.InOutQuart);
|
this.FadeIn(TRANSITION_LENGTH, Easing.InOutQuart);
|
||||||
this.MoveToX(0, transition_length, Easing.InOutQuart);
|
this.MoveToX(0, TRANSITION_LENGTH, Easing.InOutQuart);
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
@ -64,7 +64,7 @@ namespace osu.Game.Screens
|
|||||||
|
|
||||||
public override void OnSuspending(IScreen next)
|
public override void OnSuspending(IScreen next)
|
||||||
{
|
{
|
||||||
this.MoveToX(-x_movement_amount, transition_length, Easing.InOutQuart);
|
this.MoveToX(-x_movement_amount, TRANSITION_LENGTH, Easing.InOutQuart);
|
||||||
base.OnSuspending(next);
|
base.OnSuspending(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +72,8 @@ namespace osu.Game.Screens
|
|||||||
{
|
{
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
{
|
{
|
||||||
this.FadeOut(transition_length, Easing.OutExpo);
|
this.FadeOut(TRANSITION_LENGTH, Easing.OutExpo);
|
||||||
this.MoveToX(x_movement_amount, transition_length, Easing.OutExpo);
|
this.MoveToX(x_movement_amount, TRANSITION_LENGTH, Easing.OutExpo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
@ -82,7 +82,7 @@ namespace osu.Game.Screens
|
|||||||
public override void OnResuming(IScreen last)
|
public override void OnResuming(IScreen last)
|
||||||
{
|
{
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
this.MoveToX(0, transition_length, Easing.OutExpo);
|
this.MoveToX(0, TRANSITION_LENGTH, Easing.OutExpo);
|
||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,12 @@ namespace osu.Game.Screens
|
|||||||
{
|
{
|
||||||
public class BackgroundScreenStack : ScreenStack
|
public class BackgroundScreenStack : ScreenStack
|
||||||
{
|
{
|
||||||
|
public const float BACKGROUND_SCALE = 1.06f;
|
||||||
|
|
||||||
public BackgroundScreenStack()
|
public BackgroundScreenStack()
|
||||||
: base(false)
|
: base(false)
|
||||||
{
|
{
|
||||||
Scale = new Vector2(1.06f);
|
Scale = new Vector2(BACKGROUND_SCALE);
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
@ -8,6 +8,7 @@ using System.Threading;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -86,5 +87,26 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
|
|
||||||
AddInternal(background = newBackground);
|
AddInternal(background = newBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
// This is a static screen, so override the scale set in base.Update(), but also the scale set by the screen stack.
|
||||||
|
Scale = new Vector2(1f / BackgroundScreenStack.BACKGROUND_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnSuspending(IScreen next)
|
||||||
|
{
|
||||||
|
base.OnSuspending(next);
|
||||||
|
this.MoveToX(0, TRANSITION_LENGTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnExiting(IScreen next)
|
||||||
|
{
|
||||||
|
var result = base.OnExiting(next);
|
||||||
|
this.MoveToX(0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user