From feb73d6b0736ffe4793ec7621b0bf2ed9d8abef2 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:34:06 -0400 Subject: [PATCH] document colors --- MiraAPI/Colors/CustomColor.cs | 23 ++++++++++++++++++- MiraAPI/Colors/PaletteManager.cs | 20 +++++++++++----- .../Colors/RegisterCustomColorsAttribute.cs | 5 +++- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/MiraAPI/Colors/CustomColor.cs b/MiraAPI/Colors/CustomColor.cs index 3e3df97..7bbe87a 100644 --- a/MiraAPI/Colors/CustomColor.cs +++ b/MiraAPI/Colors/CustomColor.cs @@ -3,21 +3,42 @@ using Reactor.Localization.Utilities; using UnityEngine; namespace MiraAPI.Colors; + +/// +/// Represents a custom color with a main color and a shadow color. +/// +/// The name of the option. +/// The main color. +/// The shadow color. public sealed class CustomColor(StringNames name, Color32 mainColor, Color32 shadowColor) { + /// + /// Gets the main color. + /// public Color32 MainColor { get; } = mainColor; + + /// + /// Gets the shadow color. + /// public Color32 ShadowColor { get; } = shadowColor; + + /// + /// Gets the name of the color. + /// public StringNames Name { get; } = name; + /// public CustomColor(StringNames name, Color32 mainColor) : this(name, mainColor, mainColor.GetShadowColor(60)) { } + /// public CustomColor(string name, Color32 mainColor) : this(name, mainColor, mainColor.GetShadowColor(60)) { } + /// public CustomColor(string name, Color32 mainColor, Color32 shadowColor) : this(CustomStringName.CreateAndRegister(name), mainColor, shadowColor) { } -} \ No newline at end of file +} diff --git a/MiraAPI/Colors/PaletteManager.cs b/MiraAPI/Colors/PaletteManager.cs index a94de66..a12cfac 100644 --- a/MiraAPI/Colors/PaletteManager.cs +++ b/MiraAPI/Colors/PaletteManager.cs @@ -4,11 +4,19 @@ using HarmonyLib; namespace MiraAPI.Colors; -internal static class PaletteManager +/// +/// Used to register and track custom colors. +/// +public static class PaletteManager { - public static readonly List CustomColors = []; - - public static void RegisterAllColors() + /// + /// Gets all registered custom colors. + /// + public static CustomColor[] RegisteredColors => [.. CustomColors]; + + internal static readonly List 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()); - } -} \ No newline at end of file + } +} diff --git a/MiraAPI/Colors/RegisterCustomColorsAttribute.cs b/MiraAPI/Colors/RegisterCustomColorsAttribute.cs index 93d99b7..0e9ace7 100644 --- a/MiraAPI/Colors/RegisterCustomColorsAttribute.cs +++ b/MiraAPI/Colors/RegisterCustomColorsAttribute.cs @@ -2,5 +2,8 @@ namespace MiraAPI.Colors; +/// +/// Used to mark a class for custom colors registration. +/// [AttributeUsage(AttributeTargets.Class)] -public class RegisterCustomColorsAttribute : Attribute; \ No newline at end of file +public class RegisterCustomColorsAttribute : Attribute;