1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-19 01:17:19 +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.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Scoring;
using osuTK;
using osuTK.Graphics;
@ -17,11 +15,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class DrawableTopScore : CompositeDrawable
{
private const float fade_duration = 100;
private Color4 backgroundIdleColour;
private Color4 backgroundHoveredColour;
private readonly Box background;
public DrawableTopScore(ScoreInfo score, int position = 1)
@ -30,7 +23,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
AutoSizeAxes = Axes.Y;
Masking = true;
CornerRadius = 10;
CornerRadius = 5;
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
@ -84,24 +77,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OverlayColourProvider colourProvider)
{
backgroundIdleColour = colours.Gray3;
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);
background.Colour = colourProvider.Background4;
}
private class AutoSizingGrid : GridContainer

View File

@ -24,8 +24,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
private const float margin = 10;
private readonly FontUsage smallFont = OsuFont.GetFont(size: 20);
private readonly FontUsage largeFont = OsuFont.GetFont(size: 25);
private readonly FontUsage smallFont = OsuFont.GetFont(size: 16);
private readonly FontUsage largeFont = OsuFont.GetFont(size: 22);
private readonly TextColumn totalScoreColumn;
private readonly TextColumn accuracyColumn;
@ -109,6 +109,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private class InfoColumn : CompositeDrawable
{
private readonly Box separator;
private readonly OsuSpriteText text;
public InfoColumn(string title, Drawable content)
{
@ -121,9 +122,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Spacing = new Vector2(0, 2),
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()
},
separator = new Box
@ -137,9 +138,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}
[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
{
modsContainer.Clear();
foreach (Mod mod in value)
modsContainer.Children = value.Select(mod => new ModIcon(mod)
{
modsContainer.Add(new ModIcon(mod)
{
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.3f),
});
}
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.25f),
}).ToList();
}
}
}

View File

@ -1,7 +1,6 @@
// 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.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -51,13 +50,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
Anchor = 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)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(40),
Size = new Vector2(28),
FillMode = FillMode.Fit,
},
}
@ -66,7 +65,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(80),
Size = new Vector2(70),
Masking = true,
CornerRadius = 5,
EdgeEffect = new EdgeEffectParameters
@ -87,7 +86,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Spacing = new Vector2(0, 3),
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,
Origin = Anchor.CentreLeft,
@ -97,13 +96,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold)
Font = OsuFont.GetFont(size: 10, weight: FontWeight.Bold)
},
flag = new UpdateableFlag
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(20, 13),
Size = new Vector2(19, 13),
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
{
set => rankText.Text = $"#{value}";