mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:32:55 +08:00
Create ClickablePlaceholder and make of use it where applicable.
This commit is contained in:
parent
b1b3e01abd
commit
e136ecec5f
@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
typeof(Placeholder),
|
typeof(Placeholder),
|
||||||
typeof(MessagePlaceholder),
|
typeof(MessagePlaceholder),
|
||||||
typeof(RetrievalFailurePlaceholder),
|
typeof(ClickablePlaceholder),
|
||||||
typeof(UserTopScoreContainer),
|
typeof(UserTopScoreContainer),
|
||||||
typeof(Leaderboard<BeatmapLeaderboardScope, ScoreInfo>),
|
typeof(Leaderboard<BeatmapLeaderboardScope, ScoreInfo>),
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
typeof(Placeholder),
|
typeof(Placeholder),
|
||||||
typeof(MessagePlaceholder),
|
typeof(MessagePlaceholder),
|
||||||
typeof(RetrievalFailurePlaceholder),
|
typeof(ClickablePlaceholder),
|
||||||
typeof(UserTopScoreContainer),
|
typeof(UserTopScoreContainer),
|
||||||
typeof(Leaderboard<BeatmapLeaderboardScope, ScoreInfo>),
|
typeof(Leaderboard<BeatmapLeaderboardScope, ScoreInfo>),
|
||||||
typeof(LeaderboardScore),
|
typeof(LeaderboardScore),
|
||||||
|
@ -10,6 +10,7 @@ using osu.Framework.Extensions.Color4Extensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
@ -133,9 +134,9 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
switch (placeholderState = value)
|
switch (placeholderState = value)
|
||||||
{
|
{
|
||||||
case PlaceholderState.NetworkFailure:
|
case PlaceholderState.NetworkFailure:
|
||||||
replacePlaceholder(new RetrievalFailurePlaceholder
|
replacePlaceholder(new ClickablePlaceholder(@"Couldn't fetch scores!", FontAwesome.Solid.Sync)
|
||||||
{
|
{
|
||||||
OnRetry = UpdateScores,
|
Action = UpdateScores,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Online.Placeholders;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Online.Leaderboards
|
|
||||||
{
|
|
||||||
public class RetrievalFailurePlaceholder : Placeholder
|
|
||||||
{
|
|
||||||
public Action OnRetry;
|
|
||||||
|
|
||||||
public RetrievalFailurePlaceholder()
|
|
||||||
{
|
|
||||||
AddArbitraryDrawable(new RetryButton
|
|
||||||
{
|
|
||||||
Action = () => OnRetry?.Invoke(),
|
|
||||||
Padding = new MarginPadding { Right = 10 }
|
|
||||||
});
|
|
||||||
|
|
||||||
AddText(@"Couldn't retrieve scores!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public class RetryButton : OsuHoverContainer
|
|
||||||
{
|
|
||||||
private readonly SpriteIcon icon;
|
|
||||||
|
|
||||||
public new Action Action;
|
|
||||||
|
|
||||||
public RetryButton()
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
Child = new OsuClickableContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Action = () => Action?.Invoke(),
|
|
||||||
Child = icon = new SpriteIcon
|
|
||||||
{
|
|
||||||
Icon = FontAwesome.Solid.Sync,
|
|
||||||
Size = new Vector2(TEXT_SIZE),
|
|
||||||
Shadow = true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
|
||||||
{
|
|
||||||
icon.ScaleTo(0.8f, 4000, Easing.OutQuint);
|
|
||||||
return base.OnMouseDown(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnMouseUp(MouseUpEvent e)
|
|
||||||
{
|
|
||||||
icon.ScaleTo(1, 1000, Easing.OutElastic);
|
|
||||||
base.OnMouseUp(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
38
osu.Game/Online/Placeholders/ClickablePlaceholder.cs
Normal file
38
osu.Game/Online/Placeholders/ClickablePlaceholder.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Placeholders
|
||||||
|
{
|
||||||
|
public class ClickablePlaceholder : Placeholder
|
||||||
|
{
|
||||||
|
public Action Action;
|
||||||
|
|
||||||
|
public ClickablePlaceholder(string actionMessage, IconUsage icon)
|
||||||
|
{
|
||||||
|
OsuTextFlowContainer textFlow;
|
||||||
|
|
||||||
|
AddArbitraryDrawable(new OsuAnimatedButton
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Framework.Graphics.Axes.Both,
|
||||||
|
Child = textFlow = new OsuTextFlowContainer(cp => cp.Font = cp.Font.With(size: TEXT_SIZE))
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Framework.Graphics.Axes.Both,
|
||||||
|
Margin = new Framework.Graphics.MarginPadding(5)
|
||||||
|
},
|
||||||
|
Action = () => Action?.Invoke()
|
||||||
|
});
|
||||||
|
|
||||||
|
textFlow.AddIcon(icon, i =>
|
||||||
|
{
|
||||||
|
i.Padding = new Framework.Graphics.MarginPadding { Right = 10 };
|
||||||
|
});
|
||||||
|
|
||||||
|
textFlow.AddText(actionMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,47 +2,20 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
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 : ClickablePlaceholder
|
||||||
{
|
|
||||||
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 LoginButton(string actionMessage)
|
public LoginPlaceholder(string actionMessage)
|
||||||
|
: base(actionMessage, FontAwesome.Solid.UserLock)
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
var textFlowContainer = new OsuTextFlowContainer(cp => cp.Font = cp.Font.With(size: TEXT_SIZE))
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Margin = new MarginPadding(5)
|
|
||||||
};
|
|
||||||
|
|
||||||
Child = textFlowContainer;
|
|
||||||
|
|
||||||
textFlowContainer.AddIcon(FontAwesome.Solid.UserLock, icon =>
|
|
||||||
{
|
|
||||||
icon.Padding = new MarginPadding { Right = 10 };
|
|
||||||
});
|
|
||||||
|
|
||||||
textFlowContainer.AddText(actionMessage);
|
|
||||||
|
|
||||||
Action = () => login?.Show();
|
Action = () => login?.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user