From 19789840066ccc497907fd73be46b8a0c01782a9 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sun, 12 Feb 2017 17:49:30 +0100 Subject: [PATCH 01/10] mode selector line has the correct length now --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 0ef56435e6..c8ac745bba 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -31,6 +31,10 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Y; + float length = Enum.GetValues(typeof(PlayMode)).Length * ToolbarButton.WIDTH + padding*2; + float lineLength = (padding * 2 + ToolbarButton.WIDTH) / length; + + Children = new Drawable[] { new OpaqueBackground(), @@ -41,12 +45,12 @@ namespace osu.Game.Overlays.Toolbar Direction = FlowDirection.HorizontalOnly, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Padding = new MarginPadding { Left = 10, Right = 10 }, + Padding = new MarginPadding { Left = padding, Right = padding }, }, modeButtonLine = new Container { RelativeSizeAxes = Axes.X, - Size = new Vector2(0.3f, 3), + Size = new Vector2(lineLength, 3), Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, Masking = true, From c1ba53fa093988263b7df91927e7ccf54b95a988 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 13 Feb 2017 16:56:15 +0100 Subject: [PATCH 02/10] calculation is now a 'one-liner' --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index c8ac745bba..69e3403e4e 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -31,8 +31,7 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Y; - float length = Enum.GetValues(typeof(PlayMode)).Length * ToolbarButton.WIDTH + padding*2; - float lineLength = (padding * 2 + ToolbarButton.WIDTH) / length; + float lineLength = (padding * 2 + ToolbarButton.WIDTH) / (Enum.GetValues(typeof(PlayMode)).Length * ToolbarButton.WIDTH + padding * 2); Children = new Drawable[] From 1b08f6aca4d68f1c1e9c195545ec4e163165364a Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 14 Feb 2017 14:24:54 +0100 Subject: [PATCH 03/10] Line length is absolute now --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 69e3403e4e..c242460cb0 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Y; - float lineLength = (padding * 2 + ToolbarButton.WIDTH) / (Enum.GetValues(typeof(PlayMode)).Length * ToolbarButton.WIDTH + padding * 2); + float lineLength = padding * 2 + ToolbarButton.WIDTH; Children = new Drawable[] @@ -48,7 +48,6 @@ namespace osu.Game.Overlays.Toolbar }, modeButtonLine = new Container { - RelativeSizeAxes = Axes.X, Size = new Vector2(lineLength, 3), Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, From e717daa504b037347299626a7ef4b352b7244bbe Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 14 Feb 2017 16:05:57 +0100 Subject: [PATCH 04/10] Line length is calculated inline --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index c242460cb0..a63fcce2dc 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -31,9 +31,6 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Y; - float lineLength = padding * 2 + ToolbarButton.WIDTH; - - Children = new Drawable[] { new OpaqueBackground(), @@ -48,7 +45,7 @@ namespace osu.Game.Overlays.Toolbar }, modeButtonLine = new Container { - Size = new Vector2(lineLength, 3), + Size = new Vector2(padding * 2 + ToolbarButton.WIDTH, 3), Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, Masking = true, From a48e4a31a79615928aba74c2d7eb85d43c371d40 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 18 Feb 2017 21:34:21 +0100 Subject: [PATCH 05/10] 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) From 77bfe57d8cd6c49064162234f221b8dcc869d488 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 18 Feb 2017 22:00:07 +0100 Subject: [PATCH 06/10] compacted code, made public bool to disable it --- .../Graphics/Containers/ParallaxContainer.cs | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 7513961574..328d74994e 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -14,20 +14,8 @@ namespace osu.Game.Graphics.Containers { class ParallaxContainer : Container { - public float ParallaxAmount - { - get - { - return defaultParallaxAmount; - } - - set - { - defaultParallaxAmount = value; - } - } - private float parallaxAmount; - private float defaultParallaxAmount = 0.02f; + public float ParallaxAmount = 0.02f; + public bool ParallaxEnabled = true; public override bool Contains(Vector2 screenSpacePos) => true; @@ -54,9 +42,13 @@ namespace osu.Game.Graphics.Containers config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate { - parallaxAmount = config.GetBindable(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0; + ParallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); + if (!ParallaxEnabled) + { + content.MoveTo(Vector2.Zero, 1000, EasingTypes.OutQuint); + content.Scale = Vector2.One; + } }; - parallaxAmount = config.GetBindable(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0; } bool firstUpdate = true; @@ -65,9 +57,11 @@ 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; } From f166bb0f96b28e0b269326aae4cf4c7888bd97b6 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 18 Feb 2017 22:26:48 +0100 Subject: [PATCH 07/10] Moved movement to the default position to property --- .../Graphics/Containers/ParallaxContainer.cs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 328d74994e..3cf2e0f413 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -15,7 +15,24 @@ namespace osu.Game.Graphics.Containers class ParallaxContainer : Container { public float ParallaxAmount = 0.02f; - public bool ParallaxEnabled = true; + + private bool parallaxEnabled = true; + public bool ParallaxEnabled + { + get + { + return parallaxEnabled; + } + set + { + parallaxEnabled = value; + if (!parallaxEnabled) + { + content.MoveTo(Vector2.Zero, 1000, EasingTypes.OutQuint); + content.Scale = Vector2.One; + } + } + } public override bool Contains(Vector2 screenSpacePos) => true; @@ -43,11 +60,6 @@ namespace osu.Game.Graphics.Containers config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate { ParallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); - if (!ParallaxEnabled) - { - content.MoveTo(Vector2.Zero, 1000, EasingTypes.OutQuint); - content.Scale = Vector2.One; - } }; } From e83ac8b04c6f50a256819a8c2698dab77933781e Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sun, 19 Feb 2017 13:47:26 +0100 Subject: [PATCH 08/10] Removed public ParallaxEnabled property --- .../Graphics/Containers/ParallaxContainer.cs | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 3cf2e0f413..7696e82009 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -17,22 +17,6 @@ namespace osu.Game.Graphics.Containers public float ParallaxAmount = 0.02f; private bool parallaxEnabled = true; - public bool ParallaxEnabled - { - get - { - return parallaxEnabled; - } - set - { - parallaxEnabled = value; - if (!parallaxEnabled) - { - content.MoveTo(Vector2.Zero, 1000, EasingTypes.OutQuint); - content.Scale = Vector2.One; - } - } - } public override bool Contains(Vector2 screenSpacePos) => true; @@ -59,7 +43,12 @@ namespace osu.Game.Graphics.Containers config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate { - ParallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); + parallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); + if (!parallaxEnabled) + { + content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); + content.Scale = Vector2.One; + } }; } @@ -69,7 +58,7 @@ namespace osu.Game.Graphics.Containers { base.Update(); - if (ParallaxEnabled) { + 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); From 7f751d365338b7bde8fd733bbf632a2ac4ee281a Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sun, 19 Feb 2017 16:54:00 +0100 Subject: [PATCH 09/10] Update ParallaxContainer.cs --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 7696e82009..9208c5008a 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -58,7 +58,8 @@ namespace osu.Game.Graphics.Containers { base.Update(); - if (parallaxEnabled) { + 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); From 1e0a694ff86dc9e942d2adc125b20621e041fb3d Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sun, 19 Feb 2017 17:11:31 +0100 Subject: [PATCH 10/10] replaced bool with Bindable Also accounted for the ParallaxAmount when moving to default position --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 9208c5008a..bc54fd8fdc 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -9,6 +9,7 @@ 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 { @@ -16,7 +17,7 @@ namespace osu.Game.Graphics.Containers { public float ParallaxAmount = 0.02f; - private bool parallaxEnabled = true; + private Bindable parallaxEnabled; public override bool Contains(Vector2 screenSpacePos) => true; @@ -40,14 +41,13 @@ namespace osu.Game.Graphics.Containers private void load(UserInputManager input, OsuConfigManager config) { this.input = input; - - config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate + parallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); + parallaxEnabled.ValueChanged += delegate { - parallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); if (!parallaxEnabled) { content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); - content.Scale = Vector2.One; + content.Scale = new Vector2(1 + ParallaxAmount); } }; }