From d944b8c1922bbc88098223159a2291048c8cd753 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 31 Mar 2017 11:01:42 +0900 Subject: [PATCH 1/6] Implement IAccented interface + transform. --- osu-framework | 2 +- osu.Game/Graphics/IAccented.cs | 36 ++++++++++++++++++ .../Graphics/Transforms/TransformAccent.cs | 37 +++++++++++++++++++ .../UserInterface/PercentageCounter.cs | 2 +- .../Graphics/UserInterface/ScoreCounter.cs | 2 +- osu.Game/Modes/UI/ComboCounter.cs | 2 +- osu.Game/Modes/UI/ComboResultCounter.cs | 2 +- osu.Game/osu.Game.csproj | 2 + 8 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 osu.Game/Graphics/IAccented.cs create mode 100644 osu.Game/Graphics/Transforms/TransformAccent.cs diff --git a/osu-framework b/osu-framework index 269a1fd192..3931f8e358 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 269a1fd192c573d558a5ab0ff990a8b462947287 +Subproject commit 3931f8e358365b1853a76e1d141fcf4c929a2143 diff --git a/osu.Game/Graphics/IAccented.cs b/osu.Game/Graphics/IAccented.cs new file mode 100644 index 0000000000..6f0f107f3c --- /dev/null +++ b/osu.Game/Graphics/IAccented.cs @@ -0,0 +1,36 @@ +// 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.Game.Graphics.Transforms; + +namespace osu.Game.Graphics +{ + /// + /// A type of drawable that has an accent colour. + /// The accent colour is used to colorize various objects inside a drawable + /// without colorizing the drawable itself. + /// + public interface IAccented : IDrawable + { + Color4 AccentColour { get; set; } + } + + public static class AccentedExtensions + { + /// + /// Tweens the accent colour of a drawable to another colour. + /// + /// The type of drawable. + /// The drawable to apply the accent colour to. + /// The new accent colour. + /// The tween duration. + /// The tween easing. + public static void FadeAccent(this TDrawable drawable, Color4 newColour, double duration = 0, EasingTypes easing = EasingTypes.None) + where TDrawable : Drawable, IAccented + { + drawable.TransformTo(drawable.AccentColour, newColour, duration, easing, new TransformAccent()); + } + } +} diff --git a/osu.Game/Graphics/Transforms/TransformAccent.cs b/osu.Game/Graphics/Transforms/TransformAccent.cs new file mode 100644 index 0000000000..7f40a0a016 --- /dev/null +++ b/osu.Game/Graphics/Transforms/TransformAccent.cs @@ -0,0 +1,37 @@ +// 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.Transforms; +using osu.Framework.MathUtils; + +namespace osu.Game.Graphics.Transforms +{ + public class TransformAccent : Transform + { + /// + /// Current value of the transformed colour in linear colour space. + /// + public override Color4 CurrentValue + { + get + { + double time = Time?.Current ?? 0; + if (time < StartTime) return StartValue; + if (time >= EndTime) return EndValue; + + return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); + } + } + + public override void Apply(Drawable d) + { + base.Apply(d); + + var accented = d as IAccented; + if (accented != null) + accented.AccentColour = CurrentValue; + } + } +} diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index 66c9e7d461..c32b654840 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -47,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface protected class TransformAccuracy : Transform { - protected override double CurrentValue + public override double CurrentValue { get { diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index c9a1040185..c2b1b026b6 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -51,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface protected class TransformScore : Transform { - protected override double CurrentValue + public override double CurrentValue { get { diff --git a/osu.Game/Modes/UI/ComboCounter.cs b/osu.Game/Modes/UI/ComboCounter.cs index f831677e44..3629634889 100644 --- a/osu.Game/Modes/UI/ComboCounter.cs +++ b/osu.Game/Modes/UI/ComboCounter.cs @@ -213,7 +213,7 @@ namespace osu.Game.Modes.UI protected class TransformComboRoll : Transform { - protected override int CurrentValue + public override int CurrentValue { get { diff --git a/osu.Game/Modes/UI/ComboResultCounter.cs b/osu.Game/Modes/UI/ComboResultCounter.cs index 957a720c94..63009c5351 100644 --- a/osu.Game/Modes/UI/ComboResultCounter.cs +++ b/osu.Game/Modes/UI/ComboResultCounter.cs @@ -36,7 +36,7 @@ namespace osu.Game.Modes.UI protected class TransformComboResult : Transform { - protected override ulong CurrentValue + public override ulong CurrentValue { get { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a5bdf1df69..00c189d01c 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -82,7 +82,9 @@ + + From b54201cbe388603c5349eaf81dd4fd8a95779d23 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 31 Mar 2017 11:09:02 +0900 Subject: [PATCH 2/6] Appease resharpoo. --- osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs index ec98feddae..20e16ae03c 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Backgrounds; using OpenTK.Graphics; using System; +using osu.Game.Graphics; namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces { @@ -18,7 +19,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces /// a rounded (_[-Width-]_) figure such that a regular "circle" is the result of a parent with Width = 0. /// /// - public class CirclePiece : Container + public class CirclePiece : Container, IAccented { public const float SYMBOL_SIZE = TaikoHitObject.CIRCLE_RADIUS * 2f * 0.45f; public const float SYMBOL_BORDER = 8; From 591ecc0ef4087899f69068b25a07d3e4ca578983 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 31 Mar 2017 11:48:54 +0900 Subject: [PATCH 3/6] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 3931f8e358..591b799f95 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 3931f8e358365b1853a76e1d141fcf4c929a2143 +Subproject commit 591b799f95a47e5da893c82d024e01311c9c37c6 From 43c306d65860f3d42d1482e48e903a05b1a130f5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 31 Mar 2017 14:47:59 +0900 Subject: [PATCH 4/6] IAccented -> IHasAccentColour. --- osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs | 2 +- osu.Game/Graphics/{IAccented.cs => IHasAccentColour.cs} | 6 +++--- osu.Game/Graphics/Transforms/TransformAccent.cs | 2 +- osu.Game/osu.Game.csproj | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename osu.Game/Graphics/{IAccented.cs => IHasAccentColour.cs} (87%) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs index 20e16ae03c..2321ad30ee 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs @@ -19,7 +19,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces /// a rounded (_[-Width-]_) figure such that a regular "circle" is the result of a parent with Width = 0. /// /// - public class CirclePiece : Container, IAccented + public class CirclePiece : Container, IHasAccentColour { public const float SYMBOL_SIZE = TaikoHitObject.CIRCLE_RADIUS * 2f * 0.45f; public const float SYMBOL_BORDER = 8; diff --git a/osu.Game/Graphics/IAccented.cs b/osu.Game/Graphics/IHasAccentColour.cs similarity index 87% rename from osu.Game/Graphics/IAccented.cs rename to osu.Game/Graphics/IHasAccentColour.cs index 6f0f107f3c..19f063e29a 100644 --- a/osu.Game/Graphics/IAccented.cs +++ b/osu.Game/Graphics/IHasAccentColour.cs @@ -12,12 +12,12 @@ namespace osu.Game.Graphics /// The accent colour is used to colorize various objects inside a drawable /// without colorizing the drawable itself. /// - public interface IAccented : IDrawable + public interface IHasAccentColour : IDrawable { Color4 AccentColour { get; set; } } - public static class AccentedExtensions + public static class AccentedColourExtensions { /// /// Tweens the accent colour of a drawable to another colour. @@ -28,7 +28,7 @@ namespace osu.Game.Graphics /// The tween duration. /// The tween easing. public static void FadeAccent(this TDrawable drawable, Color4 newColour, double duration = 0, EasingTypes easing = EasingTypes.None) - where TDrawable : Drawable, IAccented + where TDrawable : Drawable, IHasAccentColour { drawable.TransformTo(drawable.AccentColour, newColour, duration, easing, new TransformAccent()); } diff --git a/osu.Game/Graphics/Transforms/TransformAccent.cs b/osu.Game/Graphics/Transforms/TransformAccent.cs index 7f40a0a016..406d1ea9eb 100644 --- a/osu.Game/Graphics/Transforms/TransformAccent.cs +++ b/osu.Game/Graphics/Transforms/TransformAccent.cs @@ -29,7 +29,7 @@ namespace osu.Game.Graphics.Transforms { base.Apply(d); - var accented = d as IAccented; + var accented = d as IHasAccentColour; if (accented != null) accented.AccentColour = CurrentValue; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 00c189d01c..b2f76137fd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -82,7 +82,7 @@ - + From a48224bd6dcc7e150e32518d487a96895f1f484e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 31 Mar 2017 15:05:14 +0900 Subject: [PATCH 5/6] Don't need Drawable type. --- osu-framework | 2 +- osu.Game/Graphics/IHasAccentColour.cs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/osu-framework b/osu-framework index 591b799f95..57821bd61c 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 591b799f95a47e5da893c82d024e01311c9c37c6 +Subproject commit 57821bd61c7676c2fd9e8ff3ea314ec81c1eef41 diff --git a/osu.Game/Graphics/IHasAccentColour.cs b/osu.Game/Graphics/IHasAccentColour.cs index 19f063e29a..f959bc8760 100644 --- a/osu.Game/Graphics/IHasAccentColour.cs +++ b/osu.Game/Graphics/IHasAccentColour.cs @@ -22,15 +22,13 @@ namespace osu.Game.Graphics /// /// Tweens the accent colour of a drawable to another colour. /// - /// The type of drawable. - /// The drawable to apply the accent colour to. + /// The drawable to apply the accent colour to. /// The new accent colour. /// The tween duration. /// The tween easing. - public static void FadeAccent(this TDrawable drawable, Color4 newColour, double duration = 0, EasingTypes easing = EasingTypes.None) - where TDrawable : Drawable, IHasAccentColour + public static void FadeAccent(this IHasAccentColour accentedDrawable, Color4 newColour, double duration = 0, EasingTypes easing = EasingTypes.None) { - drawable.TransformTo(drawable.AccentColour, newColour, duration, easing, new TransformAccent()); + accentedDrawable.TransformTo(accentedDrawable.AccentColour, newColour, duration, easing, new TransformAccent()); } } } From 75bdccdc3e5bbbb45478fd4f971c7aa2376c712c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 31 Mar 2017 16:03:59 +0900 Subject: [PATCH 6/6] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 57821bd61c..415884e7e1 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 57821bd61c7676c2fd9e8ff3ea314ec81c1eef41 +Subproject commit 415884e7e19f9062a4fac457a7ce19b566fa2ee7