Use an OsuAnimatedButton in LoginPlaceholder to get the correct animations.

This commit is contained in:
Lucas A
2020-03-04 17:01:37 +01:00
parent aaa0f908d5
commit ea29f7c344

View File

@ -4,43 +4,39 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays; using osu.Game.Overlays;
namespace osu.Game.Online.Placeholders namespace osu.Game.Online.Placeholders
{ {
public sealed class LoginPlaceholder : Placeholder public sealed class LoginPlaceholder : Placeholder
{
public LoginPlaceholder(string actionMessage)
{
AddArbitraryDrawable(new LoginButton(actionMessage));
}
private class LoginButton : OsuAnimatedButton
{ {
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private LoginOverlay login { get; set; } private LoginOverlay login { get; set; }
public LoginPlaceholder(string actionMessage) public LoginButton(string actionMessage)
{ {
AddIcon(FontAwesome.Solid.UserLock, cp => AutoSizeAxes = Axes.Both;
{
cp.Font = cp.Font.With(size: TEXT_SIZE);
cp.Padding = new MarginPadding { Right = 10 };
});
AddText(actionMessage); Child = new OsuTextFlowContainer(cp => cp.Font = cp.Font.With(size: TEXT_SIZE))
} .With(t => t.AutoSizeAxes = Axes.Both)
.With(t => t.AddIcon(FontAwesome.Solid.UserLock, icon =>
protected override bool OnMouseDown(MouseDownEvent e)
{ {
this.ScaleTo(0.8f, 4000, Easing.OutQuint); icon.Padding = new MarginPadding { Right = 10 };
return base.OnMouseDown(e); }))
} .With(t => t.AddText(actionMessage))
.With(t => t.Margin = new MarginPadding(5));
protected override void OnMouseUp(MouseUpEvent e) Action = () => login?.Show();
{ }
this.ScaleTo(1, 1000, Easing.OutElastic);
base.OnMouseUp(e);
}
protected override bool OnClick(ClickEvent e)
{
login?.Show();
return base.OnClick(e);
} }
} }
} }