1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

ShowMoreButton rework

This commit is contained in:
Andrei Zavatski 2020-07-28 00:43:06 +03:00
parent 1b5a23311e
commit 46d1de7fa7
2 changed files with 16 additions and 24 deletions

View File

@ -8,38 +8,43 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using System.Collections.Generic; using System.Collections.Generic;
using osuTK; using osuTK;
using osu.Framework.Allocation;
namespace osu.Game.Overlays.Comments namespace osu.Game.Overlays.Comments.Buttons
{ {
public abstract class GetCommentRepliesButton : LoadingButton public class ShowMoreButton : LoadingButton
{ {
private const int duration = 200;
protected override IEnumerable<Drawable> EffectTargets => new[] { text }; protected override IEnumerable<Drawable> EffectTargets => new[] { text };
private OsuSpriteText text; private OsuSpriteText text;
protected GetCommentRepliesButton() public ShowMoreButton()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Margin = new MarginPadding { Vertical = 10, Left = 80 };
LoadingAnimationSize = new Vector2(8); LoadingAnimationSize = new Vector2(8);
} }
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
IdleColour = colourProvider.Light2;
HoverColour = colourProvider.Light1;
}
protected override Drawable CreateContent() => new Container protected override Drawable CreateContent() => new Container
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Child = text = new OsuSpriteText Child = text = new OsuSpriteText
{ {
AlwaysPresent = true, AlwaysPresent = true,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
Text = GetText() Text = "show more"
} }
}; };
protected abstract string GetText(); protected override void OnLoadStarted() => text.FadeOut(200, Easing.OutQuint);
protected override void OnLoadStarted() => text.FadeOut(duration, Easing.OutQuint); protected override void OnLoadFinished() => text.FadeIn(200, Easing.OutQuint);
protected override void OnLoadFinished() => text.FadeIn(duration, Easing.OutQuint);
} }
} }

View File

@ -363,19 +363,6 @@ namespace osu.Game.Overlays.Comments
showMoreButton.IsLoading = loadRepliesButton.IsLoading = false; showMoreButton.IsLoading = loadRepliesButton.IsLoading = false;
} }
private class ShowMoreButton : GetCommentRepliesButton
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
Margin = new MarginPadding { Vertical = 10, Left = 80 };
IdleColour = colourProvider.Light2;
HoverColour = colourProvider.Light1;
}
protected override string GetText() => @"Show More";
}
private class ParentUsername : FillFlowContainer, IHasTooltip private class ParentUsername : FillFlowContainer, IHasTooltip
{ {
public string TooltipText => getParentMessage(); public string TooltipText => getParentMessage();