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 @@ +