mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 13:17:10 +00:00
remove translation id boilerplate
This commit is contained in:
6 files changed
+309
-71
No files matched your search
@@ -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);
|
||||
}
|
||||
+114
-41
@@ -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;
|
||||
/// <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="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
/// <param name="shadowColor">The shadow color.</param>
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
[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)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the main color.
|
||||
/// </summary>
|
||||
public Color32 MainColor
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
field = value;
|
||||
InternalMainColor = value;
|
||||
}
|
||||
}
|
||||
= mainColor;
|
||||
private StringNames? name = nameId;
|
||||
private CustomColorBrightness colorBrightness = brightness;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the shadow color.
|
||||
/// Gets the main color.
|
||||
/// </summary>
|
||||
public Color32 ShadowColor
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
field = value;
|
||||
InternalShadowColor = value;
|
||||
}
|
||||
}
|
||||
= shadowColor;
|
||||
public Color32 MainColor { get; } = mainColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the color.
|
||||
/// Gets the shadow color.
|
||||
/// </summary>
|
||||
public StringNames Name { get; set; } = name;
|
||||
public Color32 ShadowColor { get; } = shadowColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the color.
|
||||
/// </summary>
|
||||
public StringNames Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!name.HasValue && !string.IsNullOrEmpty(RawId))
|
||||
name = MiraLocaleManager.GetOrCreateLocaleString(RawId);
|
||||
|
||||
return name.GetValueOrDefault();
|
||||
}
|
||||
internal set => name = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
/// <inheritdoc cref="CustomColor"/>
|
||||
public CustomColor(StringNames name, Color32 mainColor)
|
||||
: this(name, mainColor, mainColor.DarkenAbsolute(60))
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CustomColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
/// <param name="shadowColor">The shadow color.</param>
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
public CustomColor(StringNames nameId, Color32 mainColor, Color32 shadowColor, CustomColorBrightness brightness)
|
||||
: this(nameId, null, mainColor, shadowColor, brightness)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="CustomColor"/>
|
||||
public CustomColor(string name, Color32 mainColor)
|
||||
: this(name, mainColor, mainColor.DarkenAbsolute(60))
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CustomColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
public CustomColor(StringNames nameId, Color32 mainColor, CustomColorBrightness brightness)
|
||||
: this(nameId, null, mainColor, mainColor.DarkenAbsolute(60), brightness)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="CustomColor"/>
|
||||
public CustomColor(string name, Color32 mainColor, Color32 shadowColor)
|
||||
: this(MiraLocaleManager.GetOrCreateLocaleString(name), mainColor, shadowColor)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CustomColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
/// <param name="shadowColor">The shadow color.</param>
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
public CustomColor(string rawId, Color32 mainColor, Color32 shadowColor, CustomColorBrightness brightness)
|
||||
: this(null, rawId, mainColor, shadowColor, brightness)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CustomColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
public CustomColor(string rawId, Color32 mainColor, CustomColorBrightness brightness)
|
||||
: this(null, rawId, mainColor, mainColor.DarkenAbsolute(60), brightness)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CustomColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
/// <param name="shadowColor">The shadow color.</param>
|
||||
public CustomColor(StringNames nameId, Color32 mainColor, Color32 shadowColor)
|
||||
: this(nameId, null, mainColor, shadowColor, CustomColorBrightness.Darker)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CustomColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
public CustomColor(StringNames nameId, Color32 mainColor)
|
||||
: this(nameId, null, mainColor, mainColor.DarkenAbsolute(60), CustomColorBrightness.Darker)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CustomColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
/// <param name="shadowColor">The shadow color.</param>
|
||||
public CustomColor(string rawId, Color32 mainColor, Color32 shadowColor)
|
||||
: this(null, rawId, mainColor, shadowColor, CustomColorBrightness.Darker)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CustomColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
public CustomColor(string rawId, Color32 mainColor)
|
||||
: this(null, rawId, mainColor, mainColor.DarkenAbsolute(60), CustomColorBrightness.Darker)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -6,4 +6,18 @@ namespace MiraAPI.Colors;
|
||||
/// Used to mark a class for <see cref="CustomColor"/> registration.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class RegisterCustomColorsAttribute : Attribute;
|
||||
public class RegisterCustomColorsAttribute(string idPrefix) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the translation ID prefix for all of the colors within the container type.
|
||||
/// </summary>
|
||||
public string IdPrefix { get; } = idPrefix;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RegisterCustomColorsAttribute"/> class.
|
||||
/// </summary>
|
||||
public RegisterCustomColorsAttribute()
|
||||
: this(string.Empty)
|
||||
{
|
||||
}
|
||||
}
|
||||
+165
-17
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -9,40 +8,189 @@ namespace MiraAPI.Colors;
|
||||
/// <summary>
|
||||
/// Represents a dynamic custom color that changes over time.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the color.</param>
|
||||
/// <param name="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainEvaluator">The function to evaluate the dynamic main color.</param>
|
||||
/// <param name="shadowEvaluator">The function to evaluate the dynamic shadow color.</param>
|
||||
/// <param name="mainColor">The static main color used when dynamic colors are disabled.</param>
|
||||
/// <param name="shadowColor">The static shadow color used when dynamic colors are disabled.</param>
|
||||
/// <param name="defaultTime">The default time that is used to automatically fill in the static colors when the latter is not provided.</param>
|
||||
public sealed class VariableColor(StringNames name, Func<float, Color> mainEvaluator, Func<float, Color>? shadowEvaluator, Color32? mainColor = null, Color32? shadowColor = null, float defaultTime = 0f)
|
||||
: CustomColor(name, mainColor ?? mainEvaluator(defaultTime), shadowColor ?? shadowEvaluator?.Invoke(defaultTime) ?? (mainColor ?? mainEvaluator(defaultTime)).DarkenAbsolute(60))
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
public sealed class VariableColor(
|
||||
StringNames? nameId,
|
||||
string? rawId,
|
||||
Func<float, Color> mainEvaluator,
|
||||
Func<float, Color>? 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)
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public Func<float, Color> MainEvaluator { get; set; } = mainEvaluator;
|
||||
public Func<float, Color> MainEvaluator { get; } = mainEvaluator;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public Func<float, Color> ShadowEvaluator { get; set; } = shadowEvaluator ?? (t => mainEvaluator(t).DarkenAbsolute(0.24f));
|
||||
public Func<float, Color> ShadowEvaluator { get; } = shadowEvaluator ?? (t => mainEvaluator(t).DarkenAbsolute(0.24f));
|
||||
|
||||
/// <inheritdoc cref="VariableColor"/>
|
||||
public VariableColor(StringNames name, Func<float, Color> mainEvaluator, Color32? mainColor = null, float defaultTime = 0f)
|
||||
: this(name, mainEvaluator, null, mainColor, null, defaultTime)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VariableColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="mainEvaluator">The function to evaluate the dynamic main color.</param>
|
||||
/// <param name="shadowEvaluator">The function to evaluate the dynamic shadow color.</param>
|
||||
/// <param name="mainColor">The static main color used when dynamic colors are disabled.</param>
|
||||
/// <param name="shadowColor">The static shadow color used when dynamic colors are disabled.</param>
|
||||
/// <param name="defaultTime">The default time that is used to automatically fill in the static colors when the latter is not provided.</param>
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
public VariableColor(
|
||||
StringNames nameId,
|
||||
Func<float, Color> mainEvaluator,
|
||||
Func<float, Color>? shadowEvaluator,
|
||||
CustomColorBrightness brightness,
|
||||
Color32? mainColor = null,
|
||||
Color32? shadowColor = null,
|
||||
float defaultTime = 0f)
|
||||
: this(nameId, null, mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime, brightness)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="VariableColor"/>
|
||||
public VariableColor(string name, Func<float, Color> mainEvaluator, Color32? mainColor = null, float defaultTime = 0f)
|
||||
: this(name, mainEvaluator, null, mainColor, null, defaultTime)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VariableColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="mainEvaluator">The function to evaluate the dynamic main color.</param>
|
||||
/// <param name="mainColor">The static main color used when dynamic colors are disabled.</param>
|
||||
/// <param name="defaultTime">The default time that is used to automatically fill in the static colors when the latter is not provided.</param>
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
public VariableColor(
|
||||
StringNames nameId,
|
||||
Func<float, Color> mainEvaluator,
|
||||
CustomColorBrightness brightness,
|
||||
Color32? mainColor = null,
|
||||
float defaultTime = 0f)
|
||||
: this(nameId, null, mainEvaluator, null, mainColor, null, defaultTime, brightness)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="VariableColor"/>
|
||||
public VariableColor(string name, Func<float, Color> mainEvaluator, Func<float, Color>? shadowEvaluator, Color32? mainColor = null, Color32? shadowColor = null, float defaultTime = 0f)
|
||||
: this(MiraLocaleManager.GetOrCreateLocaleString(name), mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VariableColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainEvaluator">The function to evaluate the dynamic main color.</param>
|
||||
/// <param name="shadowEvaluator">The function to evaluate the dynamic shadow color.</param>
|
||||
/// <param name="mainColor">The static main color used when dynamic colors are disabled.</param>
|
||||
/// <param name="shadowColor">The static shadow color used when dynamic colors are disabled.</param>
|
||||
/// <param name="defaultTime">The default time that is used to automatically fill in the static colors when the latter is not provided.</param>
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
public VariableColor(
|
||||
string rawId,
|
||||
Func<float, Color> mainEvaluator,
|
||||
Func<float, Color>? shadowEvaluator,
|
||||
CustomColorBrightness brightness,
|
||||
Color32? mainColor = null,
|
||||
Color32? shadowColor = null,
|
||||
float defaultTime = 0f)
|
||||
: this(null, rawId, mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime, brightness)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VariableColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainEvaluator">The function to evaluate the dynamic main color.</param>
|
||||
/// <param name="mainColor">The static main color used when dynamic colors are disabled.</param>
|
||||
/// <param name="defaultTime">The default time that is used to automatically fill in the static colors when the latter is not provided.</param>
|
||||
/// <param name="brightness">The brightness type of the color.</param>
|
||||
public VariableColor(
|
||||
string rawId,
|
||||
Func<float, Color> mainEvaluator,
|
||||
CustomColorBrightness brightness,
|
||||
Color32? mainColor = null,
|
||||
float defaultTime = 0f)
|
||||
: this(null, rawId, mainEvaluator, null, mainColor, null, defaultTime, brightness)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VariableColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="mainEvaluator">The function to evaluate the dynamic main color.</param>
|
||||
/// <param name="shadowEvaluator">The function to evaluate the dynamic shadow color.</param>
|
||||
/// <param name="mainColor">The static main color used when dynamic colors are disabled.</param>
|
||||
/// <param name="shadowColor">The static shadow color used when dynamic colors are disabled.</param>
|
||||
/// <param name="defaultTime">The default time that is used to automatically fill in the static colors when the latter is not provided.</param>
|
||||
public VariableColor(
|
||||
StringNames nameId,
|
||||
Func<float, Color> mainEvaluator,
|
||||
Func<float, Color>? shadowEvaluator,
|
||||
Color32? mainColor = null,
|
||||
Color32? shadowColor = null,
|
||||
float defaultTime = 0f)
|
||||
: this(nameId, null, mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime, CustomColorBrightness.Darker)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VariableColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="nameId">The name of the option as a <see cref="StringNames"/> value.</param>
|
||||
/// <param name="mainEvaluator">The function to evaluate the dynamic main color.</param>
|
||||
/// <param name="mainColor">The static main color used when dynamic colors are disabled.</param>
|
||||
/// <param name="defaultTime">The default time that is used to automatically fill in the static colors when the latter is not provided.</param>
|
||||
public VariableColor(
|
||||
StringNames nameId,
|
||||
Func<float, Color> mainEvaluator,
|
||||
Color32? mainColor = null,
|
||||
float defaultTime = 0f)
|
||||
: this(nameId, null, mainEvaluator, null, mainColor, null, defaultTime, CustomColorBrightness.Darker)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VariableColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainEvaluator">The function to evaluate the dynamic main color.</param>
|
||||
/// <param name="shadowEvaluator">The function to evaluate the dynamic shadow color.</param>
|
||||
/// <param name="mainColor">The static main color used when dynamic colors are disabled.</param>
|
||||
/// <param name="shadowColor">The static shadow color used when dynamic colors are disabled.</param>
|
||||
/// <param name="defaultTime">The default time that is used to automatically fill in the static colors when the latter is not provided.</param>
|
||||
public VariableColor(
|
||||
string rawId,
|
||||
Func<float, Color> mainEvaluator,
|
||||
Func<float, Color>? shadowEvaluator,
|
||||
Color32? mainColor = null,
|
||||
Color32? shadowColor = null,
|
||||
float defaultTime = 0f)
|
||||
: this(null, rawId, mainEvaluator, shadowEvaluator, mainColor, shadowColor, defaultTime, CustomColorBrightness.Darker)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VariableColor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rawId">The name of the option as a <see cref="string"/> value.</param>
|
||||
/// <param name="mainEvaluator">The function to evaluate the dynamic main color.</param>
|
||||
/// <param name="mainColor">The static main color used when dynamic colors are disabled.</param>
|
||||
/// <param name="defaultTime">The default time that is used to automatically fill in the static colors when the latter is not provided.</param>
|
||||
public VariableColor(
|
||||
string rawId,
|
||||
Func<float, Color> mainEvaluator,
|
||||
Color32? mainColor = null,
|
||||
float defaultTime = 0f)
|
||||
: this(null, rawId, mainEvaluator, null, mainColor, null, defaultTime, CustomColorBrightness.Darker)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -305,7 +305,9 @@ public sealed class MiraPluginManager
|
||||
{
|
||||
try
|
||||
{
|
||||
if (type.GetCustomAttribute<RegisterCustomColorsAttribute>() == null)
|
||||
var attribute = type.GetCustomAttribute<RegisterCustomColorsAttribute>();
|
||||
|
||||
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)
|
||||
|
||||
Reference in new issue
Block a user