Merge pull request #373 from Jorolf/MoreOptions

Enable Parallax Option
This commit is contained in:
Dean Herbert 2017-02-20 15:36:58 +09:00 committed by GitHub
commit 5916efd1c2
3 changed files with 21 additions and 6 deletions

View File

@ -31,6 +31,7 @@ protected override void InitialiseDefaults()
Set(OsuConfig.SnakingInSliders, true); Set(OsuConfig.SnakingInSliders, true);
Set(OsuConfig.SnakingOutSliders, false); Set(OsuConfig.SnakingOutSliders, false);
Set(OsuConfig.MenuParallax, true);
//todo: implement all settings below this line (remove the Disabled set when doing so). //todo: implement all settings below this line (remove the Disabled set when doing so).
Set(OsuConfig.MouseSpeed, 1.0).Disabled = true; Set(OsuConfig.MouseSpeed, 1.0).Disabled = true;
@ -143,7 +144,6 @@ protected override void InitialiseDefaults()
Set(OsuConfig.DetectPerformanceIssues, true).Disabled = true; Set(OsuConfig.DetectPerformanceIssues, true).Disabled = true;
Set(OsuConfig.MenuMusic, true).Disabled = true; Set(OsuConfig.MenuMusic, true).Disabled = true;
Set(OsuConfig.MenuVoice, true).Disabled = true; Set(OsuConfig.MenuVoice, true).Disabled = true;
Set(OsuConfig.MenuParallax, true).Disabled = true;
Set(OsuConfig.RawInput, false).Disabled = true; Set(OsuConfig.RawInput, false).Disabled = true;
Set(OsuConfig.AbsoluteToOsuWindow, Get<bool>(OsuConfig.RawInput)).Disabled = true; Set(OsuConfig.AbsoluteToOsuWindow, Get<bool>(OsuConfig.RawInput)).Disabled = true;
Set(OsuConfig.ShowMenuTips, true).Disabled = true; Set(OsuConfig.ShowMenuTips, true).Disabled = true;

View File

@ -8,6 +8,8 @@
using osu.Framework; using osu.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.Transformations;
using osu.Game.Configuration;
using osu.Framework.Configuration;
namespace osu.Game.Graphics.Containers namespace osu.Game.Graphics.Containers
{ {
@ -15,6 +17,8 @@ class ParallaxContainer : Container
{ {
public float ParallaxAmount = 0.02f; public float ParallaxAmount = 0.02f;
private Bindable<bool> parallaxEnabled;
public override bool Contains(Vector2 screenSpacePos) => true; public override bool Contains(Vector2 screenSpacePos) => true;
public ParallaxContainer() public ParallaxContainer()
@ -34,9 +38,18 @@ public ParallaxContainer()
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(UserInputManager input) private void load(UserInputManager input, OsuConfigManager config)
{ {
this.input = input; this.input = input;
parallaxEnabled = config.GetBindable<bool>(OsuConfig.MenuParallax);
parallaxEnabled.ValueChanged += delegate
{
if (!parallaxEnabled)
{
content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
content.Scale = new Vector2(1 + ParallaxAmount);
}
};
} }
bool firstUpdate = true; bool firstUpdate = true;
@ -45,9 +58,12 @@ protected override void Update()
{ {
base.Update(); base.Update();
if (parallaxEnabled)
{
Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2; 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.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
content.Scale = new Vector2(1 + ParallaxAmount); content.Scale = new Vector2(1 + ParallaxAmount);
}
firstUpdate = false; firstUpdate = false;
} }

View File

@ -59,7 +59,6 @@ private void load(OsuGame game)
background.Preload(game); background.Preload(game);
buttons.OnSettings = game.ToggleOptions; buttons.OnSettings = game.ToggleOptions;
} }
protected override void OnEntering(Screen last) protected override void OnEntering(Screen last)