mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
squash final bugs
This commit is contained in:
3 files changed
+6
-11
No files matched your search
@@ -11,8 +11,8 @@ namespace MiraAPI.Colors;
|
|||||||
/// <param name="name">The name of the option.</param>
|
/// <param name="name">The name of the option.</param>
|
||||||
/// <param name="mainColor">The main color.</param>
|
/// <param name="mainColor">The main color.</param>
|
||||||
/// <param name="shadowColor">The shadow color.</param>
|
/// <param name="shadowColor">The shadow color.</param>
|
||||||
[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1513:Closing brace should be followed by blank line", Justification = "Looks weird.")]
|
|
||||||
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Internal code.")]
|
[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 name, Color32 mainColor, Color32 shadowColor)
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ namespace MiraAPI;
|
|||||||
public sealed class VariableColorBehaviour : MonoBehaviour
|
public sealed class VariableColorBehaviour : MonoBehaviour
|
||||||
{
|
{
|
||||||
private SpriteRenderer rend;
|
private SpriteRenderer rend;
|
||||||
private Material material;
|
|
||||||
private VariableColor? color;
|
private VariableColor? color;
|
||||||
|
|
||||||
private static readonly Color VisorColor = Palette.VisorColor;
|
private static readonly Color VisorColor = Palette.VisorColor;
|
||||||
@@ -35,8 +34,7 @@ public sealed class VariableColorBehaviour : MonoBehaviour
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
rend = GetComponent<SpriteRenderer>();
|
rend = GetComponent<SpriteRenderer>();
|
||||||
material = rend.material;
|
rend.material.SetColor(ShaderID.VisorColor, VisorColor);
|
||||||
material.SetColor(ShaderID.VisorColor, VisorColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@@ -45,6 +43,7 @@ public sealed class VariableColorBehaviour : MonoBehaviour
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var time = Time.time;
|
var time = Time.time;
|
||||||
|
var material = rend.material;
|
||||||
material.SetColor(ShaderID.BodyColor, color.EvaluateMainColor(time));
|
material.SetColor(ShaderID.BodyColor, color.EvaluateMainColor(time));
|
||||||
material.SetColor(ShaderID.BackColor, color.EvaluateShadowColor(time));
|
material.SetColor(ShaderID.BackColor, color.EvaluateShadowColor(time));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,19 +44,15 @@ internal static class PlayerTabPatch
|
|||||||
[HarmonyPatch(typeof(ChatNotification), nameof(ChatNotification.Update))]
|
[HarmonyPatch(typeof(ChatNotification), nameof(ChatNotification.Update))]
|
||||||
internal static class ChatNotifRainbowPatch
|
internal static class ChatNotifRainbowPatch
|
||||||
{
|
{
|
||||||
|
private static readonly Regex RichTags = new(@"<[^>]*>", default, Regex.InfiniteMatchTimeout);
|
||||||
|
|
||||||
public static void Postfix(ChatNotification __instance)
|
public static void Postfix(ChatNotification __instance)
|
||||||
{
|
{
|
||||||
if (!__instance.gameObject.active || !PaletteManager.IsVariable(__instance.player.cosmetics.ColorId))
|
if (!__instance.gameObject.active || !PaletteManager.IsVariable(__instance.player.cosmetics.ColorId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var str = PaletteManager.GetMainColor(__instance.player.cosmetics.ColorId).ToHtmlStringRGBA();
|
var str = PaletteManager.GetMainColor(__instance.player.cosmetics.ColorId).ToHtmlStringRGBA();
|
||||||
__instance.playerNameText.text = "<color=#" + str + ">" + __instance.playerNameText.text.WithoutRichText();
|
__instance.playerNameText.text = "<color=#" + str + ">" + RichTags.Replace(__instance.playerNameText.text, string.Empty);
|
||||||
}
|
|
||||||
|
|
||||||
private static string WithoutRichText(this string text)
|
|
||||||
{
|
|
||||||
var richTagRegex = new Regex(@"<[^>]*>", default, Regex.InfiniteMatchTimeout);
|
|
||||||
return richTagRegex.Replace(text, string.Empty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user