From 740e766201ccedccfa191a80a51ebc2c01a62352 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 15 Sep 2017 19:39:55 +0300 Subject: [PATCH 01/46] BreakOverlay and LetterboxOverlay implementation --- .../Visual/TestCaseBreakOverlay.cs | 74 +++++++++++++++++++ osu.Desktop.Tests/osu.Desktop.Tests.csproj | 1 + osu.Game/Beatmaps/Timing/BreakPeriod.cs | 6 +- osu.Game/Screens/Play/BreakOverlay.cs | 64 ++++++++++++++++ osu.Game/Screens/Play/LetterboxOverlay.cs | 63 ++++++++++++++++ osu.Game/Screens/Play/Player.cs | 14 ++-- osu.Game/osu.Game.csproj | 2 + 7 files changed, 216 insertions(+), 8 deletions(-) create mode 100644 osu.Desktop.Tests/Visual/TestCaseBreakOverlay.cs create mode 100644 osu.Game/Screens/Play/BreakOverlay.cs create mode 100644 osu.Game/Screens/Play/LetterboxOverlay.cs diff --git a/osu.Desktop.Tests/Visual/TestCaseBreakOverlay.cs b/osu.Desktop.Tests/Visual/TestCaseBreakOverlay.cs new file mode 100644 index 0000000000..2c77b1ca39 --- /dev/null +++ b/osu.Desktop.Tests/Visual/TestCaseBreakOverlay.cs @@ -0,0 +1,74 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Timing; +using osu.Game.Beatmaps.Timing; +using osu.Game.Screens.Play; +using System.Collections.Generic; + +namespace osu.Desktop.Tests.Visual +{ + internal class TestCaseBreakOverlay : OsuTestCase + { + public override string Description => @"Tests breaks behavior"; + + private readonly BreakOverlay breakOverlay; + + public TestCaseBreakOverlay() + { + Clock = new FramedClock(); + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + }, + breakOverlay = new BreakOverlay(true) + }; + + AddStep("Add 2s break", () => startBreak(2000)); + AddStep("Add 5s break", () => startBreak(5000)); + AddStep("Add 2 breaks (2s each)", startMultipleBreaks); + } + + private void startBreak(double duration) + { + breakOverlay.Breaks = new List + { + new BreakPeriod + { + StartTime = Clock.CurrentTime, + EndTime = Clock.CurrentTime + duration, + } + }; + + breakOverlay.InitializeBreaks(); + } + + private void startMultipleBreaks() + { + double currentTime = Clock.CurrentTime; + + breakOverlay.Breaks = new List + { + new BreakPeriod + { + StartTime = currentTime, + EndTime = currentTime + 2000, + }, + new BreakPeriod + { + StartTime = currentTime + 4000, + EndTime = currentTime + 6000, + } + }; + + breakOverlay.InitializeBreaks(); + } + } +} \ No newline at end of file diff --git a/osu.Desktop.Tests/osu.Desktop.Tests.csproj b/osu.Desktop.Tests/osu.Desktop.Tests.csproj index f894b25f06..5882578b79 100644 --- a/osu.Desktop.Tests/osu.Desktop.Tests.csproj +++ b/osu.Desktop.Tests/osu.Desktop.Tests.csproj @@ -72,6 +72,7 @@ + diff --git a/osu.Game/Beatmaps/Timing/BreakPeriod.cs b/osu.Game/Beatmaps/Timing/BreakPeriod.cs index fb307b7144..0cf4a0c65b 100644 --- a/osu.Game/Beatmaps/Timing/BreakPeriod.cs +++ b/osu.Game/Beatmaps/Timing/BreakPeriod.cs @@ -8,7 +8,7 @@ namespace osu.Game.Beatmaps.Timing /// /// The minimum duration required for a break to have any effect. /// - private const double min_break_duration = 650; + public const double MIN_BREAK_DURATION = 650; /// /// The break start time. @@ -28,6 +28,6 @@ namespace osu.Game.Beatmaps.Timing /// /// Whether the break has any effect. Breaks that are too short are culled before they are added to the beatmap. /// - public bool HasEffect => Duration >= min_break_duration; + public bool HasEffect => Duration >= MIN_BREAK_DURATION; } -} +} \ No newline at end of file diff --git a/osu.Game/Screens/Play/BreakOverlay.cs b/osu.Game/Screens/Play/BreakOverlay.cs new file mode 100644 index 0000000000..2cbf6fd3c8 --- /dev/null +++ b/osu.Game/Screens/Play/BreakOverlay.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using System.Collections.Generic; +using osu.Game.Beatmaps.Timing; + +namespace osu.Game.Screens.Play +{ + public class BreakOverlay : VisibilityContainer + { + private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; + + public List Breaks; + + private readonly bool letterboxing; + private readonly LetterboxOverlay letterboxOverlay; + + public BreakOverlay(bool letterboxing) + { + this.letterboxing = letterboxing; + + RelativeSizeAxes = Axes.Both; + Child = letterboxOverlay = new LetterboxOverlay(); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + InitializeBreaks(); + } + + public void InitializeBreaks() + { + if (Breaks != null) + { + foreach (var b in Breaks) + { + if (b.HasEffect) + { + using (BeginAbsoluteSequence(b.StartTime, true)) + { + Show(); + + using (BeginDelayedSequence(b.Duration, true)) + Hide(); + } + } + } + } + } + + protected override void PopIn() + { + if (letterboxing) letterboxOverlay.FadeIn(fade_duration); + } + + protected override void PopOut() + { + if (letterboxing) letterboxOverlay.FadeOut(fade_duration); + } + } +} diff --git a/osu.Game/Screens/Play/LetterboxOverlay.cs b/osu.Game/Screens/Play/LetterboxOverlay.cs new file mode 100644 index 0000000000..6672b947e7 --- /dev/null +++ b/osu.Game/Screens/Play/LetterboxOverlay.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; + +namespace osu.Game.Screens.Play +{ + public class LetterboxOverlay : Container + { + private const int letterbox_height = 350; + + private Color4 transparentBlack => new Color4(0, 0, 0, 0); + + public LetterboxOverlay() + { + RelativeSizeAxes = Axes.Both; + Alpha = 0; + Children = new Drawable[] + { + new Container + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + RelativeSizeAxes = Axes.X, + Height = letterbox_height, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new ColourInfo + { + TopLeft = Color4.Black, + TopRight = Color4.Black, + BottomLeft = transparentBlack, + BottomRight = transparentBlack, + } + } + }, + new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = letterbox_height, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new ColourInfo + { + TopLeft = transparentBlack, + TopRight = transparentBlack, + BottomLeft = Color4.Black, + BottomRight = Color4.Black, + } + } + } + }; + } + } +} \ No newline at end of file diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 593abb7d26..f7b5da97e9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -161,21 +161,25 @@ namespace osu.Game.Screens.Play }, Children = new Drawable[] { - new SkipButton(firstObjectTime) { AudioClock = decoupledClock }, new Container { RelativeSizeAxes = Axes.Both, Clock = offsetClock, - Children = new Drawable[] - { - RulesetContainer, - } + Child = RulesetContainer, }, hudOverlay = new HUDOverlay { Anchor = Anchor.Centre, Origin = Anchor.Centre }, + new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Breaks = beatmap.Breaks, + Clock = decoupledClock + }, + new SkipButton(firstObjectTime) { AudioClock = decoupledClock }, } }, failOverlay = new FailOverlay diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 92bcaf90f0..19b32669f5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -81,6 +81,8 @@ + + From c59d398aa527ae0beeacab2f44351fa9ec8477f6 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 19 Sep 2017 17:26:17 +0300 Subject: [PATCH 02/46] Fix includes --- osu.Game/osu.Game.csproj | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 9301002958..5af2e18753 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -277,22 +277,6 @@ - - - - - - - - - - - - - - - - From 85b990c088c0eada760f850ef9706b72ad13def9 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 19 Sep 2017 17:28:10 +0300 Subject: [PATCH 03/46] Remove useless file --- osu.Desktop.Tests/osu.Desktop.Tests.csproj | 179 --------------------- 1 file changed, 179 deletions(-) delete mode 100644 osu.Desktop.Tests/osu.Desktop.Tests.csproj diff --git a/osu.Desktop.Tests/osu.Desktop.Tests.csproj b/osu.Desktop.Tests/osu.Desktop.Tests.csproj deleted file mode 100644 index 5882578b79..0000000000 --- a/osu.Desktop.Tests/osu.Desktop.Tests.csproj +++ /dev/null @@ -1,179 +0,0 @@ - - - - - Debug - AnyCPU - {230AC4F3-7783-49FB-9AEC-B83CDA3B9F3D} - Library - Properties - osu.Desktop.Tests - osu.Desktop.Tests - v4.6.1 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - 6 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - - $(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - True - - - $(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll - True - - - $(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll - True - - - False - $(SolutionDir)\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - - $(SolutionDir)\packages\SQLiteNetExtensions.1.3.0\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\SQLiteNetExtensions.dll - - - $(SolutionDir)\packages\SQLite.Net-PCL.3.1.1\lib\net4\SQLite.Net.Platform.Win32.dll - - - $(SolutionDir)\packages\SQLite.Net-PCL.3.1.1\lib\net40\SQLite.Net.Platform.Generic.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {65DC628F-A640-4111-AB35-3A5652BC1E17} - osu.Framework.Desktop - - - {007b2356-ab6f-4bd9-96d5-116fc2dce69a} - osu.Framework.Testing - - - {C76BF5B3-985E-4D39-95FE-97C9C879B83A} - osu.Framework - - - {d9a367c9-4c1a-489f-9b05-a0cea2b53b58} - osu.Game.Resources - - - {58F6C80C-1253-4A0E-A465-B8C85EBEADF3} - osu.Game.Rulesets.Catch - - - {48F4582B-7687-4621-9CBE-5C24197CB536} - osu.Game.Rulesets.Mania - - - {C92A607B-1FDD-4954-9F92-03FF547D9080} - osu.Game.Rulesets.Osu - - - {F167E17A-7DE6-4AF5-B920-A5112296C695} - osu.Game.Rulesets.Taiko - - - {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D} - osu.Game - - - - - osu.licenseheader - - - - - - - - - - - - - - \ No newline at end of file From 4cf88c72bfece5cfca8dd9b728fd3aa1fd7ffa65 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 19 Sep 2017 17:37:34 +0300 Subject: [PATCH 04/46] Move testcase to the correct project --- .../Tests}/Visual/TestCaseBreakOverlay.cs | 2 +- osu.Game/osu.Game.csproj | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename {osu.Desktop.Tests => osu.Game/Tests}/Visual/TestCaseBreakOverlay.cs (95%) diff --git a/osu.Desktop.Tests/Visual/TestCaseBreakOverlay.cs b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs similarity index 95% rename from osu.Desktop.Tests/Visual/TestCaseBreakOverlay.cs rename to osu.Game/Tests/Visual/TestCaseBreakOverlay.cs index 2c77b1ca39..5bf558f79c 100644 --- a/osu.Desktop.Tests/Visual/TestCaseBreakOverlay.cs +++ b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs @@ -9,7 +9,7 @@ using osu.Game.Beatmaps.Timing; using osu.Game.Screens.Play; using System.Collections.Generic; -namespace osu.Desktop.Tests.Visual +namespace osu.Game.Tests.Visual { internal class TestCaseBreakOverlay : OsuTestCase { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 5af2e18753..fef9683cc8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -728,6 +728,7 @@ + From 0f04d8c6a7dd2584542eb40e538636e96f0f582a Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 20 Sep 2017 15:58:28 +0300 Subject: [PATCH 05/46] Add remaining time container --- osu.Game/Screens/Play/BreakOverlay.cs | 38 +++++++++++++++---- osu.Game/Tests/Visual/TestCaseBreakOverlay.cs | 10 +---- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/osu.Game/Screens/Play/BreakOverlay.cs b/osu.Game/Screens/Play/BreakOverlay.cs index 2cbf6fd3c8..5162aa8007 100644 --- a/osu.Game/Screens/Play/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreakOverlay.cs @@ -5,24 +5,45 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using System.Collections.Generic; using osu.Game.Beatmaps.Timing; +using OpenTK; +using osu.Framework.Graphics.Shapes; +using OpenTK.Graphics; namespace osu.Game.Screens.Play { - public class BreakOverlay : VisibilityContainer + public class BreakOverlay : Container { private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; + private const int remaining_time_container_max_size = 500; public List Breaks; private readonly bool letterboxing; private readonly LetterboxOverlay letterboxOverlay; + private readonly Container remainingTimeContainer; public BreakOverlay(bool letterboxing) { this.letterboxing = letterboxing; RelativeSizeAxes = Axes.Both; - Child = letterboxOverlay = new LetterboxOverlay(); + Children = new Drawable[] + { + letterboxOverlay = new LetterboxOverlay(), + remainingTimeContainer = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(0, 8), + CornerRadius = 4, + Masking = true, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + } + } + }; } protected override void LoadComplete() @@ -41,22 +62,25 @@ namespace osu.Game.Screens.Play { using (BeginAbsoluteSequence(b.StartTime, true)) { - Show(); + onBreakIn(b); using (BeginDelayedSequence(b.Duration, true)) - Hide(); + onBreakOut(); } } } } } - protected override void PopIn() + private void onBreakIn(BreakPeriod b) { - if (letterboxing) letterboxOverlay.FadeIn(fade_duration); + if (letterboxing) + letterboxOverlay.FadeIn(fade_duration); + + remainingTimeContainer.ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint).Then().ResizeWidthTo(0, b.Duration); } - protected override void PopOut() + private void onBreakOut() { if (letterboxing) letterboxOverlay.FadeOut(fade_duration); } diff --git a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs index 5bf558f79c..1f59a96de2 100644 --- a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs +++ b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs @@ -21,15 +21,7 @@ namespace osu.Game.Tests.Visual { Clock = new FramedClock(); - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White, - }, - breakOverlay = new BreakOverlay(true) - }; + Child = breakOverlay = new BreakOverlay(true); AddStep("Add 2s break", () => startBreak(2000)); AddStep("Add 5s break", () => startBreak(5000)); From eb93706c26baec129a0f33d5833e30611ac636aa Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 20 Sep 2017 16:03:31 +0300 Subject: [PATCH 06/46] Remove useless usings --- osu.Game/Tests/Visual/TestCaseBreakOverlay.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs index 1f59a96de2..2f7a4a2425 100644 --- a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs +++ b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs @@ -1,9 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Shapes; using osu.Framework.Timing; using osu.Game.Beatmaps.Timing; using osu.Game.Screens.Play; From 8d7db52200ec08817b46cb70596e5d80f085fd74 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 20 Sep 2017 19:45:38 +0300 Subject: [PATCH 07/46] Add remaining time counter --- osu.Game/Screens/Play/BreakOverlay.cs | 86 +++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/BreakOverlay.cs b/osu.Game/Screens/Play/BreakOverlay.cs index 5162aa8007..fe7edf36ff 100644 --- a/osu.Game/Screens/Play/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreakOverlay.cs @@ -8,6 +8,9 @@ using osu.Game.Beatmaps.Timing; using OpenTK; using osu.Framework.Graphics.Shapes; using OpenTK.Graphics; +using osu.Game.Graphics.Sprites; +using System; +using osu.Framework.Timing; namespace osu.Game.Screens.Play { @@ -18,9 +21,19 @@ namespace osu.Game.Screens.Play public List Breaks; + public override IFrameBasedClock Clock + { + set + { + base.Clock = remainingTimeCounter.Clock = value; + } + get { return base.Clock; } + } + private readonly bool letterboxing; private readonly LetterboxOverlay letterboxOverlay; - private readonly Container remainingTimeContainer; + private readonly Container remainingTimeBox; + private readonly RemainingTimeCounter remainingTimeCounter; public BreakOverlay(bool letterboxing) { @@ -30,7 +43,7 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { letterboxOverlay = new LetterboxOverlay(), - remainingTimeContainer = new Container + remainingTimeBox = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -42,6 +55,12 @@ namespace osu.Game.Screens.Play RelativeSizeAxes = Axes.Both, Colour = Color4.White, } + }, + remainingTimeCounter = new RemainingTimeCounter + { + Anchor = Anchor.Centre, + Origin = Anchor.BottomCentre, + Margin = new MarginPadding { Bottom = 25 }, } }; } @@ -77,12 +96,71 @@ namespace osu.Game.Screens.Play if (letterboxing) letterboxOverlay.FadeIn(fade_duration); - remainingTimeContainer.ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint).Then().ResizeWidthTo(0, b.Duration); + remainingTimeBox + .ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint) + .Then() + .ResizeWidthTo(0, b.Duration); + + Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); + remainingTimeCounter.FadeIn(fade_duration); } private void onBreakOut() { - if (letterboxing) letterboxOverlay.FadeOut(fade_duration); + if (letterboxing) + letterboxOverlay.FadeOut(fade_duration); + + remainingTimeCounter.FadeOut(fade_duration); + } + + private class RemainingTimeCounter : Container + { + private readonly OsuSpriteText counter; + + private int? previousSecond; + + private double remainingTime; + + private bool isCounting; + + public RemainingTimeCounter() + { + AutoSizeAxes = Axes.Both; + Alpha = 0; + Child = counter = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 35, + Font = "Venera", + }; + } + + public void StartCounting(double remainingTime) + { + this.remainingTime = remainingTime; + isCounting = true; + } + + protected override void Update() + { + base.Update(); + + if (isCounting) + { + var currentTime = Clock.CurrentTime; + if (currentTime < remainingTime) + { + int currentSecond = (int)Math.Floor((remainingTime - Clock.CurrentTime) / 1000.0) + 1; + if (currentSecond != previousSecond) + { + counter.Text = currentSecond.ToString(); + previousSecond = currentSecond; + } + } + else isCounting = false; + } + } } } } From 4699a4460821d8c318de574b395abf77a35d136e Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 20 Sep 2017 20:50:14 +0300 Subject: [PATCH 08/46] Add info container --- osu.Game/Screens/Play/BreakOverlay.cs | 100 +++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Play/BreakOverlay.cs b/osu.Game/Screens/Play/BreakOverlay.cs index fe7edf36ff..87dd86b90c 100644 --- a/osu.Game/Screens/Play/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreakOverlay.cs @@ -11,13 +11,16 @@ using OpenTK.Graphics; using osu.Game.Graphics.Sprites; using System; using osu.Framework.Timing; +using osu.Framework.Allocation; +using osu.Game.Graphics; namespace osu.Game.Screens.Play { public class BreakOverlay : Container { private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; - private const int remaining_time_container_max_size = 500; + private const int remaining_time_container_max_size = 450; + private const int element_margin = 25; public List Breaks; @@ -34,6 +37,7 @@ namespace osu.Game.Screens.Play private readonly LetterboxOverlay letterboxOverlay; private readonly Container remainingTimeBox; private readonly RemainingTimeCounter remainingTimeCounter; + private readonly InfoContainer info; public BreakOverlay(bool letterboxing) { @@ -50,17 +54,19 @@ namespace osu.Game.Screens.Play Size = new Vector2(0, 8), CornerRadius = 4, Masking = true, - Child = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White, - } + Child = new Box { RelativeSizeAxes = Axes.Both } }, remainingTimeCounter = new RemainingTimeCounter { Anchor = Anchor.Centre, Origin = Anchor.BottomCentre, - Margin = new MarginPadding { Bottom = 25 }, + Margin = new MarginPadding { Bottom = element_margin }, + }, + info = new InfoContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.TopCentre, + Margin = new MarginPadding { Top = element_margin }, } }; } @@ -103,6 +109,8 @@ namespace osu.Game.Screens.Play Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); remainingTimeCounter.FadeIn(fade_duration); + + info.FadeIn(fade_duration); } private void onBreakOut() @@ -111,6 +119,82 @@ namespace osu.Game.Screens.Play letterboxOverlay.FadeOut(fade_duration); remainingTimeCounter.FadeOut(fade_duration); + info.FadeOut(fade_duration); + } + + private class InfoContainer : FillFlowContainer + { + public InfoContainer() + { + AutoSizeAxes = Axes.Both; + Alpha = 0; + Direction = FillDirection.Vertical; + Spacing = new Vector2(5); + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = @"current progress".ToUpper(), + TextSize = 15, + Font = "Exo2.0-Black", + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Direction = FillDirection.Vertical, + Children = new InfoLine[] + { + new InfoLine(@"Accuracy", @"88.54%"), + new InfoLine(@"Rank", @"#6584"), + new InfoLine(@"Grade", @"A"), + }, + } + }; + } + + private class InfoLine : Container + { + private const int margin = 2; + + private readonly OsuSpriteText text; + private readonly OsuSpriteText valueText; + + public InfoLine(string name, string value) + { + AutoSizeAxes = Axes.Y; + Children = new Drawable[] + { + text = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreRight, + Text = name, + TextSize = 17, + Margin = new MarginPadding { Right = margin } + }, + valueText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft, + Text = value, + TextSize = 17, + Font = "Exo2.0-Bold", + Margin = new MarginPadding { Left = margin } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + text.Colour = colours.Yellow; + valueText.Colour = colours.YellowLight; + } + } } private class RemainingTimeCounter : Container @@ -131,7 +215,7 @@ namespace osu.Game.Screens.Play { Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 35, + TextSize = 33, Font = "Venera", }; } From 581689a84d37ef44d26a91590adb45faf95e71ff Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 20 Sep 2017 20:58:20 +0300 Subject: [PATCH 09/46] CI fixes --- osu.Game/Screens/Play/BreakOverlay.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/BreakOverlay.cs b/osu.Game/Screens/Play/BreakOverlay.cs index 87dd86b90c..da7ba12a6e 100644 --- a/osu.Game/Screens/Play/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreakOverlay.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using osu.Game.Beatmaps.Timing; using OpenTK; using osu.Framework.Graphics.Shapes; -using OpenTK.Graphics; using osu.Game.Graphics.Sprites; using System; using osu.Framework.Timing; @@ -146,7 +145,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Direction = FillDirection.Vertical, - Children = new InfoLine[] + Children = new [] { new InfoLine(@"Accuracy", @"88.54%"), new InfoLine(@"Rank", @"#6584"), From 18a714df74a8e8ef75cf50b8d64a292a269626c1 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 20 Sep 2017 22:33:07 +0300 Subject: [PATCH 10/46] Move every class to it's own file --- osu.Game/Screens/Play/BreakOverlay.cs | 249 ------------------ .../Play/BreaksOverlay/BreakOverlay.cs | 120 +++++++++ .../Play/BreaksOverlay/InfoContainer.cs | 87 ++++++ .../BreaksOverlay/RemainingTimeCounter.cs | 60 +++++ osu.Game/Screens/Play/Player.cs | 1 + osu.Game/Tests/Visual/TestCaseBreakOverlay.cs | 4 +- osu.Game/osu.Game.csproj | 4 +- 7 files changed, 274 insertions(+), 251 deletions(-) delete mode 100644 osu.Game/Screens/Play/BreakOverlay.cs create mode 100644 osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs create mode 100644 osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs create mode 100644 osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs diff --git a/osu.Game/Screens/Play/BreakOverlay.cs b/osu.Game/Screens/Play/BreakOverlay.cs deleted file mode 100644 index da7ba12a6e..0000000000 --- a/osu.Game/Screens/Play/BreakOverlay.cs +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics; -using System.Collections.Generic; -using osu.Game.Beatmaps.Timing; -using OpenTK; -using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics.Sprites; -using System; -using osu.Framework.Timing; -using osu.Framework.Allocation; -using osu.Game.Graphics; - -namespace osu.Game.Screens.Play -{ - public class BreakOverlay : Container - { - private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; - private const int remaining_time_container_max_size = 450; - private const int element_margin = 25; - - public List Breaks; - - public override IFrameBasedClock Clock - { - set - { - base.Clock = remainingTimeCounter.Clock = value; - } - get { return base.Clock; } - } - - private readonly bool letterboxing; - private readonly LetterboxOverlay letterboxOverlay; - private readonly Container remainingTimeBox; - private readonly RemainingTimeCounter remainingTimeCounter; - private readonly InfoContainer info; - - public BreakOverlay(bool letterboxing) - { - this.letterboxing = letterboxing; - - RelativeSizeAxes = Axes.Both; - Children = new Drawable[] - { - letterboxOverlay = new LetterboxOverlay(), - remainingTimeBox = new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(0, 8), - CornerRadius = 4, - Masking = true, - Child = new Box { RelativeSizeAxes = Axes.Both } - }, - remainingTimeCounter = new RemainingTimeCounter - { - Anchor = Anchor.Centre, - Origin = Anchor.BottomCentre, - Margin = new MarginPadding { Bottom = element_margin }, - }, - info = new InfoContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.TopCentre, - Margin = new MarginPadding { Top = element_margin }, - } - }; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - InitializeBreaks(); - } - - public void InitializeBreaks() - { - if (Breaks != null) - { - foreach (var b in Breaks) - { - if (b.HasEffect) - { - using (BeginAbsoluteSequence(b.StartTime, true)) - { - onBreakIn(b); - - using (BeginDelayedSequence(b.Duration, true)) - onBreakOut(); - } - } - } - } - } - - private void onBreakIn(BreakPeriod b) - { - if (letterboxing) - letterboxOverlay.FadeIn(fade_duration); - - remainingTimeBox - .ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint) - .Then() - .ResizeWidthTo(0, b.Duration); - - Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); - remainingTimeCounter.FadeIn(fade_duration); - - info.FadeIn(fade_duration); - } - - private void onBreakOut() - { - if (letterboxing) - letterboxOverlay.FadeOut(fade_duration); - - remainingTimeCounter.FadeOut(fade_duration); - info.FadeOut(fade_duration); - } - - private class InfoContainer : FillFlowContainer - { - public InfoContainer() - { - AutoSizeAxes = Axes.Both; - Alpha = 0; - Direction = FillDirection.Vertical; - Spacing = new Vector2(5); - Children = new Drawable[] - { - new OsuSpriteText - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Text = @"current progress".ToUpper(), - TextSize = 15, - Font = "Exo2.0-Black", - }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Direction = FillDirection.Vertical, - Children = new [] - { - new InfoLine(@"Accuracy", @"88.54%"), - new InfoLine(@"Rank", @"#6584"), - new InfoLine(@"Grade", @"A"), - }, - } - }; - } - - private class InfoLine : Container - { - private const int margin = 2; - - private readonly OsuSpriteText text; - private readonly OsuSpriteText valueText; - - public InfoLine(string name, string value) - { - AutoSizeAxes = Axes.Y; - Children = new Drawable[] - { - text = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.CentreRight, - Text = name, - TextSize = 17, - Margin = new MarginPadding { Right = margin } - }, - valueText = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.CentreLeft, - Text = value, - TextSize = 17, - Font = "Exo2.0-Bold", - Margin = new MarginPadding { Left = margin } - } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - text.Colour = colours.Yellow; - valueText.Colour = colours.YellowLight; - } - } - } - - private class RemainingTimeCounter : Container - { - private readonly OsuSpriteText counter; - - private int? previousSecond; - - private double remainingTime; - - private bool isCounting; - - public RemainingTimeCounter() - { - AutoSizeAxes = Axes.Both; - Alpha = 0; - Child = counter = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - TextSize = 33, - Font = "Venera", - }; - } - - public void StartCounting(double remainingTime) - { - this.remainingTime = remainingTime; - isCounting = true; - } - - protected override void Update() - { - base.Update(); - - if (isCounting) - { - var currentTime = Clock.CurrentTime; - if (currentTime < remainingTime) - { - int currentSecond = (int)Math.Floor((remainingTime - Clock.CurrentTime) / 1000.0) + 1; - if (currentSecond != previousSecond) - { - counter.Text = currentSecond.ToString(); - previousSecond = currentSecond; - } - } - else isCounting = false; - } - } - } - } -} diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs new file mode 100644 index 0000000000..aec96c10ac --- /dev/null +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -0,0 +1,120 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Timing; +using osu.Game.Beatmaps.Timing; +using System.Collections.Generic; + +namespace osu.Game.Screens.Play.BreaksOverlay +{ + public class BreakOverlay : Container + { + private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; + private const int remaining_time_container_max_size = 450; + private const int element_margin = 25; + + public List Breaks; + + public override IFrameBasedClock Clock + { + set + { + base.Clock = remainingTimeCounter.Clock = value; + } + get { return base.Clock; } + } + + private readonly bool letterboxing; + private readonly LetterboxOverlay letterboxOverlay; + private readonly Container remainingTimeBox; + private readonly RemainingTimeCounter remainingTimeCounter; + private readonly InfoContainer info; + + public BreakOverlay(bool letterboxing) + { + this.letterboxing = letterboxing; + + RelativeSizeAxes = Axes.Both; + Children = new Drawable[] + { + letterboxOverlay = new LetterboxOverlay(), + remainingTimeBox = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(0, 8), + CornerRadius = 4, + Masking = true, + Child = new Box { RelativeSizeAxes = Axes.Both } + }, + remainingTimeCounter = new RemainingTimeCounter + { + Anchor = Anchor.Centre, + Origin = Anchor.BottomCentre, + Margin = new MarginPadding { Bottom = element_margin }, + }, + info = new InfoContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.TopCentre, + Margin = new MarginPadding { Top = element_margin }, + } + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + InitializeBreaks(); + } + + public void InitializeBreaks() + { + if (Breaks != null) + { + foreach (var b in Breaks) + { + if (b.HasEffect) + { + using (BeginAbsoluteSequence(b.StartTime, true)) + { + onBreakIn(b); + + using (BeginDelayedSequence(b.Duration, true)) + onBreakOut(); + } + } + } + } + } + + private void onBreakIn(BreakPeriod b) + { + if (letterboxing) + letterboxOverlay.FadeIn(fade_duration); + + remainingTimeBox + .ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint) + .Then() + .ResizeWidthTo(0, b.Duration); + + Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); + remainingTimeCounter.FadeIn(fade_duration); + + info.FadeIn(fade_duration); + } + + private void onBreakOut() + { + if (letterboxing) + letterboxOverlay.FadeOut(fade_duration); + + remainingTimeCounter.FadeOut(fade_duration); + info.FadeOut(fade_duration); + } + } +} diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs new file mode 100644 index 0000000000..75fcfcba0e --- /dev/null +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs @@ -0,0 +1,87 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Play.BreaksOverlay +{ + public class InfoContainer : FillFlowContainer + { + public InfoContainer() + { + AutoSizeAxes = Axes.Both; + Alpha = 0; + Direction = FillDirection.Vertical; + Spacing = new Vector2(5); + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = @"current progress".ToUpper(), + TextSize = 15, + Font = "Exo2.0-Black", + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Direction = FillDirection.Vertical, + Children = new [] + { + new InfoLine(@"Accuracy", @"-"), + new InfoLine(@"Rank", @"-"), + new InfoLine(@"Grade", @"-"), + }, + } + }; + } + + private class InfoLine : Container + { + private const int margin = 2; + + private readonly OsuSpriteText text; + private readonly OsuSpriteText valueText; + + public InfoLine(string name, string value) + { + AutoSizeAxes = Axes.Y; + Children = new Drawable[] + { + text = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreRight, + Text = name, + TextSize = 17, + Margin = new MarginPadding { Right = margin } + }, + valueText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft, + Text = value, + TextSize = 17, + Font = "Exo2.0-Bold", + Margin = new MarginPadding { Left = margin } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + text.Colour = colours.Yellow; + valueText.Colour = colours.YellowLight; + } + } + } +} diff --git a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs new file mode 100644 index 0000000000..fbf3e10688 --- /dev/null +++ b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs @@ -0,0 +1,60 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Framework.Graphics; +using System; + +namespace osu.Game.Screens.Play.BreaksOverlay +{ + public class RemainingTimeCounter : Container + { + private readonly OsuSpriteText counter; + + private int? previousSecond; + + private double remainingTime; + + private bool isCounting; + + public RemainingTimeCounter() + { + AutoSizeAxes = Axes.Both; + Alpha = 0; + Child = counter = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 33, + Font = "Venera", + }; + } + + public void StartCounting(double remainingTime) + { + this.remainingTime = remainingTime; + isCounting = true; + } + + protected override void Update() + { + base.Update(); + + if (isCounting) + { + var currentTime = Clock.CurrentTime; + if (currentTime < remainingTime) + { + int currentSecond = (int)Math.Floor((remainingTime - Clock.CurrentTime) / 1000.0) + 1; + if (currentSecond != previousSecond) + { + counter.Text = currentSecond.ToString(); + previousSecond = currentSecond; + } + } + else isCounting = false; + } + } + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index f7b5da97e9..86aa00875c 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -24,6 +24,7 @@ using osu.Game.Screens.Ranking; using osu.Framework.Audio.Sample; using osu.Game.Beatmaps; using osu.Game.Online.API; +using osu.Game.Screens.Play.BreaksOverlay; namespace osu.Game.Screens.Play { diff --git a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs index 2f7a4a2425..055a2bc5c4 100644 --- a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs +++ b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs @@ -3,7 +3,7 @@ using osu.Framework.Timing; using osu.Game.Beatmaps.Timing; -using osu.Game.Screens.Play; +using osu.Game.Screens.Play.BreaksOverlay; using System.Collections.Generic; namespace osu.Game.Tests.Visual @@ -22,6 +22,8 @@ namespace osu.Game.Tests.Visual AddStep("Add 2s break", () => startBreak(2000)); AddStep("Add 5s break", () => startBreak(5000)); + AddStep("Add 10s break", () => startBreak(10000)); + AddStep("Add 15s break", () => startBreak(15000)); AddStep("Add 2 breaks (2s each)", startMultipleBreaks); } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index fef9683cc8..406867c656 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -275,7 +275,9 @@ - + + + From c79568135a44d1889c6a2f204bf6f12589049427 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 21 Sep 2017 01:44:30 +0300 Subject: [PATCH 11/46] Add arrows --- .../Screens/Play/BreaksOverlay/BlurredIcon.cs | 40 ++++++++++ .../Play/BreaksOverlay/BreakOverlay.cs | 60 +++++++++++++-- .../Screens/Play/BreaksOverlay/GlowingIcon.cs | 74 +++++++++++++++++++ .../{ => BreaksOverlay}/LetterboxOverlay.cs | 4 +- osu.Game/osu.Game.csproj | 4 +- 5 files changed, 173 insertions(+), 9 deletions(-) create mode 100644 osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs create mode 100644 osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs rename osu.Game/Screens/Play/{ => BreaksOverlay}/LetterboxOverlay.cs (95%) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs b/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs new file mode 100644 index 0000000000..582bd818bd --- /dev/null +++ b/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs @@ -0,0 +1,40 @@ +// 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.Containers; +using osu.Framework.Graphics; +using osu.Game.Graphics; + +namespace osu.Game.Screens.Play.BreaksOverlay +{ + public class BlurredIcon : BufferedContainer + { + private const int icon_size = 130; + + private readonly GlowingIcon icon; + + public FontAwesome Icon + { + set { icon.Icon = value; } + get { return icon.Icon; } + } + + public BlurredIcon() + { + Anchor = Anchor.CentreLeft; + RelativePositionAxes = Axes.X; + Size = new Vector2(icon_size * 1.7f); + Masking = true; + BlurSigma = new Vector2(20); + Alpha = 0.6f; + CacheDrawnFrameBuffer = true; + Child = icon = new GlowingIcon + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Size = new Vector2(icon_size), + }; + } + } +} diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index aec96c10ac..7e245a33d9 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -14,8 +14,11 @@ namespace osu.Game.Screens.Play.BreaksOverlay public class BreakOverlay : Container { private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; - private const int remaining_time_container_max_size = 450; - private const int element_margin = 25; + private const float remaining_time_container_max_size = 0.35f; + private const int vertical_margin = 25; + private const float glowing_x_offset = 0.13f; + private const float glowing_x_final = 0.22f; + private const float blurred_x_offset = 0.2f; public List Breaks; @@ -34,6 +37,12 @@ namespace osu.Game.Screens.Play.BreaksOverlay private readonly RemainingTimeCounter remainingTimeCounter; private readonly InfoContainer info; + private readonly GlowingIcon leftGlowingIcon; + private readonly GlowingIcon rightGlowingIcon; + + private readonly BlurredIcon leftBlurredIcon; + private readonly BlurredIcon rightBlurredIcon; + public BreakOverlay(bool letterboxing) { this.letterboxing = letterboxing; @@ -41,11 +50,16 @@ namespace osu.Game.Screens.Play.BreaksOverlay RelativeSizeAxes = Axes.Both; Children = new Drawable[] { - letterboxOverlay = new LetterboxOverlay(), + letterboxOverlay = new LetterboxOverlay + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, remainingTimeBox = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, Size = new Vector2(0, 8), CornerRadius = 4, Masking = true, @@ -55,13 +69,35 @@ namespace osu.Game.Screens.Play.BreaksOverlay { Anchor = Anchor.Centre, Origin = Anchor.BottomCentre, - Margin = new MarginPadding { Bottom = element_margin }, + Margin = new MarginPadding { Bottom = vertical_margin }, }, info = new InfoContainer { Anchor = Anchor.Centre, Origin = Anchor.TopCentre, - Margin = new MarginPadding { Top = element_margin }, + Margin = new MarginPadding { Top = vertical_margin }, + }, + leftGlowingIcon = new GlowingIcon + { + Origin = Anchor.CentreRight, + Icon = Graphics.FontAwesome.fa_chevron_left, + Size = new Vector2(60), + }, + rightGlowingIcon = new GlowingIcon + { + Origin = Anchor.CentreLeft, + Icon = Graphics.FontAwesome.fa_chevron_right, + Size = new Vector2(60), + }, + leftBlurredIcon = new BlurredIcon + { + Origin = Anchor.CentreRight, + Icon = Graphics.FontAwesome.fa_chevron_left, + }, + rightBlurredIcon = new BlurredIcon + { + Origin = Anchor.CentreLeft, + Icon = Graphics.FontAwesome.fa_chevron_right, } }; } @@ -102,10 +138,16 @@ namespace osu.Game.Screens.Play.BreaksOverlay .Then() .ResizeWidthTo(0, b.Duration); - Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); + Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime); remainingTimeCounter.FadeIn(fade_duration); info.FadeIn(fade_duration); + + leftGlowingIcon.MoveToX(1 - glowing_x_final, fade_duration, Easing.OutQuint); + rightGlowingIcon.MoveToX(glowing_x_final, fade_duration, Easing.OutQuint); + + leftBlurredIcon.MoveToX(1, fade_duration, Easing.OutQuint); + rightBlurredIcon.MoveToX(0, fade_duration, Easing.OutQuint); } private void onBreakOut() @@ -115,6 +157,12 @@ namespace osu.Game.Screens.Play.BreaksOverlay remainingTimeCounter.FadeOut(fade_duration); info.FadeOut(fade_duration); + + leftGlowingIcon.MoveToX(1 + glowing_x_offset, fade_duration, Easing.OutQuint); + rightGlowingIcon.MoveToX(-glowing_x_offset, fade_duration, Easing.OutQuint); + + leftBlurredIcon.MoveToX(1 + blurred_x_offset, fade_duration, Easing.OutQuint); + rightBlurredIcon.MoveToX(-blurred_x_offset, fade_duration, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs b/osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs new file mode 100644 index 0000000000..fe08a81c5a --- /dev/null +++ b/osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs @@ -0,0 +1,74 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; + +namespace osu.Game.Screens.Play.BreaksOverlay +{ + public class GlowingIcon : Container + { + private readonly SpriteIcon icon; + private readonly SpriteIcon glow; + private readonly BufferedContainer glowContainer; + + public FontAwesome Icon + { + set { icon.Icon = glow.Icon = value; } + get { return icon.Icon; } + } + + public override Vector2 Size + { + set + { + glow.Size = icon.Size = value; + glowContainer.Size = value * 1.5f; + } + get + { + return glow.Size; + } + } + + public GlowingIcon() + { + Anchor = Anchor.CentreLeft; + RelativePositionAxes = Axes.X; + AutoSizeAxes = Axes.Both; + Children = new Drawable[] + { + glowContainer = new BufferedContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Masking = true, + BlurSigma = new Vector2(10), + CacheDrawnFrameBuffer = true, + Child = glow = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Shadow = false, + }, + }, + icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Shadow = false, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + glow.Colour = colours.Blue; + } + } +} diff --git a/osu.Game/Screens/Play/LetterboxOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs similarity index 95% rename from osu.Game/Screens/Play/LetterboxOverlay.cs rename to osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs index 6672b947e7..c95b15ef3a 100644 --- a/osu.Game/Screens/Play/LetterboxOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs @@ -7,7 +7,7 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -namespace osu.Game.Screens.Play +namespace osu.Game.Screens.Play.BreaksOverlay { public class LetterboxOverlay : Container { @@ -60,4 +60,4 @@ namespace osu.Game.Screens.Play }; } } -} \ No newline at end of file +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 406867c656..904e7800b8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -275,10 +275,12 @@ + + + - From e051bcc6dfd1895bbbca61dac269a5e59e1cf2bd Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 21 Sep 2017 01:51:40 +0300 Subject: [PATCH 12/46] Fix wrong arrows position on startup --- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 7e245a33d9..d603298262 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -82,22 +82,26 @@ namespace osu.Game.Screens.Play.BreaksOverlay Origin = Anchor.CentreRight, Icon = Graphics.FontAwesome.fa_chevron_left, Size = new Vector2(60), + X = 1 + glowing_x_offset, }, rightGlowingIcon = new GlowingIcon { Origin = Anchor.CentreLeft, Icon = Graphics.FontAwesome.fa_chevron_right, Size = new Vector2(60), + X = -glowing_x_offset, }, leftBlurredIcon = new BlurredIcon { Origin = Anchor.CentreRight, Icon = Graphics.FontAwesome.fa_chevron_left, + X = 1 + blurred_x_offset, }, rightBlurredIcon = new BlurredIcon { Origin = Anchor.CentreLeft, Icon = Graphics.FontAwesome.fa_chevron_right, + X = -blurred_x_offset, } }; } From 9667270336263be0894280dd0becb12186b4e602 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 21 Sep 2017 01:56:50 +0300 Subject: [PATCH 13/46] Remove using --- osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs b/osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs index fe08a81c5a..c92b0121c9 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.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.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; From 22ab2c5e5dfd6e26e5050e2a220a23072c451224 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 21 Sep 2017 22:54:46 +0300 Subject: [PATCH 14/46] Apply suggested changes --- .../Play/BreaksOverlay/BreakOverlay.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index d603298262..970e8c7d49 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -114,20 +114,20 @@ namespace osu.Game.Screens.Play.BreaksOverlay public void InitializeBreaks() { - if (Breaks != null) - { - foreach (var b in Breaks) - { - if (b.HasEffect) - { - using (BeginAbsoluteSequence(b.StartTime, true)) - { - onBreakIn(b); + if (Breaks == null) + return; - using (BeginDelayedSequence(b.Duration, true)) - onBreakOut(); - } - } + foreach (var b in Breaks) + { + if (!b.HasEffect) + continue; + + using (BeginAbsoluteSequence(b.StartTime, true)) + { + onBreakIn(b); + + using (BeginDelayedSequence(b.Duration, true)) + onBreakOut(); } } } From 5383e33f3d5616431fa03ebed2598e60a0317f8e Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 21 Sep 2017 22:58:49 +0300 Subject: [PATCH 15/46] Remove useless clock assignment --- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 970e8c7d49..29b24f1f87 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -5,7 +5,6 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Timing; using osu.Game.Beatmaps.Timing; using System.Collections.Generic; @@ -22,15 +21,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay public List Breaks; - public override IFrameBasedClock Clock - { - set - { - base.Clock = remainingTimeCounter.Clock = value; - } - get { return base.Clock; } - } - private readonly bool letterboxing; private readonly LetterboxOverlay letterboxOverlay; private readonly Container remainingTimeBox; From 56bde648393fb8870d1d755d9b531d972c862a82 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 22 Sep 2017 01:16:05 +0300 Subject: [PATCH 16/46] Add arrows overlay --- .../Play/BreaksOverlay/ArrowsOverlay.cs | 84 +++++++++++++++++++ .../Screens/Play/BreaksOverlay/BlurredIcon.cs | 22 +++-- .../Play/BreaksOverlay/BreakOverlay.cs | 51 ++--------- .../{GlowingIcon.cs => GlowIcon.cs} | 48 +++++------ osu.Game/osu.Game.csproj | 3 +- 5 files changed, 129 insertions(+), 79 deletions(-) create mode 100644 osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs rename osu.Game/Screens/Play/BreaksOverlay/{GlowingIcon.cs => GlowIcon.cs} (65%) diff --git a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs new file mode 100644 index 0000000000..715cc4fc0f --- /dev/null +++ b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs @@ -0,0 +1,84 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using OpenTK; + +namespace osu.Game.Screens.Play.BreaksOverlay +{ + public class ArrowsOverlay : Container + { + private const int glowing_size = 60; + private const float glowing_final_offset = 0.25f; + private const float glowing_offscreen_offset = 0.6f; + + private const int blurred_size = 130; + private const float blurred_final_offset = 0.35f; + private const float blurred_offscreen_offset = 0.7f; + + private readonly GlowIcon leftGlowIcon; + private readonly GlowIcon rightGlowIcon; + + private readonly BlurredIcon leftBlurredIcon; + private readonly BlurredIcon rightBlurredIcon; + + public ArrowsOverlay() + { + RelativeSizeAxes = Axes.Both; + Children = new Drawable[] + { + leftGlowIcon = new GlowIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreRight, + X = - glowing_offscreen_offset, + Icon = Graphics.FontAwesome.fa_chevron_right, + Size = new Vector2(glowing_size), + }, + rightGlowIcon = new GlowIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft, + X = glowing_offscreen_offset, + Icon = Graphics.FontAwesome.fa_chevron_left, + Size = new Vector2(glowing_size), + }, + leftBlurredIcon = new BlurredIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreRight, + X = - blurred_offscreen_offset, + Icon = Graphics.FontAwesome.fa_chevron_right, + Size = new Vector2(blurred_size), + }, + rightBlurredIcon = new BlurredIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft, + X = blurred_offscreen_offset, + Icon = Graphics.FontAwesome.fa_chevron_left, + Size = new Vector2(blurred_size), + }, + }; + } + + public void Show(double fadeDuration) + { + leftGlowIcon.MoveToX(-glowing_final_offset, fadeDuration, Easing.OutQuint); + rightGlowIcon.MoveToX(glowing_final_offset, fadeDuration, Easing.OutQuint); + + leftBlurredIcon.MoveToX(-blurred_final_offset, fadeDuration, Easing.OutQuint); + rightBlurredIcon.MoveToX(blurred_final_offset, fadeDuration, Easing.OutQuint); + } + + public void Hide(double fadeDuration) + { + leftGlowIcon.MoveToX(-glowing_offscreen_offset, fadeDuration, Easing.OutQuint); + rightGlowIcon.MoveToX(glowing_offscreen_offset, fadeDuration, Easing.OutQuint); + + leftBlurredIcon.MoveToX(-blurred_offscreen_offset, fadeDuration, Easing.OutQuint); + rightBlurredIcon.MoveToX(blurred_offscreen_offset, fadeDuration, Easing.OutQuint); + } + } +} diff --git a/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs b/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs index 582bd818bd..25e6eef1fd 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs @@ -10,9 +10,9 @@ namespace osu.Game.Screens.Play.BreaksOverlay { public class BlurredIcon : BufferedContainer { - private const int icon_size = 130; + private const int blur_sigma = 20; - private readonly GlowingIcon icon; + private readonly GlowIcon icon; public FontAwesome Icon { @@ -20,20 +20,26 @@ namespace osu.Game.Screens.Play.BreaksOverlay get { return icon.Icon; } } + public override Vector2 Size + { + set + { + icon.Size = value; + base.Size = value + new Vector2(blur_sigma * 2); + } + get { return icon.Size; } + } + public BlurredIcon() { - Anchor = Anchor.CentreLeft; RelativePositionAxes = Axes.X; - Size = new Vector2(icon_size * 1.7f); - Masking = true; - BlurSigma = new Vector2(20); + BlurSigma = new Vector2(blur_sigma); Alpha = 0.6f; CacheDrawnFrameBuffer = true; - Child = icon = new GlowingIcon + Child = icon = new GlowIcon { Origin = Anchor.Centre, Anchor = Anchor.Centre, - Size = new Vector2(icon_size), }; } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 29b24f1f87..c0088ce816 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -15,9 +15,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; private const float remaining_time_container_max_size = 0.35f; private const int vertical_margin = 25; - private const float glowing_x_offset = 0.13f; - private const float glowing_x_final = 0.22f; - private const float blurred_x_offset = 0.2f; public List Breaks; @@ -26,12 +23,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay private readonly Container remainingTimeBox; private readonly RemainingTimeCounter remainingTimeCounter; private readonly InfoContainer info; - - private readonly GlowingIcon leftGlowingIcon; - private readonly GlowingIcon rightGlowingIcon; - - private readonly BlurredIcon leftBlurredIcon; - private readonly BlurredIcon rightBlurredIcon; + private readonly ArrowsOverlay arrowsOverlay; public BreakOverlay(bool letterboxing) { @@ -67,31 +59,10 @@ namespace osu.Game.Screens.Play.BreaksOverlay Origin = Anchor.TopCentre, Margin = new MarginPadding { Top = vertical_margin }, }, - leftGlowingIcon = new GlowingIcon + arrowsOverlay = new ArrowsOverlay { - Origin = Anchor.CentreRight, - Icon = Graphics.FontAwesome.fa_chevron_left, - Size = new Vector2(60), - X = 1 + glowing_x_offset, - }, - rightGlowingIcon = new GlowingIcon - { - Origin = Anchor.CentreLeft, - Icon = Graphics.FontAwesome.fa_chevron_right, - Size = new Vector2(60), - X = -glowing_x_offset, - }, - leftBlurredIcon = new BlurredIcon - { - Origin = Anchor.CentreRight, - Icon = Graphics.FontAwesome.fa_chevron_left, - X = 1 + blurred_x_offset, - }, - rightBlurredIcon = new BlurredIcon - { - Origin = Anchor.CentreLeft, - Icon = Graphics.FontAwesome.fa_chevron_right, - X = -blurred_x_offset, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, } }; } @@ -136,12 +107,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay remainingTimeCounter.FadeIn(fade_duration); info.FadeIn(fade_duration); - - leftGlowingIcon.MoveToX(1 - glowing_x_final, fade_duration, Easing.OutQuint); - rightGlowingIcon.MoveToX(glowing_x_final, fade_duration, Easing.OutQuint); - - leftBlurredIcon.MoveToX(1, fade_duration, Easing.OutQuint); - rightBlurredIcon.MoveToX(0, fade_duration, Easing.OutQuint); + arrowsOverlay.Show(fade_duration); } private void onBreakOut() @@ -151,12 +117,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay remainingTimeCounter.FadeOut(fade_duration); info.FadeOut(fade_duration); - - leftGlowingIcon.MoveToX(1 + glowing_x_offset, fade_duration, Easing.OutQuint); - rightGlowingIcon.MoveToX(-glowing_x_offset, fade_duration, Easing.OutQuint); - - leftBlurredIcon.MoveToX(1 + blurred_x_offset, fade_duration, Easing.OutQuint); - rightBlurredIcon.MoveToX(-blurred_x_offset, fade_duration, Easing.OutQuint); + arrowsOverlay.Hide(fade_duration); } } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs b/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs similarity index 65% rename from osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs rename to osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs index c92b0121c9..91e794ff6b 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/GlowingIcon.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs @@ -1,42 +1,40 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Game.Graphics; using OpenTK; using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; namespace osu.Game.Screens.Play.BreaksOverlay { - public class GlowingIcon : Container + public class GlowIcon : Container { - private readonly SpriteIcon icon; - private readonly SpriteIcon glow; - private readonly BufferedContainer glowContainer; + private const int blur_sigma = 5; - public FontAwesome Icon - { - set { icon.Icon = glow.Icon = value; } - get { return icon.Icon; } - } + private readonly SpriteIcon spriteIcon; + private readonly SpriteIcon glowIcon; + private readonly BufferedContainer glowContainer; public override Vector2 Size { set { - glow.Size = icon.Size = value; - glowContainer.Size = value * 1.5f; - } - get - { - return glow.Size; + spriteIcon.Size = glowIcon.Size = value; + glowContainer.Size = value + new Vector2(blur_sigma * 2); } + get { return spriteIcon.Size; } } - public GlowingIcon() + public FontAwesome Icon + { + set { spriteIcon.Icon = glowIcon.Icon = value; } + get { return spriteIcon.Icon; } + } + + public GlowIcon() { - Anchor = Anchor.CentreLeft; RelativePositionAxes = Axes.X; AutoSizeAxes = Axes.Both; Children = new Drawable[] @@ -45,17 +43,17 @@ namespace osu.Game.Screens.Play.BreaksOverlay { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Masking = true, - BlurSigma = new Vector2(10), + BlurSigma = new Vector2(blur_sigma), CacheDrawnFrameBuffer = true, - Child = glow = new SpriteIcon + Child = glowIcon = new SpriteIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, Shadow = false, }, + }, - icon = new SpriteIcon + spriteIcon = new SpriteIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -67,7 +65,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay [BackgroundDependencyLoader] private void load(OsuColour colours) { - glow.Colour = colours.Blue; + glowIcon.Colour = colours.BlueLight; } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 904e7800b8..dd823f6144 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -275,9 +275,10 @@ + - + From d58e5a613015beb9ffb9e1da672ab2bcdaf5db7d Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 22 Sep 2017 20:43:51 +0300 Subject: [PATCH 17/46] Arrows improvements --- .../Play/BreaksOverlay/ArrowsOverlay.cs | 50 +++++++++++-------- .../Screens/Play/BreaksOverlay/BlurredIcon.cs | 22 +++++--- .../Play/BreaksOverlay/BreakOverlay.cs | 2 +- .../Screens/Play/BreaksOverlay/GlowIcon.cs | 33 ++++++------ 4 files changed, 57 insertions(+), 50 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs index 715cc4fc0f..8ba801f204 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs @@ -9,13 +9,15 @@ namespace osu.Game.Screens.Play.BreaksOverlay { public class ArrowsOverlay : Container { - private const int glowing_size = 60; - private const float glowing_final_offset = 0.25f; - private const float glowing_offscreen_offset = 0.6f; + private const int glow_icon_size = 65; + private const int glow_icon_blur_sigma = 8; + private const float glow_icon_final_offset = 0.2f; + private const float glow_icon_offscreen_offset = 0.6f; - private const int blurred_size = 130; - private const float blurred_final_offset = 0.35f; - private const float blurred_offscreen_offset = 0.7f; + private const int blurred_icon_blur_sigma = 20; + private const int blurred_icon_size = 130; + private const float blurred_icon_final_offset = 0.35f; + private const float blurred_icon_offscreen_offset = 0.7f; private readonly GlowIcon leftGlowIcon; private readonly GlowIcon rightGlowIcon; @@ -32,53 +34,57 @@ namespace osu.Game.Screens.Play.BreaksOverlay { Anchor = Anchor.Centre, Origin = Anchor.CentreRight, - X = - glowing_offscreen_offset, + X = - glow_icon_offscreen_offset, Icon = Graphics.FontAwesome.fa_chevron_right, - Size = new Vector2(glowing_size), + BlurSigma = new Vector2(glow_icon_blur_sigma), + Size = new Vector2(glow_icon_size), }, rightGlowIcon = new GlowIcon { Anchor = Anchor.Centre, Origin = Anchor.CentreLeft, - X = glowing_offscreen_offset, + X = glow_icon_offscreen_offset, Icon = Graphics.FontAwesome.fa_chevron_left, - Size = new Vector2(glowing_size), + BlurSigma = new Vector2(glow_icon_blur_sigma), + Size = new Vector2(glow_icon_size), }, leftBlurredIcon = new BlurredIcon { Anchor = Anchor.Centre, Origin = Anchor.CentreRight, - X = - blurred_offscreen_offset, + X = - blurred_icon_offscreen_offset, Icon = Graphics.FontAwesome.fa_chevron_right, - Size = new Vector2(blurred_size), + BlurSigma = new Vector2(blurred_icon_blur_sigma), + Size = new Vector2(blurred_icon_size), }, rightBlurredIcon = new BlurredIcon { Anchor = Anchor.Centre, Origin = Anchor.CentreLeft, - X = blurred_offscreen_offset, + X = blurred_icon_offscreen_offset, Icon = Graphics.FontAwesome.fa_chevron_left, - Size = new Vector2(blurred_size), + BlurSigma = new Vector2(blurred_icon_blur_sigma), + Size = new Vector2(blurred_icon_size), }, }; } public void Show(double fadeDuration) { - leftGlowIcon.MoveToX(-glowing_final_offset, fadeDuration, Easing.OutQuint); - rightGlowIcon.MoveToX(glowing_final_offset, fadeDuration, Easing.OutQuint); + leftGlowIcon.MoveToX(-glow_icon_final_offset, fadeDuration, Easing.OutQuint); + rightGlowIcon.MoveToX(glow_icon_final_offset, fadeDuration, Easing.OutQuint); - leftBlurredIcon.MoveToX(-blurred_final_offset, fadeDuration, Easing.OutQuint); - rightBlurredIcon.MoveToX(blurred_final_offset, fadeDuration, Easing.OutQuint); + leftBlurredIcon.MoveToX(-blurred_icon_final_offset, fadeDuration, Easing.OutQuint); + rightBlurredIcon.MoveToX(blurred_icon_final_offset, fadeDuration, Easing.OutQuint); } public void Hide(double fadeDuration) { - leftGlowIcon.MoveToX(-glowing_offscreen_offset, fadeDuration, Easing.OutQuint); - rightGlowIcon.MoveToX(glowing_offscreen_offset, fadeDuration, Easing.OutQuint); + leftGlowIcon.MoveToX(-glow_icon_offscreen_offset, fadeDuration, Easing.OutQuint); + rightGlowIcon.MoveToX(glow_icon_offscreen_offset, fadeDuration, Easing.OutQuint); - leftBlurredIcon.MoveToX(-blurred_offscreen_offset, fadeDuration, Easing.OutQuint); - rightBlurredIcon.MoveToX(blurred_offscreen_offset, fadeDuration, Easing.OutQuint); + leftBlurredIcon.MoveToX(-blurred_icon_offscreen_offset, fadeDuration, Easing.OutQuint); + rightBlurredIcon.MoveToX(blurred_icon_offscreen_offset, fadeDuration, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs b/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs index 25e6eef1fd..9e69d9d076 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs @@ -5,14 +5,13 @@ using OpenTK; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Game.Graphics; +using osu.Framework.Allocation; namespace osu.Game.Screens.Play.BreaksOverlay { public class BlurredIcon : BufferedContainer { - private const int blur_sigma = 20; - - private readonly GlowIcon icon; + private readonly SpriteIcon icon; public FontAwesome Icon { @@ -25,22 +24,29 @@ namespace osu.Game.Screens.Play.BreaksOverlay set { icon.Size = value; - base.Size = value + new Vector2(blur_sigma * 2); + base.Size = value + BlurSigma * 2.5f; + ForceRedraw(); } - get { return icon.Size; } + get { return base.Size; } } public BlurredIcon() { RelativePositionAxes = Axes.X; - BlurSigma = new Vector2(blur_sigma); - Alpha = 0.6f; + Alpha = 0.7f; CacheDrawnFrameBuffer = true; - Child = icon = new GlowIcon + Child = icon = new SpriteIcon { Origin = Anchor.Centre, Anchor = Anchor.Centre, + Shadow = false, }; } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Colour = colours.BlueLighter; + } } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index c0088ce816..1264feff3d 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -13,7 +13,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay public class BreakOverlay : Container { private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; - private const float remaining_time_container_max_size = 0.35f; + private const float remaining_time_container_max_size = 0.3f; private const int vertical_margin = 25; public List Breaks; diff --git a/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs b/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs index 91e794ff6b..81c2445324 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs @@ -11,25 +11,29 @@ namespace osu.Game.Screens.Play.BreaksOverlay { public class GlowIcon : Container { - private const int blur_sigma = 5; - private readonly SpriteIcon spriteIcon; - private readonly SpriteIcon glowIcon; - private readonly BufferedContainer glowContainer; + private readonly BlurredIcon blurredIcon; public override Vector2 Size { set { - spriteIcon.Size = glowIcon.Size = value; - glowContainer.Size = value + new Vector2(blur_sigma * 2); + blurredIcon.Size = value; + spriteIcon.Size = value - new Vector2(10); //Make it a bit smaller to make blur more visible + blurredIcon.ForceRedraw(); } - get { return spriteIcon.Size; } + get { return base.Size; } + } + + public Vector2 BlurSigma + { + set { blurredIcon.BlurSigma = value; } + get { return blurredIcon.BlurSigma; } } public FontAwesome Icon { - set { spriteIcon.Icon = glowIcon.Icon = value; } + set { spriteIcon.Icon = blurredIcon.Icon = value; } get { return spriteIcon.Icon; } } @@ -39,19 +43,10 @@ namespace osu.Game.Screens.Play.BreaksOverlay AutoSizeAxes = Axes.Both; Children = new Drawable[] { - glowContainer = new BufferedContainer + blurredIcon = new BlurredIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, - BlurSigma = new Vector2(blur_sigma), - CacheDrawnFrameBuffer = true, - Child = glowIcon = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Shadow = false, - }, - }, spriteIcon = new SpriteIcon { @@ -65,7 +60,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay [BackgroundDependencyLoader] private void load(OsuColour colours) { - glowIcon.Colour = colours.BlueLight; + blurredIcon.Colour = colours.Blue; } } } From 6fe2b64abdc0a7ab551e79e557932851e54cacab Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 22 Sep 2017 20:50:00 +0300 Subject: [PATCH 18/46] Start breakOut animation a bit earlier --- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 1264feff3d..27b7dc5408 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -87,7 +87,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { onBreakIn(b); - using (BeginDelayedSequence(b.Duration, true)) + using (BeginDelayedSequence(b.Duration - fade_duration, true)) onBreakOut(); } } From 92eb8e4fa9700640ab322a0e8d850ae37255c5a0 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 22 Sep 2017 21:00:45 +0300 Subject: [PATCH 19/46] Move blurred icons to a parallax container --- .../Play/BreaksOverlay/ArrowsOverlay.cs | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs index 8ba801f204..9178daac54 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs @@ -4,6 +4,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using OpenTK; +using osu.Game.Graphics.Containers; namespace osu.Game.Screens.Play.BreaksOverlay { @@ -48,24 +49,31 @@ namespace osu.Game.Screens.Play.BreaksOverlay BlurSigma = new Vector2(glow_icon_blur_sigma), Size = new Vector2(glow_icon_size), }, - leftBlurredIcon = new BlurredIcon + new ParallaxContainer { - Anchor = Anchor.Centre, - Origin = Anchor.CentreRight, - X = - blurred_icon_offscreen_offset, - Icon = Graphics.FontAwesome.fa_chevron_right, - BlurSigma = new Vector2(blurred_icon_blur_sigma), - Size = new Vector2(blurred_icon_size), - }, - rightBlurredIcon = new BlurredIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.CentreLeft, - X = blurred_icon_offscreen_offset, - Icon = Graphics.FontAwesome.fa_chevron_left, - BlurSigma = new Vector2(blurred_icon_blur_sigma), - Size = new Vector2(blurred_icon_size), - }, + ParallaxAmount = -0.02f, + Children = new Drawable[] + { + leftBlurredIcon = new BlurredIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreRight, + X = - blurred_icon_offscreen_offset, + Icon = Graphics.FontAwesome.fa_chevron_right, + BlurSigma = new Vector2(blurred_icon_blur_sigma), + Size = new Vector2(blurred_icon_size), + }, + rightBlurredIcon = new BlurredIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft, + X = blurred_icon_offscreen_offset, + Icon = Graphics.FontAwesome.fa_chevron_left, + BlurSigma = new Vector2(blurred_icon_blur_sigma), + Size = new Vector2(blurred_icon_size), + }, + } + } }; } From d73b40768e50426ed44349da7a6ad8d5f13fb143 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 22 Sep 2017 21:12:58 +0300 Subject: [PATCH 20/46] More arrow adjustments to match the design --- osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs | 8 +++++--- osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs | 1 - osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs index 9178daac54..87dc8caf13 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs @@ -10,9 +10,9 @@ namespace osu.Game.Screens.Play.BreaksOverlay { public class ArrowsOverlay : Container { - private const int glow_icon_size = 65; - private const int glow_icon_blur_sigma = 8; - private const float glow_icon_final_offset = 0.2f; + private const int glow_icon_size = 60; + private const int glow_icon_blur_sigma = 10; + private const float glow_icon_final_offset = 0.22f; private const float glow_icon_offscreen_offset = 0.6f; private const int blurred_icon_blur_sigma = 20; @@ -58,6 +58,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { Anchor = Anchor.Centre, Origin = Anchor.CentreRight, + Alpha = 0.7f, X = - blurred_icon_offscreen_offset, Icon = Graphics.FontAwesome.fa_chevron_right, BlurSigma = new Vector2(blurred_icon_blur_sigma), @@ -67,6 +68,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { Anchor = Anchor.Centre, Origin = Anchor.CentreLeft, + Alpha = 0.7f, X = blurred_icon_offscreen_offset, Icon = Graphics.FontAwesome.fa_chevron_left, BlurSigma = new Vector2(blurred_icon_blur_sigma), diff --git a/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs b/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs index 9e69d9d076..f16e7c7b96 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BlurredIcon.cs @@ -33,7 +33,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay public BlurredIcon() { RelativePositionAxes = Axes.X; - Alpha = 0.7f; CacheDrawnFrameBuffer = true; Child = icon = new SpriteIcon { diff --git a/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs b/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs index 81c2445324..b27eef632c 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/GlowIcon.cs @@ -18,8 +18,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { set { - blurredIcon.Size = value; - spriteIcon.Size = value - new Vector2(10); //Make it a bit smaller to make blur more visible + blurredIcon.Size = spriteIcon.Size = value; blurredIcon.ForceRedraw(); } get { return base.Size; } From ced620421913f255f20d271414f8c9206c3240a5 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 22 Sep 2017 22:10:05 +0300 Subject: [PATCH 21/46] oops --- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 2 +- osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 27b7dc5408..bc0a0a2242 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -101,7 +101,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay remainingTimeBox .ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint) .Then() - .ResizeWidthTo(0, b.Duration); + .ResizeWidthTo(0, b.Duration - fade_duration); Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime); remainingTimeCounter.FadeIn(fade_duration); diff --git a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs index fbf3e10688..ab6ee5ea5c 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay var currentTime = Clock.CurrentTime; if (currentTime < remainingTime) { - int currentSecond = (int)Math.Floor((remainingTime - Clock.CurrentTime) / 1000.0) + 1; + int currentSecond = (int)Math.Floor((remainingTime - Clock.CurrentTime) / 1000.0); if (currentSecond != previousSecond) { counter.Text = currentSecond.ToString(); From 2da3ea00b6a0bb550e2ab3a642632e6e363d6c01 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 23 Sep 2017 16:42:18 +0300 Subject: [PATCH 22/46] Bind break overlay to accuracy --- .../Play/BreaksOverlay/BreakOverlay.cs | 6 ++ .../Play/BreaksOverlay/InfoContainer.cs | 56 ++---------- .../Screens/Play/BreaksOverlay/InfoLine.cs | 89 +++++++++++++++++++ osu.Game/Screens/Play/Player.cs | 5 +- osu.Game/osu.Game.csproj | 1 + 5 files changed, 109 insertions(+), 48 deletions(-) create mode 100644 osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index bc0a0a2242..e9dd112557 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps.Timing; +using osu.Game.Rulesets.Scoring; using System.Collections.Generic; namespace osu.Game.Screens.Play.BreaksOverlay @@ -119,5 +120,10 @@ namespace osu.Game.Screens.Play.BreaksOverlay info.FadeOut(fade_duration); arrowsOverlay.Hide(fade_duration); } + + public void BindProcessor(ScoreProcessor processor) + { + info.AccuracyDisplay.Current.BindTo(processor.Accuracy); + } } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs index 75fcfcba0e..dc85fabbe0 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs @@ -2,16 +2,18 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Screens.Play.BreaksOverlay { public class InfoContainer : FillFlowContainer { + public PercentageInfoLine AccuracyDisplay; + public InfoLine RankDisplay; + public InfoLine GradeDisplay; + public InfoContainer() { AutoSizeAxes = Axes.Both; @@ -28,60 +30,20 @@ namespace osu.Game.Screens.Play.BreaksOverlay TextSize = 15, Font = "Exo2.0-Black", }, - new FillFlowContainer + new FillFlowContainer { AutoSizeAxes = Axes.Both, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Direction = FillDirection.Vertical, - Children = new [] + Children = new Drawable[] { - new InfoLine(@"Accuracy", @"-"), - new InfoLine(@"Rank", @"-"), - new InfoLine(@"Grade", @"-"), + AccuracyDisplay = new PercentageInfoLine(@"Accuracy"), + RankDisplay = new InfoLine(@"Rank", @"#"), + GradeDisplay = new InfoLine(@"Grade"), }, } }; } - - private class InfoLine : Container - { - private const int margin = 2; - - private readonly OsuSpriteText text; - private readonly OsuSpriteText valueText; - - public InfoLine(string name, string value) - { - AutoSizeAxes = Axes.Y; - Children = new Drawable[] - { - text = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.CentreRight, - Text = name, - TextSize = 17, - Margin = new MarginPadding { Right = margin } - }, - valueText = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.CentreLeft, - Text = value, - TextSize = 17, - Font = "Exo2.0-Bold", - Margin = new MarginPadding { Left = margin } - } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - text.Colour = colours.Yellow; - valueText.Colour = colours.YellowLight; - } - } } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs new file mode 100644 index 0000000000..0af766b321 --- /dev/null +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs @@ -0,0 +1,89 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Play.BreaksOverlay +{ + public class InfoLine : Container + where T : struct + { + private const int margin = 2; + + public Bindable Current = new Bindable(); + + private readonly OsuSpriteText text; + private readonly OsuSpriteText valueText; + + private readonly string prefix; + + public InfoLine(string name, string prefix = @"") + { + this.prefix = prefix; + + AutoSizeAxes = Axes.Y; + Children = new Drawable[] + { + text = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreRight, + Text = name, + TextSize = 17, + Margin = new MarginPadding { Right = margin } + }, + valueText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft, + Text = prefix + @"-", + TextSize = 17, + Font = "Exo2.0-Bold", + Margin = new MarginPadding { Left = margin } + } + }; + + Current.ValueChanged += currentValueChanged; + } + + private void currentValueChanged(T newValue) + { + valueText.Text = prefix + Format(newValue); + } + + protected virtual string Format(T count) => count.ToString(); + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + text.Colour = colours.Yellow; + valueText.Colour = colours.YellowLight; + } + } + + public class PercentageInfoLine : InfoLine + { + public PercentageInfoLine(string name, string prefix = "") : base(name, prefix) + { + } + + protected override string Format(double count) => $@"{count:P2}"; + } + + public enum Grade + { + SSplus, + SS, + Splus, + S, + A, + B, + C, + F + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 86aa00875c..d8ddee0ac3 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -67,6 +67,7 @@ namespace osu.Game.Screens.Play #endregion + private BreakOverlay breakOverlay; private HUDOverlay hudOverlay; private FailOverlay failOverlay; @@ -173,7 +174,7 @@ namespace osu.Game.Screens.Play Anchor = Anchor.Centre, Origin = Anchor.Centre }, - new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks) + breakOverlay = new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -211,6 +212,8 @@ namespace osu.Game.Screens.Play hudOverlay.ModDisplay.Current.BindTo(working.Mods); + breakOverlay.BindProcessor(scoreProcessor); + // Bind ScoreProcessor to ourselves scoreProcessor.AllJudged += onCompletion; scoreProcessor.Failed += onFail; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index dd823f6144..2cbbc42061 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -280,6 +280,7 @@ + From a69bef8ec075d52e721ac3f0e89b2ee2e3ff4b11 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 23 Sep 2017 16:51:31 +0300 Subject: [PATCH 23/46] Use existing enum instead of my own --- osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs | 5 +++-- osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs | 12 ------------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs index dc85fabbe0..f6c47d757f 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs @@ -5,6 +5,7 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Scoring; namespace osu.Game.Screens.Play.BreaksOverlay { @@ -12,7 +13,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { public PercentageInfoLine AccuracyDisplay; public InfoLine RankDisplay; - public InfoLine GradeDisplay; + public InfoLine GradeDisplay; public InfoContainer() { @@ -40,7 +41,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { AccuracyDisplay = new PercentageInfoLine(@"Accuracy"), RankDisplay = new InfoLine(@"Rank", @"#"), - GradeDisplay = new InfoLine(@"Grade"), + GradeDisplay = new InfoLine(@"Grade"), }, } }; diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs index 0af766b321..089dad6c38 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs @@ -74,16 +74,4 @@ namespace osu.Game.Screens.Play.BreaksOverlay protected override string Format(double count) => $@"{count:P2}"; } - - public enum Grade - { - SSplus, - SS, - Splus, - S, - A, - B, - C, - F - } } From 0615f375e1b206a55eb36fe0f396127cb0a10be2 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 23 Sep 2017 19:52:44 +0300 Subject: [PATCH 24/46] Show current grade --- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 4 ++-- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 1 + osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs | 5 ++--- osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs | 10 ++++++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index deb87e92d8..e8dd87a6a6 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Scoring Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); }; } - private ScoreRank rankFrom(double acc) + public static ScoreRank RankFrom(double acc) { if (acc == 1) return ScoreRank.X; @@ -142,7 +142,7 @@ namespace osu.Game.Rulesets.Scoring score.Combo = Combo; score.MaxCombo = HighestCombo; score.Accuracy = Accuracy; - score.Rank = rankFrom(Accuracy); + score.Rank = RankFrom(Accuracy); score.Date = DateTimeOffset.Now; score.Health = Health; } diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index e9dd112557..33fcebf3bb 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -124,6 +124,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay public void BindProcessor(ScoreProcessor processor) { info.AccuracyDisplay.Current.BindTo(processor.Accuracy); + info.GradeDisplay.Current.BindTo(processor.Accuracy); } } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs index f6c47d757f..4cff9372a3 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs @@ -5,7 +5,6 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; -using osu.Game.Rulesets.Scoring; namespace osu.Game.Screens.Play.BreaksOverlay { @@ -13,7 +12,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { public PercentageInfoLine AccuracyDisplay; public InfoLine RankDisplay; - public InfoLine GradeDisplay; + public GradeInfoLine GradeDisplay; public InfoContainer() { @@ -41,7 +40,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { AccuracyDisplay = new PercentageInfoLine(@"Accuracy"), RankDisplay = new InfoLine(@"Rank", @"#"), - GradeDisplay = new InfoLine(@"Grade"), + GradeDisplay = new GradeInfoLine(@"Grade"), }, } }; diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs index 089dad6c38..bf486e2480 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Scoring; namespace osu.Game.Screens.Play.BreaksOverlay { @@ -74,4 +75,13 @@ namespace osu.Game.Screens.Play.BreaksOverlay protected override string Format(double count) => $@"{count:P2}"; } + + public class GradeInfoLine : InfoLine + { + public GradeInfoLine(string name, string prefix = "") : base(name, prefix) + { + } + + protected override string Format(double count) => $@"{ScoreProcessor.RankFrom(count)}"; + } } From 94269e119e3838914c5ab5c9f7ec4d65594d7553 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 23 Sep 2017 19:59:34 +0300 Subject: [PATCH 25/46] Reset text only if it has been changed --- osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs index bf486e2480..f74329ceb3 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs @@ -54,7 +54,12 @@ namespace osu.Game.Screens.Play.BreaksOverlay private void currentValueChanged(T newValue) { - valueText.Text = prefix + Format(newValue); + var newText = prefix + Format(newValue); + + if (valueText.Text == newText) + return; + + valueText.Text = newText; } protected virtual string Format(T count) => count.ToString(); From c696f7457883c11e8c771096e6bb36a1efd11ec6 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 27 Sep 2017 01:10:48 +0300 Subject: [PATCH 26/46] Fix broken testcase and apply suggested changes --- .../Screens/Play/BreaksOverlay/ArrowsOverlay.cs | 4 ++-- .../Screens/Play/BreaksOverlay/BreakOverlay.cs | 2 +- .../Screens/Play/BreaksOverlay/InfoContainer.cs | 8 ++++---- .../Play/BreaksOverlay/LetterboxOverlay.cs | 16 ++++++++-------- .../Play/BreaksOverlay/RemainingTimeCounter.cs | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs index 87dc8caf13..9d729826de 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { Anchor = Anchor.Centre, Origin = Anchor.CentreRight, - X = - glow_icon_offscreen_offset, + X = -glow_icon_offscreen_offset, Icon = Graphics.FontAwesome.fa_chevron_right, BlurSigma = new Vector2(glow_icon_blur_sigma), Size = new Vector2(glow_icon_size), @@ -59,7 +59,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay Anchor = Anchor.Centre, Origin = Anchor.CentreRight, Alpha = 0.7f, - X = - blurred_icon_offscreen_offset, + X = -blurred_icon_offscreen_offset, Icon = Graphics.FontAwesome.fa_chevron_right, BlurSigma = new Vector2(blurred_icon_blur_sigma), Size = new Vector2(blurred_icon_size), diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 33fcebf3bb..90321df9d6 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -104,7 +104,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay .Then() .ResizeWidthTo(0, b.Duration - fade_duration); - Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime); + Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); remainingTimeCounter.FadeIn(fade_duration); info.FadeIn(fade_duration); diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs index 4cff9372a3..8d2bec06aa 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Text = @"current progress".ToUpper(), + Text = "current progress".ToUpper(), TextSize = 15, Font = "Exo2.0-Black", }, @@ -38,9 +38,9 @@ namespace osu.Game.Screens.Play.BreaksOverlay Direction = FillDirection.Vertical, Children = new Drawable[] { - AccuracyDisplay = new PercentageInfoLine(@"Accuracy"), - RankDisplay = new InfoLine(@"Rank", @"#"), - GradeDisplay = new GradeInfoLine(@"Grade"), + AccuracyDisplay = new PercentageInfoLine("Accuracy"), + RankDisplay = new InfoLine("Rank", @"#"), + GradeDisplay = new GradeInfoLine("Grade"), }, } }; diff --git a/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs index c95b15ef3a..1581c45c56 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs @@ -11,9 +11,9 @@ namespace osu.Game.Screens.Play.BreaksOverlay { public class LetterboxOverlay : Container { - private const int letterbox_height = 350; + private const int height = 350; - private Color4 transparentBlack => new Color4(0, 0, 0, 0); + private static readonly Color4 transparent_black = new Color4(0, 0, 0, 0); public LetterboxOverlay() { @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, RelativeSizeAxes = Axes.X, - Height = letterbox_height, + Height = height, Child = new Box { RelativeSizeAxes = Axes.Both, @@ -34,8 +34,8 @@ namespace osu.Game.Screens.Play.BreaksOverlay { TopLeft = Color4.Black, TopRight = Color4.Black, - BottomLeft = transparentBlack, - BottomRight = transparentBlack, + BottomLeft = transparent_black, + BottomRight = transparent_black, } } }, @@ -44,14 +44,14 @@ namespace osu.Game.Screens.Play.BreaksOverlay Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - Height = letterbox_height, + Height = height, Child = new Box { RelativeSizeAxes = Axes.Both, Colour = new ColourInfo { - TopLeft = transparentBlack, - TopRight = transparentBlack, + TopLeft = transparent_black, + TopRight = transparent_black, BottomLeft = Color4.Black, BottomRight = Color4.Black, } diff --git a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs index ab6ee5ea5c..e89c1e292c 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs @@ -14,7 +14,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay private int? previousSecond; - private double remainingTime; + private double endTime; private bool isCounting; @@ -31,9 +31,9 @@ namespace osu.Game.Screens.Play.BreaksOverlay }; } - public void StartCounting(double remainingTime) + public void StartCounting(double endTime) { - this.remainingTime = remainingTime; + this.endTime = endTime; isCounting = true; } @@ -44,9 +44,9 @@ namespace osu.Game.Screens.Play.BreaksOverlay if (isCounting) { var currentTime = Clock.CurrentTime; - if (currentTime < remainingTime) + if (currentTime < endTime) { - int currentSecond = (int)Math.Floor((remainingTime - Clock.CurrentTime) / 1000.0); + int currentSecond = (int)Math.Floor((endTime - Clock.CurrentTime) / 1000.0); if (currentSecond != previousSecond) { counter.Text = currentSecond.ToString(); From 92c3d722b4140020088fa8a471b6e24a2b8ad0b0 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 30 Sep 2017 05:41:32 +0300 Subject: [PATCH 27/46] Show mapper's profile when clicking on avatar in BeatmapSetOverlay --- osu.Game/OsuGame.cs | 6 ++--- osu.Game/Overlays/BeatmapSet/AuthorInfo.cs | 28 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index c137b8f6f5..75a1d61371 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -188,11 +188,11 @@ namespace osu.Game GetToolbarHeight = () => ToolbarOffset, Depth = -1 }, overlayContent.Add); - LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); LoadComponentAsync(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -2 }, mainContent.Add); + LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -3 }, mainContent.Add); LoadComponentAsync(musicController = new MusicController { - Depth = -3, + Depth = -4, Position = new Vector2(0, Toolbar.HEIGHT), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -200,7 +200,7 @@ namespace osu.Game LoadComponentAsync(notificationOverlay = new NotificationOverlay { - Depth = -3, + Depth = -4, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, overlayContent.Add); diff --git a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs index b0e4e49e31..fc9fd1e614 100644 --- a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs @@ -9,6 +9,9 @@ using osu.Game.Graphics.Sprites; using osu.Game.Users; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Game.Graphics.Containers; +using osu.Framework.Graphics.Cursor; namespace osu.Game.Overlays.BeatmapSet { @@ -17,8 +20,11 @@ namespace osu.Game.Overlays.BeatmapSet private const float height = 50; private readonly UpdateableAvatar avatar; + private readonly ClickableArea clickableArea; private readonly FillFlowContainer fields; + private UserProfileOverlay profile; + private BeatmapSetInfo beatmapSet; public BeatmapSetInfo BeatmapSet { @@ -31,6 +37,8 @@ namespace osu.Game.Overlays.BeatmapSet var i = BeatmapSet.OnlineInfo; avatar.User = i.Author; + clickableArea.Action = () => profile?.ShowUser(avatar.User); + fields.Children = new Drawable[] { new Field("made by", i.Author.Username, @"Exo2.0-RegularItalic"), @@ -58,11 +66,15 @@ namespace osu.Game.Overlays.BeatmapSet Children = new Drawable[] { - avatar = new UpdateableAvatar + clickableArea = new ClickableArea { - Size = new Vector2(height), + AutoSizeAxes = Axes.Both, CornerRadius = 3, Masking = true, + Child = avatar = new UpdateableAvatar + { + Size = new Vector2(height), + }, EdgeEffect = new EdgeEffectParameters { Colour = Color4.Black.Opacity(0.25f), @@ -80,6 +92,13 @@ namespace osu.Game.Overlays.BeatmapSet }; } + [BackgroundDependencyLoader(true)] + private void load(UserProfileOverlay profile) + { + this.profile = profile; + clickableArea.Action = () => profile?.ShowUser(avatar.User); + } + private class Field : FillFlowContainer { public Field(string first, string second, string secondFont) @@ -103,5 +122,10 @@ namespace osu.Game.Overlays.BeatmapSet }; } } + + private class ClickableArea : OsuClickableContainer, IHasTooltip + { + public string TooltipText => @"View Profile"; + } } } From b62f2437acc92d24d2b7f334cf53a3d9201fc84a Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sun, 1 Oct 2017 23:38:11 +0300 Subject: [PATCH 28/46] Don't allow counter became 0 --- osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs index e89c1e292c..c8b8b6a072 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay var currentTime = Clock.CurrentTime; if (currentTime < endTime) { - int currentSecond = (int)Math.Floor((endTime - Clock.CurrentTime) / 1000.0); + int currentSecond = (int)Math.Ceiling((endTime - Clock.CurrentTime) / 1000.0); if (currentSecond != previousSecond) { counter.Text = currentSecond.ToString(); From ac6c323f93ef73786845e3384675c91a664e1fb0 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 2 Oct 2017 00:44:57 +0300 Subject: [PATCH 29/46] Clear all tasks and transforms when resetting Breaks --- .../Play/BreaksOverlay/BreakOverlay.cs | 36 +++++++++++++++---- osu.Game/Tests/Visual/TestCaseBreakOverlay.cs | 4 --- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 90321df9d6..fe4d5ea424 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -5,9 +5,11 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Threading; using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Scoring; using System.Collections.Generic; +using System.Linq; namespace osu.Game.Screens.Play.BreaksOverlay { @@ -17,7 +19,21 @@ namespace osu.Game.Screens.Play.BreaksOverlay private const float remaining_time_container_max_size = 0.3f; private const int vertical_margin = 25; - public List Breaks; + private List breaks; + public List Breaks + { + set + { + breaks = value; + initializeBreaks(); + } + get + { + return breaks; + } + } + + private readonly List tasks = new List(); private readonly bool letterboxing; private readonly LetterboxOverlay letterboxOverlay; @@ -71,15 +87,21 @@ namespace osu.Game.Screens.Play.BreaksOverlay protected override void LoadComplete() { base.LoadComplete(); - InitializeBreaks(); + initializeBreaks(); } - public void InitializeBreaks() + private void initializeBreaks() { - if (Breaks == null) + FinishTransforms(true); + + foreach (var t in tasks) + t.Cancel(); + tasks.Clear(); + + if (breaks == null) return; - foreach (var b in Breaks) + foreach (var b in breaks) { if (!b.HasEffect) continue; @@ -104,7 +126,9 @@ namespace osu.Game.Screens.Play.BreaksOverlay .Then() .ResizeWidthTo(0, b.Duration - fade_duration); - Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); + tasks.Add(new ScheduledDelegate(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime)); + Scheduler.Add(tasks.Last()); + remainingTimeCounter.FadeIn(fade_duration); info.FadeIn(fade_duration); diff --git a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs index 055a2bc5c4..074aa16934 100644 --- a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs +++ b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs @@ -37,8 +37,6 @@ namespace osu.Game.Tests.Visual EndTime = Clock.CurrentTime + duration, } }; - - breakOverlay.InitializeBreaks(); } private void startMultipleBreaks() @@ -58,8 +56,6 @@ namespace osu.Game.Tests.Visual EndTime = currentTime + 6000, } }; - - breakOverlay.InitializeBreaks(); } } } \ No newline at end of file From 5ce2723719f6697c03125142a5b4c66d808008c8 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 2 Oct 2017 05:12:56 +0300 Subject: [PATCH 30/46] Don't use linq query --- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index fe4d5ea424..c7c5afe42c 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -9,7 +9,6 @@ using osu.Framework.Threading; using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Scoring; using System.Collections.Generic; -using System.Linq; namespace osu.Game.Screens.Play.BreaksOverlay { @@ -127,7 +126,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay .ResizeWidthTo(0, b.Duration - fade_duration); tasks.Add(new ScheduledDelegate(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime)); - Scheduler.Add(tasks.Last()); + Scheduler.Add(tasks[tasks.Count - 1]); remainingTimeCounter.FadeIn(fade_duration); From c2f487aa3edb9012fd97b58e8d5ae1b0cc8e4013 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 2 Oct 2017 05:56:38 +0300 Subject: [PATCH 31/46] Add Rank as a property to the Score Processor --- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 11 +++++++++-- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 2 +- osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs | 5 +++-- osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs | 10 ---------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index e8dd87a6a6..0b631a7148 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -51,6 +51,11 @@ namespace osu.Game.Rulesets.Scoring /// public readonly BindableInt Combo = new BindableInt(); + /// + /// The current rank. + /// + public readonly Bindable Rank = new Bindable(ScoreRank.X); + /// /// THe highest combo achieved by this score. /// @@ -74,9 +79,10 @@ namespace osu.Game.Rulesets.Scoring protected ScoreProcessor() { Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); }; + Accuracy.ValueChanged += delegate { Rank.Value = rankFrom(Accuracy.Value); }; } - public static ScoreRank RankFrom(double acc) + private ScoreRank rankFrom(double acc) { if (acc == 1) return ScoreRank.X; @@ -101,6 +107,7 @@ namespace osu.Game.Rulesets.Scoring Accuracy.Value = 1; Health.Value = 1; Combo.Value = 0; + Rank.Value = ScoreRank.X; HighestCombo.Value = 0; alreadyFailed = false; @@ -142,7 +149,7 @@ namespace osu.Game.Rulesets.Scoring score.Combo = Combo; score.MaxCombo = HighestCombo; score.Accuracy = Accuracy; - score.Rank = RankFrom(Accuracy); + score.Rank = Rank; score.Date = DateTimeOffset.Now; score.Health = Health; } diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index c7c5afe42c..53a2f4919e 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -147,7 +147,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay public void BindProcessor(ScoreProcessor processor) { info.AccuracyDisplay.Current.BindTo(processor.Accuracy); - info.GradeDisplay.Current.BindTo(processor.Accuracy); + info.GradeDisplay.Current.BindTo(processor.Rank); } } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs index 8d2bec06aa..351dc66930 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs @@ -5,6 +5,7 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Scoring; namespace osu.Game.Screens.Play.BreaksOverlay { @@ -12,7 +13,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { public PercentageInfoLine AccuracyDisplay; public InfoLine RankDisplay; - public GradeInfoLine GradeDisplay; + public InfoLine GradeDisplay; public InfoContainer() { @@ -40,7 +41,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay { AccuracyDisplay = new PercentageInfoLine("Accuracy"), RankDisplay = new InfoLine("Rank", @"#"), - GradeDisplay = new GradeInfoLine("Grade"), + GradeDisplay = new InfoLine("Grade"), }, } }; diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs index f74329ceb3..751523d68c 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoLine.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Rulesets.Scoring; namespace osu.Game.Screens.Play.BreaksOverlay { @@ -80,13 +79,4 @@ namespace osu.Game.Screens.Play.BreaksOverlay protected override string Format(double count) => $@"{count:P2}"; } - - public class GradeInfoLine : InfoLine - { - public GradeInfoLine(string name, string prefix = "") : base(name, prefix) - { - } - - protected override string Format(double count) => $@"{ScoreProcessor.RankFrom(count)}"; - } } From 70524628635d5a17535bc4f4277261164b85750c Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 2 Oct 2017 08:51:00 +0300 Subject: [PATCH 32/46] Update inline with framework --- osu-framework | 2 +- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/osu-framework b/osu-framework index 9d142a8e00..5f19dd913d 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 9d142a8e009794dfee828392e36025d08577131d +Subproject commit 5f19dd913dfc69013a3b9cf30ccfd9c44881a321 diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 53a2f4919e..9ffaf906c8 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -5,7 +5,6 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Threading; using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Scoring; using System.Collections.Generic; @@ -32,8 +31,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay } } - private readonly List tasks = new List(); - private readonly bool letterboxing; private readonly LetterboxOverlay letterboxOverlay; private readonly Container remainingTimeBox; @@ -92,10 +89,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay private void initializeBreaks() { FinishTransforms(true); - - foreach (var t in tasks) - t.Cancel(); - tasks.Clear(); + Scheduler.CancelDelayedTasks(); if (breaks == null) return; @@ -125,8 +119,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay .Then() .ResizeWidthTo(0, b.Duration - fade_duration); - tasks.Add(new ScheduledDelegate(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime)); - Scheduler.Add(tasks[tasks.Count - 1]); + Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); remainingTimeCounter.FadeIn(fade_duration); From b6ed977e1e383a388b57f557e707cff546ee56f0 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 2 Oct 2017 09:04:03 +0300 Subject: [PATCH 33/46] Fix hard crash and fix breaks have been initialized twice --- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 6 ------ osu.Game/Screens/Play/Player.cs | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 9ffaf906c8..3b2335a455 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -80,12 +80,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay }; } - protected override void LoadComplete() - { - base.LoadComplete(); - initializeBreaks(); - } - private void initializeBreaks() { FinishTransforms(true); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 79ace6c45a..589f4b663a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -192,8 +192,8 @@ namespace osu.Game.Screens.Play { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Breaks = beatmap.Breaks, - Clock = decoupledClock + Clock = decoupledClock, + Breaks = beatmap.Breaks }, } }, From 66afba62190f56c698678a4fb4ad03e280ed8318 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Oct 2017 17:38:48 +0800 Subject: [PATCH 34/46] Allow TestCasePlayer to instantiate only one ruleset type --- .../Tests/TestCaseCatchPlayer.cs | 4 +++ osu.Game/Rulesets/RulesetStore.cs | 1 - osu.Game/Tests/Visual/TestCasePlayer.cs | 31 ++++++++++++------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Tests/TestCaseCatchPlayer.cs b/osu.Game.Rulesets.Catch/Tests/TestCaseCatchPlayer.cs index 8d18a712d8..45ab8ac300 100644 --- a/osu.Game.Rulesets.Catch/Tests/TestCaseCatchPlayer.cs +++ b/osu.Game.Rulesets.Catch/Tests/TestCaseCatchPlayer.cs @@ -10,6 +10,10 @@ namespace osu.Game.Rulesets.Catch.Tests [TestFixture] public class TestCaseCatchPlayer : Game.Tests.Visual.TestCasePlayer { + public TestCaseCatchPlayer() : base(typeof(CatchRuleset)) + { + + } protected override Beatmap CreateBeatmap() { var beatmap = new Beatmap(); diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs index 5eef4a8470..407a5f7c3c 100644 --- a/osu.Game/Rulesets/RulesetStore.cs +++ b/osu.Game/Rulesets/RulesetStore.cs @@ -38,7 +38,6 @@ namespace osu.Game.Rulesets protected override void Prepare(bool reset = false) { - Connection.CreateTable(); if (reset) diff --git a/osu.Game/Tests/Visual/TestCasePlayer.cs b/osu.Game/Tests/Visual/TestCasePlayer.cs index 4a25a52e36..b0953ceb7e 100644 --- a/osu.Game/Tests/Visual/TestCasePlayer.cs +++ b/osu.Game/Tests/Visual/TestCasePlayer.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.IO; using System.Linq; using System.Text; @@ -18,31 +19,39 @@ namespace osu.Game.Tests.Visual { public class TestCasePlayer : OsuTestCase { + private readonly Type ruleset; + protected Player Player; - private RulesetStore rulesets; public override string Description => @"Showing everything to play the game."; + /// + /// Create a TestCase which runs through the Player screen. + /// + /// An optional ruleset type which we want to target. If not provided we'll allow all rulesets to be tested. + protected TestCasePlayer(Type ruleset) + { + this.ruleset = ruleset; + } + + public TestCasePlayer() + { + + } + [BackgroundDependencyLoader] private void load(RulesetStore rulesets) { - this.rulesets = rulesets; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - Add(new Box { RelativeSizeAxes = Framework.Graphics.Axes.Both, Colour = Color4.Black, }); - foreach (var r in rulesets.Query()) - AddStep(r.Name, () => loadPlayerFor(r)); + string instantiation = ruleset?.AssemblyQualifiedName; - loadPlayerFor(rulesets.Query().First()); + foreach (var r in rulesets.Query(rs => rs.Available && (instantiation == null || rs.InstantiationInfo == instantiation))) + AddStep(r.Name, () => loadPlayerFor(r)); } protected virtual Beatmap CreateBeatmap() From 12a9cbad56b84960226b21204ee2e6453d67d9a0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Oct 2017 21:54:26 +0800 Subject: [PATCH 35/46] Allow Beatmap to populate some metadata defaults if they aren't provided via BetamapInfo --- osu.Game/Beatmaps/Beatmap.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index 458c2304f2..383a331eb4 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -58,6 +58,23 @@ namespace osu.Game.Beatmaps ComboColors = original?.ComboColors ?? ComboColors; HitObjects = original?.HitObjects ?? HitObjects; Storyboard = original?.Storyboard ?? Storyboard; + + if (original == null && Metadata == null) + { + // we may have no metadata in cases we weren't sourced from the database. + // let's fill it (and other related fields) so we don't need to null-check it in future usages. + BeatmapInfo = new BeatmapInfo + { + Metadata = new BeatmapMetadata + { + Artist = @"Unknown", + Title = @"Unknown", + Author = @"Unknown Creator", + }, + Version = @"Normal", + Difficulty = new BeatmapDifficulty() + }; + } } } From 7168629b2a28f59a121a844b45f481b138e3df0d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Oct 2017 21:55:37 +0800 Subject: [PATCH 36/46] Remove CatcherArea abstraction Also fixes catcher size being relative to aspect ratio. --- .../Tests/TestCaseCatcher.cs | 4 +- osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs | 34 ++- osu.Game.Rulesets.Catch/UI/Catcher.cs | 193 +++++++++++++++ osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 229 ------------------ .../osu.Game.Rulesets.Catch.csproj | 2 +- 5 files changed, 225 insertions(+), 237 deletions(-) create mode 100644 osu.Game.Rulesets.Catch/UI/Catcher.cs delete mode 100644 osu.Game.Rulesets.Catch/UI/CatcherArea.cs diff --git a/osu.Game.Rulesets.Catch/Tests/TestCaseCatcher.cs b/osu.Game.Rulesets.Catch/Tests/TestCaseCatcher.cs index 6a065e197d..21a9bdec51 100644 --- a/osu.Game.Rulesets.Catch/Tests/TestCaseCatcher.cs +++ b/osu.Game.Rulesets.Catch/Tests/TestCaseCatcher.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Catch.Tests { public override IReadOnlyList RequiredTypes => new[] { - typeof(CatcherArea), + typeof(Catcher), }; [BackgroundDependencyLoader] @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Catch.Tests new CatchInputManager(rulesets.GetRuleset(2)) { RelativeSizeAxes = Axes.Both, - Child = new CatcherArea + Child = new Catcher { RelativePositionAxes = Axes.Both, RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs index 2b6f9bbf5a..38f3273055 100644 --- a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs +++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs @@ -1,10 +1,12 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Graphics; using osu.Game.Rulesets.UI; using OpenTK; using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects.Drawable; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects.Drawables; @@ -15,11 +17,15 @@ namespace osu.Game.Rulesets.Catch.UI { protected override Container Content => content; private readonly Container content; - private readonly CatcherArea catcherArea; + + private readonly Container catcherContainer; + private readonly Catcher catcher; public CatchPlayfield() : base(Axes.Y) { + Container explodingFruitContainer; + Reversed.Value = true; Size = new Vector2(1); @@ -33,16 +39,34 @@ namespace osu.Game.Rulesets.Catch.UI { RelativeSizeAxes = Axes.Both, }, - catcherArea = new CatcherArea + explodingFruitContainer = new Container { RelativeSizeAxes = Axes.Both, + }, + catcherContainer = new Container { + RelativeSizeAxes = Axes.X, Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, - Height = 0.3f + Height = 180, + Child = catcher = new Catcher + { + ExplodingFruitTarget = explodingFruitContainer, + RelativePositionAxes = Axes.Both, + Origin = Anchor.TopCentre, + X = 0.5f, + } } }; } + protected override void Update() + { + base.Update(); + catcher.Size = new Vector2(catcherContainer.DrawSize.Y); + } + + public bool CheckIfWeCanCatch(CatchBaseHit obj) => Math.Abs(catcher.Position.X - obj.X) < catcher.DrawSize.X / DrawSize.X / 2; + public override void Add(DrawableHitObject h) { h.Depth = (float)h.HitObject.StartTime; @@ -50,7 +74,7 @@ namespace osu.Game.Rulesets.Catch.UI base.Add(h); var fruit = (DrawableFruit)h; - fruit.CheckPosition = catcherArea.CheckIfWeCanCatch; + fruit.CheckPosition = CheckIfWeCanCatch; } public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) @@ -59,7 +83,7 @@ namespace osu.Game.Rulesets.Catch.UI { Vector2 screenPosition = judgedObject.ScreenSpaceDrawQuad.Centre; Remove(judgedObject); - catcherArea.Add(judgedObject, screenPosition); + catcher.Add(judgedObject, screenPosition); } } } diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs new file mode 100644 index 0000000000..87fe95ed2f --- /dev/null +++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs @@ -0,0 +1,193 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Framework.Input.Bindings; +using osu.Framework.MathUtils; +using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Objects.Drawables; +using OpenTK; + +namespace osu.Game.Rulesets.Catch.UI +{ + public class Catcher : Container, IKeyBindingHandler + { + private Texture texture; + + private Container caughtFruit; + + public Container ExplodingFruitTarget; + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + texture = textures.Get(@"Play/Catch/fruit-catcher-idle"); + + Children = new Drawable[] + { + createCatcherSprite(), + caughtFruit = new Container + { + Anchor = Anchor.TopCentre, + Origin = Anchor.BottomCentre, + } + }; + } + + private int currentDirection; + + private bool dashing; + + protected bool Dashing + { + get { return dashing; } + set + { + if (value == dashing) return; + + dashing = value; + + if (dashing) + Schedule(addAdditiveSprite); + } + } + + private void addAdditiveSprite() + { + if (!dashing) return; + + var additive = createCatcherSprite(); + + additive.RelativePositionAxes = Axes.Both; + additive.Blending = BlendingMode.Additive; + additive.Position = Position; + additive.Scale = Scale; + + ((Container)Parent).Add(additive); + + additive.FadeTo(0.4f).FadeOut(800, Easing.OutQuint).Expire(); + + Scheduler.AddDelayed(addAdditiveSprite, 50); + } + + private Sprite createCatcherSprite() => new Sprite + { + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fit, + Texture = texture, + OriginPosition = new Vector2(DrawWidth / 2, 10) //temporary until the sprite is aligned correctly. + }; + + public bool OnPressed(CatchAction action) + { + switch (action) + { + case CatchAction.MoveLeft: + currentDirection--; + return true; + case CatchAction.MoveRight: + currentDirection++; + return true; + case CatchAction.Dash: + Dashing = true; + return true; + } + + return false; + } + + public bool OnReleased(CatchAction action) + { + switch (action) + { + case CatchAction.MoveLeft: + currentDirection++; + return true; + case CatchAction.MoveRight: + currentDirection--; + return true; + case CatchAction.Dash: + Dashing = false; + return true; + } + + return false; + } + + /// + /// The relative space to cover in 1 millisecond. based on 1 game pixel per millisecond as in osu-stable. + /// + private const double base_speed = 1.0 / 512; + + protected override void Update() + { + base.Update(); + + if (currentDirection == 0) return; + + double dashModifier = Dashing ? 1 : 0.5; + + Scale = new Vector2(Math.Sign(currentDirection), 1); + X = (float)MathHelper.Clamp(X + Math.Sign(currentDirection) * Clock.ElapsedFrameTime * base_speed * dashModifier, 0, 1); + } + + public void Add(DrawableHitObject fruit, Vector2 absolutePosition) + { + fruit.RelativePositionAxes = Axes.None; + fruit.Position = new Vector2(ToLocalSpace(absolutePosition).X - DrawSize.X / 2, 0); + + fruit.Anchor = Anchor.TopCentre; + fruit.Origin = Anchor.BottomCentre; + fruit.Scale *= 0.7f; + fruit.LifetimeEnd = double.MaxValue; + + float distance = fruit.DrawSize.X / 2 * fruit.Scale.X; + + while (caughtFruit.Any(f => f.LifetimeEnd == double.MaxValue && Vector2Extensions.DistanceSquared(f.Position, fruit.Position) < distance * distance)) + { + fruit.X += RNG.Next(-5, 5); + fruit.Y -= RNG.Next(0, 5); + } + + caughtFruit.Add(fruit); + + if (((CatchBaseHit)fruit.HitObject).LastInCombo) + explode(); + } + + private void explode() + { + var fruit = caughtFruit.ToArray(); + + foreach (var f in fruit) + { + var originalX = f.X * Scale.X; + + if (ExplodingFruitTarget != null) + { + f.Anchor = Anchor.TopLeft; + f.Position = caughtFruit.ToSpaceOfOtherDrawable(f.DrawPosition, ExplodingFruitTarget); + + caughtFruit.Remove(f); + + ExplodingFruitTarget.Add(f); + } + + f.MoveToY(f.Y - 50, 250, Easing.OutSine) + .Then() + .MoveToY(f.Y + 50, 500, Easing.InSine); + + f.MoveToX(f.X + originalX * 6, 1000); + f.FadeOut(750); + + f.Expire(); + } + } + } +} diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs deleted file mode 100644 index 2930dbb7cc..0000000000 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Linq; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; -using osu.Framework.Input.Bindings; -using osu.Framework.MathUtils; -using osu.Game.Rulesets.Catch.Objects; -using osu.Game.Rulesets.Objects.Drawables; -using OpenTK; - -namespace osu.Game.Rulesets.Catch.UI -{ - public class CatcherArea : Container - { - private Catcher catcher; - private Container explodingFruitContainer; - - public void Add(DrawableHitObject fruit, Vector2 screenPosition) => catcher.AddToStack(fruit, screenPosition); - - public bool CheckIfWeCanCatch(CatchBaseHit obj) => Math.Abs(catcher.Position.X - obj.X) < catcher.DrawSize.X / DrawSize.X / 2; - - [BackgroundDependencyLoader] - private void load() - { - Children = new Drawable[] - { - explodingFruitContainer = new Container - { - RelativeSizeAxes = Axes.Both, - }, - catcher = new Catcher - { - RelativePositionAxes = Axes.Both, - ExplodingFruitTarget = explodingFruitContainer, - Origin = Anchor.TopCentre, - X = 0.5f, - } - }; - } - - protected override void Update() - { - base.Update(); - - catcher.Size = new Vector2(DrawSize.Y); - } - - private class Catcher : Container, IKeyBindingHandler - { - private Texture texture; - - private Container caughtFruit; - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - texture = textures.Get(@"Play/Catch/fruit-catcher-idle"); - - Children = new Drawable[] - { - createCatcherSprite(), - caughtFruit = new Container - { - Anchor = Anchor.TopCentre, - Origin = Anchor.BottomCentre, - } - }; - } - - private int currentDirection; - - private bool dashing; - - public Container ExplodingFruitTarget; - - protected bool Dashing - { - get { return dashing; } - set - { - if (value == dashing) return; - - dashing = value; - - if (dashing) - Schedule(addAdditiveSprite); - } - } - - private void addAdditiveSprite() - { - if (!dashing) return; - - var additive = createCatcherSprite(); - - additive.RelativePositionAxes = Axes.Both; - additive.Blending = BlendingMode.Additive; - additive.Position = Position; - additive.Scale = Scale; - - ((CatcherArea)Parent).Add(additive); - - additive.FadeTo(0.4f).FadeOut(800, Easing.OutQuint).Expire(); - - Scheduler.AddDelayed(addAdditiveSprite, 50); - } - - private Sprite createCatcherSprite() => new Sprite - { - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fit, - Texture = texture, - OriginPosition = new Vector2(DrawWidth / 2, 10) //temporary until the sprite is aligned correctly. - }; - - public bool OnPressed(CatchAction action) - { - switch (action) - { - case CatchAction.MoveLeft: - currentDirection--; - return true; - case CatchAction.MoveRight: - currentDirection++; - return true; - case CatchAction.Dash: - Dashing = true; - return true; - } - - return false; - } - - public bool OnReleased(CatchAction action) - { - switch (action) - { - case CatchAction.MoveLeft: - currentDirection++; - return true; - case CatchAction.MoveRight: - currentDirection--; - return true; - case CatchAction.Dash: - Dashing = false; - return true; - } - - return false; - } - - /// - /// The relative space to cover in 1 millisecond. based on 1 game pixel per millisecond as in osu-stable. - /// - private const double base_speed = 1.0 / 512; - - protected override void Update() - { - base.Update(); - - if (currentDirection == 0) return; - - double dashModifier = Dashing ? 1 : 0.5; - - Scale = new Vector2(Math.Sign(currentDirection), 1); - X = (float)MathHelper.Clamp(X + Math.Sign(currentDirection) * Clock.ElapsedFrameTime * base_speed * dashModifier, 0, 1); - } - - public void AddToStack(DrawableHitObject fruit, Vector2 absolutePosition) - { - fruit.RelativePositionAxes = Axes.None; - fruit.Position = new Vector2(ToLocalSpace(absolutePosition).X - DrawSize.X / 2, 0); - - fruit.Anchor = Anchor.TopCentre; - fruit.Origin = Anchor.BottomCentre; - fruit.Scale *= 0.7f; - fruit.LifetimeEnd = double.MaxValue; - - float distance = fruit.DrawSize.X / 2 * fruit.Scale.X; - - while (caughtFruit.Any(f => f.LifetimeEnd == double.MaxValue && Vector2Extensions.DistanceSquared(f.Position, fruit.Position) < distance * distance)) - { - fruit.X += RNG.Next(-5, 5); - fruit.Y -= RNG.Next(0, 5); - } - - caughtFruit.Add(fruit); - - if (((CatchBaseHit)fruit.HitObject).LastInCombo) - explode(); - } - - private void explode() - { - var fruit = caughtFruit.ToArray(); - - foreach (var f in fruit) - { - var originalX = f.X * Scale.X; - - if (ExplodingFruitTarget != null) - { - f.Anchor = Anchor.TopLeft; - f.Position = caughtFruit.ToSpaceOfOtherDrawable(f.DrawPosition, ExplodingFruitTarget); - - caughtFruit.Remove(f); - - ExplodingFruitTarget.Add(f); - } - - f.MoveToY(f.Y - 50, 250, Easing.OutSine) - .Then() - .MoveToY(f.Y + 50, 500, Easing.InSine); - - f.MoveToX(f.X + originalX * 6, 1000); - f.FadeOut(750); - - f.Expire(); - } - } - } - } -} diff --git a/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj b/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj index 787825d482..718ae32a17 100644 --- a/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj +++ b/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj @@ -59,7 +59,7 @@ - + From 3338024c17b6febbf5aa47acc41b021e1f25c83c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Oct 2017 22:12:53 +0800 Subject: [PATCH 37/46] Fix incorrect whitespace --- osu.Game.Rulesets.Catch/Tests/TestCaseCatchPlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Tests/TestCaseCatchPlayer.cs b/osu.Game.Rulesets.Catch/Tests/TestCaseCatchPlayer.cs index 45ab8ac300..5be07e94c0 100644 --- a/osu.Game.Rulesets.Catch/Tests/TestCaseCatchPlayer.cs +++ b/osu.Game.Rulesets.Catch/Tests/TestCaseCatchPlayer.cs @@ -12,8 +12,8 @@ namespace osu.Game.Rulesets.Catch.Tests { public TestCaseCatchPlayer() : base(typeof(CatchRuleset)) { - } + protected override Beatmap CreateBeatmap() { var beatmap = new Beatmap(); From 37393ab2c946bfb236e7ae0514efcf895ffcec4a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Oct 2017 22:24:22 +0800 Subject: [PATCH 38/46] Move brace --- osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs index 38f3273055..c4033b562d 100644 --- a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs +++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs @@ -43,7 +43,8 @@ namespace osu.Game.Rulesets.Catch.UI { RelativeSizeAxes = Axes.Both, }, - catcherContainer = new Container { + catcherContainer = new Container + { RelativeSizeAxes = Axes.X, Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, From 22a59d753b8fdb873a095ec77f67ee458c5b1d09 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 5 Oct 2017 04:38:13 +0300 Subject: [PATCH 39/46] Make all the overlays IStateful --- .../Play/BreaksOverlay/ArrowsOverlay.cs | 26 +++++---- .../Play/BreaksOverlay/BreakOverlay.cs | 17 +++--- .../Play/BreaksOverlay/InfoContainer.cs | 55 +++++++++++-------- .../Play/BreaksOverlay/LetterboxOverlay.cs | 9 ++- .../BreaksOverlay/RemainingTimeCounter.cs | 9 ++- 5 files changed, 69 insertions(+), 47 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs index 9d729826de..111ed61fd3 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs @@ -5,11 +5,15 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using OpenTK; using osu.Game.Graphics.Containers; +using System; +using osu.Game.Beatmaps.Timing; namespace osu.Game.Screens.Play.BreaksOverlay { - public class ArrowsOverlay : Container + public class ArrowsOverlay : VisibilityContainer { + private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; + private const int glow_icon_size = 60; private const int glow_icon_blur_sigma = 10; private const float glow_icon_final_offset = 0.22f; @@ -79,22 +83,22 @@ namespace osu.Game.Screens.Play.BreaksOverlay }; } - public void Show(double fadeDuration) + protected override void PopIn() { - leftGlowIcon.MoveToX(-glow_icon_final_offset, fadeDuration, Easing.OutQuint); - rightGlowIcon.MoveToX(glow_icon_final_offset, fadeDuration, Easing.OutQuint); + leftGlowIcon.MoveToX(-glow_icon_final_offset, fade_duration, Easing.OutQuint); + rightGlowIcon.MoveToX(glow_icon_final_offset, fade_duration, Easing.OutQuint); - leftBlurredIcon.MoveToX(-blurred_icon_final_offset, fadeDuration, Easing.OutQuint); - rightBlurredIcon.MoveToX(blurred_icon_final_offset, fadeDuration, Easing.OutQuint); + leftBlurredIcon.MoveToX(-blurred_icon_final_offset, fade_duration, Easing.OutQuint); + rightBlurredIcon.MoveToX(blurred_icon_final_offset, fade_duration, Easing.OutQuint); } - public void Hide(double fadeDuration) + protected override void PopOut() { - leftGlowIcon.MoveToX(-glow_icon_offscreen_offset, fadeDuration, Easing.OutQuint); - rightGlowIcon.MoveToX(glow_icon_offscreen_offset, fadeDuration, Easing.OutQuint); + leftGlowIcon.MoveToX(-glow_icon_offscreen_offset, fade_duration, Easing.OutQuint); + rightGlowIcon.MoveToX(glow_icon_offscreen_offset, fade_duration, Easing.OutQuint); - leftBlurredIcon.MoveToX(-blurred_icon_offscreen_offset, fadeDuration, Easing.OutQuint); - rightBlurredIcon.MoveToX(blurred_icon_offscreen_offset, fadeDuration, Easing.OutQuint); + leftBlurredIcon.MoveToX(-blurred_icon_offscreen_offset, fade_duration, Easing.OutQuint); + rightBlurredIcon.MoveToX(blurred_icon_offscreen_offset, fade_duration, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 3b2335a455..1b0e04eac1 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -106,7 +106,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay private void onBreakIn(BreakPeriod b) { if (letterboxing) - letterboxOverlay.FadeIn(fade_duration); + letterboxOverlay.Show(); remainingTimeBox .ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint) @@ -115,20 +115,19 @@ namespace osu.Game.Screens.Play.BreaksOverlay Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); - remainingTimeCounter.FadeIn(fade_duration); - - info.FadeIn(fade_duration); - arrowsOverlay.Show(fade_duration); + remainingTimeCounter.Show(); + info.Show(); + arrowsOverlay.Show(); } private void onBreakOut() { if (letterboxing) - letterboxOverlay.FadeOut(fade_duration); + letterboxOverlay.Hide(); - remainingTimeCounter.FadeOut(fade_duration); - info.FadeOut(fade_duration); - arrowsOverlay.Hide(fade_duration); + remainingTimeCounter.Hide(); + info.Hide(); + arrowsOverlay.Hide(); } public void BindProcessor(ScoreProcessor processor) diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs index 351dc66930..6a850d066d 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs @@ -1,16 +1,20 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Scoring; +using osu.Game.Beatmaps.Timing; namespace osu.Game.Screens.Play.BreaksOverlay { - public class InfoContainer : FillFlowContainer + public class InfoContainer : VisibilityContainer { + private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; + public PercentageInfoLine AccuracyDisplay; public InfoLine RankDisplay; public InfoLine GradeDisplay; @@ -18,33 +22,38 @@ namespace osu.Game.Screens.Play.BreaksOverlay public InfoContainer() { AutoSizeAxes = Axes.Both; - Alpha = 0; - Direction = FillDirection.Vertical; - Spacing = new Vector2(5); - Children = new Drawable[] + Child = new FillFlowContainer { - new OsuSpriteText + Direction = FillDirection.Vertical, + Spacing = new Vector2(5), + Children = new Drawable[] { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Text = "current progress".ToUpper(), - TextSize = 15, - Font = "Exo2.0-Black", - }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Direction = FillDirection.Vertical, - Children = new Drawable[] + new OsuSpriteText { - AccuracyDisplay = new PercentageInfoLine("Accuracy"), - RankDisplay = new InfoLine("Rank", @"#"), - GradeDisplay = new InfoLine("Grade"), + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = "current progress".ToUpper(), + TextSize = 15, + Font = "Exo2.0-Black", }, - } + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + AccuracyDisplay = new PercentageInfoLine("Accuracy"), + RankDisplay = new InfoLine("Rank", @"#"), + GradeDisplay = new InfoLine("Grade"), + }, + } + }, }; } + + protected override void PopIn() => this.FadeIn(fade_duration); + protected override void PopOut() => this.FadeOut(fade_duration); } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs index 1581c45c56..e0d3889673 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs @@ -1,16 +1,19 @@ // 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.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps.Timing; namespace osu.Game.Screens.Play.BreaksOverlay { - public class LetterboxOverlay : Container + public class LetterboxOverlay : VisibilityContainer { + private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; private const int height = 350; private static readonly Color4 transparent_black = new Color4(0, 0, 0, 0); @@ -18,7 +21,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay public LetterboxOverlay() { RelativeSizeAxes = Axes.Both; - Alpha = 0; Children = new Drawable[] { new Container @@ -59,5 +61,8 @@ namespace osu.Game.Screens.Play.BreaksOverlay } }; } + + protected override void PopIn() => this.FadeIn(fade_duration); + protected override void PopOut() => this.FadeOut(fade_duration); } } diff --git a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs index c8b8b6a072..b5d77d0d02 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs @@ -5,11 +5,14 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Framework.Graphics; using System; +using osu.Game.Beatmaps.Timing; namespace osu.Game.Screens.Play.BreaksOverlay { - public class RemainingTimeCounter : Container + public class RemainingTimeCounter : VisibilityContainer { + private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; + private readonly OsuSpriteText counter; private int? previousSecond; @@ -21,7 +24,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay public RemainingTimeCounter() { AutoSizeAxes = Axes.Both; - Alpha = 0; Child = counter = new OsuSpriteText { Anchor = Anchor.Centre, @@ -56,5 +58,8 @@ namespace osu.Game.Screens.Play.BreaksOverlay else isCounting = false; } } + + protected override void PopIn() => this.FadeIn(fade_duration); + protected override void PopOut() => this.FadeOut(fade_duration); } } From 20bf0502ab4cabe2e38561b75a92c5e0822b65d6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 5 Oct 2017 10:03:48 +0800 Subject: [PATCH 40/46] Use scheduling rather than raw transform delays --- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 1b0e04eac1..4457eb56f8 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -93,12 +93,11 @@ namespace osu.Game.Screens.Play.BreaksOverlay if (!b.HasEffect) continue; - using (BeginAbsoluteSequence(b.StartTime, true)) + using (BeginAbsoluteSequence(b.StartTime)) { - onBreakIn(b); - - using (BeginDelayedSequence(b.Duration - fade_duration, true)) - onBreakOut(); + Schedule(() => onBreakIn(b)); + using (BeginDelayedSequence(b.Duration - fade_duration)) + Schedule(onBreakOut); } } } @@ -113,7 +112,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay .Then() .ResizeWidthTo(0, b.Duration - fade_duration); - Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); + remainingTimeCounter.StartCounting(b.EndTime); remainingTimeCounter.Show(); info.Show(); From cc99678a963cf2f36e9affe900aa4346c93ff62a Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 5 Oct 2017 05:09:23 +0300 Subject: [PATCH 41/46] Remove useless usings --- osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs | 1 - osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs | 1 - osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs | 1 - 3 files changed, 3 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs index 111ed61fd3..0b775d5c35 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/ArrowsOverlay.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using OpenTK; using osu.Game.Graphics.Containers; -using System; using osu.Game.Beatmaps.Timing; namespace osu.Game.Screens.Play.BreaksOverlay diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs index 6a850d066d..307828b665 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.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 OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs index e0d3889673..9d5bc986e9 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/LetterboxOverlay.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 OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; From cb0dbc6d9ef6671b80d947a0d9be2734cf901baf Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 5 Oct 2017 05:23:18 +0300 Subject: [PATCH 42/46] Fix shrinking bar lingering on the screen for too long --- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 4457eb56f8..64521a7972 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -110,7 +110,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay remainingTimeBox .ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint) .Then() - .ResizeWidthTo(0, b.Duration - fade_duration); + .ResizeWidthTo(0, b.Duration - fade_duration * 2); remainingTimeCounter.StartCounting(b.EndTime); From 5caca1d3283b8478b05f0df815c17aeb386da4a1 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 5 Oct 2017 05:27:52 +0300 Subject: [PATCH 43/46] Don't use '#' in RankDisplay for now --- osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs index 307828b665..1bf9b26cc9 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs @@ -44,7 +44,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay Children = new Drawable[] { AccuracyDisplay = new PercentageInfoLine("Accuracy"), - RankDisplay = new InfoLine("Rank", @"#"), + RankDisplay = new InfoLine("Rank"), GradeDisplay = new InfoLine("Grade"), }, } From 2bc8fe027b616e904c1b6958a7427104e88f6a84 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 5 Oct 2017 06:17:48 +0300 Subject: [PATCH 44/46] Extend the testcase to test short breaks --- osu.Game/Tests/Visual/TestCaseBreakOverlay.cs | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs index 074aa16934..206ca308cf 100644 --- a/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs +++ b/osu.Game/Tests/Visual/TestCaseBreakOverlay.cs @@ -20,11 +20,12 @@ namespace osu.Game.Tests.Visual Child = breakOverlay = new BreakOverlay(true); - AddStep("Add 2s break", () => startBreak(2000)); - AddStep("Add 5s break", () => startBreak(5000)); - AddStep("Add 10s break", () => startBreak(10000)); - AddStep("Add 15s break", () => startBreak(15000)); - AddStep("Add 2 breaks (2s each)", startMultipleBreaks); + AddStep("2s break", () => startBreak(2000)); + AddStep("5s break", () => startBreak(5000)); + AddStep("10s break", () => startBreak(10000)); + AddStep("15s break", () => startBreak(15000)); + AddStep("2s, 2s", startMultipleBreaks); + AddStep("0.5s, 0.7s, 1s, 2s", startAnotherMultipleBreaks); } private void startBreak(double duration) @@ -57,5 +58,34 @@ namespace osu.Game.Tests.Visual } }; } + + private void startAnotherMultipleBreaks() + { + double currentTime = Clock.CurrentTime; + + breakOverlay.Breaks = new List + { + new BreakPeriod // Duration is less than 650 - too short to appear + { + StartTime = currentTime, + EndTime = currentTime + 500, + }, + new BreakPeriod + { + StartTime = currentTime + 1500, + EndTime = currentTime + 2200, + }, + new BreakPeriod + { + StartTime = currentTime + 3200, + EndTime = currentTime + 4200, + }, + new BreakPeriod + { + StartTime = currentTime + 5200, + EndTime = currentTime + 7200, + } + }; + } } } \ No newline at end of file From 96fcc095eb8461a5c0a30ba456e73ab2badd64bf Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 6 Oct 2017 04:49:16 +0300 Subject: [PATCH 45/46] Apply suggested shrinking bar changes --- .../Play/BreaksOverlay/BreakOverlay.cs | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index 64521a7972..ea24cffb30 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -33,6 +33,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay private readonly bool letterboxing; private readonly LetterboxOverlay letterboxOverlay; + private readonly Container remainingTimeAdjustmentBox; private readonly Container remainingTimeBox; private readonly RemainingTimeCounter remainingTimeCounter; private readonly InfoContainer info; @@ -50,15 +51,23 @@ namespace osu.Game.Screens.Play.BreaksOverlay Anchor = Anchor.Centre, Origin = Anchor.Centre, }, - remainingTimeBox = new Container + remainingTimeAdjustmentBox = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, + AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Size = new Vector2(0, 8), - CornerRadius = 4, - Masking = true, - Child = new Box { RelativeSizeAxes = Axes.Both } + Width = 0, + Child = remainingTimeBox = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Height = 8, + CornerRadius = 4, + Masking = true, + Child = new Box { RelativeSizeAxes = Axes.Both } + } }, remainingTimeCounter = new RemainingTimeCounter { @@ -107,10 +116,15 @@ namespace osu.Game.Screens.Play.BreaksOverlay if (letterboxing) letterboxOverlay.Show(); - remainingTimeBox + remainingTimeAdjustmentBox .ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint) + .Delay(b.Duration - fade_duration) + .ResizeWidthTo(0); + + remainingTimeBox + .ResizeWidthTo(0, b.Duration - fade_duration) .Then() - .ResizeWidthTo(0, b.Duration - fade_duration * 2); + .ResizeWidthTo(1); remainingTimeCounter.StartCounting(b.EndTime); From 95ac4e92658d448c07bfb29fdcdc7248d5876a12 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 6 Oct 2017 04:57:46 +0300 Subject: [PATCH 46/46] Remove useless using --- osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index ea24cffb30..f5062aa40f 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.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 OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes;