From a112b354f099655d128d8f0fe8d6d81c6ea389a7 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 4 Mar 2017 03:37:34 -0400 Subject: [PATCH 01/94] Basic implementation of score UI --- .../Tests/TestCaseLeaderboard.cs | 29 ++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Overlays/ChatOverlay.cs | 2 + .../Select/Leaderboards/Leaderboard.cs | 71 +++++ .../Leaderboards/LeaderboardScoreDisplay.cs | 271 ++++++++++++++++++ osu.Game/osu.Game.csproj | 5 + 6 files changed, 379 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs create mode 100644 osu.Game/Screens/Select/Leaderboards/Leaderboard.cs create mode 100644 osu.Game/Screens/Select/Leaderboards/LeaderboardScoreDisplay.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs b/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs new file mode 100644 index 0000000000..f699f694eb --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Framework.Screens.Testing; +using osu.Framework.Graphics; +using osu.Game.Screens.Select.Leaderboards; +using OpenTK; + +namespace osu.Desktop.VisualTests +{ + public class TestCaseLeaderboard : TestCase + { + public override string Name => @"Leaderboard"; + public override string Description => @"From song select"; + + public override void Reset() + { + base.Reset(); + + Add(new Leaderboard + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Size = new Vector2(550f, 450f), + }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 569a97e496..332630f641 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -198,6 +198,7 @@ + diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index ab5a255897..f86c0a5525 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -97,6 +97,8 @@ namespace osu.Game.Overlays if (!string.IsNullOrEmpty(postText)) { //todo: actually send to server + + careChannels.FirstOrDefault()?.AddNewMessages(new[] { new Message diff --git a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs new file mode 100644 index 0000000000..14f5c49a37 --- /dev/null +++ b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs @@ -0,0 +1,71 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using System.Collections.Generic; +using osu.Game.Modes; +using osu.Framework.Graphics.Textures; +using osu.Framework.Allocation; +using osu.Framework.MathUtils; +using System; + +namespace osu.Game.Screens.Select.Leaderboards +{ + public class Leaderboard : Container + { + private FillFlowContainer scrollFlow; + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + for (int i = 0; i < 10; i++) + { + scrollFlow.Add(new LeaderboardScoreDisplay(new LeaderboardScore + { + Avatar = textures.Get(@"Online/avatar-guest"), + Flag = textures.Get(@"Flags/__"), + Name = @"ultralaserxx", + MaxCombo = RNG.Next(0, 3000), + Accuracy = Math.Round(RNG.NextDouble(0, 100), 2), + Score = RNG.Next(0, 1000000), + Mods = new Mod[] { }, + }, i + 1)); + } + } + + public Leaderboard() + { + Children = new Drawable[] + { + new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + ScrollDraggerVisible = false, + Children = new Drawable[] + { + scrollFlow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(0f, 5f), + }, + }, + }, + }; + } + } + + public class LeaderboardScore + { + public Texture Avatar; + public Texture Flag; + public Texture Badge; + public string Name; + public int MaxCombo; + public double Accuracy; + public int Score; + public IEnumerable Mods; + } +} diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScoreDisplay.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScoreDisplay.cs new file mode 100644 index 0000000000..daab8387e1 --- /dev/null +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScoreDisplay.cs @@ -0,0 +1,271 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Select.Leaderboards +{ + public class LeaderboardScoreDisplay : Container + { + private const float height = 70; + private const float corner_radius = 5; + private const float edge_margin = 10; + private const float background_opacity = 0.25f; + private const float score_letter_size = 20f; + + private Box background; + + public readonly LeaderboardScore Score; + + protected override bool OnHover(Framework.Input.InputState state) + { + background.FadeColour(Color4.Black.Opacity(0.5f), 300, EasingTypes.OutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(Framework.Input.InputState state) + { + background.FadeColour(Color4.Black.Opacity(background_opacity), 200, EasingTypes.OutQuint); + base.OnHoverLost(state); + } + + public LeaderboardScoreDisplay(LeaderboardScore score, int index) + { + Score = score; + + RelativeSizeAxes = Axes.X; + Height = height; + + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Y, + Width = 40, + Children = new[] + { + new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Font = @"Exo2.0-MediumItalic", + TextSize = 22, + Text = index.ToString(), + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = 40, }, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + CornerRadius = corner_radius, + Masking = true, + Children = new[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(background_opacity), + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(edge_margin), + Children = new Drawable[] + { + new Container + { + Size = new Vector2(height - edge_margin * 2, height - edge_margin * 2), + CornerRadius = corner_radius, + Masking = true, + Children = new Drawable[] + { + new Sprite + { + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fill, + Texture = Score.Avatar, + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Position = new Vector2(height - edge_margin, 0f), + Children = new Drawable[] + { + new OsuSpriteText + { + Text = Score.Name, + Font = @"Exo2.0-BoldItalic", + TextSize = 23, + }, + new FillFlowContainer + { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Right, + Spacing = new Vector2(10f, 0f), + Children = new Drawable[] + { + new Container + { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Size = new Vector2(87f, 20f), + Masking = true, + Children = new Drawable[] + { + new Sprite + { + RelativeSizeAxes = Axes.Y, + Width = 30f, + Texture = Score.Flag, + }, + new Sprite + { + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, + RelativeSizeAxes = Axes.Y, + Width = 50f, + Texture = Score.Badge, + }, + }, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Right, + Spacing = new Vector2(10f, 0f), + Margin = new MarginPadding { Left = 10, }, + Children = new Drawable[] + { + new ScoreComponentLabel(FontAwesome.fa_circle_o, Score.MaxCombo.ToString()), + new ScoreComponentLabel(FontAwesome.fa_circle_o, Score.Accuracy.ToString()), + }, + }, + }, + }, + }, + }, + new Sprite + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Size = new Vector2(score_letter_size), + }, + new OsuSpriteText + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Position = new Vector2(-score_letter_size - 5f, 0f), + Font = @"Venera", + Text = Score.Score.ToString(), + TextSize = 23, + }, + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + AutoSizeAxes = Axes.Both, + // TODO: Probably remove? Seems like others don't like this kind of thing + Position = new Vector2(0f, 4f), //properly align the mod icons + Direction = FillDirection.Left, + Children = new[] + { + new ScoreModIcon(FontAwesome.fa_osu_mod_doubletime, OsuColour.FromHex(@"ffcc22")), + new ScoreModIcon(FontAwesome.fa_osu_mod_flashlight, OsuColour.FromHex(@"ffcc22")), + new ScoreModIcon(FontAwesome.fa_osu_mod_hidden, OsuColour.FromHex(@"ffcc22")), + new ScoreModIcon(FontAwesome.fa_osu_mod_hardrock, OsuColour.FromHex(@"ffcc22")), + }, + }, + }, + }, + }, + }, + }; + } + + class ScoreModIcon : Container + { + public ScoreModIcon(FontAwesome icon, Color4 colour) + { + AutoSizeAxes = Axes.Both; + + Children = new[] + { + new TextAwesome + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Icon = FontAwesome.fa_osu_mod_bg, + Colour = colour, + Shadow = true, + TextSize = 30, + }, + new TextAwesome + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Icon = icon, + Colour = OsuColour.Gray(84), + TextSize = 18, + }, + }; + } + } + + class ScoreComponentLabel : Container + { + public ScoreComponentLabel(FontAwesome icon, string value) + { + Anchor = Anchor.CentreLeft; + Origin = Anchor.CentreLeft; + Size = new Vector2(60f, 20f); + Padding = new MarginPadding { Top = 10f, }; + + Children = new Drawable[] + { + new TextAwesome + { + Icon = FontAwesome.fa_square, + Colour = OsuColour.FromHex(@"3087ac"), + Rotation = 45, + Shadow = true, + }, + new TextAwesome + { + Icon = icon, + Colour = OsuColour.FromHex(@"a4edff"), + Scale = new Vector2(0.8f), + }, + new OsuSpriteText + { + Origin = Anchor.CentreLeft, + Margin = new MarginPadding { Left = 15, }, + Font = @"Exo2.0-Bold", + Text = value, + TextSize = 17, + }, + }; + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index cf98450307..ad66e335eb 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -310,6 +310,8 @@ + + @@ -331,6 +333,9 @@ + + +