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

General refactoring

This commit is contained in:
smoogipoo 2019-04-03 15:20:38 +09:00
parent 0d127c21f1
commit ab4be3b75f
5 changed files with 48 additions and 54 deletions

View File

@ -24,6 +24,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(DrawableTopScore),
typeof(ScoresContainer),
typeof(ScoreTable),
typeof(ScoreTableRow),

View File

@ -12,12 +12,12 @@ namespace osu.Game.Graphics.Containers
{
public class OsuHoverContainer : OsuClickableContainer
{
protected const float FADE_DURATION = 500;
protected Color4 HoverColour;
protected Color4 IdleColour = Color4.White;
protected const float FADE_DURATION = 500;
protected virtual IEnumerable<Drawable> EffectTargets => new[] { Content };
protected override bool OnHover(HoverEvent e)

View File

@ -13,6 +13,17 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
private UserProfileOverlay profile;
protected ClickableUserContainer()
{
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader(true)]
private void load(UserProfileOverlay profile)
{
this.profile = profile;
}
private User user;
public User User
@ -20,26 +31,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
get => user;
set
{
if (user == value) return;
if (user == value)
return;
user = value;
OnUserChange(user);
OnUserChanged(user);
}
}
protected ClickableUserContainer()
{
AutoSizeAxes = Axes.Both;
}
protected abstract void OnUserChange(User user);
[BackgroundDependencyLoader(true)]
private void load(UserProfileOverlay profile)
{
this.profile = profile;
}
protected abstract void OnUserChanged(User user);
protected override bool OnClick(ClickEvent e)
{

View File

@ -19,6 +19,7 @@ using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
using System.Collections.Generic;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
@ -164,7 +165,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
TextSize = 20,
},
date = new SpriteText
{
@ -263,67 +263,59 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
private const float username_fade_duration = 500;
private readonly Box underscore;
private readonly Container underscoreContainer;
private readonly SpriteText text;
private readonly FillFlowContainer hoverContainer;
private Color4 hoverColour;
public float TextSize
{
set
{
if (text.TextSize == value)
return;
text.TextSize = value;
}
get => text.TextSize;
}
private readonly SpriteText normalText;
private readonly SpriteText hoveredText;
public ClickableTopScoreUsername()
{
Add(underscoreContainer = new Container
var font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold, italics: true);
Children = new Drawable[]
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = 1,
Child = underscore = new Box
normalText = new OsuSpriteText { Font = font },
hoverContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Alpha = 0,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 1),
Children = new Drawable[]
{
hoveredText = new OsuSpriteText { Font = font },
new Box
{
BypassAutoSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
Height = 1
}
}
}
});
Add(text = new SpriteText
{
Font = @"Exo2.0-BoldItalic",
});
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
hoverColour = underscore.Colour = colours.Blue;
underscoreContainer.Position = new Vector2(0, TextSize / 2 - 1);
hoverContainer.Colour = colours.Blue;
}
protected override void OnUserChange(User user)
protected override void OnUserChanged(User user)
{
text.Text = user.Username;
normalText.Text = hoveredText.Text = user.Username;
}
protected override bool OnHover(HoverEvent e)
{
text.FadeColour(hoverColour, username_fade_duration, Easing.OutQuint);
underscore.FadeIn(username_fade_duration, Easing.OutQuint);
hoverContainer.FadeIn(username_fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
text.FadeColour(Color4.White, username_fade_duration, Easing.OutQuint);
underscore.FadeOut(username_fade_duration, Easing.OutQuint);
hoverContainer.FadeOut(username_fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
}

View File

@ -145,7 +145,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
});
}
protected override void OnUserChange(User user)
protected override void OnUserChanged(User user)
{
text.Text = textBold.Text = user.Username;
}