1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:42:54 +08:00

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
This commit is contained in:
Dean Herbert 2017-01-30 22:53:50 +09:00
parent b2ec3508d5
commit 74366c620b
8 changed files with 150 additions and 59 deletions

View File

@ -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);

View File

@ -0,0 +1,64 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//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);
}
}
}

View File

@ -52,8 +52,6 @@ namespace osu.Game.Overlays
Width = 400;
Height = 130;
Anchor = Anchor.TopRight;//placeholder
Origin = Anchor.TopRight;
Margin = new MarginPadding(10);
}

View File

@ -15,7 +15,6 @@ namespace osu.Game.Overlays.Options.General
{
Children = new Drawable[]
{
new LoginOptions(),
new LanguageOptions(),
new UpdateOptions(),
};

View File

@ -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<bool>(OsuConfig.SaveUsername),
saveUsername = new CheckBoxOption
{
LabelText = "Remember username",
Bindable = config.GetBindable<bool>(OsuConfig.SaveUsername),
},
savePassword = new CheckBoxOption
{
LabelText = "Remember Password",
Bindable = config.GetBindable<bool>(OsuConfig.SavePassword),
savePassword = new CheckBoxOption
{
LabelText = "Stay logged in",
Bindable = config.GetBindable<bool>(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
}
};
};
}
}
}

View File

@ -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;
}
}
}

View File

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

View File

@ -74,6 +74,7 @@
<Compile Include="Online\API\IOnlineComponent.cs" />
<Compile Include="Online\API\Requests\GetUserRequest.cs" />
<Compile Include="Overlays\DragBar.cs" />
<Compile Include="Overlays\LoginOverlay.cs" />
<Compile Include="Overlays\MusicController.cs" />
<Compile Include="Beatmaps\Beatmap.cs" />
<Compile Include="Beatmaps\Formats\ConstructableBeatmapDecoder.cs" />