From 32dd4edc084562e5d6c0215bd6b0f4f91c4571dc Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Tue, 3 Nov 2026 00:34:29 -0500 Subject: [PATCH 1/5] remove translation id boilerplate --- MiraAPI.Example/ExampleColors.cs | 16 +- MiraAPI/Colors/CustomColor.cs | 155 +++++++++++---- MiraAPI/Colors/PaletteManager.cs | 2 + .../Colors/RegisterCustomColorsAttribute.cs | 16 +- MiraAPI/Colors/VariableColor.cs | 182 ++++++++++++++++-- MiraAPI/PluginLoading/MiraPluginManager.cs | 9 +- 6 files changed, 309 insertions(+), 71 deletions(-) diff --git a/MiraAPI.Example/ExampleColors.cs b/MiraAPI.Example/ExampleColors.cs index 297a370e..0b9c4b6e 100644 --- a/MiraAPI.Example/ExampleColors.cs +++ b/MiraAPI.Example/ExampleColors.cs @@ -5,20 +5,14 @@ using UnityEngine; namespace MiraAPI.Example; -[RegisterCustomColors] +[RegisterCustomColors("color.")] public static class ExampleColors { - public static CustomColor Cerulean { get; } = new("color.cerulean", new Color(0.0f, 0.48f, 0.65f)) - { - ColorBrightness = CustomColorBrightness.Lighter, - }; + public static CustomColor Cerulean { get; } = new("cerulean", new Color(0.0f, 0.48f, 0.65f), CustomColorBrightness.Lighter); - public static CustomColor Rose { get; } = new("color.rose", new Color(0.98f, 0.26f, 0.62f)); + public static CustomColor Rose { get; } = new("rose", new Color(0.98f, 0.26f, 0.62f)); - public static CustomColor Gold { get; } = new("color.gold", new Color(1.0f, 0.84f, 0.0f)); + public static CustomColor Gold { get; } = new("gold", new Color(1.0f, 0.84f, 0.0f)); - public static VariableColor Rainbow { get; } = new("color.rainbow", t => new HsbColor(MathUtilities.PingPong(t, 1f, 0.3f), 1f, 1f)) - { - ColorBrightness = CustomColorBrightness.Lighter, - }; + public static VariableColor Rainbow { get; } = new("rainbow", t => new HsbColor(MathUtilities.PingPong(t, 1f, 0.3f), 1f, 1f), CustomColorBrightness.Lighter); } diff --git a/MiraAPI/Colors/CustomColor.cs b/MiraAPI/Colors/CustomColor.cs index f3c38395..836c1fec 100644 --- a/MiraAPI/Colors/CustomColor.cs +++ b/MiraAPI/Colors/CustomColor.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +using System; +using System.Diagnostics.CodeAnalysis; using MiraAPI.Translation; using MiraAPI.Utilities; using UnityEngine; @@ -8,45 +9,41 @@ namespace MiraAPI.Colors; /// /// Represents a custom color with a main color and a shadow color. /// -/// The name of the option. +/// The name of the option as a value. +/// The name of the option as a value. /// The main color. /// The shadow color. +/// The brightness type of the color. [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Internal code.")] -[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1513:Closing brace should be followed by blank line", Justification = "Looks weird.")] -public class CustomColor(StringNames name, Color32 mainColor, Color32 shadowColor) +public class CustomColor(StringNames? nameId, string? rawId, Color32 mainColor, Color32 shadowColor, CustomColorBrightness brightness) { - /// - /// Gets or sets the main color. - /// - public Color32 MainColor - { - get; - set - { - field = value; - InternalMainColor = value; - } - } - = mainColor; + private StringNames? name = nameId; + private CustomColorBrightness colorBrightness = brightness; /// - /// Gets or sets the shadow color. + /// Gets the main color. /// - public Color32 ShadowColor - { - get; - set - { - field = value; - InternalShadowColor = value; - } - } - = shadowColor; + public Color32 MainColor { get; } = mainColor; /// - /// Gets or sets the name of the color. + /// Gets the shadow color. /// - public StringNames Name { get; set; } = name; + public Color32 ShadowColor { get; } = shadowColor; + + /// + /// Gets the name of the color. + /// + public StringNames Name + { + get + { + if (!name.HasValue && !string.IsNullOrEmpty(RawId)) + name = MiraLocaleManager.GetOrCreateLocaleString(RawId); + + return name.GetValueOrDefault(); + } + internal set => name = value; + } /// /// Gets the id of the color. @@ -54,28 +51,104 @@ public class CustomColor(StringNames name, Color32 mainColor, Color32 shadowColo public int ColorId { get; internal set; } = -1; /// - /// Gets or sets whether the color is lighter or darker. Can be used to help with colorblind stuff. + /// Gets or sets whether the color is lighter or darker. /// - public CustomColorBrightness ColorBrightness { get; set; } = CustomColorBrightness.Darker; + public CustomColorBrightness ColorBrightness + { + get => colorBrightness; + [Obsolete("Use the constructor to set ColorBrightness instead. This will be removed in a future version.")] + set => colorBrightness = value; + } + internal string? RawId = rawId; internal Color InternalMainColor = mainColor; internal Color InternalShadowColor = shadowColor; - /// - public CustomColor(StringNames name, Color32 mainColor) - : this(name, mainColor, mainColor.DarkenAbsolute(60)) + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The main color. + /// The shadow color. + /// The brightness type of the color. + public CustomColor(StringNames nameId, Color32 mainColor, Color32 shadowColor, CustomColorBrightness brightness) + : this(nameId, null, mainColor, shadowColor, brightness) { } - /// - public CustomColor(string name, Color32 mainColor) - : this(name, mainColor, mainColor.DarkenAbsolute(60)) + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The main color. + /// The brightness type of the color. + public CustomColor(StringNames nameId, Color32 mainColor, CustomColorBrightness brightness) + : this(nameId, null, mainColor, mainColor.DarkenAbsolute(60), brightness) { } - /// - public CustomColor(string name, Color32 mainColor, Color32 shadowColor) - : this(MiraLocaleManager.GetOrCreateLocaleString(name), mainColor, shadowColor) + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The main color. + /// The shadow color. + /// The brightness type of the color. + public CustomColor(string rawId, Color32 mainColor, Color32 shadowColor, CustomColorBrightness brightness) + : this(null, rawId, mainColor, shadowColor, brightness) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The main color. + /// The brightness type of the color. + public CustomColor(string rawId, Color32 mainColor, CustomColorBrightness brightness) + : this(null, rawId, mainColor, mainColor.DarkenAbsolute(60), brightness) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The main color. + /// The shadow color. + public CustomColor(StringNames nameId, Color32 mainColor, Color32 shadowColor) + : this(nameId, null, mainColor, shadowColor, CustomColorBrightness.Darker) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The main color. + public CustomColor(StringNames nameId, Color32 mainColor) + : this(nameId, null, mainColor, mainColor.DarkenAbsolute(60), CustomColorBrightness.Darker) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The main color. + /// The shadow color. + public CustomColor(string rawId, Color32 mainColor, Color32 shadowColor) + : this(null, rawId, mainColor, shadowColor, CustomColorBrightness.Darker) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The main color. + public CustomColor(string rawId, Color32 mainColor) + : this(null, rawId, mainColor, mainColor.DarkenAbsolute(60), CustomColorBrightness.Darker) { } } diff --git a/MiraAPI/Colors/PaletteManager.cs b/MiraAPI/Colors/PaletteManager.cs index 760822fc..b05c30fd 100644 --- a/MiraAPI/Colors/PaletteManager.cs +++ b/MiraAPI/Colors/PaletteManager.cs @@ -50,7 +50,9 @@ public static class PaletteManager var colors = CustomColors.Select(x => x.MainColor).ToArray(); var shadowColors = CustomColors.Select(x => x.ShadowColor).ToArray(); var stringNames = CustomColors.Select(x => x.Name).ToArray(); + var newColorId = originalLength; + foreach (var color in CustomColors) { color.ColorId = newColorId++; diff --git a/MiraAPI/Colors/RegisterCustomColorsAttribute.cs b/MiraAPI/Colors/RegisterCustomColorsAttribute.cs index 63565829..899957c9 100644 --- a/MiraAPI/Colors/RegisterCustomColorsAttribute.cs +++ b/MiraAPI/Colors/RegisterCustomColorsAttribute.cs @@ -6,4 +6,18 @@ namespace MiraAPI.Colors; /// Used to mark a class for registration. /// [AttributeUsage(AttributeTargets.Class)] -public class RegisterCustomColorsAttribute : Attribute; +public class RegisterCustomColorsAttribute(string idPrefix) : Attribute +{ + /// + /// Gets the translation ID prefix for all of the colors within the container type. + /// + public string IdPrefix { get; } = idPrefix; + + /// + /// Initializes a new instance of the class. + /// + public RegisterCustomColorsAttribute() + : this(string.Empty) + { + } +} diff --git a/MiraAPI/Colors/VariableColor.cs b/MiraAPI/Colors/VariableColor.cs index 84a38358..7c61e1d5 100644 --- a/MiraAPI/Colors/VariableColor.cs +++ b/MiraAPI/Colors/VariableColor.cs @@ -1,6 +1,5 @@ using System; using MiraAPI.LocalSettings; -using MiraAPI.Translation; using MiraAPI.Utilities; using UnityEngine; @@ -9,40 +8,189 @@ namespace MiraAPI.Colors; /// /// Represents a dynamic custom color that changes over time. /// -/// The name of the color. +/// The name of the option as a value. +/// The name of the option as a value. /// The function to evaluate the dynamic main color. /// The function to evaluate the dynamic shadow color. /// The static main color used when dynamic colors are disabled. /// The static shadow color used when dynamic colors are disabled. /// The default time that is used to automatically fill in the static colors when the latter is not provided. -public sealed class VariableColor(StringNames name, Func mainEvaluator, Func? shadowEvaluator, Color32? mainColor = null, Color32? shadowColor = null, float defaultTime = 0f) - : CustomColor(name, mainColor ?? mainEvaluator(defaultTime), shadowColor ?? shadowEvaluator?.Invoke(defaultTime) ?? (mainColor ?? mainEvaluator(defaultTime)).DarkenAbsolute(60)) +/// The brightness type of the color. +public sealed class VariableColor( + StringNames? nameId, + string? rawId, + Func mainEvaluator, + Func? shadowEvaluator, + Color32? mainColor, + Color32? shadowColor, + float defaultTime, + CustomColorBrightness brightness) + : CustomColor( + nameId, + rawId, + mainColor ?? mainEvaluator(defaultTime), + shadowColor ?? shadowEvaluator?.Invoke(defaultTime) ?? (mainColor ?? mainEvaluator(defaultTime)).DarkenAbsolute(60), + brightness) { /// - /// Gets or sets a delegate that takes in a time value and returns the dynamic main color. + /// Gets a delegate that takes in a time value and returns the dynamic main color. /// - public Func MainEvaluator { get; set; } = mainEvaluator; + public Func MainEvaluator { get; } = mainEvaluator; /// - /// Gets or sets a delegate that takes in a time value and returns the dynamic shadow color. + /// Gets a delegate that takes in a time value and returns the dynamic shadow color. /// - public Func ShadowEvaluator { get; set; } = shadowEvaluator ?? (t => mainEvaluator(t).DarkenAbsolute(0.24f)); + public Func ShadowEvaluator { get; } = shadowEvaluator ?? (t => mainEvaluator(t).DarkenAbsolute(0.24f)); - /// - public VariableColor(StringNames name, Func mainEvaluator, Color32? mainColor = null, float defaultTime = 0f) - : this(name, mainEvaluator, null, mainColor, null, defaultTime) + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The function to evaluate the dynamic main color. + /// The function to evaluate the dynamic shadow color. + /// The static main color used when dynamic colors are disabled. + /// The static shadow color used when dynamic colors are disabled. + /// The default time that is used to automatically fill in the static colors when the latter is not provided. + /// The brightness type of the color. + public VariableColor( + StringNames nameId, + Func mainEvaluator, + Func? shadowEvaluator, + CustomColorBrightness brightness, + Color32? mainColor = null, + Color32? shadowColor = null, + float defaultTime = 0f) + : this(nameId, null, mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime, brightness) { } - /// - public VariableColor(string name, Func mainEvaluator, Color32? mainColor = null, float defaultTime = 0f) - : this(name, mainEvaluator, null, mainColor, null, defaultTime) + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The function to evaluate the dynamic main color. + /// The static main color used when dynamic colors are disabled. + /// The default time that is used to automatically fill in the static colors when the latter is not provided. + /// The brightness type of the color. + public VariableColor( + StringNames nameId, + Func mainEvaluator, + CustomColorBrightness brightness, + Color32? mainColor = null, + float defaultTime = 0f) + : this(nameId, null, mainEvaluator, null, mainColor, null, defaultTime, brightness) { } - /// - public VariableColor(string name, Func mainEvaluator, Func? shadowEvaluator, Color32? mainColor = null, Color32? shadowColor = null, float defaultTime = 0f) - : this(MiraLocaleManager.GetOrCreateLocaleString(name), mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime) + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The function to evaluate the dynamic main color. + /// The function to evaluate the dynamic shadow color. + /// The static main color used when dynamic colors are disabled. + /// The static shadow color used when dynamic colors are disabled. + /// The default time that is used to automatically fill in the static colors when the latter is not provided. + /// The brightness type of the color. + public VariableColor( + string rawId, + Func mainEvaluator, + Func? shadowEvaluator, + CustomColorBrightness brightness, + Color32? mainColor = null, + Color32? shadowColor = null, + float defaultTime = 0f) + : this(null, rawId, mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime, brightness) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The function to evaluate the dynamic main color. + /// The static main color used when dynamic colors are disabled. + /// The default time that is used to automatically fill in the static colors when the latter is not provided. + /// The brightness type of the color. + public VariableColor( + string rawId, + Func mainEvaluator, + CustomColorBrightness brightness, + Color32? mainColor = null, + float defaultTime = 0f) + : this(null, rawId, mainEvaluator, null, mainColor, null, defaultTime, brightness) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The function to evaluate the dynamic main color. + /// The function to evaluate the dynamic shadow color. + /// The static main color used when dynamic colors are disabled. + /// The static shadow color used when dynamic colors are disabled. + /// The default time that is used to automatically fill in the static colors when the latter is not provided. + public VariableColor( + StringNames nameId, + Func mainEvaluator, + Func? shadowEvaluator, + Color32? mainColor = null, + Color32? shadowColor = null, + float defaultTime = 0f) + : this(nameId, null, mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime, CustomColorBrightness.Darker) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The function to evaluate the dynamic main color. + /// The static main color used when dynamic colors are disabled. + /// The default time that is used to automatically fill in the static colors when the latter is not provided. + public VariableColor( + StringNames nameId, + Func mainEvaluator, + Color32? mainColor = null, + float defaultTime = 0f) + : this(nameId, null, mainEvaluator, null, mainColor, null, defaultTime, CustomColorBrightness.Darker) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The function to evaluate the dynamic main color. + /// The function to evaluate the dynamic shadow color. + /// The static main color used when dynamic colors are disabled. + /// The static shadow color used when dynamic colors are disabled. + /// The default time that is used to automatically fill in the static colors when the latter is not provided. + public VariableColor( + string rawId, + Func mainEvaluator, + Func? shadowEvaluator, + Color32? mainColor = null, + Color32? shadowColor = null, + float defaultTime = 0f) + : this(null, rawId, mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime, CustomColorBrightness.Darker) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name of the option as a value. + /// The function to evaluate the dynamic main color. + /// The static main color used when dynamic colors are disabled. + /// The default time that is used to automatically fill in the static colors when the latter is not provided. + public VariableColor( + string rawId, + Func mainEvaluator, + Color32? mainColor = null, + float defaultTime = 0f) + : this(null, rawId, mainEvaluator, null, mainColor, null, defaultTime, CustomColorBrightness.Darker) { } diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index 3214b099..9d4b47dd 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -305,7 +305,9 @@ public sealed class MiraPluginManager { try { - if (type.GetCustomAttribute() == null) + var attribute = type.GetCustomAttribute(); + + if (attribute == null) { return; } @@ -329,6 +331,11 @@ public sealed class MiraPluginManager continue; } + if (!string.IsNullOrEmpty(color.RawId)) + { + color.Name = MiraLocaleManager.GetOrCreateLocaleString(attribute.IdPrefix + color.RawId); + } + PaletteManager.CustomColors.Add(color); if (color is VariableColor) From f93fcc16e96a18c7b381290c599c9441e3b9a241 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Tue, 3 Nov 2026 09:21:38 -0500 Subject: [PATCH 2/5] deprecate some constructors --- MiraAPI.Example/ExampleColors.cs | 4 ++-- MiraAPI/Colors/CustomColor.cs | 4 ++++ MiraAPI/PluginLoading/MiraPluginManager.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MiraAPI.Example/ExampleColors.cs b/MiraAPI.Example/ExampleColors.cs index 0b9c4b6e..88710683 100644 --- a/MiraAPI.Example/ExampleColors.cs +++ b/MiraAPI.Example/ExampleColors.cs @@ -10,9 +10,9 @@ public static class ExampleColors { public static CustomColor Cerulean { get; } = new("cerulean", new Color(0.0f, 0.48f, 0.65f), CustomColorBrightness.Lighter); - public static CustomColor Rose { get; } = new("rose", new Color(0.98f, 0.26f, 0.62f)); + public static CustomColor Rose { get; } = new("rose", new Color(0.98f, 0.26f, 0.62f), CustomColorBrightness.Lighter); - public static CustomColor Gold { get; } = new("gold", new Color(1.0f, 0.84f, 0.0f)); + public static CustomColor Gold { get; } = new("gold", new Color(1.0f, 0.84f, 0.0f), CustomColorBrightness.Lighter); public static VariableColor Rainbow { get; } = new("rainbow", t => new HsbColor(MathUtilities.PingPong(t, 1f, 0.3f), 1f, 1f), CustomColorBrightness.Lighter); } diff --git a/MiraAPI/Colors/CustomColor.cs b/MiraAPI/Colors/CustomColor.cs index 836c1fec..fa3df61c 100644 --- a/MiraAPI/Colors/CustomColor.cs +++ b/MiraAPI/Colors/CustomColor.cs @@ -116,6 +116,7 @@ public class CustomColor(StringNames? nameId, string? rawId, Color32 mainColor, /// The name of the option as a value. /// The main color. /// The shadow color. + [Obsolete("Use the constructor that takes in a CustomColorBrightness parameter. This will be removed in a future version.")] public CustomColor(StringNames nameId, Color32 mainColor, Color32 shadowColor) : this(nameId, null, mainColor, shadowColor, CustomColorBrightness.Darker) { @@ -126,6 +127,7 @@ public class CustomColor(StringNames? nameId, string? rawId, Color32 mainColor, /// /// The name of the option as a value. /// The main color. + [Obsolete("Use the constructor that takes in a CustomColorBrightness parameter. This will be removed in a future version.")] public CustomColor(StringNames nameId, Color32 mainColor) : this(nameId, null, mainColor, mainColor.DarkenAbsolute(60), CustomColorBrightness.Darker) { @@ -137,6 +139,7 @@ public class CustomColor(StringNames? nameId, string? rawId, Color32 mainColor, /// The name of the option as a value. /// The main color. /// The shadow color. + [Obsolete("Use the constructor that takes in a CustomColorBrightness parameter. This will be removed in a future version.")] public CustomColor(string rawId, Color32 mainColor, Color32 shadowColor) : this(null, rawId, mainColor, shadowColor, CustomColorBrightness.Darker) { @@ -147,6 +150,7 @@ public class CustomColor(StringNames? nameId, string? rawId, Color32 mainColor, /// /// The name of the option as a value. /// The main color. + [Obsolete("Use the constructor that takes in a CustomColorBrightness parameter. This will be removed in a future version.")] public CustomColor(string rawId, Color32 mainColor) : this(null, rawId, mainColor, mainColor.DarkenAbsolute(60), CustomColorBrightness.Darker) { diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index 9d4b47dd..ad12098b 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -331,7 +331,7 @@ public sealed class MiraPluginManager continue; } - if (!string.IsNullOrEmpty(color.RawId)) + if (!string.IsNullOrEmpty(color.RawId) && !string.IsNullOrEmpty(attribute.IdPrefix)) { color.Name = MiraLocaleManager.GetOrCreateLocaleString(attribute.IdPrefix + color.RawId); } From d7abb1dcb844333901dd272fec67410ce4d69859 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Tue, 3 Nov 2026 09:30:31 -0500 Subject: [PATCH 3/5] clear warnings --- MiraAPI/Colors/CustomColor.cs | 5 ++++- MiraAPI/Colors/RegisterCustomColorsAttribute.cs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/MiraAPI/Colors/CustomColor.cs b/MiraAPI/Colors/CustomColor.cs index fa3df61c..6dc3a5fa 100644 --- a/MiraAPI/Colors/CustomColor.cs +++ b/MiraAPI/Colors/CustomColor.cs @@ -42,7 +42,10 @@ public class CustomColor(StringNames? nameId, string? rawId, Color32 mainColor, return name.GetValueOrDefault(); } - internal set => name = value; + internal set + { + name = value; + } } /// diff --git a/MiraAPI/Colors/RegisterCustomColorsAttribute.cs b/MiraAPI/Colors/RegisterCustomColorsAttribute.cs index 899957c9..b7c96206 100644 --- a/MiraAPI/Colors/RegisterCustomColorsAttribute.cs +++ b/MiraAPI/Colors/RegisterCustomColorsAttribute.cs @@ -5,6 +5,7 @@ namespace MiraAPI.Colors; /// /// Used to mark a class for registration. /// +/// The group translation ID prefix to attach to color names before registration. [AttributeUsage(AttributeTargets.Class)] public class RegisterCustomColorsAttribute(string idPrefix) : Attribute { From acfb7fb9b8025e94c51a1ddd0ac27e4292205013 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Wed, 4 Nov 2026 01:44:01 -0500 Subject: [PATCH 4/5] use new extension --- MiraAPI/PluginLoading/MiraPluginManager.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index 78a39267..bed8d283 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -312,9 +312,7 @@ public sealed class MiraPluginManager { try { - var attribute = type.GetCustomAttribute(); - - if (attribute == null) + if (!type.TryGetCustomAttribute(out var attribute)) { return false; } From 61761052833d2a984f3623a4d084d31946b99b4f Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Fri, 6 Nov 2026 17:55:23 -0500 Subject: [PATCH 5/5] leverage inheritdoc --- MiraAPI/Colors/CustomColor.cs | 56 ++++-------------------- MiraAPI/Colors/VariableColor.cs | 76 ++++----------------------------- 2 files changed, 16 insertions(+), 116 deletions(-) diff --git a/MiraAPI/Colors/CustomColor.cs b/MiraAPI/Colors/CustomColor.cs index 6dc3a5fa..d9225e25 100644 --- a/MiraAPI/Colors/CustomColor.cs +++ b/MiraAPI/Colors/CustomColor.cs @@ -67,92 +67,52 @@ public class CustomColor(StringNames? nameId, string? rawId, Color32 mainColor, internal Color InternalMainColor = mainColor; internal Color InternalShadowColor = shadowColor; - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The main color. - /// The shadow color. - /// The brightness type of the color. + /// public CustomColor(StringNames nameId, Color32 mainColor, Color32 shadowColor, CustomColorBrightness brightness) : this(nameId, null, mainColor, shadowColor, brightness) { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The main color. - /// The brightness type of the color. + /// public CustomColor(StringNames nameId, Color32 mainColor, CustomColorBrightness brightness) : this(nameId, null, mainColor, mainColor.DarkenAbsolute(60), brightness) { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The main color. - /// The shadow color. - /// The brightness type of the color. + /// public CustomColor(string rawId, Color32 mainColor, Color32 shadowColor, CustomColorBrightness brightness) : this(null, rawId, mainColor, shadowColor, brightness) { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The main color. - /// The brightness type of the color. + /// public CustomColor(string rawId, Color32 mainColor, CustomColorBrightness brightness) : this(null, rawId, mainColor, mainColor.DarkenAbsolute(60), brightness) { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The main color. - /// The shadow color. + /// [Obsolete("Use the constructor that takes in a CustomColorBrightness parameter. This will be removed in a future version.")] public CustomColor(StringNames nameId, Color32 mainColor, Color32 shadowColor) : this(nameId, null, mainColor, shadowColor, CustomColorBrightness.Darker) { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The main color. + /// [Obsolete("Use the constructor that takes in a CustomColorBrightness parameter. This will be removed in a future version.")] public CustomColor(StringNames nameId, Color32 mainColor) : this(nameId, null, mainColor, mainColor.DarkenAbsolute(60), CustomColorBrightness.Darker) { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The main color. - /// The shadow color. + /// [Obsolete("Use the constructor that takes in a CustomColorBrightness parameter. This will be removed in a future version.")] public CustomColor(string rawId, Color32 mainColor, Color32 shadowColor) : this(null, rawId, mainColor, shadowColor, CustomColorBrightness.Darker) { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The main color. + /// [Obsolete("Use the constructor that takes in a CustomColorBrightness parameter. This will be removed in a future version.")] public CustomColor(string rawId, Color32 mainColor) : this(null, rawId, mainColor, mainColor.DarkenAbsolute(60), CustomColorBrightness.Darker) diff --git a/MiraAPI/Colors/VariableColor.cs b/MiraAPI/Colors/VariableColor.cs index 7c61e1d5..b3ff8ad1 100644 --- a/MiraAPI/Colors/VariableColor.cs +++ b/MiraAPI/Colors/VariableColor.cs @@ -42,16 +42,7 @@ public sealed class VariableColor( /// public Func ShadowEvaluator { get; } = shadowEvaluator ?? (t => mainEvaluator(t).DarkenAbsolute(0.24f)); - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The function to evaluate the dynamic main color. - /// The function to evaluate the dynamic shadow color. - /// The static main color used when dynamic colors are disabled. - /// The static shadow color used when dynamic colors are disabled. - /// The default time that is used to automatically fill in the static colors when the latter is not provided. - /// The brightness type of the color. + /// public VariableColor( StringNames nameId, Func mainEvaluator, @@ -64,14 +55,7 @@ public sealed class VariableColor( { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The function to evaluate the dynamic main color. - /// The static main color used when dynamic colors are disabled. - /// The default time that is used to automatically fill in the static colors when the latter is not provided. - /// The brightness type of the color. + /// public VariableColor( StringNames nameId, Func mainEvaluator, @@ -82,16 +66,7 @@ public sealed class VariableColor( { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The function to evaluate the dynamic main color. - /// The function to evaluate the dynamic shadow color. - /// The static main color used when dynamic colors are disabled. - /// The static shadow color used when dynamic colors are disabled. - /// The default time that is used to automatically fill in the static colors when the latter is not provided. - /// The brightness type of the color. + /// public VariableColor( string rawId, Func mainEvaluator, @@ -104,14 +79,7 @@ public sealed class VariableColor( { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The function to evaluate the dynamic main color. - /// The static main color used when dynamic colors are disabled. - /// The default time that is used to automatically fill in the static colors when the latter is not provided. - /// The brightness type of the color. + /// public VariableColor( string rawId, Func mainEvaluator, @@ -122,15 +90,7 @@ public sealed class VariableColor( { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The function to evaluate the dynamic main color. - /// The function to evaluate the dynamic shadow color. - /// The static main color used when dynamic colors are disabled. - /// The static shadow color used when dynamic colors are disabled. - /// The default time that is used to automatically fill in the static colors when the latter is not provided. + /// public VariableColor( StringNames nameId, Func mainEvaluator, @@ -142,13 +102,7 @@ public sealed class VariableColor( { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The function to evaluate the dynamic main color. - /// The static main color used when dynamic colors are disabled. - /// The default time that is used to automatically fill in the static colors when the latter is not provided. + /// public VariableColor( StringNames nameId, Func mainEvaluator, @@ -158,15 +112,7 @@ public sealed class VariableColor( { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The function to evaluate the dynamic main color. - /// The function to evaluate the dynamic shadow color. - /// The static main color used when dynamic colors are disabled. - /// The static shadow color used when dynamic colors are disabled. - /// The default time that is used to automatically fill in the static colors when the latter is not provided. + /// public VariableColor( string rawId, Func mainEvaluator, @@ -178,13 +124,7 @@ public sealed class VariableColor( { } - /// - /// Initializes a new instance of the class. - /// - /// The name of the option as a value. - /// The function to evaluate the dynamic main color. - /// The static main color used when dynamic colors are disabled. - /// The default time that is used to automatically fill in the static colors when the latter is not provided. + /// public VariableColor( string rawId, Func mainEvaluator,