From 88d50b6c4751e7fc87580b8e5bed753052017fa3 Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Sat, 22 Aug 2020 00:15:37 +0900
Subject: [PATCH 01/12] Remove alpha mangling from LegacyDecoder

---
 osu.Game/Beatmaps/Formats/LegacyDecoder.cs | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
index 44ef9bcacc..c15240a4f6 100644
--- a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
@@ -104,10 +104,6 @@ namespace osu.Game.Beatmaps.Formats
             try
             {
                 byte alpha = split.Length == 4 ? byte.Parse(split[3]) : (byte)255;
-
-                if (alpha == 0)
-                    alpha = 255;
-
                 colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), alpha);
             }
             catch

From 2424fa08027ebe105e1102997e8379ec31528c0a Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Sat, 22 Aug 2020 00:15:58 +0900
Subject: [PATCH 02/12] Add helper methods

---
 osu.Game/Skinning/LegacySkinExtensions.cs | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/osu.Game/Skinning/LegacySkinExtensions.cs b/osu.Game/Skinning/LegacySkinExtensions.cs
index bb46dc8b9f..088eae4bce 100644
--- a/osu.Game/Skinning/LegacySkinExtensions.cs
+++ b/osu.Game/Skinning/LegacySkinExtensions.cs
@@ -9,6 +9,7 @@ using osu.Framework.Graphics.Animations;
 using osu.Framework.Graphics.OpenGL.Textures;
 using osu.Framework.Graphics.Sprites;
 using osu.Framework.Graphics.Textures;
+using osuTK.Graphics;
 using static osu.Game.Skinning.LegacySkinConfiguration;
 
 namespace osu.Game.Skinning
@@ -62,6 +63,21 @@ namespace osu.Game.Skinning
             }
         }
 
+        public static Color4 ToLegacyColour(this Color4 colour)
+        {
+            if (colour.A == 0)
+                colour.A = 1;
+            return colour;
+        }
+
+        public static T WithInitialColour<T>(this T drawable, Color4 colour)
+            where T : Drawable
+        {
+            drawable.Alpha = colour.A;
+            drawable.Colour = ToLegacyColour(colour);
+            return drawable;
+        }
+
         public class SkinnableTextureAnimation : TextureAnimation
         {
             [Resolved(canBeNull: true)]

From eaba32335327dc0a4f987f8b8f35bb89a01d51cb Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Sat, 22 Aug 2020 00:17:35 +0900
Subject: [PATCH 03/12] Update catch with legacy colour setters

---
 .../Skinning/CatchLegacySkinTransformer.cs                | 8 +++++++-
 osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs      | 3 +--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs b/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs
index d929da1a29..5abd87d6f4 100644
--- a/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs
+++ b/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs
@@ -6,6 +6,7 @@ using osu.Framework.Bindables;
 using osu.Framework.Graphics;
 using osu.Game.Skinning;
 using osuTK;
+using osuTK.Graphics;
 
 namespace osu.Game.Rulesets.Catch.Skinning
 {
@@ -61,7 +62,12 @@ namespace osu.Game.Rulesets.Catch.Skinning
             switch (lookup)
             {
                 case CatchSkinColour colour:
-                    return Source.GetConfig<SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour));
+                    var result = (Bindable<Color4>)Source.GetConfig<SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour));
+                    if (result == null)
+                        return null;
+
+                    result.Value = result.Value.ToLegacyColour();
+                    return (IBindable<TValue>)result;
             }
 
             return Source.GetConfig<TLookup, TValue>(lookup);
diff --git a/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs b/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs
index 5be54d3882..c9dd1d1f3e 100644
--- a/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs
+++ b/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs
@@ -40,7 +40,6 @@ namespace osu.Game.Rulesets.Catch.Skinning
                 colouredSprite = new Sprite
                 {
                     Texture = skin.GetTexture(lookupName),
-                    Colour = drawableObject.AccentColour.Value,
                     Anchor = Anchor.Centre,
                     Origin = Anchor.Centre,
                 },
@@ -76,7 +75,7 @@ namespace osu.Game.Rulesets.Catch.Skinning
         {
             base.LoadComplete();
 
-            accentColour.BindValueChanged(colour => colouredSprite.Colour = colour.NewValue, true);
+            accentColour.BindValueChanged(colour => colouredSprite.Colour = colour.NewValue.ToLegacyColour(), true);
         }
     }
 }

From 454564b18928a17525e12596ca38446844cb0600 Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Sat, 22 Aug 2020 00:19:15 +0900
Subject: [PATCH 04/12] Update mania with legacy colour setters

---
 .../Skinning/LegacyColumnBackground.cs        | 20 ++++++++-----------
 .../Skinning/LegacyHitTarget.cs               |  2 +-
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs b/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs
index 64a7641421..b97547bbc6 100644
--- a/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs
@@ -58,28 +58,24 @@ namespace osu.Game.Rulesets.Mania.Skinning
 
             InternalChildren = new Drawable[]
             {
-                new Box
-                {
-                    RelativeSizeAxes = Axes.Both,
-                    Colour = backgroundColour
-                },
-                new Box
+                new Box { RelativeSizeAxes = Axes.Both }.WithInitialColour(backgroundColour),
+                new Container
                 {
                     RelativeSizeAxes = Axes.Y,
                     Width = leftLineWidth,
                     Scale = new Vector2(0.740f, 1),
-                    Colour = lineColour,
-                    Alpha = hasLeftLine ? 1 : 0
+                    Alpha = hasLeftLine ? 1 : 0,
+                    Child = new Box { RelativeSizeAxes = Axes.Both }.WithInitialColour(lineColour)
                 },
-                new Box
+                new Container
                 {
                     Anchor = Anchor.TopRight,
                     Origin = Anchor.TopRight,
                     RelativeSizeAxes = Axes.Y,
                     Width = rightLineWidth,
                     Scale = new Vector2(0.740f, 1),
-                    Colour = lineColour,
-                    Alpha = hasRightLine ? 1 : 0
+                    Alpha = hasRightLine ? 1 : 0,
+                    Child = new Box { RelativeSizeAxes = Axes.Both }.WithInitialColour(lineColour)
                 },
                 lightContainer = new Container
                 {
@@ -90,7 +86,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
                     {
                         Anchor = Anchor.BottomCentre,
                         Origin = Anchor.BottomCentre,
-                        Colour = lightColour,
+                        Colour = lightColour.ToLegacyColour(),
                         Texture = skin.GetTexture(lightImage),
                         RelativeSizeAxes = Axes.X,
                         Width = 1,
diff --git a/osu.Game.Rulesets.Mania/Skinning/LegacyHitTarget.cs b/osu.Game.Rulesets.Mania/Skinning/LegacyHitTarget.cs
index d055ef3480..2177eaa5e6 100644
--- a/osu.Game.Rulesets.Mania/Skinning/LegacyHitTarget.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/LegacyHitTarget.cs
@@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
                         Anchor = Anchor.CentreLeft,
                         RelativeSizeAxes = Axes.X,
                         Height = 1,
-                        Colour = lineColour,
+                        Colour = lineColour.ToLegacyColour(),
                         Alpha = showJudgementLine ? 0.9f : 0
                     }
                 }

From 16a2ab9dea4fd58e56eb00c017e61fce002b7ed2 Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Sat, 22 Aug 2020 00:20:33 +0900
Subject: [PATCH 05/12] Update osu with legacy colour setters

---
 osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs | 3 +--
 osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs      | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs b/osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs
index 0ab3e8825b..8a6beddb51 100644
--- a/osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs
@@ -59,7 +59,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
                         hitCircleSprite = new Sprite
                         {
                             Texture = getTextureWithFallback(string.Empty),
-                            Colour = drawableObject.AccentColour.Value,
                             Anchor = Anchor.Centre,
                             Origin = Anchor.Centre,
                         },
@@ -107,7 +106,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
             base.LoadComplete();
 
             state.BindValueChanged(updateState, true);
-            accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true);
+            accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue.ToLegacyColour(), true);
             indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true);
         }
 
diff --git a/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs b/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
index 0f586034d5..3b75fcc8a0 100644
--- a/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
@@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
         [BackgroundDependencyLoader]
         private void load(ISkinSource skin, DrawableHitObject drawableObject)
         {
-            animationContent.Colour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBall)?.Value ?? Color4.White;
+            var ballColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBall)?.Value ?? Color4.White;
 
             InternalChildren = new[]
             {
@@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
                     Texture = skin.GetTexture("sliderb-nd"),
                     Colour = new Color4(5, 5, 5, 255),
                 },
-                animationContent.With(d =>
+                animationContent.WithInitialColour(ballColour).With(d =>
                 {
                     d.Anchor = Anchor.Centre;
                     d.Origin = Anchor.Centre;

From 9fbc5f3aeb546fc27572a4c511793d6dd91088ea Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Sat, 22 Aug 2020 00:23:08 +0900
Subject: [PATCH 06/12] Update taiko with legacy colour setters

---
 osu.Game.Rulesets.Taiko/Skinning/LegacyCirclePiece.cs | 2 +-
 osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs    | 6 +++---
 osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs         | 5 +++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/osu.Game.Rulesets.Taiko/Skinning/LegacyCirclePiece.cs b/osu.Game.Rulesets.Taiko/Skinning/LegacyCirclePiece.cs
index bfcf268c3d..ed69b529ed 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/LegacyCirclePiece.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/LegacyCirclePiece.cs
@@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning
 
         private void updateAccentColour()
         {
-            backgroundLayer.Colour = accentColour;
+            backgroundLayer.Colour = accentColour.ToLegacyColour();
         }
     }
 }
diff --git a/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs b/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs
index 8223e3bc01..6bb8f9433e 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs
@@ -76,9 +76,9 @@ namespace osu.Game.Rulesets.Taiko.Skinning
 
         private void updateAccentColour()
         {
-            headCircle.AccentColour = accentColour;
-            body.Colour = accentColour;
-            end.Colour = accentColour;
+            headCircle.AccentColour = accentColour.ToLegacyColour();
+            body.Colour = accentColour.ToLegacyColour();
+            end.Colour = accentColour.ToLegacyColour();
         }
     }
 }
diff --git a/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs b/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs
index 656728f6e4..f36aae205a 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs
@@ -2,6 +2,7 @@
 // See the LICENCE file in the repository root for full licence text.
 
 using osu.Framework.Allocation;
+using osu.Game.Skinning;
 using osuTK.Graphics;
 
 namespace osu.Game.Rulesets.Taiko.Skinning
@@ -18,9 +19,9 @@ namespace osu.Game.Rulesets.Taiko.Skinning
         [BackgroundDependencyLoader]
         private void load()
         {
-            AccentColour = component == TaikoSkinComponents.CentreHit
+            AccentColour = (component == TaikoSkinComponents.CentreHit
                 ? new Color4(235, 69, 44, 255)
-                : new Color4(67, 142, 172, 255);
+                : new Color4(67, 142, 172, 255)).ToLegacyColour();
         }
     }
 }

From f89b6f44653112a86cc5df93be0d6e11ad0ad8d3 Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Sat, 22 Aug 2020 00:52:53 +0900
Subject: [PATCH 07/12] Add xmldocs

---
 osu.Game/Skinning/LegacySkinExtensions.cs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/osu.Game/Skinning/LegacySkinExtensions.cs b/osu.Game/Skinning/LegacySkinExtensions.cs
index 088eae4bce..ee7d74d7ec 100644
--- a/osu.Game/Skinning/LegacySkinExtensions.cs
+++ b/osu.Game/Skinning/LegacySkinExtensions.cs
@@ -63,6 +63,11 @@ namespace osu.Game.Skinning
             }
         }
 
+        /// <summary>
+        /// The resultant colour after setting a post-constructor colour in osu!stable.
+        /// </summary>
+        /// <param name="colour">The <see cref="Color4"/> to convert.</param>
+        /// <returns>The converted <see cref="Color4"/>.</returns>
         public static Color4 ToLegacyColour(this Color4 colour)
         {
             if (colour.A == 0)
@@ -70,6 +75,16 @@ namespace osu.Game.Skinning
             return colour;
         }
 
+        /// <summary>
+        /// Equivalent of setting a colour in the constructor in osu!stable.
+        /// Doubles the alpha channel into <see cref="Drawable.Alpha"/> and uses <see cref="ToLegacyColour"/> to set <see cref="Drawable.Colour"/>.
+        /// </summary>
+        /// <remarks>
+        /// Beware: Any existing value in <see cref="Drawable.Alpha"/> is overwritten.
+        /// </remarks>
+        /// <param name="drawable">The <see cref="Drawable"/> to set the "InitialColour" of.</param>
+        /// <param name="colour">The <see cref="Color4"/> to set.</param>
+        /// <returns>The given <see cref="Drawable"/>.</returns>
         public static T WithInitialColour<T>(this T drawable, Color4 colour)
             where T : Drawable
         {

From 356c67f00d778e1f6d2535eb534a864d6b04caa4 Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Sat, 22 Aug 2020 00:55:03 +0900
Subject: [PATCH 08/12] Remove outdated/wrong test

---
 osu.Game.Tests/Resources/skin-zero-alpha-colour.ini |  5 -----
 osu.Game.Tests/Skins/LegacySkinDecoderTest.cs       | 10 ----------
 2 files changed, 15 deletions(-)
 delete mode 100644 osu.Game.Tests/Resources/skin-zero-alpha-colour.ini

diff --git a/osu.Game.Tests/Resources/skin-zero-alpha-colour.ini b/osu.Game.Tests/Resources/skin-zero-alpha-colour.ini
deleted file mode 100644
index 3c0dae6b13..0000000000
--- a/osu.Game.Tests/Resources/skin-zero-alpha-colour.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[General]
-Version: latest
-
-[Colours]
-Combo1: 255,255,255,0
\ No newline at end of file
diff --git a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
index c408d2f182..aedf26ee75 100644
--- a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
+++ b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
@@ -108,15 +108,5 @@ namespace osu.Game.Tests.Skins
             using (var stream = new LineBufferedReader(resStream))
                 Assert.That(decoder.Decode(stream).LegacyVersion, Is.EqualTo(1.0m));
         }
-
-        [Test]
-        public void TestDecodeColourWithZeroAlpha()
-        {
-            var decoder = new LegacySkinDecoder();
-
-            using (var resStream = TestResources.OpenResource("skin-zero-alpha-colour.ini"))
-            using (var stream = new LineBufferedReader(resStream))
-                Assert.That(decoder.Decode(stream).ComboColours[0].A, Is.EqualTo(1.0f));
-        }
     }
 }

From 08078b9513895806f9df2a08922fc7c4bf826fd9 Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Sat, 22 Aug 2020 00:56:29 +0900
Subject: [PATCH 09/12] Rename method to remove "InitialColour" namings

---
 osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs | 6 +++---
 osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs         | 2 +-
 osu.Game/Skinning/LegacySkinExtensions.cs                  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs b/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs
index b97547bbc6..54a16b840f 100644
--- a/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs
@@ -58,14 +58,14 @@ namespace osu.Game.Rulesets.Mania.Skinning
 
             InternalChildren = new Drawable[]
             {
-                new Box { RelativeSizeAxes = Axes.Both }.WithInitialColour(backgroundColour),
+                new Box { RelativeSizeAxes = Axes.Both }.WithLegacyColour(backgroundColour),
                 new Container
                 {
                     RelativeSizeAxes = Axes.Y,
                     Width = leftLineWidth,
                     Scale = new Vector2(0.740f, 1),
                     Alpha = hasLeftLine ? 1 : 0,
-                    Child = new Box { RelativeSizeAxes = Axes.Both }.WithInitialColour(lineColour)
+                    Child = new Box { RelativeSizeAxes = Axes.Both }.WithLegacyColour(lineColour)
                 },
                 new Container
                 {
@@ -75,7 +75,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
                     Width = rightLineWidth,
                     Scale = new Vector2(0.740f, 1),
                     Alpha = hasRightLine ? 1 : 0,
-                    Child = new Box { RelativeSizeAxes = Axes.Both }.WithInitialColour(lineColour)
+                    Child = new Box { RelativeSizeAxes = Axes.Both }.WithLegacyColour(lineColour)
                 },
                 lightContainer = new Container
                 {
diff --git a/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs b/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
index 3b75fcc8a0..27dec1b691 100644
--- a/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
@@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
                     Texture = skin.GetTexture("sliderb-nd"),
                     Colour = new Color4(5, 5, 5, 255),
                 },
-                animationContent.WithInitialColour(ballColour).With(d =>
+                animationContent.WithLegacyColour(ballColour).With(d =>
                 {
                     d.Anchor = Anchor.Centre;
                     d.Origin = Anchor.Centre;
diff --git a/osu.Game/Skinning/LegacySkinExtensions.cs b/osu.Game/Skinning/LegacySkinExtensions.cs
index ee7d74d7ec..7420f82f04 100644
--- a/osu.Game/Skinning/LegacySkinExtensions.cs
+++ b/osu.Game/Skinning/LegacySkinExtensions.cs
@@ -82,10 +82,10 @@ namespace osu.Game.Skinning
         /// <remarks>
         /// Beware: Any existing value in <see cref="Drawable.Alpha"/> is overwritten.
         /// </remarks>
-        /// <param name="drawable">The <see cref="Drawable"/> to set the "InitialColour" of.</param>
+        /// <param name="drawable">The <see cref="Drawable"/> to set the colour of.</param>
         /// <param name="colour">The <see cref="Color4"/> to set.</param>
         /// <returns>The given <see cref="Drawable"/>.</returns>
-        public static T WithInitialColour<T>(this T drawable, Color4 colour)
+        public static T WithLegacyColour<T>(this T drawable, Color4 colour)
             where T : Drawable
         {
             drawable.Alpha = colour.A;

From ab8d9be095e4925d67cb1c06be49a2e92f24195f Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Tue, 25 Aug 2020 15:16:41 +0900
Subject: [PATCH 10/12] Move out into a separate method

---
 .../Skinning/CatchLegacySkinTransformer.cs    |  2 +-
 .../Skinning/LegacyFruitPiece.cs              |  2 +-
 .../Skinning/LegacyColumnBackground.cs        | 17 +++++--
 .../Skinning/LegacyHitTarget.cs               |  2 +-
 .../Skinning/LegacyMainCirclePiece.cs         |  2 +-
 .../Skinning/LegacySliderBall.cs              |  4 +-
 .../Skinning/LegacyCirclePiece.cs             |  2 +-
 .../Skinning/LegacyDrumRoll.cs                |  6 +--
 osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs |  7 +--
 .../Skinning/LegacyColourCompatibility.cs     | 46 +++++++++++++++++++
 osu.Game/Skinning/LegacySkinExtensions.cs     | 31 -------------
 11 files changed, 73 insertions(+), 48 deletions(-)
 create mode 100644 osu.Game/Skinning/LegacyColourCompatibility.cs

diff --git a/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs b/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs
index 5abd87d6f4..ea2f031d65 100644
--- a/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs
+++ b/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs
@@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Catch.Skinning
                     if (result == null)
                         return null;
 
-                    result.Value = result.Value.ToLegacyColour();
+                    result.Value = LegacyColourCompatibility.DisallowZeroAlpha(result.Value);
                     return (IBindable<TValue>)result;
             }
 
diff --git a/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs b/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs
index c9dd1d1f3e..381d066750 100644
--- a/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs
+++ b/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs
@@ -75,7 +75,7 @@ namespace osu.Game.Rulesets.Catch.Skinning
         {
             base.LoadComplete();
 
-            accentColour.BindValueChanged(colour => colouredSprite.Colour = colour.NewValue.ToLegacyColour(), true);
+            accentColour.BindValueChanged(colour => colouredSprite.Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true);
         }
     }
 }
diff --git a/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs b/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs
index 54a16b840f..da6075248a 100644
--- a/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/LegacyColumnBackground.cs
@@ -58,14 +58,20 @@ namespace osu.Game.Rulesets.Mania.Skinning
 
             InternalChildren = new Drawable[]
             {
-                new Box { RelativeSizeAxes = Axes.Both }.WithLegacyColour(backgroundColour),
+                LegacyColourCompatibility.ApplyWithDoubledAlpha(new Box
+                {
+                    RelativeSizeAxes = Axes.Both
+                }, backgroundColour),
                 new Container
                 {
                     RelativeSizeAxes = Axes.Y,
                     Width = leftLineWidth,
                     Scale = new Vector2(0.740f, 1),
                     Alpha = hasLeftLine ? 1 : 0,
-                    Child = new Box { RelativeSizeAxes = Axes.Both }.WithLegacyColour(lineColour)
+                    Child = LegacyColourCompatibility.ApplyWithDoubledAlpha(new Box
+                    {
+                        RelativeSizeAxes = Axes.Both
+                    }, lineColour)
                 },
                 new Container
                 {
@@ -75,7 +81,10 @@ namespace osu.Game.Rulesets.Mania.Skinning
                     Width = rightLineWidth,
                     Scale = new Vector2(0.740f, 1),
                     Alpha = hasRightLine ? 1 : 0,
-                    Child = new Box { RelativeSizeAxes = Axes.Both }.WithLegacyColour(lineColour)
+                    Child = LegacyColourCompatibility.ApplyWithDoubledAlpha(new Box
+                    {
+                        RelativeSizeAxes = Axes.Both
+                    }, lineColour)
                 },
                 lightContainer = new Container
                 {
@@ -86,7 +95,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
                     {
                         Anchor = Anchor.BottomCentre,
                         Origin = Anchor.BottomCentre,
-                        Colour = lightColour.ToLegacyColour(),
+                        Colour = LegacyColourCompatibility.DisallowZeroAlpha(lightColour),
                         Texture = skin.GetTexture(lightImage),
                         RelativeSizeAxes = Axes.X,
                         Width = 1,
diff --git a/osu.Game.Rulesets.Mania/Skinning/LegacyHitTarget.cs b/osu.Game.Rulesets.Mania/Skinning/LegacyHitTarget.cs
index 2177eaa5e6..48504e6548 100644
--- a/osu.Game.Rulesets.Mania/Skinning/LegacyHitTarget.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/LegacyHitTarget.cs
@@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
                         Anchor = Anchor.CentreLeft,
                         RelativeSizeAxes = Axes.X,
                         Height = 1,
-                        Colour = lineColour.ToLegacyColour(),
+                        Colour = LegacyColourCompatibility.DisallowZeroAlpha(lineColour),
                         Alpha = showJudgementLine ? 0.9f : 0
                     }
                 }
diff --git a/osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs b/osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs
index 8a6beddb51..d15a0a3203 100644
--- a/osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs
@@ -106,7 +106,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
             base.LoadComplete();
 
             state.BindValueChanged(updateState, true);
-            accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue.ToLegacyColour(), true);
+            accentColour.BindValueChanged(colour => hitCircleSprite.Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true);
             indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true);
         }
 
diff --git a/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs b/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
index 27dec1b691..25ab96445a 100644
--- a/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
@@ -39,11 +39,11 @@ namespace osu.Game.Rulesets.Osu.Skinning
                     Texture = skin.GetTexture("sliderb-nd"),
                     Colour = new Color4(5, 5, 5, 255),
                 },
-                animationContent.WithLegacyColour(ballColour).With(d =>
+                LegacyColourCompatibility.ApplyWithDoubledAlpha(animationContent.With(d =>
                 {
                     d.Anchor = Anchor.Centre;
                     d.Origin = Anchor.Centre;
-                }),
+                }), ballColour),
                 layerSpec = new Sprite
                 {
                     Anchor = Anchor.Centre,
diff --git a/osu.Game.Rulesets.Taiko/Skinning/LegacyCirclePiece.cs b/osu.Game.Rulesets.Taiko/Skinning/LegacyCirclePiece.cs
index ed69b529ed..9b73ccd248 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/LegacyCirclePiece.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/LegacyCirclePiece.cs
@@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning
 
         private void updateAccentColour()
         {
-            backgroundLayer.Colour = accentColour.ToLegacyColour();
+            backgroundLayer.Colour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
         }
     }
 }
diff --git a/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs b/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs
index 6bb8f9433e..025eff53d5 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs
@@ -76,9 +76,9 @@ namespace osu.Game.Rulesets.Taiko.Skinning
 
         private void updateAccentColour()
         {
-            headCircle.AccentColour = accentColour.ToLegacyColour();
-            body.Colour = accentColour.ToLegacyColour();
-            end.Colour = accentColour.ToLegacyColour();
+            headCircle.AccentColour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
+            body.Colour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
+            end.Colour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
         }
     }
 }
diff --git a/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs b/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs
index f36aae205a..b11b64c22c 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs
@@ -19,9 +19,10 @@ namespace osu.Game.Rulesets.Taiko.Skinning
         [BackgroundDependencyLoader]
         private void load()
         {
-            AccentColour = (component == TaikoSkinComponents.CentreHit
-                ? new Color4(235, 69, 44, 255)
-                : new Color4(67, 142, 172, 255)).ToLegacyColour();
+            AccentColour = LegacyColourCompatibility.DisallowZeroAlpha(
+                component == TaikoSkinComponents.CentreHit
+                    ? new Color4(235, 69, 44, 255)
+                    : new Color4(67, 142, 172, 255));
         }
     }
 }
diff --git a/osu.Game/Skinning/LegacyColourCompatibility.cs b/osu.Game/Skinning/LegacyColourCompatibility.cs
new file mode 100644
index 0000000000..b842b50426
--- /dev/null
+++ b/osu.Game/Skinning/LegacyColourCompatibility.cs
@@ -0,0 +1,46 @@
+// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osuTK.Graphics;
+
+namespace osu.Game.Skinning
+{
+    /// <summary>
+    /// Compatibility methods to convert osu!stable colours to osu!lazer-compatible ones. Should be used for legacy skins only.
+    /// </summary>
+    public static class LegacyColourCompatibility
+    {
+        /// <summary>
+        /// Forces an alpha of 1 if a given <see cref="Color4"/> is fully transparent.
+        /// </summary>
+        /// <remarks>
+        /// This is equivalent to setting colour post-constructor in osu!stable.
+        /// </remarks>
+        /// <param name="colour">The <see cref="Color4"/> to disallow zero alpha on.</param>
+        /// <returns>The resultant <see cref="Color4"/>.</returns>
+        public static Color4 DisallowZeroAlpha(Color4 colour)
+        {
+            if (colour.A == 0)
+                colour.A = 1;
+            return colour;
+        }
+
+        /// <summary>
+        /// Applies a <see cref="Color4"/> to a <see cref="Drawable"/>, doubling the alpha value into the <see cref="Drawable.Alpha"/> property.
+        /// </summary>
+        /// <remarks>
+        /// This is equivalent to setting colour in the constructor in osu!stable.
+        /// </remarks>
+        /// <param name="drawable">The <see cref="Drawable"/> to apply the colour to.</param>
+        /// <param name="colour">The <see cref="Color4"/> to apply.</param>
+        /// <returns>The given <paramref name="drawable"/>.</returns>
+        public static T ApplyWithDoubledAlpha<T>(T drawable, Color4 colour)
+            where T : Drawable
+        {
+            drawable.Alpha = colour.A;
+            drawable.Colour = DisallowZeroAlpha(colour);
+            return drawable;
+        }
+    }
+}
diff --git a/osu.Game/Skinning/LegacySkinExtensions.cs b/osu.Game/Skinning/LegacySkinExtensions.cs
index 7420f82f04..bb46dc8b9f 100644
--- a/osu.Game/Skinning/LegacySkinExtensions.cs
+++ b/osu.Game/Skinning/LegacySkinExtensions.cs
@@ -9,7 +9,6 @@ using osu.Framework.Graphics.Animations;
 using osu.Framework.Graphics.OpenGL.Textures;
 using osu.Framework.Graphics.Sprites;
 using osu.Framework.Graphics.Textures;
-using osuTK.Graphics;
 using static osu.Game.Skinning.LegacySkinConfiguration;
 
 namespace osu.Game.Skinning
@@ -63,36 +62,6 @@ namespace osu.Game.Skinning
             }
         }
 
-        /// <summary>
-        /// The resultant colour after setting a post-constructor colour in osu!stable.
-        /// </summary>
-        /// <param name="colour">The <see cref="Color4"/> to convert.</param>
-        /// <returns>The converted <see cref="Color4"/>.</returns>
-        public static Color4 ToLegacyColour(this Color4 colour)
-        {
-            if (colour.A == 0)
-                colour.A = 1;
-            return colour;
-        }
-
-        /// <summary>
-        /// Equivalent of setting a colour in the constructor in osu!stable.
-        /// Doubles the alpha channel into <see cref="Drawable.Alpha"/> and uses <see cref="ToLegacyColour"/> to set <see cref="Drawable.Colour"/>.
-        /// </summary>
-        /// <remarks>
-        /// Beware: Any existing value in <see cref="Drawable.Alpha"/> is overwritten.
-        /// </remarks>
-        /// <param name="drawable">The <see cref="Drawable"/> to set the colour of.</param>
-        /// <param name="colour">The <see cref="Color4"/> to set.</param>
-        /// <returns>The given <see cref="Drawable"/>.</returns>
-        public static T WithLegacyColour<T>(this T drawable, Color4 colour)
-            where T : Drawable
-        {
-            drawable.Alpha = colour.A;
-            drawable.Colour = ToLegacyColour(colour);
-            return drawable;
-        }
-
         public class SkinnableTextureAnimation : TextureAnimation
         {
             [Resolved(canBeNull: true)]

From c09cef4fca2d5264d96958cc388534012aa7ede0 Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Tue, 25 Aug 2020 19:39:03 +0900
Subject: [PATCH 11/12] Apply post-merge fixes to LegacyStageBackground

---
 .../Skinning/LegacyStageBackground.cs         | 29 ++++++++++---------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/osu.Game.Rulesets.Mania/Skinning/LegacyStageBackground.cs b/osu.Game.Rulesets.Mania/Skinning/LegacyStageBackground.cs
index 19ec86b1ed..16a6123724 100644
--- a/osu.Game.Rulesets.Mania/Skinning/LegacyStageBackground.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/LegacyStageBackground.cs
@@ -108,37 +108,38 @@ namespace osu.Game.Rulesets.Mania.Skinning
 
                 InternalChildren = new Drawable[]
                 {
-                    new Container
+                    LegacyColourCompatibility.ApplyWithDoubledAlpha(new Box
                     {
-                        RelativeSizeAxes = Axes.Both,
-                        Child = new Box
-                        {
-                            RelativeSizeAxes = Axes.Both,
-                            Colour = backgroundColour
-                        },
-                    },
+                        RelativeSizeAxes = Axes.Both
+                    }, backgroundColour),
                     new HitTargetInsetContainer
                     {
                         RelativeSizeAxes = Axes.Both,
                         Children = new[]
                         {
-                            new Box
+                            new Container
                             {
                                 RelativeSizeAxes = Axes.Y,
                                 Width = leftLineWidth,
                                 Scale = new Vector2(0.740f, 1),
-                                Colour = lineColour,
-                                Alpha = hasLeftLine ? 1 : 0
+                                Alpha = hasLeftLine ? 1 : 0,
+                                Child = LegacyColourCompatibility.ApplyWithDoubledAlpha(new Box
+                                {
+                                    RelativeSizeAxes = Axes.Both
+                                }, lineColour)
                             },
-                            new Box
+                            new Container
                             {
                                 Anchor = Anchor.TopRight,
                                 Origin = Anchor.TopRight,
                                 RelativeSizeAxes = Axes.Y,
                                 Width = rightLineWidth,
                                 Scale = new Vector2(0.740f, 1),
-                                Colour = lineColour,
-                                Alpha = hasRightLine ? 1 : 0
+                                Alpha = hasRightLine ? 1 : 0,
+                                Child = LegacyColourCompatibility.ApplyWithDoubledAlpha(new Box
+                                {
+                                    RelativeSizeAxes = Axes.Both
+                                }, lineColour)
                             },
                         }
                     }

From 2cf2ba8fc5cb0e1648756774d99e81b1f045c70b Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Wed, 26 Aug 2020 14:24:04 +0900
Subject: [PATCH 12/12] Store computed accent colour to local

---
 osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs b/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs
index 025eff53d5..5ab8e3a8c8 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/LegacyDrumRoll.cs
@@ -76,9 +76,11 @@ namespace osu.Game.Rulesets.Taiko.Skinning
 
         private void updateAccentColour()
         {
-            headCircle.AccentColour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
-            body.Colour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
-            end.Colour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
+            var colour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
+
+            headCircle.AccentColour = colour;
+            body.Colour = colour;
+            end.Colour = colour;
         }
     }
 }