1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 09:37:23 +08:00

Recolour DrawableTopScore

This commit is contained in:
Andrei Zavatski 2020-02-04 14:17:22 +03:00
parent 873eda3bb5
commit 0e54e0e092
3 changed files with 20 additions and 52 deletions

View File

@ -7,8 +7,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Scoring; using osu.Game.Scoring;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -17,11 +15,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
public class DrawableTopScore : CompositeDrawable public class DrawableTopScore : CompositeDrawable
{ {
private const float fade_duration = 100;
private Color4 backgroundIdleColour;
private Color4 backgroundHoveredColour;
private readonly Box background; private readonly Box background;
public DrawableTopScore(ScoreInfo score, int position = 1) public DrawableTopScore(ScoreInfo score, int position = 1)
@ -30,7 +23,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
Masking = true; Masking = true;
CornerRadius = 10; CornerRadius = 5;
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
{ {
Type = EdgeEffectType.Shadow, Type = EdgeEffectType.Shadow,
@ -84,24 +77,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
backgroundIdleColour = colours.Gray3; background.Colour = colourProvider.Background4;
backgroundHoveredColour = colours.Gray4;
background.Colour = backgroundIdleColour;
}
protected override bool OnHover(HoverEvent e)
{
background.FadeColour(backgroundHoveredColour, fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
background.FadeColour(backgroundIdleColour, fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
} }
private class AutoSizingGrid : GridContainer private class AutoSizingGrid : GridContainer

View File

@ -24,8 +24,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
private const float margin = 10; private const float margin = 10;
private readonly FontUsage smallFont = OsuFont.GetFont(size: 20); private readonly FontUsage smallFont = OsuFont.GetFont(size: 16);
private readonly FontUsage largeFont = OsuFont.GetFont(size: 25); private readonly FontUsage largeFont = OsuFont.GetFont(size: 22);
private readonly TextColumn totalScoreColumn; private readonly TextColumn totalScoreColumn;
private readonly TextColumn accuracyColumn; private readonly TextColumn accuracyColumn;
@ -109,6 +109,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private class InfoColumn : CompositeDrawable private class InfoColumn : CompositeDrawable
{ {
private readonly Box separator; private readonly Box separator;
private readonly OsuSpriteText text;
public InfoColumn(string title, Drawable content) public InfoColumn(string title, Drawable content)
{ {
@ -121,9 +122,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Spacing = new Vector2(0, 2), Spacing = new Vector2(0, 2),
Children = new[] Children = new[]
{ {
new OsuSpriteText text = new OsuSpriteText
{ {
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black), Font = OsuFont.GetFont(size: 10, weight: FontWeight.Black),
Text = title.ToUpper() Text = title.ToUpper()
}, },
separator = new Box separator = new Box
@ -137,9 +138,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
separator.Colour = colours.Gray5; separator.Colour = text.Colour = colourProvider.Foreground1;
} }
} }
@ -189,15 +190,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
set set
{ {
modsContainer.Clear(); modsContainer.Clear();
modsContainer.Children = value.Select(mod => new ModIcon(mod)
foreach (Mod mod in value)
{ {
modsContainer.Add(new ModIcon(mod) AutoSizeAxes = Axes.Both,
{ Scale = new Vector2(0.25f),
AutoSizeAxes = Axes.Both, }).ToList();
Scale = new Vector2(0.3f),
});
}
} }
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -51,13 +50,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Bold, italics: true) Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true)
}, },
rank = new UpdateableRank(ScoreRank.D) rank = new UpdateableRank(ScoreRank.D)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(40), Size = new Vector2(28),
FillMode = FillMode.Fit, FillMode = FillMode.Fit,
}, },
} }
@ -66,7 +65,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(80), Size = new Vector2(70),
Masking = true, Masking = true,
CornerRadius = 5, CornerRadius = 5,
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
@ -87,7 +86,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Spacing = new Vector2(0, 3), Spacing = new Vector2(0, 3),
Children = new Drawable[] Children = new Drawable[]
{ {
usernameText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold, italics: true)) usernameText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true))
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
@ -97,13 +96,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold) Font = OsuFont.GetFont(size: 10, weight: FontWeight.Bold)
}, },
flag = new UpdateableFlag flag = new UpdateableFlag
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Size = new Vector2(20, 13), Size = new Vector2(19, 13),
ShowPlaceholderOnNull = false, ShowPlaceholderOnNull = false,
}, },
} }
@ -112,12 +111,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
rankText.Colour = colours.Yellow;
}
public int ScorePosition public int ScorePosition
{ {
set => rankText.Text = $"#{value}"; set => rankText.Text = $"#{value}";