document colors

This commit is contained in:
XtraCube committed 2024-08-29 20:34:06 -04:00
1 parent 54717c495f
commit feb73d6b07
3 files changed
+40 -8

No files matched your search

+22 -1
View File
@@ -3,21 +3,42 @@ using Reactor.Localization.Utilities;
using UnityEngine;
namespace MiraAPI.Colors;
/// <summary>
/// Represents a custom color with a main color and a shadow color.
/// </summary>
/// <param name="name">The name of the option.</param>
/// <param name="mainColor">The main color.</param>
/// <param name="shadowColor">The shadow color.</param>
public sealed class CustomColor(StringNames name, Color32 mainColor, Color32 shadowColor)
{
/// <summary>
/// Gets the main color.
/// </summary>
public Color32 MainColor { get; } = mainColor;
/// <summary>
/// Gets the shadow color.
/// </summary>
public Color32 ShadowColor { get; } = shadowColor;
/// <summary>
/// Gets the name of the color.
/// </summary>
public StringNames Name { get; } = name;
/// <inheritdoc />
public CustomColor(StringNames name, Color32 mainColor) : this(name, mainColor, mainColor.GetShadowColor(60))
{
}
/// <inheritdoc />
public CustomColor(string name, Color32 mainColor) : this(name, mainColor, mainColor.GetShadowColor(60))
{
}
/// <inheritdoc />
public CustomColor(string name, Color32 mainColor, Color32 shadowColor) : this(CustomStringName.CreateAndRegister(name), mainColor, shadowColor)
{
}
}
}
+14 -6
View File
@@ -4,11 +4,19 @@ using HarmonyLib;
namespace MiraAPI.Colors;
internal static class PaletteManager
/// <summary>
/// Used to register and track custom colors.
/// </summary>
public static class PaletteManager
{
public static readonly List<CustomColor> CustomColors = [];
public static void RegisterAllColors()
/// <summary>
/// Gets all registered custom colors.
/// </summary>
public static CustomColor[] RegisteredColors => [.. CustomColors];
internal static readonly List<CustomColor> CustomColors = [];
internal static void RegisterAllColors()
{
var colors = CustomColors.Select(x => x.MainColor);
var shadowColors = CustomColors.Select(x => x.ShadowColor);
@@ -17,5 +25,5 @@ internal static class PaletteManager
Palette.PlayerColors = Palette.PlayerColors.ToArray().AddRangeToArray(colors.ToArray());
Palette.ShadowColors = Palette.ShadowColors.ToArray().AddRangeToArray(shadowColors.ToArray());
Palette.ColorNames = Palette.ColorNames.ToArray().AddRangeToArray(stringNames.ToArray());
}
}
}
}
@@ -2,5 +2,8 @@
namespace MiraAPI.Colors;
/// <summary>
/// Used to mark a class for custom colors registration.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class RegisterCustomColorsAttribute : Attribute;
public class RegisterCustomColorsAttribute : Attribute;