mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Create ClickablePlaceholder and make of use it where applicable.
This commit is contained in:
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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Online.Placeholders
|
||||
{
|
||||
public sealed class LoginPlaceholder : Placeholder
|
||||
public sealed class LoginPlaceholder : ClickablePlaceholder
|
||||
{
|
||||
[Resolved(CanBeNull = true)]
|
||||
private LoginOverlay login { get; set; }
|
||||
|
||||
public LoginPlaceholder(string actionMessage)
|
||||
: base(actionMessage, FontAwesome.Solid.UserLock)
|
||||
{
|
||||
AddArbitraryDrawable(new LoginButton(actionMessage));
|
||||
}
|
||||
|
||||
private class LoginButton : OsuAnimatedButton
|
||||
{
|
||||
[Resolved(CanBeNull = true)]
|
||||
private LoginOverlay login { get; set; }
|
||||
|
||||
public LoginButton(string actionMessage)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user