Esempio n. 1
0
        private static bool Prefix(ref Chat __instance, ref string user, ref string text, ref Talker.Type type)
        {
            // Pings should not add a message to the chat.
            if (type == Talker.Type.Ping)
            {
                return(false);
            }

            __instance.AddString(VChatPlugin.GetFormattedMessage(new CombinedMessageType(type), user, text));
            return(false);
        }
Esempio n. 2
0
        private static bool Prefix(Chat __instance, ref string user, ref string text, ref Talker.Type type)
        {
            if (!IsOOC(text))
            {
                return(true);
            }
            text = text.Substring(text.IndexOf(" "));

            var message = $"<color={ColorUtility.ToHtmlStringRGBA(Color.blue)}>[OOC] {user}:{text}</color>";

            __instance.AddString(message);

            return(false);
        }
Esempio n. 3
0
        private static bool Prefix(Chat __instance, ref long senderID, ref Vector3 pos, ref Talker.Type type,
                                   ref string user, ref string text)
        {
            Log.LogInfo($"[Chat] [{Enum.GetName(typeof(Talker.Type), type)}] {user} ({senderID}) {pos}: {text}");

            // Prevent OOC messages from appearing on the player's head.
            if (!IsOOC(text))
            {
                return(true);
            }
            text = text.Replace('<', ' ');
            text = text.Replace('>', ' ');
            __instance.AddString(user, text, type);
            return(false);
        }
Esempio n. 4
0
        private static bool Prefix(ref Chat __instance, GameObject go, long senderID, Vector3 pos, Talker.Type type, string user, string text)
        {
            if (Configuration.Current.Chat.IsEnabled)
            {
                Player Author = Helper.getPlayerBySenderId(senderID);

                // Handle Ping Changes
                if (type == Talker.Type.Ping && Configuration.Current.Chat.pingDistance > 1)
                {
                    text = text.Replace('<', ' ');
                    text = text.Replace('>', ' ');

                    // Restrict the ping display to players only within a certain radius of the creator of the ping
                    if (Vector3.Distance(Author.transform.position, Player.m_localPlayer.transform.position) >= Configuration.Current.Chat.pingDistance)
                    {
                        // exit
                        return(false);
                    }

                    __instance.AddInworldText(go, senderID, pos, type, user, text);
                    return(false);
                }

                // Handle Shout distances and types
                if (type == Talker.Type.Shout && Configuration.Current.Chat.shoutDistance > 1)
                {
                    // Restrict the shout display to players only within a certain radius
                    if (Vector3.Distance(Author.transform.position, Player.m_localPlayer.transform.position) <= Configuration.Current.Chat.shoutDistance)
                    {
                        // rerturn to default behavior
                        return(true);
                    }
                    else
                    {
                        // Only add string to chat window and show no ping
                        if (Configuration.Current.Chat.outOfRangeShoutsDisplayInChatWindow)
                        {
                            __instance.AddString(user, text, Talker.Type.Shout);
                        }
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 5
0
        private static void Postfix(ref Chat __instance)
        {
            var chat = __instance;

            // Listen on value changed, this updated the input field and carrot text color to match the targeted channel.
            __instance.m_input.onValueChanged.AddListener((text) =>
            {
                if (chat.m_input != null)
                {
                    VChatPlugin.UpdateCurrentChatTypeAndColor(chat.m_input, text);
                }
            });

            // Listen when the chat field is closed, this resets the position of the message history (arrow up & down handler)
            __instance.m_input.onEndEdit.AddListener((text) =>
            {
                if (string.IsNullOrEmpty(chat.m_input.text))
                {
                    VChatPlugin.MessageSendHistoryIndex = 0;
                }
            });

            // Enable chat window click-through.
            if (VChatPlugin.Settings.EnableClickThroughChatWindow && __instance.m_chatWindow != null)
            {
                __instance.m_chatWindow.ChangeClickThroughInChildren(VChatPlugin.Settings.EnableClickThroughChatWindow);
            }

            // Set the hide delay.
            __instance.m_hideDelay = VChatPlugin.Settings.ChatHideDelay;

            // Update the input colour since we may not be on local.
            VChatPlugin.UpdateChatInputColor(__instance.m_input, VChatPlugin.LastChatType);

            // Get the latest release of VChat and notify the user when the chat is starting up for the first time.
            var latestReleaseVersion = GithubHelper.GetLatestGithubRelease(VChatPlugin.RepositoryAuthor, VChatPlugin.RepositoryName);

            if (!string.IsNullOrEmpty(latestReleaseVersion))
            {
                List <string> messages = new();
                if (VersionHelper.IsNewerVersion(VChatPlugin.Version, latestReleaseVersion))
                {
                    messages.AddRange(new[] {
                        $"You are running on an older version of {VChatPlugin.Name} ({VChatPlugin.Version}).",
                        $"version {latestReleaseVersion} has been released, see {VChatPlugin.RepositoryUrl}",
                    });
                }
                else
                {
                    messages.Add($"{VChatPlugin.Name} {VChatPlugin.Version} is loaded and up to date.");
                }

                foreach (var msg in messages)
                {
                    __instance.AddString($"[{VChatPlugin.Name}] {msg}");
                }
            }

            // Reset the server plugin status as we may have changed server from a single player world to a dedicated server.
            PlayerPatchOnSpawned.HasSentServerPluginStatusMessage = false;
        }