mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 22:22:55 +08:00
Remove custom styled text
This commit is contained in:
parent
e88da95379
commit
3b7d26cca8
@ -24,7 +24,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(Header),
|
||||
typeof(ClickableUserContainer),
|
||||
typeof(ScoreTable),
|
||||
typeof(ScoreTableRow),
|
||||
typeof(ScoreTableHeaderRow),
|
||||
|
@ -1,51 +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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
public abstract class ClickableUserContainer : Container
|
||||
{
|
||||
private UserProfileOverlay profile;
|
||||
|
||||
protected ClickableUserContainer()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(UserProfileOverlay profile)
|
||||
{
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
private User user;
|
||||
|
||||
public User User
|
||||
{
|
||||
get => user;
|
||||
set
|
||||
{
|
||||
if (user == value)
|
||||
return;
|
||||
|
||||
user = value;
|
||||
|
||||
OnUserChanged(user);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void OnUserChanged(User user);
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
profile?.ShowUser(user);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,10 +5,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Online.Leaderboards;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
@ -53,17 +53,27 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White
|
||||
};
|
||||
|
||||
protected override Drawable CreatePlayerCell() => new FillFlowContainer
|
||||
protected override Drawable CreatePlayerCell()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5, 0),
|
||||
Children = new Drawable[]
|
||||
var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE))
|
||||
{
|
||||
new DrawableFlag(score.User.Country) { Size = new Vector2(20, 13) },
|
||||
new ClickableScoreUsername { User = score.User }
|
||||
}
|
||||
};
|
||||
AutoSizeAxes = Axes.Both,
|
||||
};
|
||||
|
||||
username.AddLink(score.User.Username, null, LinkAction.OpenUserProfile, score.User.Id.ToString(), "Open profile");
|
||||
|
||||
return new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DrawableFlag(score.User.Country) { Size = new Vector2(20, 13) },
|
||||
username
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override IEnumerable<Drawable> CreateStatisticsCells()
|
||||
{
|
||||
@ -100,47 +110,5 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
Scale = new Vector2(0.3f)
|
||||
})
|
||||
};
|
||||
|
||||
private class ClickableScoreUsername : ClickableUserContainer
|
||||
{
|
||||
private const int fade_duration = 100;
|
||||
|
||||
private readonly SpriteText text;
|
||||
private readonly SpriteText textBold;
|
||||
|
||||
public ClickableScoreUsername()
|
||||
{
|
||||
Add(text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Font = OsuFont.GetFont(size: TEXT_SIZE)
|
||||
});
|
||||
|
||||
Add(textBold = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold),
|
||||
Alpha = 0,
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnUserChanged(User user) => text.Text = textBold.Text = user.Username;
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
textBold.Show();
|
||||
text.Hide();
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
textBold.Hide();
|
||||
text.Show();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Online.Leaderboards;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
@ -24,7 +24,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
private readonly SpriteText rankText;
|
||||
private readonly DrawableRank rank;
|
||||
private readonly UpdateableAvatar avatar;
|
||||
private readonly UsernameText usernameText;
|
||||
private readonly LinkFlowContainer usernameText;
|
||||
private readonly SpriteText date;
|
||||
private readonly DrawableFlag flag;
|
||||
|
||||
@ -77,10 +77,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
Spacing = new Vector2(0, 3),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
usernameText = new UsernameText
|
||||
usernameText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold, italics: true))
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
},
|
||||
date = new SpriteText
|
||||
{
|
||||
@ -113,69 +114,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
set
|
||||
{
|
||||
avatar.User = usernameText.User = value.User;
|
||||
avatar.User = value.User;
|
||||
flag.Country = value.User.Country;
|
||||
date.Text = $@"achieved {value.Date.Humanize()}";
|
||||
|
||||
usernameText.Clear();
|
||||
usernameText.AddLink(value.User.Username, null, LinkAction.OpenUserProfile, value.User.Id.ToString(), "Open profile");
|
||||
|
||||
rank.UpdateRank(value.Rank);
|
||||
}
|
||||
}
|
||||
|
||||
private class UsernameText : ClickableUserContainer
|
||||
{
|
||||
private const float username_fade_duration = 150;
|
||||
|
||||
private readonly FillFlowContainer hoverContainer;
|
||||
|
||||
private readonly SpriteText normalText;
|
||||
private readonly SpriteText hoveredText;
|
||||
|
||||
public UsernameText()
|
||||
{
|
||||
var font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold, italics: true);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
normalText = new OsuSpriteText { Font = font },
|
||||
hoverContainer = new FillFlowContainer
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
hoverContainer.Colour = colours.Blue;
|
||||
}
|
||||
|
||||
protected override void OnUserChanged(User user) => normalText.Text = hoveredText.Text = user.Username;
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
hoverContainer.FadeIn(username_fade_duration, Easing.OutQuint);
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
hoverContainer.FadeOut(username_fade_duration, Easing.OutQuint);
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user