1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:09:34 +08:00
osu-lazer/osu.Game/Screens/Select/Leaderboards/RetrievalFailurePlaceholder.cs

66 lines
1.9 KiB
C#
Raw Normal View History

2018-04-13 17:19:50 +08: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-07-21 10:38:28 +08:00
using osu.Framework.Input.EventArgs;
using osu.Framework.Input.States;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using OpenTK;
namespace osu.Game.Screens.Select.Leaderboards
{
public class RetrievalFailurePlaceholder : Placeholder
{
public Action OnRetry;
public RetrievalFailurePlaceholder()
{
2018-06-28 12:04:39 +08:00
AddArbitraryDrawable(new RetryButton
2018-04-13 17:19:50 +08:00
{
2018-06-28 12:04:39 +08:00
Action = () => OnRetry?.Invoke(),
Padding = new MarginPadding { Right = 10 }
});
AddText(@"Couldn't retrieve scores!");
2018-04-13 17:19:50 +08:00
}
public class RetryButton : OsuHoverContainer
{
private readonly SpriteIcon icon;
public new Action Action;
public RetryButton()
{
2018-06-28 12:04:39 +08:00
AutoSizeAxes = Axes.Both;
2018-04-13 17:19:50 +08:00
Child = new OsuClickableContainer
{
AutoSizeAxes = Axes.Both,
Action = () => Action?.Invoke(),
Child = icon = new SpriteIcon
{
Icon = FontAwesome.fa_refresh,
2018-06-28 12:04:39 +08:00
Size = new Vector2(TEXT_SIZE),
2018-04-13 17:19:50 +08:00
Shadow = true,
},
};
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
icon.ScaleTo(0.8f, 4000, Easing.OutQuint);
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
icon.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args);
}
}
}
}