1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Fix background overflows

This commit is contained in:
smoogipoo 2021-08-20 17:50:49 +09:00
parent 3d96da84e6
commit 258ba4674c
3 changed files with 34 additions and 10 deletions

View File

@ -11,6 +11,9 @@ namespace osu.Game.Screens
{
public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen>
{
protected const float TRANSITION_LENGTH = 500;
private const float x_movement_amount = 50;
private readonly bool animateOnEnter;
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
@ -27,9 +30,6 @@ namespace osu.Game.Screens
return other?.GetType() == GetType();
}
private const float transition_length = 500;
private const float x_movement_amount = 50;
protected override bool OnKeyDown(KeyDownEvent e)
{
// we don't want to handle escape key.
@ -55,8 +55,8 @@ namespace osu.Game.Screens
this.FadeOut();
this.MoveToX(x_movement_amount);
this.FadeIn(transition_length, Easing.InOutQuart);
this.MoveToX(0, transition_length, Easing.InOutQuart);
this.FadeIn(TRANSITION_LENGTH, Easing.InOutQuart);
this.MoveToX(0, TRANSITION_LENGTH, Easing.InOutQuart);
}
base.OnEntering(last);
@ -64,7 +64,7 @@ namespace osu.Game.Screens
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);
}
@ -72,8 +72,8 @@ namespace osu.Game.Screens
{
if (IsLoaded)
{
this.FadeOut(transition_length, Easing.OutExpo);
this.MoveToX(x_movement_amount, transition_length, Easing.OutExpo);
this.FadeOut(TRANSITION_LENGTH, Easing.OutExpo);
this.MoveToX(x_movement_amount, TRANSITION_LENGTH, Easing.OutExpo);
}
return base.OnExiting(next);
@ -82,7 +82,7 @@ namespace osu.Game.Screens
public override void OnResuming(IScreen last)
{
if (IsLoaded)
this.MoveToX(0, transition_length, Easing.OutExpo);
this.MoveToX(0, TRANSITION_LENGTH, Easing.OutExpo);
base.OnResuming(last);
}
}

View File

@ -10,10 +10,12 @@ namespace osu.Game.Screens
{
public class BackgroundScreenStack : ScreenStack
{
public const float BACKGROUND_SCALE = 1.06f;
public BackgroundScreenStack()
: base(false)
{
Scale = new Vector2(1.06f);
Scale = new Vector2(BACKGROUND_SCALE);
RelativeSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;

View File

@ -8,6 +8,7 @@ using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Game.Online.Rooms;
using osuTK;
@ -86,5 +87,26 @@ namespace osu.Game.Screens.OnlinePlay.Components
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;
}
}
}