From d8724e5e3e3fe5a7ac303ca14846462be4a20824 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 24 Mar 2017 23:02:24 +0100 Subject: [PATCH 01/50] Add metadata details --- .../Tests/TestCaseDetails.cs | 31 +++++++ .../osu.Desktop.VisualTests.csproj | 5 +- osu.Game/Screens/Select/BeatmapDetailArea.cs | 29 +++++-- osu.Game/Screens/Select/Details.cs | 87 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 5 files changed, 145 insertions(+), 8 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseDetails.cs create mode 100644 osu.Game/Screens/Select/Details.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs new file mode 100644 index 0000000000..b97c61218f --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -0,0 +1,31 @@ +using osu.Framework.Graphics; +using osu.Framework.Screens.Testing; +using osu.Game.Database; +using osu.Game.Screens.Select; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Desktop.VisualTests.Tests +{ + class TestCaseDetails : TestCase + { + + public override void Reset() + { + base.Reset(); + + Add(new Details + { + RelativeSizeAxes = Axes.Both, + Metadata = new BeatmapMetadata + { + Source = "Some guy", + Tags = "beatmap metadata example with a very very long list of tags and not much creativity", + }, + }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index f1b4a99510..d94358a6a1 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -1,4 +1,4 @@ - + {69051C69-12AE-4E7D-A3E6-460D2E282312} @@ -183,6 +183,7 @@ + @@ -211,7 +212,7 @@ - + diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 21e4d643f2..c7ee57e36c 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -17,8 +18,9 @@ namespace osu.Game.Screens.Select private readonly Container content; protected override Container Content => content; - public readonly Container Details; //todo: replace with a real details view when added + public readonly Details Details; public readonly Leaderboard Leaderboard; + private BeatmapDetailTab currentTab; private APIAccess api; @@ -32,7 +34,11 @@ namespace osu.Game.Screens.Select set { beatmap = value; - if (IsLoaded) Schedule(updateScores); + if (IsLoaded) + if(currentTab == BeatmapDetailTab.Details) + Schedule(updateDetails); + else + Schedule(updateScores); } } @@ -50,15 +56,15 @@ namespace osu.Game.Screens.Select case BeatmapDetailTab.Details: Details.Show(); Leaderboard.Hide(); + updateDetails(); break; default: Details.Hide(); Leaderboard.Show(); + updateScores(); break; } - - //for now let's always update scores. - updateScores(); + currentTab = tab; }, }, content = new Container @@ -70,7 +76,7 @@ namespace osu.Game.Screens.Select Add(new Drawable[] { - Details = new Container + Details = new Details { RelativeSizeAxes = Axes.Both, }, @@ -107,5 +113,16 @@ namespace osu.Game.Screens.Select getScoresRequest.Success += r => Leaderboard.Scores = r.Scores; api.Queue(getScoresRequest); } + + + + private void updateDetails() + { + if (!IsLoaded) return; + + if (api == null || beatmap?.BeatmapInfo == null) return; + + Details.Metadata = beatmap.Beatmap.Metadata; + } } } diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs new file mode 100644 index 0000000000..7748bcd1b5 --- /dev/null +++ b/osu.Game/Screens/Select/Details.cs @@ -0,0 +1,87 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Game.Database; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Primitives; +using osu.Game.Graphics; +using OpenTK; +using osu.Framework.Allocation; + +namespace osu.Game.Screens.Select +{ + public class Details : Container + { + private FillFlowContainer metadataContainer; + private SpriteText description; + private SpriteText source; + private FillFlowContainer tags; + private BeatmapMetadata metadata; + public BeatmapMetadata Metadata + { + get + { + return metadata; + } + + set + { + if (metadata == value) return; + metadata = value; + source.Text = metadata.Source; + tags.Children = metadata.Tags.Split(' ').ToList().Select(text => new SpriteText { Text = text }); + } + } + + public Details() + { + Children = new[] + { + metadataContainer = new FillFlowContainer() + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Width = 0.4f, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new SpriteText + { + Text = "Description", + }, + description = new SpriteText(), + new SpriteText + { + Text = "Source", + Margin = new MarginPadding { Top = 20 }, + }, + source = new SpriteText(), + new SpriteText + { + Text = "Tags", + Margin = new MarginPadding { Top = 20 }, + }, + tags = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + Spacing = new Vector2(3,0), + }, + }, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + description.Colour = colour.GrayB; + source.Colour = colour.GrayB; + tags.Colour = colour.Yellow; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 989e605c16..9d7627b5f2 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -201,6 +201,7 @@ + From 775fd63d0fa6a03184d77e556f1c17416359908e Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 25 Mar 2017 23:33:03 +0100 Subject: [PATCH 02/50] Added difficulty container --- .../Tests/TestCaseDetails.cs | 23 +- osu.Game/Screens/Select/BeatmapDetailArea.cs | 5 +- osu.Game/Screens/Select/Details.cs | 239 ++++++++++++++++-- osu.Game/Screens/Select/DetailsBar.cs | 68 +++++ osu.Game/osu.Game.csproj | 1 + 5 files changed, 309 insertions(+), 27 deletions(-) create mode 100644 osu.Game/Screens/Select/DetailsBar.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs index b97c61218f..36e52717e4 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -1,4 +1,7 @@ -using osu.Framework.Graphics; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; using osu.Framework.Screens.Testing; using osu.Game.Database; using osu.Game.Screens.Select; @@ -20,10 +23,22 @@ namespace osu.Desktop.VisualTests.Tests Add(new Details { RelativeSizeAxes = Axes.Both, - Metadata = new BeatmapMetadata + Beatmap = new BeatmapInfo { - Source = "Some guy", - Tags = "beatmap metadata example with a very very long list of tags and not much creativity", + Version = "VisualTest", + Metadata = new BeatmapMetadata + { + Source = "Some guy", + Tags = "beatmap metadata example with a very very long list of tags and not much creativity", + }, + Difficulty = new BeatmapDifficulty + { + CircleSize = 7, + ApproachRate = 3.5f, + OverallDifficulty = 5.7f, + DrainRate = 1, + }, + StarDifficulty = 5.3f, }, }); } diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index c7ee57e36c..f2e5388d0c 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -79,6 +79,7 @@ namespace osu.Game.Screens.Select Details = new Details { RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(5), }, Leaderboard = new Leaderboard { @@ -121,8 +122,8 @@ namespace osu.Game.Screens.Select if (!IsLoaded) return; if (api == null || beatmap?.BeatmapInfo == null) return; - - Details.Metadata = beatmap.Beatmap.Metadata; + + Details.Beatmap = beatmap.Beatmap.BeatmapInfo; } } } diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs index 7748bcd1b5..2374d0a674 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details.cs @@ -1,46 +1,72 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics; -using osu.Game.Database; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Primitives; -using osu.Game.Graphics; using OpenTK; +using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Game.Database; +using osu.Game.Graphics; +using System.Linq; namespace osu.Game.Screens.Select { public class Details : Container { - private FillFlowContainer metadataContainer; private SpriteText description; private SpriteText source; private FillFlowContainer tags; - private BeatmapMetadata metadata; - public BeatmapMetadata Metadata + + private DifficultyRow circleSize; + private DifficultyRow drainRate; + private DifficultyRow approachRate; + private DifficultyRow overallDifficulty; + private DifficultyRow stars; + + private BeatmapInfo beatmap; + public BeatmapInfo Beatmap { get { - return metadata; + return beatmap; } set { - if (metadata == value) return; - metadata = value; - source.Text = metadata.Source; - tags.Children = metadata.Tags.Split(' ').ToList().Select(text => new SpriteText { Text = text }); + if (beatmap == value) return; + beatmap = value; + description.Text = beatmap.Version; + source.Text = beatmap.Metadata.Source; + tags.Children = beatmap.Metadata.Tags.Split(' ').Select(text => new SpriteText + { + Text = text, + TextSize = 14, + Font = "Exo2.0-Medium", + }); + + circleSize.Value = beatmap.Difficulty.CircleSize; + drainRate.Value = beatmap.Difficulty.DrainRate; + approachRate.Value = beatmap.Difficulty.ApproachRate; + overallDifficulty.Value = beatmap.Difficulty.OverallDifficulty; + stars.Value = (float) beatmap.StarDifficulty; } } public Details() { - Children = new[] + Children = new Drawable[] { - metadataContainer = new FillFlowContainer() + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.5f, + }, + new FillFlowContainer() { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -48,22 +74,39 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Y, Width = 0.4f, Direction = FillDirection.Vertical, + Padding = new MarginPadding(5), Children = new Drawable[] { new SpriteText { Text = "Description", + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + description = new SpriteText + { + TextSize = 14, + Font = @"Exo2.0-Medium", + Direction = FillDirection.Full, }, - description = new SpriteText(), new SpriteText { Text = "Source", + TextSize = 14, + Font = @"Exo2.0-Bold", Margin = new MarginPadding { Top = 20 }, }, - source = new SpriteText(), + source = new SpriteText + { + TextSize = 14, + Font = @"Exo2.0-Medium", + Direction = FillDirection.Full, + }, new SpriteText { Text = "Tags", + TextSize = 14, + Font = @"Exo2.0-Bold", Margin = new MarginPadding { Top = 20 }, }, tags = new FillFlowContainer @@ -72,7 +115,65 @@ namespace osu.Game.Screens.Select Spacing = new Vector2(3,0), }, }, - } + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Width = 0.6f, + Padding = new MarginPadding(5) { Top = 0 }, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.5f, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0,10), + Padding = new MarginPadding(7), + Children = new [] + { + circleSize = new DifficultyRow + { + DifficultyName = "Circle Size", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + MaxValue = 7, + }, + drainRate = new DifficultyRow + { + DifficultyName = "HP Drain", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }, + approachRate = new DifficultyRow + { + DifficultyName = "Accuracy", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }, + overallDifficulty = new DifficultyRow + { + DifficultyName = "Limit Break", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }, + stars = new DifficultyRow + { + DifficultyName = "Star Difficulty", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }, + }, + }, + }, + }, }; } @@ -81,7 +182,103 @@ namespace osu.Game.Screens.Select { description.Colour = colour.GrayB; source.Colour = colour.GrayB; - tags.Colour = colour.Yellow; + tags.Colour = colour.YellowLight; + stars.BarColour = colour.YellowLight; + } + + private class DifficultyRow : Container + { + private SpriteText name; + private DetailsBar bar; + private SpriteText valueText; + + private float difficultyValue; + public float Value + { + get + { + return difficultyValue; + } + set + { + difficultyValue = value; + bar.Value = value/maxValue; + valueText.Text = value.ToString(); + } + } + + private float maxValue = 10; + public float MaxValue + { + get + { + return maxValue; + } + set + { + maxValue = value; + bar.Value = Value/value; + } + } + + public string DifficultyName + { + get + { + return name.Text; + } + set + { + name.Text = value; + } + } + + public SRGBColour BarColour + { + get + { + return bar.BarColour; + } + set + { + bar.BarColour = value; + } + } + + public DifficultyRow() + { + Children = new Drawable[] + { + name = new SpriteText + { + TextSize = 14, + Font = @"Exo2.0-Medium", + }, + bar = new DetailsBar + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(1, 0.35f), + Padding = new MarginPadding { Left = 100, Right = 25 }, + }, + valueText = new SpriteText + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + TextSize = 14, + Font = @"Exo2.0-Medium", + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + name.Colour = colour.GrayB; + bar.BackgroundColour = colour.Gray7; + valueText.Colour = colour.GrayB; + } } } } diff --git a/osu.Game/Screens/Select/DetailsBar.cs b/osu.Game/Screens/Select/DetailsBar.cs new file mode 100644 index 0000000000..aabdf6809f --- /dev/null +++ b/osu.Game/Screens/Select/DetailsBar.cs @@ -0,0 +1,68 @@ +// 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.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; + +namespace osu.Game.Screens.Select +{ + class DetailsBar : Container + { + private Box background; + private Box bar; + + public float Value + { + get + { + return bar.Width; + } + set + { + bar.ResizeTo(new Vector2(value, 1), 200); + } + } + + public SRGBColour BackgroundColour + { + get + { + return background.Colour; + } + set + { + background.Colour = value; + } + } + + public SRGBColour BarColour + { + get + { + return bar.Colour; + } + set + { + bar.Colour = value; + } + } + + public DetailsBar() + { + Children = new [] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + bar = new Box + { + RelativeSizeAxes = Axes.Both, + } + }; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 9d7627b5f2..2198167c7d 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -202,6 +202,7 @@ + From 909fdb647c11b13ad24802e94bdb2361919f3c1a Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 28 Mar 2017 17:12:54 +0200 Subject: [PATCH 03/50] Added ratings and different bar rotations --- .../Tests/TestCaseDetails.cs | 4 + .../osu.Desktop.VisualTests.csproj | 2 +- osu.Game/Screens/Select/BeatmapDetailArea.cs | 1 + osu.Game/Screens/Select/Details.cs | 205 ++++++++++++++---- osu.Game/Screens/Select/DetailsBar.cs | 63 +++++- 5 files changed, 231 insertions(+), 44 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs index 36e52717e4..d0d7602831 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -40,6 +40,10 @@ namespace osu.Desktop.VisualTests.Tests }, StarDifficulty = 5.3f, }, + Ratings = new[] + { + 1,2,3,4,5,6,7,8,9,10 + } }); } } diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index d94358a6a1..19b679dc1c 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -212,7 +212,7 @@ - + diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index f2e5388d0c..337ad04e7d 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -124,6 +124,7 @@ namespace osu.Game.Screens.Select if (api == null || beatmap?.BeatmapInfo == null) return; Details.Beatmap = beatmap.Beatmap.BeatmapInfo; + } } } diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs index 2374d0a674..54f3d5b519 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Database; using osu.Game.Graphics; +using System.Collections.Generic; using System.Linq; namespace osu.Game.Screens.Select @@ -23,10 +24,15 @@ namespace osu.Game.Screens.Select private DifficultyRow circleSize; private DifficultyRow drainRate; - private DifficultyRow approachRate; private DifficultyRow overallDifficulty; + private DifficultyRow approachRate; private DifficultyRow stars; + private DetailsBar ratingsBar; + private SpriteText negativeRatings; + private SpriteText positiveRatings; + private FillFlowContainer ratingsGraph; + private BeatmapInfo beatmap; public BeatmapInfo Beatmap { @@ -50,12 +56,43 @@ namespace osu.Game.Screens.Select circleSize.Value = beatmap.Difficulty.CircleSize; drainRate.Value = beatmap.Difficulty.DrainRate; - approachRate.Value = beatmap.Difficulty.ApproachRate; overallDifficulty.Value = beatmap.Difficulty.OverallDifficulty; + approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float) beatmap.StarDifficulty; } } + private List ratings; + public IEnumerable Ratings + { + get + { + return ratings; + } + set + { + ratings = value.ToList(); + negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); + positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); + ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); + + List ratingsGraphBars = ratingsGraph.Children.ToList(); + for (int i = 0; i < 10; i++) + if(ratingsGraphBars.Count > i) + ratingsGraphBars[i].Length = (float)ratings[i] / ratings.Max(); + else + ratingsGraph.Add(new DetailsBar + { + RelativeSizeAxes = Axes.Both, + Width = 0.1f, + Length = (float)ratings[i] / ratings.Max(), + Direction = BarDirection.BottomToTop, + BackgroundColour = new Color4(0, 0, 0, 0), + }); + } + } + + public Details() { Children = new Drawable[] @@ -74,7 +111,7 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Y, Width = 0.4f, Direction = FillDirection.Vertical, - Padding = new MarginPadding(5), + Padding = new MarginPadding(10) { Top = 25 }, Children = new Drawable[] { new SpriteText @@ -116,59 +153,143 @@ namespace osu.Game.Screens.Select }, }, }, - new Container + new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Width = 0.6f, - Padding = new MarginPadding(5) { Top = 0 }, - Children = new Drawable[] + Direction = FillDirection.Vertical, + Spacing = new Vector2(0,15), + Padding = new MarginPadding(10) { Top = 0 }, + Children = new [] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = 0.5f, - }, - new FillFlowContainer + new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0,10), - Padding = new MarginPadding(7), - Children = new [] + Children = new Drawable[] { - circleSize = new DifficultyRow + new Box { - DifficultyName = "Circle Size", - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - MaxValue = 7, + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.5f, }, - drainRate = new DifficultyRow + new FillFlowContainer { - DifficultyName = "HP Drain", - AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0,10), + Padding = new MarginPadding(15) { Top = 25 }, + Children = new [] + { + circleSize = new DifficultyRow + { + DifficultyName = "Circle Size", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + MaxValue = 7, + }, + drainRate = new DifficultyRow + { + DifficultyName = "HP Drain", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }, + overallDifficulty = new DifficultyRow + { + DifficultyName = "Accuracy", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }, + approachRate = new DifficultyRow + { + DifficultyName = "Approach Rate", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }, + stars = new DifficultyRow + { + DifficultyName = "Star Difficulty", + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }, + }, }, - approachRate = new DifficultyRow + }, + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new Box { - DifficultyName = "Accuracy", - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.5f, }, - overallDifficulty = new DifficultyRow + new FillFlowContainer { - DifficultyName = "Limit Break", - AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - }, - stars = new DifficultyRow - { - DifficultyName = "Star Difficulty", AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Padding = new MarginPadding(15) { Top = 25, Bottom = 0 }, + Children = new Drawable[] + { + new SpriteText + { + Text = "User Rating", + TextSize = 14, + Font = @"Exo2.0-Medium", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }, + ratingsBar = new DetailsBar + { + RelativeSizeAxes = Axes.X, + Height = 5, + Length = 0, + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new[] + { + negativeRatings = new SpriteText + { + TextSize = 14, + Font = @"Exo2.0-Medium", + Text = "0", + }, + positiveRatings = new SpriteText + { + TextSize = 14, + Font = @"Exo2.0-Medium", + Text = "0", + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }, + }, + }, + new SpriteText + { + Text = "Rating Spread", + TextSize = 14, + Font = @"Exo2.0-Medium", + Anchor = Anchor.BottomCentre, + Origin = Anchor.TopCentre, + }, + ratingsGraph = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Height = 50, + } + }, }, }, }, @@ -183,7 +304,13 @@ namespace osu.Game.Screens.Select description.Colour = colour.GrayB; source.Colour = colour.GrayB; tags.Colour = colour.YellowLight; + stars.BarColour = colour.YellowLight; + + ratingsBar.BackgroundColour = colour.Green; + ratingsBar.BarColour = colour.YellowDark; + + ratingsGraph.Colour = colour.BlueDark; } private class DifficultyRow : Container @@ -202,7 +329,7 @@ namespace osu.Game.Screens.Select set { difficultyValue = value; - bar.Value = value/maxValue; + bar.Length = value/maxValue; valueText.Text = value.ToString(); } } @@ -217,7 +344,7 @@ namespace osu.Game.Screens.Select set { maxValue = value; - bar.Value = Value/value; + bar.Length = Value/value; } } diff --git a/osu.Game/Screens/Select/DetailsBar.cs b/osu.Game/Screens/Select/DetailsBar.cs index aabdf6809f..650d690a78 100644 --- a/osu.Game/Screens/Select/DetailsBar.cs +++ b/osu.Game/Screens/Select/DetailsBar.cs @@ -9,20 +9,24 @@ using osu.Framework.Graphics.Sprites; namespace osu.Game.Screens.Select { - class DetailsBar : Container + public class DetailsBar : Container { private Box background; private Box bar; - public float Value + private const int resizeDuration = 250; + + private float length; + public float Length { get { - return bar.Width; + return length; } set { - bar.ResizeTo(new Vector2(value, 1), 200); + length = value; + updateBarLength(); } } @@ -50,6 +54,20 @@ namespace osu.Game.Screens.Select } } + private BarDirection direction = BarDirection.LeftToRight; + public BarDirection Direction + { + get + { + return direction; + } + set + { + direction = value; + updateBarLength(); + } + } + public DetailsBar() { Children = new [] @@ -64,5 +82,42 @@ namespace osu.Game.Screens.Select } }; } + + private void updateBarLength() + { + switch (direction) + { + case BarDirection.LeftToRight: + case BarDirection.RightToLeft: + bar.ResizeTo(new Vector2(length, 1), resizeDuration); + break; + case BarDirection.TopToBottom: + case BarDirection.BottomToTop: + bar.ResizeTo(new Vector2(1, length), resizeDuration); + break; + } + + switch (direction) + { + case BarDirection.LeftToRight: + case BarDirection.TopToBottom: + bar.Anchor = Anchor.TopLeft; + bar.Origin = Anchor.TopLeft; + break; + case BarDirection.RightToLeft: + case BarDirection.BottomToTop: + bar.Anchor = Anchor.BottomRight; + bar.Origin = Anchor.BottomRight; + break; + } + } + } + + public enum BarDirection + { + LeftToRight, + RightToLeft, + TopToBottom, + BottomToTop, } } From 199c70ff95bed34a9140452ad42fe124ca6b58dd Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 28 Mar 2017 20:18:56 +0200 Subject: [PATCH 04/50] Added fails and retries --- .../Tests/TestCaseDetails.cs | 13 +- osu.Game/Screens/Select/Details.cs | 143 +++++++++++++++++- osu.Game/Screens/Select/DetailsBar.cs | 7 +- 3 files changed, 150 insertions(+), 13 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs index d0d7602831..3f50f4aaed 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; using osu.Framework.Screens.Testing; using osu.Game.Database; using osu.Game.Screens.Select; @@ -20,9 +21,11 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Add(new Details + Details details; + Add(details = new Details { RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(150), Beatmap = new BeatmapInfo { Version = "VisualTest", @@ -40,11 +43,11 @@ namespace osu.Desktop.VisualTests.Tests }, StarDifficulty = 5.3f, }, - Ratings = new[] - { - 1,2,3,4,5,6,7,8,9,10 - } }); + + details.Ratings = Enumerable.Range(1, 10); + details.Fails = Enumerable.Range(1, 100).Select(i => (int)(Math.Cos(i) * 100)); + details.Retries = Enumerable.Range(1, 100).Select(i => (int)(Math.Sin(i) * 100)); } } } diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs index 54f3d5b519..e99d218445 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details.cs @@ -13,6 +13,7 @@ using osu.Game.Database; using osu.Game.Graphics; using System.Collections.Generic; using System.Linq; +using System; namespace osu.Game.Screens.Select { @@ -33,6 +34,8 @@ namespace osu.Game.Screens.Select private SpriteText positiveRatings; private FillFlowContainer ratingsGraph; + private FillFlowContainer retryAndFailGraph; + private BeatmapInfo beatmap; public BeatmapInfo Beatmap { @@ -91,7 +94,53 @@ namespace osu.Game.Screens.Select }); } } - + + private List retries = Enumerable.Repeat(0,100).ToList(); + public IEnumerable Retries + { + get + { + return retries; + } + set + { + retries = value.ToList(); + calcRetryAndFailBarLength(); + } + } + + private List fails = Enumerable.Repeat(0,100).ToList(); + public IEnumerable Fails + { + get + { + return fails; + } + set + { + fails = value.ToList(); + calcRetryAndFailBarLength(); + } + } + + private void calcRetryAndFailBarLength() + { + List retryAndFailGraphBars = retryAndFailGraph.Children.ToList(); + for (int i = 0; i < 100; i++) + if (retryAndFailGraphBars.Count > i) + { + retryAndFailGraphBars[i].FailLength = (float)fails[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)); + retryAndFailGraphBars[i].RetryLength = (float)retries[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)); + } + else + retryAndFailGraph.Add(new RetryAndFailBar + { + RelativeSizeAxes = Axes.Both, + Width = 0.01f, + FailLength = (float)fails[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)), + RetryLength = (float)retries[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)), + }); + } public Details() { @@ -280,7 +329,7 @@ namespace osu.Game.Screens.Select Text = "Rating Spread", TextSize = 14, Font = @"Exo2.0-Medium", - Anchor = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, ratingsGraph = new FillFlowContainer @@ -288,13 +337,40 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.X, Direction = FillDirection.Horizontal, Height = 50, - } + }, }, }, }, }, }, }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Left = 10, Right = 10 }, + Children = new Drawable[] + { + retryAndFailGraph = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Height = 50, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }, + new SpriteText + { + Text = "Points of Failure", + TextSize = 14, + Font = @"Exo2.0-Medium", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }, + }, + }, }; } @@ -305,11 +381,10 @@ namespace osu.Game.Screens.Select source.Colour = colour.GrayB; tags.Colour = colour.YellowLight; - stars.BarColour = colour.YellowLight; + stars.BarColour = colour.Yellow; ratingsBar.BackgroundColour = colour.Green; ratingsBar.BarColour = colour.YellowDark; - ratingsGraph.Colour = colour.BlueDark; } @@ -407,5 +482,63 @@ namespace osu.Game.Screens.Select valueText.Colour = colour.GrayB; } } + + private class RetryAndFailBar : Container + { + private DetailsBar retryBar; + private DetailsBar failBar; + + public float RetryLength + { + get + { + return retryBar.Length; + } + set + { + retryBar.Length = value + FailLength; + } + } + + public float FailLength + { + get + { + return failBar.Length; + } + set + { + failBar.Length = value; + } + } + + public RetryAndFailBar() + { + Children = new[] + { + retryBar = new DetailsBar + { + RelativeSizeAxes = Axes.Both, + Direction = BarDirection.BottomToTop, + Length = 0, + BackgroundColour = new Color4(0,0,0,0), + }, + failBar = new DetailsBar + { + RelativeSizeAxes = Axes.Both, + Direction = BarDirection.BottomToTop, + Length = 0, + BackgroundColour = new Color4(0,0,0,0), + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + retryBar.Colour = colour.Yellow; + failBar.Colour = colour.YellowDarker; + } + } } } diff --git a/osu.Game/Screens/Select/DetailsBar.cs b/osu.Game/Screens/Select/DetailsBar.cs index 650d690a78..daefcc9a54 100644 --- a/osu.Game/Screens/Select/DetailsBar.cs +++ b/osu.Game/Screens/Select/DetailsBar.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using System; namespace osu.Game.Screens.Select { @@ -14,7 +15,7 @@ namespace osu.Game.Screens.Select private Box background; private Box bar; - private const int resizeDuration = 250; + private const int resize_duration = 250; private float length; public float Length @@ -89,11 +90,11 @@ namespace osu.Game.Screens.Select { case BarDirection.LeftToRight: case BarDirection.RightToLeft: - bar.ResizeTo(new Vector2(length, 1), resizeDuration); + bar.ResizeTo(new Vector2(length, 1), resize_duration); break; case BarDirection.TopToBottom: case BarDirection.BottomToTop: - bar.ResizeTo(new Vector2(1, length), resizeDuration); + bar.ResizeTo(new Vector2(1, length), resize_duration); break; } From 7bd13d76a82c22a2d0e493de6eac679959245e46 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 29 Mar 2017 14:48:43 +0200 Subject: [PATCH 05/50] fixes + updates to DetailsBar and a button for the TestCaseDetails --- osu.Desktop.VisualTests/Tests/TestCaseDetails.cs | 13 ++++++++++++- osu.Game/Screens/Select/Details.cs | 2 +- osu.Game/Screens/Select/DetailsBar.cs | 10 ++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs index 3f50f4aaed..2d22009f21 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -16,12 +16,12 @@ namespace osu.Desktop.VisualTests.Tests { class TestCaseDetails : TestCase { + private Details details; public override void Reset() { base.Reset(); - Details details; Add(details = new Details { RelativeSizeAxes = Axes.Both, @@ -48,6 +48,17 @@ namespace osu.Desktop.VisualTests.Tests details.Ratings = Enumerable.Range(1, 10); details.Fails = Enumerable.Range(1, 100).Select(i => (int)(Math.Cos(i) * 100)); details.Retries = Enumerable.Range(1, 100).Select(i => (int)(Math.Sin(i) * 100)); + + AddButton("new retry/fail values", newRetryAndFailValues); + } + + private int lastRange = 1; + + private void newRetryAndFailValues() + { + lastRange += 100; + details.Fails = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Cos(i) * 100)); + details.Retries = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Sin(i) * 100)); } } } diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs index e99d218445..c50cae0f4f 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details.cs @@ -50,7 +50,7 @@ namespace osu.Game.Screens.Select beatmap = value; description.Text = beatmap.Version; source.Text = beatmap.Metadata.Source; - tags.Children = beatmap.Metadata.Tags.Split(' ').Select(text => new SpriteText + tags.Children = beatmap.Metadata.Tags?.Split(' ').Select(text => new SpriteText { Text = text, TextSize = 14, diff --git a/osu.Game/Screens/Select/DetailsBar.cs b/osu.Game/Screens/Select/DetailsBar.cs index daefcc9a54..b48b618fad 100644 --- a/osu.Game/Screens/Select/DetailsBar.cs +++ b/osu.Game/Screens/Select/DetailsBar.cs @@ -6,7 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using System; +using osu.Framework.Graphics.Transforms; namespace osu.Game.Screens.Select { @@ -17,6 +17,8 @@ namespace osu.Game.Screens.Select private const int resize_duration = 250; + private const EasingTypes easing = EasingTypes.InOutCubic; + private float length; public float Length { @@ -26,7 +28,7 @@ namespace osu.Game.Screens.Select } set { - length = value; + length = MathHelper.Clamp(value,0,1); updateBarLength(); } } @@ -90,11 +92,11 @@ namespace osu.Game.Screens.Select { case BarDirection.LeftToRight: case BarDirection.RightToLeft: - bar.ResizeTo(new Vector2(length, 1), resize_duration); + bar.ResizeTo(new Vector2(length, 1), resize_duration, easing); break; case BarDirection.TopToBottom: case BarDirection.BottomToTop: - bar.ResizeTo(new Vector2(1, length), resize_duration); + bar.ResizeTo(new Vector2(1, length), resize_duration, easing); break; } From ab4d1c772574d301398a7c5721d1468147a08e36 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 29 Mar 2017 15:33:36 +0200 Subject: [PATCH 06/50] better maxValue calculation for the retry and fail graph --- osu.Game/Screens/Select/Details.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs index c50cae0f4f..9ea474020b 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details.cs @@ -13,7 +13,6 @@ using osu.Game.Database; using osu.Game.Graphics; using System.Collections.Generic; using System.Linq; -using System; namespace osu.Game.Screens.Select { @@ -126,19 +125,20 @@ namespace osu.Game.Screens.Select private void calcRetryAndFailBarLength() { List retryAndFailGraphBars = retryAndFailGraph.Children.ToList(); + float maxValue = fails.Select((value, index) => value + retries[index]).Max(); for (int i = 0; i < 100; i++) if (retryAndFailGraphBars.Count > i) { - retryAndFailGraphBars[i].FailLength = (float)fails[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)); - retryAndFailGraphBars[i].RetryLength = (float)retries[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)); + retryAndFailGraphBars[i].FailLength = fails[i] / maxValue; + retryAndFailGraphBars[i].RetryLength = retries[i] / maxValue; } else retryAndFailGraph.Add(new RetryAndFailBar { RelativeSizeAxes = Axes.Both, Width = 0.01f, - FailLength = (float)fails[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)), - RetryLength = (float)retries[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)), + FailLength = fails[i] / maxValue, + RetryLength = retries[i] / maxValue, }); } From 2f15653d463cf565faf86391eccc4b65c54433b4 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 29 Mar 2017 15:37:51 +0200 Subject: [PATCH 07/50] removed duplicate code --- osu.Desktop.VisualTests/Tests/TestCaseDetails.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs index 2d22009f21..0e281fdef5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -46,8 +46,7 @@ namespace osu.Desktop.VisualTests.Tests }); details.Ratings = Enumerable.Range(1, 10); - details.Fails = Enumerable.Range(1, 100).Select(i => (int)(Math.Cos(i) * 100)); - details.Retries = Enumerable.Range(1, 100).Select(i => (int)(Math.Sin(i) * 100)); + newRetryAndFailValues(); AddButton("new retry/fail values", newRetryAndFailValues); } @@ -56,9 +55,9 @@ namespace osu.Desktop.VisualTests.Tests private void newRetryAndFailValues() { - lastRange += 100; details.Fails = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Cos(i) * 100)); details.Retries = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Sin(i) * 100)); + lastRange += 100; } } } From 866f72e653b4e4fbcf8e3a58b7087395bb70a9d8 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 29 Mar 2017 15:51:54 +0200 Subject: [PATCH 08/50] fix something the merge broke --- osu.Desktop.VisualTests/Tests/TestCaseDetails.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs index 0e281fdef5..0335e80e3a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -3,7 +3,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; -using osu.Framework.Screens.Testing; +using osu.Framework.Testing; using osu.Game.Database; using osu.Game.Screens.Select; using System; From cdb3150c560ab6d82badfacb8a8f6657f3ce8362 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 29 Mar 2017 16:00:29 +0200 Subject: [PATCH 09/50] add readonlies and remove unused using directives --- .../Tests/TestCaseDetails.cs | 5 +-- osu.Game/Screens/Select/BeatmapDetailArea.cs | 1 - osu.Game/Screens/Select/Details.cs | 36 +++++++++---------- osu.Game/Screens/Select/DetailsBar.cs | 5 ++- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs index 0335e80e3a..3bfc0b147b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -7,14 +7,11 @@ using osu.Framework.Testing; using osu.Game.Database; using osu.Game.Screens.Select; using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Desktop.VisualTests.Tests { - class TestCaseDetails : TestCase + internal class TestCaseDetails : TestCase { private Details details; diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 337ad04e7d..355b2958e7 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs index 9ea474020b..1145e13338 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details.cs @@ -18,22 +18,22 @@ namespace osu.Game.Screens.Select { public class Details : Container { - private SpriteText description; - private SpriteText source; - private FillFlowContainer tags; + private readonly SpriteText description; + private readonly SpriteText source; + private readonly FillFlowContainer tags; - private DifficultyRow circleSize; - private DifficultyRow drainRate; - private DifficultyRow overallDifficulty; - private DifficultyRow approachRate; - private DifficultyRow stars; + private readonly DifficultyRow circleSize; + private readonly DifficultyRow drainRate; + private readonly DifficultyRow overallDifficulty; + private readonly DifficultyRow approachRate; + private readonly DifficultyRow stars; - private DetailsBar ratingsBar; - private SpriteText negativeRatings; - private SpriteText positiveRatings; - private FillFlowContainer ratingsGraph; + private readonly DetailsBar ratingsBar; + private readonly SpriteText negativeRatings; + private readonly SpriteText positiveRatings; + private readonly FillFlowContainer ratingsGraph; - private FillFlowContainer retryAndFailGraph; + private readonly FillFlowContainer retryAndFailGraph; private BeatmapInfo beatmap; public BeatmapInfo Beatmap @@ -390,9 +390,9 @@ namespace osu.Game.Screens.Select private class DifficultyRow : Container { - private SpriteText name; - private DetailsBar bar; - private SpriteText valueText; + private readonly SpriteText name; + private readonly DetailsBar bar; + private readonly SpriteText valueText; private float difficultyValue; public float Value @@ -485,8 +485,8 @@ namespace osu.Game.Screens.Select private class RetryAndFailBar : Container { - private DetailsBar retryBar; - private DetailsBar failBar; + private readonly DetailsBar retryBar; + private readonly DetailsBar failBar; public float RetryLength { diff --git a/osu.Game/Screens/Select/DetailsBar.cs b/osu.Game/Screens/Select/DetailsBar.cs index b48b618fad..a7193cb822 100644 --- a/osu.Game/Screens/Select/DetailsBar.cs +++ b/osu.Game/Screens/Select/DetailsBar.cs @@ -6,14 +6,13 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; namespace osu.Game.Screens.Select { public class DetailsBar : Container { - private Box background; - private Box bar; + private readonly Box background; + private readonly Box bar; private const int resize_duration = 250; From a3430dd072a0ba38f43c488bdbe60c655102158b Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 29 Mar 2017 16:10:07 +0200 Subject: [PATCH 10/50] add culture info --- osu.Game/Screens/Select/Details.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs index 1145e13338..38709057bb 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details.cs @@ -12,6 +12,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Database; using osu.Game.Graphics; using System.Collections.Generic; +using System.Globalization; using System.Linq; namespace osu.Game.Screens.Select @@ -405,7 +406,7 @@ namespace osu.Game.Screens.Select { difficultyValue = value; bar.Length = value/maxValue; - valueText.Text = value.ToString(); + valueText.Text = value.ToString(CultureInfo.InvariantCulture); } } From 0d4f2c59a536b40192679524b78142d7c03ac651 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 30 Mar 2017 17:32:18 +0200 Subject: [PATCH 11/50] there's probably something in here I overlooked --- ...seDetails.cs => TestCaseBeatmapDetails.cs} | 9 +- .../osu.Desktop.VisualTests.csproj | 4 +- osu.Game/Screens/Select/BeatmapDetailArea.cs | 5 +- .../{Details.cs => Details/BeatmapDetails.cs} | 112 +++++++----------- .../BeatmapDetailsBar.cs} | 6 +- .../Select/Details/BeatmapDetailsGraph.cs | 38 ++++++ osu.Game/osu.Game.csproj | 5 +- 7 files changed, 98 insertions(+), 81 deletions(-) rename osu.Desktop.VisualTests/Tests/{TestCaseDetails.cs => TestCaseBeatmapDetails.cs} (84%) rename osu.Game/Screens/Select/{Details.cs => Details/BeatmapDetails.cs} (82%) rename osu.Game/Screens/Select/{DetailsBar.cs => Details/BeatmapDetailsBar.cs} (92%) create mode 100644 osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs similarity index 84% rename from osu.Desktop.VisualTests/Tests/TestCaseDetails.cs rename to osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 3bfc0b147b..dfd40e7d15 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -6,20 +6,23 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Testing; using osu.Game.Database; using osu.Game.Screens.Select; +using osu.Game.Screens.Select.Details; using System; using System.Linq; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseDetails : TestCase + internal class TestCaseBeatmapDetails : TestCase { - private Details details; + public override string Description => "BeatmapDetails tab of BeatmapDetailArea"; + + private BeatmapDetails details; public override void Reset() { base.Reset(); - Add(details = new Details + Add(details = new BeatmapDetails { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding(150), diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index e74ac8b166..aff1b2437f 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -1,4 +1,4 @@ - + {69051C69-12AE-4E7D-A3E6-460D2E282312} @@ -187,7 +187,7 @@ - + diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 355b2958e7..d7a104b364 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Primitives; using osu.Game.Beatmaps; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Screens.Select.Details; using osu.Game.Screens.Select.Leaderboards; namespace osu.Game.Screens.Select @@ -17,7 +18,7 @@ namespace osu.Game.Screens.Select private readonly Container content; protected override Container Content => content; - public readonly Details Details; + public readonly BeatmapDetails Details; public readonly Leaderboard Leaderboard; private BeatmapDetailTab currentTab; @@ -75,7 +76,7 @@ namespace osu.Game.Screens.Select Add(new Drawable[] { - Details = new Details + Details = new BeatmapDetails { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding(5), diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details/BeatmapDetails.cs similarity index 82% rename from osu.Game/Screens/Select/Details.cs rename to osu.Game/Screens/Select/Details/BeatmapDetails.cs index 38709057bb..8802d213b8 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details/BeatmapDetails.cs @@ -15,9 +15,9 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; -namespace osu.Game.Screens.Select +namespace osu.Game.Screens.Select.Details { - public class Details : Container + public class BeatmapDetails : Container { private readonly SpriteText description; private readonly SpriteText source; @@ -29,12 +29,13 @@ namespace osu.Game.Screens.Select private readonly DifficultyRow approachRate; private readonly DifficultyRow stars; - private readonly DetailsBar ratingsBar; + private readonly BeatmapDetailsBar ratingsBar; private readonly SpriteText negativeRatings; private readonly SpriteText positiveRatings; - private readonly FillFlowContainer ratingsGraph; + private readonly BeatmapDetailsGraph ratingsGraph; - private readonly FillFlowContainer retryAndFailGraph; + private readonly BeatmapDetailsGraph retryGraph; + private readonly BeatmapDetailsGraph failGraph; private BeatmapInfo beatmap; public BeatmapInfo Beatmap @@ -79,19 +80,7 @@ namespace osu.Game.Screens.Select positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); - List ratingsGraphBars = ratingsGraph.Children.ToList(); - for (int i = 0; i < 10; i++) - if(ratingsGraphBars.Count > i) - ratingsGraphBars[i].Length = (float)ratings[i] / ratings.Max(); - else - ratingsGraph.Add(new DetailsBar - { - RelativeSizeAxes = Axes.Both, - Width = 0.1f, - Length = (float)ratings[i] / ratings.Max(), - Direction = BarDirection.BottomToTop, - BackgroundColour = new Color4(0, 0, 0, 0), - }); + ratingsGraph.Values = ratings.Select(rating => (float)rating / ratings.Max()); } } @@ -105,7 +94,7 @@ namespace osu.Game.Screens.Select set { retries = value.ToList(); - calcRetryAndFailBarLength(); + calcRetryAndFailGraph(); } } @@ -119,31 +108,18 @@ namespace osu.Game.Screens.Select set { fails = value.ToList(); - calcRetryAndFailBarLength(); + calcRetryAndFailGraph(); } } - private void calcRetryAndFailBarLength() + private void calcRetryAndFailGraph() { - List retryAndFailGraphBars = retryAndFailGraph.Children.ToList(); - float maxValue = fails.Select((value, index) => value + retries[index]).Max(); - for (int i = 0; i < 100; i++) - if (retryAndFailGraphBars.Count > i) - { - retryAndFailGraphBars[i].FailLength = fails[i] / maxValue; - retryAndFailGraphBars[i].RetryLength = retries[i] / maxValue; - } - else - retryAndFailGraph.Add(new RetryAndFailBar - { - RelativeSizeAxes = Axes.Both, - Width = 0.01f, - FailLength = fails[i] / maxValue, - RetryLength = retries[i] / maxValue, - }); + failGraph.Values = fails.Select(fail => (float)fail / fails.Max()); + List retryAndFails = retries.Select((retry, index) => (float)retry + fails[index]).ToList(); + retryGraph.Values = retryAndFails.Select(value => value / retryAndFails.Max()); } - public Details() + public BeatmapDetails() { Children = new Drawable[] { @@ -211,7 +187,7 @@ namespace osu.Game.Screens.Select Direction = FillDirection.Vertical, Spacing = new Vector2(0,15), Padding = new MarginPadding(10) { Top = 0 }, - Children = new [] + Children = new Drawable[] { new Container { @@ -297,7 +273,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, - ratingsBar = new DetailsBar + ratingsBar = new BeatmapDetailsBar { RelativeSizeAxes = Axes.X, Height = 5, @@ -333,7 +309,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, - ratingsGraph = new FillFlowContainer + ratingsGraph = new BeatmapDetailsGraph { RelativeSizeAxes = Axes.X, Direction = FillDirection.Horizontal, @@ -343,32 +319,27 @@ namespace osu.Game.Screens.Select }, }, }, - }, - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Direction = FillDirection.Vertical, - Padding = new MarginPadding { Left = 10, Right = 10 }, - Children = new Drawable[] - { - retryAndFailGraph = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, - Height = 50, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - }, new SpriteText { Text = "Points of Failure", TextSize = 14, Font = @"Exo2.0-Medium", - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, + }, + new Container + { + RelativeSizeAxes = Axes.X, + Size = new Vector2(1/0.6f, 50), + Children = new[] + { + retryGraph = new BeatmapDetailsGraph + { + RelativeSizeAxes = Axes.Both, + }, + failGraph = new BeatmapDetailsGraph + { + RelativeSizeAxes = Axes.Both, + }, + }, }, }, }, @@ -387,12 +358,15 @@ namespace osu.Game.Screens.Select ratingsBar.BackgroundColour = colour.Green; ratingsBar.BarColour = colour.YellowDark; ratingsGraph.Colour = colour.BlueDark; + + failGraph.Colour = colour.YellowDarker; + retryGraph.Colour = colour.Yellow; } private class DifficultyRow : Container { private readonly SpriteText name; - private readonly DetailsBar bar; + private readonly BeatmapDetailsBar bar; private readonly SpriteText valueText; private float difficultyValue; @@ -457,7 +431,7 @@ namespace osu.Game.Screens.Select TextSize = 14, Font = @"Exo2.0-Medium", }, - bar = new DetailsBar + bar = new BeatmapDetailsBar { Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, @@ -484,10 +458,10 @@ namespace osu.Game.Screens.Select } } - private class RetryAndFailBar : Container + private class RetryAndFailBar : Container { - private readonly DetailsBar retryBar; - private readonly DetailsBar failBar; + private readonly BeatmapDetailsBar retryBar; + private readonly BeatmapDetailsBar failBar; public float RetryLength { @@ -517,14 +491,14 @@ namespace osu.Game.Screens.Select { Children = new[] { - retryBar = new DetailsBar + retryBar = new BeatmapDetailsBar { RelativeSizeAxes = Axes.Both, Direction = BarDirection.BottomToTop, Length = 0, BackgroundColour = new Color4(0,0,0,0), }, - failBar = new DetailsBar + failBar = new BeatmapDetailsBar { RelativeSizeAxes = Axes.Both, Direction = BarDirection.BottomToTop, diff --git a/osu.Game/Screens/Select/DetailsBar.cs b/osu.Game/Screens/Select/Details/BeatmapDetailsBar.cs similarity index 92% rename from osu.Game/Screens/Select/DetailsBar.cs rename to osu.Game/Screens/Select/Details/BeatmapDetailsBar.cs index a7193cb822..d637903754 100644 --- a/osu.Game/Screens/Select/DetailsBar.cs +++ b/osu.Game/Screens/Select/Details/BeatmapDetailsBar.cs @@ -7,9 +7,9 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -namespace osu.Game.Screens.Select +namespace osu.Game.Screens.Select.Details { - public class DetailsBar : Container + public class BeatmapDetailsBar : Container { private readonly Box background; private readonly Box bar; @@ -70,7 +70,7 @@ namespace osu.Game.Screens.Select } } - public DetailsBar() + public BeatmapDetailsBar() { Children = new [] { diff --git a/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs b/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs new file mode 100644 index 0000000000..5f462c0559 --- /dev/null +++ b/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs @@ -0,0 +1,38 @@ +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using System.Collections.Generic; +using System.Linq; + +namespace osu.Game.Screens.Select.Details +{ + public class BeatmapDetailsGraph : FillFlowContainer + { + + public IEnumerable Values + { + set + { + List values = value.ToList(); + List graphBars = Children.ToList(); + for (int i = 0; i < values.Count; i++) + if (graphBars.Count > i) + { + graphBars[i].Length = values[i] / values.Max(); + graphBars[i].Width = 1.0f / values.Count; + } + else + Add(new BeatmapDetailsBar + { + RelativeSizeAxes = Axes.Both, + Width = 1.0f / values.Count, + Length = values[i] / values.Max(), + Direction = BarDirection.BottomToTop, + BackgroundColour = new Color4(0, 0, 0, 0), + }); + + } + } + + } +} \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 313db4e110..f5bb482d26 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -201,8 +201,9 @@ - - + + + From 50b85801413fe7f8c5338a629926cc29c05a735c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 31 Mar 2017 21:13:20 +0200 Subject: [PATCH 12/50] add license header --- osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs b/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs index 5f462c0559..6a90ff60d1 100644 --- a/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs +++ b/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs @@ -1,4 +1,7 @@ -using OpenTK.Graphics; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using System.Collections.Generic; @@ -35,4 +38,4 @@ namespace osu.Game.Screens.Select.Details } } -} \ No newline at end of file +} From d8bb72dd7811ecf1039ee8a377f30f8b995664c3 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 31 Mar 2017 21:19:23 +0200 Subject: [PATCH 13/50] remove unused using-directive --- osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs b/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs index 6a90ff60d1..67a44d4f9f 100644 --- a/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs +++ b/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs @@ -5,7 +5,6 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using System.Collections.Generic; -using System.Linq; namespace osu.Game.Screens.Select.Details { From 1f19d72474f43f18b374ffc0e6bc92c0f863aac4 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 31 Mar 2017 21:24:05 +0200 Subject: [PATCH 14/50] removed wrong using >.> --- osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs | 1 - osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index dfd40e7d15..f517e04b4b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Testing; using osu.Game.Database; -using osu.Game.Screens.Select; using osu.Game.Screens.Select.Details; using System; using System.Linq; diff --git a/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs b/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs index 67a44d4f9f..6a90ff60d1 100644 --- a/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs +++ b/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs @@ -5,6 +5,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using System.Collections.Generic; +using System.Linq; namespace osu.Game.Screens.Select.Details { From e380254386dde65c6428b2cb7f1c1bcc46abfe7c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 31 Mar 2017 22:32:09 +0200 Subject: [PATCH 15/50] remove unnecessary code --- osu.Game/Screens/Select/Details/BeatmapDetails.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/Details/BeatmapDetails.cs b/osu.Game/Screens/Select/Details/BeatmapDetails.cs index 8802d213b8..de9897396f 100644 --- a/osu.Game/Screens/Select/Details/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/Details/BeatmapDetails.cs @@ -80,7 +80,7 @@ namespace osu.Game.Screens.Select.Details positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); - ratingsGraph.Values = ratings.Select(rating => (float)rating / ratings.Max()); + ratingsGraph.Values = ratings.Select(rating => (float)rating); } } @@ -114,9 +114,9 @@ namespace osu.Game.Screens.Select.Details private void calcRetryAndFailGraph() { - failGraph.Values = fails.Select(fail => (float)fail / fails.Max()); - List retryAndFails = retries.Select((retry, index) => (float)retry + fails[index]).ToList(); - retryGraph.Values = retryAndFails.Select(value => value / retryAndFails.Max()); + failGraph.Values = fails.Select(fail => (float)fail); + retryGraph.Values = retries.Select((retry, index) => (float)retry + fails[index]); + } public BeatmapDetails() From d0b4f867258074176a7ee6a920a7bb514490e521 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 1 Apr 2017 14:16:18 +0200 Subject: [PATCH 16/50] fix errors from merge --- .../Tests/TestCaseBeatmapDetails.cs | 11 +++++++---- osu.Game/Screens/Select/BeatmapDetailArea.cs | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index f517e04b4b..3a57c1bc87 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -44,10 +44,8 @@ namespace osu.Desktop.VisualTests.Tests }, }); - details.Ratings = Enumerable.Range(1, 10); - newRetryAndFailValues(); - - AddButton("new retry/fail values", newRetryAndFailValues); + AddStep("new retry/fail values", newRetryAndFailValues); + AddStep("new ratings", newRatings); } private int lastRange = 1; @@ -58,5 +56,10 @@ namespace osu.Desktop.VisualTests.Tests details.Retries = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Sin(i) * 100)); lastRange += 100; } + + private void newRatings() + { + details.Ratings = Enumerable.Range(1, 10); + } } } diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index d7a104b364..c5dc7057bb 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -124,7 +124,6 @@ namespace osu.Game.Screens.Select if (api == null || beatmap?.BeatmapInfo == null) return; Details.Beatmap = beatmap.Beatmap.BeatmapInfo; - } } } From 017281246db3a8fbb549b11da7b6495d824087e0 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 1 Apr 2017 18:12:44 +0200 Subject: [PATCH 17/50] changed SpriteText to OsuSpriteText --- .../Screens/Select/Details/BeatmapDetails.cs | 55 ++++++++----------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/osu.Game/Screens/Select/Details/BeatmapDetails.cs b/osu.Game/Screens/Select/Details/BeatmapDetails.cs index de9897396f..cf50853691 100644 --- a/osu.Game/Screens/Select/Details/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/Details/BeatmapDetails.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Database; using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -19,9 +20,9 @@ namespace osu.Game.Screens.Select.Details { public class BeatmapDetails : Container { - private readonly SpriteText description; - private readonly SpriteText source; - private readonly FillFlowContainer tags; + private readonly OsuSpriteText description; + private readonly OsuSpriteText source; + private readonly FillFlowContainer tags; private readonly DifficultyRow circleSize; private readonly DifficultyRow drainRate; @@ -30,8 +31,8 @@ namespace osu.Game.Screens.Select.Details private readonly DifficultyRow stars; private readonly BeatmapDetailsBar ratingsBar; - private readonly SpriteText negativeRatings; - private readonly SpriteText positiveRatings; + private readonly OsuSpriteText negativeRatings; + private readonly OsuSpriteText positiveRatings; private readonly BeatmapDetailsGraph ratingsGraph; private readonly BeatmapDetailsGraph retryGraph; @@ -51,10 +52,9 @@ namespace osu.Game.Screens.Select.Details beatmap = value; description.Text = beatmap.Version; source.Text = beatmap.Metadata.Source; - tags.Children = beatmap.Metadata.Tags?.Split(' ').Select(text => new SpriteText + tags.Children = beatmap.Metadata.Tags?.Split(' ').Select(text => new OsuSpriteText { Text = text, - TextSize = 14, Font = "Exo2.0-Medium", }); @@ -140,39 +140,34 @@ namespace osu.Game.Screens.Select.Details Padding = new MarginPadding(10) { Top = 25 }, Children = new Drawable[] { - new SpriteText + new OsuSpriteText { Text = "Description", - TextSize = 14, Font = @"Exo2.0-Bold", }, - description = new SpriteText + description = new OsuSpriteText { - TextSize = 14, Font = @"Exo2.0-Medium", Direction = FillDirection.Full, }, - new SpriteText + new OsuSpriteText { Text = "Source", - TextSize = 14, Font = @"Exo2.0-Bold", Margin = new MarginPadding { Top = 20 }, }, - source = new SpriteText + source = new OsuSpriteText { - TextSize = 14, Font = @"Exo2.0-Medium", Direction = FillDirection.Full, }, - new SpriteText + new OsuSpriteText { Text = "Tags", - TextSize = 14, Font = @"Exo2.0-Bold", Margin = new MarginPadding { Top = 20 }, }, - tags = new FillFlowContainer + tags = new FillFlowContainer { RelativeSizeAxes = Axes.X, Spacing = new Vector2(3,0), @@ -265,10 +260,9 @@ namespace osu.Game.Screens.Select.Details Padding = new MarginPadding(15) { Top = 25, Bottom = 0 }, Children = new Drawable[] { - new SpriteText + new OsuSpriteText { Text = "User Rating", - TextSize = 14, Font = @"Exo2.0-Medium", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -285,15 +279,13 @@ namespace osu.Game.Screens.Select.Details AutoSizeAxes = Axes.Y, Children = new[] { - negativeRatings = new SpriteText + negativeRatings = new OsuSpriteText { - TextSize = 14, Font = @"Exo2.0-Medium", Text = "0", }, - positiveRatings = new SpriteText + positiveRatings = new OsuSpriteText { - TextSize = 14, Font = @"Exo2.0-Medium", Text = "0", Anchor = Anchor.TopRight, @@ -301,7 +293,7 @@ namespace osu.Game.Screens.Select.Details }, }, }, - new SpriteText + new OsuSpriteText { Text = "Rating Spread", TextSize = 14, @@ -319,10 +311,9 @@ namespace osu.Game.Screens.Select.Details }, }, }, - new SpriteText + new OsuSpriteText { Text = "Points of Failure", - TextSize = 14, Font = @"Exo2.0-Medium", }, new Container @@ -365,9 +356,9 @@ namespace osu.Game.Screens.Select.Details private class DifficultyRow : Container { - private readonly SpriteText name; + private readonly OsuSpriteText name; private readonly BeatmapDetailsBar bar; - private readonly SpriteText valueText; + private readonly OsuSpriteText valueText; private float difficultyValue; public float Value @@ -426,9 +417,8 @@ namespace osu.Game.Screens.Select.Details { Children = new Drawable[] { - name = new SpriteText + name = new OsuSpriteText { - TextSize = 14, Font = @"Exo2.0-Medium", }, bar = new BeatmapDetailsBar @@ -439,11 +429,10 @@ namespace osu.Game.Screens.Select.Details Size = new Vector2(1, 0.35f), Padding = new MarginPadding { Left = 100, Right = 25 }, }, - valueText = new SpriteText + valueText = new OsuSpriteText { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - TextSize = 14, Font = @"Exo2.0-Medium", }, }; From 5a694e0c9d20909d9265c57c6f1d8de307bf445a Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 3 Apr 2017 19:28:05 +0200 Subject: [PATCH 18/50] changed location of BarGraph to be more generic --- .../Tests/TestCaseBeatmapDetails.cs | 2 +- .../UserInterface/BarGraph.cs} | 45 ++++++++++++++++--- osu.Game/Screens/Select/BeatmapDetailArea.cs | 1 - .../Select/{Details => }/BeatmapDetails.cs | 35 ++++++++------- .../Select/Details/BeatmapDetailsGraph.cs | 41 ----------------- osu.Game/osu.Game.csproj | 9 ++-- 6 files changed, 63 insertions(+), 70 deletions(-) rename osu.Game/{Screens/Select/Details/BeatmapDetailsBar.cs => Graphics/UserInterface/BarGraph.cs} (66%) rename osu.Game/Screens/Select/{Details => }/BeatmapDetails.cs (92%) delete mode 100644 osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 3a57c1bc87..1f7662306f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -5,7 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Testing; using osu.Game.Database; -using osu.Game.Screens.Select.Details; +using osu.Game.Screens.Select; using System; using System.Linq; diff --git a/osu.Game/Screens/Select/Details/BeatmapDetailsBar.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs similarity index 66% rename from osu.Game/Screens/Select/Details/BeatmapDetailsBar.cs rename to osu.Game/Graphics/UserInterface/BarGraph.cs index d637903754..80412c41e5 100644 --- a/osu.Game/Screens/Select/Details/BeatmapDetailsBar.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -1,15 +1,48 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using System.Collections.Generic; +using System.Linq; -namespace osu.Game.Screens.Select.Details +namespace osu.Game.Graphics.UserInterface { - public class BeatmapDetailsBar : Container + public class BarGraph : FillFlowContainer + { + + public IEnumerable Values + { + set + { + List values = value.ToList(); + List graphBars = Children.ToList(); + for (int i = 0; i < values.Count; i++) + if (graphBars.Count > i) + { + graphBars[i].Length = values[i] / values.Max(); + graphBars[i].Width = 1.0f / values.Count; + } + else + Add(new Bar + { + RelativeSizeAxes = Axes.Both, + Width = 1.0f / values.Count, + Length = values[i] / values.Max(), + Direction = BarDirection.BottomToTop, + BackgroundColour = new Color4(0, 0, 0, 0), + }); + + } + } + + } + + public class Bar : Container { private readonly Box background; private readonly Box bar; @@ -27,7 +60,7 @@ namespace osu.Game.Screens.Select.Details } set { - length = MathHelper.Clamp(value,0,1); + length = MathHelper.Clamp(value, 0, 1); updateBarLength(); } } @@ -70,9 +103,9 @@ namespace osu.Game.Screens.Select.Details } } - public BeatmapDetailsBar() + public Bar() { - Children = new [] + Children = new[] { background = new Box { diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index c5dc7057bb..8387e39f67 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Primitives; using osu.Game.Beatmaps; using osu.Game.Online.API; using osu.Game.Online.API.Requests; -using osu.Game.Screens.Select.Details; using osu.Game.Screens.Select.Leaderboards; namespace osu.Game.Screens.Select diff --git a/osu.Game/Screens/Select/Details/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs similarity index 92% rename from osu.Game/Screens/Select/Details/BeatmapDetails.cs rename to osu.Game/Screens/Select/BeatmapDetails.cs index cf50853691..6bc7fe5ca0 100644 --- a/osu.Game/Screens/Select/Details/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -12,11 +12,12 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using System.Collections.Generic; using System.Globalization; using System.Linq; -namespace osu.Game.Screens.Select.Details +namespace osu.Game.Screens.Select { public class BeatmapDetails : Container { @@ -30,13 +31,13 @@ namespace osu.Game.Screens.Select.Details private readonly DifficultyRow approachRate; private readonly DifficultyRow stars; - private readonly BeatmapDetailsBar ratingsBar; + private readonly Bar ratingsBar; private readonly OsuSpriteText negativeRatings; private readonly OsuSpriteText positiveRatings; - private readonly BeatmapDetailsGraph ratingsGraph; + private readonly BarGraph ratingsGraph; - private readonly BeatmapDetailsGraph retryGraph; - private readonly BeatmapDetailsGraph failGraph; + private readonly BarGraph retryGraph; + private readonly BarGraph failGraph; private BeatmapInfo beatmap; public BeatmapInfo Beatmap @@ -267,7 +268,7 @@ namespace osu.Game.Screens.Select.Details Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, - ratingsBar = new BeatmapDetailsBar + ratingsBar = new Bar { RelativeSizeAxes = Axes.X, Height = 5, @@ -301,7 +302,7 @@ namespace osu.Game.Screens.Select.Details Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, - ratingsGraph = new BeatmapDetailsGraph + ratingsGraph = new BarGraph { RelativeSizeAxes = Axes.X, Direction = FillDirection.Horizontal, @@ -316,17 +317,17 @@ namespace osu.Game.Screens.Select.Details Text = "Points of Failure", Font = @"Exo2.0-Medium", }, - new Container + new Container { RelativeSizeAxes = Axes.X, Size = new Vector2(1/0.6f, 50), Children = new[] { - retryGraph = new BeatmapDetailsGraph + retryGraph = new BarGraph { RelativeSizeAxes = Axes.Both, }, - failGraph = new BeatmapDetailsGraph + failGraph = new BarGraph { RelativeSizeAxes = Axes.Both, }, @@ -357,7 +358,7 @@ namespace osu.Game.Screens.Select.Details private class DifficultyRow : Container { private readonly OsuSpriteText name; - private readonly BeatmapDetailsBar bar; + private readonly Bar bar; private readonly OsuSpriteText valueText; private float difficultyValue; @@ -421,7 +422,7 @@ namespace osu.Game.Screens.Select.Details { Font = @"Exo2.0-Medium", }, - bar = new BeatmapDetailsBar + bar = new Bar { Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, @@ -447,10 +448,10 @@ namespace osu.Game.Screens.Select.Details } } - private class RetryAndFailBar : Container + private class RetryAndFailBar : Container { - private readonly BeatmapDetailsBar retryBar; - private readonly BeatmapDetailsBar failBar; + private readonly Bar retryBar; + private readonly Bar failBar; public float RetryLength { @@ -480,14 +481,14 @@ namespace osu.Game.Screens.Select.Details { Children = new[] { - retryBar = new BeatmapDetailsBar + retryBar = new Bar { RelativeSizeAxes = Axes.Both, Direction = BarDirection.BottomToTop, Length = 0, BackgroundColour = new Color4(0,0,0,0), }, - failBar = new BeatmapDetailsBar + failBar = new Bar { RelativeSizeAxes = Axes.Both, Direction = BarDirection.BottomToTop, diff --git a/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs b/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs deleted file mode 100644 index 6a90ff60d1..0000000000 --- a/osu.Game/Screens/Select/Details/BeatmapDetailsGraph.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK.Graphics; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using System.Collections.Generic; -using System.Linq; - -namespace osu.Game.Screens.Select.Details -{ - public class BeatmapDetailsGraph : FillFlowContainer - { - - public IEnumerable Values - { - set - { - List values = value.ToList(); - List graphBars = Children.ToList(); - for (int i = 0; i < values.Count; i++) - if (graphBars.Count > i) - { - graphBars[i].Length = values[i] / values.Max(); - graphBars[i].Width = 1.0f / values.Count; - } - else - Add(new BeatmapDetailsBar - { - RelativeSizeAxes = Axes.Both, - Width = 1.0f / values.Count, - Length = values[i] / values.Max(), - Direction = BarDirection.BottomToTop, - BackgroundColour = new Color4(0, 0, 0, 0), - }); - - } - } - - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 360f8c9772..2e1ded6136 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -206,9 +206,8 @@ - - - + + @@ -391,7 +390,9 @@ - + + + From 8e689a06d8f113c743248387dc4491bb3c538ad4 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 3 Apr 2017 23:03:49 +0200 Subject: [PATCH 19/50] change font --- osu.Game/Screens/Select/BeatmapDetails.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 6bc7fe5ca0..2e9d78cced 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -56,7 +56,7 @@ namespace osu.Game.Screens.Select tags.Children = beatmap.Metadata.Tags?.Split(' ').Select(text => new OsuSpriteText { Text = text, - Font = "Exo2.0-Medium", + Font = "Exo2.0-Regular", }); circleSize.Value = beatmap.Difficulty.CircleSize; @@ -148,7 +148,7 @@ namespace osu.Game.Screens.Select }, description = new OsuSpriteText { - Font = @"Exo2.0-Medium", + Font = @"Exo2.0-Regular", Direction = FillDirection.Full, }, new OsuSpriteText @@ -159,7 +159,7 @@ namespace osu.Game.Screens.Select }, source = new OsuSpriteText { - Font = @"Exo2.0-Medium", + Font = @"Exo2.0-Regular", Direction = FillDirection.Full, }, new OsuSpriteText @@ -282,12 +282,12 @@ namespace osu.Game.Screens.Select { negativeRatings = new OsuSpriteText { - Font = @"Exo2.0-Medium", + Font = @"Exo2.0-Regular", Text = "0", }, positiveRatings = new OsuSpriteText { - Font = @"Exo2.0-Medium", + Font = @"Exo2.0-Regular", Text = "0", Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -298,7 +298,7 @@ namespace osu.Game.Screens.Select { Text = "Rating Spread", TextSize = 14, - Font = @"Exo2.0-Medium", + Font = @"Exo2.0-Regular", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, @@ -315,7 +315,7 @@ namespace osu.Game.Screens.Select new OsuSpriteText { Text = "Points of Failure", - Font = @"Exo2.0-Medium", + Font = @"Exo2.0-Regular", }, new Container { @@ -420,7 +420,7 @@ namespace osu.Game.Screens.Select { name = new OsuSpriteText { - Font = @"Exo2.0-Medium", + Font = @"Exo2.0-Regular", }, bar = new Bar { @@ -434,7 +434,7 @@ namespace osu.Game.Screens.Select { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - Font = @"Exo2.0-Medium", + Font = @"Exo2.0-Regular", }, }; } From 58f8dc82541775e28cf58a176ebd0b389837f225 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 4 Apr 2017 17:17:22 +0200 Subject: [PATCH 20/50] add direction to graphs --- osu.Game/Graphics/UserInterface/BarGraph.cs | 19 +++++++++++++++++-- osu.Game/Screens/Select/BeatmapDetails.cs | 1 - 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index 80412c41e5..5ad14a92f5 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -14,6 +14,22 @@ namespace osu.Game.Graphics.UserInterface { public class BarGraph : FillFlowContainer { + private BarDirection direction = BarDirection.BottomToTop; + public new BarDirection Direction + { + get + { + return direction; + } + set + { + direction = value; + foreach (var bar in Children) + bar.Direction = direction; + base.Direction = direction == BarDirection.LeftToRight || direction == BarDirection.RightToLeft ? FillDirection.Vertical : FillDirection.Horizontal; + } + } + public IEnumerable Values { @@ -33,13 +49,12 @@ namespace osu.Game.Graphics.UserInterface RelativeSizeAxes = Axes.Both, Width = 1.0f / values.Count, Length = values[i] / values.Max(), - Direction = BarDirection.BottomToTop, + Direction = Direction, BackgroundColour = new Color4(0, 0, 0, 0), }); } } - } public class Bar : Container diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 2e9d78cced..5adced7c95 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -305,7 +305,6 @@ namespace osu.Game.Screens.Select ratingsGraph = new BarGraph { RelativeSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, Height = 50, }, }, From 078d44aec31edce4bf7dd6fdc92d278c3f67f356 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 4 Apr 2017 17:17:37 +0200 Subject: [PATCH 21/50] some changes to the testcase --- osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 1f7662306f..72b27bb8b2 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -44,7 +44,7 @@ namespace osu.Desktop.VisualTests.Tests }, }); - AddStep("new retry/fail values", newRetryAndFailValues); + AddRepeatStep("new retry/fail values", newRetryAndFailValues, 10); AddStep("new ratings", newRatings); } @@ -57,9 +57,7 @@ namespace osu.Desktop.VisualTests.Tests lastRange += 100; } - private void newRatings() - { - details.Ratings = Enumerable.Range(1, 10); - } + private void newRatings() => details.Ratings = Enumerable.Range(1, 10); + } } From b2731bb0a130b26beaa0567a46e14e680a13b076 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 4 Apr 2017 17:27:08 +0200 Subject: [PATCH 22/50] some formatting --- .../Tests/TestCaseBeatmapDetails.cs | 3 +-- .../Tests/TestCaseGraphAndBar.cs | 11 +++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Graphics/UserInterface/BarGraph.cs | 6 +++--- osu.Game/Screens/Select/BeatmapDetailArea.cs | 13 +++++++------ osu.Game/Screens/Select/BeatmapDetails.cs | 19 ++++++++++++------- 6 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 72b27bb8b2..9af7329600 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -58,6 +58,5 @@ namespace osu.Desktop.VisualTests.Tests } private void newRatings() => details.Ratings = Enumerable.Range(1, 10); - } -} +} \ No newline at end of file diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs b/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs new file mode 100644 index 0000000000..f43b6a557d --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs @@ -0,0 +1,11 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseGraphAndBar : TestCase + { + } +} \ No newline at end of file diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 38c574f61f..ce60d25ad3 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -190,6 +190,7 @@ + diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index 5ad14a92f5..ce8a5f18b8 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -30,7 +30,6 @@ namespace osu.Game.Graphics.UserInterface } } - public IEnumerable Values { set @@ -52,7 +51,6 @@ namespace osu.Game.Graphics.UserInterface Direction = Direction, BackgroundColour = new Color4(0, 0, 0, 0), }); - } } } @@ -141,6 +139,7 @@ namespace osu.Game.Graphics.UserInterface case BarDirection.RightToLeft: bar.ResizeTo(new Vector2(length, 1), resize_duration, easing); break; + case BarDirection.TopToBottom: case BarDirection.BottomToTop: bar.ResizeTo(new Vector2(1, length), resize_duration, easing); @@ -154,6 +153,7 @@ namespace osu.Game.Graphics.UserInterface bar.Anchor = Anchor.TopLeft; bar.Origin = Anchor.TopLeft; break; + case BarDirection.RightToLeft: case BarDirection.BottomToTop: bar.Anchor = Anchor.BottomRight; @@ -170,4 +170,4 @@ namespace osu.Game.Graphics.UserInterface TopToBottom, BottomToTop, } -} +} \ No newline at end of file diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 8387e39f67..cb697c31d0 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -24,6 +24,7 @@ namespace osu.Game.Screens.Select private APIAccess api; private WorkingBeatmap beatmap; + public WorkingBeatmap Beatmap { get @@ -34,7 +35,7 @@ namespace osu.Game.Screens.Select { beatmap = value; if (IsLoaded) - if(currentTab == BeatmapDetailTab.Details) + if (currentTab == BeatmapDetailTab.Details) Schedule(updateDetails); else Schedule(updateScores); @@ -48,7 +49,7 @@ namespace osu.Game.Screens.Select new BeatmapDetailAreaTabControl { RelativeSizeAxes = Axes.X, - OnFilter = (tab, mods) => + OnFilter = (tab, mods) => { switch (tab) { @@ -57,6 +58,7 @@ namespace osu.Game.Screens.Select Leaderboard.Hide(); updateDetails(); break; + default: Details.Hide(); Leaderboard.Show(); @@ -100,6 +102,7 @@ namespace osu.Game.Screens.Select } private GetScoresRequest getScoresRequest; + private void updateScores() { if (!IsLoaded) return; @@ -114,15 +117,13 @@ namespace osu.Game.Screens.Select api.Queue(getScoresRequest); } - - private void updateDetails() { if (!IsLoaded) return; if (api == null || beatmap?.BeatmapInfo == null) return; - + Details.Beatmap = beatmap.Beatmap.BeatmapInfo; } } -} +} \ No newline at end of file diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 5adced7c95..433374509b 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -40,6 +40,7 @@ namespace osu.Game.Screens.Select private readonly BarGraph failGraph; private BeatmapInfo beatmap; + public BeatmapInfo Beatmap { get @@ -63,11 +64,12 @@ namespace osu.Game.Screens.Select drainRate.Value = beatmap.Difficulty.DrainRate; overallDifficulty.Value = beatmap.Difficulty.OverallDifficulty; approachRate.Value = beatmap.Difficulty.ApproachRate; - stars.Value = (float) beatmap.StarDifficulty; + stars.Value = (float)beatmap.StarDifficulty; } } private List ratings; + public IEnumerable Ratings { get @@ -85,7 +87,8 @@ namespace osu.Game.Screens.Select } } - private List retries = Enumerable.Repeat(0,100).ToList(); + private List retries = Enumerable.Repeat(0, 100).ToList(); + public IEnumerable Retries { get @@ -99,7 +102,8 @@ namespace osu.Game.Screens.Select } } - private List fails = Enumerable.Repeat(0,100).ToList(); + private List fails = Enumerable.Repeat(0, 100).ToList(); + public IEnumerable Fails { get @@ -117,7 +121,6 @@ namespace osu.Game.Screens.Select { failGraph.Values = fails.Select(fail => (float)fail); retryGraph.Values = retries.Select((retry, index) => (float)retry + fails[index]); - } public BeatmapDetails() @@ -361,6 +364,7 @@ namespace osu.Game.Screens.Select private readonly OsuSpriteText valueText; private float difficultyValue; + public float Value { get @@ -370,12 +374,13 @@ namespace osu.Game.Screens.Select set { difficultyValue = value; - bar.Length = value/maxValue; + bar.Length = value / maxValue; valueText.Text = value.ToString(CultureInfo.InvariantCulture); } } private float maxValue = 10; + public float MaxValue { get @@ -385,7 +390,7 @@ namespace osu.Game.Screens.Select set { maxValue = value; - bar.Length = Value/value; + bar.Length = Value / value; } } @@ -505,4 +510,4 @@ namespace osu.Game.Screens.Select } } } -} +} \ No newline at end of file From 502afc0a4890e67c43f9c13c9780a8cc7714f297 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 4 Apr 2017 18:09:16 +0200 Subject: [PATCH 23/50] some fixes to BarGraph so Direction works properly --- osu.Game/Graphics/UserInterface/BarGraph.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index ce8a5f18b8..2daa19bb4e 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -24,9 +24,12 @@ namespace osu.Game.Graphics.UserInterface set { direction = value; + base.Direction = (direction & BarDirection.Horizontal) > 0 ? FillDirection.Vertical : FillDirection.Horizontal; foreach (var bar in Children) + { + bar.Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / Children.Count()) : new Vector2(1.0f / Children.Count(), 1); bar.Direction = direction; - base.Direction = direction == BarDirection.LeftToRight || direction == BarDirection.RightToLeft ? FillDirection.Vertical : FillDirection.Horizontal; + } } } @@ -40,13 +43,13 @@ namespace osu.Game.Graphics.UserInterface if (graphBars.Count > i) { graphBars[i].Length = values[i] / values.Max(); - graphBars[i].Width = 1.0f / values.Count; + graphBars[i].Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1); } else Add(new Bar { RelativeSizeAxes = Axes.Both, - Width = 1.0f / values.Count, + Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1), Length = values[i] / values.Max(), Direction = Direction, BackgroundColour = new Color4(0, 0, 0, 0), @@ -165,9 +168,12 @@ namespace osu.Game.Graphics.UserInterface public enum BarDirection { - LeftToRight, - RightToLeft, - TopToBottom, - BottomToTop, + LeftToRight = 1 << 0, + RightToLeft = 1 << 1, + TopToBottom = 1 << 2, + BottomToTop = 1 << 3, + + Vertical = TopToBottom | BottomToTop, + Horizontal = LeftToRight | RightToLeft, } } \ No newline at end of file From cd2fc3148e1f323d78a5540b680162f362bf964c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 4 Apr 2017 18:10:57 +0200 Subject: [PATCH 24/50] added TestCaseGraphAndBar --- .../Tests/TestCaseGraphAndBar.cs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs b/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs index f43b6a557d..571a5031c8 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs @@ -1,11 +1,42 @@ // 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.Testing; +using osu.Game.Graphics.UserInterface; +using System.Collections.Generic; +using System.Linq; namespace osu.Desktop.VisualTests.Tests { internal class TestCaseGraphAndBar : TestCase { + public override string Description => "graphs and bars, bars and graphs"; + + private BarGraph graph; + + public override void Reset() + { + base.Reset(); + + Children = new[] + { + graph = new BarGraph + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(0.5f), + }, + }; + + AddStep("values from 1-10", () => graph.Values = Enumerable.Range(1,10).Select(i => (float)i)); + AddStep("reversed values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Reverse().Select(i => (float)i)); + AddStep("Bottom to top", () => graph.Direction = BarDirection.BottomToTop); + AddStep("Top to bottom", () => graph.Direction = BarDirection.TopToBottom); + AddStep("Left to right", () => graph.Direction = BarDirection.LeftToRight); + AddStep("Right to left", () => graph.Direction = BarDirection.RightToLeft); + } } } \ No newline at end of file From f9bf1c69bf73b34f88154bcce074f9f2a59de56d Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 4 Apr 2017 18:23:29 +0200 Subject: [PATCH 25/50] add Flags to BarDirection and remove unused "using" --- osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs | 1 - osu.Game/Graphics/UserInterface/BarGraph.cs | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs b/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs index 571a5031c8..5ae64b5e73 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs @@ -5,7 +5,6 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Testing; using osu.Game.Graphics.UserInterface; -using System.Collections.Generic; using System.Linq; namespace osu.Desktop.VisualTests.Tests diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index 2daa19bb4e..8f02f14ea8 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using System; using System.Collections.Generic; using System.Linq; @@ -166,6 +167,7 @@ namespace osu.Game.Graphics.UserInterface } } + [Flags] public enum BarDirection { LeftToRight = 1 << 0, From 28193cbaaa8d50b24c0d2761b7049ac3ae6b278c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 6 Apr 2017 15:39:23 +0200 Subject: [PATCH 26/50] hide BeatmapDetails on entering the Select screen --- osu.Game/Screens/Select/BeatmapDetailArea.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index cb697c31d0..3fd349da7f 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -81,6 +81,7 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding(5), + Alpha = 0, }, Leaderboard = new Leaderboard { From eb4b3772e98218cf64ee041f5393908cd805941d Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 7 Apr 2017 18:13:55 +0200 Subject: [PATCH 27/50] put Bar into its own file and let it only add a background if BackgroundColour is changed --- osu.Game/Graphics/UserInterface/Bar.cs | 134 +++++++++++++++++++ osu.Game/Graphics/UserInterface/BarGraph.cs | 124 ----------------- osu.Game/Screens/Select/BeatmapDetailArea.cs | 2 +- osu.Game/osu.Game.csproj | 1 + 4 files changed, 136 insertions(+), 125 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/Bar.cs diff --git a/osu.Game/Graphics/UserInterface/Bar.cs b/osu.Game/Graphics/UserInterface/Bar.cs new file mode 100644 index 0000000000..7c2123a309 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/Bar.cs @@ -0,0 +1,134 @@ +// 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.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using System; + +namespace osu.Game.Graphics.UserInterface +{ + public class Bar : Container + { + private Box background; + private readonly Box bar; + + private const int resize_duration = 250; + + private const EasingTypes easing = EasingTypes.InOutCubic; + + private float length; + public float Length + { + get + { + return length; + } + set + { + length = MathHelper.Clamp(value, 0, 1); + updateBarLength(); + } + } + + public SRGBColour BackgroundColour + { + get + { + return background?.Colour ?? default(SRGBColour); + } + set + { + if (background == null) + Add(background = new Box + { + RelativeSizeAxes = Axes.Both, + Depth = 1, + }); + background.Colour = value; + } + } + + public SRGBColour BarColour + { + get + { + return bar.Colour; + } + set + { + bar.Colour = value; + } + } + + private BarDirection direction = BarDirection.LeftToRight; + public BarDirection Direction + { + get + { + return direction; + } + set + { + direction = value; + updateBarLength(); + } + } + + public Bar() + { + Children = new[] + { + bar = new Box + { + RelativeSizeAxes = Axes.Both, + } + }; + } + + private void updateBarLength() + { + switch (direction) + { + case BarDirection.LeftToRight: + case BarDirection.RightToLeft: + bar.ResizeTo(new Vector2(length, 1), resize_duration, easing); + break; + + case BarDirection.TopToBottom: + case BarDirection.BottomToTop: + bar.ResizeTo(new Vector2(1, length), resize_duration, easing); + break; + } + + switch (direction) + { + case BarDirection.LeftToRight: + case BarDirection.TopToBottom: + bar.Anchor = Anchor.TopLeft; + bar.Origin = Anchor.TopLeft; + break; + + case BarDirection.RightToLeft: + case BarDirection.BottomToTop: + bar.Anchor = Anchor.BottomRight; + bar.Origin = Anchor.BottomRight; + break; + } + } + } + + [Flags] + public enum BarDirection + { + LeftToRight = 1 << 0, + RightToLeft = 1 << 1, + TopToBottom = 1 << 2, + BottomToTop = 1 << 3, + + Vertical = TopToBottom | BottomToTop, + Horizontal = LeftToRight | RightToLeft, + } +} \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index 8f02f14ea8..2b1ea7aacd 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -4,10 +4,7 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using System; using System.Collections.Generic; using System.Linq; @@ -53,129 +50,8 @@ namespace osu.Game.Graphics.UserInterface Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1), Length = values[i] / values.Max(), Direction = Direction, - BackgroundColour = new Color4(0, 0, 0, 0), }); } } } - - public class Bar : Container - { - private readonly Box background; - private readonly Box bar; - - private const int resize_duration = 250; - - private const EasingTypes easing = EasingTypes.InOutCubic; - - private float length; - public float Length - { - get - { - return length; - } - set - { - length = MathHelper.Clamp(value, 0, 1); - updateBarLength(); - } - } - - public SRGBColour BackgroundColour - { - get - { - return background.Colour; - } - set - { - background.Colour = value; - } - } - - public SRGBColour BarColour - { - get - { - return bar.Colour; - } - set - { - bar.Colour = value; - } - } - - private BarDirection direction = BarDirection.LeftToRight; - public BarDirection Direction - { - get - { - return direction; - } - set - { - direction = value; - updateBarLength(); - } - } - - public Bar() - { - Children = new[] - { - background = new Box - { - RelativeSizeAxes = Axes.Both, - }, - bar = new Box - { - RelativeSizeAxes = Axes.Both, - } - }; - } - - private void updateBarLength() - { - switch (direction) - { - case BarDirection.LeftToRight: - case BarDirection.RightToLeft: - bar.ResizeTo(new Vector2(length, 1), resize_duration, easing); - break; - - case BarDirection.TopToBottom: - case BarDirection.BottomToTop: - bar.ResizeTo(new Vector2(1, length), resize_duration, easing); - break; - } - - switch (direction) - { - case BarDirection.LeftToRight: - case BarDirection.TopToBottom: - bar.Anchor = Anchor.TopLeft; - bar.Origin = Anchor.TopLeft; - break; - - case BarDirection.RightToLeft: - case BarDirection.BottomToTop: - bar.Anchor = Anchor.BottomRight; - bar.Origin = Anchor.BottomRight; - break; - } - } - } - - [Flags] - public enum BarDirection - { - LeftToRight = 1 << 0, - RightToLeft = 1 << 1, - TopToBottom = 1 << 2, - BottomToTop = 1 << 3, - - Vertical = TopToBottom | BottomToTop, - Horizontal = LeftToRight | RightToLeft, - } } \ No newline at end of file diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 3fd349da7f..480814d013 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -56,7 +56,6 @@ namespace osu.Game.Screens.Select case BeatmapDetailTab.Details: Details.Show(); Leaderboard.Hide(); - updateDetails(); break; default: @@ -66,6 +65,7 @@ namespace osu.Game.Screens.Select break; } currentTab = tab; + updateDetails(); }, }, content = new Container diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c669af1da6..3e7f7e4abe 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -87,6 +87,7 @@ + From 9881889f88c75cd2eed150fbd8a9ab9b4cc9ef01 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 7 Apr 2017 18:24:36 +0200 Subject: [PATCH 28/50] removed some unused stuff --- osu.Game/Graphics/UserInterface/BarGraph.cs | 1 - osu.Game/Screens/Select/BeatmapDetailArea.cs | 8 +-- osu.Game/Screens/Select/BeatmapDetails.cs | 58 -------------------- 3 files changed, 2 insertions(+), 65 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index 2b1ea7aacd..e3f087b95c 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -2,7 +2,6 @@ // 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 System.Collections.Generic; diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 480814d013..169530a0c2 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -24,7 +24,6 @@ namespace osu.Game.Screens.Select private APIAccess api; private WorkingBeatmap beatmap; - public WorkingBeatmap Beatmap { get @@ -34,11 +33,8 @@ namespace osu.Game.Screens.Select set { beatmap = value; - if (IsLoaded) - if (currentTab == BeatmapDetailTab.Details) - Schedule(updateDetails); - else - Schedule(updateScores); + Schedule(updateDetails); + Schedule(updateScores); } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 433374509b..56dda7fd89 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -451,63 +451,5 @@ namespace osu.Game.Screens.Select valueText.Colour = colour.GrayB; } } - - private class RetryAndFailBar : Container - { - private readonly Bar retryBar; - private readonly Bar failBar; - - public float RetryLength - { - get - { - return retryBar.Length; - } - set - { - retryBar.Length = value + FailLength; - } - } - - public float FailLength - { - get - { - return failBar.Length; - } - set - { - failBar.Length = value; - } - } - - public RetryAndFailBar() - { - Children = new[] - { - retryBar = new Bar - { - RelativeSizeAxes = Axes.Both, - Direction = BarDirection.BottomToTop, - Length = 0, - BackgroundColour = new Color4(0,0,0,0), - }, - failBar = new Bar - { - RelativeSizeAxes = Axes.Both, - Direction = BarDirection.BottomToTop, - Length = 0, - BackgroundColour = new Color4(0,0,0,0), - }, - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colour) - { - retryBar.Colour = colour.Yellow; - failBar.Colour = colour.YellowDarker; - } - } } } \ No newline at end of file From 65d9f4fc4589628e601ba3a523cbd2073916678e Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 7 Apr 2017 19:27:14 +0200 Subject: [PATCH 29/50] hide MetadataSegments without content and remove fail/retry initialisations --- osu.Game/Screens/Select/BeatmapDetails.cs | 141 ++++++++++++++-------- 1 file changed, 92 insertions(+), 49 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 56dda7fd89..5acc5ccb56 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -21,9 +21,9 @@ namespace osu.Game.Screens.Select { public class BeatmapDetails : Container { - private readonly OsuSpriteText description; - private readonly OsuSpriteText source; - private readonly FillFlowContainer tags; + private readonly MetadataSegment description; + private readonly MetadataSegment source; + private readonly MetadataSegment tags; private readonly DifficultyRow circleSize; private readonly DifficultyRow drainRate; @@ -52,13 +52,10 @@ namespace osu.Game.Screens.Select { if (beatmap == value) return; beatmap = value; - description.Text = beatmap.Version; - source.Text = beatmap.Metadata.Source; - tags.Children = beatmap.Metadata.Tags?.Split(' ').Select(text => new OsuSpriteText - { - Text = text, - Font = "Exo2.0-Regular", - }); + + description.ContentText = beatmap.Version; + source.ContentText = beatmap.Metadata.Source; + tags.ContentText = beatmap.Metadata.Tags; circleSize.Value = beatmap.Difficulty.CircleSize; drainRate.Value = beatmap.Difficulty.DrainRate; @@ -87,8 +84,7 @@ namespace osu.Game.Screens.Select } } - private List retries = Enumerable.Repeat(0, 100).ToList(); - + private List retries; public IEnumerable Retries { get @@ -102,8 +98,7 @@ namespace osu.Game.Screens.Select } } - private List fails = Enumerable.Repeat(0, 100).ToList(); - + private List fails; public IEnumerable Fails { get @@ -120,7 +115,7 @@ namespace osu.Game.Screens.Select private void calcRetryAndFailGraph() { failGraph.Values = fails.Select(fail => (float)fail); - retryGraph.Values = retries.Select((retry, index) => (float)retry + fails[index]); + retryGraph.Values = retries?.Select((retry, index) => (float)retry + fails?[index] ?? 0) ?? new List(); } public BeatmapDetails() @@ -133,7 +128,7 @@ namespace osu.Game.Screens.Select Colour = Color4.Black, Alpha = 0.5f, }, - new FillFlowContainer() + new FillFlowContainer() { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -141,41 +136,29 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Y, Width = 0.4f, Direction = FillDirection.Vertical, + LayoutDuration = 1, + LayoutEasing = EasingTypes.OutQuint, Padding = new MarginPadding(10) { Top = 25 }, - Children = new Drawable[] + Children = new [] { - new OsuSpriteText - { - Text = "Description", - Font = @"Exo2.0-Bold", - }, - description = new OsuSpriteText - { - Font = @"Exo2.0-Regular", - Direction = FillDirection.Full, - }, - new OsuSpriteText - { - Text = "Source", - Font = @"Exo2.0-Bold", - Margin = new MarginPadding { Top = 20 }, - }, - source = new OsuSpriteText - { - Font = @"Exo2.0-Regular", - Direction = FillDirection.Full, - }, - new OsuSpriteText - { - Text = "Tags", - Font = @"Exo2.0-Bold", - Margin = new MarginPadding { Top = 20 }, - }, - tags = new FillFlowContainer + description = new MetadataSegment { + HeaderText = "Description", RelativeSizeAxes = Axes.X, - Spacing = new Vector2(3,0), + AutoSizeAxes = Axes.Y, }, + source = new MetadataSegment + { + HeaderText = "Source", + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, + tags = new MetadataSegment + { + HeaderText = "Tags", + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + } }, }, new FillFlowContainer @@ -343,9 +326,9 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load(OsuColour colour) { - description.Colour = colour.GrayB; - source.Colour = colour.GrayB; - tags.Colour = colour.YellowLight; + description.ContentColour = colour.GrayB; + source.ContentColour = colour.GrayB; + tags.ContentColour = colour.YellowLight; stars.BarColour = colour.Yellow; @@ -451,5 +434,65 @@ namespace osu.Game.Screens.Select valueText.Colour = colour.GrayB; } } + + private class MetadataSegment : Container + { + private readonly OsuSpriteText header; + private readonly FillFlowContainer content; + + private const int fade_time = 250; + + public string HeaderText + { + set + { + header.Text = value; + } + } + + public string ContentText + { + set + { + if (value == "") + FadeOut(fade_time); + else + { + FadeIn(fade_time); + content.Children = value.Split(' ').Select(text => new OsuSpriteText + { + Text = text + " ", + Font = "Exo2.0-Regular", + }); + } + } + } + + public SRGBColour ContentColour + { + set + { + content.Colour = value; + } + } + + public MetadataSegment() + { + Children = new Drawable[] + { + header = new OsuSpriteText + { + Font = @"Exo2.0-Bold", + }, + content = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Full, + Margin = new MarginPadding { Top = header.TextSize } + } + }; + } + } } } \ No newline at end of file From 899e559b5c3f93b1c313d1612ea7010f0d8505c3 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 7 Apr 2017 19:58:49 +0200 Subject: [PATCH 30/50] ratings hide now + remove unnessary stuff --- osu.Game/Screens/Select/BeatmapDetailArea.cs | 3 --- osu.Game/Screens/Select/BeatmapDetails.cs | 21 +++++++++++++------- osu.Game/osu.Game.csproj | 4 +--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 169530a0c2..15db451ea9 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -19,7 +19,6 @@ namespace osu.Game.Screens.Select public readonly BeatmapDetails Details; public readonly Leaderboard Leaderboard; - private BeatmapDetailTab currentTab; private APIAccess api; @@ -60,8 +59,6 @@ namespace osu.Game.Screens.Select updateScores(); break; } - currentTab = tab; - updateDetails(); }, }, content = new Container diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 5acc5ccb56..2655fce8c5 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -31,6 +31,7 @@ namespace osu.Game.Screens.Select private readonly DifficultyRow approachRate; private readonly DifficultyRow stars; + private readonly Container ratingsContainer; private readonly Bar ratingsBar; private readonly OsuSpriteText negativeRatings; private readonly OsuSpriteText positiveRatings; @@ -40,7 +41,6 @@ namespace osu.Game.Screens.Select private readonly BarGraph failGraph; private BeatmapInfo beatmap; - public BeatmapInfo Beatmap { get @@ -66,7 +66,6 @@ namespace osu.Game.Screens.Select } private List ratings; - public IEnumerable Ratings { get @@ -76,11 +75,17 @@ namespace osu.Game.Screens.Select set { ratings = value.ToList(); - negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); - positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); - ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); + if(ratings.Count == 0) + ratingsContainer.FadeOut(250); + else + { + ratingsContainer.FadeIn(250); + negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); + positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); + ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); - ratingsGraph.Values = ratings.Select(rating => (float)rating); + ratingsGraph.Values = ratings.Select(rating => (float)rating); + } } } @@ -227,10 +232,12 @@ namespace osu.Game.Screens.Select }, }, }, - new Container + ratingsContainer = new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + Alpha = 0, + AlwaysPresent = true, Children = new Drawable[] { new Box diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3e7f7e4abe..1888fda4a6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -385,9 +385,7 @@ - - - + From 6a87fd611235afb6e61515dfaea096414fdac3f6 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 7 Apr 2017 20:19:03 +0200 Subject: [PATCH 31/50] retries and fails hide if they're not present --- osu.Game/Screens/Select/BeatmapDetails.cs | 46 +++++++++++++++-------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 2655fce8c5..23e3fcf0d5 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -37,6 +37,7 @@ namespace osu.Game.Screens.Select private readonly OsuSpriteText positiveRatings; private readonly BarGraph ratingsGraph; + private readonly FillFlowContainer retryAndFailContainer; private readonly BarGraph retryGraph; private readonly BarGraph failGraph; @@ -119,8 +120,14 @@ namespace osu.Game.Screens.Select private void calcRetryAndFailGraph() { - failGraph.Values = fails.Select(fail => (float)fail); - retryGraph.Values = retries?.Select((retry, index) => (float)retry + fails?[index] ?? 0) ?? new List(); + if ((fails?.Count ?? 0) == 0 || (retries?.Count ?? 0) == 0) + retryAndFailContainer.FadeOut(250); + else + { + retryAndFailContainer.FadeIn(250); + failGraph.Values = fails.Select(fail => (float)fail); + retryGraph.Values = retries?.Select((retry, index) => (float)retry + fails[index]) ?? new List(); + } } public BeatmapDetails() @@ -304,26 +311,35 @@ namespace osu.Game.Screens.Select }, }, }, - new OsuSpriteText - { - Text = "Points of Failure", - Font = @"Exo2.0-Regular", - }, - new Container + retryAndFailContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, - Size = new Vector2(1/0.6f, 50), - Children = new[] + AutoSizeAxes = Axes.Y, + Alpha = 0, + Children = new Drawable[] { - retryGraph = new BarGraph + new OsuSpriteText { - RelativeSizeAxes = Axes.Both, + Text = "Points of Failure", + Font = @"Exo2.0-Regular", }, - failGraph = new BarGraph + new Container { - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + Size = new Vector2(1/0.6f, 50), + Children = new[] + { + retryGraph = new BarGraph + { + RelativeSizeAxes = Axes.Both, + }, + failGraph = new BarGraph + { + RelativeSizeAxes = Axes.Both, + }, + }, }, - }, + } }, }, }, From c60a55285c6d20838f11e6319033b2a7aec05eb7 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 7 Apr 2017 20:32:09 +0200 Subject: [PATCH 32/50] updated TestCase and some null checks --- osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs | 6 +++--- osu.Game/Graphics/UserInterface/BarGraph.cs | 2 +- osu.Game/Screens/Select/BeatmapDetails.cs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 9af7329600..2885520106 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -45,7 +45,9 @@ namespace osu.Desktop.VisualTests.Tests }); AddRepeatStep("new retry/fail values", newRetryAndFailValues, 10); - AddStep("new ratings", newRatings); + AddStep("new ratings", () => details.Ratings = Enumerable.Range(1, 10)); + AddStep("remove retries and fails", () => details.Retries = null ); + AddStep("remove ratings", () => details.Ratings = null); } private int lastRange = 1; @@ -56,7 +58,5 @@ namespace osu.Desktop.VisualTests.Tests details.Retries = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Sin(i) * 100)); lastRange += 100; } - - private void newRatings() => details.Ratings = Enumerable.Range(1, 10); } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index e3f087b95c..832ba74b89 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -34,7 +34,7 @@ namespace osu.Game.Graphics.UserInterface { set { - List values = value.ToList(); + List values = value?.ToList() ?? new List(); List graphBars = Children.ToList(); for (int i = 0; i < values.Count; i++) if (graphBars.Count > i) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 23e3fcf0d5..a319d3841c 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -75,7 +75,7 @@ namespace osu.Game.Screens.Select } set { - ratings = value.ToList(); + ratings = value?.ToList() ?? new List(); if(ratings.Count == 0) ratingsContainer.FadeOut(250); else @@ -99,7 +99,7 @@ namespace osu.Game.Screens.Select } set { - retries = value.ToList(); + retries = value?.ToList() ?? new List(); calcRetryAndFailGraph(); } } @@ -113,7 +113,7 @@ namespace osu.Game.Screens.Select } set { - fails = value.ToList(); + fails = value?.ToList() ?? new List(); calcRetryAndFailGraph(); } } @@ -126,7 +126,7 @@ namespace osu.Game.Screens.Select { retryAndFailContainer.FadeIn(250); failGraph.Values = fails.Select(fail => (float)fail); - retryGraph.Values = retries?.Select((retry, index) => (float)retry + fails[index]) ?? new List(); + retryGraph.Values = retries?.Select((retry, index) => (float)retry + fails[index]); } } From 841d101be73026ef3c84bb5d585eced7d2ad311d Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 7 Apr 2017 20:41:03 +0200 Subject: [PATCH 33/50] renaming --- osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 2885520106..00f0d67e24 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -44,10 +44,10 @@ namespace osu.Desktop.VisualTests.Tests }, }); - AddRepeatStep("new retry/fail values", newRetryAndFailValues, 10); + AddRepeatStep("new fail values", newRetryAndFailValues, 10); AddStep("new ratings", () => details.Ratings = Enumerable.Range(1, 10)); - AddStep("remove retries and fails", () => details.Retries = null ); - AddStep("remove ratings", () => details.Ratings = null); + AddStep("remove fails", () => details.Fails = null ); + AddStep("remove ratings", () => details.Ratings = null ); } private int lastRange = 1; From 5e56e84c4a789cf5130cf69f26ee3f9508078c0b Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 8 Apr 2017 13:31:55 +0200 Subject: [PATCH 34/50] change SRGBColour to Color4 and use IHasAccentColour in some places --- osu.Game/Graphics/UserInterface/Bar.cs | 8 ++++---- osu.Game/Screens/Select/BeatmapDetails.cs | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/Bar.cs b/osu.Game/Graphics/UserInterface/Bar.cs index 7c2123a309..2320e48de8 100644 --- a/osu.Game/Graphics/UserInterface/Bar.cs +++ b/osu.Game/Graphics/UserInterface/Bar.cs @@ -2,8 +2,8 @@ // 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.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using System; @@ -33,11 +33,11 @@ namespace osu.Game.Graphics.UserInterface } } - public SRGBColour BackgroundColour + public Color4 BackgroundColour { get { - return background?.Colour ?? default(SRGBColour); + return background?.Colour ?? default(Color4); } set { @@ -51,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface } } - public SRGBColour BarColour + public Color4 BarColour { get { diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index a319d3841c..6be42a7759 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -5,7 +5,6 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; @@ -349,11 +348,11 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load(OsuColour colour) { - description.ContentColour = colour.GrayB; - source.ContentColour = colour.GrayB; - tags.ContentColour = colour.YellowLight; + description.AccentColour = colour.GrayB; + source.AccentColour = colour.GrayB; + tags.AccentColour = colour.YellowLight; - stars.BarColour = colour.Yellow; + stars.AccentColour = colour.Yellow; ratingsBar.BackgroundColour = colour.Green; ratingsBar.BarColour = colour.YellowDark; @@ -363,7 +362,7 @@ namespace osu.Game.Screens.Select retryGraph.Colour = colour.Yellow; } - private class DifficultyRow : Container + private class DifficultyRow : Container, IHasAccentColour { private readonly OsuSpriteText name; private readonly Bar bar; @@ -412,7 +411,7 @@ namespace osu.Game.Screens.Select } } - public SRGBColour BarColour + public Color4 AccentColour { get { @@ -458,7 +457,7 @@ namespace osu.Game.Screens.Select } } - private class MetadataSegment : Container + private class MetadataSegment : Container, IHasAccentColour { private readonly OsuSpriteText header; private readonly FillFlowContainer content; @@ -491,8 +490,12 @@ namespace osu.Game.Screens.Select } } - public SRGBColour ContentColour + public Color4 AccentColour { + get + { + return content.Colour; + } set { content.Colour = value; From f7a9a11ae59441e7a493bbc851f11b43aa486e3d Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 8 Apr 2017 13:53:11 +0200 Subject: [PATCH 35/50] Bar uses AccentColour aswell --- osu.Game/Graphics/UserInterface/Bar.cs | 4 ++-- osu.Game/Screens/Select/BeatmapDetails.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/Bar.cs b/osu.Game/Graphics/UserInterface/Bar.cs index 2320e48de8..555d366f98 100644 --- a/osu.Game/Graphics/UserInterface/Bar.cs +++ b/osu.Game/Graphics/UserInterface/Bar.cs @@ -10,7 +10,7 @@ using System; namespace osu.Game.Graphics.UserInterface { - public class Bar : Container + public class Bar : Container, IHasAccentColour { private Box background; private readonly Box bar; @@ -51,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface } } - public Color4 BarColour + public Color4 AccentColour { get { diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 6be42a7759..f1daf4eeb9 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -355,7 +355,7 @@ namespace osu.Game.Screens.Select stars.AccentColour = colour.Yellow; ratingsBar.BackgroundColour = colour.Green; - ratingsBar.BarColour = colour.YellowDark; + ratingsBar.AccentColour = colour.YellowDark; ratingsGraph.Colour = colour.BlueDark; failGraph.Colour = colour.YellowDarker; @@ -415,11 +415,11 @@ namespace osu.Game.Screens.Select { get { - return bar.BarColour; + return bar.AccentColour; } set { - bar.BarColour = value; + bar.AccentColour = value; } } From bcef1ce2b68f5c74bc140633cb4ad14ae8ed54ac Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 8 Apr 2017 13:59:22 +0200 Subject: [PATCH 36/50] replace space in text with Spacing in FillFlowContainer --- osu.Game/Screens/Select/BeatmapDetails.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index f1daf4eeb9..6bbe7a0858 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -483,7 +483,7 @@ namespace osu.Game.Screens.Select FadeIn(fade_time); content.Children = value.Split(' ').Select(text => new OsuSpriteText { - Text = text + " ", + Text = text, Font = "Exo2.0-Regular", }); } @@ -515,6 +515,7 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Full, + Spacing = new Vector2(5,0), Margin = new MarginPadding { Top = header.TextSize } } }; From 24b4b3ad7d8011a27c01f619158f27f4c3ab620d Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 10 Apr 2017 16:42:23 +0200 Subject: [PATCH 37/50] update to everything --- .../Tests/TestCaseBeatmapDetails.cs | 36 ++- osu.Game/Database/BeatmapInfo.cs | 3 + osu.Game/Database/BeatmapMetric.cs | 23 ++ osu.Game/Graphics/UserInterface/Bar.cs | 16 +- osu.Game/Graphics/UserInterface/BarGraph.cs | 13 +- osu.Game/Screens/Select/BeatmapDetails.cs | 221 +++++------------- osu.Game/osu.Game.csproj | 1 + 7 files changed, 140 insertions(+), 173 deletions(-) create mode 100644 osu.Game/Database/BeatmapMetric.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 00f0d67e24..3394a6498e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -41,21 +41,45 @@ namespace osu.Desktop.VisualTests.Tests DrainRate = 1, }, StarDifficulty = 5.3f, + Metric = new BeatmapMetric + { + Ratings = Enumerable.Range(0,10).ToArray(), + Fails = Enumerable.Range(lastRange, 100).Select(i => (i % 12) - 6).ToArray(), + Retries = Enumerable.Range(lastRange - 3, 100).Select(i => (i % 12) - 6).ToArray(), + }, }, }); - AddRepeatStep("new fail values", newRetryAndFailValues, 10); - AddStep("new ratings", () => details.Ratings = Enumerable.Range(1, 10)); - AddStep("remove fails", () => details.Fails = null ); - AddStep("remove ratings", () => details.Ratings = null ); + AddRepeatStep("fail values", newRetryAndFailValues, 10); } private int lastRange = 1; private void newRetryAndFailValues() { - details.Fails = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Cos(i) * 100)); - details.Retries = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Sin(i) * 100)); + details.Beatmap = new BeatmapInfo + { + Version = "VisualTest", + Metadata = new BeatmapMetadata + { + Source = "Some guy", + Tags = "beatmap metadata example with a very very long list of tags and not much creativity", + }, + Difficulty = new BeatmapDifficulty + { + CircleSize = 7, + ApproachRate = 3.5f, + OverallDifficulty = 5.7f, + DrainRate = 1, + }, + StarDifficulty = 5.3f, + Metric = new BeatmapMetric + { + Ratings = Enumerable.Range(0, 10).ToArray(), + Fails = Enumerable.Range(lastRange, 100).Select(i => (i % 12) - 6).ToArray(), + Retries = Enumerable.Range(lastRange - 3, 100).Select(i => (i % 12) - 6).ToArray(), + }, + }; lastRange += 100; } } diff --git a/osu.Game/Database/BeatmapInfo.cs b/osu.Game/Database/BeatmapInfo.cs index bc6e077633..252d52a744 100644 --- a/osu.Game/Database/BeatmapInfo.cs +++ b/osu.Game/Database/BeatmapInfo.cs @@ -41,6 +41,9 @@ namespace osu.Game.Database [OneToOne(CascadeOperations = CascadeOperation.All)] public BeatmapDifficulty Difficulty { get; set; } + [Ignore] + public BeatmapMetric Metric { get; set; } + public string Path { get; set; } public string Hash { get; set; } diff --git a/osu.Game/Database/BeatmapMetric.cs b/osu.Game/Database/BeatmapMetric.cs new file mode 100644 index 0000000000..2302289047 --- /dev/null +++ b/osu.Game/Database/BeatmapMetric.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Database +{ + public class BeatmapMetric + { + /// + /// Ratings for a beatmap, length should be 10 + /// + public int[] Ratings { get; set; } + + /// + /// Fails for a beatmap, length should be 100 + /// + public int[] Fails { get; set; } + + /// + /// Retries for a beatmap, length should be 100 + /// + public int[] Retries { get; set; } + } +} diff --git a/osu.Game/Graphics/UserInterface/Bar.cs b/osu.Game/Graphics/UserInterface/Bar.cs index 555d366f98..c9733b807d 100644 --- a/osu.Game/Graphics/UserInterface/Bar.cs +++ b/osu.Game/Graphics/UserInterface/Bar.cs @@ -20,6 +20,9 @@ namespace osu.Game.Graphics.UserInterface private const EasingTypes easing = EasingTypes.InOutCubic; private float length; + /// + /// Length of the bar, ranges from 0 to 1 + /// public float Length { get @@ -41,12 +44,6 @@ namespace osu.Game.Graphics.UserInterface } set { - if (background == null) - Add(background = new Box - { - RelativeSizeAxes = Axes.Both, - Depth = 1, - }); background.Colour = value; } } @@ -81,10 +78,15 @@ namespace osu.Game.Graphics.UserInterface { Children = new[] { + background = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(0,0,0,0) + }, bar = new Box { RelativeSizeAxes = Axes.Both, - } + }, }; } diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index 832ba74b89..b29726ab1c 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -11,6 +11,11 @@ namespace osu.Game.Graphics.UserInterface { public class BarGraph : FillFlowContainer { + /// + /// Manually sets the max value, if null is instead used + /// + public float? MaxValue { get; set; } + private BarDirection direction = BarDirection.BottomToTop; public new BarDirection Direction { @@ -30,6 +35,9 @@ namespace osu.Game.Graphics.UserInterface } } + /// + /// A list of floats that defines the length of each + /// public IEnumerable Values { set @@ -39,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface for (int i = 0; i < values.Count; i++) if (graphBars.Count > i) { - graphBars[i].Length = values[i] / values.Max(); + graphBars[i].Length = values[i] / (MaxValue ?? values.Max()); graphBars[i].Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1); } else @@ -47,9 +55,10 @@ namespace osu.Game.Graphics.UserInterface { RelativeSizeAxes = Axes.Both, Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1), - Length = values[i] / values.Max(), + Length = values[i] / (MaxValue ?? values.Max()), Direction = Direction, }); + Remove(Children.Where((bar, index) => index >= values.Count)); } } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 6bbe7a0858..e33f42e5b1 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -47,85 +47,49 @@ namespace osu.Game.Screens.Select { return beatmap; } - set { if (beatmap == value) return; beatmap = value; - description.ContentText = beatmap.Version; - source.ContentText = beatmap.Metadata.Source; - tags.ContentText = beatmap.Metadata.Tags; + description.Text = beatmap.Version; + source.Text = beatmap.Metadata.Source; + tags.Text = beatmap.Metadata.Tags; circleSize.Value = beatmap.Difficulty.CircleSize; drainRate.Value = beatmap.Difficulty.DrainRate; overallDifficulty.Value = beatmap.Difficulty.OverallDifficulty; approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - } - } - private List ratings; - public IEnumerable Ratings - { - get - { - return ratings; - } - set - { - ratings = value?.ToList() ?? new List(); - if(ratings.Count == 0) - ratingsContainer.FadeOut(250); + + List ratings = beatmap.Metric?.Ratings?.ToList() ?? new List(); + if (ratings.Count == 0) + ratingsContainer.Hide(); else { - ratingsContainer.FadeIn(250); + ratingsContainer.Show(); negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); ratingsGraph.Values = ratings.Select(rating => (float)rating); } - } - } - private List retries; - public IEnumerable Retries - { - get - { - return retries; - } - set - { - retries = value?.ToList() ?? new List(); - calcRetryAndFailGraph(); - } - } + List retries = beatmap.Metric?.Retries?.ToList() ?? new List(); + List fails = beatmap.Metric?.Fails?.ToList() ?? new List(); - private List fails; - public IEnumerable Fails - { - get - { - return fails; - } - set - { - fails = value?.ToList() ?? new List(); - calcRetryAndFailGraph(); - } - } - - private void calcRetryAndFailGraph() - { - if ((fails?.Count ?? 0) == 0 || (retries?.Count ?? 0) == 0) - retryAndFailContainer.FadeOut(250); - else - { - retryAndFailContainer.FadeIn(250); - failGraph.Values = fails.Select(fail => (float)fail); - retryGraph.Values = retries?.Select((retry, index) => (float)retry + fails[index]); + if ((fails?.Count ?? 0) == 0 || (retries?.Count ?? 0) == 0) + retryAndFailContainer.Hide(); + else + { + retryAndFailContainer.Show(); + float maxValue = fails.Select((fail, index) => fail + retries[index]).Max(); + failGraph.MaxValue = maxValue; + retryGraph.MaxValue = maxValue; + failGraph.Values = fails.Select(fail => (float)fail); + retryGraph.Values = retries.Select((retry, index) => retry + MathHelper.Clamp(fails[index], 0, maxValue)); + } } } @@ -152,24 +116,9 @@ namespace osu.Game.Screens.Select Padding = new MarginPadding(10) { Top = 25 }, Children = new [] { - description = new MetadataSegment - { - HeaderText = "Description", - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - }, - source = new MetadataSegment - { - HeaderText = "Source", - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - }, - tags = new MetadataSegment - { - HeaderText = "Tags", - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - } + description = new MetadataSegment("Description"), + source = new MetadataSegment("Source"), + tags = new MetadataSegment("Tags") }, }, new FillFlowContainer @@ -178,7 +127,7 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Y, Width = 0.6f, Direction = FillDirection.Vertical, - Spacing = new Vector2(0,15), + Spacing = new Vector2(0, 15), Padding = new MarginPadding(10) { Top = 0 }, Children = new Drawable[] { @@ -203,37 +152,11 @@ namespace osu.Game.Screens.Select Padding = new MarginPadding(15) { Top = 25 }, Children = new [] { - circleSize = new DifficultyRow - { - DifficultyName = "Circle Size", - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - MaxValue = 7, - }, - drainRate = new DifficultyRow - { - DifficultyName = "HP Drain", - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - }, - overallDifficulty = new DifficultyRow - { - DifficultyName = "Accuracy", - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - }, - approachRate = new DifficultyRow - { - DifficultyName = "Approach Rate", - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - }, - stars = new DifficultyRow - { - DifficultyName = "Star Difficulty", - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - }, + circleSize = new DifficultyRow("Circle Size", 7), + drainRate = new DifficultyRow("HP Drain"), + overallDifficulty = new DifficultyRow("Accuracy"), + approachRate = new DifficultyRow("Approach Rate"), + stars = new DifficultyRow("Star Diffculty"), }, }, }, @@ -320,7 +243,7 @@ namespace osu.Game.Screens.Select new OsuSpriteText { Text = "Points of Failure", - Font = @"Exo2.0-Regular", + Font = @"Exo2.0-Regular", }, new Container { @@ -341,7 +264,7 @@ namespace osu.Game.Screens.Select } }, }, - }, + } }; } @@ -368,8 +291,9 @@ namespace osu.Game.Screens.Select private readonly Bar bar; private readonly OsuSpriteText valueText; - private float difficultyValue; + private readonly float maxValue; + private float difficultyValue; public float Value { get @@ -384,33 +308,6 @@ namespace osu.Game.Screens.Select } } - private float maxValue = 10; - - public float MaxValue - { - get - { - return maxValue; - } - set - { - maxValue = value; - bar.Length = Value / value; - } - } - - public string DifficultyName - { - get - { - return name.Text; - } - set - { - name.Text = value; - } - } - public Color4 AccentColour { get @@ -423,13 +320,17 @@ namespace osu.Game.Screens.Select } } - public DifficultyRow() + public DifficultyRow(string difficultyName, float maxValue = 10) { + this.maxValue = maxValue; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; Children = new Drawable[] { name = new OsuSpriteText { Font = @"Exo2.0-Regular", + Text = difficultyName, }, bar = new Bar { @@ -462,30 +363,30 @@ namespace osu.Game.Screens.Select private readonly OsuSpriteText header; private readonly FillFlowContainer content; - private const int fade_time = 250; - - public string HeaderText + public string Text { set { - header.Text = value; - } - } - - public string ContentText - { - set - { - if (value == "") - FadeOut(fade_time); + if (string.IsNullOrEmpty(value)) + Hide(); else { - FadeIn(fade_time); - content.Children = value.Split(' ').Select(text => new OsuSpriteText - { - Text = text, - Font = "Exo2.0-Regular", - }); + Show(); + if (header.Text == "Tags") + content.Children = value.Split(' ').Select(text => new OsuSpriteText + { + Text = text, + Font = "Exo2.0-Regular", + }); + else + content.Children = new[] + { + new OsuSpriteText + { + Text = value, + Font = "Exo2.0-Regular", + } + }; } } } @@ -502,13 +403,17 @@ namespace osu.Game.Screens.Select } } - public MetadataSegment() + public MetadataSegment(string headerText) { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Margin = new MarginPadding { Top = 10 }; Children = new Drawable[] { header = new OsuSpriteText { Font = @"Exo2.0-Bold", + Text = headerText, }, content = new FillFlowContainer { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1888fda4a6..7f01efbe70 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -79,6 +79,7 @@ + From 412d6a14ca01fbe1e43e7f1baca9df0bc2544cf6 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 10 Apr 2017 16:45:34 +0200 Subject: [PATCH 38/50] removed something unnecessary --- osu.Game/Graphics/UserInterface/Bar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/Bar.cs b/osu.Game/Graphics/UserInterface/Bar.cs index c9733b807d..4647adb91c 100644 --- a/osu.Game/Graphics/UserInterface/Bar.cs +++ b/osu.Game/Graphics/UserInterface/Bar.cs @@ -40,7 +40,7 @@ namespace osu.Game.Graphics.UserInterface { get { - return background?.Colour ?? default(Color4); + return background.Colour; } set { From ad41fd5c1a91eb54ff203104fbdecc6e3a0c589d Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 10 Apr 2017 16:49:48 +0200 Subject: [PATCH 39/50] more unnecessary stuff --- osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs | 9 ++++----- osu.Game/Graphics/UserInterface/Bar.cs | 2 +- osu.Game/Screens/Select/BeatmapDetails.cs | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 3394a6498e..200c2ba786 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Testing; using osu.Game.Database; using osu.Game.Screens.Select; -using System; using System.Linq; namespace osu.Desktop.VisualTests.Tests @@ -44,8 +43,8 @@ namespace osu.Desktop.VisualTests.Tests Metric = new BeatmapMetric { Ratings = Enumerable.Range(0,10).ToArray(), - Fails = Enumerable.Range(lastRange, 100).Select(i => (i % 12) - 6).ToArray(), - Retries = Enumerable.Range(lastRange - 3, 100).Select(i => (i % 12) - 6).ToArray(), + Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToArray(), }, }, }); @@ -76,8 +75,8 @@ namespace osu.Desktop.VisualTests.Tests Metric = new BeatmapMetric { Ratings = Enumerable.Range(0, 10).ToArray(), - Fails = Enumerable.Range(lastRange, 100).Select(i => (i % 12) - 6).ToArray(), - Retries = Enumerable.Range(lastRange - 3, 100).Select(i => (i % 12) - 6).ToArray(), + Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToArray(), }, }; lastRange += 100; diff --git a/osu.Game/Graphics/UserInterface/Bar.cs b/osu.Game/Graphics/UserInterface/Bar.cs index 4647adb91c..07aafbb655 100644 --- a/osu.Game/Graphics/UserInterface/Bar.cs +++ b/osu.Game/Graphics/UserInterface/Bar.cs @@ -12,7 +12,7 @@ namespace osu.Game.Graphics.UserInterface { public class Bar : Container, IHasAccentColour { - private Box background; + private readonly Box background; private readonly Box bar; private const int resize_duration = 250; diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index e33f42e5b1..2414122d7b 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -79,7 +79,7 @@ namespace osu.Game.Screens.Select List retries = beatmap.Metric?.Retries?.ToList() ?? new List(); List fails = beatmap.Metric?.Fails?.ToList() ?? new List(); - if ((fails?.Count ?? 0) == 0 || (retries?.Count ?? 0) == 0) + if (fails.Count == 0 || retries.Count == 0) retryAndFailContainer.Hide(); else { From fb5952186c45a5526b625ae366c9d09961fcbed6 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 11 Apr 2017 14:02:56 +0200 Subject: [PATCH 40/50] changes and fixes --- .../Tests/TestCaseBeatmapDetails.cs | 12 ++++---- ...estCaseGraphAndBar.cs => TestCaseGraph.cs} | 5 ++-- .../osu.Desktop.VisualTests.csproj | 2 +- osu.Game/Database/BeatmapMetric.cs | 8 ++++-- osu.Game/Graphics/UserInterface/BarGraph.cs | 2 +- osu.Game/Screens/Select/BeatmapDetails.cs | 28 +++++++++---------- 6 files changed, 30 insertions(+), 27 deletions(-) rename osu.Desktop.VisualTests/Tests/{TestCaseGraphAndBar.cs => TestCaseGraph.cs} (84%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 200c2ba786..9ea182c5c7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -42,9 +42,9 @@ namespace osu.Desktop.VisualTests.Tests StarDifficulty = 5.3f, Metric = new BeatmapMetric { - Ratings = Enumerable.Range(0,10).ToArray(), - Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToArray(), + Ratings = Enumerable.Range(0,10).ToList(), + Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToList(), + Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToList(), }, }, }); @@ -74,9 +74,9 @@ namespace osu.Desktop.VisualTests.Tests StarDifficulty = 5.3f, Metric = new BeatmapMetric { - Ratings = Enumerable.Range(0, 10).ToArray(), - Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToArray(), + Ratings = Enumerable.Range(0, 10).ToList(), + Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToList(), + Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToList(), }, }; lastRange += 100; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs b/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs similarity index 84% rename from osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs rename to osu.Desktop.VisualTests/Tests/TestCaseGraph.cs index 5ae64b5e73..7ac795f6f9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs @@ -9,9 +9,9 @@ using System.Linq; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseGraphAndBar : TestCase + internal class TestCaseGraph : TestCase { - public override string Description => "graphs and bars, bars and graphs"; + public override string Description => "graph"; private BarGraph graph; @@ -31,6 +31,7 @@ namespace osu.Desktop.VisualTests.Tests }; AddStep("values from 1-10", () => graph.Values = Enumerable.Range(1,10).Select(i => (float)i)); + AddStep("values from 1-100", () => graph.Values = Enumerable.Range(1, 100).Select(i => (float)i)); AddStep("reversed values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Reverse().Select(i => (float)i)); AddStep("Bottom to top", () => graph.Direction = BarDirection.BottomToTop); AddStep("Top to bottom", () => graph.Direction = BarDirection.TopToBottom); diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 44d823e50d..455e04ccec 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -190,7 +190,7 @@ - + diff --git a/osu.Game/Database/BeatmapMetric.cs b/osu.Game/Database/BeatmapMetric.cs index 2302289047..6272e5d6b1 100644 --- a/osu.Game/Database/BeatmapMetric.cs +++ b/osu.Game/Database/BeatmapMetric.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; + namespace osu.Game.Database { public class BeatmapMetric @@ -8,16 +10,16 @@ namespace osu.Game.Database /// /// Ratings for a beatmap, length should be 10 /// - public int[] Ratings { get; set; } + public List Ratings { get; set; } /// /// Fails for a beatmap, length should be 100 /// - public int[] Fails { get; set; } + public List Fails { get; set; } /// /// Retries for a beatmap, length should be 100 /// - public int[] Retries { get; set; } + public List Retries { get; set; } } } diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index b29726ab1c..41a00d7fec 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -58,7 +58,7 @@ namespace osu.Game.Graphics.UserInterface Length = values[i] / (MaxValue ?? values.Max()), Direction = Direction, }); - Remove(Children.Where((bar, index) => index >= values.Count)); + Remove(Children.Where((bar, index) => index >= values.Count).ToList()); } } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 2414122d7b..fab36ba5a6 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -36,7 +36,7 @@ namespace osu.Game.Screens.Select private readonly OsuSpriteText positiveRatings; private readonly BarGraph ratingsGraph; - private readonly FillFlowContainer retryAndFailContainer; + private readonly FillFlowContainer retryFailContainer; private readonly BarGraph retryGraph; private readonly BarGraph failGraph; @@ -62,34 +62,34 @@ namespace osu.Game.Screens.Select approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - - List ratings = beatmap.Metric?.Ratings?.ToList() ?? new List(); - if (ratings.Count == 0) - ratingsContainer.Hide(); - else + if (beatmap.Metric?.Ratings.Count != 0) { + List ratings = beatmap.Metric?.Ratings; ratingsContainer.Show(); + negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); ratingsGraph.Values = ratings.Select(rating => (float)rating); } - - List retries = beatmap.Metric?.Retries?.ToList() ?? new List(); - List fails = beatmap.Metric?.Fails?.ToList() ?? new List(); - - if (fails.Count == 0 || retries.Count == 0) - retryAndFailContainer.Hide(); else + ratingsContainer.Hide(); + + if (beatmap.Metric?.Retries.Count != 0 && beatmap.Metric?.Fails.Count != 0) { - retryAndFailContainer.Show(); + List retries = beatmap.Metric?.Retries; + List fails = beatmap.Metric?.Fails; + + retryFailContainer.Show(); float maxValue = fails.Select((fail, index) => fail + retries[index]).Max(); failGraph.MaxValue = maxValue; retryGraph.MaxValue = maxValue; failGraph.Values = fails.Select(fail => (float)fail); retryGraph.Values = retries.Select((retry, index) => retry + MathHelper.Clamp(fails[index], 0, maxValue)); } + else + retryFailContainer.Hide(); } } @@ -233,7 +233,7 @@ namespace osu.Game.Screens.Select }, }, }, - retryAndFailContainer = new FillFlowContainer + retryFailContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, From bfebba3a206a7e818bf5aa3ad635d1144cd357ef Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 11 Apr 2017 14:12:23 +0200 Subject: [PATCH 41/50] null reference fixes --- osu.Game/Screens/Select/BeatmapDetails.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index fab36ba5a6..a76497b221 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -62,9 +62,11 @@ namespace osu.Game.Screens.Select approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - if (beatmap.Metric?.Ratings.Count != 0) + if (beatmap.Metric?.Ratings?.Count == 0) + ratingsContainer.Hide(); + else { - List ratings = beatmap.Metric?.Ratings; + List ratings = beatmap.Metric.Ratings; ratingsContainer.Show(); negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); @@ -73,23 +75,22 @@ namespace osu.Game.Screens.Select ratingsGraph.Values = ratings.Select(rating => (float)rating); } + + if (beatmap.Metric?.Retries?.Count == 0 && beatmap.Metric?.Fails?.Count == 0) + retryFailContainer.Hide(); else - ratingsContainer.Hide(); - - if (beatmap.Metric?.Retries.Count != 0 && beatmap.Metric?.Fails.Count != 0) { - List retries = beatmap.Metric?.Retries; - List fails = beatmap.Metric?.Fails; - + List retries = beatmap.Metric.Retries; + List fails = beatmap.Metric.Fails; retryFailContainer.Show(); + float maxValue = fails.Select((fail, index) => fail + retries[index]).Max(); failGraph.MaxValue = maxValue; retryGraph.MaxValue = maxValue; + failGraph.Values = fails.Select(fail => (float)fail); retryGraph.Values = retries.Select((retry, index) => retry + MathHelper.Clamp(fails[index], 0, maxValue)); } - else - retryFailContainer.Hide(); } } From 9dd8920c2ceda574835057667a773090ae5ae409 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 11 Apr 2017 14:22:13 +0200 Subject: [PATCH 42/50] :thinking: I hope this works --- osu.Game/Screens/Select/BeatmapDetails.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index a76497b221..811235ea13 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -62,7 +62,7 @@ namespace osu.Game.Screens.Select approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - if (beatmap.Metric?.Ratings?.Count == 0) + if (beatmap.Metric?.Ratings == null) ratingsContainer.Hide(); else { @@ -76,7 +76,7 @@ namespace osu.Game.Screens.Select ratingsGraph.Values = ratings.Select(rating => (float)rating); } - if (beatmap.Metric?.Retries?.Count == 0 && beatmap.Metric?.Fails?.Count == 0) + if (beatmap.Metric?.Retries == null && beatmap.Metric?.Fails == null) retryFailContainer.Hide(); else { From 9026880495e266540313d0d6e40c338f7f2fe01b Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 11 Apr 2017 14:40:12 +0200 Subject: [PATCH 43/50] fix --- osu.Game/Screens/Select/BeatmapDetails.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 811235ea13..559f159e49 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -76,7 +76,7 @@ namespace osu.Game.Screens.Select ratingsGraph.Values = ratings.Select(rating => (float)rating); } - if (beatmap.Metric?.Retries == null && beatmap.Metric?.Fails == null) + if (beatmap.Metric?.Retries == null || beatmap.Metric?.Fails == null) retryFailContainer.Hide(); else { From d4e5f550914dfb0b3f1104b1cf0ade75fc3b5802 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 11 Apr 2017 18:43:48 +0200 Subject: [PATCH 44/50] the power of linq --- .../Tests/TestCaseBeatmapDetails.cs | 32 ++++--------------- osu.Game/Database/BeatmapMetric.cs | 6 ++-- osu.Game/Graphics/UserInterface/BarGraph.cs | 17 +++++----- osu.Game/Screens/Select/BeatmapDetails.cs | 23 +++++++------ 4 files changed, 28 insertions(+), 50 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 9ea182c5c7..7cf42b966a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -42,9 +42,9 @@ namespace osu.Desktop.VisualTests.Tests StarDifficulty = 5.3f, Metric = new BeatmapMetric { - Ratings = Enumerable.Range(0,10).ToList(), - Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToList(), - Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToList(), + Ratings = Enumerable.Range(0,10), + Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6), }, }, }); @@ -56,29 +56,9 @@ namespace osu.Desktop.VisualTests.Tests private void newRetryAndFailValues() { - details.Beatmap = new BeatmapInfo - { - Version = "VisualTest", - Metadata = new BeatmapMetadata - { - Source = "Some guy", - Tags = "beatmap metadata example with a very very long list of tags and not much creativity", - }, - Difficulty = new BeatmapDifficulty - { - CircleSize = 7, - ApproachRate = 3.5f, - OverallDifficulty = 5.7f, - DrainRate = 1, - }, - StarDifficulty = 5.3f, - Metric = new BeatmapMetric - { - Ratings = Enumerable.Range(0, 10).ToList(), - Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToList(), - Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToList(), - }, - }; + details.Beatmap.Metric.Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6); + details.Beatmap.Metric.Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6); + details.Beatmap = details.Beatmap; lastRange += 100; } } diff --git a/osu.Game/Database/BeatmapMetric.cs b/osu.Game/Database/BeatmapMetric.cs index 6272e5d6b1..e40da27d1d 100644 --- a/osu.Game/Database/BeatmapMetric.cs +++ b/osu.Game/Database/BeatmapMetric.cs @@ -10,16 +10,16 @@ namespace osu.Game.Database /// /// Ratings for a beatmap, length should be 10 /// - public List Ratings { get; set; } + public IEnumerable Ratings { get; set; } /// /// Fails for a beatmap, length should be 100 /// - public List Fails { get; set; } + public IEnumerable Fails { get; set; } /// /// Retries for a beatmap, length should be 100 /// - public List Retries { get; set; } + public IEnumerable Retries { get; set; } } } diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index 41a00d7fec..0b249d857b 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -42,23 +42,22 @@ namespace osu.Game.Graphics.UserInterface { set { - List values = value?.ToList() ?? new List(); - List graphBars = Children.ToList(); - for (int i = 0; i < values.Count; i++) - if (graphBars.Count > i) + List bars = Children.ToList(); + foreach (var bar in value.Select((length, index) => new { Value = length, Bar = bars.Count > index ? bars[index] : null })) + if (bar.Bar != null) { - graphBars[i].Length = values[i] / (MaxValue ?? values.Max()); - graphBars[i].Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1); + bar.Bar.Length = bar.Value / (MaxValue ?? value.Max()); + bar.Bar.Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / value.Count()) : new Vector2(1.0f / value.Count(), 1); } else Add(new Bar { RelativeSizeAxes = Axes.Both, - Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1), - Length = values[i] / (MaxValue ?? values.Max()), + Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / value.Count()) : new Vector2(1.0f / value.Count(), 1), + Length = bar.Value / (MaxValue ?? value.Max()), Direction = Direction, }); - Remove(Children.Where((bar, index) => index >= values.Count).ToList()); + Remove(Children.Where((bar, index) => index >= value.Count()).ToList()); } } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 559f159e49..b5a666e556 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -49,7 +49,6 @@ namespace osu.Game.Screens.Select } set { - if (beatmap == value) return; beatmap = value; description.Text = beatmap.Version; @@ -62,11 +61,9 @@ namespace osu.Game.Screens.Select approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - if (beatmap.Metric?.Ratings == null) - ratingsContainer.Hide(); - else + if (beatmap.Metric?.Ratings.Count() > 0) { - List ratings = beatmap.Metric.Ratings; + List ratings = beatmap.Metric.Ratings.ToList(); ratingsContainer.Show(); negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); @@ -75,22 +72,24 @@ namespace osu.Game.Screens.Select ratingsGraph.Values = ratings.Select(rating => (float)rating); } - - if (beatmap.Metric?.Retries == null || beatmap.Metric?.Fails == null) - retryFailContainer.Hide(); else + ratingsContainer.Hide(); + + if (beatmap.Metric?.Retries.Count() > 0 && beatmap.Metric?.Retries.Count() > 0) { - List retries = beatmap.Metric.Retries; - List fails = beatmap.Metric.Fails; + IEnumerable retries = beatmap.Metric.Retries; + IEnumerable fails = beatmap.Metric.Fails; retryFailContainer.Show(); - float maxValue = fails.Select((fail, index) => fail + retries[index]).Max(); + float maxValue = fails.Zip(retries, (fail, retry) => fail + retry).Max(); failGraph.MaxValue = maxValue; retryGraph.MaxValue = maxValue; failGraph.Values = fails.Select(fail => (float)fail); - retryGraph.Values = retries.Select((retry, index) => retry + MathHelper.Clamp(fails[index], 0, maxValue)); + retryGraph.Values = retries.Zip(fails, (retry, fail) => retry + MathHelper.Clamp(fail, 0, maxValue)); } + else + retryFailContainer.Hide(); } } From ed2f5d210efe96beac035156f46d5d7c0a2a838c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 11 Apr 2017 22:48:53 +0200 Subject: [PATCH 45/50] condensed some commits because they were small or already reversed --- osu.Game/Graphics/UserInterface/BarGraph.cs | 1 + osu.Game/Screens/Select/BeatmapDetailArea.cs | 2 +- osu.Game/Screens/Select/BeatmapDetails.cs | 14 +++++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index 0b249d857b..d0965a1861 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -57,6 +57,7 @@ namespace osu.Game.Graphics.UserInterface Length = bar.Value / (MaxValue ?? value.Max()), Direction = Direction, }); + //I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards Remove(Children.Where((bar, index) => index >= value.Count()).ToList()); } } diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 23d40e0260..ae117254fa 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Select { beatmap = value; Leaderboard.Beatmap = beatmap?.BeatmapInfo; - Details.Beatmap = beatmap.Beatmap.BeatmapInfo; + Details.Beatmap = beatmap?.Beatmap.BeatmapInfo; } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index b5a666e556..6f6b2f5880 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -12,7 +12,6 @@ using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -50,6 +49,7 @@ namespace osu.Game.Screens.Select set { beatmap = value; + if (beatmap == null) return; description.Text = beatmap.Version; source.Text = beatmap.Metadata.Source; @@ -61,9 +61,9 @@ namespace osu.Game.Screens.Select approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - if (beatmap.Metric?.Ratings.Count() > 0) + if (beatmap.Metric?.Ratings.Count() == 10) { - List ratings = beatmap.Metric.Ratings.ToList(); + var ratings = beatmap.Metric.Ratings.ToList(); ratingsContainer.Show(); negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); @@ -75,10 +75,10 @@ namespace osu.Game.Screens.Select else ratingsContainer.Hide(); - if (beatmap.Metric?.Retries.Count() > 0 && beatmap.Metric?.Retries.Count() > 0) + if (beatmap.Metric?.Retries.Count() == 100 && beatmap.Metric?.Fails.Count() == 100) { - IEnumerable retries = beatmap.Metric.Retries; - IEnumerable fails = beatmap.Metric.Fails; + var retries = beatmap.Metric.Retries; + var fails = beatmap.Metric.Fails; retryFailContainer.Show(); float maxValue = fails.Zip(retries, (fail, retry) => fail + retry).Max(); @@ -111,7 +111,7 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Y, Width = 0.4f, Direction = FillDirection.Vertical, - LayoutDuration = 1, + LayoutDuration = 200, LayoutEasing = EasingTypes.OutQuint, Padding = new MarginPadding(10) { Top = 25 }, Children = new [] From d2affe68675131ced3e0354607c4bb917e01bf5b Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 12 Apr 2017 10:52:24 +0200 Subject: [PATCH 46/50] requested changes --- osu.Game/Graphics/UserInterface/Bar.cs | 1 + osu.Game/Screens/Select/BeatmapDetails.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/Bar.cs b/osu.Game/Graphics/UserInterface/Bar.cs index 07aafbb655..76b75f1084 100644 --- a/osu.Game/Graphics/UserInterface/Bar.cs +++ b/osu.Game/Graphics/UserInterface/Bar.cs @@ -86,6 +86,7 @@ namespace osu.Game.Graphics.UserInterface bar = new Box { RelativeSizeAxes = Axes.Both, + Width = 0, }, }; } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 6f6b2f5880..990ecabdb5 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -180,7 +180,12 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, - Padding = new MarginPadding(15) { Top = 25, Bottom = 0 }, + Padding = new MarginPadding + { + Top = 25, + Left = 15, + Right = 15, + }, Children = new Drawable[] { new OsuSpriteText @@ -194,7 +199,6 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.X, Height = 5, - Length = 0, }, new Container { From e285d33f8cfe0658f458541805a32a3f7d775a14 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 12 Apr 2017 11:05:10 +0200 Subject: [PATCH 47/50] fails, retries and size not enforced --- osu.Game/Screens/Select/BeatmapDetails.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 990ecabdb5..1479ef35ce 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -61,21 +61,21 @@ namespace osu.Game.Screens.Select approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - if (beatmap.Metric?.Ratings.Count() == 10) + if (beatmap.Metric?.Ratings.Any() ?? false) { var ratings = beatmap.Metric.Ratings.ToList(); ratingsContainer.Show(); - negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); - positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); - ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); + negativeRatings.Text = ratings.GetRange(0, ratings.Count / 2).Sum().ToString(); + positiveRatings.Text = ratings.GetRange(ratings.Count / 2, ratings.Count / 2).Sum().ToString(); + ratingsBar.Length = (float)ratings.GetRange(0, ratings.Count / 2).Sum() / ratings.Sum(); ratingsGraph.Values = ratings.Select(rating => (float)rating); } else ratingsContainer.Hide(); - if (beatmap.Metric?.Retries.Count() == 100 && beatmap.Metric?.Fails.Count() == 100) + if ((beatmap.Metric?.Retries.Any() ?? false) && (beatmap.Metric?.Fails.Any() ?? false)) { var retries = beatmap.Metric.Retries; var fails = beatmap.Metric.Fails; From 98ce9e072410554620f4082748d4f4d209cc65e4 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 12 Apr 2017 11:25:32 +0200 Subject: [PATCH 48/50] remove ?? --- osu.Game/Screens/Select/BeatmapDetails.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 1479ef35ce..0d3a9ba9ee 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -75,7 +75,7 @@ namespace osu.Game.Screens.Select else ratingsContainer.Hide(); - if ((beatmap.Metric?.Retries.Any() ?? false) && (beatmap.Metric?.Fails.Any() ?? false)) + if ((beatmap.Metric?.Retries.Any() ?? false) && beatmap.Metric.Fails.Any()) { var retries = beatmap.Metric.Retries; var fails = beatmap.Metric.Fails; From 00cd2c8372a0a50058a2f01f00a9cdc978915950 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Apr 2017 21:08:28 +0900 Subject: [PATCH 49/50] Better comments. --- osu.Game/Database/BeatmapMetric.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Database/BeatmapMetric.cs b/osu.Game/Database/BeatmapMetric.cs index e40da27d1d..ae21bc4170 100644 --- a/osu.Game/Database/BeatmapMetric.cs +++ b/osu.Game/Database/BeatmapMetric.cs @@ -8,17 +8,17 @@ namespace osu.Game.Database public class BeatmapMetric { /// - /// Ratings for a beatmap, length should be 10 + /// Total vote counts of user ratings on a scale of 0..length. /// public IEnumerable Ratings { get; set; } /// - /// Fails for a beatmap, length should be 100 + /// Points of failure on a relative time scale (usually 0..100). /// public IEnumerable Fails { get; set; } /// - /// Retries for a beatmap, length should be 100 + /// Points of retry on a relative time scale (usually 0..100). /// public IEnumerable Retries { get; set; } } From 2c3fa303862e93c539fc6789d0b8d18fda6ff134 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Apr 2017 21:09:39 +0900 Subject: [PATCH 50/50] Metric -> Metrics. --- .../Tests/TestCaseBeatmapDetails.cs | 6 +++--- osu.Game/Database/BeatmapInfo.cs | 2 +- .../Database/{BeatmapMetric.cs => BeatmapMetrics.cs} | 5 ++++- osu.Game/Screens/Select/BeatmapDetails.cs | 10 +++++----- osu.Game/osu.Game.csproj | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) rename osu.Game/Database/{BeatmapMetric.cs => BeatmapMetrics.cs} (80%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 7cf42b966a..4a59ad9534 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -40,7 +40,7 @@ namespace osu.Desktop.VisualTests.Tests DrainRate = 1, }, StarDifficulty = 5.3f, - Metric = new BeatmapMetric + Metrics = new BeatmapMetrics { Ratings = Enumerable.Range(0,10), Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6), @@ -56,8 +56,8 @@ namespace osu.Desktop.VisualTests.Tests private void newRetryAndFailValues() { - details.Beatmap.Metric.Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6); - details.Beatmap.Metric.Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6); + details.Beatmap.Metrics.Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6); + details.Beatmap.Metrics.Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6); details.Beatmap = details.Beatmap; lastRange += 100; } diff --git a/osu.Game/Database/BeatmapInfo.cs b/osu.Game/Database/BeatmapInfo.cs index 7dc62d64e8..3e84825919 100644 --- a/osu.Game/Database/BeatmapInfo.cs +++ b/osu.Game/Database/BeatmapInfo.cs @@ -42,7 +42,7 @@ namespace osu.Game.Database public BeatmapDifficulty Difficulty { get; set; } [Ignore] - public BeatmapMetric Metric { get; set; } + public BeatmapMetrics Metrics { get; set; } public string Path { get; set; } diff --git a/osu.Game/Database/BeatmapMetric.cs b/osu.Game/Database/BeatmapMetrics.cs similarity index 80% rename from osu.Game/Database/BeatmapMetric.cs rename to osu.Game/Database/BeatmapMetrics.cs index ae21bc4170..91320110d0 100644 --- a/osu.Game/Database/BeatmapMetric.cs +++ b/osu.Game/Database/BeatmapMetrics.cs @@ -5,7 +5,10 @@ using System.Collections.Generic; namespace osu.Game.Database { - public class BeatmapMetric + /// + /// Beatmap metrics based on acculumated online data from community plays. + /// + public class BeatmapMetrics { /// /// Total vote counts of user ratings on a scale of 0..length. diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 0d3a9ba9ee..a0d15101e0 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -61,9 +61,9 @@ namespace osu.Game.Screens.Select approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - if (beatmap.Metric?.Ratings.Any() ?? false) + if (beatmap.Metrics?.Ratings.Any() ?? false) { - var ratings = beatmap.Metric.Ratings.ToList(); + var ratings = beatmap.Metrics.Ratings.ToList(); ratingsContainer.Show(); negativeRatings.Text = ratings.GetRange(0, ratings.Count / 2).Sum().ToString(); @@ -75,10 +75,10 @@ namespace osu.Game.Screens.Select else ratingsContainer.Hide(); - if ((beatmap.Metric?.Retries.Any() ?? false) && beatmap.Metric.Fails.Any()) + if ((beatmap.Metrics?.Retries.Any() ?? false) && beatmap.Metrics.Fails.Any()) { - var retries = beatmap.Metric.Retries; - var fails = beatmap.Metric.Fails; + var retries = beatmap.Metrics.Retries; + var fails = beatmap.Metrics.Fails; retryFailContainer.Show(); float maxValue = fails.Zip(retries, (fail, retry) => fail + retry).Max(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 76ec4d3387..578704f4f8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -76,7 +76,7 @@ - +