diff --git a/Patches/ClientOptionsPatch.cs b/Patches/ClientOptionsPatch.cs index cc4f2d4..7f44a19 100644 --- a/Patches/ClientOptionsPatch.cs +++ b/Patches/ClientOptionsPatch.cs @@ -13,6 +13,7 @@ public static class OptionsMenuBehaviourPatch private static ClientOptionItem BetterHost; private static ClientOptionItem BetterRoleAlgorithma; private static ClientOptionItem BetterNotifications; + private static ClientOptionItem ChatInGameplay; private static ClientOptionItem LobbyPlayerInfo; private static ClientOptionItem DisableLobbyTheme; private static ClientOptionItem UnlockFPS; @@ -79,6 +80,11 @@ public static class OptionsMenuBehaviourPatch BetterNotificationManager.Notifying = false; } } + + if (ChatInGameplay == null || ChatInGameplay.ToggleButton == null) + { + ChatInGameplay = ClientOptionItem.Create("Chat In Gameplay", Main.ChatInGameplay, __instance); + } if (LobbyPlayerInfo == null || LobbyPlayerInfo.ToggleButton == null) { diff --git a/Patches/HudManagerPatch.cs b/Patches/HudManagerPatch.cs index f470522..50aea35 100644 --- a/Patches/HudManagerPatch.cs +++ b/Patches/HudManagerPatch.cs @@ -53,8 +53,29 @@ public class HudManagerPatch if (gameStart != null) gameStart.transform.SetLocalY(-2.8f); - if (GameStates.InGame && __instance?.Chat?.gameObject.active != true) - __instance.Chat.gameObject.SetActive(true); + + // Set chat + if (GameStates.InGame) + { + if (!Main.ChatInGameplay.Value) + { + if (!PlayerControl.LocalPlayer.IsAlive()) + { + __instance.Chat.gameObject.SetActive(true); + } + else if (GameStates.IsInGamePlay && !(GameStates.IsMeeting || GameStates.IsExilling)) + { + __instance.Chat.gameObject.SetActive(false); + } + } + else + { + if (__instance?.Chat?.gameObject.active == false) + { + __instance.Chat.gameObject.SetActive(true); + } + } + } } catch { } } diff --git a/main.cs b/main.cs index d9a1642..bbd2247 100644 --- a/main.cs +++ b/main.cs @@ -176,6 +176,7 @@ public class Main : BasePlugin public static ConfigEntry BetterHost { get; private set; } public static ConfigEntry BetterRoleAlgorithma { get; private set; } public static ConfigEntry BetterNotifications { get; private set; } + public static ConfigEntry ChatInGameplay { get; private set; } public static ConfigEntry LobbyPlayerInfo { get; private set; } public static ConfigEntry DisableLobbyTheme { get; private set; } public static ConfigEntry UnlockFPS { get; private set; } @@ -187,6 +188,7 @@ public class Main : BasePlugin BetterHost = Config.Bind("Better Options", "BetterHost", false); BetterRoleAlgorithma = Config.Bind("Better Options", "BetterRoleAlgorithma", true); BetterNotifications = Config.Bind("Better Options", "BetterNotifications", true); + ChatInGameplay = Config.Bind("Better Options", "ChatInGameplay", true); LobbyPlayerInfo = Config.Bind("Better Options", "LobbyPlayerInfo", true); DisableLobbyTheme = Config.Bind("Better Options", "DisableLobbyTheme", true); UnlockFPS = Config.Bind("Better Options", "UnlockFPS", false);