mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 16:37:26 +08:00
ec71deec51
I am aware there are more throughout the codebase but intentionally left the remaining mentioned for one reason or another. The intention here is to mainly change user-facing versioning to change the positioning of the "lazer" term (to be where we would expect "cuttingedge" or "beta" to be).
47 lines
1.8 KiB
C#
47 lines
1.8 KiB
C#
// 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 apply osu!stable quirks to colours. 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;
|
|
}
|
|
}
|
|
}
|