From 559960036e61edf1caefb5670fe9c939dad0ef59 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 5 Feb 2019 14:48:35 +0300 Subject: [PATCH 01/42] update top score design --- .../Graphics/Containers/OsuHoverContainer.cs | 10 +- .../BeatmapSet/Scores/ClickableUsername.cs | 15 +- .../BeatmapSet/Scores/DrawableScore.cs | 16 +- .../BeatmapSet/Scores/DrawableTopScore.cs | 422 ++++++++++++------ .../BeatmapSet/Scores/ScoresContainer.cs | 7 + 5 files changed, 328 insertions(+), 142 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuHoverContainer.cs b/osu.Game/Graphics/Containers/OsuHoverContainer.cs index 276b0f9dd1..091499b7cd 100644 --- a/osu.Game/Graphics/Containers/OsuHoverContainer.cs +++ b/osu.Game/Graphics/Containers/OsuHoverContainer.cs @@ -1,12 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; -using osuTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Input.Events; +using osuTK.Graphics; +using System.Collections.Generic; namespace osu.Game.Graphics.Containers { @@ -16,17 +16,19 @@ namespace osu.Game.Graphics.Containers protected Color4 IdleColour = Color4.White; + protected const float FADE_DURATION = 500; + protected virtual IEnumerable EffectTargets => new[] { Content }; protected override bool OnHover(HoverEvent e) { - EffectTargets.ForEach(d => d.FadeColour(HoverColour, 500, Easing.OutQuint)); + EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint)); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - EffectTargets.ForEach(d => d.FadeColour(IdleColour, 500, Easing.OutQuint)); + EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint)); base.OnHoverLost(e); } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs index 0eb8b325d3..e2aade986d 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs @@ -3,16 +3,20 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Users; +using System.Collections.Generic; namespace osu.Game.Overlays.BeatmapSet.Scores { public class ClickableUsername : OsuHoverContainer { - private readonly OsuSpriteText text; + private readonly SpriteText text; + protected override IEnumerable EffectTargets => new[] { text }; + private UserProfileOverlay profile; private User user; @@ -24,7 +28,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (user == value) return; user = value; - text.Text = user.Username; + OnUserUpdate(user); } } @@ -41,12 +45,17 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public ClickableUsername() { AutoSizeAxes = Axes.Both; - Child = text = new OsuSpriteText + Child = text = new SpriteText { Font = @"Exo2.0-BoldItalic", }; } + protected virtual void OnUserUpdate(User user) + { + text.Text = user.Username; + } + [BackgroundDependencyLoader(true)] private void load(UserProfileOverlay profile) { diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index 1f50385adc..609524f170 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . 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; @@ -16,6 +15,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Users; +using osuTK; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -56,13 +56,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores 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 } - }, + //new ClickableUsername + //{ + // Anchor = Anchor.CentreLeft, + // Origin = Anchor.CentreLeft, + // User = score.User, + // Margin = new MarginPadding { Left = 100 } + //}, modsContainer = new ScoreModsContainer { Anchor = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index c9551cf6f8..2e2bb78634 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -1,13 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osuTK; -using osuTK.Graphics; +using Humanizer; 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.Sprites; @@ -19,29 +19,38 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Scoring; using osu.Game.Users; +using osuTK; +using osuTK.Graphics; +using System.Collections.Generic; namespace osu.Game.Overlays.BeatmapSet.Scores { public class DrawableTopScore : Container { private const float fade_duration = 100; - private const float height = 200; + private const float height = 100; private const float avatar_size = 80; private const float margin = 10; private readonly Box background; - private readonly Box bottomBackground; - private readonly Box middleLine; private readonly UpdateableAvatar avatar; private readonly DrawableFlag flag; private readonly ClickableUsername username; - private readonly OsuSpriteText rankText; - private readonly OsuSpriteText date; + private readonly SpriteText rankText; + private readonly SpriteText date; private readonly DrawableRank rank; - private readonly InfoColumn totalScore; - private readonly InfoColumn accuracy; - private readonly InfoColumn statistics; - private readonly ScoreModsContainer modsContainer; + + private readonly AutoSizeInfoColumn totalScore; + private readonly MediumInfoColumn accuracy; + private readonly MediumInfoColumn maxCombo; + + private readonly SmallInfoColumn hitGreat; + private readonly SmallInfoColumn hitGood; + private readonly SmallInfoColumn hitMeh; + private readonly SmallInfoColumn hitMiss; + private readonly SmallInfoColumn pp; + + private readonly ModsInfoColumn modsInfo; private APIScoreInfo score; public APIScoreInfo Score @@ -54,153 +63,296 @@ namespace osu.Game.Overlays.BeatmapSet.Scores avatar.User = username.User = score.User; flag.Country = score.User.Country; - date.Text = $@"achieved {score.Date:MMM d, yyyy}"; + date.Text = $@"achieved {score.Date.Humanize()}"; rank.UpdateRank(score.Rank); totalScore.Value = $@"{score.TotalScore:N0}"; accuracy.Value = $@"{score.Accuracy:P2}"; - statistics.Value = $"{score.Statistics[HitResult.Great]}/{score.Statistics[HitResult.Good]}/{score.Statistics[HitResult.Meh]}"; + maxCombo.Value = $@"{score.MaxCombo:N0}x"; - modsContainer.Clear(); - foreach (Mod mod in score.Mods) - modsContainer.Add(new ModIcon(mod) - { - AutoSizeAxes = Axes.Both, - Scale = new Vector2(0.45f), - }); + hitGreat.Value = $"{score.Statistics[HitResult.Great]}"; + hitGood.Value = $"{score.Statistics[HitResult.Good]}"; + hitMeh.Value = $"{score.Statistics[HitResult.Meh]}"; + hitMiss.Value = $"{score.Statistics[HitResult.Miss]}"; + pp.Value = $@"{score.PP:N0}"; + + modsInfo.ClearMods(); + modsInfo.Mods = score.Mods; } } public DrawableTopScore() { RelativeSizeAxes = Axes.X; - Height = height; - CornerRadius = 5; - BorderThickness = 4; + AutoSizeAxes = Axes.Y; + CornerRadius = 3; Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.2f), + Radius = 1, + Offset = new Vector2(0, 1), + }; Children = new Drawable[] { background = new Box { RelativeSizeAxes = Axes.Both, - Alpha = 0, - AlwaysPresent = true, //used for correct border representation - }, - avatar = new UpdateableAvatar - { - Size = new Vector2(avatar_size), - Masking = true, - CornerRadius = 5, - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.25f), - Offset = new Vector2(0, 2), - Radius = 1, - }, - Margin = new MarginPadding { Top = margin, Left = margin } - }, - flag = new DrawableFlag - { - Size = new Vector2(30, 20), - Position = new Vector2(margin * 2 + avatar_size, height / 4), - }, - username = new ClickableUsername - { - Origin = Anchor.BottomLeft, - TextSize = 30, - Position = new Vector2(margin * 2 + avatar_size, height / 4), - Margin = new MarginPadding { Bottom = 4 } - }, - rankText = new OsuSpriteText - { - Anchor = Anchor.TopRight, - Origin = Anchor.BottomRight, - Text = "#1", - TextSize = 40, - Font = @"Exo2.0-BoldItalic", - Y = height / 4, - Margin = new MarginPadding { Right = margin } - }, - date = new OsuSpriteText - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Y = height / 4, - Margin = new MarginPadding { Right = margin } + Colour = Color4.White, }, new Container { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.Both, - Height = 0.5f, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding(margin), Children = new Drawable[] { - bottomBackground = new Box { RelativeSizeAxes = Axes.Both }, - middleLine = new Box + new FillFlowContainer { - RelativeSizeAxes = Axes.X, - Height = 1, - }, - rank = new DrawableRank(ScoreRank.F) - { - Origin = Anchor.BottomLeft, - Size = new Vector2(avatar_size, 40), - FillMode = FillMode.Fit, - Y = height / 4, - Margin = new MarginPadding { Left = margin } - }, - new FillFlowContainer - { - Origin = Anchor.BottomLeft, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, AutoSizeAxes = Axes.Both, - Position = new Vector2(height / 2, height / 4), Direction = FillDirection.Horizontal, - Spacing = new Vector2(15, 0), - Children = new[] + Spacing = new Vector2(margin, 0), + Children = new Drawable[] { - totalScore = new InfoColumn("Score"), - accuracy = new InfoColumn("Accuracy"), - statistics = new InfoColumn("300/100/50"), - }, + new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), + Children = new Drawable[] + { + rankText = new SpriteText + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Text = "#1", + TextSize = 20, + Font = @"Exo2.0-BoldItalic", + }, + rank = new DrawableRank(ScoreRank.F) + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Size = new Vector2(30), + FillMode = FillMode.Fit, + }, + } + }, + avatar = new UpdateableAvatar + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(avatar_size), + Masking = true, + CornerRadius = 5, + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Offset = new Vector2(0, 2), + Radius = 1, + }, + }, + new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 3), + Children = new Drawable[] + { + username = new ClickableTopScoreUsername + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 20, + }, + date = new SpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 10, + }, + flag = new DrawableFlag + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Size = new Vector2(20, 13), + }, + } + } + } }, - modsContainer = new ScoreModsContainer + new Container { - AutoSizeAxes = Axes.Y, - Width = 80, - Position = new Vector2(height / 2, height / 4), + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + Child = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(margin, 0), + Children = new Drawable[] + { + totalScore = new AutoSizeInfoColumn("Total Score"), + accuracy = new MediumInfoColumn("Accuracy"), + maxCombo = new MediumInfoColumn("Max Combo"), + hitGreat = new SmallInfoColumn("300", 20), + hitGood = new SmallInfoColumn("100", 20), + hitMeh = new SmallInfoColumn("50", 20), + hitMiss = new SmallInfoColumn("miss", 20), + pp = new SmallInfoColumn("pp", 20), + modsInfo = new ModsInfoColumn("mods"), + } + } } } - }, + } }; } [BackgroundDependencyLoader] private void load(OsuColour colours) { - background.Colour = bottomBackground.Colour = colours.Gray4; - middleLine.Colour = colours.Gray2; - date.Colour = colours.Gray9; - BorderColour = rankText.Colour = colours.Yellow; + date.Colour = rankText.Colour = colours.ContextMenuGray; } protected override bool OnHover(HoverEvent e) { - background.FadeIn(fade_duration, Easing.OutQuint); + background.FadeColour(Color4.WhiteSmoke, fade_duration, Easing.OutQuint); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - background.FadeOut(fade_duration, Easing.OutQuint); + background.FadeColour(Color4.White, fade_duration, Easing.OutQuint); base.OnHoverLost(e); } - private class InfoColumn : FillFlowContainer + private class ClickableTopScoreUsername : ClickableUsername { - private readonly OsuSpriteText headerText; - private readonly OsuSpriteText valueText; + private Box underscore; + + public ClickableTopScoreUsername() + { + Add(new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Height = 1, + Position = new Vector2(0, TextSize / 2 + 1.5f), + Depth = 1, + Child = underscore = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + } + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + IdleColour = colours.ContextMenuGray; + HoverColour = underscore.Colour = colours.Blue; + } + + protected override bool OnHover(HoverEvent e) + { + underscore.FadeIn(FADE_DURATION, Easing.OutQuint); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + underscore.FadeOut(FADE_DURATION, Easing.OutQuint); + base.OnHoverLost(e); + } + } + + private class DrawableInfoColumn : FillFlowContainer + { + private readonly SpriteText headerText; + private const float header_text_size = 12; + + public DrawableInfoColumn(string header) + { + AutoSizeAxes = Axes.Y; + Direction = FillDirection.Vertical; + Spacing = new Vector2(0, 2); + Children = new Drawable[] + { + new Container + { + AutoSizeAxes = Axes.X, + Height = header_text_size, + Child = headerText = new SpriteText + { + TextSize = 12, + Text = header.ToUpper(), + } + }, + new Container + { + RelativeSizeAxes = Axes.X, + Height = 3, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.LightGray, + } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + headerText.Colour = colours.ContextMenuGray; + } + } + + private class ModsInfoColumn : DrawableInfoColumn + { + private readonly FillFlowContainer modsContainer; + + public IEnumerable Mods + { + set + { + foreach (Mod mod in value) + modsContainer.Add(new ModIcon(mod) + { + AutoSizeAxes = Axes.Both, + Scale = new Vector2(0.3f), + }); + } + } + + public ModsInfoColumn(string header) : base(header) + { + AutoSizeAxes = Axes.Both; + Add(modsContainer = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + }); + } + + public void ClearMods() => modsContainer.Clear(); + } + + private class TextInfoColumn : DrawableInfoColumn + { + private readonly SpriteText valueText; public string Value { @@ -213,31 +365,47 @@ namespace osu.Game.Overlays.BeatmapSet.Scores get { return valueText.Text; } } - public InfoColumn(string header) + public TextInfoColumn(string header, float valueTextSize = 25) : base(header) { - AutoSizeAxes = Axes.Both; - Direction = FillDirection.Vertical; - Spacing = new Vector2(0, 3); - Children = new Drawable[] + Add(valueText = new SpriteText { - headerText = new OsuSpriteText - { - TextSize = 14, - Text = header, - Font = @"Exo2.0-Bold", - }, - valueText = new OsuSpriteText - { - TextSize = 25, - Font = @"Exo2.0-RegularItalic", - } - }; + TextSize = valueTextSize, + Font = @"Exo2.0-Light", + }); } [BackgroundDependencyLoader] private void load(OsuColour colours) { - headerText.Colour = colours.Gray9; + valueText.Colour = colours.ContextMenuGray; + } + } + + private class AutoSizeInfoColumn : TextInfoColumn + { + public AutoSizeInfoColumn(string header, float valueTextSize = 25) : base(header, valueTextSize) + { + AutoSizeAxes = Axes.Both; + } + } + + private class MediumInfoColumn : TextInfoColumn + { + private const float width = 70; + + public MediumInfoColumn(string header, float valueTextSize = 25) : base(header, valueTextSize) + { + Width = width; + } + } + + private class SmallInfoColumn : TextInfoColumn + { + private const float width = 40; + + public SmallInfoColumn(string header, float valueTextSize = 25) : base(header, valueTextSize) + { + Width = width; } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index ab34d2ba1d..ac3068c2c8 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -12,6 +12,8 @@ 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 { @@ -98,6 +100,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores AutoSizeAxes = Axes.Y; Children = new Drawable[] { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + }, new FillFlowContainer { Anchor = Anchor.TopCentre, From f560dde157acd3bb83cf417fd6d10a8d67088576 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 5 Feb 2019 15:26:45 +0300 Subject: [PATCH 02/42] Add some flow for info containers --- .../BeatmapSet/Scores/DrawableTopScore.cs | 54 ++++++++++++++----- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 2e2bb78634..d061e176e0 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -193,23 +193,49 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, - AutoSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Width = 0.7f, Child = new FillFlowContainer { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(margin, 0), + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Spacing = new Vector2(margin), Children = new Drawable[] { - totalScore = new AutoSizeInfoColumn("Total Score"), - accuracy = new MediumInfoColumn("Accuracy"), - maxCombo = new MediumInfoColumn("Max Combo"), - hitGreat = new SmallInfoColumn("300", 20), - hitGood = new SmallInfoColumn("100", 20), - hitMeh = new SmallInfoColumn("50", 20), - hitMiss = new SmallInfoColumn("miss", 20), - pp = new SmallInfoColumn("pp", 20), - modsInfo = new ModsInfoColumn("mods"), + new FillFlowContainer + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(margin, 0), + Children = new Drawable[] + { + hitGreat = new SmallInfoColumn("300", 20), + hitGood = new SmallInfoColumn("100", 20), + hitMeh = new SmallInfoColumn("50", 20), + hitMiss = new SmallInfoColumn("miss", 20), + pp = new SmallInfoColumn("pp", 20), + modsInfo = new ModsInfoColumn("mods"), + } + }, + new FillFlowContainer + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(margin, 0), + Children = new Drawable[] + { + totalScore = new AutoSizeInfoColumn("Total Score"), + accuracy = new MediumInfoColumn("Accuracy"), + maxCombo = new MediumInfoColumn("Max Combo"), + } + }, } } } @@ -248,7 +274,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, Height = 1, - Position = new Vector2(0, TextSize / 2 + 1.5f), + Position = new Vector2(0, TextSize / 2 - 1), Depth = 1, Child = underscore = new Box { From c85dc1a2362434298d57661f4cd87e8f71f4e049 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 5 Feb 2019 19:32:33 +0300 Subject: [PATCH 03/42] update another scores design --- .../Visual/TestCaseBeatmapSetOverlay.cs | 8 +- ...eUsername.cs => ClickableUserContainer.cs} | 29 +- .../BeatmapSet/Scores/DrawableScore.cs | 278 ++++++++++++++---- .../BeatmapSet/Scores/DrawableTopScore.cs | 46 ++- .../BeatmapSet/Scores/ScoreTextLine.cs | 118 ++++++++ .../BeatmapSet/Scores/ScoresContainer.cs | 18 +- 6 files changed, 397 insertions(+), 100 deletions(-) rename osu.Game/Overlays/BeatmapSet/Scores/{ClickableUsername.cs => ClickableUserContainer.cs} (60%) create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/TestCaseBeatmapSetOverlay.cs index b98014b866..20609dc595 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapSetOverlay.cs @@ -1,9 +1,6 @@ // Copyright (c) ppy Pty Ltd . 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 RequiredTypes => new[] { typeof(Header), - typeof(ClickableUsername), + typeof(ClickableUserContainer), typeof(DrawableScore), typeof(DrawableTopScore), typeof(ScoresContainer), diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs similarity index 60% rename from osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs rename to osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs index e2aade986d..2f402bfa74 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs @@ -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 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) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index 609524f170..6f6fd22a13 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -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); + } + } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index d061e176e0..7d82b05099 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -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); } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs new file mode 100644 index 0000000000..d8655b4882 --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs @@ -0,0 +1,118 @@ +// Copyright (c) ppy Pty Ltd . 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; + } + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index ac3068c2c8..5fd1084a14 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -1,19 +1,19 @@ // Copyright (c) ppy Pty Ltd . 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))); } From 9cca11fb0d71c81f930cb48dd95a6ff9962cdd8f Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 6 Feb 2019 01:48:43 +0300 Subject: [PATCH 04/42] Warning fixes --- .../BeatmapSet/Scores/ClickableUserContainer.cs | 6 +----- osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs | 9 ++------- .../Overlays/BeatmapSet/Scores/DrawableTopScore.cs | 12 +++++------- osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs | 1 - 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs index 2f402bfa74..621e1ee1f2 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs @@ -4,12 +4,8 @@ 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; -using osu.Game.Graphics.Sprites; using osu.Game.Users; -using System.Collections.Generic; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -30,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } } - public ClickableUserContainer() + protected ClickableUserContainer() { AutoSizeAxes = Axes.Both; } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index 6f6fd22a13..c2f198d3ee 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -8,17 +8,14 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Leaderboards; -using osu.Game.Overlays.Profile.Sections.Ranks; using osu.Game.Rulesets.Mods; 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 { @@ -27,7 +24,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private const int fade_duration = 100; private const float text_size = 14; - private readonly Box background; private readonly Box hoveredBackground; private readonly SpriteText rank; private readonly SpriteText scoreText; @@ -42,11 +38,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly ClickableScoreUsername username; private readonly APIScoreInfo score; - private Color4 backgroundColor; public DrawableScore(int index, APIScoreInfo score) { FillFlowContainer modsContainer; + Box background; this.score = score; @@ -196,8 +192,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores 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; - + background.Colour = (index % 2 == 0) ? Color4.WhiteSmoke : Color4.White; foreach (Mod mod in score.Mods) modsContainer.Add(new ModIcon(mod) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 7d82b05099..48b824390d 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -10,10 +10,8 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Leaderboards; -using osu.Game.Overlays.Profile.Sections.Ranks; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; @@ -264,7 +262,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private class ClickableTopScoreUsername : ClickableUserContainer { - private const float fade_duration = 500; + private const float username_fade_duration = 500; private readonly Box underscore; private readonly Container underscoreContainer; @@ -317,15 +315,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected override bool OnHover(HoverEvent e) { - text.FadeColour(hoverColour, fade_duration, Easing.OutQuint); - underscore.FadeIn(fade_duration, Easing.OutQuint); + text.FadeColour(hoverColour, username_fade_duration, Easing.OutQuint); + underscore.FadeIn(username_fade_duration, Easing.OutQuint); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - text.FadeColour(Color4.Black, fade_duration, Easing.OutQuint); - underscore.FadeOut(fade_duration, Easing.OutQuint); + text.FadeColour(Color4.Black, username_fade_duration, Easing.OutQuint); + underscore.FadeOut(username_fade_duration, Easing.OutQuint); base.OnHoverLost(e); } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs index d8655b4882..53a477b908 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs @@ -5,7 +5,6 @@ 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 From f43ee6b6a36f12c54de0a2c941c27a01bcb85626 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 8 Feb 2019 19:06:46 +0300 Subject: [PATCH 05/42] update drawable top score inline with the latest design --- .../BeatmapSet/Scores/DrawableTopScore.cs | 85 ++++++++----------- .../BeatmapSet/Scores/ScoresContainer.cs | 7 -- 2 files changed, 35 insertions(+), 57 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 48b824390d..487194c819 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -30,6 +30,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private const float avatar_size = 80; private const float margin = 10; + private OsuColour colours; + + private Color4 backgroundIdleColour => colours.Gray3; + private Color4 backgroundHoveredColour => colours.Gray4; + private readonly Box background; private readonly UpdateableAvatar avatar; private readonly DrawableFlag flag; @@ -38,8 +43,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly SpriteText date; private readonly DrawableRank rank; - private readonly AutoSizeInfoColumn totalScore; - private readonly MediumInfoColumn accuracy; + private readonly AutoSizedInfoColumn totalScore; + private readonly AutoSizedInfoColumn accuracy; private readonly MediumInfoColumn maxCombo; private readonly SmallInfoColumn hitGreat; @@ -56,7 +61,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores get { return score; } set { - if (score == value) return; + if (score == value) + return; score = value; avatar.User = username.User = score.User; @@ -83,7 +89,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - CornerRadius = 3; + CornerRadius = 10; Masking = true; EdgeEffect = new EdgeEffectParameters { @@ -97,7 +103,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores background = new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.White, }, new Container { @@ -115,31 +120,20 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(margin, 0), Children = new Drawable[] { - new FillFlowContainer + rankText = new SpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 2), - Children = new Drawable[] - { - rankText = new SpriteText - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Text = "#1", - TextSize = 20, - Font = @"Exo2.0-BoldItalic", - }, - rank = new DrawableRank(ScoreRank.F) - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Size = new Vector2(30), - FillMode = FillMode.Fit, - }, - } + Text = "#1", + TextSize = 30, + Font = @"Exo2.0-BoldItalic", + }, + rank = new DrawableRank(ScoreRank.F) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(40), + FillMode = FillMode.Fit, }, avatar = new UpdateableAvatar { @@ -229,8 +223,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(margin, 0), Children = new Drawable[] { - totalScore = new AutoSizeInfoColumn("Total Score"), - accuracy = new MediumInfoColumn("Accuracy"), + totalScore = new AutoSizedInfoColumn("Total Score"), + accuracy = new AutoSizedInfoColumn("Accuracy"), maxCombo = new MediumInfoColumn("Max Combo"), } }, @@ -245,18 +239,21 @@ namespace osu.Game.Overlays.BeatmapSet.Scores [BackgroundDependencyLoader] private void load(OsuColour colours) { - date.Colour = rankText.Colour = colours.ContextMenuGray; + this.colours = colours; + + rankText.Colour = colours.Yellow; + background.Colour = backgroundIdleColour; } protected override bool OnHover(HoverEvent e) { - background.FadeColour(Color4.WhiteSmoke, fade_duration, Easing.OutQuint); + background.FadeColour(backgroundHoveredColour, fade_duration, Easing.OutQuint); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - background.FadeColour(Color4.White, fade_duration, Easing.OutQuint); + background.FadeColour(backgroundIdleColour, fade_duration, Easing.OutQuint); base.OnHoverLost(e); } @@ -274,7 +271,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { set { - if (text.TextSize == value) return; + if (text.TextSize == value) + return; text.TextSize = value; } get { return text.TextSize; } @@ -297,7 +295,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Add(text = new SpriteText { Font = @"Exo2.0-BoldItalic", - Colour = Color4.Black, }); } @@ -322,7 +319,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected override void OnHoverLost(HoverLostEvent e) { - text.FadeColour(Color4.Black, username_fade_duration, Easing.OutQuint); + text.FadeColour(Color4.White, username_fade_duration, Easing.OutQuint); underscore.FadeOut(username_fade_duration, Easing.OutQuint); base.OnHoverLost(e); } @@ -348,6 +345,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { TextSize = 12, Text = header.ToUpper(), + Font = @"Exo2.0-Bold", } }, new Container @@ -362,12 +360,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } }; } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - headerText.Colour = colours.ContextMenuGray; - } } private class ModsInfoColumn : DrawableInfoColumn @@ -420,20 +412,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Add(valueText = new SpriteText { TextSize = valueTextSize, - Font = @"Exo2.0-Light", }); } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - valueText.Colour = colours.ContextMenuGray; - } } - private class AutoSizeInfoColumn : TextInfoColumn + private class AutoSizedInfoColumn : TextInfoColumn { - public AutoSizeInfoColumn(string header, float valueTextSize = 25) : base(header, valueTextSize) + public AutoSizedInfoColumn(string header, float valueTextSize = 25) : base(header, valueTextSize) { AutoSizeAxes = Axes.Both; } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 5fd1084a14..5211f1398f 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -4,14 +4,12 @@ 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; @@ -102,11 +100,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores AutoSizeAxes = Axes.Y; Children = new Drawable[] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White, - }, new FillFlowContainer { Anchor = Anchor.TopCentre, From 7a3ae0f479bebb101ad8b00828419ff0eae5291d Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 8 Feb 2019 19:50:02 +0300 Subject: [PATCH 06/42] update drawable score inline with the latest design --- .../BeatmapSet/Scores/DrawableScore.cs | 75 ++++--------------- .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 58 ++++++++++++++ .../BeatmapSet/Scores/ScoreTextLine.cs | 16 +--- .../BeatmapSet/Scores/ScoresContainer.cs | 22 +++--- 4 files changed, 87 insertions(+), 84 deletions(-) create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index c2f198d3ee..1076fe6449 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -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); } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs new file mode 100644 index 0000000000..90947364e4 --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -0,0 +1,58 @@ +// Copyright (c) ppy Pty Ltd . 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 scores; + public IEnumerable 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); + } + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs index 53a477b908..43255683c4 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs @@ -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; - } } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 5211f1398f..8f3414c292 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -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 From 13c154a0b37f2c4c89f66d697dab122ec9a754d4 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 8 Feb 2019 20:07:21 +0300 Subject: [PATCH 07/42] Fix background colour and a bug with removing scores --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 7 ++----- .../Overlays/BeatmapSet/Scores/ScoresContainer.cs | 12 +++++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 90947364e4..7de13b7204 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Online.API.Requests.Responses; using System.Collections.Generic; +using System.Linq; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -48,11 +49,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public void ClearScores() { scores = null; - foreach (var s in this) - { - if (s is DrawableScore) - Remove(s); - } + Clear(); } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 8f3414c292..2a9e76874e 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -4,12 +4,15 @@ 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; 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; @@ -20,6 +23,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private const int spacing = 15; private const int fade_duration = 200; + private readonly Box background; private readonly ScoreTable scoreTable; private readonly DrawableTopScore topScore; @@ -98,6 +102,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores AutoSizeAxes = Axes.Y; Children = new Drawable[] { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, new FillFlowContainer { Anchor = Anchor.TopCentre, @@ -127,9 +135,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } [BackgroundDependencyLoader] - private void load(APIAccess api) + private void load(APIAccess api, OsuColour colours) { this.api = api; + + background.Colour = colours.Gray2; updateDisplay(); } From bd1f4f954955bf426225e67d9db270c275135483 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 8 Feb 2019 20:35:07 +0300 Subject: [PATCH 08/42] Small design fixes --- .../BeatmapSet/Scores/DrawableScore.cs | 2 +- .../BeatmapSet/Scores/DrawableTopScore.cs | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index 1076fe6449..cb9d89dc2c 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -176,7 +176,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (index == 0) scoreText.Font = @"Exo2.0-Bold"; - accuracy.Colour = (score.Accuracy == 1) ? Color4.LightGreen : Color4.White; + accuracy.Colour = (score.Accuracy == 1) ? Color4.GreenYellow : Color4.White; hitGreat.Colour = (score.Statistics[HitResult.Great] == 0) ? Color4.Gray : Color4.White; hitGood.Colour = (score.Statistics[HitResult.Good] == 0) ? Color4.Gray : Color4.White; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 487194c819..903e86423b 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -169,7 +169,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - TextSize = 10, + TextSize = 15, + Font = @"Exo2.0-Bold", }, flag = new DrawableFlag { @@ -327,9 +328,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private class DrawableInfoColumn : FillFlowContainer { - private readonly SpriteText headerText; private const float header_text_size = 12; + private readonly SpriteText headerText; + private readonly Box line; + public DrawableInfoColumn(string header) { AutoSizeAxes = Axes.Y; @@ -351,15 +354,20 @@ namespace osu.Game.Overlays.BeatmapSet.Scores new Container { RelativeSizeAxes = Axes.X, - Height = 3, - Child = new Box + Height = 2, + Child = line = new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.LightGray, } } }; } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + line.Colour = colours.Gray5; + } } private class ModsInfoColumn : DrawableInfoColumn From 107e0a5239be8e629d4c0a5498fd49ff03e082be Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 8 Feb 2019 20:43:11 +0300 Subject: [PATCH 09/42] Warning fixes --- .../BeatmapSet/Scores/DrawableScore.cs | 31 +++++++------------ .../BeatmapSet/Scores/DrawableTopScore.cs | 7 ++--- .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 2 -- .../BeatmapSet/Scores/ScoreTextLine.cs | 2 -- .../BeatmapSet/Scores/ScoresContainer.cs | 1 - 5 files changed, 14 insertions(+), 29 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index cb9d89dc2c..d37bbe5db0 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -27,25 +27,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly Box hoveredBackground; private readonly Box background; - 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; - public DrawableScore(int index, APIScoreInfo score, int maxModsAmount) { - FillFlowContainer modsContainer; + SpriteText accuracy; + SpriteText scoreText; + SpriteText hitGreat; + SpriteText hitGood; + SpriteText hitMeh; + SpriteText hitMiss; - this.score = score; + FillFlowContainer modsContainer; RelativeSizeAxes = Axes.X; Height = 25; @@ -62,7 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores RelativeSizeAxes = Axes.Both, Alpha = 0, }, - rank = new SpriteText + new SpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreRight, @@ -102,14 +93,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Size = new Vector2(20, 13), X = 230, }, - username = new ClickableScoreUsername + new ClickableScoreUsername { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, User = score.User, X = ScoreTextLine.PLAYER_POSITION, }, - maxCombo = new SpriteText + new SpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, @@ -154,7 +145,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores X = ScoreTextLine.HIT_MISS_POSITION, TextSize = text_size, }, - pp = new SpriteText + new SpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 903e86423b..d2421ec606 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -330,10 +330,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { private const float header_text_size = 12; - private readonly SpriteText headerText; private readonly Box line; - public DrawableInfoColumn(string header) + protected DrawableInfoColumn(string header) { AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; @@ -344,7 +343,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { AutoSizeAxes = Axes.X, Height = header_text_size, - Child = headerText = new SpriteText + Child = new SpriteText { TextSize = 12, Text = header.ToUpper(), @@ -415,7 +414,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores get { return valueText.Text; } } - public TextInfoColumn(string header, float valueTextSize = 25) : base(header) + protected TextInfoColumn(string header, float valueTextSize = 25) : base(header) { Add(valueText = new SpriteText { diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 7de13b7204..1b20b2c382 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Online.API.Requests.Responses; using System.Collections.Generic; -using System.Linq; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -28,7 +27,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Add(new ScoreTextLine(maxModsAmount)); - int index = 0; foreach (var s in scores) Add(new DrawableScore(index++, s, maxModsAmount)); diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs index 43255683c4..04934185a1 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs @@ -1,11 +1,9 @@ // Copyright (c) ppy Pty Ltd . 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.Game.Graphics; namespace osu.Game.Overlays.BeatmapSet.Scores { diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 2a9e76874e..2783b0483b 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -12,7 +12,6 @@ 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; From 105053e91b01bfb86a8af60b82fa25b2a7acb344 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 9 Feb 2019 00:56:41 +0300 Subject: [PATCH 10/42] TestCase fix --- osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs | 8 ++++++-- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs index 321a38d087..bcc1774729 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs @@ -17,10 +17,11 @@ using osu.Game.Beatmaps; using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets.Osu; using osu.Game.Scoring; +using NUnit.Framework; namespace osu.Game.Tests.Visual { - [System.ComponentModel.Description("in BeatmapOverlay")] + [Description("in BeatmapOverlay")] public class TestCaseBeatmapScoresContainer : OsuTestCase { private readonly IEnumerable scores; @@ -160,11 +161,12 @@ namespace osu.Game.Tests.Visual Accuracy = 0.6543, }, }; - foreach(var s in scores) + foreach (var s in scores) { s.Statistics.Add(HitResult.Great, RNG.Next(2000)); s.Statistics.Add(HitResult.Good, RNG.Next(2000)); s.Statistics.Add(HitResult.Meh, RNG.Next(2000)); + s.Statistics.Add(HitResult.Miss, RNG.Next(2000)); } anotherScores = new[] @@ -277,6 +279,7 @@ namespace osu.Game.Tests.Visual s.Statistics.Add(HitResult.Great, RNG.Next(2000)); s.Statistics.Add(HitResult.Good, RNG.Next(2000)); s.Statistics.Add(HitResult.Meh, RNG.Next(2000)); + s.Statistics.Add(HitResult.Miss, RNG.Next(2000)); } topScoreInfo = new APIScoreInfo @@ -304,6 +307,7 @@ namespace osu.Game.Tests.Visual topScoreInfo.Statistics.Add(HitResult.Great, RNG.Next(2000)); topScoreInfo.Statistics.Add(HitResult.Good, RNG.Next(2000)); topScoreInfo.Statistics.Add(HitResult.Meh, RNG.Next(2000)); + topScoreInfo.Statistics.Add(HitResult.Miss, RNG.Next(2000)); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 2783b0483b..180f4a949c 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -73,6 +73,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private void updateDisplay() { + scoreTable.ClearScores(); + loading = false; var scoreCount = scores?.Count() ?? 0; @@ -80,15 +82,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (scoreCount == 0) { topScore.Hide(); - scoreTable.ClearScores(); return; } topScore.Score = scores.FirstOrDefault(); topScore.Show(); - scoreTable.ClearScores(); - if (scoreCount < 2) return; From 04e57d7d3dcd2dc7423a6ef077437abafcfeb7e9 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 9 Feb 2019 06:23:58 +0300 Subject: [PATCH 11/42] Refactor to make things more flexible --- .../BeatmapSet/Scores/DrawableScore.cs | 242 ++++++++---------- .../BeatmapSet/Scores/DrawableTopScore.cs | 2 +- .../BeatmapSet/Scores/ScoreTableLine.cs | 183 +++++++++++++ .../BeatmapSet/Scores/ScoreTextLine.cs | 146 ++++------- 4 files changed, 341 insertions(+), 232 deletions(-) create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index d37bbe5db0..8741fd8dfe 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -22,24 +22,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public class DrawableScore : Container { private const int fade_duration = 100; - private const float text_size = 14; + private const int text_size = 14; private readonly Box hoveredBackground; private readonly Box background; public DrawableScore(int index, APIScoreInfo score, int maxModsAmount) { - SpriteText accuracy; - SpriteText scoreText; - SpriteText hitGreat; - SpriteText hitGood; - SpriteText hitMeh; - SpriteText hitMiss; - - FillFlowContainer modsContainer; - RelativeSizeAxes = Axes.X; - Height = 25; + AutoSizeAxes = Axes.Y; CornerRadius = 3; Masking = true; Children = new Drawable[] @@ -53,138 +44,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores RelativeSizeAxes = Axes.Both, Alpha = 0, }, - new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreRight, - Text = $"#{index + 1}", - TextSize = text_size, - X = ScoreTextLine.RANK_POSITION, - Font = @"Exo2.0-Bold", - }, - new DrawableRank(score.Rank) - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Size = new Vector2(30, 20), - FillMode = FillMode.Fit, - X = 45 - }, - scoreText = new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Text = $@"{score.TotalScore:N0}", - X = ScoreTextLine.SCORE_POSITION, - TextSize = text_size, - }, - accuracy = new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Text = $@"{score.Accuracy:P2}", - X = ScoreTextLine.ACCURACY_POSITION, - TextSize = text_size, - }, - new DrawableFlag(score.User.Country) - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Size = new Vector2(20, 13), - X = 230, - }, - new ClickableScoreUsername - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - User = score.User, - X = ScoreTextLine.PLAYER_POSITION, - }, - new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Text = $@"{score.MaxCombo:N0}x", - RelativePositionAxes = Axes.X, - X = ScoreTextLine.MAX_COMBO_POSITION, - TextSize = text_size, - }, - 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, - }, - 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, - }, - 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, - }, - 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, - }, - new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Text = $@"{score.PP:N0}", - RelativePositionAxes = Axes.X, - X = ScoreTextLine.PP_POSITION, - TextSize = text_size, - }, - modsContainer = new FillFlowContainer - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreLeft, - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, - X = -30 * maxModsAmount, - }, + new DrawableScoreData(index, score, maxModsAmount), }; - if (index == 0) - scoreText.Font = @"Exo2.0-Bold"; - - accuracy.Colour = (score.Accuracy == 1) ? Color4.GreenYellow : Color4.White; - - 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; - - if (index % 2 == 0) + 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), - }); } [BackgroundDependencyLoader] @@ -251,5 +115,103 @@ namespace osu.Game.Overlays.BeatmapSet.Scores base.OnHoverLost(e); } } + + private class DrawableScoreData : ScoreTableLine + { + public DrawableScoreData(int index, APIScoreInfo score, int maxModsAmount) : base(maxModsAmount) + { + SpriteText scoreText; + SpriteText accuracy; + SpriteText hitGreat; + SpriteText hitGood; + SpriteText hitMeh; + SpriteText hitMiss; + + FillFlowContainer modsContainer; + + RankContainer.Add(new SpriteText + { + Text = $"#{index + 1}", + Font = @"Exo2.0-Bold", + TextSize = text_size, + }); + DrawableRankContainer.Add(new DrawableRank(score.Rank) + { + Size = new Vector2(30, 20), + FillMode = FillMode.Fit, + }); + ScoreContainer.Add(scoreText = new SpriteText + { + Text = $@"{score.TotalScore:N0}", + TextSize = text_size, + }); + AccuracyContainer.Add(accuracy = new SpriteText + { + Text = $@"{score.Accuracy:P2}", + TextSize = text_size, + }); + FlagContainer.Add(new DrawableFlag(score.User.Country) + { + Size = new Vector2(20, 13), + }); + PlayerContainer.Add(new ClickableScoreUsername + { + User = score.User, + }); + MaxComboContainer.Add(new SpriteText + { + Text = $@"{score.MaxCombo:N0}x", + TextSize = text_size, + }); + HitGreatContainer.Add(hitGreat = new SpriteText + { + Text = $"{score.Statistics[HitResult.Great]}", + TextSize = text_size, + }); + HitGoodContainer.Add(hitGood = new SpriteText + { + Text = $"{score.Statistics[HitResult.Good]}", + TextSize = text_size, + }); + HitMehContainer.Add(hitMeh = new SpriteText + { + Text = $"{score.Statistics[HitResult.Meh]}", + TextSize = text_size, + }); + HitMissContainer.Add(hitMiss = new SpriteText + { + Text = $"{score.Statistics[HitResult.Miss]}", + TextSize = text_size, + }); + PPContainer.Add(new SpriteText + { + Text = $@"{score.PP:N0}", + TextSize = text_size, + }); + ModsContainer.Add(modsContainer = new FillFlowContainer + { + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + }); + + if (index == 0) + scoreText.Font = @"Exo2.0-Bold"; + + accuracy.Colour = (score.Accuracy == 1) ? Color4.GreenYellow : Color4.White; + 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; + + 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), + }); + } + } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index d2421ec606..7623153710 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -188,7 +188,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Origin = Anchor.CentreRight, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Width = 0.7f, + Width = 0.65f, Child = new FillFlowContainer { AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs new file mode 100644 index 0000000000..d57225b541 --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs @@ -0,0 +1,183 @@ +// Copyright (c) ppy Pty Ltd . 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; + +namespace osu.Game.Overlays.BeatmapSet.Scores +{ + public class ScoreTableLine : GridContainer + { + private const float rank_position = 30; + private const float drawable_rank_position = 45; + private const float score_position = 90; + private const float accuracy_position = 170; + private const float flag_position = 220; + private const float player_position = 250; + + private const float max_combo_position = 0.1f; + private const float hit_great_position = 0.3f; + private const float hit_good_position = 0.45f; + private const float hit_meh_position = 0.6f; + private const float hit_miss_position = 0.75f; + private const float pp_position = 0.9f; + + protected readonly Container RankContainer; + protected readonly Container DrawableRankContainer; + protected readonly Container ScoreContainer; + protected readonly Container AccuracyContainer; + protected readonly Container FlagContainer; + protected readonly Container PlayerContainer; + protected readonly Container MaxComboContainer; + protected readonly Container HitGreatContainer; + protected readonly Container HitGoodContainer; + protected readonly Container HitMehContainer; + protected readonly Container HitMissContainer; + protected readonly Container PPContainer; + protected readonly Container ModsContainer; + + public ScoreTableLine(int maxModsAmount) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + RowDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 25), + }; + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 300), + new Dimension(), + new Dimension(GridSizeMode.AutoSize), + }; + Content = new[] + { + new Drawable[] + { + new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + RankContainer = new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + X = rank_position, + }, + DrawableRankContainer = new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + X = drawable_rank_position, + }, + ScoreContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + X = score_position, + }, + AccuracyContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + X = accuracy_position, + }, + FlagContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + X = flag_position, + }, + PlayerContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + X = player_position, + } + } + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] + { + MaxComboContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + RelativePositionAxes = Axes.X, + X = max_combo_position, + }, + HitGreatContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + RelativePositionAxes = Axes.X, + X = hit_great_position, + }, + HitGoodContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + RelativePositionAxes = Axes.X, + X = hit_good_position, + }, + HitMehContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + RelativePositionAxes = Axes.X, + X = hit_meh_position, + }, + HitMissContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + RelativePositionAxes = Axes.X, + X = hit_miss_position, + }, + PPContainer = new Container + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + RelativePositionAxes = Axes.X, + X = pp_position, + } + } + }, + new Container + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Child = ModsContainer = new Container + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + X = -30 * maxModsAmount, + } + } + } + }; + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs index 04934185a1..b7c9742764 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs @@ -1,107 +1,71 @@ // Copyright (c) ppy Pty Ltd . 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.Framework.Graphics.Sprites; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class ScoreTextLine : Container + public class ScoreTextLine : ScoreTableLine { 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 ScoreTextLine(int maxModsAmount) + public ScoreTextLine(int maxModsAmount) : base(maxModsAmount) { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Children = new Drawable[] + RankContainer.Add(new SpriteText { - 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.CentreRight, - Origin = Anchor.CentreLeft, - Text = "mods".ToUpper(), - X = -30 * maxModsAmount, - }, - }; - } - - private class ScoreText : SpriteText - { - public ScoreText() + Text = @"rank".ToUpper(), + TextSize = text_size, + }); + ScoreContainer.Add(new SpriteText { - TextSize = text_size; - } + Text = @"score".ToUpper(), + TextSize = text_size, + }); + AccuracyContainer.Add(new SpriteText + { + Text = @"accuracy".ToUpper(), + TextSize = text_size, + }); + PlayerContainer.Add(new SpriteText + { + Text = @"player".ToUpper(), + TextSize = text_size, + }); + MaxComboContainer.Add(new SpriteText + { + Text = @"max combo".ToUpper(), + TextSize = text_size, + }); + HitGreatContainer.Add(new SpriteText + { + Text = "300".ToUpper(), + TextSize = text_size, + }); + HitGoodContainer.Add(new SpriteText + { + Text = "100".ToUpper(), + TextSize = text_size, + }); + HitMehContainer.Add(new SpriteText + { + Text = "50".ToUpper(), + TextSize = text_size, + }); + HitMissContainer.Add(new SpriteText + { + Text = @"miss".ToUpper(), + TextSize = text_size, + }); + PPContainer.Add(new SpriteText + { + Text = @"pp".ToUpper(), + TextSize = text_size, + }); + ModsContainer.Add(new SpriteText + { + Text = @"mods".ToUpper(), + TextSize = text_size, + }); } } } From 4d489da03280c51ca1ff2b88f9d00d4dcdf2e715 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 10 Feb 2019 04:16:56 +0300 Subject: [PATCH 12/42] small visual improvements --- .../BeatmapSet/Scores/DrawableTopScore.cs | 12 ++--- .../BeatmapSet/Scores/ScoreTableLine.cs | 2 +- .../BeatmapSet/Scores/ScoreTextLine.cs | 48 +++++++++---------- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 7623153710..e4486b1514 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -200,8 +200,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { new FillFlowContainer { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(margin, 0), @@ -210,15 +210,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores hitGreat = new SmallInfoColumn("300", 20), hitGood = new SmallInfoColumn("100", 20), hitMeh = new SmallInfoColumn("50", 20), - hitMiss = new SmallInfoColumn("miss", 20), + hitMiss = new SmallInfoColumn("misses", 20), pp = new SmallInfoColumn("pp", 20), modsInfo = new ModsInfoColumn("mods"), } }, new FillFlowContainer { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(margin, 0), @@ -347,7 +347,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { TextSize = 12, Text = header.ToUpper(), - Font = @"Exo2.0-Bold", + Font = @"Exo2.0-Black", } }, new Container diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs index d57225b541..5c4723eae1 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs @@ -173,7 +173,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, AutoSizeAxes = Axes.Both, - X = -30 * maxModsAmount, + X = -30 * ((maxModsAmount == 0) ? 1 : maxModsAmount), } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs index b7c9742764..9fd12df3a8 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs @@ -7,65 +7,63 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { public class ScoreTextLine : ScoreTableLine { - private const float text_size = 12; - public ScoreTextLine(int maxModsAmount) : base(maxModsAmount) { - RankContainer.Add(new SpriteText + RankContainer.Add(new ScoreText { Text = @"rank".ToUpper(), - TextSize = text_size, }); - ScoreContainer.Add(new SpriteText + ScoreContainer.Add(new ScoreText { Text = @"score".ToUpper(), - TextSize = text_size, }); - AccuracyContainer.Add(new SpriteText + AccuracyContainer.Add(new ScoreText { Text = @"accuracy".ToUpper(), - TextSize = text_size, }); - PlayerContainer.Add(new SpriteText + PlayerContainer.Add(new ScoreText { Text = @"player".ToUpper(), - TextSize = text_size, }); - MaxComboContainer.Add(new SpriteText + MaxComboContainer.Add(new ScoreText { Text = @"max combo".ToUpper(), - TextSize = text_size, }); - HitGreatContainer.Add(new SpriteText + HitGreatContainer.Add(new ScoreText { Text = "300".ToUpper(), - TextSize = text_size, }); - HitGoodContainer.Add(new SpriteText + HitGoodContainer.Add(new ScoreText { Text = "100".ToUpper(), - TextSize = text_size, }); - HitMehContainer.Add(new SpriteText + HitMehContainer.Add(new ScoreText { Text = "50".ToUpper(), - TextSize = text_size, }); - HitMissContainer.Add(new SpriteText + HitMissContainer.Add(new ScoreText { - Text = @"miss".ToUpper(), - TextSize = text_size, + Text = @"misses".ToUpper(), }); - PPContainer.Add(new SpriteText + PPContainer.Add(new ScoreText { Text = @"pp".ToUpper(), - TextSize = text_size, }); - ModsContainer.Add(new SpriteText + ModsContainer.Add(new ScoreText { Text = @"mods".ToUpper(), - TextSize = text_size, }); } + + private class ScoreText : SpriteText + { + private const float text_size = 12; + + public ScoreText() + { + TextSize = text_size; + Font = @"Exo2.0-Black"; + } + } } } From 8c0e325d8bc54ae802668c483ffdf30a6acbdd0f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 8 Mar 2019 16:40:37 +0900 Subject: [PATCH 13/42] Reduce + make beatmap scores testcase work --- .../Visual/TestCaseBeatmapScoresContainer.cs | 147 +----------------- 1 file changed, 6 insertions(+), 141 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs index 4ad5b2dc35..072bbff4cf 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs @@ -13,9 +13,7 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Users; using System.Collections.Generic; using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; using osu.Game.Online.API.Requests.Responses; -using osu.Game.Rulesets.Osu; using osu.Game.Scoring; using NUnit.Framework; @@ -67,6 +65,7 @@ namespace osu.Game.Tests.Visual new OsuModHardRock(), }, Rank = ScoreRank.XH, + MaxCombo = 1234, TotalScore = 1234567890, Accuracy = 1, }, @@ -89,6 +88,7 @@ namespace osu.Game.Tests.Visual new OsuModFlashlight(), }, Rank = ScoreRank.S, + MaxCombo = 1234, TotalScore = 1234789, Accuracy = 0.9997, }, @@ -110,6 +110,7 @@ namespace osu.Game.Tests.Visual new OsuModHidden(), }, Rank = ScoreRank.B, + MaxCombo = 1234, TotalScore = 12345678, Accuracy = 0.9854, }, @@ -130,6 +131,7 @@ namespace osu.Game.Tests.Visual new OsuModDoubleTime(), }, Rank = ScoreRank.C, + MaxCombo = 1234, TotalScore = 1234567, Accuracy = 0.8765, }, @@ -146,6 +148,7 @@ namespace osu.Game.Tests.Visual }, }, Rank = ScoreRank.F, + MaxCombo = 1234, TotalScore = 123456, Accuracy = 0.6543, }, @@ -159,145 +162,7 @@ namespace osu.Game.Tests.Visual s.Statistics.Add(HitResult.Miss, RNG.Next(2000)); } - IEnumerable anotherScores = new[] - { - new APIScoreInfo - { - User = new User - { - Id = 4608074, - Username = @"Skycries", - Country = new Country - { - FullName = @"Brazil", - FlagName = @"BR", - }, - }, - Mods = new Mod[] - { - new OsuModDoubleTime(), - new OsuModHidden(), - new OsuModFlashlight(), - }, - Rank = ScoreRank.S, - TotalScore = 1234789, - Accuracy = 0.9997, - }, - new APIScoreInfo - { - User = new User - { - Id = 6602580, - Username = @"waaiiru", - Country = new Country - { - FullName = @"Spain", - FlagName = @"ES", - }, - }, - Mods = new Mod[] - { - new OsuModDoubleTime(), - new OsuModHidden(), - new OsuModFlashlight(), - new OsuModHardRock(), - }, - Rank = ScoreRank.XH, - TotalScore = 1234567890, - Accuracy = 1, - }, - new APIScoreInfo - { - User = new User - { - Id = 7151382, - Username = @"Mayuri Hana", - Country = new Country - { - FullName = @"Thailand", - FlagName = @"TH", - }, - }, - Rank = ScoreRank.F, - TotalScore = 123456, - Accuracy = 0.6543, - }, - new APIScoreInfo - { - User = new User - { - Id = 1014222, - Username = @"eLy", - Country = new Country - { - FullName = @"Japan", - FlagName = @"JP", - }, - }, - Mods = new Mod[] - { - new OsuModDoubleTime(), - new OsuModHidden(), - }, - Rank = ScoreRank.B, - TotalScore = 12345678, - Accuracy = 0.9854, - }, - new APIScoreInfo - { - User = new User - { - Id = 1541390, - Username = @"Toukai", - Country = new Country - { - FullName = @"Canada", - FlagName = @"CA", - }, - }, - Mods = new Mod[] - { - new OsuModDoubleTime(), - }, - Rank = ScoreRank.C, - TotalScore = 1234567, - Accuracy = 0.8765, - }, - }; - foreach (var s in anotherScores) - { - s.Statistics.Add(HitResult.Great, RNG.Next(2000)); - s.Statistics.Add(HitResult.Good, RNG.Next(2000)); - s.Statistics.Add(HitResult.Meh, RNG.Next(2000)); - s.Statistics.Add(HitResult.Miss, RNG.Next(2000)); - } - - var topScoreInfo = new APIScoreInfo - { - User = new User - { - Id = 2705430, - Username = @"Mooha", - Country = new Country - { - FullName = @"France", - FlagName = @"FR", - }, - }, - Mods = new Mod[] - { - new OsuModDoubleTime(), - new OsuModFlashlight(), - new OsuModHardRock(), - }, - Rank = ScoreRank.B, - TotalScore = 987654321, - Accuracy = 0.8487, - }; - topScoreInfo.Statistics.Add(HitResult.Great, RNG.Next(2000)); - topScoreInfo.Statistics.Add(HitResult.Good, RNG.Next(2000)); - topScoreInfo.Statistics.Add(HitResult.Meh, RNG.Next(2000)); - topScoreInfo.Statistics.Add(HitResult.Miss, RNG.Next(2000)); + scoresContainer.Scores = scores; } [BackgroundDependencyLoader] From a40ffcc6920d5bc25f0782727a1b967e1b1fc951 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 8 Mar 2019 16:44:39 +0900 Subject: [PATCH 14/42] Apply formatting adjustments --- .../Visual/TestCaseBeatmapScoresContainer.cs | 8 ++++-- .../Scores/ClickableUserContainer.cs | 1 - .../BeatmapSet/Scores/DrawableScore.cs | 3 ++- .../BeatmapSet/Scores/DrawableTopScore.cs | 25 +++++++++++++------ .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 6 ++--- .../BeatmapSet/Scores/ScoreTextLine.cs | 3 ++- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs index 072bbff4cf..ead743a283 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs @@ -26,10 +26,9 @@ namespace osu.Game.Tests.Visual public TestCaseBeatmapScoresContainer() { - Container container; ScoresContainer scoresContainer; - Child = container = new Container + Child = new Container { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -65,6 +64,7 @@ namespace osu.Game.Tests.Visual new OsuModHardRock(), }, Rank = ScoreRank.XH, + PP = 200, MaxCombo = 1234, TotalScore = 1234567890, Accuracy = 1, @@ -88,6 +88,7 @@ namespace osu.Game.Tests.Visual new OsuModFlashlight(), }, Rank = ScoreRank.S, + PP = 190, MaxCombo = 1234, TotalScore = 1234789, Accuracy = 0.9997, @@ -110,6 +111,7 @@ namespace osu.Game.Tests.Visual new OsuModHidden(), }, Rank = ScoreRank.B, + PP = 180, MaxCombo = 1234, TotalScore = 12345678, Accuracy = 0.9854, @@ -131,6 +133,7 @@ namespace osu.Game.Tests.Visual new OsuModDoubleTime(), }, Rank = ScoreRank.C, + PP = 170, MaxCombo = 1234, TotalScore = 1234567, Accuracy = 0.8765, @@ -148,6 +151,7 @@ namespace osu.Game.Tests.Visual }, }, Rank = ScoreRank.F, + PP = 160, MaxCombo = 1234, TotalScore = 123456, Accuracy = 0.6543, diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs index 3f1c8f56f5..cf1c3d7fcf 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; -using osu.Game.Graphics; using osu.Game.Users; namespace osu.Game.Overlays.BeatmapSet.Scores diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index 8741fd8dfe..19e999547b 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -118,7 +118,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private class DrawableScoreData : ScoreTableLine { - public DrawableScoreData(int index, APIScoreInfo score, int maxModsAmount) : base(maxModsAmount) + public DrawableScoreData(int index, APIScoreInfo score, int maxModsAmount) + : base(maxModsAmount) { SpriteText scoreText; SpriteText accuracy; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index e4486b1514..3712f38d02 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -56,13 +56,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly ModsInfoColumn modsInfo; private APIScoreInfo score; + public APIScoreInfo Score { - get { return score; } + get => score; set { if (score == value) return; + score = value; avatar.User = username.User = score.User; @@ -274,9 +276,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { if (text.TextSize == value) return; + text.TextSize = value; } - get { return text.TextSize; } + get => text.TextSize; } public ClickableTopScoreUsername() @@ -386,7 +389,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } } - public ModsInfoColumn(string header) : base(header) + public ModsInfoColumn(string header) + : base(header) { AutoSizeAxes = Axes.Both; Add(modsContainer = new FillFlowContainer @@ -409,12 +413,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { if (valueText.Text == value) return; + valueText.Text = value; } - get { return valueText.Text; } + get => valueText.Text; } - protected TextInfoColumn(string header, float valueTextSize = 25) : base(header) + protected TextInfoColumn(string header, float valueTextSize = 25) + : base(header) { Add(valueText = new SpriteText { @@ -425,7 +431,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private class AutoSizedInfoColumn : TextInfoColumn { - public AutoSizedInfoColumn(string header, float valueTextSize = 25) : base(header, valueTextSize) + public AutoSizedInfoColumn(string header, float valueTextSize = 25) + : base(header, valueTextSize) { AutoSizeAxes = Axes.Both; } @@ -435,7 +442,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { private const float width = 70; - public MediumInfoColumn(string header, float valueTextSize = 25) : base(header, valueTextSize) + public MediumInfoColumn(string header, float valueTextSize = 25) + : base(header, valueTextSize) { Width = width; } @@ -445,7 +453,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { private const float width = 40; - public SmallInfoColumn(string header, float valueTextSize = 25) : base(header, valueTextSize) + public SmallInfoColumn(string header, float valueTextSize = 25) + : base(header, valueTextSize) { Width = width; } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 1b20b2c382..d69bc39bc6 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -11,6 +11,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public class ScoreTable : FillFlowContainer { private IEnumerable scores; + public IEnumerable Scores { set @@ -31,10 +32,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores foreach (var s in scores) Add(new DrawableScore(index++, s, maxModsAmount)); } - get - { - return scores; - } + get => scores; } public ScoreTable() diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs index 9fd12df3a8..9e201bd98d 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs @@ -7,7 +7,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { public class ScoreTextLine : ScoreTableLine { - public ScoreTextLine(int maxModsAmount) : base(maxModsAmount) + public ScoreTextLine(int maxModsAmount) + : base(maxModsAmount) { RankContainer.Add(new ScoreText { From 9a05643ec980732837124698e535396c34ab73bf Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 8 Mar 2019 17:18:54 +0900 Subject: [PATCH 15/42] Minor refactorings --- .../BeatmapSet/Scores/DrawableScore.cs | 2 + .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 45 +++--- .../BeatmapSet/Scores/ScoresContainer.cs | 140 +++++++++--------- 3 files changed, 97 insertions(+), 90 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index 19e999547b..a2a9f9a01b 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -31,8 +31,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; + CornerRadius = 3; Masking = true; + Children = new Drawable[] { background = new Box diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index d69bc39bc6..4723fcaf2b 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -5,47 +5,50 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Online.API.Requests.Responses; using System.Collections.Generic; +using System.Linq; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class ScoreTable : FillFlowContainer + public class ScoreTable : CompositeDrawable { - private IEnumerable scores; + private readonly FillFlowContainer scoresFlow; + + public ScoreTable() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + InternalChild = scoresFlow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical + }; + } public IEnumerable Scores { set { - scores = value; + scoresFlow.Clear(); + + if (value == null || !value.Any()) + return; int maxModsAmount = 0; - foreach (var s in scores) + foreach (var s in value) { var scoreModsAmount = s.Mods.Length; if (scoreModsAmount > maxModsAmount) maxModsAmount = scoreModsAmount; } - Add(new ScoreTextLine(maxModsAmount)); + scoresFlow.Add(new ScoreTextLine(maxModsAmount)); int index = 0; - foreach (var s in scores) - Add(new DrawableScore(index++, s, maxModsAmount)); + foreach (var s in value) + scoresFlow.Add(new DrawableScore(index++, s, maxModsAmount)); } - get => scores; - } - - public ScoreTable() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Direction = FillDirection.Vertical; - } - - public void ClearScores() - { - scores = null; - Clear(); } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index d99f391d21..6c90e192ac 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -17,7 +17,7 @@ using System.Linq; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class ScoresContainer : Container + public class ScoresContainer : CompositeDrawable { private const int spacing = 15; private const int fade_duration = 200; @@ -28,77 +28,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly DrawableTopScore topScore; private readonly LoadingAnimation loadingAnimation; - private bool loading - { - set => loadingAnimation.FadeTo(value ? 1 : 0, fade_duration); - } - - private IEnumerable scores; - private BeatmapInfo beatmap; - - public IEnumerable Scores - { - get => scores; - set - { - getScoresRequest?.Cancel(); - scores = value; - - updateDisplay(); - } - } - - private GetScoresRequest getScoresRequest; - private APIAccess api; - - public BeatmapInfo Beatmap - { - get => beatmap; - set - { - beatmap = value; - - Scores = null; - - if (beatmap?.OnlineBeatmapID.HasValue != true) - return; - - loading = true; - - getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset); - getScoresRequest.Success += r => Schedule(() => Scores = r.Scores); - api.Queue(getScoresRequest); - } - } - - private void updateDisplay() - { - scoreTable.ClearScores(); - - loading = false; - - var scoreCount = scores?.Count() ?? 0; - - if (scoreCount == 0) - { - topScore.Hide(); - return; - } - - topScore.Score = scores.FirstOrDefault(); - topScore.Show(); - - if (scoreCount < 2) - return; - - scoreTable.Scores = scores; - } + [Resolved] + private APIAccess api { get; set; } public ScoresContainer() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Children = new Drawable[] + + InternalChildren = new Drawable[] { background = new Box { @@ -135,12 +73,76 @@ namespace osu.Game.Overlays.BeatmapSet.Scores [BackgroundDependencyLoader] private void load(APIAccess api, OsuColour colours) { - this.api = api; - background.Colour = colours.Gray2; updateDisplay(); } + private bool loading + { + set => loadingAnimation.FadeTo(value ? 1 : 0, fade_duration); + } + + private GetScoresRequest getScoresRequest; + + private IEnumerable scores; + + public IEnumerable Scores + { + get => scores; + set + { + getScoresRequest?.Cancel(); + scores = value; + + updateDisplay(); + } + } + + private BeatmapInfo beatmap; + + public BeatmapInfo Beatmap + { + get => beatmap; + set + { + beatmap = value; + + Scores = null; + + if (beatmap?.OnlineBeatmapID.HasValue != true) + return; + + loading = true; + + getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset); + getScoresRequest.Success += r => Schedule(() => Scores = r.Scores); + api.Queue(getScoresRequest); + } + } + + private void updateDisplay() + { + scoreTable.Scores = Enumerable.Empty(); + + loading = false; + + var scoreCount = scores?.Count() ?? 0; + + if (scoreCount == 0) + { + topScore.Hide(); + return; + } + + topScore.Score = scores.FirstOrDefault(); + topScore.Show(); + + if (scoreCount < 2) + return; + + scoreTable.Scores = scores; + } + protected override void Dispose(bool isDisposing) { getScoresRequest?.Cancel(); From 315788c97535344f84988c12a63777fbc5032620 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 11 Mar 2019 15:11:01 +0900 Subject: [PATCH 16/42] Rename a few classes --- osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs | 6 +++--- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 2 +- .../Scores/{ScoreTextLine.cs => ScoreTableHeader.cs} | 4 ++-- .../Scores/{ScoreTableLine.cs => ScoreTableRow.cs} | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename osu.Game/Overlays/BeatmapSet/Scores/{ScoreTextLine.cs => ScoreTableHeader.cs} (94%) rename osu.Game/Overlays/BeatmapSet/Scores/{ScoreTableLine.cs => ScoreTableRow.cs} (98%) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index a2a9f9a01b..d7396c8839 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -46,7 +46,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores RelativeSizeAxes = Axes.Both, Alpha = 0, }, - new DrawableScoreData(index, score, maxModsAmount), + new ScoreRow(index, score, maxModsAmount), }; if (index % 2 != 0) @@ -118,9 +118,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } } - private class DrawableScoreData : ScoreTableLine + private class ScoreRow : ScoreTableRow { - public DrawableScoreData(int index, APIScoreInfo score, int maxModsAmount) + public ScoreRow(int index, APIScoreInfo score, int maxModsAmount) : base(maxModsAmount) { SpriteText scoreText; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 4723fcaf2b..5d248c5501 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -43,7 +43,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores maxModsAmount = scoreModsAmount; } - scoresFlow.Add(new ScoreTextLine(maxModsAmount)); + scoresFlow.Add(new ScoreTableHeader(maxModsAmount)); int index = 0; foreach (var s in value) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeader.cs similarity index 94% rename from osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs rename to osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeader.cs index 9e201bd98d..544bf34ec5 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTextLine.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeader.cs @@ -5,9 +5,9 @@ using osu.Framework.Graphics.Sprites; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class ScoreTextLine : ScoreTableLine + public class ScoreTableHeader : ScoreTableRow { - public ScoreTextLine(int maxModsAmount) + public ScoreTableHeader(int maxModsAmount) : base(maxModsAmount) { RankContainer.Add(new ScoreText diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs similarity index 98% rename from osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs rename to osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs index 5c4723eae1..3a48a0cca1 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableLine.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs @@ -6,7 +6,7 @@ using osu.Framework.Graphics.Containers; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class ScoreTableLine : GridContainer + public class ScoreTableRow : GridContainer { private const float rank_position = 30; private const float drawable_rank_position = 45; @@ -36,7 +36,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected readonly Container PPContainer; protected readonly Container ModsContainer; - public ScoreTableLine(int maxModsAmount) + public ScoreTableRow(int maxModsAmount) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; From 41d25c7d19d6d7babd2c0194d77fc68bf8dcfc2b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 20 Mar 2019 17:15:21 +0900 Subject: [PATCH 17/42] Fix post-merge errors --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 6c90e192ac..79858a9ccb 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -29,7 +29,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly LoadingAnimation loadingAnimation; [Resolved] - private APIAccess api { get; set; } + private IAPIProvider api { get; set; } public ScoresContainer() { @@ -71,7 +71,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } [BackgroundDependencyLoader] - private void load(APIAccess api, OsuColour colours) + private void load(OsuColour colours) { background.Colour = colours.Gray2; updateDisplay(); From f7016e1d2c81b4ab675c3a654ca3695bbf1265b5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 20 Mar 2019 17:15:38 +0900 Subject: [PATCH 18/42] Rename DrawableScore --- osu.Game.Tests/Visual/TestCaseBeatmapSetOverlay.cs | 2 +- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 2 +- .../Scores/{DrawableScore.cs => ScoreTableScore.cs} | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename osu.Game/Overlays/BeatmapSet/Scores/{DrawableScore.cs => ScoreTableScore.cs} (98%) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/TestCaseBeatmapSetOverlay.cs index 20609dc595..58ccaf9dfa 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapSetOverlay.cs @@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual { typeof(Header), typeof(ClickableUserContainer), - typeof(DrawableScore), + typeof(ScoreTableScore), typeof(DrawableTopScore), typeof(ScoresContainer), typeof(AuthorInfo), diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 5d248c5501..aacbc12cd8 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -47,7 +47,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores int index = 0; foreach (var s in value) - scoresFlow.Add(new DrawableScore(index++, s, maxModsAmount)); + scoresFlow.Add(new ScoreTableScore(index++, s, maxModsAmount)); } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScore.cs similarity index 98% rename from osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs rename to osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScore.cs index d7396c8839..a54770fb39 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScore.cs @@ -19,7 +19,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class DrawableScore : Container + public class ScoreTableScore : Container { private const int fade_duration = 100; private const int text_size = 14; @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly Box hoveredBackground; private readonly Box background; - public DrawableScore(int index, APIScoreInfo score, int maxModsAmount) + public ScoreTableScore(int index, APIScoreInfo score, int maxModsAmount) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; From f4aeb390efb7ee2a8620a73c02e0a43bf25b1f86 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 26 Mar 2019 10:21:34 +0900 Subject: [PATCH 19/42] Initial re-layout of score table --- .../TestCaseBeatmapScoresContainer.cs | 12 +- .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 213 +++++++++++++++++- 2 files changed, 222 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs index b626c23f25..2bc0796045 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs @@ -1,18 +1,17 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.MathUtils; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapSet.Scores; using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; @@ -24,6 +23,15 @@ namespace osu.Game.Tests.Visual.SongSelect [Description("in BeatmapOverlay")] public class TestCaseBeatmapScoresContainer : OsuTestCase { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(ScoresContainer), + typeof(ScoreTable), + typeof(ScoreTableRow), + typeof(ScoreTableHeader), + typeof(ScoreTableScore) + }; + private readonly Box background; public TestCaseBeatmapScoresContainer() diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index aacbc12cd8..7e838f0aae 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -6,19 +6,52 @@ using osu.Framework.Graphics.Containers; using osu.Game.Online.API.Requests.Responses; using System.Collections.Generic; using System.Linq; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Game.Graphics; +using osu.Game.Online.Leaderboards; +using osu.Game.Rulesets.Scoring; +using osu.Game.Rulesets.UI; +using osu.Game.Users; +using osuTK; +using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet.Scores { public class ScoreTable : CompositeDrawable { + private const int fade_duration = 100; + private const int text_size = 14; + private readonly FillFlowContainer scoresFlow; + private readonly ScoresGrid scoresGrid; public ScoreTable() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - InternalChild = scoresFlow = new FillFlowContainer + InternalChild = scoresGrid = new ScoresGrid + { + RelativeSizeAxes = Axes.X, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 40), + new Dimension(GridSizeMode.Absolute, 70), + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.Distributed, minSize: 180), + new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), + new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), + new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), + new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), + new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), + new Dimension(GridSizeMode.Distributed, minSize: 40, maxSize: 70), + new Dimension(GridSizeMode.AutoSize), + } + }; + + scoresFlow = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -48,6 +81,184 @@ namespace osu.Game.Overlays.BeatmapSet.Scores int index = 0; foreach (var s in value) scoresFlow.Add(new ScoreTableScore(index++, s, maxModsAmount)); + + scoresGrid.Content = value.Select((s, i) => createRowContents(s, i).ToArray()).ToArray(); + } + } + + private IEnumerable createRowContents(APIScoreInfo score, int index) + { + yield return new SpriteText + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Text = $"#{index + 1}", + Font = @"Exo2.0-Bold", + TextSize = text_size, + }; + + yield return new DrawableRank(score.Rank) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(30, 20), + FillMode = FillMode.Fit, + }; + + yield return new SpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding { Right = 20 }, + Text = $@"{score.TotalScore:N0}", + TextSize = text_size, + Font = index == 0 ? OsuFont.GetFont(weight: FontWeight.Bold) : OsuFont.Default + }; + + yield return new SpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding { Right = 20 }, + Text = $@"{score.Accuracy:P2}", + TextSize = text_size, + Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White + }; + + yield return new FillFlowContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5, 0), + Children = new Drawable[] + { + new DrawableFlag(score.User.Country) + { + Size = new Vector2(20, 13), + }, + new ClickableScoreUsername + { + User = score.User, + } + } + }; + + yield return new SpriteText + { + Text = $@"{score.MaxCombo:N0}x", + TextSize = text_size, + }; + + yield return new SpriteText + { + Text = $"{score.Statistics[HitResult.Great]}", + TextSize = text_size, + Colour = score.Statistics[HitResult.Great] == 0 ? Color4.Gray : Color4.White + }; + + yield return new SpriteText + { + Text = $"{score.Statistics[HitResult.Good]}", + TextSize = text_size, + Colour = score.Statistics[HitResult.Good] == 0 ? Color4.Gray : Color4.White + }; + + yield return new SpriteText + { + Text = $"{score.Statistics[HitResult.Meh]}", + TextSize = text_size, + Colour = score.Statistics[HitResult.Meh] == 0 ? Color4.Gray : Color4.White + }; + + yield return new SpriteText + { + Text = $"{score.Statistics[HitResult.Miss]}", + TextSize = text_size, + Colour = score.Statistics[HitResult.Miss] == 0 ? Color4.Gray : Color4.White + }; + + yield return new SpriteText + { + Text = $@"{score.PP:N0}", + TextSize = text_size, + }; + + yield return new FillFlowContainer + { + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Scale = new Vector2(0.3f), + }) + }; + } + + private class ScoresGrid : GridContainer + { + public ScoresGrid() + { + AutoSizeAxes = Axes.Y; + } + + public Drawable[][] Content + { + get => base.Content; + set + { + base.Content = value; + + RowDimensions = Enumerable.Repeat(new Dimension(GridSizeMode.Absolute, 25), value.Length).ToArray(); + } + } + } + + 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); } } } From adab31fd582dfe6509e863f3f221b012271142b1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 26 Mar 2019 17:38:56 +0900 Subject: [PATCH 20/42] Cleanup + fix up score table layout --- .../Online/TestCaseBeatmapSetOverlay.cs | 6 +- .../TestCaseBeatmapScoresContainer.cs | 5 +- .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 237 +++-------------- .../BeatmapSet/Scores/ScoreTableHeader.cs | 70 ----- .../BeatmapSet/Scores/ScoreTableHeaderRow.cs | 46 ++++ .../BeatmapSet/Scores/ScoreTableRow.cs | 246 ++++++------------ .../Scores/ScoreTableRowBackground.cs | 64 +++++ .../BeatmapSet/Scores/ScoreTableScore.cs | 220 ---------------- .../BeatmapSet/Scores/ScoreTableScoreRow.cs | 168 ++++++++++++ 9 files changed, 401 insertions(+), 661 deletions(-) delete mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeader.cs create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRowBackground.cs delete mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScore.cs create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs diff --git a/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs index df24c42b00..19d295cf12 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs @@ -25,7 +25,11 @@ namespace osu.Game.Tests.Visual.Online { typeof(Header), typeof(ClickableUserContainer), - typeof(ScoreTableScore), + typeof(ScoreTable), + typeof(ScoreTableRow), + typeof(ScoreTableHeaderRow), + typeof(ScoreTableScoreRow), + typeof(ScoreTableRowBackground), typeof(DrawableTopScore), typeof(ScoresContainer), typeof(AuthorInfo), diff --git a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs index 2bc0796045..63dacef8fa 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs @@ -28,8 +28,9 @@ namespace osu.Game.Tests.Visual.SongSelect typeof(ScoresContainer), typeof(ScoreTable), typeof(ScoreTableRow), - typeof(ScoreTableHeader), - typeof(ScoreTableScore) + typeof(ScoreTableHeaderRow), + typeof(ScoreTableScoreRow), + typeof(ScoreTableRowBackground), }; private readonly Box background; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 7e838f0aae..e2acf778a3 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -6,203 +6,74 @@ using osu.Framework.Graphics.Containers; using osu.Game.Online.API.Requests.Responses; using System.Collections.Generic; using System.Linq; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; -using osu.Game.Graphics; -using osu.Game.Online.Leaderboards; -using osu.Game.Rulesets.Scoring; -using osu.Game.Rulesets.UI; -using osu.Game.Users; -using osuTK; -using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet.Scores { public class ScoreTable : CompositeDrawable { - private const int fade_duration = 100; - private const int text_size = 14; - - private readonly FillFlowContainer scoresFlow; private readonly ScoresGrid scoresGrid; + private readonly FillFlowContainer backgroundFlow; public ScoreTable() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - InternalChild = scoresGrid = new ScoresGrid + InternalChildren = new Drawable[] { - RelativeSizeAxes = Axes.X, - ColumnDimensions = new[] + backgroundFlow = new FillFlowContainer { - new Dimension(GridSizeMode.Absolute, 40), - new Dimension(GridSizeMode.Absolute, 70), - new Dimension(GridSizeMode.AutoSize), - new Dimension(GridSizeMode.AutoSize), - new Dimension(GridSizeMode.Distributed, minSize: 180), - new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), - new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), - new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), - new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), - new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), - new Dimension(GridSizeMode.Distributed, minSize: 40, maxSize: 70), - new Dimension(GridSizeMode.AutoSize), + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Top = 25 } + }, + scoresGrid = new ScoresGrid + { + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 40), + new Dimension(GridSizeMode.Absolute, 70), + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.Distributed, minSize: 150), + new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 90), + new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), + new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), + new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), + new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), + new Dimension(GridSizeMode.Distributed, minSize: 40, maxSize: 70), + new Dimension(GridSizeMode.AutoSize), + } } }; - - scoresFlow = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical - }; } public IEnumerable Scores { set { - scoresFlow.Clear(); - if (value == null || !value.Any()) return; - int maxModsAmount = 0; - foreach (var s in value) - { - var scoreModsAmount = s.Mods.Length; - if (scoreModsAmount > maxModsAmount) - maxModsAmount = scoreModsAmount; - } - - scoresFlow.Add(new ScoreTableHeader(maxModsAmount)); + var content = new List { new ScoreTableHeaderRow().CreateDrawables().ToArray() }; int index = 0; foreach (var s in value) - scoresFlow.Add(new ScoreTableScore(index++, s, maxModsAmount)); + content.Add(new ScoreTableScoreRow(index++, s).CreateDrawables().ToArray()); - scoresGrid.Content = value.Select((s, i) => createRowContents(s, i).ToArray()).ToArray(); + scoresGrid.Content = content.ToArray(); + + backgroundFlow.Clear(); + for (int i = 0; i < index; i++) + backgroundFlow.Add(new ScoreTableRowBackground(i)); } } - private IEnumerable createRowContents(APIScoreInfo score, int index) - { - yield return new SpriteText - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Text = $"#{index + 1}", - Font = @"Exo2.0-Bold", - TextSize = text_size, - }; - - yield return new DrawableRank(score.Rank) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(30, 20), - FillMode = FillMode.Fit, - }; - - yield return new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Margin = new MarginPadding { Right = 20 }, - Text = $@"{score.TotalScore:N0}", - TextSize = text_size, - Font = index == 0 ? OsuFont.GetFont(weight: FontWeight.Bold) : OsuFont.Default - }; - - yield return new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Margin = new MarginPadding { Right = 20 }, - Text = $@"{score.Accuracy:P2}", - TextSize = text_size, - Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White - }; - - yield return new FillFlowContainer - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5, 0), - Children = new Drawable[] - { - new DrawableFlag(score.User.Country) - { - Size = new Vector2(20, 13), - }, - new ClickableScoreUsername - { - User = score.User, - } - } - }; - - yield return new SpriteText - { - Text = $@"{score.MaxCombo:N0}x", - TextSize = text_size, - }; - - yield return new SpriteText - { - Text = $"{score.Statistics[HitResult.Great]}", - TextSize = text_size, - Colour = score.Statistics[HitResult.Great] == 0 ? Color4.Gray : Color4.White - }; - - yield return new SpriteText - { - Text = $"{score.Statistics[HitResult.Good]}", - TextSize = text_size, - Colour = score.Statistics[HitResult.Good] == 0 ? Color4.Gray : Color4.White - }; - - yield return new SpriteText - { - Text = $"{score.Statistics[HitResult.Meh]}", - TextSize = text_size, - Colour = score.Statistics[HitResult.Meh] == 0 ? Color4.Gray : Color4.White - }; - - yield return new SpriteText - { - Text = $"{score.Statistics[HitResult.Miss]}", - TextSize = text_size, - Colour = score.Statistics[HitResult.Miss] == 0 ? Color4.Gray : Color4.White - }; - - yield return new SpriteText - { - Text = $@"{score.PP:N0}", - TextSize = text_size, - }; - - yield return new FillFlowContainer - { - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, - ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m) - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Scale = new Vector2(0.3f), - }) - }; - } - private class ScoresGrid : GridContainer { public ScoresGrid() { + RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; } @@ -217,49 +88,5 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } } } - - 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); - } - } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeader.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeader.cs deleted file mode 100644 index 544bf34ec5..0000000000 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeader.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics.Sprites; - -namespace osu.Game.Overlays.BeatmapSet.Scores -{ - public class ScoreTableHeader : ScoreTableRow - { - public ScoreTableHeader(int maxModsAmount) - : base(maxModsAmount) - { - RankContainer.Add(new ScoreText - { - Text = @"rank".ToUpper(), - }); - ScoreContainer.Add(new ScoreText - { - Text = @"score".ToUpper(), - }); - AccuracyContainer.Add(new ScoreText - { - Text = @"accuracy".ToUpper(), - }); - PlayerContainer.Add(new ScoreText - { - Text = @"player".ToUpper(), - }); - MaxComboContainer.Add(new ScoreText - { - Text = @"max combo".ToUpper(), - }); - HitGreatContainer.Add(new ScoreText - { - Text = "300".ToUpper(), - }); - HitGoodContainer.Add(new ScoreText - { - Text = "100".ToUpper(), - }); - HitMehContainer.Add(new ScoreText - { - Text = "50".ToUpper(), - }); - HitMissContainer.Add(new ScoreText - { - Text = @"misses".ToUpper(), - }); - PPContainer.Add(new ScoreText - { - Text = @"pp".ToUpper(), - }); - ModsContainer.Add(new ScoreText - { - Text = @"mods".ToUpper(), - }); - } - - private class ScoreText : SpriteText - { - private const float text_size = 12; - - public ScoreText() - { - TextSize = text_size; - Font = @"Exo2.0-Black"; - } - } - } -} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs new file mode 100644 index 0000000000..a48716b71a --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs @@ -0,0 +1,46 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.BeatmapSet.Scores +{ + public class ScoreTableHeaderRow : ScoreTableRow + { + protected override Drawable CreateIndexCell() => new CellText("rank"); + + protected override Drawable CreateRankCell() => new Container(); + + protected override Drawable CreateScoreCell() => new CellText("score"); + + protected override Drawable CreateAccuracyCell() => new CellText("accuracy"); + + protected override Drawable CreatePlayerCell() => new CellText("player"); + + protected override IEnumerable CreateStatisticsCells() => new[] + { + new CellText("max combo"), + new CellText("300"), + new CellText("100"), + new CellText("50"), + new CellText("miss"), + }; + + protected override Drawable CreatePpCell() => new CellText("pp"); + + protected override Drawable CreateModsCell() => new CellText("mods"); + + private class CellText : OsuSpriteText + { + public CellText(string text) + { + Text = text.ToUpper(); + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black); + } + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs index 3a48a0cca1..4abfb92957 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs @@ -1,183 +1,103 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class ScoreTableRow : GridContainer + public abstract class ScoreTableRow { - private const float rank_position = 30; - private const float drawable_rank_position = 45; - private const float score_position = 90; - private const float accuracy_position = 170; - private const float flag_position = 220; - private const float player_position = 250; + protected const int TEXT_SIZE = 14; - private const float max_combo_position = 0.1f; - private const float hit_great_position = 0.3f; - private const float hit_good_position = 0.45f; - private const float hit_meh_position = 0.6f; - private const float hit_miss_position = 0.75f; - private const float pp_position = 0.9f; - - protected readonly Container RankContainer; - protected readonly Container DrawableRankContainer; - protected readonly Container ScoreContainer; - protected readonly Container AccuracyContainer; - protected readonly Container FlagContainer; - protected readonly Container PlayerContainer; - protected readonly Container MaxComboContainer; - protected readonly Container HitGreatContainer; - protected readonly Container HitGoodContainer; - protected readonly Container HitMehContainer; - protected readonly Container HitMissContainer; - protected readonly Container PPContainer; - protected readonly Container ModsContainer; - - public ScoreTableRow(int maxModsAmount) + public IEnumerable CreateDrawables() { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - RowDimensions = new[] + yield return new Container { - new Dimension(GridSizeMode.Absolute, 25), + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + Child = CreateIndexCell() }; - ColumnDimensions = new[] + + yield return new Container { - new Dimension(GridSizeMode.Absolute, 300), - new Dimension(), - new Dimension(GridSizeMode.AutoSize), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Child = CreateRankCell() }; - Content = new[] + + yield return new Container { - new Drawable[] + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Right = 20 }, + Child = CreateScoreCell() + }; + + yield return new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Right = 20 }, + Child = CreateAccuracyCell() + }; + + yield return new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Right = 20 }, + Child = CreatePlayerCell() + }; + + foreach (var cell in CreateStatisticsCells()) + { + yield return new Container { - new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - RankContainer = new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreRight, - AutoSizeAxes = Axes.Both, - X = rank_position, - }, - DrawableRankContainer = new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - X = drawable_rank_position, - }, - ScoreContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - X = score_position, - }, - AccuracyContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - X = accuracy_position, - }, - FlagContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - X = flag_position, - }, - PlayerContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - X = player_position, - } - } - }, - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Children = new Drawable[] - { - MaxComboContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - RelativePositionAxes = Axes.X, - X = max_combo_position, - }, - HitGreatContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - RelativePositionAxes = Axes.X, - X = hit_great_position, - }, - HitGoodContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - RelativePositionAxes = Axes.X, - X = hit_good_position, - }, - HitMehContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - RelativePositionAxes = Axes.X, - X = hit_meh_position, - }, - HitMissContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - RelativePositionAxes = Axes.X, - X = hit_miss_position, - }, - PPContainer = new Container - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - RelativePositionAxes = Axes.X, - X = pp_position, - } - } - }, - new Container - { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Child = ModsContainer = new Container - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - X = -30 * ((maxModsAmount == 0) ? 1 : maxModsAmount), - } - } - } + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Child = cell + }; + } + + yield return new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Child = CreatePpCell() + }; + + yield return new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Child = CreateModsCell() }; } + + protected abstract Drawable CreateIndexCell(); + + protected abstract Drawable CreateRankCell(); + + protected abstract Drawable CreateScoreCell(); + + protected abstract Drawable CreateAccuracyCell(); + + protected abstract Drawable CreatePlayerCell(); + + protected abstract IEnumerable CreateStatisticsCells(); + + protected abstract Drawable CreatePpCell(); + + protected abstract Drawable CreateModsCell(); } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRowBackground.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRowBackground.cs new file mode 100644 index 0000000000..d820f4d89d --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRowBackground.cs @@ -0,0 +1,64 @@ +// Copyright (c) ppy Pty Ltd . 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.Shapes; +using osu.Framework.Input.Events; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.BeatmapSet.Scores +{ + public class ScoreTableRowBackground : CompositeDrawable + { + private const int fade_duration = 100; + + private readonly Box hoveredBackground; + private readonly Box background; + + public ScoreTableRowBackground(int index) + { + RelativeSizeAxes = Axes.X; + Height = 25; + + CornerRadius = 3; + Masking = true; + + InternalChildren = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + hoveredBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + }, + }; + + if (index % 2 != 0) + background.Alpha = 0; + } + + [BackgroundDependencyLoader] + 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); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + hoveredBackground.FadeOut(fade_duration, Easing.OutQuint); + base.OnHoverLost(e); + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScore.cs deleted file mode 100644 index a54770fb39..0000000000 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScore.cs +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (c) ppy Pty Ltd . 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.Shapes; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; -using osu.Game.Graphics; -using osu.Game.Online.API.Requests.Responses; -using osu.Game.Online.Leaderboards; -using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.Scoring; -using osu.Game.Rulesets.UI; -using osu.Game.Users; -using osuTK; -using osuTK.Graphics; - -namespace osu.Game.Overlays.BeatmapSet.Scores -{ - public class ScoreTableScore : Container - { - private const int fade_duration = 100; - private const int text_size = 14; - - private readonly Box hoveredBackground; - private readonly Box background; - - public ScoreTableScore(int index, APIScoreInfo score, int maxModsAmount) - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - - CornerRadius = 3; - Masking = true; - - Children = new Drawable[] - { - background = new Box - { - RelativeSizeAxes = Axes.Both, - }, - hoveredBackground = new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - }, - new ScoreRow(index, score, maxModsAmount), - }; - - if (index % 2 != 0) - background.Alpha = 0; - } - - [BackgroundDependencyLoader] - 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); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - hoveredBackground.FadeOut(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); - } - } - - private class ScoreRow : ScoreTableRow - { - public ScoreRow(int index, APIScoreInfo score, int maxModsAmount) - : base(maxModsAmount) - { - SpriteText scoreText; - SpriteText accuracy; - SpriteText hitGreat; - SpriteText hitGood; - SpriteText hitMeh; - SpriteText hitMiss; - - FillFlowContainer modsContainer; - - RankContainer.Add(new SpriteText - { - Text = $"#{index + 1}", - Font = @"Exo2.0-Bold", - TextSize = text_size, - }); - DrawableRankContainer.Add(new DrawableRank(score.Rank) - { - Size = new Vector2(30, 20), - FillMode = FillMode.Fit, - }); - ScoreContainer.Add(scoreText = new SpriteText - { - Text = $@"{score.TotalScore:N0}", - TextSize = text_size, - }); - AccuracyContainer.Add(accuracy = new SpriteText - { - Text = $@"{score.Accuracy:P2}", - TextSize = text_size, - }); - FlagContainer.Add(new DrawableFlag(score.User.Country) - { - Size = new Vector2(20, 13), - }); - PlayerContainer.Add(new ClickableScoreUsername - { - User = score.User, - }); - MaxComboContainer.Add(new SpriteText - { - Text = $@"{score.MaxCombo:N0}x", - TextSize = text_size, - }); - HitGreatContainer.Add(hitGreat = new SpriteText - { - Text = $"{score.Statistics[HitResult.Great]}", - TextSize = text_size, - }); - HitGoodContainer.Add(hitGood = new SpriteText - { - Text = $"{score.Statistics[HitResult.Good]}", - TextSize = text_size, - }); - HitMehContainer.Add(hitMeh = new SpriteText - { - Text = $"{score.Statistics[HitResult.Meh]}", - TextSize = text_size, - }); - HitMissContainer.Add(hitMiss = new SpriteText - { - Text = $"{score.Statistics[HitResult.Miss]}", - TextSize = text_size, - }); - PPContainer.Add(new SpriteText - { - Text = $@"{score.PP:N0}", - TextSize = text_size, - }); - ModsContainer.Add(modsContainer = new FillFlowContainer - { - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, - }); - - if (index == 0) - scoreText.Font = @"Exo2.0-Bold"; - - accuracy.Colour = (score.Accuracy == 1) ? Color4.GreenYellow : Color4.White; - 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; - - 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), - }); - } - } - } -} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs new file mode 100644 index 0000000000..cd1ade934a --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs @@ -0,0 +1,168 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +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.Sprites; +using osu.Game.Online.Leaderboards; +using osu.Game.Rulesets.Scoring; +using osu.Game.Rulesets.UI; +using osu.Game.Scoring; +using osu.Game.Users; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.BeatmapSet.Scores +{ + public class ScoreTableScoreRow : ScoreTableRow + { + private readonly int index; + private readonly ScoreInfo score; + + public ScoreTableScoreRow(int index, ScoreInfo score) + { + this.index = index; + this.score = score; + } + + protected override Drawable CreateIndexCell() => new OsuSpriteText + { + Text = $"#{index + 1}", + Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold) + }; + + protected override Drawable CreateRankCell() => new DrawableRank(score.Rank) + { + Size = new Vector2(30, 20), + }; + + protected override Drawable CreateScoreCell() => new OsuSpriteText + { + Text = $@"{score.TotalScore:N0}", + Font = OsuFont.GetFont(size: TEXT_SIZE, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium) + }; + + protected override Drawable CreateAccuracyCell() => new OsuSpriteText + { + Text = $@"{score.Accuracy:P2}", + Font = OsuFont.GetFont(size: TEXT_SIZE), + Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White + }; + + protected override Drawable CreatePlayerCell() => 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) }, + new ClickableScoreUsername { User = score.User } + } + }; + + protected override IEnumerable CreateStatisticsCells() + { + yield return new OsuSpriteText + { + Text = $@"{score.MaxCombo:N0}x", + Font = OsuFont.GetFont(size: TEXT_SIZE) + }; + + yield return new OsuSpriteText + { + Text = $"{score.Statistics[HitResult.Great]}", + Font = OsuFont.GetFont(size: TEXT_SIZE), + Colour = score.Statistics[HitResult.Great] == 0 ? Color4.Gray : Color4.White + }; + + yield return new OsuSpriteText + { + Text = $"{score.Statistics[HitResult.Good]}", + Font = OsuFont.GetFont(size: TEXT_SIZE), + Colour = score.Statistics[HitResult.Good] == 0 ? Color4.Gray : Color4.White + }; + + yield return new OsuSpriteText + { + Text = $"{score.Statistics[HitResult.Meh]}", + Font = OsuFont.GetFont(size: TEXT_SIZE), + Colour = score.Statistics[HitResult.Meh] == 0 ? Color4.Gray : Color4.White + }; + + yield return new OsuSpriteText + { + Text = $"{score.Statistics[HitResult.Miss]}", + Font = OsuFont.GetFont(size: TEXT_SIZE), + Colour = score.Statistics[HitResult.Miss] == 0 ? Color4.Gray : Color4.White + }; + } + + protected override Drawable CreatePpCell() => new OsuSpriteText + { + Text = $@"{score.PP:N0}", + Font = OsuFont.GetFont(size: TEXT_SIZE) + }; + + protected override Drawable CreateModsCell() => new FillFlowContainer + { + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m) + { + AutoSizeAxes = Axes.Both, + 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 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); + } + } + } +} From 7239ebf5deb6b0809e453fa8e9fcd1c1b61056a5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 27 Mar 2019 13:57:26 +0900 Subject: [PATCH 21/42] Add margin for mods --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs index 4abfb92957..8efda73270 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs @@ -80,6 +80,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Right = 20 }, Child = CreateModsCell() }; } From ab4be3b75f1ae455a18d21fc3609c96e9dbab00c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 15:20:38 +0900 Subject: [PATCH 22/42] General refactoring --- .../TestCaseBeatmapScoresContainer.cs | 1 + .../Graphics/Containers/OsuHoverContainer.cs | 4 +- .../Scores/ClickableUserContainer.cs | 29 ++++---- .../BeatmapSet/Scores/DrawableTopScore.cs | 66 ++++++++----------- .../BeatmapSet/Scores/ScoreTableScoreRow.cs | 2 +- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs index c72d12c09c..4a38f98810 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs @@ -24,6 +24,7 @@ namespace osu.Game.Tests.Visual.SongSelect { public override IReadOnlyList RequiredTypes => new[] { + typeof(DrawableTopScore), typeof(ScoresContainer), typeof(ScoreTable), typeof(ScoreTableRow), diff --git a/osu.Game/Graphics/Containers/OsuHoverContainer.cs b/osu.Game/Graphics/Containers/OsuHoverContainer.cs index 091499b7cd..880807c8b4 100644 --- a/osu.Game/Graphics/Containers/OsuHoverContainer.cs +++ b/osu.Game/Graphics/Containers/OsuHoverContainer.cs @@ -12,12 +12,12 @@ namespace osu.Game.Graphics.Containers { public class OsuHoverContainer : OsuClickableContainer { + protected const float FADE_DURATION = 500; + protected Color4 HoverColour; protected Color4 IdleColour = Color4.White; - protected const float FADE_DURATION = 500; - protected virtual IEnumerable EffectTargets => new[] { Content }; protected override bool OnHover(HoverEvent e) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs index cf1c3d7fcf..2448ae17f8 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs @@ -13,6 +13,17 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { private UserProfileOverlay profile; + protected ClickableUserContainer() + { + AutoSizeAxes = Axes.Both; + } + + [BackgroundDependencyLoader(true)] + private void load(UserProfileOverlay profile) + { + this.profile = profile; + } + private User user; public User User @@ -20,26 +31,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores get => user; set { - if (user == value) return; + if (user == value) + return; user = value; - OnUserChange(user); + OnUserChanged(user); } } - protected ClickableUserContainer() - { - AutoSizeAxes = Axes.Both; - } - - protected abstract void OnUserChange(User user); - - [BackgroundDependencyLoader(true)] - private void load(UserProfileOverlay profile) - { - this.profile = profile; - } + protected abstract void OnUserChanged(User user); protected override bool OnClick(ClickEvent e) { diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 82905d065e..e3141624b5 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -19,6 +19,7 @@ using osu.Game.Users; using osuTK; using osuTK.Graphics; using System.Collections.Generic; +using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -164,7 +165,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - TextSize = 20, }, date = new SpriteText { @@ -263,67 +263,59 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { private const float username_fade_duration = 500; - private readonly Box underscore; - private readonly Container underscoreContainer; - private readonly SpriteText text; + private readonly FillFlowContainer hoverContainer; - private Color4 hoverColour; - - public float TextSize - { - set - { - if (text.TextSize == value) - return; - - text.TextSize = value; - } - get => text.TextSize; - } + private readonly SpriteText normalText; + private readonly SpriteText hoveredText; public ClickableTopScoreUsername() { - Add(underscoreContainer = new Container + var font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold, italics: true); + + Children = new Drawable[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.X, - Height = 1, - Child = underscore = new Box + normalText = new OsuSpriteText { Font = font }, + hoverContainer = new FillFlowContainer { - RelativeSizeAxes = Axes.Both, + 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 + } + } } - }); - Add(text = new SpriteText - { - Font = @"Exo2.0-BoldItalic", - }); + }; } [BackgroundDependencyLoader] private void load(OsuColour colours) { - hoverColour = underscore.Colour = colours.Blue; - underscoreContainer.Position = new Vector2(0, TextSize / 2 - 1); + hoverContainer.Colour = colours.Blue; } - protected override void OnUserChange(User user) + protected override void OnUserChanged(User user) { - text.Text = user.Username; + normalText.Text = hoveredText.Text = user.Username; } protected override bool OnHover(HoverEvent e) { - text.FadeColour(hoverColour, username_fade_duration, Easing.OutQuint); - underscore.FadeIn(username_fade_duration, Easing.OutQuint); + hoverContainer.FadeIn(username_fade_duration, Easing.OutQuint); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - text.FadeColour(Color4.White, username_fade_duration, Easing.OutQuint); - underscore.FadeOut(username_fade_duration, Easing.OutQuint); + hoverContainer.FadeOut(username_fade_duration, Easing.OutQuint); base.OnHoverLost(e); } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs index cd1ade934a..a0c6db9a56 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs @@ -145,7 +145,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores }); } - protected override void OnUserChange(User user) + protected override void OnUserChanged(User user) { text.Text = textBold.Text = user.Username; } From 7f425059aecbc83a0f8b12873fd95f789c8c5858 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 15:41:22 +0900 Subject: [PATCH 23/42] Adjust transforms --- .../Overlays/BeatmapSet/Scores/DrawableTopScore.cs | 2 +- .../BeatmapSet/Scores/ScoreTableScoreRow.cs | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index e3141624b5..3bcb44ab94 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -261,7 +261,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private class ClickableTopScoreUsername : ClickableUserContainer { - private const float username_fade_duration = 500; + private const float username_fade_duration = 150; private readonly FillFlowContainer hoverContainer; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs index a0c6db9a56..83901cc662 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs @@ -145,22 +145,19 @@ namespace osu.Game.Overlays.BeatmapSet.Scores }); } - protected override void OnUserChanged(User user) - { - text.Text = textBold.Text = user.Username; - } + protected override void OnUserChanged(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); + textBold.Show(); + text.Hide(); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - textBold.FadeOut(fade_duration, Easing.OutQuint); - text.FadeIn(fade_duration, Easing.OutQuint); + textBold.Hide(); + text.Show(); base.OnHoverLost(e); } } From dff58ab4edb52c2faec7eb241b6b50602cd1d432 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 15:41:33 +0900 Subject: [PATCH 24/42] Initial cleanup pass of DrawableTopScore --- .../BeatmapSet/Scores/DrawableTopScore.cs | 201 +++++++----------- 1 file changed, 72 insertions(+), 129 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 3bcb44ab94..66ef2a30a3 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -43,15 +43,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly SpriteText date; private readonly DrawableRank rank; - private readonly AutoSizedInfoColumn totalScore; - private readonly AutoSizedInfoColumn accuracy; - private readonly MediumInfoColumn maxCombo; - - private readonly SmallInfoColumn hitGreat; - private readonly SmallInfoColumn hitGood; - private readonly SmallInfoColumn hitMeh; - private readonly SmallInfoColumn hitMiss; - private readonly SmallInfoColumn pp; + private readonly SpriteText totalScoreText; + private readonly SpriteText accuracyText; + private readonly SpriteText maxComboText; + private readonly SpriteText hitGreatText; + private readonly SpriteText hitGoodText; + private readonly SpriteText hitMehText; + private readonly SpriteText hitMissText; + private readonly SpriteText ppText; private readonly ModsInfoColumn modsInfo; @@ -72,17 +71,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores date.Text = $@"achieved {score.Date.Humanize()}"; rank.UpdateRank(score.Rank); - totalScore.Value = $@"{score.TotalScore:N0}"; - accuracy.Value = $@"{score.Accuracy:P2}"; - maxCombo.Value = $@"{score.MaxCombo:N0}x"; + totalScoreText.Text = $@"{score.TotalScore:N0}"; + accuracyText.Text = $@"{score.Accuracy:P2}"; + maxComboText.Text = $@"{score.MaxCombo:N0}x"; - hitGreat.Value = $"{score.Statistics[HitResult.Great]}"; - hitGood.Value = $"{score.Statistics[HitResult.Good]}"; - hitMeh.Value = $"{score.Statistics[HitResult.Meh]}"; - hitMiss.Value = $"{score.Statistics[HitResult.Miss]}"; - pp.Value = $@"{score.PP:N0}"; + hitGreatText.Text = $"{score.Statistics[HitResult.Great]}"; + hitGoodText.Text = $"{score.Statistics[HitResult.Good]}"; + hitMehText.Text = $"{score.Statistics[HitResult.Meh]}"; + hitMissText.Text = $"{score.Statistics[HitResult.Miss]}"; + ppText.Text = $@"{score.PP:N0}"; - modsInfo.ClearMods(); modsInfo.Mods = score.Mods; } } @@ -91,8 +89,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - CornerRadius = 10; + Masking = true; + CornerRadius = 10; EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, @@ -100,6 +99,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Radius = 1, Offset = new Vector2(0, 1), }; + + var smallFont = OsuFont.GetFont(size: 20); + var largeFont = OsuFont.GetFont(size: 25); + Children = new Drawable[] { background = new Box @@ -208,12 +211,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(margin, 0), Children = new Drawable[] { - hitGreat = new SmallInfoColumn("300", 20), - hitGood = new SmallInfoColumn("100", 20), - hitMeh = new SmallInfoColumn("50", 20), - hitMiss = new SmallInfoColumn("misses", 20), - pp = new SmallInfoColumn("pp", 20), - modsInfo = new ModsInfoColumn("mods"), + new InfoColumn("300", hitGreatText = new OsuSpriteText { Font = smallFont }), + new InfoColumn("100", hitGoodText = new OsuSpriteText { Font = smallFont }), + new InfoColumn("50", hitMehText = new OsuSpriteText { Font = smallFont }), + new InfoColumn("misses", hitMissText = new OsuSpriteText { Font = smallFont }), + new InfoColumn("pp", ppText = new OsuSpriteText { Font = smallFont }), + modsInfo = new ModsInfoColumn(), } }, new FillFlowContainer @@ -225,9 +228,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(margin, 0), Children = new Drawable[] { - totalScore = new AutoSizedInfoColumn("Total Score"), - accuracy = new AutoSizedInfoColumn("Accuracy"), - maxCombo = new MediumInfoColumn("Max Combo"), + new InfoColumn("total score", totalScoreText = new OsuSpriteText { Font = largeFont }), + new InfoColumn("accuracy", accuracyText = new OsuSpriteText { Font = largeFont }), + new InfoColumn("max combo", maxComboText = new OsuSpriteText { Font = largeFont }) } }, } @@ -302,10 +305,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores hoverContainer.Colour = colours.Blue; } - protected override void OnUserChanged(User user) - { - normalText.Text = hoveredText.Text = user.Username; - } + protected override void OnUserChanged(User user) => normalText.Text = hoveredText.Text = user.Username; protected override bool OnHover(HoverEvent e) { @@ -320,38 +320,32 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } } - private class DrawableInfoColumn : FillFlowContainer + private class InfoColumn : CompositeDrawable { - private const float header_text_size = 12; + private readonly Box separator; - private readonly Box line; - - protected DrawableInfoColumn(string header) + public InfoColumn(string title, Drawable content) { - AutoSizeAxes = Axes.Y; - Direction = FillDirection.Vertical; - Spacing = new Vector2(0, 2); - Children = new Drawable[] + AutoSizeAxes = Axes.Both; + + InternalChild = new FillFlowContainer { - new Container + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), + Children = new[] { - AutoSizeAxes = Axes.X, - Height = header_text_size, - Child = new SpriteText + new OsuSpriteText { - TextSize = 12, - Text = header.ToUpper(), - Font = @"Exo2.0-Black", - } - }, - new Container - { - RelativeSizeAxes = Axes.X, - Height = 2, - Child = line = new Box + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black), + Text = title.ToUpper() + }, + separator = new Box { - RelativeSizeAxes = Axes.Both, - } + RelativeSizeAxes = Axes.X, + Height = 2 + }, + content } }; } @@ -359,96 +353,45 @@ namespace osu.Game.Overlays.BeatmapSet.Scores [BackgroundDependencyLoader] private void load(OsuColour colours) { - line.Colour = colours.Gray5; + separator.Colour = colours.Gray5; } } - private class ModsInfoColumn : DrawableInfoColumn + private class ModsInfoColumn : InfoColumn { private readonly FillFlowContainer modsContainer; + public ModsInfoColumn() + : this(new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal + }) + { + } + + private ModsInfoColumn(FillFlowContainer modsContainer) + : base("mods", modsContainer) + { + this.modsContainer = modsContainer; + } + public IEnumerable Mods { set { + modsContainer.Clear(); + foreach (Mod mod in value) + { modsContainer.Add(new ModIcon(mod) { AutoSizeAxes = Axes.Both, Scale = new Vector2(0.3f), }); + } } } - - public ModsInfoColumn(string header) - : base(header) - { - AutoSizeAxes = Axes.Both; - Add(modsContainer = new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - }); - } - - public void ClearMods() => modsContainer.Clear(); - } - - private class TextInfoColumn : DrawableInfoColumn - { - private readonly SpriteText valueText; - - public string Value - { - set - { - if (valueText.Text == value) - return; - - valueText.Text = value; - } - get => valueText.Text; - } - - protected TextInfoColumn(string header, float valueTextSize = 25) - : base(header) - { - Add(valueText = new SpriteText - { - TextSize = valueTextSize, - }); - } - } - - private class AutoSizedInfoColumn : TextInfoColumn - { - public AutoSizedInfoColumn(string header, float valueTextSize = 25) - : base(header, valueTextSize) - { - AutoSizeAxes = Axes.Both; - } - } - - private class MediumInfoColumn : TextInfoColumn - { - private const float width = 70; - - public MediumInfoColumn(string header, float valueTextSize = 25) - : base(header, valueTextSize) - { - Width = width; - } - } - - private class SmallInfoColumn : TextInfoColumn - { - private const float width = 40; - - public SmallInfoColumn(string header, float valueTextSize = 25) - : base(header, valueTextSize) - { - Width = width; - } } } } From 0cf27e244d4948d9425cdfe18941800a96d5226e Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 15:44:14 +0900 Subject: [PATCH 25/42] Fix usages of SpriteText and obsolete members --- osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 66ef2a30a3..6e5104b137 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -125,13 +125,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(margin, 0), Children = new Drawable[] { - rankText = new SpriteText + rankText = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = "#1", - TextSize = 30, - Font = @"Exo2.0-BoldItalic", + Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true) }, rank = new DrawableRank(ScoreRank.F) { @@ -173,8 +172,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - TextSize = 15, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold) }, flag = new DrawableFlag { From d6b15f040a7b7cab448905b4b9d562105c8ff3c1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 15:57:36 +0900 Subject: [PATCH 26/42] Improve statistics display --- .../BeatmapSet/Scores/DrawableTopScore.cs | 78 ++++++++++++------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 6e5104b137..052eaf60e5 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -12,13 +12,15 @@ using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Online.Leaderboards; using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Scoring; using osu.Game.Users; using osuTK; using osuTK.Graphics; using System.Collections.Generic; +using System.Linq; +using osu.Framework.Extensions; +using osu.Framework.Localisation; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.BeatmapSet.Scores @@ -26,7 +28,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public class DrawableTopScore : Container { private const float fade_duration = 100; - private const float height = 100; private const float avatar_size = 80; private const float margin = 10; @@ -35,6 +36,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private Color4 backgroundIdleColour => colours.Gray3; private Color4 backgroundHoveredColour => colours.Gray4; + private readonly FontUsage smallStatisticsFont = OsuFont.GetFont(size: 20); + private readonly FontUsage largeStatisticsFont = OsuFont.GetFont(size: 25); + private readonly Box background; private readonly UpdateableAvatar avatar; private readonly DrawableFlag flag; @@ -43,14 +47,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly SpriteText date; private readonly DrawableRank rank; - private readonly SpriteText totalScoreText; - private readonly SpriteText accuracyText; - private readonly SpriteText maxComboText; - private readonly SpriteText hitGreatText; - private readonly SpriteText hitGoodText; - private readonly SpriteText hitMehText; - private readonly SpriteText hitMissText; - private readonly SpriteText ppText; + private readonly FillFlowContainer statisticsContainer; + + private readonly TextColumn totalScoreColumn; + private readonly TextColumn accuracyColumn; + private readonly TextColumn maxComboColumn; + private readonly TextColumn ppColumn; private readonly ModsInfoColumn modsInfo; @@ -71,15 +73,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores date.Text = $@"achieved {score.Date.Humanize()}"; rank.UpdateRank(score.Rank); - totalScoreText.Text = $@"{score.TotalScore:N0}"; - accuracyText.Text = $@"{score.Accuracy:P2}"; - maxComboText.Text = $@"{score.MaxCombo:N0}x"; + totalScoreColumn.Text = $@"{score.TotalScore:N0}"; + accuracyColumn.Text = $@"{score.Accuracy:P2}"; + maxComboColumn.Text = $@"{score.MaxCombo:N0}x"; + ppColumn.Text = $@"{score.PP:N0}"; - hitGreatText.Text = $"{score.Statistics[HitResult.Great]}"; - hitGoodText.Text = $"{score.Statistics[HitResult.Good]}"; - hitMehText.Text = $"{score.Statistics[HitResult.Meh]}"; - hitMissText.Text = $"{score.Statistics[HitResult.Miss]}"; - ppText.Text = $@"{score.PP:N0}"; + statisticsContainer.ChildrenEnumerable = score.Statistics.Select(kvp => new TextColumn(kvp.Key.GetDescription(), smallStatisticsFont) { Text = kvp.Value.ToString() }); modsInfo.Mods = score.Mods; } @@ -100,9 +99,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Offset = new Vector2(0, 1), }; - var smallFont = OsuFont.GetFont(size: 20); - var largeFont = OsuFont.GetFont(size: 25); - Children = new Drawable[] { background = new Box @@ -209,11 +205,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(margin, 0), Children = new Drawable[] { - new InfoColumn("300", hitGreatText = new OsuSpriteText { Font = smallFont }), - new InfoColumn("100", hitGoodText = new OsuSpriteText { Font = smallFont }), - new InfoColumn("50", hitMehText = new OsuSpriteText { Font = smallFont }), - new InfoColumn("misses", hitMissText = new OsuSpriteText { Font = smallFont }), - new InfoColumn("pp", ppText = new OsuSpriteText { Font = smallFont }), + statisticsContainer = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(margin, 0), + }, + ppColumn = new TextColumn("pp", smallStatisticsFont), modsInfo = new ModsInfoColumn(), } }, @@ -226,9 +224,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(margin, 0), Children = new Drawable[] { - new InfoColumn("total score", totalScoreText = new OsuSpriteText { Font = largeFont }), - new InfoColumn("accuracy", accuracyText = new OsuSpriteText { Font = largeFont }), - new InfoColumn("max combo", maxComboText = new OsuSpriteText { Font = largeFont }) + totalScoreColumn = new TextColumn("total score", largeStatisticsFont), + accuracyColumn = new TextColumn("accuracy", largeStatisticsFont), + maxComboColumn = new TextColumn("max combo", largeStatisticsFont) } }, } @@ -355,6 +353,28 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } } + private class TextColumn : InfoColumn + { + private readonly SpriteText text; + + public TextColumn(string title, FontUsage font) + : this(title, new OsuSpriteText { Font = font }) + { + } + + private TextColumn(string title, SpriteText text) + : base(title, text) + { + this.text = text; + } + + public LocalisedString Text + { + get => text.Text; + set => text.Text = value; + } + } + private class ModsInfoColumn : InfoColumn { private readonly FillFlowContainer modsContainer; From 2c18b6df1c21e0983bc7536d95923a41a404ea82 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 16:09:19 +0900 Subject: [PATCH 27/42] Fix score table using 300/100/50 --- .../TestCaseBeatmapScoresContainer.cs | 2 +- .../API/Requests/Responses/APILegacyScores.cs | 2 +- .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 21 ++++++----- .../BeatmapSet/Scores/ScoreTableHeaderRow.cs | 22 ++++++++---- .../BeatmapSet/Scores/ScoreTableScoreRow.cs | 35 +++++-------------- .../BeatmapSet/Scores/ScoresContainer.cs | 8 ++--- 6 files changed, 41 insertions(+), 49 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs index 4a38f98810..b30d6b1546 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.SongSelect } }; - IEnumerable scores = new[] + var scores = new List { new ScoreInfo { diff --git a/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs b/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs index 15ec5d3b13..c629caaa6f 100644 --- a/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs +++ b/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs @@ -9,6 +9,6 @@ namespace osu.Game.Online.API.Requests.Responses public class APILegacyScores { [JsonProperty(@"scores")] - public IEnumerable Scores; + public List Scores; } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 08e73da841..ada442d50e 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -48,24 +48,27 @@ namespace osu.Game.Overlays.BeatmapSet.Scores }; } - public IEnumerable Scores + public IReadOnlyList Scores { set { if (value == null || !value.Any()) return; - var content = new List { new ScoreTableHeaderRow().CreateDrawables().ToArray() }; - - int index = 0; - foreach (var s in value) - content.Add(new ScoreTableScoreRow(index++, s).CreateDrawables().ToArray()); - - scoresGrid.Content = content.ToArray(); + var content = new List + { + new ScoreTableHeaderRow(value.First()).CreateDrawables().ToArray() + }; backgroundFlow.Clear(); - for (int i = 0; i < index; i++) + + for (int i = 0; i < value.Count; i++) + { + content.Add(new ScoreTableScoreRow(i, value[i]).CreateDrawables().ToArray()); backgroundFlow.Add(new ScoreTableRowBackground(i)); + } + + scoresGrid.Content = content.ToArray(); } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs index a48716b71a..c73543eb10 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs @@ -2,15 +2,24 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Scoring; namespace osu.Game.Overlays.BeatmapSet.Scores { public class ScoreTableHeaderRow : ScoreTableRow { + private readonly ScoreInfo score; + + public ScoreTableHeaderRow(ScoreInfo score) + { + this.score = score; + } + protected override Drawable CreateIndexCell() => new CellText("rank"); protected override Drawable CreateRankCell() => new Container(); @@ -21,14 +30,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected override Drawable CreatePlayerCell() => new CellText("player"); - protected override IEnumerable CreateStatisticsCells() => new[] + protected override IEnumerable CreateStatisticsCells() { - new CellText("max combo"), - new CellText("300"), - new CellText("100"), - new CellText("50"), - new CellText("miss"), - }; + yield return new CellText("max combo"); + + foreach (var kvp in score.Statistics) + yield return new CellText(kvp.Key.GetDescription()); + } protected override Drawable CreatePpCell() => new CellText("pp"); diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs index 83901cc662..2cb16a5785 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs @@ -10,7 +10,6 @@ using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.Leaderboards; -using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Scoring; using osu.Game.Users; @@ -74,33 +73,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Font = OsuFont.GetFont(size: TEXT_SIZE) }; - yield return new OsuSpriteText + foreach (var kvp in score.Statistics) { - Text = $"{score.Statistics[HitResult.Great]}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = score.Statistics[HitResult.Great] == 0 ? Color4.Gray : Color4.White - }; - - yield return new OsuSpriteText - { - Text = $"{score.Statistics[HitResult.Good]}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = score.Statistics[HitResult.Good] == 0 ? Color4.Gray : Color4.White - }; - - yield return new OsuSpriteText - { - Text = $"{score.Statistics[HitResult.Meh]}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = score.Statistics[HitResult.Meh] == 0 ? Color4.Gray : Color4.White - }; - - yield return new OsuSpriteText - { - Text = $"{score.Statistics[HitResult.Miss]}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = score.Statistics[HitResult.Miss] == 0 ? Color4.Gray : Color4.White - }; + yield return new OsuSpriteText + { + Text = $"{kvp.Value}", + Font = OsuFont.GetFont(size: TEXT_SIZE), + Colour = kvp.Value == 0 ? Color4.Gray : Color4.White + }; + } } protected override Drawable CreatePpCell() => new OsuSpriteText diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index a29d812088..de080732f9 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -83,9 +83,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } private GetScoresRequest getScoresRequest; - private IEnumerable scores; + private IReadOnlyList scores; - public IEnumerable Scores + public IReadOnlyList Scores { get => scores; set @@ -121,11 +121,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private void updateDisplay() { - scoreTable.Scores = Enumerable.Empty(); + scoreTable.Scores = new List(); loading = false; - var scoreCount = scores?.Count() ?? 0; + var scoreCount = scores?.Count ?? 0; if (scoreCount == 0) { From e246fad301616d1b97ec20a5f21a2ef4186e731f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 16:09:34 +0900 Subject: [PATCH 28/42] Clear table if no scores are provided --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index ada442d50e..09ab0e3f6a 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -52,6 +52,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { set { + scoresGrid.Content = new Drawable[0][]; + backgroundFlow.Clear(); + if (value == null || !value.Any()) return; @@ -60,8 +63,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores new ScoreTableHeaderRow(value.First()).CreateDrawables().ToArray() }; - backgroundFlow.Clear(); - for (int i = 0; i < value.Count; i++) { content.Add(new ScoreTableScoreRow(i, value[i]).CreateDrawables().ToArray()); From 42c915190a968c340d6185ed10539ec2161b8c70 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 16:12:24 +0900 Subject: [PATCH 29/42] Reorder DrawableTopScore --- .../BeatmapSet/Scores/DrawableTopScore.cs | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 052eaf60e5..f22c6b3529 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -31,10 +31,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private const float avatar_size = 80; private const float margin = 10; - private OsuColour colours; - - private Color4 backgroundIdleColour => colours.Gray3; - private Color4 backgroundHoveredColour => colours.Gray4; + private Color4 backgroundIdleColour; + private Color4 backgroundHoveredColour; private readonly FontUsage smallStatisticsFont = OsuFont.GetFont(size: 20); private readonly FontUsage largeStatisticsFont = OsuFont.GetFont(size: 25); @@ -56,34 +54,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly ModsInfoColumn modsInfo; - private ScoreInfo score; - - public ScoreInfo Score - { - get => score; - set - { - if (score == value) - return; - - score = value; - - avatar.User = username.User = score.User; - flag.Country = score.User.Country; - date.Text = $@"achieved {score.Date.Humanize()}"; - rank.UpdateRank(score.Rank); - - totalScoreColumn.Text = $@"{score.TotalScore:N0}"; - accuracyColumn.Text = $@"{score.Accuracy:P2}"; - maxComboColumn.Text = $@"{score.MaxCombo:N0}x"; - ppColumn.Text = $@"{score.PP:N0}"; - - statisticsContainer.ChildrenEnumerable = score.Statistics.Select(kvp => new TextColumn(kvp.Key.GetDescription(), smallStatisticsFont) { Text = kvp.Value.ToString() }); - - modsInfo.Mods = score.Mods; - } - } - public DrawableTopScore() { RelativeSizeAxes = Axes.X; @@ -240,12 +210,36 @@ namespace osu.Game.Overlays.BeatmapSet.Scores [BackgroundDependencyLoader] private void load(OsuColour colours) { - this.colours = colours; - + backgroundIdleColour = colours.Gray3; + backgroundHoveredColour = colours.Gray4; rankText.Colour = colours.Yellow; + background.Colour = backgroundIdleColour; } + /// + /// Sets the score to be displayed. + /// + public ScoreInfo Score + { + set + { + avatar.User = username.User = value.User; + flag.Country = value.User.Country; + date.Text = $@"achieved {value.Date.Humanize()}"; + rank.UpdateRank(value.Rank); + + totalScoreColumn.Text = $@"{value.TotalScore:N0}"; + accuracyColumn.Text = $@"{value.Accuracy:P2}"; + maxComboColumn.Text = $@"{value.MaxCombo:N0}x"; + ppColumn.Text = $@"{value.PP:N0}"; + + statisticsContainer.ChildrenEnumerable = value.Statistics.Select(kvp => new TextColumn(kvp.Key.GetDescription(), smallStatisticsFont) { Text = kvp.Value.ToString() }); + + modsInfo.Mods = value.Mods; + } + } + protected override bool OnHover(HoverEvent e) { background.FadeColour(backgroundHoveredColour, fade_duration, Easing.OutQuint); From f8596e055ad8a4c0379666a0913add225a15c456 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 16:36:38 +0900 Subject: [PATCH 30/42] Separate into multiple files --- .../TestCaseBeatmapScoresContainer.cs | 2 + .../BeatmapSet/Scores/DrawableTopScore.cs | 329 ++---------------- .../Scores/TopScoreStatisticsSection.cs | 204 +++++++++++ .../BeatmapSet/Scores/TopScoreUserSection.cs | 181 ++++++++++ 4 files changed, 409 insertions(+), 307 deletions(-) create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs diff --git a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs index b30d6b1546..0457e1469a 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs @@ -25,6 +25,8 @@ namespace osu.Game.Tests.Visual.SongSelect public override IReadOnlyList RequiredTypes => new[] { typeof(DrawableTopScore), + typeof(TopScoreUserSection), + typeof(TopScoreStatisticsSection), typeof(ScoresContainer), typeof(ScoreTable), typeof(ScoreTableRow), diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index f22c6b3529..3667fc3f9f 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -1,58 +1,29 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using Humanizer; 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.Online.Leaderboards; -using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.UI; using osu.Game.Scoring; -using osu.Game.Users; using osuTK; using osuTK.Graphics; -using System.Collections.Generic; -using System.Linq; -using osu.Framework.Extensions; -using osu.Framework.Localisation; -using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.BeatmapSet.Scores { public class DrawableTopScore : Container { private const float fade_duration = 100; - private const float avatar_size = 80; - private const float margin = 10; private Color4 backgroundIdleColour; private Color4 backgroundHoveredColour; - private readonly FontUsage smallStatisticsFont = OsuFont.GetFont(size: 20); - private readonly FontUsage largeStatisticsFont = OsuFont.GetFont(size: 25); - private readonly Box background; - private readonly UpdateableAvatar avatar; - private readonly DrawableFlag flag; - private readonly ClickableTopScoreUsername username; - private readonly SpriteText rankText; - private readonly SpriteText date; - private readonly DrawableRank rank; - - private readonly FillFlowContainer statisticsContainer; - - private readonly TextColumn totalScoreColumn; - private readonly TextColumn accuracyColumn; - private readonly TextColumn maxComboColumn; - private readonly TextColumn ppColumn; - - private readonly ModsInfoColumn modsInfo; + private readonly TopScoreUserSection userSection; + private readonly TopScoreStatisticsSection statisticsSection; public DrawableTopScore() { @@ -79,128 +50,30 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Padding = new MarginPadding(margin), + Padding = new MarginPadding(10), Children = new Drawable[] { - new FillFlowContainer + new AutoSizingGrid { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(margin, 0), - Children = new Drawable[] - { - rankText = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Text = "#1", - Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true) - }, - rank = new DrawableRank(ScoreRank.F) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(40), - FillMode = FillMode.Fit, - }, - avatar = new UpdateableAvatar - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(avatar_size), - Masking = true, - CornerRadius = 5, - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.25f), - Offset = new Vector2(0, 2), - Radius = 1, - }, - }, - new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 3), - Children = new Drawable[] - { - username = new ClickableTopScoreUsername - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - }, - date = new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold) - }, - flag = new DrawableFlag - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Size = new Vector2(20, 13), - }, - } - } - } - }, - new Container - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Width = 0.65f, - Child = new FillFlowContainer + Content = new[] { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Spacing = new Vector2(margin), - Children = new Drawable[] + new Drawable[] { - new FillFlowContainer + userSection = new TopScoreUserSection { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(margin, 0), - Children = new Drawable[] - { - statisticsContainer = new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(margin, 0), - }, - ppColumn = new TextColumn("pp", smallStatisticsFont), - modsInfo = new ModsInfoColumn(), - } + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, }, - new FillFlowContainer + statisticsSection = new TopScoreStatisticsSection { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(margin, 0), - Children = new Drawable[] - { - totalScoreColumn = new TextColumn("total score", largeStatisticsFont), - accuracyColumn = new TextColumn("accuracy", largeStatisticsFont), - maxComboColumn = new TextColumn("max combo", largeStatisticsFont) - } - }, - } - } + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + } + }, + }, + ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, + RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, } } } @@ -212,7 +85,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { backgroundIdleColour = colours.Gray3; backgroundHoveredColour = colours.Gray4; - rankText.Colour = colours.Yellow; background.Colour = backgroundIdleColour; } @@ -224,19 +96,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { set { - avatar.User = username.User = value.User; - flag.Country = value.User.Country; - date.Text = $@"achieved {value.Date.Humanize()}"; - rank.UpdateRank(value.Rank); - - totalScoreColumn.Text = $@"{value.TotalScore:N0}"; - accuracyColumn.Text = $@"{value.Accuracy:P2}"; - maxComboColumn.Text = $@"{value.MaxCombo:N0}x"; - ppColumn.Text = $@"{value.PP:N0}"; - - statisticsContainer.ChildrenEnumerable = value.Statistics.Select(kvp => new TextColumn(kvp.Key.GetDescription(), smallStatisticsFont) { Text = kvp.Value.ToString() }); - - modsInfo.Mods = value.Mods; + userSection.Score = value; + statisticsSection.Score = value; } } @@ -252,157 +113,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores base.OnHoverLost(e); } - private class ClickableTopScoreUsername : ClickableUserContainer + private class AutoSizingGrid : GridContainer { - private const float username_fade_duration = 150; - - private readonly FillFlowContainer hoverContainer; - - private readonly SpriteText normalText; - private readonly SpriteText hoveredText; - - public ClickableTopScoreUsername() + public AutoSizingGrid() { - 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); - } - } - - private class InfoColumn : CompositeDrawable - { - private readonly Box separator; - - public InfoColumn(string title, Drawable content) - { - AutoSizeAxes = Axes.Both; - - InternalChild = new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 2), - Children = new[] - { - new OsuSpriteText - { - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black), - Text = title.ToUpper() - }, - separator = new Box - { - RelativeSizeAxes = Axes.X, - Height = 2 - }, - content - } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - separator.Colour = colours.Gray5; - } - } - - private class TextColumn : InfoColumn - { - private readonly SpriteText text; - - public TextColumn(string title, FontUsage font) - : this(title, new OsuSpriteText { Font = font }) - { - } - - private TextColumn(string title, SpriteText text) - : base(title, text) - { - this.text = text; - } - - public LocalisedString Text - { - get => text.Text; - set => text.Text = value; - } - } - - private class ModsInfoColumn : InfoColumn - { - private readonly FillFlowContainer modsContainer; - - public ModsInfoColumn() - : this(new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal - }) - { - } - - private ModsInfoColumn(FillFlowContainer modsContainer) - : base("mods", modsContainer) - { - this.modsContainer = modsContainer; - } - - public IEnumerable Mods - { - set - { - modsContainer.Clear(); - - foreach (Mod mod in value) - { - modsContainer.Add(new ModIcon(mod) - { - AutoSizeAxes = Axes.Both, - Scale = new Vector2(0.3f), - }); - } - } + AutoSizeAxes = Axes.Y; } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs new file mode 100644 index 0000000000..6761d0f710 --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs @@ -0,0 +1,204 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Scoring; +using osu.Game.Rulesets.UI; +using osu.Game.Scoring; +using osuTK; + +namespace osu.Game.Overlays.BeatmapSet.Scores +{ + public class TopScoreStatisticsSection : CompositeDrawable + { + private const float margin = 10; + + private readonly FontUsage smallFont = OsuFont.GetFont(size: 20); + private readonly FontUsage largeFont = OsuFont.GetFont(size: 25); + + private readonly TextColumn totalScoreColumn; + private readonly TextColumn accuracyColumn; + private readonly TextColumn maxComboColumn; + private readonly TextColumn ppColumn; + + private readonly FillFlowContainer statisticsColumns; + private readonly ModsInfoColumn modsColumn; + + public TopScoreStatisticsSection() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + InternalChild = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(10, 0), + Children = new Drawable[] + { + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(margin, 0), + Children = new Drawable[] + { + statisticsColumns = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(margin, 0), + }, + ppColumn = new TextColumn("pp", smallFont), + modsColumn = new ModsInfoColumn(), + } + }, + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(margin, 0), + Children = new Drawable[] + { + totalScoreColumn = new TextColumn("total score", largeFont), + accuracyColumn = new TextColumn("accuracy", largeFont), + maxComboColumn = new TextColumn("max combo", largeFont) + } + }, + } + }; + } + + /// + /// Sets the score to be displayed. + /// + public ScoreInfo Score + { + set + { + totalScoreColumn.Text = $@"{value.TotalScore:N0}"; + accuracyColumn.Text = $@"{value.Accuracy:P2}"; + maxComboColumn.Text = $@"{value.MaxCombo:N0}x"; + ppColumn.Text = $@"{value.PP:N0}"; + + statisticsColumns.ChildrenEnumerable = value.Statistics.Select(kvp => createStatisticsColumn(kvp.Key, kvp.Value)); + modsColumn.Mods = value.Mods; + } + } + + private TextColumn createStatisticsColumn(HitResult hitResult, int count) => new TextColumn(hitResult.GetDescription(), smallFont) + { + Text = count.ToString() + }; + + private class InfoColumn : CompositeDrawable + { + private readonly Box separator; + + public InfoColumn(string title, Drawable content) + { + AutoSizeAxes = Axes.Both; + + InternalChild = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), + Children = new[] + { + new OsuSpriteText + { + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black), + Text = title.ToUpper() + }, + separator = new Box + { + RelativeSizeAxes = Axes.X, + Height = 2 + }, + content + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + separator.Colour = colours.Gray5; + } + } + + private class TextColumn : InfoColumn + { + private readonly SpriteText text; + + public TextColumn(string title, FontUsage font) + : this(title, new OsuSpriteText { Font = font }) + { + } + + private TextColumn(string title, SpriteText text) + : base(title, text) + { + this.text = text; + } + + public LocalisedString Text + { + set => text.Text = value; + } + } + + private class ModsInfoColumn : InfoColumn + { + private readonly FillFlowContainer modsContainer; + + public ModsInfoColumn() + : this(new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal + }) + { + } + + private ModsInfoColumn(FillFlowContainer modsContainer) + : base("mods", modsContainer) + { + this.modsContainer = modsContainer; + } + + public IEnumerable Mods + { + set + { + modsContainer.Clear(); + + foreach (Mod mod in value) + { + modsContainer.Add(new ModIcon(mod) + { + AutoSizeAxes = Axes.Both, + Scale = new Vector2(0.3f), + }); + } + } + } + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs new file mode 100644 index 0000000000..1ec4b7197d --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -0,0 +1,181 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using Humanizer; +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.Sprites; +using osu.Game.Online.Leaderboards; +using osu.Game.Scoring; +using osu.Game.Users; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.BeatmapSet.Scores +{ + public class TopScoreUserSection : CompositeDrawable + { + private readonly SpriteText rankText; + private readonly DrawableRank rank; + private readonly UpdateableAvatar avatar; + private readonly UsernameText usernameText; + private readonly SpriteText date; + private readonly DrawableFlag flag; + + public TopScoreUserSection() + { + AutoSizeAxes = Axes.Both; + + InternalChild = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(10, 0), + Children = new Drawable[] + { + rankText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Text = "#1", + Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true) + }, + rank = new DrawableRank(ScoreRank.F) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(40), + FillMode = FillMode.Fit, + }, + avatar = new UpdateableAvatar + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(80), + Masking = true, + CornerRadius = 5, + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Offset = new Vector2(0, 2), + Radius = 1, + }, + }, + new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 3), + Children = new Drawable[] + { + usernameText = new UsernameText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, + date = new SpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold) + }, + flag = new DrawableFlag + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Size = new Vector2(20, 13), + }, + } + } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + rankText.Colour = colours.Yellow; + } + + /// + /// Sets the score to be displayed. + /// + public ScoreInfo Score + { + set + { + avatar.User = usernameText.User = value.User; + flag.Country = value.User.Country; + date.Text = $@"achieved {value.Date.Humanize()}"; + 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); + } + } + } +} From 3da008d29380dac150b4cd1d6fb629cace86700c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 16:43:56 +0900 Subject: [PATCH 31/42] Add a bit of padding between the sections --- osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 3667fc3f9f..aace49e120 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -65,6 +65,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }, + null, statisticsSection = new TopScoreStatisticsSection { Anchor = Anchor.CentreRight, @@ -72,7 +73,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } }, }, - ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, + ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.Absolute, 20) }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, } } From 3b7d26cca805330a1a98bb1f86059890204999dc Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 3 Apr 2019 17:49:01 +0900 Subject: [PATCH 32/42] Remove custom styled text --- .../Online/TestCaseBeatmapSetOverlay.cs | 1 - .../Scores/ClickableUserContainer.cs | 51 ------------- .../BeatmapSet/Scores/ScoreTableScoreRow.cs | 74 ++++++------------- .../BeatmapSet/Scores/TopScoreUserSection.cs | 73 +++--------------- 4 files changed, 31 insertions(+), 168 deletions(-) delete mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs diff --git a/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs index 19d295cf12..9cbccbd603 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs @@ -24,7 +24,6 @@ namespace osu.Game.Tests.Visual.Online public override IReadOnlyList RequiredTypes => new[] { typeof(Header), - typeof(ClickableUserContainer), typeof(ScoreTable), typeof(ScoreTableRow), typeof(ScoreTableHeaderRow), diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs deleted file mode 100644 index 2448ae17f8..0000000000 --- a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) ppy Pty Ltd . 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; - } - } -} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs index 2cb16a5785..adb79eedfa 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs @@ -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 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); - } - } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index 1ec4b7197d..f401dc93a7 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -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); - } - } } } From 5d37851d34b716d361cd67fa8bef60e81e36a399 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Apr 2019 18:14:59 +0900 Subject: [PATCH 33/42] Rename and move test to correct location --- .../TestCaseScoresContainer.cs} | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) rename osu.Game.Tests/Visual/{SongSelect/TestCaseBeatmapScoresContainer.cs => Online/TestCaseScoresContainer.cs} (96%) diff --git a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/Online/TestCaseScoresContainer.cs similarity index 96% rename from osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs rename to osu.Game.Tests/Visual/Online/TestCaseScoresContainer.cs index 0457e1469a..3d87e1743c 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseScoresContainer.cs @@ -15,19 +15,16 @@ using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Users; -using NUnit.Framework; -namespace osu.Game.Tests.Visual.SongSelect +namespace osu.Game.Tests.Visual.Online { - [Description("in BeatmapOverlay")] - public class TestCaseBeatmapScoresContainer : OsuTestCase + public class TestCaseScoresContainer : OsuTestCase { public override IReadOnlyList RequiredTypes => new[] { typeof(DrawableTopScore), typeof(TopScoreUserSection), typeof(TopScoreStatisticsSection), - typeof(ScoresContainer), typeof(ScoreTable), typeof(ScoreTableRow), typeof(ScoreTableHeaderRow), @@ -37,7 +34,7 @@ namespace osu.Game.Tests.Visual.SongSelect private readonly Box background; - public TestCaseBeatmapScoresContainer() + public TestCaseScoresContainer() { ScoresContainer scoresContainer; From 5c3c08566f4f99e6f414ae618a23739cd5a4df8e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Apr 2019 18:20:03 +0900 Subject: [PATCH 34/42] DrawableTopScore can be composite --- osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index aace49e120..d8bd15a4a9 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -14,7 +14,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class DrawableTopScore : Container + public class DrawableTopScore : CompositeDrawable { private const float fade_duration = 100; @@ -40,7 +40,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Offset = new Vector2(0, 1), }; - Children = new Drawable[] + InternalChildren = new Drawable[] { background = new Box { From a15a9bd03aa95502172ac33958c2cb36e7e5c13f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Apr 2019 18:29:46 +0900 Subject: [PATCH 35/42] Rewrite updateDisplay logic to not fail on some cases --- .../BeatmapSet/Scores/ScoresContainer.cs | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index de080732f9..ef2b14b8f0 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -121,25 +121,17 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private void updateDisplay() { - scoreTable.Scores = new List(); - loading = false; - var scoreCount = scores?.Count ?? 0; + scoreTable.Scores = scores?.Count > 1 ? scores : new List(); - if (scoreCount == 0) + if (scores.Any()) { - topScore.Hide(); - return; + topScore.Score = scores.FirstOrDefault(); + topScore.Show(); } - - topScore.Score = scores.FirstOrDefault(); - topScore.Show(); - - if (scoreCount < 2) - return; - - scoreTable.Scores = scores; + else + topScore.Hide(); } protected override void Dispose(bool isDisposing) From cb417ebd777085599a2d848e631db49b13a4c8d9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Apr 2019 18:44:19 +0900 Subject: [PATCH 36/42] Player -> User --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs | 2 +- osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs | 4 ++-- osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs index c73543eb10..f6f410a729 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs @@ -28,7 +28,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected override Drawable CreateAccuracyCell() => new CellText("accuracy"); - protected override Drawable CreatePlayerCell() => new CellText("player"); + protected override Drawable CreateUserCell() => new CellText("player"); protected override IEnumerable CreateStatisticsCells() { diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs index 8efda73270..15355512ba 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs @@ -53,7 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Origin = Anchor.CentreLeft, AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Right = 20 }, - Child = CreatePlayerCell() + Child = CreateUserCell() }; foreach (var cell in CreateStatisticsCells()) @@ -93,7 +93,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected abstract Drawable CreateAccuracyCell(); - protected abstract Drawable CreatePlayerCell(); + protected abstract Drawable CreateUserCell(); protected abstract IEnumerable CreateStatisticsCells(); diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs index adb79eedfa..75d45d0b23 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs @@ -53,7 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White }; - protected override Drawable CreatePlayerCell() + protected override Drawable CreateUserCell() { var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE)) { From 84da708d44f2db71e7a50c93b5f49961787a8c3b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Apr 2019 18:46:08 +0900 Subject: [PATCH 37/42] Fix nullref --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index ef2b14b8f0..8ef3f71fe3 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -125,7 +125,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores scoreTable.Scores = scores?.Count > 1 ? scores : new List(); - if (scores.Any()) + if (scores?.Any() == true) { topScore.Score = scores.FirstOrDefault(); topScore.Show(); From e13fffaca3dd5b520a5073234d83a99b44f10cc3 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 4 Apr 2019 16:32:04 +0900 Subject: [PATCH 38/42] Make ScoreTable use TableContainer --- .../Online/TestCaseBeatmapSetOverlay.cs | 3 - .../Visual/Online/TestCaseScoresContainer.cs | 3 - .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 184 +++++++++++++----- .../BeatmapSet/Scores/ScoreTableHeaderRow.cs | 54 ----- .../BeatmapSet/Scores/ScoreTableRow.cs | 104 ---------- .../BeatmapSet/Scores/ScoreTableScoreRow.cs | 114 ----------- 6 files changed, 136 insertions(+), 326 deletions(-) delete mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs delete mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs delete mode 100644 osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs diff --git a/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs index 9cbccbd603..8363f8be04 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs @@ -25,9 +25,6 @@ namespace osu.Game.Tests.Visual.Online { typeof(Header), typeof(ScoreTable), - typeof(ScoreTableRow), - typeof(ScoreTableHeaderRow), - typeof(ScoreTableScoreRow), typeof(ScoreTableRowBackground), typeof(DrawableTopScore), typeof(ScoresContainer), diff --git a/osu.Game.Tests/Visual/Online/TestCaseScoresContainer.cs b/osu.Game.Tests/Visual/Online/TestCaseScoresContainer.cs index 3d87e1743c..1ef4558691 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseScoresContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseScoresContainer.cs @@ -26,9 +26,6 @@ namespace osu.Game.Tests.Visual.Online typeof(TopScoreUserSection), typeof(TopScoreStatisticsSection), typeof(ScoreTable), - typeof(ScoreTableRow), - typeof(ScoreTableHeaderRow), - typeof(ScoreTableScoreRow), typeof(ScoreTableRowBackground), }; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 09ab0e3f6a..08e8dc7ecc 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -5,13 +5,26 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using System.Collections.Generic; using System.Linq; +using osu.Framework.Extensions; +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; +using osu.Game.Users; +using osuTK; +using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class ScoreTable : CompositeDrawable + public class ScoreTable : TableContainer { - private readonly ScoresGrid scoresGrid; + private const float horizontal_inset = 20; + private const float row_height = 25; + private const int text_size = 14; + private readonly FillFlowContainer backgroundFlow; public ScoreTable() @@ -19,77 +32,152 @@ namespace osu.Game.Overlays.BeatmapSet.Scores RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - InternalChildren = new Drawable[] + Padding = new MarginPadding { Horizontal = horizontal_inset }; + RowSize = new Dimension(GridSizeMode.Absolute, row_height); + + AddInternal(backgroundFlow = new FillFlowContainer { - backgroundFlow = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Top = 25 } - }, - scoresGrid = new ScoresGrid - { - ColumnDimensions = new[] - { - new Dimension(GridSizeMode.Absolute, 40), - new Dimension(GridSizeMode.Absolute, 70), - new Dimension(GridSizeMode.AutoSize), - new Dimension(GridSizeMode.AutoSize), - new Dimension(GridSizeMode.Distributed, minSize: 150), - new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 90), - new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), - new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), - new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), - new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70), - new Dimension(GridSizeMode.Distributed, minSize: 40, maxSize: 70), - new Dimension(GridSizeMode.AutoSize), - } - } - }; + RelativeSizeAxes = Axes.Both, + Depth = 1f, + Padding = new MarginPadding { Horizontal = -horizontal_inset }, + Margin = new MarginPadding { Top = row_height } + }); } public IReadOnlyList Scores { set { - scoresGrid.Content = new Drawable[0][]; + Content = null; backgroundFlow.Clear(); if (value == null || !value.Any()) return; - var content = new List - { - new ScoreTableHeaderRow(value.First()).CreateDrawables().ToArray() - }; - for (int i = 0; i < value.Count; i++) - { - content.Add(new ScoreTableScoreRow(i, value[i]).CreateDrawables().ToArray()); backgroundFlow.Add(new ScoreTableRowBackground(i)); - } - scoresGrid.Content = content.ToArray(); + Columns = createHeaders(value[0]); + Content = value.Select((s, i) => createContent(i, s)).ToArray().ToRectangular(); } } - private class ScoresGrid : GridContainer + private TableColumn[] createHeaders(ScoreInfo score) { - public ScoresGrid() + var columns = new List { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; + new TableColumn("rank", Anchor.CentreRight, new Dimension(GridSizeMode.AutoSize)), + new TableColumn("", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 70)), // grade + new TableColumn("score", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)), + new TableColumn("accuracy", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)), + new TableColumn("player", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 150)), + new TableColumn("max combo", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 90)) + }; + + foreach (var statistic in score.Statistics) + columns.Add(new TableColumn(statistic.Key.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70))); + + columns.AddRange(new[] + { + new TableColumn("pp", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 40, maxSize: 70)), + new TableColumn("mods", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)), + }); + + return columns.ToArray(); + } + + private Drawable[] createContent(int index, ScoreInfo score) + { + var content = new List + { + new OsuSpriteText + { + Text = $"#{index + 1}", + Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold) + }, + new DrawableRank(score.Rank) + { + Size = new Vector2(30, 20) + }, + new OsuSpriteText + { + Margin = new MarginPadding { Right = horizontal_inset }, + Text = $@"{score.TotalScore:N0}", + Font = OsuFont.GetFont(size: text_size, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium) + }, + new OsuSpriteText + { + Margin = new MarginPadding { Right = horizontal_inset }, + Text = $@"{score.Accuracy:P2}", + Font = OsuFont.GetFont(size: text_size), + Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White + }, + }; + + var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: text_size)) { AutoSizeAxes = Axes.Both }; + username.AddLink(score.User.Username, null, LinkAction.OpenUserProfile, score.User.Id.ToString(), "Open profile"); + + content.AddRange(new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Margin = new MarginPadding { Right = horizontal_inset }, + Spacing = new Vector2(5, 0), + Children = new Drawable[] + { + new DrawableFlag(score.User.Country) { Size = new Vector2(20, 13) }, + username + } + }, + new OsuSpriteText + { + Text = $@"{score.MaxCombo:N0}x", + Font = OsuFont.GetFont(size: text_size) + } + }); + + foreach (var kvp in score.Statistics) + { + content.Add(new OsuSpriteText + { + Text = $"{kvp.Value}", + Font = OsuFont.GetFont(size: text_size), + Colour = kvp.Value == 0 ? Color4.Gray : Color4.White + }); } - public Drawable[][] Content + content.AddRange(new Drawable[] { - get => base.Content; - set + new OsuSpriteText { - base.Content = value; + Text = $@"{score.PP:N0}", + Font = OsuFont.GetFont(size: text_size) + }, + new FillFlowContainer + { + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m) + { + AutoSizeAxes = Axes.Both, + Scale = new Vector2(0.3f) + }) + }, + }); - RowDimensions = Enumerable.Repeat(new Dimension(GridSizeMode.Absolute, 25), value.Length).ToArray(); - } + return content.ToArray(); + } + + protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? string.Empty); + + private class HeaderText : OsuSpriteText + { + public HeaderText(string text) + { + Text = text.ToUpper(); + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black); } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs deleted file mode 100644 index f6f410a729..0000000000 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using osu.Framework.Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Scoring; - -namespace osu.Game.Overlays.BeatmapSet.Scores -{ - public class ScoreTableHeaderRow : ScoreTableRow - { - private readonly ScoreInfo score; - - public ScoreTableHeaderRow(ScoreInfo score) - { - this.score = score; - } - - protected override Drawable CreateIndexCell() => new CellText("rank"); - - protected override Drawable CreateRankCell() => new Container(); - - protected override Drawable CreateScoreCell() => new CellText("score"); - - protected override Drawable CreateAccuracyCell() => new CellText("accuracy"); - - protected override Drawable CreateUserCell() => new CellText("player"); - - protected override IEnumerable CreateStatisticsCells() - { - yield return new CellText("max combo"); - - foreach (var kvp in score.Statistics) - yield return new CellText(kvp.Key.GetDescription()); - } - - protected override Drawable CreatePpCell() => new CellText("pp"); - - protected override Drawable CreateModsCell() => new CellText("mods"); - - private class CellText : OsuSpriteText - { - public CellText(string text) - { - Text = text.ToUpper(); - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black); - } - } - } -} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs deleted file mode 100644 index 15355512ba..0000000000 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRow.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; - -namespace osu.Game.Overlays.BeatmapSet.Scores -{ - public abstract class ScoreTableRow - { - protected const int TEXT_SIZE = 14; - - public IEnumerable CreateDrawables() - { - yield return new Container - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - AutoSizeAxes = Axes.Both, - Child = CreateIndexCell() - }; - - yield return new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Child = CreateRankCell() - }; - - yield return new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Right = 20 }, - Child = CreateScoreCell() - }; - - yield return new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Right = 20 }, - Child = CreateAccuracyCell() - }; - - yield return new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Right = 20 }, - Child = CreateUserCell() - }; - - foreach (var cell in CreateStatisticsCells()) - { - yield return new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Child = cell - }; - } - - yield return new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Child = CreatePpCell() - }; - - yield return new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Right = 20 }, - Child = CreateModsCell() - }; - } - - protected abstract Drawable CreateIndexCell(); - - protected abstract Drawable CreateRankCell(); - - protected abstract Drawable CreateScoreCell(); - - protected abstract Drawable CreateAccuracyCell(); - - protected abstract Drawable CreateUserCell(); - - protected abstract IEnumerable CreateStatisticsCells(); - - protected abstract Drawable CreatePpCell(); - - protected abstract Drawable CreateModsCell(); - } -} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs deleted file mode 100644 index 75d45d0b23..0000000000 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using System.Linq; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -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; -using osu.Game.Users; -using osuTK; -using osuTK.Graphics; - -namespace osu.Game.Overlays.BeatmapSet.Scores -{ - public class ScoreTableScoreRow : ScoreTableRow - { - private readonly int index; - private readonly ScoreInfo score; - - public ScoreTableScoreRow(int index, ScoreInfo score) - { - this.index = index; - this.score = score; - } - - protected override Drawable CreateIndexCell() => new OsuSpriteText - { - Text = $"#{index + 1}", - Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold) - }; - - protected override Drawable CreateRankCell() => new DrawableRank(score.Rank) - { - Size = new Vector2(30, 20), - }; - - protected override Drawable CreateScoreCell() => new OsuSpriteText - { - Text = $@"{score.TotalScore:N0}", - Font = OsuFont.GetFont(size: TEXT_SIZE, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium) - }; - - protected override Drawable CreateAccuracyCell() => new OsuSpriteText - { - Text = $@"{score.Accuracy:P2}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White - }; - - protected override Drawable CreateUserCell() - { - var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE)) - { - 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 CreateStatisticsCells() - { - yield return new OsuSpriteText - { - Text = $@"{score.MaxCombo:N0}x", - Font = OsuFont.GetFont(size: TEXT_SIZE) - }; - - foreach (var kvp in score.Statistics) - { - yield return new OsuSpriteText - { - Text = $"{kvp.Value}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = kvp.Value == 0 ? Color4.Gray : Color4.White - }; - } - } - - protected override Drawable CreatePpCell() => new OsuSpriteText - { - Text = $@"{score.PP:N0}", - Font = OsuFont.GetFont(size: TEXT_SIZE) - }; - - protected override Drawable CreateModsCell() => new FillFlowContainer - { - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, - ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m) - { - AutoSizeAxes = Axes.Both, - Scale = new Vector2(0.3f) - }) - }; - } -} From a6bf076dc7fe9c9777bf546285973df963170cae Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 4 Apr 2019 17:58:34 +0900 Subject: [PATCH 39/42] Adjust green colour --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 08e8dc7ecc..3addef854a 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using System.Collections.Generic; using System.Linq; +using osu.Framework.Allocation; using osu.Framework.Extensions; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -27,6 +28,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly FillFlowContainer backgroundFlow; + private Color4 highAccuracyColour; + public ScoreTable() { RelativeSizeAxes = Axes.X; @@ -44,6 +47,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores }); } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + highAccuracyColour = colours.GreenLight; + } + public IReadOnlyList Scores { set @@ -110,7 +119,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Margin = new MarginPadding { Right = horizontal_inset }, Text = $@"{score.Accuracy:P2}", Font = OsuFont.GetFont(size: text_size), - Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White + Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White }, }; From 15fbb6f176395ae2ef5cc76c9cfe12ba2c53f6e4 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 5 Apr 2019 14:15:36 +0900 Subject: [PATCH 40/42] Use common AddUserLink method --- osu.Game/Graphics/Containers/LinkFlowContainer.cs | 4 ++++ osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 3 +-- osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs | 3 +-- osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs | 3 +-- osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs | 5 ++--- osu.Game/Screens/Multi/Match/Components/HostInfo.cs | 4 +--- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs index dace873b92..eefbeea24c 100644 --- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs +++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics; using osu.Framework.Logging; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; +using osu.Game.Users; namespace osu.Game.Graphics.Containers { @@ -75,6 +76,9 @@ namespace osu.Game.Graphics.Containers return createLink(text, null, url, linkType, linkArgument, tooltipText); } + public IEnumerable AddUserLink(User user, Action creationParameters = null) + => createLink(AddText(user.Username, creationParameters), user.Username, null, LinkAction.OpenUserProfile, user.Id.ToString(), "View profile"); + private IEnumerable createLink(IEnumerable drawables, string text, string url = null, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null, Action action = null) { AddInternal(new DrawableLinkCompiler(drawables.OfType().ToList()) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 3addef854a..693ce958dd 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -10,7 +10,6 @@ using osu.Framework.Extensions; 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; @@ -124,7 +123,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores }; var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: text_size)) { AutoSizeAxes = Axes.Both }; - username.AddLink(score.User.Username, null, LinkAction.OpenUserProfile, score.User.Id.ToString(), "Open profile"); + username.AddUserLink(score.User); content.AddRange(new Drawable[] { diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index f401dc93a7..c0d9ecad3a 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Sprites; 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; @@ -119,7 +118,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores date.Text = $@"achieved {value.Date.Humanize()}"; usernameText.Clear(); - usernameText.AddLink(value.User.Username, null, LinkAction.OpenUserProfile, value.User.Id.ToString(), "Open profile"); + usernameText.AddUserLink(value.User); rank.UpdateRank(value.Rank); } diff --git a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs index 23771451bd..d63f2fecd2 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Online.Chat; using osuTK; namespace osu.Game.Screens.Multi.Components @@ -60,7 +59,7 @@ namespace osu.Game.Screens.Multi.Components if (beatmap != null) { beatmapAuthor.AddText("mapped by ", s => s.Colour = OsuColour.Gray(0.8f)); - beatmapAuthor.AddLink(beatmap.Metadata.Author.Username, null, LinkAction.OpenUserProfile, beatmap.Metadata.Author.Id.ToString(), "View Profile"); + beatmapAuthor.AddUserLink(beatmap.Metadata.Author); } }, true); } diff --git a/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs b/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs index 40e59de25d..51d3c93624 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; -using osu.Game.Online.Chat; using osu.Game.Users; using osuTK; @@ -95,8 +94,8 @@ namespace osu.Game.Screens.Multi.Lounge.Components if (host.NewValue != null) { hostText.AddText("hosted by "); - hostText.AddLink(host.NewValue.Username, null, LinkAction.OpenUserProfile, host.NewValue.Id.ToString(), "Open profile", - s => s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true)); + hostText.AddUserLink(host.NewValue, s => s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true)); + flagContainer.Child = new DrawableFlag(host.NewValue.Country) { RelativeSizeAxes = Axes.Both }; } }, true); diff --git a/osu.Game/Screens/Multi/Match/Components/HostInfo.cs b/osu.Game/Screens/Multi/Match/Components/HostInfo.cs index 02c8929f44..b898cd0466 100644 --- a/osu.Game/Screens/Multi/Match/Components/HostInfo.cs +++ b/osu.Game/Screens/Multi/Match/Components/HostInfo.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Online.Chat; using osu.Game.Users; using osuTK; @@ -54,8 +53,7 @@ namespace osu.Game.Screens.Multi.Match.Components { linkContainer.AddText("hosted by"); linkContainer.NewLine(); - linkContainer.AddLink(host.Username, null, LinkAction.OpenUserProfile, host.Id.ToString(), "View Profile", - s => s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true)); + linkContainer.AddUserLink(host, s => s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true)); } } } From a34a511f221e5d964772228d5feb1fb331fed543 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 Apr 2019 14:55:25 +0900 Subject: [PATCH 41/42] Update framework --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f3c648cf02..74ed9f91dd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -16,7 +16,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 7ce7329246..9fff64c61c 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + + From 0208526837180c9e19f7f297b7d5c49d0629398c Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 5 Apr 2019 18:21:54 +0900 Subject: [PATCH 42/42] Fix button system visual issue --- osu.Game/Screens/Menu/Button.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 794fc093d3..383150cbd3 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -63,6 +63,8 @@ namespace osu.Game.Screens.Menu { box = new Container { + // box needs to be always present to ensure the button is always sized correctly for flow + AlwaysPresent = true, Masking = true, MaskingSmoothness = 2, EdgeEffect = new EdgeEffectParameters