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

update drawable score inline with the latest design

This commit is contained in:
EVAST9919 2019-02-08 19:50:02 +03:00
parent f43ee6b6a3
commit 7a3ae0f479
4 changed files with 87 additions and 84 deletions

View File

@ -25,6 +25,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private const float text_size = 14;
private readonly Box hoveredBackground;
private readonly Box background;
private readonly SpriteText rank;
private readonly SpriteText scoreText;
private readonly SpriteText accuracy;
@ -39,10 +41,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private readonly APIScoreInfo score;
public DrawableScore(int index, APIScoreInfo score)
public DrawableScore(int index, APIScoreInfo score, int maxModsAmount)
{
FillFlowContainer modsContainer;
Box background;
this.score = score;
@ -69,7 +70,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
TextSize = text_size,
X = ScoreTextLine.RANK_POSITION,
Font = @"Exo2.0-Bold",
Colour = Color4.Black,
},
new DrawableRank(score.Rank)
{
@ -85,7 +85,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Origin = Anchor.CentreLeft,
Text = $@"{score.TotalScore:N0}",
X = ScoreTextLine.SCORE_POSITION,
Colour = Color4.Black,
TextSize = text_size,
},
accuracy = new SpriteText
@ -109,7 +108,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Origin = Anchor.CentreLeft,
User = score.User,
X = ScoreTextLine.PLAYER_POSITION,
Colour = Color4.Black,
},
maxCombo = new SpriteText
{
@ -119,7 +117,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
RelativePositionAxes = Axes.X,
X = ScoreTextLine.MAX_COMBO_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
hitGreat = new SpriteText
{
@ -129,7 +126,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
RelativePositionAxes = Axes.X,
X = ScoreTextLine.HIT_GREAT_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
hitGood = new SpriteText
{
@ -139,7 +135,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
RelativePositionAxes = Axes.X,
X = ScoreTextLine.HIT_GOOD_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
hitMeh = new SpriteText
{
@ -149,7 +144,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
RelativePositionAxes = Axes.X,
X = ScoreTextLine.HIT_MEH_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
hitMiss = new SpriteText
{
@ -159,7 +153,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
RelativePositionAxes = Axes.X,
X = ScoreTextLine.HIT_MISS_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
pp = new SpriteText
{
@ -169,34 +162,35 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
RelativePositionAxes = Axes.X,
X = ScoreTextLine.PP_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
modsContainer = new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
RelativePositionAxes = Axes.X,
X = ScoreTextLine.MODS_POSITION,
X = -30 * maxModsAmount,
},
};
if (index == 0)
scoreText.Font = @"Exo2.0-Bold";
accuracy.Colour = (score.Accuracy == 1) ? Color4.Green : Color4.Black;
accuracy.Colour = (score.Accuracy == 1) ? Color4.LightGreen : Color4.White;
hitGreat.Colour = (score.Statistics[HitResult.Great] == 0) ? Color4.Gray : Color4.Black;
hitGood.Colour = (score.Statistics[HitResult.Good] == 0) ? Color4.Gray : Color4.Black;
hitMeh.Colour = (score.Statistics[HitResult.Meh] == 0) ? Color4.Gray : Color4.Black;
hitMiss.Colour = (score.Statistics[HitResult.Miss] == 0) ? Color4.Gray : Color4.Black;
hitGreat.Colour = (score.Statistics[HitResult.Great] == 0) ? Color4.Gray : Color4.White;
hitGood.Colour = (score.Statistics[HitResult.Good] == 0) ? Color4.Gray : Color4.White;
hitMeh.Colour = (score.Statistics[HitResult.Meh] == 0) ? Color4.Gray : Color4.White;
hitMiss.Colour = (score.Statistics[HitResult.Miss] == 0) ? Color4.Gray : Color4.White;
background.Colour = (index % 2 == 0) ? Color4.WhiteSmoke : Color4.White;
if (index % 2 == 0)
background.Alpha = 0;
foreach (Mod mod in score.Mods)
modsContainer.Add(new ModIcon(mod)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.3f),
});
@ -206,55 +200,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private void load(OsuColour colours)
{
hoveredBackground.Colour = colours.Gray4;
background.Colour = colours.Gray3;
}
protected override bool OnHover(HoverEvent e)
{
hoveredBackground.FadeIn(fade_duration, Easing.OutQuint);
rank.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
scoreText.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
accuracy.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
username.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
maxCombo.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
pp.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
if (score.Statistics[HitResult.Great] != 0)
hitGreat.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
if (score.Statistics[HitResult.Good] != 0)
hitGood.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
if (score.Statistics[HitResult.Meh] != 0)
hitMeh.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
if (score.Statistics[HitResult.Miss] != 0)
hitMiss.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
hoveredBackground.FadeOut(fade_duration, Easing.OutQuint);
rank.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
scoreText.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
username.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
accuracy.FadeColour((score.Accuracy == 1) ? Color4.Green : Color4.Black, fade_duration, Easing.OutQuint);
maxCombo.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
pp.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
if (score.Statistics[HitResult.Great] != 0)
hitGreat.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
if (score.Statistics[HitResult.Good] != 0)
hitGood.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
if (score.Statistics[HitResult.Meh] != 0)
hitMeh.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
if (score.Statistics[HitResult.Miss] != 0)
hitMiss.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}

View File

@ -0,0 +1,58 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using System.Collections.Generic;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ScoreTable : FillFlowContainer
{
private IEnumerable<APIScoreInfo> scores;
public IEnumerable<APIScoreInfo> Scores
{
set
{
scores = value;
int maxModsAmount = 0;
foreach (var s in scores)
{
var scoreModsAmount = s.Mods.Length;
if (scoreModsAmount > maxModsAmount)
maxModsAmount = scoreModsAmount;
}
Add(new ScoreTextLine(maxModsAmount));
int index = 0;
foreach (var s in scores)
Add(new DrawableScore(index++, s, maxModsAmount));
}
get
{
return scores;
}
}
public ScoreTable()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
}
public void ClearScores()
{
scores = null;
foreach (var s in this)
{
if (s is DrawableScore)
Remove(s);
}
}
}
}

View File

@ -23,9 +23,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
public const float HIT_MEH_POSITION = 0.7f;
public const float HIT_MISS_POSITION = 0.75f;
public const float PP_POSITION = 0.8f;
public const float MODS_POSITION = 0.9f;
public ScoreTextLine()
public ScoreTextLine(int maxModsAmount)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@ -91,11 +90,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
},
new ScoreText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
Text = "mods".ToUpper(),
X = MODS_POSITION,
RelativePositionAxes = Axes.X,
X = -30 * maxModsAmount,
},
};
}
@ -106,12 +104,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
TextSize = text_size;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = colours.ContextMenuGray;
}
}
}
}

View File

@ -20,7 +20,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private const int spacing = 15;
private const int fade_duration = 200;
private readonly FillFlowContainer flow;
private readonly ScoreTable scoreTable;
private readonly DrawableTopScore topScore;
private readonly LoadingAnimation loadingAnimation;
@ -76,22 +77,19 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
if (scoreCount == 0)
{
topScore.Hide();
flow.Clear();
scoreTable.ClearScores();
return;
}
topScore.Score = scores.FirstOrDefault();
topScore.Show();
flow.Clear();
scoreTable.ClearScores();
if (scoreCount < 2)
return;
flow.Add(new ScoreTextLine());
for (int i = 0; i < scoreCount; i++)
flow.Add(new DrawableScore(i, scores.ElementAt(i)));
scoreTable.Scores = scores;
}
public ScoresContainer()
@ -113,13 +111,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Children = new Drawable[]
{
topScore = new DrawableTopScore(),
flow = new FillFlowContainer
scoreTable = new ScoreTable
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 1),
},
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
}
}
},
loadingAnimation = new LoadingAnimation