mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
document colors
This commit is contained in:
1 parent
54717c495f
commit
feb73d6b07
3 files changed
+40
-8
No files matched your search
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
Reference in new issue
Block a user