Fix chat theme and errors

This commit is contained in:
D1GQ committed 2024-10-26 16:54:37 -05:00
1 parent 5330d9535c
commit daad9e0e6d
1 file changed
+6 -3
+6 -3
View File
@@ -105,7 +105,8 @@ class ChatPatch
[HarmonyPostfix]
public static void AddChat_Postfix(ChatController __instance, [HarmonyArgument(0)] PlayerControl sourcePlayer, [HarmonyArgument(1)] string chatText)
{
ChatBubble chatBubble = SetChatPoolTheme();
ChatBubble? chatBubble = SetChatPoolTheme();
if (chatBubble == null) return;
StringBuilder sbTag = new StringBuilder();
StringBuilder sbInfo = new StringBuilder();
@@ -178,7 +179,7 @@ class ChatPatch
chatBubble.NameText.text = playerName;
chatBubble.ColorBlindName.color = Palette.PlayerColors[sourcePlayer.Data.DefaultOutfit.ColorId];
if (sourcePlayer.IsAlive())
if (sourcePlayer.IsAlive() || !PlayerControl.LocalPlayer.IsAlive())
{
Logger.Log($"{sourcePlayer.Data.PlayerName} -> {chatText}", "ChatLog");
}
@@ -234,7 +235,7 @@ class ChatPatch
}
// Set chat theme
public static ChatBubble SetChatPoolTheme(ChatBubble? asChatBubble = null)
public static ChatBubble? SetChatPoolTheme(ChatBubble? asChatBubble = null)
{
ChatBubble Get() => HudManager.Instance.Chat.chatBubblePool.activeChildren.ToArray()
.Select(c => c.GetComponent<ChatBubble>())
@@ -242,6 +243,8 @@ class ChatPatch
ChatBubble chatBubble = asChatBubble ??= Get();
if (chatBubble == null) return chatBubble;
if (Main.ChatDarkMode.Value)
{
chatBubble.transform.Find("ChatText (TMP)").GetComponent<TextMeshPro>().color = new Color(1f, 1f, 1f, 1f);