From 0d8815bd376509c012fa13e26d1ebc8f238cd48c Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 3 Feb 2017 15:22:02 -0400 Subject: [PATCH 01/43] Added back current work --- .../Tests/TestCaseSongProgressBar.cs | 26 +++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + .../UserInterface/SongProgressBar.cs} | 38 ++++++++++--------- .../UserInterface/SongProgressGraph.cs | 9 +++++ osu.Game/Overlays/Pause/PauseOverlay.cs | 6 --- osu.Game/Overlays/Pause/PauseProgressGraph.cs | 9 ----- osu.Game/osu.Game.csproj | 4 +- 7 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs rename osu.Game/{Overlays/Pause/PauseProgressBar.cs => Graphics/UserInterface/SongProgressBar.cs} (80%) create mode 100644 osu.Game/Graphics/UserInterface/SongProgressGraph.cs delete mode 100644 osu.Game/Overlays/Pause/PauseProgressGraph.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs new file mode 100644 index 0000000000..479dac895e --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs @@ -0,0 +1,26 @@ +using System; +using osu.Framework.Graphics; +using osu.Framework.GameModes.Testing; +using osu.Game.Graphics.UserInterface; + +namespace osu.Desktop.VisualTests +{ + public class TestCaseSongProgressBar : TestCase + { + public override string Name => @"SongProgressBar"; + + public override string Description => @"Tests the song progress bar"; + + public override void Reset() + { + base.Reset(); + + Add(new SongProgressBar + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X + }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 69df007013..1619c18e4c 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -188,6 +188,7 @@ + diff --git a/osu.Game/Overlays/Pause/PauseProgressBar.cs b/osu.Game/Graphics/UserInterface/SongProgressBar.cs similarity index 80% rename from osu.Game/Overlays/Pause/PauseProgressBar.cs rename to osu.Game/Graphics/UserInterface/SongProgressBar.cs index 28824cb7ea..ec208ad0de 100644 --- a/osu.Game/Overlays/Pause/PauseProgressBar.cs +++ b/osu.Game/Graphics/UserInterface/SongProgressBar.cs @@ -6,12 +6,16 @@ using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Framework.Graphics.Primitives; -namespace osu.Game.Overlays.Pause +namespace osu.Game.Graphics.UserInterface { - public class PauseProgressBar : Container + public class SongProgressBar : Container { - private Color4 fillColour = new Color4(221, 255, 255, 255); - private Color4 glowColour = new Color4(221, 255, 255, 150); + private const int bar_height = 5; + private const int graph_height = 40; + private const int handle_height = 25; + private const int handle_width = 14; + private Color4 fill_colour = new Color4(221, 255, 255, 255); + private Color4 glow_colour = new Color4(221, 255, 255, 150); private Container fill; private WorkingBeatmap current; @@ -32,22 +36,22 @@ namespace osu.Game.Overlays.Pause } } - public PauseProgressBar() + public SongProgressBar() { RelativeSizeAxes = Axes.X; - Height = 60; + Height = bar_height + graph_height + handle_height; Children = new Drawable[] { - new PauseProgressGraph + new SongProgressGraph { RelativeSizeAxes = Axes.X, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, - Height = 35, + Height = graph_height, Margin = new MarginPadding { - Bottom = 5 + Bottom = bar_height } }, new Container @@ -55,7 +59,7 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, RelativeSizeAxes = Axes.X, - Height = 5, + Height = bar_height, Children = new Drawable[] { new Box @@ -72,7 +76,7 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Width = 0, - Height = 60, + Height = bar_height + graph_height + handle_height, Children = new Drawable[] { new Container @@ -88,12 +92,12 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - Height = 5, + Height = bar_height, Masking = true, EdgeEffect = new EdgeEffect { Type = EdgeEffectType.Glow, - Colour = glowColour, + Colour = glow_colour, Radius = 5 }, Children = new Drawable[] @@ -101,7 +105,7 @@ namespace osu.Game.Overlays.Pause new Box { RelativeSizeAxes = Axes.Both, - Colour = fillColour + Colour = fill_colour } } } @@ -112,7 +116,7 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, Width = 2, - Height = 35, + Height = bar_height + graph_height , Children = new Drawable[] { new Box @@ -124,8 +128,8 @@ namespace osu.Game.Overlays.Pause { Origin = Anchor.BottomCentre, Anchor = Anchor.TopCentre, - Width = 14, - Height = 25, + Width = handle_width, + Height = handle_height, CornerRadius = 5, Masking = true, Children = new Drawable[] diff --git a/osu.Game/Graphics/UserInterface/SongProgressGraph.cs b/osu.Game/Graphics/UserInterface/SongProgressGraph.cs new file mode 100644 index 0000000000..4af7b8e857 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/SongProgressGraph.cs @@ -0,0 +1,9 @@ +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Graphics.UserInterface +{ + public class SongProgressGraph : Container + { + // TODO: Implement the song progress graph + } +} diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 3cf514b7c8..3d1e52bb20 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -186,12 +186,6 @@ namespace osu.Game.Overlays.Pause Anchor = Anchor.TopCentre } } - }, - new PauseProgressBar - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Width = 1f } }; diff --git a/osu.Game/Overlays/Pause/PauseProgressGraph.cs b/osu.Game/Overlays/Pause/PauseProgressGraph.cs deleted file mode 100644 index fab9f37923..0000000000 --- a/osu.Game/Overlays/Pause/PauseProgressGraph.cs +++ /dev/null @@ -1,9 +0,0 @@ -using osu.Framework.Graphics.Containers; - -namespace osu.Game.Overlays.Pause -{ - public class PauseProgressGraph : Container - { - // TODO: Implement the pause progress graph - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f8fa2c951a..2b26c1ee50 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -247,11 +247,11 @@ - - + + From 3d0feb4de9073790c5717f7f7cf67620a3b5e0df Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 7 Feb 2017 01:49:41 -0400 Subject: [PATCH 02/43] Very basic implementation of the graph --- .../Tests/TestCaseSongProgressBar.cs | 55 +++++++------ .../Graphics/UserInterface/SongProgressBar.cs | 8 +- .../UserInterface/SongProgressGraph.cs | 58 ++++++++++++- .../UserInterface/SongProgressGraphColumn.cs | 81 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 5 files changed, 174 insertions(+), 29 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs index 479dac895e..dbb9ad0e49 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs @@ -1,26 +1,35 @@ -using System; -using osu.Framework.Graphics; -using osu.Framework.GameModes.Testing; +using System; +using OpenTK.Graphics; using osu.Game.Graphics.UserInterface; +using osu.Framework.Graphics; +using osu.Framework.GameModes.Testing; +using osu.Framework.Graphics.Sprites; +using osu.Framework.GameModes.Testing; +using osu.Framework.Graphics.Colour; -namespace osu.Desktop.VisualTests -{ - public class TestCaseSongProgressBar : TestCase - { - public override string Name => @"SongProgressBar"; - - public override string Description => @"Tests the song progress bar"; - - public override void Reset() - { - base.Reset(); - - Add(new SongProgressBar +namespace osu.Desktop.VisualTests +{ + public class TestCaseSongProgressBar : TestCase + { + public override string Name => @"SongProgressBar"; + + public override string Description => @"Tests the song progress bar"; + + public override void Reset() + { + base.Reset(); + + Add(new Box { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X - }); - } - } -} + ColourInfo = ColourInfo.GradientVertical(Color4.WhiteSmoke, Color4.Gray), + RelativeSizeAxes = Framework.Graphics.Axes.Both, + }); + Add(new SongProgressBar + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X + }); + } + } +} diff --git a/osu.Game/Graphics/UserInterface/SongProgressBar.cs b/osu.Game/Graphics/UserInterface/SongProgressBar.cs index ec208ad0de..1c837a980f 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressBar.cs +++ b/osu.Game/Graphics/UserInterface/SongProgressBar.cs @@ -11,13 +11,14 @@ namespace osu.Game.Graphics.UserInterface public class SongProgressBar : Container { private const int bar_height = 5; - private const int graph_height = 40; + private const int graph_height = 34; private const int handle_height = 25; private const int handle_width = 14; private Color4 fill_colour = new Color4(221, 255, 255, 255); private Color4 glow_colour = new Color4(221, 255, 255, 150); private Container fill; + private SongProgressGraph progressGraph; private WorkingBeatmap current; [BackgroundDependencyLoader] @@ -33,6 +34,7 @@ namespace osu.Game.Graphics.UserInterface if (current?.TrackLoaded ?? false) { fill.Width = (float)(current.Track.CurrentTime / current.Track.Length); + progressGraph.Progress = fill.Width; } } @@ -43,7 +45,7 @@ namespace osu.Game.Graphics.UserInterface Children = new Drawable[] { - new SongProgressGraph + progressGraph = new SongProgressGraph { RelativeSizeAxes = Axes.X, Origin = Anchor.BottomCentre, @@ -116,7 +118,7 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, Width = 2, - Height = bar_height + graph_height , + Height = bar_height + graph_height, Children = new Drawable[] { new Box diff --git a/osu.Game/Graphics/UserInterface/SongProgressGraph.cs b/osu.Game/Graphics/UserInterface/SongProgressGraph.cs index 4af7b8e857..4e03f0a906 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressGraph.cs +++ b/osu.Game/Graphics/UserInterface/SongProgressGraph.cs @@ -1,9 +1,61 @@ -using osu.Framework.Graphics.Containers; +using OpenTK; +using System; +using System.Collections.Generic; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; namespace osu.Game.Graphics.UserInterface { - public class SongProgressGraph : Container + public class SongProgressGraph : BufferedContainer { - // TODO: Implement the song progress graph + private List columns = new List(); + + public override bool HandleInput => false; + + private float progress; + public float Progress + { + get + { + return progress; + } + set + { + if (value == progress) return; + progress = value; + + for (int i = 0; i < columns.Count; i++) + { + columns[i].State = i <= (columns.Count * progress) ? SongProgressGraphColumnState.Lit : SongProgressGraphColumnState.Dimmed; + } + + ForceRedraw(); + } + } + + public SongProgressGraph() + { + CacheDrawnFrameBuffer = true; + PixelSnapping = true; + + Margin = new MarginPadding + { + Left = 1, + Right = 1 + }; + + var random = new Random(); + for (int column = 0; column < 1200; column += 3) + { + columns.Add(new SongProgressGraphColumn + { + Position = new Vector2(column, 0), + Filled = random.Next(1, 11), + State = SongProgressGraphColumnState.Dimmed + }); + + Add(columns[columns.Count - 1]); + } + } } } diff --git a/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs b/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs new file mode 100644 index 0000000000..c14e0ba634 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs @@ -0,0 +1,81 @@ +using OpenTK; +using OpenTK.Graphics; +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; + +namespace osu.Game.Graphics.UserInterface +{ + public class SongProgressGraphColumn : Container + { + private int rows = 11; + private Color4 empty_colour = Color4.White.Opacity(50); + private Color4 lit_colour = new Color4(221, 255, 255, 255); + private Color4 dimmed_colour = Color4.White.Opacity(175); + + private List drawableRows = new List(); + + private int filled; + public int Filled + { + get + { + return filled; + } + set + { + if (value == filled) return; + filled = value; + } + } + + private SongProgressGraphColumnState state; + public SongProgressGraphColumnState State + { + get + { + return state; + } + set + { + if (value == state) return; + state = value; + + fillActive(value == SongProgressGraphColumnState.Lit ? lit_colour : dimmed_colour); + } + } + + private void fillActive(Color4 color) + { + for (int i = 0; i < drawableRows.Count; i++) + { + drawableRows[i].Colour = i <= Filled ? color : empty_colour; + } + } + + public SongProgressGraphColumn() + { + Size = new Vector2(4, rows * 3); + + for (int row = 0; row < rows * 3; row += 3) + { + drawableRows.Add(new Box + { + Size = new Vector2(2), + Position = new Vector2(0, row + 1) + }); + + Add(drawableRows[drawableRows.Count - 1]); + } + + // Reverse drawableRows so when iterating through them they start at the bottom + drawableRows.Reverse(); + } + } + + public enum SongProgressGraphColumnState + { + Lit, Dimmed + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0de83a3134..c43bba96bd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -257,6 +257,7 @@ + From dfc53be095bbdfb8bc15ecfbacc84039922a86c4 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 7 Feb 2017 13:02:56 -0400 Subject: [PATCH 03/43] Further work on the progress graph, column states moved to an enum, SongProgressGraphColumnState -> ColumnState, graph can resize dynamically --- .../Graphics/UserInterface/SongProgressBar.cs | 2 + .../UserInterface/SongProgressGraph.cs | 69 ++++++++++++------- .../UserInterface/SongProgressGraphColumn.cs | 8 +-- 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/SongProgressBar.cs b/osu.Game/Graphics/UserInterface/SongProgressBar.cs index 1c837a980f..95c53bdd5e 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressBar.cs +++ b/osu.Game/Graphics/UserInterface/SongProgressBar.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Framework.Graphics.Primitives; +using OpenTK; namespace osu.Game.Graphics.UserInterface { @@ -119,6 +120,7 @@ namespace osu.Game.Graphics.UserInterface Anchor = Anchor.BottomRight, Width = 2, Height = bar_height + graph_height, + Position = new Vector2(2, 0), Children = new Drawable[] { new Box diff --git a/osu.Game/Graphics/UserInterface/SongProgressGraph.cs b/osu.Game/Graphics/UserInterface/SongProgressGraph.cs index 4e03f0a906..27f60992c0 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressGraph.cs +++ b/osu.Game/Graphics/UserInterface/SongProgressGraph.cs @@ -3,12 +3,14 @@ using System; using System.Collections.Generic; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics; namespace osu.Game.Graphics.UserInterface { public class SongProgressGraph : BufferedContainer { private List columns = new List(); + private float lastDrawWidth; public override bool HandleInput => false; @@ -24,38 +26,55 @@ namespace osu.Game.Graphics.UserInterface if (value == progress) return; progress = value; - for (int i = 0; i < columns.Count; i++) - { - columns[i].State = i <= (columns.Count * progress) ? SongProgressGraphColumnState.Lit : SongProgressGraphColumnState.Dimmed; - } - - ForceRedraw(); + redrawProgress(); } } + private void redrawProgress() + { + for (int i = 0; i < columns.Count; i++) + { + columns[i].State = i <= (columns.Count * progress) ? ColumnState.Lit : ColumnState.Dimmed; + } + + ForceRedraw(); + } + + private void recreateGraph() + { + RemoveAll(delegate { return true; }, true); + columns.RemoveAll(delegate { return true; }); + + // Random filled values used for testing + var random = new Random(); + for (int column = 0; column < DrawWidth; column += 3) + { + columns.Add(new SongProgressGraphColumn + { + Position = new Vector2(column + 1, 0), + Filled = random.Next(1, 11), + State = ColumnState.Dimmed + }); + + Add(columns[columns.Count - 1]); + } + + redrawProgress(); + } + + protected override void Update() + { + base.Update(); + + if (DrawWidth == lastDrawWidth) return; + recreateGraph(); + lastDrawWidth = DrawWidth; + } + public SongProgressGraph() { CacheDrawnFrameBuffer = true; PixelSnapping = true; - - Margin = new MarginPadding - { - Left = 1, - Right = 1 - }; - - var random = new Random(); - for (int column = 0; column < 1200; column += 3) - { - columns.Add(new SongProgressGraphColumn - { - Position = new Vector2(column, 0), - Filled = random.Next(1, 11), - State = SongProgressGraphColumnState.Dimmed - }); - - Add(columns[columns.Count - 1]); - } } } } diff --git a/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs b/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs index c14e0ba634..7bf1169641 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs +++ b/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs @@ -30,8 +30,8 @@ namespace osu.Game.Graphics.UserInterface } } - private SongProgressGraphColumnState state; - public SongProgressGraphColumnState State + private ColumnState state; + public ColumnState State { get { @@ -42,7 +42,7 @@ namespace osu.Game.Graphics.UserInterface if (value == state) return; state = value; - fillActive(value == SongProgressGraphColumnState.Lit ? lit_colour : dimmed_colour); + fillActive(value == ColumnState.Lit ? lit_colour : dimmed_colour); } } @@ -74,7 +74,7 @@ namespace osu.Game.Graphics.UserInterface } } - public enum SongProgressGraphColumnState + public enum ColumnState { Lit, Dimmed } From 02ddaf336e9d94e151c6c6d3228262651578c1e4 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 7 Feb 2017 13:26:17 -0400 Subject: [PATCH 04/43] Added license headers --- osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs | 5 ++++- osu.Game/Graphics/UserInterface/SongProgressBar.cs | 5 ++++- osu.Game/Graphics/UserInterface/SongProgressGraph.cs | 5 ++++- osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs index dbb9ad0e49..d8696db680 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; using OpenTK.Graphics; using osu.Game.Graphics.UserInterface; using osu.Framework.Graphics; diff --git a/osu.Game/Graphics/UserInterface/SongProgressBar.cs b/osu.Game/Graphics/UserInterface/SongProgressBar.cs index 95c53bdd5e..14f57d17d2 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressBar.cs +++ b/osu.Game/Graphics/UserInterface/SongProgressBar.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.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; diff --git a/osu.Game/Graphics/UserInterface/SongProgressGraph.cs b/osu.Game/Graphics/UserInterface/SongProgressGraph.cs index 27f60992c0..deaab3cc74 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressGraph.cs +++ b/osu.Game/Graphics/UserInterface/SongProgressGraph.cs @@ -1,4 +1,7 @@ -using OpenTK; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; using System; using System.Collections.Generic; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs b/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs index 7bf1169641..cb7af44c0b 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs +++ b/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs @@ -1,4 +1,7 @@ -using OpenTK; +// 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 System.Collections.Generic; using osu.Framework.Graphics; From 50f93bc2153e1e6875bdf9e4727a74eb58481097 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 8 Feb 2017 16:22:31 -0400 Subject: [PATCH 05/43] Refactoring to SongProgress in osu.Game.Screens.Play, moving out progress bar into it's own class --- ...ProgressBar.cs => TestCaseSongProgress.cs} | 10 +- .../osu.Desktop.VisualTests.csproj | 2 +- .../Graphics/UserInterface/SongProgressBar.cs | 158 ------------------ osu.Game/Screens/Play/SongProgress.cs | 113 +++++++++++++ osu.Game/Screens/Play/SongProgressBar.cs | 15 ++ .../Play}/SongProgressGraph.cs | 13 +- .../Play}/SongProgressGraphColumn.cs | 5 +- osu.Game/osu.Game.csproj | 7 +- 8 files changed, 148 insertions(+), 175 deletions(-) rename osu.Desktop.VisualTests/Tests/{TestCaseSongProgressBar.cs => TestCaseSongProgress.cs} (74%) delete mode 100644 osu.Game/Graphics/UserInterface/SongProgressBar.cs create mode 100644 osu.Game/Screens/Play/SongProgress.cs create mode 100644 osu.Game/Screens/Play/SongProgressBar.cs rename osu.Game/{Graphics/UserInterface => Screens/Play}/SongProgressGraph.cs (83%) rename osu.Game/{Graphics/UserInterface => Screens/Play}/SongProgressGraphColumn.cs (91%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs similarity index 74% rename from osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs rename to osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index d8696db680..2f9183bf65 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgressBar.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -3,7 +3,7 @@ using System; using OpenTK.Graphics; -using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Play; using osu.Framework.Graphics; using osu.Framework.GameModes.Testing; using osu.Framework.Graphics.Sprites; @@ -12,11 +12,11 @@ using osu.Framework.Graphics.Colour; namespace osu.Desktop.VisualTests { - public class TestCaseSongProgressBar : TestCase + public class TestCaseSongProgress : TestCase { - public override string Name => @"SongProgressBar"; + public override string Name => @"Song Progress"; - public override string Description => @"Tests the song progress bar"; + public override string Description => @"With real data"; public override void Reset() { @@ -27,7 +27,7 @@ namespace osu.Desktop.VisualTests ColourInfo = ColourInfo.GradientVertical(Color4.WhiteSmoke, Color4.Gray), RelativeSizeAxes = Framework.Graphics.Axes.Both, }); - Add(new SongProgressBar + Add(new SongProgress { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 1619c18e4c..b9c092b12a 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -188,7 +188,7 @@ - + diff --git a/osu.Game/Graphics/UserInterface/SongProgressBar.cs b/osu.Game/Graphics/UserInterface/SongProgressBar.cs deleted file mode 100644 index 14f57d17d2..0000000000 --- a/osu.Game/Graphics/UserInterface/SongProgressBar.cs +++ /dev/null @@ -1,158 +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.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; -using osu.Framework.Graphics.Primitives; -using OpenTK; - -namespace osu.Game.Graphics.UserInterface -{ - public class SongProgressBar : Container - { - private const int bar_height = 5; - private const int graph_height = 34; - private const int handle_height = 25; - private const int handle_width = 14; - private Color4 fill_colour = new Color4(221, 255, 255, 255); - private Color4 glow_colour = new Color4(221, 255, 255, 150); - - private Container fill; - private SongProgressGraph progressGraph; - private WorkingBeatmap current; - - [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) - { - current = osuGame.Beatmap.Value; - } - - protected override void Update() - { - base.Update(); - - if (current?.TrackLoaded ?? false) - { - fill.Width = (float)(current.Track.CurrentTime / current.Track.Length); - progressGraph.Progress = fill.Width; - } - } - - public SongProgressBar() - { - RelativeSizeAxes = Axes.X; - Height = bar_height + graph_height + handle_height; - - Children = new Drawable[] - { - progressGraph = new SongProgressGraph - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Height = graph_height, - Margin = new MarginPadding - { - Bottom = bar_height - } - }, - new Container - { - Origin = Anchor.BottomRight, - Anchor = Anchor.BottomRight, - RelativeSizeAxes = Axes.X, - Height = bar_height, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = 0.5f - } - } - }, - fill = new Container - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Width = 0, - Height = bar_height + graph_height + handle_height, - Children = new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.Both, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Masking = true, - Children = new Drawable[] - { - new Container - { - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = bar_height, - Masking = true, - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Glow, - Colour = glow_colour, - Radius = 5 - }, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = fill_colour - } - } - } - } - }, - new Container - { - Origin = Anchor.BottomRight, - Anchor = Anchor.BottomRight, - Width = 2, - Height = bar_height + graph_height, - Position = new Vector2(2, 0), - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White - }, - new Container - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.TopCentre, - Width = handle_width, - Height = handle_height, - CornerRadius = 5, - Masking = true, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White - } - } - } - } - } - } - } - }; - } - } -} diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs new file mode 100644 index 0000000000..85ce79dbf0 --- /dev/null +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -0,0 +1,113 @@ +// 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.Game.Beatmaps; +using osu.Game.Screens.Play; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Game.Overlays; + +namespace osu.Game.Screens.Play +{ + public class SongProgress : Container + { + private const int graph_height = 34; + private const int handle_height = 25; + private const int handle_width = 14; + public static readonly Color4 FILL_COLOUR = new Color4(221, 255, 255, 255); + public static readonly Color4 GLOW_COLOUR = new Color4(221, 255, 255, 150); + + private SongProgressBar progress; + private SongProgressGraph graph; + private WorkingBeatmap current; + + [BackgroundDependencyLoader] + private void load(OsuGameBase osuGame) + { + current = osuGame.Beatmap.Value; + } + + protected override void Update() + { + base.Update(); + + if (current?.TrackLoaded ?? false) + { + float currentProgress = (float)(current.Track.CurrentTime / current.Track.Length); + + progress.UpdatePosition(currentProgress); + graph.Progress = (int)(graph.ColumnCount * currentProgress); + } + } + + public SongProgress() + { + RelativeSizeAxes = Axes.X; + Height = SongProgressBar.BAR_HEIGHT + graph_height + handle_height; + + Children = new Drawable[] + { + graph = new SongProgressGraph + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + Height = graph_height, + Margin = new MarginPadding + { + Bottom = SongProgressBar.BAR_HEIGHT + } + }, + progress = new SongProgressBar + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + IsEnabled = true, + SeekRequested = delegate (float position) + { + Framework.Logging.Logger.Log($@"Seeked to {position}"); + } + } + + //handle = new Container + // { + // Origin = Anchor.BottomLeft, + // Anchor = Anchor.BottomLeft, + // Width = 2, + // Height = bar_height + graph_height, + // Position = new Vector2(2, 0), + // Children = new Drawable[] + // { + // new Box + // { + // RelativeSizeAxes = Axes.Both, + // Colour = Color4.White + // }, + // new Container + // { + // Origin = Anchor.BottomCentre, + // Anchor = Anchor.TopCentre, + // Width = handle_width, + // Height = handle_height, + // CornerRadius = 5, + // Masking = true, + // Children = new Drawable[] + // { + // new Box + // { + // RelativeSizeAxes = Axes.Both, + // Colour = Color4.White + // } + // } + // } + // } + // } + }; + } + } +} diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs new file mode 100644 index 0000000000..7b29dd2ac0 --- /dev/null +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -0,0 +1,15 @@ +using System; +using osu.Game.Overlays; +namespace osu.Game.Screens.Play +{ + public class SongProgressBar : DragBar + { + public static readonly int BAR_HEIGHT = 5; + + public SongProgressBar() + { + Colour = SongProgress.FILL_COLOUR; + Height = BAR_HEIGHT; + } + } +} diff --git a/osu.Game/Graphics/UserInterface/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs similarity index 83% rename from osu.Game/Graphics/UserInterface/SongProgressGraph.cs rename to osu.Game/Screens/Play/SongProgressGraph.cs index deaab3cc74..19dc61e0f2 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -8,7 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics; -namespace osu.Game.Graphics.UserInterface +namespace osu.Game.Screens.Play { public class SongProgressGraph : BufferedContainer { @@ -16,9 +16,10 @@ namespace osu.Game.Graphics.UserInterface private float lastDrawWidth; public override bool HandleInput => false; + public int ColumnCount => columns.Count; - private float progress; - public float Progress + private int progress; + public int Progress { get { @@ -37,7 +38,7 @@ namespace osu.Game.Graphics.UserInterface { for (int i = 0; i < columns.Count; i++) { - columns[i].State = i <= (columns.Count * progress) ? ColumnState.Lit : ColumnState.Dimmed; + columns[i].State = i <= progress ? ColumnState.Lit : ColumnState.Dimmed; } ForceRedraw(); @@ -48,7 +49,7 @@ namespace osu.Game.Graphics.UserInterface RemoveAll(delegate { return true; }, true); columns.RemoveAll(delegate { return true; }); - // Random filled values used for testing + // Random filled values used for testing for now var random = new Random(); for (int column = 0; column < DrawWidth; column += 3) { @@ -70,7 +71,7 @@ namespace osu.Game.Graphics.UserInterface base.Update(); if (DrawWidth == lastDrawWidth) return; - recreateGraph(); + //recreateGraph(); lastDrawWidth = DrawWidth; } diff --git a/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs similarity index 91% rename from osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs rename to osu.Game/Screens/Play/SongProgressGraphColumn.cs index cb7af44c0b..892c758bf1 100644 --- a/osu.Game/Graphics/UserInterface/SongProgressGraphColumn.cs +++ b/osu.Game/Screens/Play/SongProgressGraphColumn.cs @@ -4,17 +4,18 @@ using OpenTK; using OpenTK.Graphics; using System.Collections.Generic; +using osu.Game.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -namespace osu.Game.Graphics.UserInterface +namespace osu.Game.Screens.Play { public class SongProgressGraphColumn : Container { private int rows = 11; private Color4 empty_colour = Color4.White.Opacity(50); - private Color4 lit_colour = new Color4(221, 255, 255, 255); + private Color4 lit_colour = SongProgress.FILL_COLOUR; private Color4 dimmed_colour = Color4.White.Opacity(175); private List drawableRows = new List(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c43bba96bd..3f84a9eb80 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -255,9 +255,10 @@ - - - + + + + From 7fea2331812471e8e0df1bf9b92515221934361e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 9 Feb 2017 16:28:40 -0400 Subject: [PATCH 06/43] Removed gradient from test case, modified DragBar to allow access to what's needed in the progress bar, styled the progress bar --- .../Tests/TestCaseSongProgress.cs | 5 -- osu.Game/Overlays/DragBar.cs | 24 +++++--- osu.Game/Screens/Play/SongProgress.cs | 54 ++++------------ osu.Game/Screens/Play/SongProgressBar.cs | 61 +++++++++++++++++-- osu.Game/Screens/Play/SongProgressGraph.cs | 2 +- .../Screens/Play/SongProgressGraphColumn.cs | 1 + 6 files changed, 86 insertions(+), 61 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 2f9183bf65..bd6943bece 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -22,11 +22,6 @@ namespace osu.Desktop.VisualTests { base.Reset(); - Add(new Box - { - ColourInfo = ColourInfo.GradientVertical(Color4.WhiteSmoke, Color4.Gray), - RelativeSizeAxes = Framework.Graphics.Axes.Both, - }); Add(new SongProgress { Anchor = Anchor.BottomCentre, diff --git a/osu.Game/Overlays/DragBar.cs b/osu.Game/Overlays/DragBar.cs index 32a1ed4933..5b1c9c5a37 100644 --- a/osu.Game/Overlays/DragBar.cs +++ b/osu.Game/Overlays/DragBar.cs @@ -11,7 +11,8 @@ namespace osu.Game.Overlays { public class DragBar : Container { - private Box fill; + protected Container fillContainer; + protected Box fill; public Action SeekRequested; private bool isDragging; @@ -24,7 +25,7 @@ namespace osu.Game.Overlays { enabled = value; if (!enabled) - fill.Width = 0; + fillContainer.Width = 0; } } @@ -34,12 +35,19 @@ namespace osu.Game.Overlays Children = new Drawable[] { - fill = new Box() + fillContainer = new Container { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, RelativeSizeAxes = Axes.Both, - Width = 0 + Width = 0, + Children = new Drawable[] + { + fill = new Box + { + RelativeSizeAxes = Axes.Both + } + } } }; } @@ -48,7 +56,7 @@ namespace osu.Game.Overlays { if (isDragging || !IsEnabled) return; - fill.Width = position; + fillContainer.Width = position; } private void seek(InputState state) @@ -56,7 +64,7 @@ namespace osu.Game.Overlays if (!IsEnabled) return; float seekLocation = state.Mouse.Position.X / DrawWidth; SeekRequested?.Invoke(seekLocation); - fill.Width = seekLocation; + fillContainer.Width = seekLocation; } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 85ce79dbf0..7e87df75e5 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -16,9 +16,8 @@ namespace osu.Game.Screens.Play { public class SongProgress : Container { - private const int graph_height = 34; - private const int handle_height = 25; - private const int handle_width = 14; + public static readonly int BAR_HEIGHT = 5; + public static readonly int GRAPH_HEIGHT = 34; public static readonly Color4 FILL_COLOUR = new Color4(221, 255, 255, 255); public static readonly Color4 GLOW_COLOUR = new Color4(221, 255, 255, 150); @@ -40,15 +39,20 @@ namespace osu.Game.Screens.Play { float currentProgress = (float)(current.Track.CurrentTime / current.Track.Length); + progress.IsEnabled = true; progress.UpdatePosition(currentProgress); graph.Progress = (int)(graph.ColumnCount * currentProgress); } + else + { + progress.IsEnabled = false; + } } public SongProgress() { RelativeSizeAxes = Axes.X; - Height = SongProgressBar.BAR_HEIGHT + graph_height + handle_height; + Height = BAR_HEIGHT + GRAPH_HEIGHT + SongProgressBar.HANDLE_SIZE.Y; Children = new Drawable[] { @@ -57,56 +61,22 @@ namespace osu.Game.Screens.Play RelativeSizeAxes = Axes.X, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, - Height = graph_height, + Height = GRAPH_HEIGHT, Margin = new MarginPadding { - Bottom = SongProgressBar.BAR_HEIGHT + Bottom = BAR_HEIGHT } }, progress = new SongProgressBar { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, - IsEnabled = true, SeekRequested = delegate (float position) { - Framework.Logging.Logger.Log($@"Seeked to {position}"); + current?.Track?.Seek(current.Track.Length * position); + current?.Track?.Start(); } } - - //handle = new Container - // { - // Origin = Anchor.BottomLeft, - // Anchor = Anchor.BottomLeft, - // Width = 2, - // Height = bar_height + graph_height, - // Position = new Vector2(2, 0), - // Children = new Drawable[] - // { - // new Box - // { - // RelativeSizeAxes = Axes.Both, - // Colour = Color4.White - // }, - // new Container - // { - // Origin = Anchor.BottomCentre, - // Anchor = Anchor.TopCentre, - // Width = handle_width, - // Height = handle_height, - // CornerRadius = 5, - // Masking = true, - // Children = new Drawable[] - // { - // new Box - // { - // RelativeSizeAxes = Axes.Both, - // Colour = Color4.White - // } - // } - // } - // } - // } }; } } diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 7b29dd2ac0..9c6d46b79c 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -1,15 +1,66 @@ -using System; -using osu.Game.Overlays; +// 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.Game.Overlays; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Primitives; + namespace osu.Game.Screens.Play { public class SongProgressBar : DragBar { - public static readonly int BAR_HEIGHT = 5; + public static readonly Vector2 HANDLE_SIZE = new Vector2(14, 25); + + private Container handle; public SongProgressBar() { - Colour = SongProgress.FILL_COLOUR; - Height = BAR_HEIGHT; + fill.Colour = SongProgress.FILL_COLOUR; + Height = SongProgress.BAR_HEIGHT; + + Add(new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.5f, + Depth = 1 + }); + fillContainer.Add(handle = new Container + { + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, + Width = 2, + Height = SongProgress.BAR_HEIGHT + SongProgress.GRAPH_HEIGHT, + Colour = Color4.White, + Position = new Vector2(2, 0), + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + }, + new Container + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, + Size = HANDLE_SIZE, + CornerRadius = 5, + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White + } + } + } + } + }); } } } diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 19dc61e0f2..20a7608ffe 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -71,7 +71,7 @@ namespace osu.Game.Screens.Play base.Update(); if (DrawWidth == lastDrawWidth) return; - //recreateGraph(); + recreateGraph(); lastDrawWidth = DrawWidth; } diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs index 892c758bf1..894e7009c2 100644 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ b/osu.Game/Screens/Play/SongProgressGraphColumn.cs @@ -8,6 +8,7 @@ using osu.Game.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; namespace osu.Game.Screens.Play { From 4d7766b92bced8d96af023271e0c1420d9a68dc5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 9 Feb 2017 18:51:05 -0400 Subject: [PATCH 07/43] Added displaying given values to the graph --- osu.Game/Screens/Play/SongProgress.cs | 20 ++++++++- osu.Game/Screens/Play/SongProgressGraph.cs | 51 ++++++++++++++++++---- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 7e87df75e5..3cbf70b612 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -11,6 +11,8 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Game.Overlays; +using System.Collections.Generic; +using System; namespace osu.Game.Screens.Play { @@ -49,6 +51,11 @@ namespace osu.Game.Screens.Play } } + public void DisplayValues(List values) + { + graph.Values = values; + } + public SongProgress() { RelativeSizeAxes = Axes.X; @@ -77,7 +84,18 @@ namespace osu.Game.Screens.Play current?.Track?.Start(); } } - }; + }; + + // TODO: Remove + var random = new Random(); + + List newValues = new List(); + for (int i = 0; i < 1000; i++) + { + newValues.Add(random.Next(1, 11)); + } + + DisplayValues(newValues); } } } diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 20a7608ffe..13bae892d7 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -2,11 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using System; using System.Collections.Generic; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics; +using System; namespace osu.Game.Screens.Play { @@ -34,6 +32,22 @@ namespace osu.Game.Screens.Play } } + private List calculatedValues = new List(); // values but adjusted to fit the amount of columns + private List values; + public List Values + { + get + { + return values; + } + set + { + if (value == values) return; + values = value; + recreateGraph(); + } + } + private void redrawProgress() { for (int i = 0; i < columns.Count; i++) @@ -44,25 +58,46 @@ namespace osu.Game.Screens.Play ForceRedraw(); } + private void redrawFilled() + { + for (int i = 0; i < ColumnCount; i++) + { + columns[i].Filled = calculatedValues[i]; + } + + ForceRedraw(); + } + + private void recalculateValues() + { + calculatedValues.RemoveAll(delegate { return true; }); + + float step = (float)values.Count / (float)ColumnCount; + + for (float i = 0; i < values.Count; i += step) + { + calculatedValues.Add(values[(int)i]); + } + } + private void recreateGraph() { RemoveAll(delegate { return true; }, true); columns.RemoveAll(delegate { return true; }); - // Random filled values used for testing for now - var random = new Random(); - for (int column = 0; column < DrawWidth; column += 3) + for (int x = 0; x < DrawWidth; x += 3) { columns.Add(new SongProgressGraphColumn { - Position = new Vector2(column + 1, 0), - Filled = random.Next(1, 11), + Position = new Vector2(x + 1, 0), State = ColumnState.Dimmed }); Add(columns[columns.Count - 1]); } + recalculateValues(); + redrawFilled(); redrawProgress(); } From ac6726ee2ea050f1a240191ed1fb85b0e2ae52b8 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 9 Feb 2017 18:56:50 -0400 Subject: [PATCH 08/43] Fixed setting column filled values not updating visually, added gray background to visual test --- osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs | 5 +++++ osu.Game/Screens/Play/SongProgressGraphColumn.cs | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index bd6943bece..36dd789709 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -22,6 +22,11 @@ namespace osu.Desktop.VisualTests { base.Reset(); + Add(new Box + { + Colour = Color4.Gray, + RelativeSizeAxes = Axes.Both + }); Add(new SongProgress { Anchor = Anchor.BottomCentre, diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs index 894e7009c2..b92cf63865 100644 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ b/osu.Game/Screens/Play/SongProgressGraphColumn.cs @@ -32,6 +32,8 @@ namespace osu.Game.Screens.Play { if (value == filled) return; filled = value; + + fillActive(); } } @@ -47,15 +49,17 @@ namespace osu.Game.Screens.Play if (value == state) return; state = value; - fillActive(value == ColumnState.Lit ? lit_colour : dimmed_colour); + fillActive(); } } - private void fillActive(Color4 color) + private void fillActive() { + Color4 colour = State == ColumnState.Lit ? lit_colour : dimmed_colour; + for (int i = 0; i < drawableRows.Count; i++) { - drawableRows[i].Colour = i <= Filled ? color : empty_colour; + drawableRows[i].Colour = i <= Filled ? colour : empty_colour; } } From 843b58c8f4a12dd8ba400a9dbe37c1890572b0c4 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 9 Feb 2017 19:08:23 -0400 Subject: [PATCH 09/43] Moved random graph values to test case, added null handling for graph values --- .../Tests/TestCaseSongProgress.cs | 16 ++++++++++++++-- osu.Game/Screens/Play/SongProgress.cs | 13 +------------ osu.Game/Screens/Play/SongProgressGraph.cs | 10 ++++++++++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 36dd789709..6fa91a46c4 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -9,15 +9,17 @@ using osu.Framework.GameModes.Testing; using osu.Framework.Graphics.Sprites; using osu.Framework.GameModes.Testing; using osu.Framework.Graphics.Colour; +using System.Collections.Generic; namespace osu.Desktop.VisualTests { public class TestCaseSongProgress : TestCase { public override string Name => @"Song Progress"; - public override string Description => @"With real data"; + private SongProgress progress; + public override void Reset() { base.Reset(); @@ -27,12 +29,22 @@ namespace osu.Desktop.VisualTests Colour = Color4.Gray, RelativeSizeAxes = Axes.Both }); - Add(new SongProgress + Add(progress = new SongProgress { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.X }); + + var random = new Random(); + + List newValues = new List(); + for (int i = 0; i < 1000; i++) + { + newValues.Add(random.Next(1, 11)); + } + + progress.DisplayValues(newValues); } } } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 3cbf70b612..8568d30d38 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -84,18 +84,7 @@ namespace osu.Game.Screens.Play current?.Track?.Start(); } } - }; - - // TODO: Remove - var random = new Random(); - - List newValues = new List(); - for (int i = 0; i < 1000; i++) - { - newValues.Add(random.Next(1, 11)); - } - - DisplayValues(newValues); + }; } } } diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 13bae892d7..06810c7d07 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -72,6 +72,16 @@ namespace osu.Game.Screens.Play { calculatedValues.RemoveAll(delegate { return true; }); + if (values == null) + { + for (float i = 0; i < ColumnCount; i++) + { + calculatedValues.Add(0); + } + + return; + } + float step = (float)values.Count / (float)ColumnCount; for (float i = 0; i < values.Count; i += step) From 0327c46d36df0d1950c54536262ff38988712480 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 9 Feb 2017 19:29:12 -0400 Subject: [PATCH 10/43] Fixed columns not being able to have zero fill --- osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs | 2 +- osu.Game/Screens/Play/SongProgressGraph.cs | 3 +++ osu.Game/Screens/Play/SongProgressGraphColumn.cs | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 6fa91a46c4..1f0b993fee 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -41,7 +41,7 @@ namespace osu.Desktop.VisualTests List newValues = new List(); for (int i = 0; i < 1000; i++) { - newValues.Add(random.Next(1, 11)); + newValues.Add(random.Next(0, 11)); } progress.DisplayValues(newValues); diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 06810c7d07..921b630db3 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -70,6 +70,9 @@ namespace osu.Game.Screens.Play private void recalculateValues() { + // Resizes values to fit the amount of columns and stores it in calculatedValues + // Defaults to all zeros if values is null + calculatedValues.RemoveAll(delegate { return true; }); if (values == null) diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs index b92cf63865..95fcf5ad36 100644 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ b/osu.Game/Screens/Play/SongProgressGraphColumn.cs @@ -59,7 +59,14 @@ namespace osu.Game.Screens.Play for (int i = 0; i < drawableRows.Count; i++) { - drawableRows[i].Colour = i <= Filled ? colour : empty_colour; + if (Filled == 0) // i <= Filled doesn't work for zero fill + { + drawableRows[i].Colour = empty_colour; + } + else + { + drawableRows[i].Colour = i <= Filled ? colour : empty_colour; + } } } From c61052d62e1215b79ed67ba98ee3ca2ed9f28b56 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 9 Feb 2017 20:12:15 -0400 Subject: [PATCH 11/43] Added toggling the progress bar, added buttons to the visual test --- .../Tests/TestCaseSongProgress.cs | 13 ++++++++----- osu.Game/Screens/Play/SongProgress.cs | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 1f0b993fee..9706348494 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -24,11 +24,6 @@ namespace osu.Desktop.VisualTests { base.Reset(); - Add(new Box - { - Colour = Color4.Gray, - RelativeSizeAxes = Axes.Both - }); Add(progress = new SongProgress { Anchor = Anchor.BottomCentre, @@ -36,6 +31,14 @@ namespace osu.Desktop.VisualTests RelativeSizeAxes = Axes.X }); + AddButton("Toggle Bar", progress.ToggleVisibility); + AddButton("New Values", displayNewValues); + + displayNewValues(); + } + + private void displayNewValues() + { var random = new Random(); List newValues = new List(); diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 8568d30d38..55888d72f3 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -13,15 +13,17 @@ using osu.Framework.Graphics.Primitives; using osu.Game.Overlays; using System.Collections.Generic; using System; +using osu.Framework.Graphics.Transformations; namespace osu.Game.Screens.Play { - public class SongProgress : Container + public class SongProgress : OverlayContainer { public static readonly int BAR_HEIGHT = 5; public static readonly int GRAPH_HEIGHT = 34; public static readonly Color4 FILL_COLOUR = new Color4(221, 255, 255, 255); public static readonly Color4 GLOW_COLOUR = new Color4(221, 255, 255, 150); + private float progress_transition_duration = 100; private SongProgressBar progress; private SongProgressGraph graph; @@ -56,6 +58,18 @@ namespace osu.Game.Screens.Play graph.Values = values; } + protected override void PopIn() + { + progress.FadeTo(1f, progress_transition_duration, EasingTypes.In); + MoveTo(Vector2.Zero, progress_transition_duration, EasingTypes.In); + } + + protected override void PopOut() + { + progress.FadeTo(0f, progress_transition_duration, EasingTypes.In); + MoveTo(new Vector2(0f, BAR_HEIGHT), progress_transition_duration, EasingTypes.In); + } + public SongProgress() { RelativeSizeAxes = Axes.X; From 536925c77a51631ee8e3c69d99716f71cae3d43e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 2 Mar 2017 09:15:53 -0400 Subject: [PATCH 12/43] Comply to naming conventions --- osu.Game/Overlays/DragBar.cs | 14 +++++++------- osu.Game/Screens/Play/SongProgressBar.cs | 4 ++-- osu.Game/Screens/Play/SongProgressGraphColumn.cs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/DragBar.cs b/osu.Game/Overlays/DragBar.cs index 44106d387a..908616ed6a 100644 --- a/osu.Game/Overlays/DragBar.cs +++ b/osu.Game/Overlays/DragBar.cs @@ -11,8 +11,8 @@ namespace osu.Game.Overlays { public class DragBar : Container { - protected Container fillContainer; - protected Box fill; + protected Container FillContainer; + protected Box Fill; public Action SeekRequested; private bool isDragging; @@ -25,7 +25,7 @@ namespace osu.Game.Overlays { enabled = value; if (!enabled) - fillContainer.Width = 0; + FillContainer.Width = 0; } } @@ -35,7 +35,7 @@ namespace osu.Game.Overlays Children = new Drawable[] { - fillContainer = new Container + FillContainer = new Container { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, @@ -43,7 +43,7 @@ namespace osu.Game.Overlays Width = 0, Children = new Drawable[] { - fill = new Box + Fill = new Box { RelativeSizeAxes = Axes.Both } @@ -56,7 +56,7 @@ namespace osu.Game.Overlays { if (isDragging || !IsEnabled) return; - fillContainer.Width = position; + FillContainer.Width = position; } private void seek(InputState state) @@ -64,7 +64,7 @@ namespace osu.Game.Overlays if (!IsEnabled) return; float seekLocation = state.Mouse.Position.X / DrawWidth; SeekRequested?.Invoke(seekLocation); - fillContainer.Width = seekLocation; + FillContainer.Width = seekLocation; } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 9c6d46b79c..dc3a761742 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Play public SongProgressBar() { - fill.Colour = SongProgress.FILL_COLOUR; + Fill.Colour = SongProgress.FILL_COLOUR; Height = SongProgress.BAR_HEIGHT; Add(new Box @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Play Alpha = 0.5f, Depth = 1 }); - fillContainer.Add(handle = new Container + FillContainer.Add(handle = new Container { Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs index a4a647f60c..e676007dc2 100644 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ b/osu.Game/Screens/Play/SongProgressGraphColumn.cs @@ -13,9 +13,9 @@ namespace osu.Game.Screens.Play public class SongProgressGraphColumn : Container { private int rows = 11; - private Color4 empty_colour = Color4.White.Opacity(50); - private Color4 lit_colour = SongProgress.FILL_COLOUR; - private Color4 dimmed_colour = Color4.White.Opacity(175); + private readonly Color4 empty_colour = Color4.White.Opacity(50); + private readonly Color4 lit_colour = SongProgress.FILL_COLOUR; + private readonly Color4 dimmed_colour = Color4.White.Opacity(175); private List drawableRows = new List(); From 1eeb4aa8759df15f3f9a2a8500812fcd07a76769 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 2 Mar 2017 09:21:16 -0400 Subject: [PATCH 13/43] Missed some --- osu.Game/Screens/Play/SongProgressGraphColumn.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs index e676007dc2..6a9be707a5 100644 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ b/osu.Game/Screens/Play/SongProgressGraphColumn.cs @@ -13,9 +13,9 @@ namespace osu.Game.Screens.Play public class SongProgressGraphColumn : Container { private int rows = 11; - private readonly Color4 empty_colour = Color4.White.Opacity(50); - private readonly Color4 lit_colour = SongProgress.FILL_COLOUR; - private readonly Color4 dimmed_colour = Color4.White.Opacity(175); + private readonly Color4 emptyColour = Color4.White.Opacity(50); + private readonly Color4 litColour = SongProgress.FILL_COLOUR; + private readonly Color4 dimmedColour = Color4.White.Opacity(175); private List drawableRows = new List(); From 223962121ed208f6bb5b45322e6de9af5bcb8ee2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 2 Mar 2017 09:26:29 -0400 Subject: [PATCH 14/43] Refactor not just rename --- osu.Game/Screens/Play/SongProgressGraphColumn.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs index 6a9be707a5..a296779359 100644 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ b/osu.Game/Screens/Play/SongProgressGraphColumn.cs @@ -53,17 +53,17 @@ namespace osu.Game.Screens.Play private void fillActive() { - Color4 colour = State == ColumnState.Lit ? lit_colour : dimmed_colour; + Color4 colour = State == ColumnState.Lit ? litColour : dimmedColour; for (int i = 0; i < drawableRows.Count; i++) { if (Filled == 0) // i <= Filled doesn't work for zero fill { - drawableRows[i].Colour = empty_colour; + drawableRows[i].Colour = emptyColour; } else { - drawableRows[i].Colour = i <= Filled ? colour : empty_colour; + drawableRows[i].Colour = i <= Filled ? colour : emptyColour; } } } From 340ddb59cd55e8197c631c05f9d734274ee8a1b7 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 22 Mar 2017 08:54:21 -0300 Subject: [PATCH 15/43] License headers --- osu.Game/Screens/Play/SongProgress.cs | 2 +- osu.Game/Screens/Play/SongProgressBar.cs | 110 +++++++++++------------ 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 261b1d0a9a..54e3cc5730 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Play public static readonly int GRAPH_HEIGHT = 34; public static readonly Color4 FILL_COLOUR = new Color4(221, 255, 255, 255); public static readonly Color4 GLOW_COLOUR = new Color4(221, 255, 255, 150); - private float progress_transition_duration = 100; + private const float progress_transition_duration = 100; private SongProgressBar progress; private SongProgressGraph graph; diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index dc3a761742..aa0e2a4bb0 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -1,66 +1,66 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; +// 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.Game.Overlays; -using osu.Framework.Graphics.Containers; +using osu.Game.Overlays; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Primitives; -namespace osu.Game.Screens.Play -{ - public class SongProgressBar : DragBar - { - public static readonly Vector2 HANDLE_SIZE = new Vector2(14, 25); - - private Container handle; - - public SongProgressBar() - { - Fill.Colour = SongProgress.FILL_COLOUR; - Height = SongProgress.BAR_HEIGHT; - - Add(new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = 0.5f, - Depth = 1 - }); +namespace osu.Game.Screens.Play +{ + public class SongProgressBar : DragBar + { + public static readonly Vector2 HANDLE_SIZE = new Vector2(14, 25); + + private Container handle; + + public SongProgressBar() + { + Fill.Colour = SongProgress.FILL_COLOUR; + Height = SongProgress.BAR_HEIGHT; + + Add(new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.5f, + Depth = 1 + }); FillContainer.Add(handle = new Container { Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, Width = 2, - Height = SongProgress.BAR_HEIGHT + SongProgress.GRAPH_HEIGHT, - Colour = Color4.White, + Height = SongProgress.BAR_HEIGHT + SongProgress.GRAPH_HEIGHT, + Colour = Color4.White, Position = new Vector2(2, 0), - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - }, - new Container - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.TopCentre, - Size = HANDLE_SIZE, - CornerRadius = 5, - Masking = true, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White - } - } - } - } - }); - } - } -} + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + }, + new Container + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, + Size = HANDLE_SIZE, + CornerRadius = 5, + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White + } + } + } + } + }); + } + } +} From 333008e26d50ff0853c6dad981d20002ed4abd84 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 22 Mar 2017 08:59:44 -0300 Subject: [PATCH 16/43] Formatting --- osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs | 2 +- osu.Game/Screens/Play/SongProgressBar.cs | 5 +---- osu.Game/Screens/Play/SongProgressGraph.cs | 6 ++---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 037bc0754f..9038e198cb 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -11,7 +11,7 @@ namespace osu.Desktop.VisualTests.Tests { internal class TestCaseSongProgress : TestCase { - public override string Description => @"With real data"; + public override string Description => @"With (half)real data"; private SongProgress progress; diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index aa0e2a4bb0..18454c7200 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -7,7 +7,6 @@ using osu.Game.Overlays; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Primitives; namespace osu.Game.Screens.Play { @@ -15,8 +14,6 @@ namespace osu.Game.Screens.Play { public static readonly Vector2 HANDLE_SIZE = new Vector2(14, 25); - private Container handle; - public SongProgressBar() { Fill.Colour = SongProgress.FILL_COLOUR; @@ -29,7 +26,7 @@ namespace osu.Game.Screens.Play Alpha = 0.5f, Depth = 1 }); - FillContainer.Add(handle = new Container + FillContainer.Add(new Container { Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index f4bd21ae45..20934fab17 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -4,7 +4,6 @@ using OpenTK; using System.Collections.Generic; using osu.Framework.Graphics.Containers; -using System; namespace osu.Game.Screens.Play { @@ -85,8 +84,7 @@ namespace osu.Game.Screens.Play return; } - float step = (float)values.Count / (float)ColumnCount; - + float step = values.Count / ColumnCount; for (float i = 0; i < values.Count; i += step) { calculatedValues.Add(values[(int)i]); @@ -103,7 +101,7 @@ namespace osu.Game.Screens.Play columns.Add(new SongProgressGraphColumn { Position = new Vector2(x + 1, 0), - State = ColumnState.Dimmed + State = ColumnState.Dimmed, }); Add(columns[columns.Count - 1]); From 818bdd8e88c86a0a3ce08efae42d467c22e3ad6a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 22 Mar 2017 09:27:04 -0300 Subject: [PATCH 17/43] SongProgress in HudOverlay --- .../Tests/TestCaseSongProgress.cs | 7 +++---- osu.Game/Modes/UI/HudOverlay.cs | 3 +++ osu.Game/Modes/UI/StandardHudOverlay.cs | 12 ++++++++++++ osu.Game/Screens/Play/Player.cs | 2 ++ osu.Game/Screens/Play/SongProgress.cs | 4 ++-- osu.Game/Screens/Play/SongProgressGraph.cs | 8 ++++---- osu.Game/Screens/Play/SongProgressGraphColumn.cs | 7 ++++--- 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 9038e198cb..976e4a2431 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using osu.Framework.Graphics; +using osu.Framework.MathUtils; using osu.Framework.Screens.Testing; using osu.Game.Screens.Play; @@ -34,15 +35,13 @@ namespace osu.Desktop.VisualTests.Tests private void displayNewValues() { - var random = new Random(); - List newValues = new List(); for (int i = 0; i < 1000; i++) { - newValues.Add(random.Next(0, 11)); + newValues.Add(RNG.Next(0, 11)); } - progress.DisplayValues(newValues); + progress.DisplayValues(newValues.ToArray()); } } } diff --git a/osu.Game/Modes/UI/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs index 4b454797ce..30e6c6e737 100644 --- a/osu.Game/Modes/UI/HudOverlay.cs +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -19,6 +19,7 @@ namespace osu.Game.Modes.UI public readonly ScoreCounter ScoreCounter; public readonly PercentageCounter AccuracyCounter; public readonly HealthDisplay HealthDisplay; + public readonly SongProgress Progress; private Bindable showKeyCounter; @@ -27,6 +28,7 @@ namespace osu.Game.Modes.UI protected abstract PercentageCounter CreateAccuracyCounter(); protected abstract ScoreCounter CreateScoreCounter(); protected abstract HealthDisplay CreateHealthDisplay(); + protected abstract SongProgress CreateProgress(); protected HudOverlay() { @@ -39,6 +41,7 @@ namespace osu.Game.Modes.UI ScoreCounter = CreateScoreCounter(), AccuracyCounter = CreateAccuracyCounter(), HealthDisplay = CreateHealthDisplay(), + Progress = CreateProgress(), }; } diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index f77191adf7..d86498208a 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -50,5 +50,17 @@ namespace osu.Game.Modes.UI Position = new Vector2(0, 30), Margin = new MarginPadding { Right = 5 }, }; + + protected override SongProgress CreateProgress() + { + var p = new SongProgress() + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + }; + + return p; + } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index bd54e6e263..31f7d3c0b7 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -125,6 +125,7 @@ namespace osu.Game.Screens.Play Depth = -1, OnResume = delegate { + hudOverlay.Progress.State = Visibility.Visible; Delay(400); Schedule(Resume); }, @@ -212,6 +213,7 @@ namespace osu.Game.Screens.Play { lastPauseActionTime = Time.Current; hudOverlay.KeyCounter.IsCounting = true; + hudOverlay.Progress.State = Visibility.Hidden; pauseOverlay.Hide(); sourceClock.Start(); IsPaused = false; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 54e3cc5730..52b45a9fc8 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load(OsuGameBase osuGame) { - current = osuGame.Beatmap.Value; + current = osuGame.Beatmap.Value; } protected override void Update() @@ -49,7 +49,7 @@ namespace osu.Game.Screens.Play } } - public void DisplayValues(List values) + public void DisplayValues(int[] values) { graph.Values = values; } diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 20934fab17..d0caa1201f 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -32,8 +32,8 @@ namespace osu.Game.Screens.Play } private List calculatedValues = new List(); // values but adjusted to fit the amount of columns - private List values; - public List Values + private int[] values; + public int[] Values { get { @@ -84,8 +84,8 @@ namespace osu.Game.Screens.Play return; } - float step = values.Count / ColumnCount; - for (float i = 0; i < values.Count; i += step) + float step = values.Length / (float)ColumnCount; + for (float i = 0; i < values.Length; i += step) { calculatedValues.Add(values[(int)i]); } diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs index 9d7dd3bc34..514fdcf82a 100644 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ b/osu.Game/Screens/Play/SongProgressGraphColumn.cs @@ -12,8 +12,8 @@ namespace osu.Game.Screens.Play { public class SongProgressGraphColumn : Container { - private int rows = 11; - private readonly Color4 emptyColour = Color4.White.Opacity(50); + private readonly int rows = 11; + private readonly Color4 emptyColour = Color4.White.Opacity(100); private readonly Color4 litColour = SongProgress.FILL_COLOUR; private readonly Color4 dimmedColour = Color4.White.Opacity(175); @@ -90,6 +90,7 @@ namespace osu.Game.Screens.Play public enum ColumnState { - Lit, Dimmed + Lit, + Dimmed } } From 5ebbc2c0ba46cc02c1a273d67a3a0b418bf466bf Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 22 Mar 2017 09:33:01 -0300 Subject: [PATCH 18/43] Formatting --- osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs | 1 - osu.Game/Screens/Play/SongProgress.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 976e4a2431..3dce7034b1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.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 System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.MathUtils; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 52b45a9fc8..c10565e7e0 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -8,7 +8,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using System.Collections.Generic; using osu.Framework.Graphics.Transforms; namespace osu.Game.Screens.Play From 8703e5a9623611028f82d85df54e52661aaaa195 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 22 Mar 2017 09:35:08 -0300 Subject: [PATCH 19/43] More formatting --- osu.Game/Modes/UI/StandardHudOverlay.cs | 127 ++++++++++++------------ 1 file changed, 61 insertions(+), 66 deletions(-) diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index d86498208a..7ecffc41d0 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -1,66 +1,61 @@ -// 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.Primitives; -using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Play; - -namespace osu.Game.Modes.UI -{ - public class StandardHudOverlay : HudOverlay - { - protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Position = new Vector2(0, 65), - TextSize = 20, - Margin = new MarginPadding { Right = 5 }, - }; - - protected override ComboCounter CreateComboCounter() => new StandardComboCounter - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - }; - - protected override HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay - { - Size = new Vector2(1, 5), - RelativeSizeAxes = Axes.X, - Margin = new MarginPadding { Top = 20 } - }; - - protected override KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection - { - IsCounting = true, - FadeTime = 50, - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Margin = new MarginPadding(10), - }; - - protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6) - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - TextSize = 40, - Position = new Vector2(0, 30), - Margin = new MarginPadding { Right = 5 }, - }; - - protected override SongProgress CreateProgress() - { - var p = new SongProgress() - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - }; - - return p; - } - } -} +// 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.Primitives; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Play; + +namespace osu.Game.Modes.UI +{ + public class StandardHudOverlay : HudOverlay + { + protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Position = new Vector2(0, 65), + TextSize = 20, + Margin = new MarginPadding { Right = 5 }, + }; + + protected override ComboCounter CreateComboCounter() => new StandardComboCounter + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }; + + protected override HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay + { + Size = new Vector2(1, 5), + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Top = 20 } + }; + + protected override KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection + { + IsCounting = true, + FadeTime = 50, + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Margin = new MarginPadding(10), + }; + + protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + TextSize = 40, + Position = new Vector2(0, 30), + Margin = new MarginPadding { Right = 5 }, + }; + + protected override SongProgress CreateProgress() => new SongProgress() + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + }; + } +} From e4af30bd154c263de860b9bbacbb6dd932ebb7ec Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 22 Mar 2017 09:38:40 -0300 Subject: [PATCH 20/43] Line endings --- osu.Game/Modes/UI/StandardHudOverlay.cs | 122 ++++++++++++------------ 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index 7ecffc41d0..63f978f66a 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -1,61 +1,61 @@ -// 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.Primitives; -using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Play; - -namespace osu.Game.Modes.UI -{ - public class StandardHudOverlay : HudOverlay - { - protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Position = new Vector2(0, 65), - TextSize = 20, - Margin = new MarginPadding { Right = 5 }, - }; - - protected override ComboCounter CreateComboCounter() => new StandardComboCounter - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - }; - - protected override HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay - { - Size = new Vector2(1, 5), - RelativeSizeAxes = Axes.X, - Margin = new MarginPadding { Top = 20 } - }; - - protected override KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection - { - IsCounting = true, - FadeTime = 50, - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Margin = new MarginPadding(10), - }; - - protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6) - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - TextSize = 40, - Position = new Vector2(0, 30), - Margin = new MarginPadding { Right = 5 }, - }; - - protected override SongProgress CreateProgress() => new SongProgress() - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - }; - } -} +// 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.Primitives; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Play; + +namespace osu.Game.Modes.UI +{ + public class StandardHudOverlay : HudOverlay + { + protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Position = new Vector2(0, 65), + TextSize = 20, + Margin = new MarginPadding { Right = 5 }, + }; + + protected override ComboCounter CreateComboCounter() => new StandardComboCounter + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }; + + protected override HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay + { + Size = new Vector2(1, 5), + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Top = 20 } + }; + + protected override KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection + { + IsCounting = true, + FadeTime = 50, + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Margin = new MarginPadding(10), + }; + + protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + TextSize = 40, + Position = new Vector2(0, 30), + Margin = new MarginPadding { Right = 5 }, + }; + + protected override SongProgress CreateProgress() => new SongProgress() + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + }; + } +} From b5d661b53a2dd02deb3c83ce1a516d8e2104496a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 18:20:00 +0900 Subject: [PATCH 21/43] some fixing and restyling. --- .../Tests/TestCaseSongProgress.cs | 4 +- osu.Game/Screens/Play/SongProgress.cs | 5 +- osu.Game/Screens/Play/SongProgressBar.cs | 2 +- osu.Game/Screens/Play/SongProgressGraph.cs | 8 +-- .../Screens/Play/SongProgressGraphColumn.cs | 50 +++++++++++-------- 5 files changed, 38 insertions(+), 31 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 3dce7034b1..07648d3428 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -21,8 +21,8 @@ namespace osu.Desktop.VisualTests.Tests Add(progress = new SongProgress { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X }); diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index c10565e7e0..9629d8d1e7 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -15,7 +15,6 @@ namespace osu.Game.Screens.Play public class SongProgress : OverlayContainer { public static readonly int BAR_HEIGHT = 5; - public static readonly int GRAPH_HEIGHT = 34; public static readonly Color4 FILL_COLOUR = new Color4(221, 255, 255, 255); public static readonly Color4 GLOW_COLOUR = new Color4(221, 255, 255, 150); private const float progress_transition_duration = 100; @@ -68,7 +67,7 @@ namespace osu.Game.Screens.Play public SongProgress() { RelativeSizeAxes = Axes.X; - Height = BAR_HEIGHT + GRAPH_HEIGHT + SongProgressBar.HANDLE_SIZE.Y; + Height = BAR_HEIGHT + SongProgressGraphColumn.HEIGHT + SongProgressBar.HANDLE_SIZE.Y; Children = new Drawable[] { @@ -77,7 +76,7 @@ namespace osu.Game.Screens.Play RelativeSizeAxes = Axes.X, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, - Height = GRAPH_HEIGHT, + Height = SongProgressGraphColumn.HEIGHT, Margin = new MarginPadding { Bottom = BAR_HEIGHT diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 18454c7200..76ec5d3c6c 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -31,7 +31,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, Width = 2, - Height = SongProgress.BAR_HEIGHT + SongProgress.GRAPH_HEIGHT, + Height = SongProgress.BAR_HEIGHT + SongProgressGraphColumn.HEIGHT, Colour = Color4.White, Position = new Vector2(2, 0), Children = new Drawable[] diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index d0caa1201f..30858baae1 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -93,14 +93,14 @@ namespace osu.Game.Screens.Play private void recreateGraph() { - RemoveAll(delegate { return true; }); - columns.RemoveAll(delegate { return true; }); + Clear(); + columns.Clear(); - for (int x = 0; x < DrawWidth; x += 3) + for (float x = 0; x < DrawWidth; x += SongProgressGraphColumn.WIDTH) { columns.Add(new SongProgressGraphColumn { - Position = new Vector2(x + 1, 0), + Position = new Vector2(x, 0), State = ColumnState.Dimmed, }); diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs index 514fdcf82a..aad5013462 100644 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ b/osu.Game/Screens/Play/SongProgressGraphColumn.cs @@ -12,12 +12,19 @@ namespace osu.Game.Screens.Play { public class SongProgressGraphColumn : Container { - private readonly int rows = 11; + private const float cube_count = 6; + private const float cube_size = 4; + private const float padding = 2; + + public const float WIDTH = cube_size + padding; + + public const float HEIGHT = cube_count * WIDTH; + private readonly Color4 emptyColour = Color4.White.Opacity(100); private readonly Color4 litColour = SongProgress.FILL_COLOUR; private readonly Color4 dimmedColour = Color4.White.Opacity(175); - private List drawableRows = new List(); + private readonly List drawableRows = new List(); private int filled; public int Filled @@ -51,6 +58,26 @@ namespace osu.Game.Screens.Play } } + public SongProgressGraphColumn() + { + Size = new Vector2(WIDTH, HEIGHT); + + for (int r = 0; r < cube_count; r++) + { + drawableRows.Add(new Box + { + EdgeSmoothness = new Vector2(padding / 4), + Size = new Vector2(cube_size), + Position = new Vector2(0, r * WIDTH + padding) + }); + + Add(drawableRows[drawableRows.Count - 1]); + } + + // Reverse drawableRows so when iterating through them they start at the bottom + drawableRows.Reverse(); + } + private void fillActive() { Color4 colour = State == ColumnState.Lit ? litColour : dimmedColour; @@ -67,25 +94,6 @@ namespace osu.Game.Screens.Play } } } - - public SongProgressGraphColumn() - { - Size = new Vector2(4, rows * 3); - - for (int row = 0; row < rows * 3; row += 3) - { - drawableRows.Add(new Box - { - Size = new Vector2(2), - Position = new Vector2(0, row + 1) - }); - - Add(drawableRows[drawableRows.Count - 1]); - } - - // Reverse drawableRows so when iterating through them they start at the bottom - drawableRows.Reverse(); - } } public enum ColumnState From 0337f18fb9951dce66e3e47c2fa3caf9966d04e7 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 06:37:12 -0300 Subject: [PATCH 22/43] Cleaning --- osu.Game/Modes/UI/StandardHudOverlay.cs | 1 + osu.Game/Screens/Play/SongProgress.cs | 101 ++++++------ osu.Game/Screens/Play/SongProgressBar.cs | 11 +- osu.Game/Screens/Play/SongProgressGraph.cs | 153 ++++++++++++++---- .../Screens/Play/SongProgressGraphColumn.cs | 96 ----------- osu.Game/osu.Game.csproj | 1 - 6 files changed, 178 insertions(+), 185 deletions(-) delete mode 100644 osu.Game/Screens/Play/SongProgressGraphColumn.cs diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index 63f978f66a..bb679252c2 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -56,6 +56,7 @@ namespace osu.Game.Modes.UI Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, + Depth = -2, //make it on top of the pause overlay }; } } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index c10565e7e0..415594fa88 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -3,72 +3,53 @@ using OpenTK; using OpenTK.Graphics; -using osu.Game.Beatmaps; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Transforms; +using System; namespace osu.Game.Screens.Play { public class SongProgress : OverlayContainer { - public static readonly int BAR_HEIGHT = 5; - public static readonly int GRAPH_HEIGHT = 34; - public static readonly Color4 FILL_COLOUR = new Color4(221, 255, 255, 255); - public static readonly Color4 GLOW_COLOUR = new Color4(221, 255, 255, 150); - private const float progress_transition_duration = 100; + private readonly int bar_height = 5; + private readonly int graph_height = 34; + private readonly Vector2 handle_size = new Vector2(14, 25); + private readonly Color4 fill_colour = new Color4(221, 255, 255, 255); + private const float transition_duration = 100; - private SongProgressBar progress; + private SongProgressBar bar; private SongProgressGraph graph; - private WorkingBeatmap current; - [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) + public Action OnSeek; + + private double currentTime; + public double CurrentTime { - current = osuGame.Beatmap.Value; - } - - protected override void Update() - { - base.Update(); - - if (current?.TrackLoaded ?? false) + get { return currentTime; } + set { - float currentProgress = (float)(current.Track.CurrentTime / current.Track.Length); - - progress.IsEnabled = true; - progress.UpdatePosition(currentProgress); - graph.Progress = (int)(graph.ColumnCount * currentProgress); - } - else - { - progress.IsEnabled = false; + currentTime = value; + updateProgress(); } } - public void DisplayValues(int[] values) + private double duration; + public double Duration { - graph.Values = values; - } - - protected override void PopIn() - { - progress.FadeTo(1f, progress_transition_duration, EasingTypes.In); - MoveTo(Vector2.Zero, progress_transition_duration, EasingTypes.In); - } - - protected override void PopOut() - { - progress.FadeTo(0f, progress_transition_duration, EasingTypes.In); - MoveTo(new Vector2(0f, BAR_HEIGHT), progress_transition_duration, EasingTypes.In); + get { return duration; } + set + { + duration = value; + updateProgress(); + } } public SongProgress() { RelativeSizeAxes = Axes.X; - Height = BAR_HEIGHT + GRAPH_HEIGHT + SongProgressBar.HANDLE_SIZE.Y; + Height = bar_height + graph_height + handle_size.Y; Children = new Drawable[] { @@ -77,23 +58,47 @@ namespace osu.Game.Screens.Play RelativeSizeAxes = Axes.X, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, - Height = GRAPH_HEIGHT, + Height = graph_height, Margin = new MarginPadding { - Bottom = BAR_HEIGHT + Bottom = bar_height } }, - progress = new SongProgressBar + bar = new SongProgressBar(bar_height + graph_height, handle_size, fill_colour) { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, + Height = bar_height, SeekRequested = delegate (float position) { - current?.Track?.Seek(current.Track.Length * position); - current?.Track?.Start(); + OnSeek?.Invoke(Duration * position); } } }; } + + public void DisplayValues(int[] values) + { + graph.Values = values; + } + + private void updateProgress() + { + float currentProgress = (float)(CurrentTime / Duration); + bar.UpdatePosition(currentProgress); + graph.Progress = (int)(graph.ColumnCount * currentProgress); + } + + protected override void PopIn() + { + bar.FadeTo(1f, transition_duration, EasingTypes.In); + MoveTo(Vector2.Zero, transition_duration, EasingTypes.In); + } + + protected override void PopOut() + { + bar.FadeTo(0f, transition_duration, EasingTypes.In); + MoveTo(new Vector2(0f, bar_height), transition_duration, EasingTypes.In); + } } } diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 18454c7200..31acb1354f 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -12,12 +12,9 @@ namespace osu.Game.Screens.Play { public class SongProgressBar : DragBar { - public static readonly Vector2 HANDLE_SIZE = new Vector2(14, 25); - - public SongProgressBar() + public SongProgressBar(float barHeight, Vector2 handleSize, Color4 fillColour) { - Fill.Colour = SongProgress.FILL_COLOUR; - Height = SongProgress.BAR_HEIGHT; + Fill.Colour = fillColour; Add(new Box { @@ -31,7 +28,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, Width = 2, - Height = SongProgress.BAR_HEIGHT + SongProgress.GRAPH_HEIGHT, + Height = barHeight, Colour = Color4.White, Position = new Vector2(2, 0), Children = new Drawable[] @@ -44,7 +41,7 @@ namespace osu.Game.Screens.Play { Origin = Anchor.BottomCentre, Anchor = Anchor.TopCentre, - Size = HANDLE_SIZE, + Size = handleSize, CornerRadius = 5, Masking = true, Children = new Drawable[] diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index d0caa1201f..617c47fe70 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -4,24 +4,26 @@ using OpenTK; using System.Collections.Generic; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using OpenTK.Graphics; +using osu.Framework; +using osu.Framework.Extensions.Color4Extensions; namespace osu.Game.Screens.Play { public class SongProgressGraph : BufferedContainer { - private List columns = new List(); + private Column[] columns; private float lastDrawWidth; + public int ColumnCount => columns.Length; + public override bool HandleInput => false; - public int ColumnCount => columns.Count; private int progress; public int Progress { - get - { - return progress; - } + get { return progress; } set { if (value == progress) return; @@ -31,14 +33,11 @@ namespace osu.Game.Screens.Play } } - private List calculatedValues = new List(); // values but adjusted to fit the amount of columns + private int[] calculatedValues = { }; // values but adjusted to fit the amount of columns private int[] values; public int[] Values { - get - { - return values; - } + get { return values; } set { if (value == values) return; @@ -47,9 +46,28 @@ namespace osu.Game.Screens.Play } } + public SongProgressGraph() + { + CacheDrawnFrameBuffer = true; + PixelSnapping = true; + } + + protected override void Update() + { + base.Update(); + + // todo: Recreating in update is probably not the best idea + if (DrawWidth == lastDrawWidth) return; + recreateGraph(); + lastDrawWidth = DrawWidth; + } + + /// + /// Redraws all the columns to match their lit/dimmed state. + /// private void redrawProgress() { - for (int i = 0; i < columns.Count; i++) + for (int i = 0; i < columns.Length; i++) { columns[i].State = i <= progress ? ColumnState.Lit : ColumnState.Dimmed; } @@ -57,28 +75,29 @@ namespace osu.Game.Screens.Play ForceRedraw(); } + /// + /// Redraws the filled amount of all the columns. + /// private void redrawFilled() { for (int i = 0; i < ColumnCount; i++) { columns[i].Filled = calculatedValues[i]; } - - ForceRedraw(); } + /// + /// Takes and adjusts it to fit the amount of columns. + /// private void recalculateValues() { - // Resizes values to fit the amount of columns and stores it in calculatedValues - // Defaults to all zeros if values is null - - calculatedValues.RemoveAll(delegate { return true; }); + var newValues = new List(); if (values == null) { for (float i = 0; i < ColumnCount; i++) { - calculatedValues.Add(0); + newValues.Add(0); } return; @@ -87,44 +106,112 @@ namespace osu.Game.Screens.Play float step = values.Length / (float)ColumnCount; for (float i = 0; i < values.Length; i += step) { - calculatedValues.Add(values[(int)i]); + newValues.Add(values[(int)i]); } + + calculatedValues = newValues.ToArray(); } + /// + /// Recreates the entire graph. + /// private void recreateGraph() { - RemoveAll(delegate { return true; }); - columns.RemoveAll(delegate { return true; }); + var newColumns = new List(); for (int x = 0; x < DrawWidth; x += 3) { - columns.Add(new SongProgressGraphColumn + newColumns.Add(new Column { Position = new Vector2(x + 1, 0), State = ColumnState.Dimmed, }); - - Add(columns[columns.Count - 1]); } + columns = newColumns.ToArray(); + Children = columns; + recalculateValues(); redrawFilled(); redrawProgress(); } - protected override void Update() + private class Column : Container, IStateful { - base.Update(); + private readonly int rows = 11; + private readonly Color4 emptyColour = Color4.White.Opacity(100); + private readonly Color4 litColour = new Color4(221, 255, 255, 255); + private readonly Color4 dimmedColour = Color4.White.Opacity(175); - if (DrawWidth == lastDrawWidth) return; - recreateGraph(); - lastDrawWidth = DrawWidth; + private List drawableRows = new List(); + + private int filled; + public int Filled + { + get { return filled; } + set + { + if (value == filled) return; + filled = value; + + fillActive(); + } + } + + private ColumnState state; + public ColumnState State + { + get { return state; } + set + { + if (value == state) return; + state = value; + + fillActive(); + } + } + + public Column() + { + Size = new Vector2(4, rows * 3); + + for (int row = 0; row < rows * 3; row += 3) + { + drawableRows.Add(new Box + { + Size = new Vector2(2), + Position = new Vector2(0, row + 1) + }); + + Add(drawableRows[drawableRows.Count - 1]); + } + + // Reverse drawableRows so when iterating through them they start at the bottom + drawableRows.Reverse(); + } + + private void fillActive() + { + Color4 colour = State == ColumnState.Lit ? litColour : dimmedColour; + + for (int i = 0; i < drawableRows.Count; i++) + { + if (Filled == 0) // i <= Filled doesn't work for zero fill + { + drawableRows[i].Colour = emptyColour; + } + else + { + drawableRows[i].Colour = i <= Filled ? colour : emptyColour; + } + } + } } - public SongProgressGraph() + private enum ColumnState { - CacheDrawnFrameBuffer = true; - PixelSnapping = true; + Lit, + Dimmed } } } diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs deleted file mode 100644 index 514fdcf82a..0000000000 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ /dev/null @@ -1,96 +0,0 @@ -// 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 System.Collections.Generic; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Extensions.Color4Extensions; - -namespace osu.Game.Screens.Play -{ - public class SongProgressGraphColumn : Container - { - private readonly int rows = 11; - private readonly Color4 emptyColour = Color4.White.Opacity(100); - private readonly Color4 litColour = SongProgress.FILL_COLOUR; - private readonly Color4 dimmedColour = Color4.White.Opacity(175); - - private List drawableRows = new List(); - - private int filled; - public int Filled - { - get - { - return filled; - } - set - { - if (value == filled) return; - filled = value; - - fillActive(); - } - } - - private ColumnState state; - public ColumnState State - { - get - { - return state; - } - set - { - if (value == state) return; - state = value; - - fillActive(); - } - } - - private void fillActive() - { - Color4 colour = State == ColumnState.Lit ? litColour : dimmedColour; - - for (int i = 0; i < drawableRows.Count; i++) - { - if (Filled == 0) // i <= Filled doesn't work for zero fill - { - drawableRows[i].Colour = emptyColour; - } - else - { - drawableRows[i].Colour = i <= Filled ? colour : emptyColour; - } - } - } - - public SongProgressGraphColumn() - { - Size = new Vector2(4, rows * 3); - - for (int row = 0; row < rows * 3; row += 3) - { - drawableRows.Add(new Box - { - Size = new Vector2(2), - Position = new Vector2(0, row + 1) - }); - - Add(drawableRows[drawableRows.Count - 1]); - } - - // Reverse drawableRows so when iterating through them they start at the bottom - drawableRows.Reverse(); - } - } - - public enum ColumnState - { - Lit, - Dimmed - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a1dc99d11c..a35f7b9f59 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -333,7 +333,6 @@ - From 39238928635034d85add25cc69df16b945803fbb Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 07:20:16 -0300 Subject: [PATCH 23/43] Delete SongProgressGraphColumn.cs --- .../Screens/Play/SongProgressGraphColumn.cs | 104 ------------------ 1 file changed, 104 deletions(-) delete mode 100644 osu.Game/Screens/Play/SongProgressGraphColumn.cs diff --git a/osu.Game/Screens/Play/SongProgressGraphColumn.cs b/osu.Game/Screens/Play/SongProgressGraphColumn.cs deleted file mode 100644 index aad5013462..0000000000 --- a/osu.Game/Screens/Play/SongProgressGraphColumn.cs +++ /dev/null @@ -1,104 +0,0 @@ -// 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 System.Collections.Generic; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Extensions.Color4Extensions; - -namespace osu.Game.Screens.Play -{ - public class SongProgressGraphColumn : Container - { - private const float cube_count = 6; - private const float cube_size = 4; - private const float padding = 2; - - public const float WIDTH = cube_size + padding; - - public const float HEIGHT = cube_count * WIDTH; - - private readonly Color4 emptyColour = Color4.White.Opacity(100); - private readonly Color4 litColour = SongProgress.FILL_COLOUR; - private readonly Color4 dimmedColour = Color4.White.Opacity(175); - - private readonly List drawableRows = new List(); - - private int filled; - public int Filled - { - get - { - return filled; - } - set - { - if (value == filled) return; - filled = value; - - fillActive(); - } - } - - private ColumnState state; - public ColumnState State - { - get - { - return state; - } - set - { - if (value == state) return; - state = value; - - fillActive(); - } - } - - public SongProgressGraphColumn() - { - Size = new Vector2(WIDTH, HEIGHT); - - for (int r = 0; r < cube_count; r++) - { - drawableRows.Add(new Box - { - EdgeSmoothness = new Vector2(padding / 4), - Size = new Vector2(cube_size), - Position = new Vector2(0, r * WIDTH + padding) - }); - - Add(drawableRows[drawableRows.Count - 1]); - } - - // Reverse drawableRows so when iterating through them they start at the bottom - drawableRows.Reverse(); - } - - private void fillActive() - { - Color4 colour = State == ColumnState.Lit ? litColour : dimmedColour; - - for (int i = 0; i < drawableRows.Count; i++) - { - if (Filled == 0) // i <= Filled doesn't work for zero fill - { - drawableRows[i].Colour = emptyColour; - } - else - { - drawableRows[i].Colour = i <= Filled ? colour : emptyColour; - } - } - } - } - - public enum ColumnState - { - Lit, - Dimmed - } -} From ca2816f9c8554d04af1b40b66178592547aa5ad1 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 07:24:43 -0300 Subject: [PATCH 24/43] Formatting --- osu.Game/Modes/UI/StandardHudOverlay.cs | 2 +- osu.Game/Screens/Play/SongProgress.cs | 16 ++++++++-------- osu.Game/Screens/Play/SongProgressGraph.cs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index 86e94049f6..d51ffab06b 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -57,7 +57,7 @@ namespace osu.Game.Modes.UI Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, Depth = -2, //todo: find out why this doesn't put progress on top of PauseOverlay - Values = new int[] { 3 }, //todo: removeme + Values = new[] { 3 }, //todo: removeme }; } } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 678a1b8c92..b99fb429dd 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -13,14 +13,14 @@ namespace osu.Game.Screens.Play { public class SongProgress : OverlayContainer { - private readonly int bar_height = 5; - private readonly int graph_height = 34; - private readonly Vector2 handle_size = new Vector2(14, 25); - private readonly Color4 fill_colour = new Color4(221, 255, 255, 255); + private const int bar_height = 5; + private const int graph_height = 34; + private readonly Vector2 handleSize = new Vector2(14, 25); + private readonly Color4 fillColour = new Color4(221, 255, 255, 255); private const float transition_duration = 200; - private SongProgressBar bar; - private SongProgressGraph graph; + private readonly SongProgressBar bar; + private readonly SongProgressGraph graph; public Action OnSeek; @@ -55,7 +55,7 @@ namespace osu.Game.Screens.Play public SongProgress() { RelativeSizeAxes = Axes.X; - Height = bar_height + graph_height + SongProgressGraph.Column.HEIGHT + handle_size.Y; + Height = bar_height + graph_height + SongProgressGraph.Column.HEIGHT + handleSize.Y; Children = new Drawable[] { @@ -70,7 +70,7 @@ namespace osu.Game.Screens.Play Bottom = bar_height } }, - bar = new SongProgressBar(bar_height + graph_height, handle_size, fill_colour) + bar = new SongProgressBar(bar_height + graph_height, handleSize, fillColour) { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 387309041f..14e7f55a05 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -88,7 +88,7 @@ namespace osu.Game.Screens.Play } /// - /// Takes and adjusts it to fit the amount of columns. + /// Takes and adjusts it to fit the amount of columns. /// private void recalculateValues() { From 938f5eaf589f13b4a6f69fe1970310abe5ff92a5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 07:38:08 -0300 Subject: [PATCH 25/43] Dragging --- .../Tests/TestCaseSongProgress.cs | 1 + osu.Game/Screens/Play/Player.cs | 6 ++++++ osu.Game/Screens/Play/SongProgress.cs | 3 +-- osu.Game/Screens/Play/SongProgressBar.cs | 12 +++++++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 80ca040ef8..b66a6a4ec1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -25,6 +25,7 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, Length = 100, + OnSeek = (time) => progress.CurrentTime = time, }); AddButton("Toggle Bar", progress.ToggleVisibility); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 2dde50f492..22eb157cc9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -140,6 +140,12 @@ namespace osu.Game.Screens.Play hudOverlay.BindHitRenderer(hitRenderer); hudOverlay.Progress.Length = Beatmap.Track.Length; + hudOverlay.Progress.OnSeek = (time) => + { + //todo: temporary + Beatmap.Track.Seek(time); + Beatmap.Track.Start(); + }; //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) hitRenderer.OnAllJudged += onCompletion; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index b99fb429dd..6f50381a4f 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -70,11 +70,10 @@ namespace osu.Game.Screens.Play Bottom = bar_height } }, - bar = new SongProgressBar(bar_height + graph_height, handleSize, fillColour) + bar = new SongProgressBar(bar_height, graph_height, handleSize, fillColour) { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, - Height = bar_height, SeekRequested = delegate (float position) { OnSeek?.Invoke(Length * position); diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 31acb1354f..f720e2bf96 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -12,13 +12,19 @@ namespace osu.Game.Screens.Play { public class SongProgressBar : DragBar { - public SongProgressBar(float barHeight, Vector2 handleSize, Color4 fillColour) + public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize, Color4 fillColour) { Fill.Colour = fillColour; + Height = barHeight + handleBarHeight + handleSize.Y; + FillContainer.RelativeSizeAxes = Axes.X; + FillContainer.Height = barHeight; Add(new Box { - RelativeSizeAxes = Axes.Both, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = barHeight, Colour = Color4.Black, Alpha = 0.5f, Depth = 1 @@ -28,7 +34,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, Width = 2, - Height = barHeight, + Height = barHeight + handleBarHeight, Colour = Color4.White, Position = new Vector2(2, 0), Children = new Drawable[] From bbca6cf602316d5f9969fe7cb888cde304c7cb29 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 08:13:03 -0300 Subject: [PATCH 26/43] Fix bottom square being clipped --- .../Tests/TestCaseSongProgress.cs | 2 +- osu.Game/Screens/Play/SongProgress.cs | 23 +++++++++---------- osu.Game/Screens/Play/SongProgressGraph.cs | 13 +++++++---- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index b66a6a4ec1..5563f3f9ea 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -39,7 +39,7 @@ namespace osu.Desktop.VisualTests.Tests List newValues = new List(); for (int i = 0; i < 1000; i++) { - newValues.Add(RNG.Next(0, 11)); + newValues.Add(RNG.Next(0, 6)); } progress.Values = newValues.ToArray(); diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 6f50381a4f..8ab5492179 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -14,7 +14,6 @@ namespace osu.Game.Screens.Play public class SongProgress : OverlayContainer { private const int bar_height = 5; - private const int graph_height = 34; private readonly Vector2 handleSize = new Vector2(14, 25); private readonly Color4 fillColour = new Color4(221, 255, 255, 255); private const float transition_duration = 200; @@ -55,30 +54,30 @@ namespace osu.Game.Screens.Play public SongProgress() { RelativeSizeAxes = Axes.X; - Height = bar_height + graph_height + SongProgressGraph.Column.HEIGHT + handleSize.Y; + Height = bar_height + SongProgressGraph.Column.HEIGHT + handleSize.Y; Children = new Drawable[] { graph = new SongProgressGraph { RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Height = graph_height, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Height = SongProgressGraph.Column.HEIGHT, Margin = new MarginPadding { - Bottom = bar_height - } + Bottom = bar_height, + }, }, - bar = new SongProgressBar(bar_height, graph_height, handleSize, fillColour) + bar = new SongProgressBar(bar_height, SongProgressGraph.Column.HEIGHT, handleSize, fillColour) { - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, SeekRequested = delegate (float position) { OnSeek?.Invoke(Length * position); - } - } + }, + }, }; } diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 14e7f55a05..e3d6aa785e 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -5,10 +5,12 @@ using OpenTK; using OpenTK.Graphics; using System.Linq; using System.Collections.Generic; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Containers; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics.Primitives; namespace osu.Game.Screens.Play { @@ -124,6 +126,8 @@ namespace osu.Game.Screens.Play { newColumns.Add(new Column { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, Position = new Vector2(x, 0), State = ColumnState.Dimmed, }); @@ -180,14 +184,15 @@ namespace osu.Game.Screens.Play public Column() { Size = new Vector2(WIDTH, HEIGHT); + Margin = new MarginPadding { Bottom = 1 }; //todo: probably find a better fix, not quite sure why this works - for (int r = 0; r Date: Thu, 23 Mar 2017 08:32:24 -0300 Subject: [PATCH 27/43] Fix for the fix --- osu.Game/Screens/Play/SongProgress.cs | 4 ++-- osu.Game/Screens/Play/SongProgressGraph.cs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 8ab5492179..13219323f4 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -93,14 +93,14 @@ namespace osu.Game.Screens.Play bar.IsEnabled = true; updateProgress(); //in case progress was changed while the bar was hidden - bar.FadeTo(1f, transition_duration, EasingTypes.In); + bar.FadeIn(transition_duration, EasingTypes.In); MoveTo(Vector2.Zero, transition_duration, EasingTypes.In); } protected override void PopOut() { bar.IsEnabled = false; - bar.FadeTo(0f, transition_duration, EasingTypes.In); + bar.FadeOut(transition_duration, EasingTypes.In); MoveTo(new Vector2(0f, bar_height), transition_duration, EasingTypes.In); } } diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index e3d6aa785e..45da103d6a 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -151,7 +151,7 @@ namespace osu.Game.Screens.Play private const float cube_size = 4; private const float padding = 2; public const float WIDTH = cube_size + padding; - public const float HEIGHT = cube_count * WIDTH; + public const float HEIGHT = (cube_count * WIDTH) + padding + 1; private readonly List drawableRows = new List(); @@ -184,7 +184,6 @@ namespace osu.Game.Screens.Play public Column() { Size = new Vector2(WIDTH, HEIGHT); - Margin = new MarginPadding { Bottom = 1 }; //todo: probably find a better fix, not quite sure why this works for (int r = 0; r < cube_count; r++) { @@ -192,7 +191,7 @@ namespace osu.Game.Screens.Play { EdgeSmoothness = new Vector2(padding / 4), Size = new Vector2(cube_size), - Position = new Vector2(0, r * WIDTH), + Position = new Vector2(0, r * WIDTH + padding), }); Add(drawableRows[drawableRows.Count - 1]); From b429d8f1b3ed22b04acc2563dd63654a713f4314 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 09:05:53 -0300 Subject: [PATCH 28/43] More proper fix --- osu.Game/Screens/Play/SongProgressGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 45da103d6a..a57253e517 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -151,7 +151,7 @@ namespace osu.Game.Screens.Play private const float cube_size = 4; private const float padding = 2; public const float WIDTH = cube_size + padding; - public const float HEIGHT = (cube_count * WIDTH) + padding + 1; + public const float HEIGHT = cube_count * WIDTH + padding; private readonly List drawableRows = new List(); From 0a11d035fe4eba959def8b9db09ae62c1d275568 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 09:07:13 -0300 Subject: [PATCH 29/43] Formatting --- osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs | 2 +- osu.Game/Screens/Play/Player.cs | 6 ------ osu.Game/Screens/Play/SongProgressGraph.cs | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 5563f3f9ea..626bf5c87f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -25,7 +25,7 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, Length = 100, - OnSeek = (time) => progress.CurrentTime = time, + OnSeek = time => progress.CurrentTime = time, }); AddButton("Toggle Bar", progress.ToggleVisibility); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 22eb157cc9..2dde50f492 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -140,12 +140,6 @@ namespace osu.Game.Screens.Play hudOverlay.BindHitRenderer(hitRenderer); hudOverlay.Progress.Length = Beatmap.Track.Length; - hudOverlay.Progress.OnSeek = (time) => - { - //todo: temporary - Beatmap.Track.Seek(time); - Beatmap.Track.Start(); - }; //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) hitRenderer.OnAllJudged += onCompletion; diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index a57253e517..198799efa1 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Containers; using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics.Primitives; namespace osu.Game.Screens.Play { From b56fb310bf0780e7ee8fd9e727e47a563988f6ba Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 23:38:23 -0300 Subject: [PATCH 30/43] More cleanup --- .../Tests/TestCaseSongProgress.cs | 2 +- osu.Game/Screens/Play/SongProgress.cs | 10 +++++----- osu.Game/Screens/Play/SongProgressGraph.cs | 12 +++--------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 626bf5c87f..efce867c3f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -11,7 +11,7 @@ namespace osu.Desktop.VisualTests.Tests { internal class TestCaseSongProgress : TestCase { - public override string Description => @"With (half)real data"; + public override string Description => @"With fake data"; private SongProgress progress; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 13219323f4..09e0c7cfba 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -13,7 +13,7 @@ namespace osu.Game.Screens.Play { public class SongProgress : OverlayContainer { - private const int bar_height = 5; + private const int progress_height = 5; private readonly Vector2 handleSize = new Vector2(14, 25); private readonly Color4 fillColour = new Color4(221, 255, 255, 255); private const float transition_duration = 200; @@ -54,7 +54,7 @@ namespace osu.Game.Screens.Play public SongProgress() { RelativeSizeAxes = Axes.X; - Height = bar_height + SongProgressGraph.Column.HEIGHT + handleSize.Y; + Height = progress_height + SongProgressGraph.Column.HEIGHT + handleSize.Y; Children = new Drawable[] { @@ -66,10 +66,10 @@ namespace osu.Game.Screens.Play Height = SongProgressGraph.Column.HEIGHT, Margin = new MarginPadding { - Bottom = bar_height, + Bottom = progress_height, }, }, - bar = new SongProgressBar(bar_height, SongProgressGraph.Column.HEIGHT, handleSize, fillColour) + bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handleSize, fillColour) { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, @@ -101,7 +101,7 @@ namespace osu.Game.Screens.Play { bar.IsEnabled = false; bar.FadeOut(transition_duration, EasingTypes.In); - MoveTo(new Vector2(0f, bar_height), transition_duration, EasingTypes.In); + MoveTo(new Vector2(0f, progress_height), transition_duration, EasingTypes.In); } } } diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 198799efa1..f6dfbc2715 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -16,7 +16,6 @@ namespace osu.Game.Screens.Play public class SongProgressGraph : BufferedContainer { private Column[] columns = { }; - private float lastDrawWidth; public int ColumnCount => columns.Length; @@ -54,6 +53,7 @@ namespace osu.Game.Screens.Play PixelSnapping = true; } + private float lastDrawWidth; protected override void Update() { base.Update(); @@ -98,9 +98,7 @@ namespace osu.Game.Screens.Play if (values == null) { for (float i = 0; i < ColumnCount; i++) - { newValues.Add(0); - } return; } @@ -192,10 +190,10 @@ namespace osu.Game.Screens.Play Size = new Vector2(cube_size), Position = new Vector2(0, r * WIDTH + padding), }); - - Add(drawableRows[drawableRows.Count - 1]); } + Children = drawableRows; + // Reverse drawableRows so when iterating through them they start at the bottom drawableRows.Reverse(); } @@ -207,13 +205,9 @@ namespace osu.Game.Screens.Play for (int i = 0; i < drawableRows.Count; i++) { if (Filled == 0) // i <= Filled doesn't work for zero fill - { drawableRows[i].Colour = emptyColour; - } else - { drawableRows[i].Colour = i <= Filled ? colour : emptyColour; - } } } } From f1f6f2041f73882a412d3be1336590c1116d8c63 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 23:57:33 -0300 Subject: [PATCH 31/43] Null track handling in player --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 2dde50f492..bdd6949618 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -139,7 +139,7 @@ namespace osu.Game.Screens.Play hitRenderer.InputManager.ReplayInputHandler = ReplayInputHandler; hudOverlay.BindHitRenderer(hitRenderer); - hudOverlay.Progress.Length = Beatmap.Track.Length; + hudOverlay.Progress.Length = Beatmap?.Track?.Length ?? 0; //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) hitRenderer.OnAllJudged += onCompletion; From 0edee042008c8de0a48b681317eb72bdacd5086f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 24 Mar 2017 00:41:14 -0300 Subject: [PATCH 32/43] Use OsuColour instead of static colours --- osu.Game/Screens/Play/SongProgress.cs | 20 ++++++++++++-------- osu.Game/Screens/Play/SongProgressBar.cs | 9 +++++++-- osu.Game/Screens/Play/SongProgressGraph.cs | 20 +++++++++++++++++--- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 09e0c7cfba..5f1fd974ed 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -8,6 +8,8 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Transforms; using System; +using osu.Game.Graphics; +using osu.Framework.Allocation; namespace osu.Game.Screens.Play { @@ -15,11 +17,10 @@ namespace osu.Game.Screens.Play { private const int progress_height = 5; private readonly Vector2 handleSize = new Vector2(14, 25); - private readonly Color4 fillColour = new Color4(221, 255, 255, 255); private const float transition_duration = 200; - private readonly SongProgressBar bar; - private readonly SongProgressGraph graph; + private SongProgressBar bar; + private SongProgressGraph graph; public Action OnSeek; @@ -51,6 +52,12 @@ namespace osu.Game.Screens.Play set { graph.Values = value; } } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + graph.FillColour = bar.FillColour = colours.BlueLighter; + } + public SongProgress() { RelativeSizeAxes = Axes.X; @@ -64,12 +71,9 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Height = SongProgressGraph.Column.HEIGHT, - Margin = new MarginPadding - { - Bottom = progress_height, - }, + Margin = new MarginPadding { Bottom = progress_height }, }, - bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handleSize, fillColour) + bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handleSize) { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index f720e2bf96..f8ee030d21 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -12,9 +12,14 @@ namespace osu.Game.Screens.Play { public class SongProgressBar : DragBar { - public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize, Color4 fillColour) + public Color4 FillColour + { + get { return Fill.Colour; } + set { Fill.Colour = value; } + } + + public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize) { - Fill.Colour = fillColour; Height = barHeight + handleBarHeight + handleSize.Y; FillContainer.RelativeSizeAxes = Axes.X; FillContainer.Height = barHeight; diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index f6dfbc2715..9bac81a721 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -47,6 +47,19 @@ namespace osu.Game.Screens.Play } } + private Color4 fillColour; + public Color4 FillColour + { + get { return fillColour; } + set + { + if (value == fillColour) return; + fillColour = value; + + redrawFilled(); + } + } + public SongProgressGraph() { CacheDrawnFrameBuffer = true; @@ -121,7 +134,7 @@ namespace osu.Game.Screens.Play for (float x = 0; x < DrawWidth; x += Column.WIDTH) { - newColumns.Add(new Column + newColumns.Add(new Column(fillColour) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -141,7 +154,7 @@ namespace osu.Game.Screens.Play public class Column : Container, IStateful { private readonly Color4 emptyColour = Color4.White.Opacity(100); - private readonly Color4 litColour = new Color4(221, 255, 255, 255); + private readonly Color4 litColour; private readonly Color4 dimmedColour = Color4.White.Opacity(175); private const float cube_count = 6; @@ -178,9 +191,10 @@ namespace osu.Game.Screens.Play } } - public Column() + public Column(Color4 litColour) { Size = new Vector2(WIDTH, HEIGHT); + this.litColour = litColour; for (int r = 0; r < cube_count; r++) { From a6dfed9668f368ae2e04513222020c5a2e9e6f95 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 24 Mar 2017 00:41:56 -0300 Subject: [PATCH 33/43] Formatting --- osu.Game/Screens/Play/SongProgress.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 5f1fd974ed..e0b48b0ec0 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -19,8 +19,8 @@ namespace osu.Game.Screens.Play private readonly Vector2 handleSize = new Vector2(14, 25); private const float transition_duration = 200; - private SongProgressBar bar; - private SongProgressGraph graph; + private readonly SongProgressBar bar; + private readonly SongProgressGraph graph; public Action OnSeek; From f0035659dbcbaf7b470f61d22dca220cb6d0c979 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 24 Mar 2017 00:45:19 -0300 Subject: [PATCH 34/43] Unused using --- osu.Game/Screens/Play/SongProgress.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index e0b48b0ec0..af677c9471 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.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 osu.Framework.Graphics.Primitives; From 1842d80e282e6e40815c49f1074255f76e893ee2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Apr 2017 09:40:35 +0900 Subject: [PATCH 35/43] Update test case. --- osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs | 6 +++--- osu.Game/Screens/Play/SongProgress.cs | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index efce867c3f..13a77855d9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.MathUtils; -using osu.Framework.Screens.Testing; +using osu.Framework.Testing; using osu.Game.Screens.Play; namespace osu.Desktop.VisualTests.Tests @@ -28,8 +28,8 @@ namespace osu.Desktop.VisualTests.Tests OnSeek = time => progress.CurrentTime = time, }); - AddButton("Toggle Bar", progress.ToggleVisibility); - AddButton("New Values", displayNewValues); + AddStep("Toggle Bar", progress.ToggleVisibility); + AddStep("New Values", displayNewValues); displayNewValues(); } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index af677c9471..783b7611a2 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -5,7 +5,6 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Transforms; using System; using osu.Game.Graphics; using osu.Framework.Allocation; From 7e99fc47e2bb154eb2f21e2691766254ff3a8aee Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Apr 2017 15:20:39 +0900 Subject: [PATCH 36/43] wip --- .../Tests/TestCaseSongProgress.cs | 404 +++++++++++++++++- osu.Game/Overlays/DragBar.cs | 5 +- osu.Game/Screens/Play/Player.cs | 4 +- osu.Game/Screens/Play/SongProgress.cs | 41 +- osu.Game/Screens/Play/SongProgressBar.cs | 4 +- osu.Game/Screens/Play/SongProgressGraph.cs | 2 +- 6 files changed, 423 insertions(+), 37 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 13a77855d9..feb7aac0ce 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -1,11 +1,22 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; +using System.Linq; +using osu.Framework; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Framework.Testing; -using osu.Game.Screens.Play; +using osu.Game.Graphics; +using osu.Game.Overlays; +using OpenTK; +using OpenTK.Graphics; namespace osu.Desktop.VisualTests.Tests { @@ -24,12 +35,12 @@ namespace osu.Desktop.VisualTests.Tests Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - Length = 100, - OnSeek = time => progress.CurrentTime = time, }); - AddStep("Toggle Bar", progress.ToggleVisibility); - AddStep("New Values", displayNewValues); + AddStep("Toggle Bar", progress.ToggleBar); + AddWaitStep(5); + //AddStep("Toggle Bar", progress.ToggleVisibility); + //AddStep("New Values", displayNewValues); displayNewValues(); } @@ -43,7 +54,388 @@ namespace osu.Desktop.VisualTests.Tests } progress.Values = newValues.ToArray(); - progress.CurrentTime = RNG.Next(0, 100); + progress.Progress = RNG.NextDouble(); + } + } + + public class SongProgress : OverlayContainer + { + private const int progress_height = 5; + + private static readonly Vector2 handle_size = new Vector2(14, 25); + + private const float transition_duration = 200; + + private readonly SongProgressBar bar; + private readonly SongProgressGraph graph; + + public Action OnSeek; + + private double progress; + public double Progress + { + get { return progress; } + set + { + progress = value; + updateProgress(); + } + } + + public int[] Values + { + get { return graph.Values; } + set { graph.Values = value; } + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + graph.FillColour = bar.FillColour = colours.BlueLighter; + } + + public SongProgress() + { + RelativeSizeAxes = Axes.X; + Height = progress_height + SongProgressGraph.Column.HEIGHT + handle_size.Y; + + Children = new Drawable[] + { + graph = new SongProgressGraph + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Height = SongProgressGraph.Column.HEIGHT, + Margin = new MarginPadding { Bottom = progress_height }, + }, + bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handle_size) + { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Alpha = 0, + SeekRequested = delegate (float position) + { + OnSeek?.Invoke(position); + }, + }, + }; + } + + private void updateProgress() + { + bar.UpdatePosition((float)progress); + graph.Progress = (int)(graph.ColumnCount * progress); + } + + private bool barVisible; + + public void ToggleBar() + { + barVisible = !barVisible; + + updateBarVisibility(); + } + + private void updateBarVisibility() + { + bar.FadeTo(barVisible ? 1 : 0, transition_duration, EasingTypes.In); + MoveTo(new Vector2(0, barVisible ? 0 : progress_height), transition_duration, EasingTypes.In); + } + + protected override void PopIn() + { + updateBarVisibility(); + } + + protected override void PopOut() + { + } + + protected override void Update() + { + base.Update(); + + updateProgress(); + } + } + + public class SongProgressGraph : BufferedContainer + { + private Game.Screens.Play.SongProgressGraph.Column[] columns = { }; + + public int ColumnCount => columns.Length; + + public override bool HandleInput => false; + + private int progress; + public int Progress + { + get { return progress; } + set + { + if (value == progress) return; + progress = value; + + redrawProgress(); + } + } + + private int[] calculatedValues = { }; // values but adjusted to fit the amount of columns + private int[] values; + public int[] Values + { + get { return values; } + set + { + if (value == values) return; + values = value; + recreateGraph(); + } + } + + private Color4 fillColour; + public Color4 FillColour + { + get { return fillColour; } + set + { + if (value == fillColour) return; + fillColour = value; + + redrawFilled(); + } + } + + public SongProgressGraph() + { + CacheDrawnFrameBuffer = true; + PixelSnapping = true; + } + + private float lastDrawWidth; + protected override void Update() + { + base.Update(); + + // todo: Recreating in update is probably not the best idea + if (DrawWidth == lastDrawWidth) return; + recreateGraph(); + lastDrawWidth = DrawWidth; + } + + /// + /// Redraws all the columns to match their lit/dimmed state. + /// + private void redrawProgress() + { + for (int i = 0; i < columns.Length; i++) + { + columns[i].State = i <= progress ? Game.Screens.Play.SongProgressGraph.ColumnState.Lit : Game.Screens.Play.SongProgressGraph.ColumnState.Dimmed; + } + + ForceRedraw(); + } + + /// + /// Redraws the filled amount of all the columns. + /// + private void redrawFilled() + { + for (int i = 0; i < ColumnCount; i++) + { + columns[i].Filled = calculatedValues.ElementAtOrDefault(i); + } + } + + /// + /// Takes and adjusts it to fit the amount of columns. + /// + private void recalculateValues() + { + var newValues = new List(); + + if (values == null) + { + for (float i = 0; i < ColumnCount; i++) + newValues.Add(0); + + return; + } + + float step = values.Length / (float)ColumnCount; + for (float i = 0; i < values.Length; i += step) + { + newValues.Add(values[(int)i]); + } + + calculatedValues = newValues.ToArray(); + } + + /// + /// Recreates the entire graph. + /// + private void recreateGraph() + { + var newColumns = new List(); + + for (float x = 0; x < DrawWidth; x += Game.Screens.Play.SongProgressGraph.Column.WIDTH) + { + newColumns.Add(new Game.Screens.Play.SongProgressGraph.Column(fillColour) + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Position = new Vector2(x, 0), + State = Game.Screens.Play.SongProgressGraph.ColumnState.Dimmed, + }); + } + + columns = newColumns.ToArray(); + Children = columns; + + recalculateValues(); + redrawFilled(); + redrawProgress(); + } + + public class Column : Container, IStateful + { + private readonly Color4 emptyColour = Color4.White.Opacity(100); + private readonly Color4 litColour; + private readonly Color4 dimmedColour = Color4.White.Opacity(175); + + private const float cube_count = 6; + private const float cube_size = 4; + private const float padding = 2; + public const float WIDTH = cube_size + padding; + public const float HEIGHT = cube_count * WIDTH + padding; + + private readonly List drawableRows = new List(); + + private int filled; + public int Filled + { + get { return filled; } + set + { + if (value == filled) return; + filled = value; + + fillActive(); + } + } + + private Game.Screens.Play.SongProgressGraph.ColumnState state; + public Game.Screens.Play.SongProgressGraph.ColumnState State + { + get { return state; } + set + { + if (value == state) return; + state = value; + + fillActive(); + } + } + + public Column(Color4 litColour) + { + Size = new Vector2(WIDTH, HEIGHT); + this.litColour = litColour; + + for (int r = 0; r < cube_count; r++) + { + drawableRows.Add(new Box + { + EdgeSmoothness = new Vector2(padding / 4), + Size = new Vector2(cube_size), + Position = new Vector2(0, r * WIDTH + padding), + }); + } + + Children = drawableRows; + + // Reverse drawableRows so when iterating through them they start at the bottom + drawableRows.Reverse(); + } + + private void fillActive() + { + Color4 colour = State == Game.Screens.Play.SongProgressGraph.ColumnState.Lit ? litColour : dimmedColour; + + for (int i = 0; i < drawableRows.Count; i++) + { + if (Filled == 0) // i <= Filled doesn't work for zero fill + drawableRows[i].Colour = emptyColour; + else + drawableRows[i].Colour = i <= Filled ? colour : emptyColour; + } + } + } + + public enum ColumnState + { + Lit, + Dimmed + } + } + + public class SongProgressBar : DragBar + { + public Color4 FillColour + { + get { return FillContainer.Colour; } + set { FillContainer.Colour = value; } + } + + public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize) + { + Height = barHeight + handleBarHeight + handleSize.Y; + FillContainer.RelativeSizeAxes = Axes.X; + FillContainer.Height = barHeight; + + Add(new Box + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = barHeight, + Colour = Color4.Black, + Alpha = 0.5f, + Depth = 1 + }); + FillContainer.Add(new Container + { + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, + Width = 2, + Height = barHeight + handleBarHeight, + Colour = Color4.White, + Position = new Vector2(2, 0), + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + }, + new Container + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, + Size = handleSize, + CornerRadius = 5, + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White + } + } + } + } + }); } } } diff --git a/osu.Game/Overlays/DragBar.cs b/osu.Game/Overlays/DragBar.cs index 2ee986cd29..123cd404c7 100644 --- a/osu.Game/Overlays/DragBar.cs +++ b/osu.Game/Overlays/DragBar.cs @@ -14,7 +14,6 @@ namespace osu.Game.Overlays public class DragBar : Container { protected readonly Container FillContainer; - protected readonly Box Fill; public Action SeekRequested; @@ -46,7 +45,7 @@ namespace osu.Game.Overlays Width = 0, Children = new Drawable[] { - Fill = new Box + new Box { RelativeSizeAxes = Axes.Both } @@ -73,7 +72,7 @@ namespace osu.Game.Overlays private void updatePosition(float position) { position = MathHelper.Clamp(position, 0, 1); - fill.TransformTo(fill.Width, position, 200, EasingTypes.OutQuint, new TransformSeek()); + FillContainer.TransformTo(FillContainer.Width, position, 200, EasingTypes.OutQuint, new TransformSeek()); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index df2645af7b..9b3ca0df26 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -121,8 +121,6 @@ namespace osu.Game.Screens.Play hudOverlay.BindHitRenderer(HitRenderer); hudOverlay.Progress.Hide(); - hudOverlay.Progress.Length = Beatmap?.Track?.Length ?? 0; - //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) HitRenderer.OnAllJudged += onCompletion; @@ -167,7 +165,7 @@ namespace osu.Game.Screens.Play { base.Update(); - hudOverlay.Progress.CurrentTime = Beatmap.Track.CurrentTime; + hudOverlay.Progress.Progress = Beatmap.Track.CurrentTime / Beatmap.Track.Length; } private void initializeSkipButton() diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 783b7611a2..b2e289c422 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -14,7 +14,9 @@ namespace osu.Game.Screens.Play public class SongProgress : OverlayContainer { private const int progress_height = 5; - private readonly Vector2 handleSize = new Vector2(14, 25); + + private static readonly Vector2 handle_size = new Vector2(14, 25); + private const float transition_duration = 200; private readonly SongProgressBar bar; @@ -22,24 +24,13 @@ namespace osu.Game.Screens.Play public Action OnSeek; - private double currentTime; - public double CurrentTime + private double progress; + public double Progress { - get { return currentTime; } + get { return progress; } set { - currentTime = value; - updateProgress(); - } - } - - private double length; - public double Length - { - get { return length; } - set - { - length = value; + progress = value; updateProgress(); } } @@ -59,7 +50,7 @@ namespace osu.Game.Screens.Play public SongProgress() { RelativeSizeAxes = Axes.X; - Height = progress_height + SongProgressGraph.Column.HEIGHT + handleSize.Y; + Height = progress_height + SongProgressGraph.Column.HEIGHT + handle_size.Y; Children = new Drawable[] { @@ -71,13 +62,13 @@ namespace osu.Game.Screens.Play Height = SongProgressGraph.Column.HEIGHT, Margin = new MarginPadding { Bottom = progress_height }, }, - bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handleSize) + bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handle_size) { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, SeekRequested = delegate (float position) { - OnSeek?.Invoke(Length * position); + OnSeek?.Invoke(position); }, }, }; @@ -85,9 +76,8 @@ namespace osu.Game.Screens.Play private void updateProgress() { - float currentProgress = (float)(CurrentTime / Length); - bar.UpdatePosition(currentProgress); - graph.Progress = (int)(graph.ColumnCount * currentProgress); + bar.UpdatePosition((float)progress); + graph.Progress = (int)(graph.ColumnCount * progress); } protected override void PopIn() @@ -105,5 +95,12 @@ namespace osu.Game.Screens.Play bar.FadeOut(transition_duration, EasingTypes.In); MoveTo(new Vector2(0f, progress_height), transition_duration, EasingTypes.In); } + + protected override void Update() + { + base.Update(); + + updateProgress(); + } } } diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index f8ee030d21..a42122d9e1 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -14,8 +14,8 @@ namespace osu.Game.Screens.Play { public Color4 FillColour { - get { return Fill.Colour; } - set { Fill.Colour = value; } + get { return FillContainer.Colour; } + set { FillContainer.Colour = value; } } public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize) diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 9bac81a721..4f0cdbf67a 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -117,7 +117,7 @@ namespace osu.Game.Screens.Play } float step = values.Length / (float)ColumnCount; - for (float i = 0; i < values.Length; i += step) + for (float i = 0; i < values.Length; i += step) { newValues.Add(values[(int)i]); } From 8c41707ac798c94bd2c3e06bfc9c44ba48727457 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 14 Apr 2017 14:40:52 +0900 Subject: [PATCH 37/43] Fix incorrect default state. Handle input better. --- .../Tests/TestCaseSongProgress.cs | 395 +----------------- osu.Game/Overlays/DragBar.cs | 13 +- osu.Game/Screens/Play/SongProgress.cs | 36 +- osu.Game/Screens/Play/SongProgressBar.cs | 13 +- 4 files changed, 43 insertions(+), 414 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index feb7aac0ce..aafd1753e5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -1,22 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Collections.Generic; -using System.Linq; -using osu.Framework; -using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Framework.Testing; -using osu.Game.Graphics; -using osu.Game.Overlays; -using OpenTK; -using OpenTK.Graphics; +using osu.Game.Screens.Play; namespace osu.Desktop.VisualTests.Tests { @@ -34,7 +23,6 @@ namespace osu.Desktop.VisualTests.Tests { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, }); AddStep("Toggle Bar", progress.ToggleBar); @@ -57,385 +45,4 @@ namespace osu.Desktop.VisualTests.Tests progress.Progress = RNG.NextDouble(); } } - - public class SongProgress : OverlayContainer - { - private const int progress_height = 5; - - private static readonly Vector2 handle_size = new Vector2(14, 25); - - private const float transition_duration = 200; - - private readonly SongProgressBar bar; - private readonly SongProgressGraph graph; - - public Action OnSeek; - - private double progress; - public double Progress - { - get { return progress; } - set - { - progress = value; - updateProgress(); - } - } - - public int[] Values - { - get { return graph.Values; } - set { graph.Values = value; } - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - graph.FillColour = bar.FillColour = colours.BlueLighter; - } - - public SongProgress() - { - RelativeSizeAxes = Axes.X; - Height = progress_height + SongProgressGraph.Column.HEIGHT + handle_size.Y; - - Children = new Drawable[] - { - graph = new SongProgressGraph - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Height = SongProgressGraph.Column.HEIGHT, - Margin = new MarginPadding { Bottom = progress_height }, - }, - bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handle_size) - { - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Alpha = 0, - SeekRequested = delegate (float position) - { - OnSeek?.Invoke(position); - }, - }, - }; - } - - private void updateProgress() - { - bar.UpdatePosition((float)progress); - graph.Progress = (int)(graph.ColumnCount * progress); - } - - private bool barVisible; - - public void ToggleBar() - { - barVisible = !barVisible; - - updateBarVisibility(); - } - - private void updateBarVisibility() - { - bar.FadeTo(barVisible ? 1 : 0, transition_duration, EasingTypes.In); - MoveTo(new Vector2(0, barVisible ? 0 : progress_height), transition_duration, EasingTypes.In); - } - - protected override void PopIn() - { - updateBarVisibility(); - } - - protected override void PopOut() - { - } - - protected override void Update() - { - base.Update(); - - updateProgress(); - } - } - - public class SongProgressGraph : BufferedContainer - { - private Game.Screens.Play.SongProgressGraph.Column[] columns = { }; - - public int ColumnCount => columns.Length; - - public override bool HandleInput => false; - - private int progress; - public int Progress - { - get { return progress; } - set - { - if (value == progress) return; - progress = value; - - redrawProgress(); - } - } - - private int[] calculatedValues = { }; // values but adjusted to fit the amount of columns - private int[] values; - public int[] Values - { - get { return values; } - set - { - if (value == values) return; - values = value; - recreateGraph(); - } - } - - private Color4 fillColour; - public Color4 FillColour - { - get { return fillColour; } - set - { - if (value == fillColour) return; - fillColour = value; - - redrawFilled(); - } - } - - public SongProgressGraph() - { - CacheDrawnFrameBuffer = true; - PixelSnapping = true; - } - - private float lastDrawWidth; - protected override void Update() - { - base.Update(); - - // todo: Recreating in update is probably not the best idea - if (DrawWidth == lastDrawWidth) return; - recreateGraph(); - lastDrawWidth = DrawWidth; - } - - /// - /// Redraws all the columns to match their lit/dimmed state. - /// - private void redrawProgress() - { - for (int i = 0; i < columns.Length; i++) - { - columns[i].State = i <= progress ? Game.Screens.Play.SongProgressGraph.ColumnState.Lit : Game.Screens.Play.SongProgressGraph.ColumnState.Dimmed; - } - - ForceRedraw(); - } - - /// - /// Redraws the filled amount of all the columns. - /// - private void redrawFilled() - { - for (int i = 0; i < ColumnCount; i++) - { - columns[i].Filled = calculatedValues.ElementAtOrDefault(i); - } - } - - /// - /// Takes and adjusts it to fit the amount of columns. - /// - private void recalculateValues() - { - var newValues = new List(); - - if (values == null) - { - for (float i = 0; i < ColumnCount; i++) - newValues.Add(0); - - return; - } - - float step = values.Length / (float)ColumnCount; - for (float i = 0; i < values.Length; i += step) - { - newValues.Add(values[(int)i]); - } - - calculatedValues = newValues.ToArray(); - } - - /// - /// Recreates the entire graph. - /// - private void recreateGraph() - { - var newColumns = new List(); - - for (float x = 0; x < DrawWidth; x += Game.Screens.Play.SongProgressGraph.Column.WIDTH) - { - newColumns.Add(new Game.Screens.Play.SongProgressGraph.Column(fillColour) - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Position = new Vector2(x, 0), - State = Game.Screens.Play.SongProgressGraph.ColumnState.Dimmed, - }); - } - - columns = newColumns.ToArray(); - Children = columns; - - recalculateValues(); - redrawFilled(); - redrawProgress(); - } - - public class Column : Container, IStateful - { - private readonly Color4 emptyColour = Color4.White.Opacity(100); - private readonly Color4 litColour; - private readonly Color4 dimmedColour = Color4.White.Opacity(175); - - private const float cube_count = 6; - private const float cube_size = 4; - private const float padding = 2; - public const float WIDTH = cube_size + padding; - public const float HEIGHT = cube_count * WIDTH + padding; - - private readonly List drawableRows = new List(); - - private int filled; - public int Filled - { - get { return filled; } - set - { - if (value == filled) return; - filled = value; - - fillActive(); - } - } - - private Game.Screens.Play.SongProgressGraph.ColumnState state; - public Game.Screens.Play.SongProgressGraph.ColumnState State - { - get { return state; } - set - { - if (value == state) return; - state = value; - - fillActive(); - } - } - - public Column(Color4 litColour) - { - Size = new Vector2(WIDTH, HEIGHT); - this.litColour = litColour; - - for (int r = 0; r < cube_count; r++) - { - drawableRows.Add(new Box - { - EdgeSmoothness = new Vector2(padding / 4), - Size = new Vector2(cube_size), - Position = new Vector2(0, r * WIDTH + padding), - }); - } - - Children = drawableRows; - - // Reverse drawableRows so when iterating through them they start at the bottom - drawableRows.Reverse(); - } - - private void fillActive() - { - Color4 colour = State == Game.Screens.Play.SongProgressGraph.ColumnState.Lit ? litColour : dimmedColour; - - for (int i = 0; i < drawableRows.Count; i++) - { - if (Filled == 0) // i <= Filled doesn't work for zero fill - drawableRows[i].Colour = emptyColour; - else - drawableRows[i].Colour = i <= Filled ? colour : emptyColour; - } - } - } - - public enum ColumnState - { - Lit, - Dimmed - } - } - - public class SongProgressBar : DragBar - { - public Color4 FillColour - { - get { return FillContainer.Colour; } - set { FillContainer.Colour = value; } - } - - public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize) - { - Height = barHeight + handleBarHeight + handleSize.Y; - FillContainer.RelativeSizeAxes = Axes.X; - FillContainer.Height = barHeight; - - Add(new Box - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = barHeight, - Colour = Color4.Black, - Alpha = 0.5f, - Depth = 1 - }); - FillContainer.Add(new Container - { - Origin = Anchor.BottomRight, - Anchor = Anchor.BottomRight, - Width = 2, - Height = barHeight + handleBarHeight, - Colour = Color4.White, - Position = new Vector2(2, 0), - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - }, - new Container - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.TopCentre, - Size = handleSize, - CornerRadius = 5, - Masking = true, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White - } - } - } - } - }); - } - } } diff --git a/osu.Game/Overlays/DragBar.cs b/osu.Game/Overlays/DragBar.cs index 8690388127..16e399deae 100644 --- a/osu.Game/Overlays/DragBar.cs +++ b/osu.Game/Overlays/DragBar.cs @@ -13,7 +13,7 @@ namespace osu.Game.Overlays { public class DragBar : Container { - protected readonly Container FillContainer; + protected readonly Container Fill; public Action SeekRequested; @@ -27,7 +27,7 @@ namespace osu.Game.Overlays { enabled = value; if (!enabled) - FillContainer.Width = 0; + Fill.Width = 0; } } @@ -37,8 +37,9 @@ namespace osu.Game.Overlays Children = new Drawable[] { - FillContainer = new Container + Fill = new Container { + Name = "FillContainer", Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, RelativeSizeAxes = Axes.Both, @@ -63,8 +64,10 @@ namespace osu.Game.Overlays private void seek(InputState state) { - if (!IsEnabled) return; float seekLocation = state.Mouse.Position.X / DrawWidth; + + if (!IsEnabled) return; + SeekRequested?.Invoke(seekLocation); updatePosition(seekLocation); } @@ -72,7 +75,7 @@ namespace osu.Game.Overlays private void updatePosition(float position) { position = MathHelper.Clamp(position, 0, 1); - FillContainer.TransformTo(() => FillContainer.Width, position, 200, EasingTypes.OutQuint, new TransformSeek()); + Fill.TransformTo(() => Fill.Width, position, 200, EasingTypes.OutQuint, new TransformSeek()); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index b2e289c422..1cb4ebd380 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -11,7 +11,7 @@ using osu.Framework.Allocation; namespace osu.Game.Screens.Play { - public class SongProgress : OverlayContainer + public class SongProgress : OverlayContainer { private const int progress_height = 5; @@ -51,6 +51,7 @@ namespace osu.Game.Screens.Play { RelativeSizeAxes = Axes.X; Height = progress_height + SongProgressGraph.Column.HEIGHT + handle_size.Y; + Y = progress_height; Children = new Drawable[] { @@ -64,8 +65,9 @@ namespace osu.Game.Screens.Play }, bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handle_size) { - Origin = Anchor.BottomLeft, + Alpha = 0, Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, SeekRequested = delegate (float position) { OnSeek?.Invoke(position); @@ -74,26 +76,40 @@ namespace osu.Game.Screens.Play }; } + protected override void LoadComplete() + { + State = Visibility.Visible; + } + private void updateProgress() { bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); } + private bool barVisible; + + public void ToggleBar() + { + barVisible = !barVisible; + updateBarVisibility(); + } + + private void updateBarVisibility() + { + bar.FadeTo(barVisible ? 1 : 0, transition_duration, EasingTypes.In); + MoveTo(new Vector2(0, barVisible ? 0 : progress_height), transition_duration, EasingTypes.In); + } + protected override void PopIn() { - bar.IsEnabled = true; - updateProgress(); //in case progress was changed while the bar was hidden - - bar.FadeIn(transition_duration, EasingTypes.In); - MoveTo(Vector2.Zero, transition_duration, EasingTypes.In); + updateBarVisibility(); + FadeIn(100); } protected override void PopOut() { - bar.IsEnabled = false; - bar.FadeOut(transition_duration, EasingTypes.In); - MoveTo(new Vector2(0f, progress_height), transition_duration, EasingTypes.In); + FadeOut(100); } protected override void Update() diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index a42122d9e1..d0fb3c8a3d 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -14,18 +14,20 @@ namespace osu.Game.Screens.Play { public Color4 FillColour { - get { return FillContainer.Colour; } - set { FillContainer.Colour = value; } + get { return Fill.Colour; } + set { Fill.Colour = value; } } public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize) { Height = barHeight + handleBarHeight + handleSize.Y; - FillContainer.RelativeSizeAxes = Axes.X; - FillContainer.Height = barHeight; + + Fill.RelativeSizeAxes = Axes.X; + Fill.Height = barHeight; Add(new Box { + Name = "Background", Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, @@ -34,7 +36,8 @@ namespace osu.Game.Screens.Play Alpha = 0.5f, Depth = 1 }); - FillContainer.Add(new Container + + Fill.Add(new Container { Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, From 6421f040dd747f55c7e70ec5d4d96116244b65a5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 14 Apr 2017 15:27:24 +0900 Subject: [PATCH 38/43] Fix SongProgress handling escape. --- osu.Game/Screens/Play/SongProgress.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 1cb4ebd380..b5f9b7b822 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -15,6 +15,8 @@ namespace osu.Game.Screens.Play { private const int progress_height = 5; + protected override bool HideOnEscape => false; + private static readonly Vector2 handle_size = new Vector2(14, 25); private const float transition_duration = 200; @@ -104,7 +106,7 @@ namespace osu.Game.Screens.Play protected override void PopIn() { updateBarVisibility(); - FadeIn(100); + FadeIn(500, EasingTypes.OutQuint); } protected override void PopOut() From acd7a5b254721a6955dacc8e31e8b3e68ca62a23 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 14 Apr 2017 17:58:30 +0900 Subject: [PATCH 39/43] Hook up beatmap object density to progress display. --- .../Tests/TestCaseSongProgress.cs | 11 +++---- osu.Game/Modes/UI/HitRenderer.cs | 4 +++ osu.Game/Modes/UI/StandardHudOverlay.cs | 2 -- osu.Game/Screens/Play/Player.cs | 7 ++--- osu.Game/Screens/Play/SongProgress.cs | 31 +++++++++++++++++-- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index aafd1753e5..5563c0170d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Framework.Testing; +using osu.Game.Modes.Objects; using osu.Game.Screens.Play; namespace osu.Desktop.VisualTests.Tests @@ -35,13 +36,11 @@ namespace osu.Desktop.VisualTests.Tests private void displayNewValues() { - List newValues = new List(); - for (int i = 0; i < 1000; i++) - { - newValues.Add(RNG.Next(0, 6)); - } + List objects = new List(); + for (double i = 0; i < 2000; i += RNG.NextDouble() * 10 + i / 1000) + objects.Add(new HitObject { StartTime = i }); - progress.Values = newValues.ToArray(); + progress.Objects = objects; progress.Progress = RNG.NextDouble(); } } diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index dd5eff5a95..6962c80d87 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -58,6 +58,8 @@ namespace osu.Game.Modes.UI /// public bool HasReplayLoaded => InputManager.ReplayInputHandler != null; + public abstract IEnumerable Objects { get; } + /// /// Whether all the HitObjects have been judged. /// @@ -185,6 +187,8 @@ namespace osu.Game.Modes.UI private readonly Container content; + public override IEnumerable Objects => Beatmap.HitObjects; + protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) { diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index e2eda4a168..2ff5d327df 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -57,8 +57,6 @@ namespace osu.Game.Modes.UI Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - Depth = -2, //todo: find out why this doesn't put progress on top of PauseOverlay - Values = new[] { 3 }, //todo: removeme }; } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 570c1831c0..1e3555f798 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -63,9 +63,7 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config) { - var beatmap = Beatmap.Beatmap; - - if (beatmap.BeatmapInfo?.Mode > PlayMode.Taiko) + if (Beatmap.Beatmap.BeatmapInfo?.Mode > PlayMode.Taiko) { //we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor. Exit(); @@ -125,7 +123,8 @@ namespace osu.Game.Screens.Play hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys()); hudOverlay.BindProcessor(scoreProcessor); hudOverlay.BindHitRenderer(HitRenderer); - hudOverlay.Progress.Hide(); + + hudOverlay.Progress.Objects = HitRenderer.Objects; //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) HitRenderer.OnAllJudged += onCompletion; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index b5f9b7b822..4efd05ccb7 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -6,8 +6,12 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using System; +using System.Collections.Generic; using osu.Game.Graphics; using osu.Framework.Allocation; +using System.Linq; +using osu.Game.Modes.Objects; +using osu.Game.Modes.Objects.Types; namespace osu.Game.Screens.Play { @@ -37,10 +41,31 @@ namespace osu.Game.Screens.Play } } - public int[] Values + public IEnumerable Objects { - get { return graph.Values; } - set { graph.Values = value; } + set + { + var objects = value; + + const int granularity = 200; + + var lastHit = ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; + var interval = lastHit / granularity; + + var values = new int[granularity]; + + foreach (var h in objects) + { + IHasEndTime end = h as IHasEndTime; + + int startRange = (int)(h.StartTime / interval); + int endRange = (int)((end?.EndTime ?? h.StartTime) / interval); + for (int i = startRange; i <= endRange; i++) + values[i]++; + } + + graph.Values = values; + } } [BackgroundDependencyLoader] From ea0631ede8008a38b09f50e2babf80a2dd0f7458 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 14 Apr 2017 18:23:34 +0900 Subject: [PATCH 40/43] Encapsulate progress update logic better. --- .../Tests/TestCaseSongProgress.cs | 1 - osu.Game/Screens/Play/Player.cs | 8 +---- osu.Game/Screens/Play/SongProgress.cs | 35 ++++++++----------- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 5563c0170d..50d6918faa 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -41,7 +41,6 @@ namespace osu.Desktop.VisualTests.Tests objects.Add(new HitObject { StartTime = i }); progress.Objects = objects; - progress.Progress = RNG.NextDouble(); } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 1e3555f798..666c3e41a4 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -125,6 +125,7 @@ namespace osu.Game.Screens.Play hudOverlay.BindHitRenderer(HitRenderer); hudOverlay.Progress.Objects = HitRenderer.Objects; + hudOverlay.Progress.AudioClock = interpolatedSourceClock; //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) HitRenderer.OnAllJudged += onCompletion; @@ -175,13 +176,6 @@ namespace osu.Game.Screens.Play }; } - protected override void Update() - { - base.Update(); - - hudOverlay.Progress.Progress = Beatmap.Track.CurrentTime / Beatmap.Track.Length; - } - private void initializeSkipButton() { const double skip_required_cutoff = 3000; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 4efd05ccb7..52f3b9e1ae 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -10,12 +10,13 @@ using System.Collections.Generic; using osu.Game.Graphics; using osu.Framework.Allocation; using System.Linq; +using osu.Framework.Timing; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Types; namespace osu.Game.Screens.Play { - public class SongProgress : OverlayContainer + public class SongProgress : OverlayContainer { private const int progress_height = 5; @@ -30,27 +31,21 @@ namespace osu.Game.Screens.Play public Action OnSeek; - private double progress; - public double Progress - { - get { return progress; } - set - { - progress = value; - updateProgress(); - } - } + public IClock AudioClock; + + private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; + + private IEnumerable objects; public IEnumerable Objects { set { - var objects = value; + objects = value; const int granularity = 200; - var lastHit = ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; - var interval = lastHit / granularity; + var interval = lastHitTime / granularity; var values = new int[granularity]; @@ -108,12 +103,6 @@ namespace osu.Game.Screens.Play State = Visibility.Visible; } - private void updateProgress() - { - bar.UpdatePosition((float)progress); - graph.Progress = (int)(graph.ColumnCount * progress); - } - private bool barVisible; public void ToggleBar() @@ -143,7 +132,11 @@ namespace osu.Game.Screens.Play { base.Update(); - updateProgress(); + double progress = (AudioClock?.CurrentTime ?? Time.Current) / lastHitTime; + + bar.UpdatePosition((float)progress); + graph.Progress = (int)(graph.ColumnCount * progress); + } } } From 98544a807776c349cb34d816c4947ee46567d187 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 14 Apr 2017 19:20:07 +0900 Subject: [PATCH 41/43] Fix unsynchronised tweening. --- osu.Game/Overlays/DragBar.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/DragBar.cs b/osu.Game/Overlays/DragBar.cs index 16e399deae..bb28f08553 100644 --- a/osu.Game/Overlays/DragBar.cs +++ b/osu.Game/Overlays/DragBar.cs @@ -59,7 +59,7 @@ namespace osu.Game.Overlays { if (IsSeeking || !IsEnabled) return; - updatePosition(position); + updatePosition(position, false); } private void seek(InputState state) @@ -72,10 +72,10 @@ namespace osu.Game.Overlays updatePosition(seekLocation); } - private void updatePosition(float position) + private void updatePosition(float position, bool easing = true) { position = MathHelper.Clamp(position, 0, 1); - Fill.TransformTo(() => Fill.Width, position, 200, EasingTypes.OutQuint, new TransformSeek()); + Fill.TransformTo(() => Fill.Width, position, easing ? 200 : 0, EasingTypes.OutQuint, new TransformSeek()); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) From 627114abeca6f0d6d7e5e0e0a5f9e463270bd59b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 14 Apr 2017 19:23:33 +0900 Subject: [PATCH 42/43] Improve test case. --- osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 50d6918faa..363b0b481e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Framework.Testing; +using osu.Framework.Timing; using osu.Game.Modes.Objects; using osu.Game.Screens.Play; @@ -22,14 +23,16 @@ namespace osu.Desktop.VisualTests.Tests Add(progress = new SongProgress { + AudioClock = new StopwatchClock(true), Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, }); AddStep("Toggle Bar", progress.ToggleBar); AddWaitStep(5); - //AddStep("Toggle Bar", progress.ToggleVisibility); - //AddStep("New Values", displayNewValues); + AddStep("Toggle Bar", progress.ToggleBar); + AddWaitStep(2); + AddRepeatStep("New Values", displayNewValues, 5); displayNewValues(); } @@ -37,7 +40,7 @@ namespace osu.Desktop.VisualTests.Tests private void displayNewValues() { List objects = new List(); - for (double i = 0; i < 2000; i += RNG.NextDouble() * 10 + i / 1000) + for (double i = 0; i < 5000; i += RNG.NextDouble() * 10 + i / 1000) objects.Add(new HitObject { StartTime = i }); progress.Objects = objects; From 31ce66bfdcd19141148c3a8fd8db1946bda09e8a Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Sat, 15 Apr 2017 01:31:42 +0900 Subject: [PATCH 43/43] Trim whitespace. --- osu.Game/Modes/UI/StandardHudOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index 6e9d5fb805..161a700bef 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -63,7 +63,7 @@ namespace osu.Game.Modes.UI Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, }; - + [BackgroundDependencyLoader] private void load(OsuColour colours) {