mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 13:22:55 +08:00
Merge pull request #2134 from peppy/player-reduced-parallax
Reduce parallax effect during gameplay
This commit is contained in:
commit
d97c4c765b
@ -14,7 +14,9 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
public class ParallaxContainer : Container, IRequireHighFrequencyMousePosition
|
public class ParallaxContainer : Container, IRequireHighFrequencyMousePosition
|
||||||
{
|
{
|
||||||
public float ParallaxAmount = 0.02f;
|
public const float DEFAULT_PARALLAX_AMOUNT = 0.02f;
|
||||||
|
|
||||||
|
public float ParallaxAmount = DEFAULT_PARALLAX_AMOUNT;
|
||||||
|
|
||||||
private Bindable<bool> parallaxEnabled;
|
private Bindable<bool> parallaxEnabled;
|
||||||
|
|
||||||
|
@ -52,6 +52,10 @@ namespace osu.Game.Screens
|
|||||||
|
|
||||||
protected readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
protected readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||||
|
|
||||||
|
protected virtual float BackgroundParallaxAmount => 1;
|
||||||
|
|
||||||
|
private ParallaxContainer backgroundParallaxContainer;
|
||||||
|
|
||||||
public WorkingBeatmap InitialBeatmap
|
public WorkingBeatmap InitialBeatmap
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
@ -102,11 +106,10 @@ namespace osu.Game.Screens
|
|||||||
|
|
||||||
protected override void OnResuming(Screen last)
|
protected override void OnResuming(Screen last)
|
||||||
{
|
{
|
||||||
base.OnResuming(last);
|
|
||||||
logo.AppendAnimatingAction(() => LogoArriving(logo, true), true);
|
|
||||||
sampleExit?.Play();
|
sampleExit?.Play();
|
||||||
|
applyArrivingDefaults(true);
|
||||||
|
|
||||||
ShowOverlays.Value = ShowOverlaysOnEnter;
|
base.OnResuming(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSuspending(Screen next)
|
protected override void OnSuspending(Screen next)
|
||||||
@ -123,6 +126,8 @@ namespace osu.Game.Screens
|
|||||||
|
|
||||||
if (lastOsu?.Background != null)
|
if (lastOsu?.Background != null)
|
||||||
{
|
{
|
||||||
|
backgroundParallaxContainer = lastOsu.backgroundParallaxContainer;
|
||||||
|
|
||||||
if (bg == null || lastOsu.Background.Equals(bg))
|
if (bg == null || lastOsu.Background.Equals(bg))
|
||||||
//we can keep the previous mode's background.
|
//we can keep the previous mode's background.
|
||||||
Background = lastOsu.Background;
|
Background = lastOsu.Background;
|
||||||
@ -136,7 +141,7 @@ namespace osu.Game.Screens
|
|||||||
// this makes up for the fact our padding changes when the global toolbar is visible.
|
// this makes up for the fact our padding changes when the global toolbar is visible.
|
||||||
bg.Scale = new Vector2(1.06f);
|
bg.Scale = new Vector2(1.06f);
|
||||||
|
|
||||||
AddInternal(new ParallaxContainer
|
AddInternal(backgroundParallaxContainer = new ParallaxContainer
|
||||||
{
|
{
|
||||||
Depth = float.MaxValue,
|
Depth = float.MaxValue,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
@ -149,11 +154,9 @@ namespace osu.Game.Screens
|
|||||||
if ((logo = lastOsu?.logo) == null)
|
if ((logo = lastOsu?.logo) == null)
|
||||||
LoadComponentAsync(logo = new OsuLogo { Alpha = 0 }, AddInternal);
|
LoadComponentAsync(logo = new OsuLogo { Alpha = 0 }, AddInternal);
|
||||||
|
|
||||||
logo.AppendAnimatingAction(() => LogoArriving(logo, false), true);
|
applyArrivingDefaults(false);
|
||||||
|
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
|
|
||||||
ShowOverlays.Value = ShowOverlaysOnEnter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnExiting(Screen next)
|
protected override bool OnExiting(Screen next)
|
||||||
@ -193,6 +196,16 @@ namespace osu.Game.Screens
|
|||||||
logo.Ripple = true;
|
logo.Ripple = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applyArrivingDefaults(bool isResuming)
|
||||||
|
{
|
||||||
|
logo.AppendAnimatingAction(() => LogoArriving(logo, isResuming), true);
|
||||||
|
|
||||||
|
if (backgroundParallaxContainer != null)
|
||||||
|
backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount;
|
||||||
|
|
||||||
|
ShowOverlays.Value = ShowOverlaysOnEnter;
|
||||||
|
}
|
||||||
|
|
||||||
private void onExitingLogo()
|
private void onExitingLogo()
|
||||||
{
|
{
|
||||||
logo.AppendAnimatingAction(() => { LogoExiting(logo); }, false);
|
logo.AppendAnimatingAction(() => { LogoExiting(logo); }, false);
|
||||||
|
@ -37,6 +37,8 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||||
|
|
||||||
|
protected override float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => false;
|
public override bool ShowOverlaysOnEnter => false;
|
||||||
|
|
||||||
public Action RestartRequested;
|
public Action RestartRequested;
|
||||||
|
Loading…
Reference in New Issue
Block a user