mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
minor improvements
This commit is contained in:
4 files changed
+17
-12
No files matched your search
@@ -42,9 +42,11 @@ public record struct CmykColor(float c, float m, float y, float k, float a = 1f)
|
||||
/// <returns>A Unity <see cref="Color"/> representing the same visual color.</returns>
|
||||
public static Color ToColor(CmykColor cmyk)
|
||||
{
|
||||
var r = (1f - cmyk.c) * (1f - cmyk.k);
|
||||
var g = (1f - cmyk.m) * (1f - cmyk.k);
|
||||
var b = (1f - cmyk.y) * (1f - cmyk.k);
|
||||
var key = 1f - cmyk.k;
|
||||
|
||||
var r = (1f - cmyk.c) * key;
|
||||
var g = (1f - cmyk.m) * key;
|
||||
var b = (1f - cmyk.y) * key;
|
||||
|
||||
return new Color(MathUtilities.Clamp01(r), MathUtilities.Clamp01(g), MathUtilities.Clamp01(b), cmyk.a);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public record struct HslColor(float h, float s, float l, float a = 1f)
|
||||
var l = (max + min) / 2f;
|
||||
var delta = max - min;
|
||||
|
||||
var s = delta == 0f ? 0f : delta / (1f - MathF.Abs(2f * l - 1f));
|
||||
var s = delta == 0f ? 0f : delta / (1f - MathF.Abs((2f * l) - 1f));
|
||||
|
||||
var h = 0f;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace MiraAPI.Colors;
|
||||
/// <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 are not provided.</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)).GetShadowColor(60))
|
||||
{
|
||||
|
||||
@@ -70,23 +70,26 @@ internal static class RainbowLobbyInfoPanePatch
|
||||
[SuppressMessage("Style", "IDE0045:Convert to conditional expression", Justification = "Operator becomes too large.")]
|
||||
public static void Postfix(HostInfoPanel __instance)
|
||||
{
|
||||
if (!__instance.gameObject.activeInHierarchy || !PaletteManager.IsVariable(__instance.player.cosmetics.ColorId))
|
||||
{
|
||||
if (!__instance.gameObject.activeInHierarchy)
|
||||
return;
|
||||
|
||||
var colorId = __instance.player.cosmetics.ColorId;
|
||||
|
||||
if (!PaletteManager.IsVariable(colorId))
|
||||
return;
|
||||
}
|
||||
|
||||
var host = GameData.Instance.GetHost();
|
||||
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
var text = PaletteManager.GetMainColor(__instance.player.cosmetics.ColorId).ToHtmlStringRGBA();
|
||||
__instance.hostLabel.text = TranslationController.Instance.GetString(StringNames.HostNounLabel);
|
||||
var text = PaletteManager.GetMainColor(colorId).ToHtmlStringRGBA();
|
||||
var label = __instance.hostLabel;
|
||||
label.text = TranslationController.Instance.GetString(StringNames.HostNounLabel);
|
||||
|
||||
if (__instance.ShouldBoldenHostLabel(DataManager.Settings.Language.CurrentLanguage))
|
||||
{
|
||||
__instance.hostLabel.text = __instance.hostLabel.text.Insert(0, "<b>");
|
||||
__instance.hostLabel.text = __instance.hostLabel.text.Insert(__instance.hostLabel.text.Length, "</b>");
|
||||
label.text = "<b>" + label.text + "</b>";
|
||||
}
|
||||
|
||||
if (AmongUsClient.Instance.AmHost)
|
||||
|
||||
Reference in new issue
Block a user