1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 08:02:55 +08:00

update another scores design

This commit is contained in:
EVAST9919 2019-02-05 19:32:33 +03:00
parent f560dde157
commit c85dc1a236
6 changed files with 397 additions and 100 deletions

View File

@ -1,9 +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 System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
@ -13,6 +10,9 @@ using osu.Game.Overlays.BeatmapSet.Buttons;
using osu.Game.Overlays.BeatmapSet.Scores;
using osu.Game.Rulesets;
using osu.Game.Users;
using System;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Tests.Visual
{
@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(Header),
typeof(ClickableUsername),
typeof(ClickableUserContainer),
typeof(DrawableScore),
typeof(DrawableTopScore),
typeof(ScoresContainer),

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers;
@ -12,11 +13,8 @@ using System.Collections.Generic;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ClickableUsername : OsuHoverContainer
public abstract class ClickableUserContainer : Container
{
private readonly SpriteText text;
protected override IEnumerable<Drawable> EffectTargets => new[] { text };
private UserProfileOverlay profile;
private User user;
@ -28,33 +26,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
if (user == value) return;
user = value;
OnUserUpdate(user);
OnUserChange(user);
}
}
public float TextSize
{
set
{
if (text.TextSize == value) return;
text.TextSize = value;
}
get { return text.TextSize; }
}
public ClickableUsername()
public ClickableUserContainer()
{
AutoSizeAxes = Axes.Both;
Child = text = new SpriteText
{
Font = @"Exo2.0-BoldItalic",
};
}
protected virtual void OnUserUpdate(User user)
{
text.Text = user.Username;
}
protected abstract void OnUserChange(User user);
[BackgroundDependencyLoader(true)]
private void load(UserProfileOverlay profile)

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
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.Sprites;
@ -16,62 +17,63 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
using System.Collections.Generic;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class DrawableScore : Container
{
private const int fade_duration = 100;
private const float side_margin = 20;
private const float text_size = 14;
private readonly Box background;
private readonly Box hoveredBackground;
private readonly SpriteText rank;
private readonly SpriteText scoreText;
private readonly SpriteText accuracy;
private readonly SpriteText maxCombo;
private readonly SpriteText hitGreat;
private readonly SpriteText hitGood;
private readonly SpriteText hitMeh;
private readonly SpriteText hitMiss;
private readonly SpriteText pp;
private readonly ClickableScoreUsername username;
private readonly APIScoreInfo score;
private Color4 backgroundColor;
public DrawableScore(int index, APIScoreInfo score)
{
ScoreModsContainer modsContainer;
FillFlowContainer modsContainer;
this.score = score;
RelativeSizeAxes = Axes.X;
Height = 30;
Height = 25;
CornerRadius = 3;
Masking = true;
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
},
hoveredBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
},
new OsuSpriteText
rank = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
Text = $"#{index + 1}",
Font = @"Exo2.0-RegularItalic",
Margin = new MarginPadding { Left = side_margin }
},
new DrawableFlag(score.User.Country)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(30, 20),
Margin = new MarginPadding { Left = 60 }
},
//new ClickableUsername
//{
// Anchor = Anchor.CentreLeft,
// Origin = Anchor.CentreLeft,
// User = score.User,
// Margin = new MarginPadding { Left = 100 }
//},
modsContainer = new ScoreModsContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Width = 0.06f,
RelativePositionAxes = Axes.X,
X = 0.42f
TextSize = text_size,
X = ScoreTextLine.RANK_POSITION,
Font = @"Exo2.0-Bold",
Colour = Color4.Black,
},
new DrawableRank(score.Rank)
{
@ -79,64 +81,232 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Origin = Anchor.CentreLeft,
Size = new Vector2(30, 20),
FillMode = FillMode.Fit,
RelativePositionAxes = Axes.X,
X = 0.55f
X = 45
},
new OsuSpriteText
scoreText = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
Text = $@"{score.TotalScore:N0}",
Font = @"Venera",
RelativePositionAxes = Axes.X,
X = 0.75f,
FixedWidth = true,
X = ScoreTextLine.SCORE_POSITION,
Colour = Color4.Black,
TextSize = text_size,
},
new OsuSpriteText
accuracy = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
Text = $@"{score.Accuracy:P2}",
Font = @"Exo2.0-RegularItalic",
RelativePositionAxes = Axes.X,
X = 0.85f
X = ScoreTextLine.ACCURACY_POSITION,
TextSize = text_size,
},
new OsuSpriteText
new DrawableFlag(score.User.Country)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Text = $"{score.Statistics[HitResult.Great]}/{score.Statistics[HitResult.Good]}/{score.Statistics[HitResult.Meh]}",
Font = @"Exo2.0-RegularItalic",
Margin = new MarginPadding { Right = side_margin }
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(20, 13),
X = 230,
},
username = new ClickableScoreUsername
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
User = score.User,
X = ScoreTextLine.PLAYER_POSITION,
Colour = Color4.Black,
},
maxCombo = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = $@"{score.MaxCombo:N0}x",
RelativePositionAxes = Axes.X,
X = ScoreTextLine.MAX_COMBO_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
hitGreat = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = $"{score.Statistics[HitResult.Great]}",
RelativePositionAxes = Axes.X,
X = ScoreTextLine.HIT_GREAT_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
hitGood = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = $"{score.Statistics[HitResult.Good]}",
RelativePositionAxes = Axes.X,
X = ScoreTextLine.HIT_GOOD_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
hitMeh = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = $"{score.Statistics[HitResult.Meh]}",
RelativePositionAxes = Axes.X,
X = ScoreTextLine.HIT_MEH_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
hitMiss = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = $"{score.Statistics[HitResult.Miss]}",
RelativePositionAxes = Axes.X,
X = ScoreTextLine.HIT_MISS_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
pp = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = $@"{score.PP:N0}",
RelativePositionAxes = Axes.X,
X = ScoreTextLine.PP_POSITION,
TextSize = text_size,
Colour = Color4.Black,
},
modsContainer = new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
RelativePositionAxes = Axes.X,
X = ScoreTextLine.MODS_POSITION,
},
};
if (index == 0)
scoreText.Font = @"Exo2.0-Bold";
accuracy.Colour = (score.Accuracy == 1) ? Color4.Green : Color4.Black;
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;
background.Colour = backgroundColor = (index % 2 == 0) ? Color4.WhiteSmoke : Color4.White;
foreach (Mod mod in score.Mods)
modsContainer.Add(new ModIcon(mod)
{
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.35f),
Scale = new Vector2(0.3f),
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.Gray4;
hoveredBackground.Colour = colours.Gray4;
}
protected override bool OnHover(HoverEvent e)
{
background.FadeIn(fade_duration, Easing.OutQuint);
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)
{
background.FadeOut(fade_duration, Easing.OutQuint);
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);
}
protected override bool OnClick(ClickEvent e) => true;
private class ClickableScoreUsername : ClickableUserContainer
{
private readonly SpriteText text;
private readonly SpriteText textBold;
public ClickableScoreUsername()
{
Add(text = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
TextSize = text_size,
});
Add(textBold = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
TextSize = text_size,
Font = @"Exo2.0-Bold",
Alpha = 0,
});
}
protected override void OnUserChange(User user)
{
text.Text = textBold.Text = user.Username;
}
protected override bool OnHover(HoverEvent e)
{
textBold.FadeIn(fade_duration, Easing.OutQuint);
text.FadeOut(fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
textBold.FadeOut(fade_duration, Easing.OutQuint);
text.FadeIn(fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
}
}
}

View File

@ -35,7 +35,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private readonly Box background;
private readonly UpdateableAvatar avatar;
private readonly DrawableFlag flag;
private readonly ClickableUsername username;
private readonly ClickableTopScoreUsername username;
private readonly SpriteText rankText;
private readonly SpriteText date;
private readonly DrawableRank rank;
@ -262,44 +262,70 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
base.OnHoverLost(e);
}
private class ClickableTopScoreUsername : ClickableUsername
private class ClickableTopScoreUsername : ClickableUserContainer
{
private Box underscore;
private const float fade_duration = 500;
private readonly Box underscore;
private readonly Container underscoreContainer;
private readonly SpriteText text;
private Color4 hoverColour;
public float TextSize
{
set
{
if (text.TextSize == value) return;
text.TextSize = value;
}
get { return text.TextSize; }
}
public ClickableTopScoreUsername()
{
Add(new Container
Add(underscoreContainer = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = 1,
Position = new Vector2(0, TextSize / 2 - 1),
Depth = 1,
Child = underscore = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
}
});
Add(text = new SpriteText
{
Font = @"Exo2.0-BoldItalic",
Colour = Color4.Black,
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
IdleColour = colours.ContextMenuGray;
HoverColour = underscore.Colour = colours.Blue;
hoverColour = underscore.Colour = colours.Blue;
underscoreContainer.Position = new Vector2(0, TextSize / 2 - 1);
}
protected override void OnUserChange(User user)
{
text.Text = user.Username;
}
protected override bool OnHover(HoverEvent e)
{
underscore.FadeIn(FADE_DURATION, Easing.OutQuint);
text.FadeColour(hoverColour, fade_duration, Easing.OutQuint);
underscore.FadeIn(fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
underscore.FadeOut(FADE_DURATION, Easing.OutQuint);
text.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
underscore.FadeOut(fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
}

View File

@ -0,0 +1,118 @@
// 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.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ScoreTextLine : Container
{
private const float text_size = 12;
public const float RANK_POSITION = 30;
public const float SCORE_POSITION = 90;
public const float ACCURACY_POSITION = 170;
public const float PLAYER_POSITION = 270;
public const float MAX_COMBO_POSITION = 0.5f;
public const float HIT_GREAT_POSITION = 0.6f;
public const float HIT_GOOD_POSITION = 0.65f;
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()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Children = new Drawable[]
{
new ScoreText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
Text = "rank".ToUpper(),
X = RANK_POSITION,
},
new ScoreText
{
Text = "score".ToUpper(),
X = SCORE_POSITION,
},
new ScoreText
{
Text = "accuracy".ToUpper(),
X = ACCURACY_POSITION,
},
new ScoreText
{
Text = "player".ToUpper(),
X = PLAYER_POSITION,
},
new ScoreText
{
Text = "max combo".ToUpper(),
X = MAX_COMBO_POSITION,
RelativePositionAxes = Axes.X,
},
new ScoreText
{
Text = "300",
RelativePositionAxes = Axes.X,
X = HIT_GREAT_POSITION,
},
new ScoreText
{
Text = "100".ToUpper(),
RelativePositionAxes = Axes.X,
X = HIT_GOOD_POSITION,
},
new ScoreText
{
Text = "50".ToUpper(),
RelativePositionAxes = Axes.X,
X = HIT_MEH_POSITION,
},
new ScoreText
{
Text = "miss".ToUpper(),
RelativePositionAxes = Axes.X,
X = HIT_MISS_POSITION,
},
new ScoreText
{
Text = "pp".ToUpper(),
RelativePositionAxes = Axes.X,
X = PP_POSITION,
},
new ScoreText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
Text = "mods".ToUpper(),
X = MODS_POSITION,
RelativePositionAxes = Axes.X,
},
};
}
private class ScoreText : SpriteText
{
public ScoreText()
{
TextSize = text_size;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = colours.ContextMenuGray;
}
}
}
}

View File

@ -1,19 +1,19 @@
// 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 osuTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osuTK;
using osuTK.Graphics;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
@ -90,7 +90,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
if (scoreCount < 2)
return;
for (int i = 1; i < scoreCount; i++)
flow.Add(new ScoreTextLine());
for (int i = 0; i < scoreCount; i++)
flow.Add(new DrawableScore(i, scores.ElementAt(i)));
}