From a48e4a31a79615928aba74c2d7eb85d43c371d40 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 18 Feb 2017 21:34:21 +0100 Subject: [PATCH] Parallax Option works now --- osu.Game/Configuration/OsuConfigManager.cs | 2 +- .../Graphics/Containers/ParallaxContainer.cs | 28 ++++++++++++++++--- osu.Game/Screens/Menu/MainMenu.cs | 1 - 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 381bca2a71..1562571efc 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -31,6 +31,7 @@ namespace osu.Game.Configuration Set(OsuConfig.SnakingInSliders, true); Set(OsuConfig.SnakingOutSliders, false); + Set(OsuConfig.MenuParallax, true); //todo: implement all settings below this line (remove the Disabled set when doing so). Set(OsuConfig.MouseSpeed, 1.0).Disabled = true; @@ -143,7 +144,6 @@ namespace osu.Game.Configuration Set(OsuConfig.DetectPerformanceIssues, true).Disabled = true; Set(OsuConfig.MenuMusic, true).Disabled = true; Set(OsuConfig.MenuVoice, true).Disabled = true; - Set(OsuConfig.MenuParallax, true).Disabled = true; Set(OsuConfig.RawInput, false).Disabled = true; Set(OsuConfig.AbsoluteToOsuWindow, Get(OsuConfig.RawInput)).Disabled = true; Set(OsuConfig.ShowMenuTips, true).Disabled = true; diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index fe3601a5f2..7513961574 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -8,12 +8,26 @@ using OpenTK; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.Transformations; +using osu.Game.Configuration; namespace osu.Game.Graphics.Containers { class ParallaxContainer : Container { - public float ParallaxAmount = 0.02f; + public float ParallaxAmount + { + get + { + return defaultParallaxAmount; + } + + set + { + defaultParallaxAmount = value; + } + } + private float parallaxAmount; + private float defaultParallaxAmount = 0.02f; public override bool Contains(Vector2 screenSpacePos) => true; @@ -34,9 +48,15 @@ namespace osu.Game.Graphics.Containers protected override Container Content => content; [BackgroundDependencyLoader] - private void load(UserInputManager input) + private void load(UserInputManager input, OsuConfigManager config) { this.input = input; + + config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate + { + parallaxAmount = config.GetBindable(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0; + }; + parallaxAmount = config.GetBindable(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0; } bool firstUpdate = true; @@ -46,8 +66,8 @@ namespace osu.Game.Graphics.Containers base.Update(); Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2; - content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); - content.Scale = new Vector2(1 + ParallaxAmount); + content.MoveTo(offset * parallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); + content.Scale = new Vector2(1 + parallaxAmount); firstUpdate = false; } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 29fc44d673..1a6310ea4e 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -59,7 +59,6 @@ namespace osu.Game.Screens.Menu background.Preload(game); buttons.OnSettings = game.ToggleOptions; - } protected override void OnEntering(Screen last)