1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 22:22:54 +08:00

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 @@ 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<bool>(OsuConfig.RawInput)).Disabled = true;
Set(OsuConfig.ShowMenuTips, true).Disabled = true;

View File

@ -8,6 +8,8 @@ using OpenTK;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Transformations;
using osu.Game.Configuration;
using osu.Framework.Configuration;
namespace osu.Game.Graphics.Containers
{
@ -15,6 +17,8 @@ namespace osu.Game.Graphics.Containers
{
public float ParallaxAmount = 0.02f;
private Bindable<bool> parallaxEnabled;
public override bool Contains(Vector2 screenSpacePos) => true;
public ParallaxContainer()
@ -34,9 +38,18 @@ namespace osu.Game.Graphics.Containers
protected override Container<Drawable> Content => content;
[BackgroundDependencyLoader]
private void load(UserInputManager input)
private void load(UserInputManager input, OsuConfigManager config)
{
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;
@ -45,9 +58,12 @@ 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);
if (parallaxEnabled)
{
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);
}
firstUpdate = false;
}

View File

@ -59,7 +59,6 @@ namespace osu.Game.Screens.Menu
background.Preload(game);
buttons.OnSettings = game.ToggleOptions;
}
protected override void OnEntering(Screen last)