mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 08:12:56 +08:00
compacted code, made public bool to disable it
This commit is contained in:
parent
a48e4a31a7
commit
77bfe57d8c
@ -14,20 +14,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
class ParallaxContainer : Container
|
class ParallaxContainer : Container
|
||||||
{
|
{
|
||||||
public float ParallaxAmount
|
public float ParallaxAmount = 0.02f;
|
||||||
{
|
public bool ParallaxEnabled = true;
|
||||||
get
|
|
||||||
{
|
|
||||||
return defaultParallaxAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
defaultParallaxAmount = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private float parallaxAmount;
|
|
||||||
private float defaultParallaxAmount = 0.02f;
|
|
||||||
|
|
||||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
@ -54,9 +42,13 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
config.GetBindable<bool>(OsuConfig.MenuParallax).ValueChanged += delegate
|
config.GetBindable<bool>(OsuConfig.MenuParallax).ValueChanged += delegate
|
||||||
{
|
{
|
||||||
parallaxAmount = config.GetBindable<bool>(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0;
|
ParallaxEnabled = config.GetBindable<bool>(OsuConfig.MenuParallax);
|
||||||
|
if (!ParallaxEnabled)
|
||||||
|
{
|
||||||
|
content.MoveTo(Vector2.Zero, 1000, EasingTypes.OutQuint);
|
||||||
|
content.Scale = Vector2.One;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
parallaxAmount = config.GetBindable<bool>(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool firstUpdate = true;
|
bool firstUpdate = true;
|
||||||
@ -65,9 +57,11 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2;
|
if (ParallaxEnabled) {
|
||||||
content.MoveTo(offset * parallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
|
Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2;
|
||||||
content.Scale = new Vector2(1 + parallaxAmount);
|
content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
|
||||||
|
content.Scale = new Vector2(1 + ParallaxAmount);
|
||||||
|
}
|
||||||
|
|
||||||
firstUpdate = false;
|
firstUpdate = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user