From cbd6fe3f361afdecedc405a68449a2032b3a842f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 30 Jan 2017 22:00:23 +0900 Subject: [PATCH 01/10] Move definition of MusicController's position out of itself. --- osu.Game/OsuGame.cs | 7 +- osu.Game/Overlays/MusicController.cs | 218 ++++++++++++++------------- osu.Game/Overlays/Toolbar/Toolbar.cs | 4 +- 3 files changed, 120 insertions(+), 109 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index c4d94b5d65..0309d60834 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -21,6 +21,7 @@ using osu.Game.Modes; using osu.Game.Overlays.Toolbar; using osu.Game.Screens; using osu.Game.Screens.Menu; +using OpenTK; namespace osu.Game { @@ -101,7 +102,11 @@ namespace osu.Game //overlay elements (chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add); (options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add); - (musicController = new MusicController() { Depth = -3 }).Preload(this, overlayContent.Add); + (musicController = new MusicController() + { + Depth = -3, + Position = new Vector2(0, Toolbar.HEIGHT), + }).Preload(this, overlayContent.Add); Dependencies.Cache(options); Dependencies.Cache(musicController); diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index e480bf3061..8730309a6a 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -28,8 +28,6 @@ namespace osu.Game.Overlays { public class MusicController : OverlayContainer { - private static readonly Vector2 start_position = new Vector2(0, 50); - private MusicControllerBackground backgroundSprite; private DragBar progress; private TextAwesome playButton, listButton; @@ -47,22 +45,15 @@ namespace osu.Game.Overlays private BeatmapDatabase beatmaps; private BaseGame game; + private Container dragContainer; + public MusicController() { Width = 400; Height = 130; - CornerRadius = 5; - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(40), - Radius = 5, - }; - Masking = true; Anchor = Anchor.TopRight;//placeholder Origin = Anchor.TopRight; - Position = start_position; Margin = new MarginPadding(10); } @@ -75,13 +66,13 @@ namespace osu.Game.Overlays // Diminish the drag distance as we go further to simulate "rubber band" feeling. change *= (float)Math.Pow(change.Length, 0.7f) / change.Length; - MoveTo(start_position + change); + dragContainer.MoveTo(change); return base.OnDrag(state); } protected override bool OnDragEnd(InputState state) { - MoveTo(start_position, 800, EasingTypes.OutElastic); + dragContainer.MoveTo(Vector2.Zero, 800, EasingTypes.OutElastic); return base.OnDragEnd(state); } @@ -93,111 +84,126 @@ namespace osu.Game.Overlays Children = new Drawable[] { - title = new SpriteText + dragContainer = new Container { - Origin = Anchor.BottomCentre, - Anchor = Anchor.TopCentre, - Position = new Vector2(0, 40), - TextSize = 25, - Colour = Color4.White, - Text = @"Nothing to play", - Font = @"Exo2.0-MediumItalic" - }, - artist = new SpriteText - { - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Position = new Vector2(0, 45), - TextSize = 15, - Colour = Color4.White, - Text = @"Nothing to play", - Font = @"Exo2.0-BoldItalic" - }, - new ClickableContainer - { - AutoSizeAxes = Axes.Both, - Origin = Anchor.Centre, - Anchor = Anchor.BottomCentre, - Position = new Vector2(0, -30), - Action = () => + Masking = true, + CornerRadius = 5, + EdgeEffect = new EdgeEffect { - if (current?.Track == null) return; - if (current.Track.IsRunning) - current.Track.Stop(); - else - current.Track.Start(); + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(40), + Radius = 5, }, + RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - playButton = new TextAwesome + title = new SpriteText { - TextSize = 30, - Icon = FontAwesome.fa_play_circle_o, - Origin = Anchor.Centre, - Anchor = Anchor.Centre - } - } - }, - new ClickableContainer - { - AutoSizeAxes = Axes.Both, - Origin = Anchor.Centre, - Anchor = Anchor.BottomCentre, - Position = new Vector2(-30, -30), - Action = prev, - Children = new Drawable[] - { - new TextAwesome + Origin = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, + Position = new Vector2(0, 40), + TextSize = 25, + Colour = Color4.White, + Text = @"Nothing to play", + Font = @"Exo2.0-MediumItalic" + }, + artist = new SpriteText { + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Position = new Vector2(0, 45), TextSize = 15, - Icon = FontAwesome.fa_step_backward, - Origin = Anchor.Centre, - Anchor = Anchor.Centre - } - } - }, - new ClickableContainer - { - AutoSizeAxes = Axes.Both, - Origin = Anchor.Centre, - Anchor = Anchor.BottomCentre, - Position = new Vector2(30, -30), - Action = next, - Children = new Drawable[] - { - new TextAwesome + Colour = Color4.White, + Text = @"Nothing to play", + Font = @"Exo2.0-BoldItalic" + }, + new ClickableContainer { - TextSize = 15, - Icon = FontAwesome.fa_step_forward, + AutoSizeAxes = Axes.Both, Origin = Anchor.Centre, - Anchor = Anchor.Centre - } - } - }, - new ClickableContainer - { - AutoSizeAxes = Axes.Both, - Origin = Anchor.Centre, - Anchor = Anchor.BottomRight, - Position = new Vector2(20, -30), - Children = new Drawable[] - { - listButton = new TextAwesome + Anchor = Anchor.BottomCentre, + Position = new Vector2(0, -30), + Action = () => + { + if (current?.Track == null) return; + if (current.Track.IsRunning) + current.Track.Stop(); + else + current.Track.Start(); + }, + Children = new Drawable[] + { + playButton = new TextAwesome + { + TextSize = 30, + Icon = FontAwesome.fa_play_circle_o, + Origin = Anchor.Centre, + Anchor = Anchor.Centre + } + } + }, + new ClickableContainer { - TextSize = 15, - Icon = FontAwesome.fa_bars, + AutoSizeAxes = Axes.Both, Origin = Anchor.Centre, - Anchor = Anchor.Centre + Anchor = Anchor.BottomCentre, + Position = new Vector2(-30, -30), + Action = prev, + Children = new Drawable[] + { + new TextAwesome + { + TextSize = 15, + Icon = FontAwesome.fa_step_backward, + Origin = Anchor.Centre, + Anchor = Anchor.Centre + } + } + }, + new ClickableContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.Centre, + Anchor = Anchor.BottomCentre, + Position = new Vector2(30, -30), + Action = next, + Children = new Drawable[] + { + new TextAwesome + { + TextSize = 15, + Icon = FontAwesome.fa_step_forward, + Origin = Anchor.Centre, + Anchor = Anchor.Centre + } + } + }, + new ClickableContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.Centre, + Anchor = Anchor.BottomRight, + Position = new Vector2(20, -30), + Children = new Drawable[] + { + listButton = new TextAwesome + { + TextSize = 15, + Icon = FontAwesome.fa_bars, + Origin = Anchor.Centre, + Anchor = Anchor.Centre + } + } + }, + progress = new DragBar + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + Height = 10, + Colour = colours.Yellow, + SeekRequested = seek } } - }, - progress = new DragBar - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Height = 10, - Colour = colours.Yellow, - SeekRequested = seek } }; @@ -210,7 +216,7 @@ namespace osu.Game.Overlays playList = beatmaps.GetAllWithChildren(); backgroundSprite = new MusicControllerBackground(); - AddInternal(backgroundSprite); + dragContainer.Add(backgroundSprite); } protected override void LoadComplete() @@ -333,7 +339,7 @@ namespace osu.Game.Overlays (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate { - Add(newBackground); + dragContainer.Add(newBackground); switch (direction) { diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 783f7b65da..d6db3282a2 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Toolbar { public class Toolbar : OverlayContainer { - private const float height = 50; + public const float HEIGHT = 50; public Action OnHome; public Action OnPlayModeChange; @@ -120,7 +120,7 @@ namespace osu.Game.Overlays.Toolbar }; RelativeSizeAxes = Axes.X; - Size = new Vector2(1, height); + Size = new Vector2(1, HEIGHT); } public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode); From b2ec3508d57f832edd54a08a8453a22b0fa9de8e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 30 Jan 2017 22:16:17 +0900 Subject: [PATCH 02/10] Add shadow to opaque toolbar elements. --- osu.Game/Overlays/Toolbar/ToolbarButton.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 47f2df8d3f..bd404a0e84 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -168,6 +168,12 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Both; Masking = true; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(40), + Radius = 5, + }; Children = new Drawable[] { From 74366c620bab4374059c180068ce24f33ed06d72 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 30 Jan 2017 22:53:50 +0900 Subject: [PATCH 03/10] Move login screen to toolbar and update design (still not fully implemented). # Conflicts: # osu.Game/Overlays/Options/General/LoginOptions.cs # osu.Game/Overlays/Toolbar/Toolbar.cs --- osu.Game/OsuGame.cs | 2 + osu.Game/Overlays/LoginOverlay.cs | 64 +++++++++++++++++++ osu.Game/Overlays/MusicController.cs | 2 - .../Options/General/GeneralSection.cs | 1 - .../Overlays/Options/General/LoginOptions.cs | 56 ++++++++-------- osu.Game/Overlays/Toolbar/Toolbar.cs | 59 +++++++++-------- .../Overlays/Toolbar/ToolbarUserButton.cs | 24 ++++++- osu.Game/osu.Game.csproj | 1 + 8 files changed, 150 insertions(+), 59 deletions(-) create mode 100644 osu.Game/Overlays/LoginOverlay.cs diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 0309d60834..592f9143e9 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -106,6 +106,8 @@ namespace osu.Game { Depth = -3, Position = new Vector2(0, Toolbar.HEIGHT), + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, }).Preload(this, overlayContent.Add); Dependencies.Cache(options); diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs new file mode 100644 index 0000000000..5b69c85eb4 --- /dev/null +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -0,0 +1,64 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Game.Graphics; +using osu.Game.Overlays.Options.General; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays +{ + class LoginOverlay : OverlayContainer + { + private LoginOptions optionsSection; + + public LoginOverlay() + { + Width = 360; + AutoSizeAxes = Axes.Y; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Children = new Drawable[] + { + new Box { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.8f, + }, + optionsSection = new LoginOptions() + { + Padding = new MarginPadding(10), + }, + new Box { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = 3, + Colour = colours.Yellow, + Alpha = 1, + }, + }; + } + + protected override void PopIn() + { + optionsSection.ScaleTo(new Vector2(1, 1), 300, EasingTypes.OutExpo); + FadeIn(200); + } + + protected override void PopOut() + { + optionsSection.ScaleTo(new Vector2(1, 0), 300, EasingTypes.OutExpo); + FadeOut(200); + } + } +} diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 8730309a6a..fa70841e5c 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -52,8 +52,6 @@ namespace osu.Game.Overlays Width = 400; Height = 130; - Anchor = Anchor.TopRight;//placeholder - Origin = Anchor.TopRight; Margin = new MarginPadding(10); } diff --git a/osu.Game/Overlays/Options/General/GeneralSection.cs b/osu.Game/Overlays/Options/General/GeneralSection.cs index d91734db1f..cbcb1857a6 100644 --- a/osu.Game/Overlays/Options/General/GeneralSection.cs +++ b/osu.Game/Overlays/Options/General/GeneralSection.cs @@ -15,7 +15,6 @@ namespace osu.Game.Overlays.Options.General { Children = new Drawable[] { - new LoginOptions(), new LanguageOptions(), new UpdateOptions(), }; diff --git a/osu.Game/Overlays/Options/General/LoginOptions.cs b/osu.Game/Overlays/Options/General/LoginOptions.cs index 333b794d58..48a310f060 100644 --- a/osu.Game/Overlays/Options/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/General/LoginOptions.cs @@ -11,8 +11,8 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; -using osu.Game.Configuration; - +using osu.Game.Configuration; + namespace osu.Game.Overlays.Options.General { public class LoginOptions : OptionsSubsection, IOnlineComponent @@ -21,8 +21,8 @@ namespace osu.Game.Overlays.Options.General [BackgroundDependencyLoader(permitNulls: true)] private void load(APIAccess api) - { - api?.Register(this); + { + api?.Register(this); } public void APIStateChanged(APIAccess api, APIState state) @@ -86,10 +86,10 @@ namespace osu.Game.Overlays.Options.General api.Login(username.Text, password.Text); } - [BackgroundDependencyLoader(permitNulls: true)] - private void load(APIAccess api, OsuConfigManager config) - { - this.api = api; + [BackgroundDependencyLoader(permitNulls: true)] + private void load(APIAccess api, OsuConfigManager config) + { + this.api = api; Direction = FlowDirection.VerticalOnly; AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; @@ -97,41 +97,41 @@ namespace osu.Game.Overlays.Options.General Children = new Drawable[] { new SpriteText { Text = "Username" }, - username = new TextBox - { - Height = 20, - RelativeSizeAxes = Axes.X, - Text = api?.Username ?? string.Empty + username = new TextBox + { + Height = 20, + RelativeSizeAxes = Axes.X, + Text = api?.Username ?? string.Empty }, new SpriteText { Text = "Password" }, - password = new PasswordTextBox - { - Height = 20, - RelativeSizeAxes = Axes.X + password = new PasswordTextBox + { + Height = 20, + RelativeSizeAxes = Axes.X }, - saveUsername = new CheckBoxOption - { - LabelText = "Remember Username", - Bindable = config.GetBindable(OsuConfig.SaveUsername), + saveUsername = new CheckBoxOption + { + LabelText = "Remember username", + Bindable = config.GetBindable(OsuConfig.SaveUsername), }, - savePassword = new CheckBoxOption - { - LabelText = "Remember Password", - Bindable = config.GetBindable(OsuConfig.SavePassword), + savePassword = new CheckBoxOption + { + LabelText = "Stay logged in", + Bindable = config.GetBindable(OsuConfig.SavePassword), }, new OsuButton { RelativeSizeAxes = Axes.X, - Text = "Log in", + Text = "Sign in", Action = performLogin }, new OsuButton { RelativeSizeAxes = Axes.X, - Text = "Register", + Text = "Register new account", //Action = registerLink } - }; + }; } } } diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index d6db3282a2..9af43b5072 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -33,31 +33,7 @@ namespace osu.Game.Overlays.Toolbar private const float alpha_hovering = 0.8f; private const float alpha_normal = 0.6f; - - protected override void PopIn() - { - MoveToY(0, transition_time, EasingTypes.OutQuint); - FadeIn(transition_time, EasingTypes.OutQuint); - } - - protected override void PopOut() - { - MoveToY(-DrawSize.Y, transition_time, EasingTypes.InQuint); - FadeOut(transition_time, EasingTypes.InQuint); - } - - protected override bool OnHover(InputState state) - { - solidBackground.FadeTo(alpha_hovering, transition_time, EasingTypes.OutQuint); - gradientBackground.FadeIn(transition_time, EasingTypes.OutQuint); - return true; - } - - protected override void OnHoverLost(InputState state) - { - solidBackground.FadeTo(alpha_normal, transition_time, EasingTypes.OutQuint); - gradientBackground.FadeOut(transition_time, EasingTypes.OutQuint); - } + public override bool Contains(Vector2 screenSpacePos) => true; public Toolbar() { @@ -96,7 +72,7 @@ namespace osu.Game.Overlays.Toolbar } } }, - new FlowContainer + new PassThroughFlowContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -124,5 +100,36 @@ namespace osu.Game.Overlays.Toolbar } public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode); + + protected override void PopIn() + { + MoveToY(0, transition_time, EasingTypes.OutQuint); + FadeIn(transition_time, EasingTypes.OutQuint); + } + + protected override void PopOut() + { + MoveToY(-DrawSize.Y, transition_time, EasingTypes.InQuint); + FadeOut(transition_time, EasingTypes.InQuint); + } + + protected override bool OnHover(InputState state) + { + solidBackground.FadeTo(alpha_hovering, transition_time, EasingTypes.OutQuint); + gradientBackground.FadeIn(transition_time, EasingTypes.OutQuint); + return true; + } + + protected override void OnHoverLost(InputState state) + { + solidBackground.FadeTo(alpha_normal, transition_time, EasingTypes.OutQuint); + gradientBackground.FadeOut(transition_time, EasingTypes.OutQuint); + } + + class PassThroughFlowContainer : FlowContainer + { + //needed to get input to the login overlay. + public override bool Contains(Vector2 screenSpacePos) => true; + } } } diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index e093dbeca0..e9f5b8bdaf 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -12,17 +12,18 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Game.Configuration; using osu.Game.Online.API; using OpenTK; using OpenTK.Graphics; using osu.Game.Graphics; +using osu.Framework.Input; namespace osu.Game.Overlays.Toolbar { class ToolbarUserButton : ToolbarButton, IOnlineComponent { private Avatar avatar; + private LoginOverlay loginOverlay; public ToolbarUserButton() { @@ -33,10 +34,29 @@ namespace osu.Game.Overlays.Toolbar Flow.Add(avatar = new Avatar()); } + public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || loginOverlay.Contains(screenSpacePos); + [BackgroundDependencyLoader] - private void load(APIAccess api, OsuConfigManager config) + private void load(APIAccess api, OsuGameBase game) { api.Register(this); + + (loginOverlay = new LoginOverlay + { + Position = new Vector2(0, 1), + RelativePositionAxes = Axes.Y, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }).Preload(game, Add); + } + + protected override bool OnClick(InputState state) + { + if (!base.Contains(state.Mouse.NativeState.Position)) return false; + + loginOverlay.ToggleVisibility(); + + return base.OnClick(state); } public void APIStateChanged(APIAccess api, APIState state) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a90fa2a8cb..cfbb83e2a6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -74,6 +74,7 @@ + From 2aa924c10400530619035e9c234a2552beb7bbca Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 30 Jan 2017 23:24:30 +0900 Subject: [PATCH 04/10] Fix global hover regression. --- osu.Game/Overlays/Toolbar/Toolbar.cs | 73 ++++++++++++++++------------ 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 9af43b5072..35a6586260 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -25,8 +25,6 @@ namespace osu.Game.Overlays.Toolbar public Action OnPlayModeChange; private ToolbarModeSelector modeSelector; - private Box solidBackground; - private Box gradientBackground; private const int transition_time = 250; @@ -39,21 +37,7 @@ namespace osu.Game.Overlays.Toolbar { Children = new Drawable[] { - solidBackground = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(0.1f), - Alpha = alpha_normal, - }, - gradientBackground = new Box - { - RelativeSizeAxes = Axes.X, - Anchor = Anchor.BottomLeft, - Alpha = 0, - Height = 90, - ColourInfo = ColourInfo.GradientVertical( - OsuColour.Gray(0.1f).Opacity(0.5f), OsuColour.Gray(0.1f).Opacity(0)), - }, + new ToolbarBackground(), new FlowContainer { Direction = FlowDirection.HorizontalOnly, @@ -99,6 +83,48 @@ namespace osu.Game.Overlays.Toolbar Size = new Vector2(1, HEIGHT); } + public class ToolbarBackground : Container + { + private Box solidBackground; + private Box gradientBackground; + + public ToolbarBackground() + { + RelativeSizeAxes = Axes.Both; + Children = new Drawable[] + { + solidBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(0.1f), + Alpha = alpha_normal, + }, + gradientBackground = new Box + { + RelativeSizeAxes = Axes.X, + Anchor = Anchor.BottomLeft, + Alpha = 0, + Height = 90, + ColourInfo = ColourInfo.GradientVertical( + OsuColour.Gray(0.1f).Opacity(0.5f), OsuColour.Gray(0.1f).Opacity(0)), + }, + }; + } + + protected override bool OnHover(InputState state) + { + solidBackground.FadeTo(alpha_hovering, transition_time, EasingTypes.OutQuint); + gradientBackground.FadeIn(transition_time, EasingTypes.OutQuint); + return true; + } + + protected override void OnHoverLost(InputState state) + { + solidBackground.FadeTo(alpha_normal, transition_time, EasingTypes.OutQuint); + gradientBackground.FadeOut(transition_time, EasingTypes.OutQuint); + } + } + public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode); protected override void PopIn() @@ -113,19 +139,6 @@ namespace osu.Game.Overlays.Toolbar FadeOut(transition_time, EasingTypes.InQuint); } - protected override bool OnHover(InputState state) - { - solidBackground.FadeTo(alpha_hovering, transition_time, EasingTypes.OutQuint); - gradientBackground.FadeIn(transition_time, EasingTypes.OutQuint); - return true; - } - - protected override void OnHoverLost(InputState state) - { - solidBackground.FadeTo(alpha_normal, transition_time, EasingTypes.OutQuint); - gradientBackground.FadeOut(transition_time, EasingTypes.OutQuint); - } - class PassThroughFlowContainer : FlowContainer { //needed to get input to the login overlay. From 4cf2993db14af865a06f5db1ec2b5ddf2c8b2adf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 30 Jan 2017 23:25:37 +0900 Subject: [PATCH 05/10] Fix lack of visibility check causing weird hover regions. --- osu.Game/Overlays/Toolbar/ToolbarUserButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index e9f5b8bdaf..e20795e8ad 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Toolbar Flow.Add(avatar = new Avatar()); } - public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || loginOverlay.Contains(screenSpacePos); + public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || (loginOverlay.IsVisible && loginOverlay.Contains(screenSpacePos)); [BackgroundDependencyLoader] private void load(APIAccess api, OsuGameBase game) From 3476abc38bff61b14132bd723e09e8ffefa5d87e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 31 Jan 2017 16:42:46 +0900 Subject: [PATCH 06/10] Add proper masking support to the login overlay. --- osu.Game/Overlays/LoginOverlay.cs | 47 ++++++++++++------- .../Overlays/Options/General/LoginOptions.cs | 17 ++++++- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index 5b69c85eb4..9a4a6e8895 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -18,10 +18,11 @@ namespace osu.Game.Overlays { private LoginOptions optionsSection; + const float transition_time = 300; + public LoginOverlay() { - Width = 360; - AutoSizeAxes = Axes.Y; + AutoSizeAxes = Axes.Both; } [BackgroundDependencyLoader] @@ -34,31 +35,43 @@ namespace osu.Game.Overlays Colour = Color4.Black, Alpha = 0.8f, }, - optionsSection = new LoginOptions() + new Container { - Padding = new MarginPadding(10), - }, - new Box { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = 3, - Colour = colours.Yellow, - Alpha = 1, - }, + Width = 360, + AutoSizeAxes = Axes.Y, + Masking = true, + AutoSizeDuration = transition_time, + AutoSizeEasing = EasingTypes.OutQuint, + Children = new Drawable[] + { + optionsSection = new LoginOptions + { + Padding = new MarginPadding(10), + }, + new Box + { + RelativeSizeAxes = Axes.X, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Height = 3, + Colour = colours.Yellow, + Alpha = 1, + }, + } + } }; } protected override void PopIn() { - optionsSection.ScaleTo(new Vector2(1, 1), 300, EasingTypes.OutExpo); - FadeIn(200); + optionsSection.Bounding = true; + FadeIn(transition_time, EasingTypes.OutQuint); } protected override void PopOut() { - optionsSection.ScaleTo(new Vector2(1, 0), 300, EasingTypes.OutExpo); - FadeOut(200); + optionsSection.Bounding = false; + FadeOut(transition_time, EasingTypes.OutQuint); } } } diff --git a/osu.Game/Overlays/Options/General/LoginOptions.cs b/osu.Game/Overlays/Options/General/LoginOptions.cs index 48a310f060..a47e775cd7 100644 --- a/osu.Game/Overlays/Options/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/General/LoginOptions.cs @@ -12,13 +12,28 @@ using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Configuration; - +using osu.Framework.Graphics.Primitives; + namespace osu.Game.Overlays.Options.General { public class LoginOptions : OptionsSubsection, IOnlineComponent { + private bool bounding = true; + protected override string Header => "Sign In"; + public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty; + + public bool Bounding + { + get { return bounding; } + set + { + bounding = value; + Invalidate(Invalidation.SizeInParentSpace); + } + } + [BackgroundDependencyLoader(permitNulls: true)] private void load(APIAccess api) { From 22ef576c6445e97c1ec32feae0658a7674da7fbe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 31 Jan 2017 16:59:38 +0900 Subject: [PATCH 07/10] Make LoginOverlay mask better. --- osu-framework | 2 +- osu.Game/Overlays/Toolbar/Toolbar.cs | 4 +- osu.Game/Overlays/Toolbar/ToolbarButton.cs | 1 + osu.Game/Overlays/Toolbar/ToolbarUserArea.cs | 46 +++++++++++++++++++ .../Overlays/Toolbar/ToolbarUserButton.cs | 28 +---------- osu.Game/osu.Game.csproj | 1 + 6 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 osu.Game/Overlays/Toolbar/ToolbarUserArea.cs diff --git a/osu-framework b/osu-framework index 2f03fae533..b10125a733 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 2f03fae533293bf255a942569c07396f853378f3 +Subproject commit b10125a7334c07221503163a289522bddf6b793d diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 35a6586260..224c897875 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -63,14 +63,14 @@ namespace osu.Game.Overlays.Toolbar Direction = FlowDirection.HorizontalOnly, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, - Children = new [] + Children = new Drawable[] { new ToolbarMusicButton(), new ToolbarButton { Icon = FontAwesome.fa_search }, - new ToolbarUserButton(), + new ToolbarUserArea(), new ToolbarButton { Icon = FontAwesome.fa_bars diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index bd404a0e84..cfdb71f3ce 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -122,6 +122,7 @@ namespace osu.Game.Overlays.Toolbar }; RelativeSizeAxes = Axes.Y; + AutoSizeAxes = Axes.X; } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs new file mode 100644 index 0000000000..a6feffab65 --- /dev/null +++ b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs @@ -0,0 +1,46 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using OpenTK; + +namespace osu.Game.Overlays.Toolbar +{ + class ToolbarUserArea : Container + { + private LoginOverlay loginOverlay; + private ToolbarUserButton button; + + public override RectangleF BoundingBox => button.BoundingBox; + + public override bool Contains(Vector2 screenSpacePos) => true; + + public override Vector2 Size => button.Size; + + public ToolbarUserArea() + { + RelativeSizeAxes = Axes.Y; + + Children = new Drawable[] { + button = new ToolbarUserButton + { + Action = toggle, + }, + loginOverlay = new LoginOverlay + { + Position = new Vector2(0, 1), + RelativePositionAxes = Axes.Y, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + } + }; + } + + private void toggle() + { + loginOverlay.ToggleVisibility(); + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index e20795e8ad..d1af30e88d 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -1,12 +1,7 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -16,14 +11,12 @@ using osu.Game.Online.API; using OpenTK; using OpenTK.Graphics; using osu.Game.Graphics; -using osu.Framework.Input; namespace osu.Game.Overlays.Toolbar { class ToolbarUserButton : ToolbarButton, IOnlineComponent { private Avatar avatar; - private LoginOverlay loginOverlay; public ToolbarUserButton() { @@ -34,29 +27,10 @@ namespace osu.Game.Overlays.Toolbar Flow.Add(avatar = new Avatar()); } - public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || (loginOverlay.IsVisible && loginOverlay.Contains(screenSpacePos)); - [BackgroundDependencyLoader] - private void load(APIAccess api, OsuGameBase game) + private void load(APIAccess api) { api.Register(this); - - (loginOverlay = new LoginOverlay - { - Position = new Vector2(0, 1), - RelativePositionAxes = Axes.Y, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - }).Preload(game, Add); - } - - protected override bool OnClick(InputState state) - { - if (!base.Contains(state.Mouse.NativeState.Position)) return false; - - loginOverlay.ToggleVisibility(); - - return base.OnClick(state); } public void APIStateChanged(APIAccess api, APIState state) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index cfbb83e2a6..e525317736 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -98,6 +98,7 @@ + From 6cd9f93fb5c0ad756ea33c8ea910634fd7b3595b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 31 Jan 2017 17:05:42 +0900 Subject: [PATCH 08/10] Adjust transitions slightly. --- osu.Game/Overlays/LoginOverlay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index 9a4a6e8895..91bea093db 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays { private LoginOptions optionsSection; - const float transition_time = 300; + const float transition_time = 400; public LoginOverlay() { @@ -71,7 +71,7 @@ namespace osu.Game.Overlays protected override void PopOut() { optionsSection.Bounding = false; - FadeOut(transition_time, EasingTypes.OutQuint); + FadeOut(transition_time); } } } From 64f4098791e3e9bb28f70edd9b4aed1e01198ca6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 31 Jan 2017 17:05:54 +0900 Subject: [PATCH 09/10] Move MusicController beneath Toolbar. --- osu.Game/OsuGame.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 592f9143e9..ede86db1db 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -104,7 +104,7 @@ namespace osu.Game (options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add); (musicController = new MusicController() { - Depth = -3, + Depth = -2, Position = new Vector2(0, Toolbar.HEIGHT), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -115,7 +115,7 @@ namespace osu.Game (Toolbar = new Toolbar { - Depth = -2, + Depth = -3, OnHome = delegate { mainMenu?.MakeCurrent(); }, OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, }).Preload(this, t => From 20ee1872b44e0af8ca0d83e7543e24140fd27f59 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 31 Jan 2017 17:15:46 +0900 Subject: [PATCH 10/10] Broaden invalidation. --- osu.Game/Overlays/Options/General/LoginOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Options/General/LoginOptions.cs b/osu.Game/Overlays/Options/General/LoginOptions.cs index 9814c2e832..6556c238a4 100644 --- a/osu.Game/Overlays/Options/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/General/LoginOptions.cs @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Options.General set { bounding = value; - Invalidate(Invalidation.SizeInParentSpace); + Invalidate(Invalidation.Geometry); } }