osu/osu.Game/Screens/Select/Leaderboards/RetrievalFailurePlaceholder.cs

65 lines
1.8 KiB
C#
Raw Normal View History

2018-04-13 09:19:50 +00:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics;
2018-10-02 03:02:47 +00:00
using osu.Framework.Input.Events;
2018-04-13 09:19:50 +00:00
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
2018-11-20 07:51:59 +00:00
using osuTK;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Screens.Select.Leaderboards
{
public class RetrievalFailurePlaceholder : Placeholder
{
public Action OnRetry;
public RetrievalFailurePlaceholder()
{
2018-06-28 04:04:39 +00:00
AddArbitraryDrawable(new RetryButton
2018-04-13 09:19:50 +00:00
{
2018-06-28 04:04:39 +00:00
Action = () => OnRetry?.Invoke(),
Padding = new MarginPadding { Right = 10 }
});
AddText(@"Couldn't retrieve scores!");
2018-04-13 09:19:50 +00:00
}
public class RetryButton : OsuHoverContainer
{
private readonly SpriteIcon icon;
public new Action Action;
public RetryButton()
{
2018-06-28 04:04:39 +00:00
AutoSizeAxes = Axes.Both;
2018-04-13 09:19:50 +00:00
Child = new OsuClickableContainer
{
AutoSizeAxes = Axes.Both,
Action = () => Action?.Invoke(),
Child = icon = new SpriteIcon
{
Icon = FontAwesome.fa_refresh,
2018-06-28 04:04:39 +00:00
Size = new Vector2(TEXT_SIZE),
2018-04-13 09:19:50 +00:00
Shadow = true,
},
};
}
2018-10-02 03:02:47 +00:00
protected override bool OnMouseDown(MouseDownEvent e)
2018-04-13 09:19:50 +00:00
{
icon.ScaleTo(0.8f, 4000, Easing.OutQuint);
2018-10-02 03:02:47 +00:00
return base.OnMouseDown(e);
2018-04-13 09:19:50 +00:00
}
2018-10-02 03:02:47 +00:00
protected override bool OnMouseUp(MouseUpEvent e)
2018-04-13 09:19:50 +00:00
{
icon.ScaleTo(1, 1000, Easing.OutElastic);
2018-10-02 03:02:47 +00:00
return base.OnMouseUp(e);
2018-04-13 09:19:50 +00:00
}
}
}
}