Esempio n. 1
0
 private static void SetChat(PLNetworkManager instance)
 {
     if (curentHistory == null)
     {
         instance.CurrentChatText = "";
     }
     else
     {
         instance.CurrentChatText = curentHistory.Value;
     }
 }
Esempio n. 2
0
 public static void SetChat(PLNetworkManager instance)
 {
     if (currentHistory == null)
     {
         if (node != null)
         {
             instance.CurrentChatText = node.Value.Item1;
             cursorPos = node.Value.Item2;
         }
         else
         {
             instance.CurrentChatText = "";
         }
     }
     else
     {
         instance.CurrentChatText = currentHistory.Value;
     }
 }
        static void Prefix(PLNetworkManager __instance)
        {
            if (string.IsNullOrWhiteSpace(__instance.CurrentChatText))
            {
                return;
            }

            LinkedListNode <string> lastMessage = Update.chatHistory.FindLast(__instance.CurrentChatText.TrimEnd(newline));

            if (lastMessage != null)
            {
                Update.chatHistory.Remove(lastMessage);
            }
            Update.chatHistory.AddLast(__instance.CurrentChatText.TrimEnd(newline));
            if (Update.chatHistory.Count > 100)
            {
                Update.chatHistory.RemoveFirst();
            }
        }
Esempio n. 4
0
        private static bool TagFound(string str, PLNetworkManager networkManager, int pos)
        {
            if (pos <= 0)
            {
                return(false);
            }
            bool tagFound = false;

            for (int i = str.Length - pos; i < str.Length; i++)
            {
                if (networkManager.CurrentChatText[i] == '>')
                {
                    tagFound = true;
                    break;
                }
                else if (networkManager.CurrentChatText[i] == '<')
                {
                    break;
                }
            }
            if (tagFound)
            {
                tagFound = false;
                for (int i = str.Length - pos - 1; i >= 0; i--)
                {
                    if (networkManager.CurrentChatText[i] == '<')
                    {
                        tagFound = true;
                        break;
                    }
                    else if (networkManager.CurrentChatText[i] == '>')
                    {
                        break;
                    }
                }
            }
            return(tagFound);
        }
Esempio n. 5
0
        static void Prefix(PLInGameUI __instance, ref bool ___evenChatString, ref string __state)
        {
            PLNetworkManager networkManager = PLNetworkManager.Instance;

            if (networkManager.IsTyping)
            {
                ___evenChatString = false;
                __state           = networkManager.CurrentChatText;

                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                {
                    if (cursorPos2 == -1)
                    {
                        cursorPos2 = cursorPos;
                    }
                    HandleArrows(__state);
                    if (Input.GetKeyDown(KeyCode.Home))
                    {
                        cursorPos = __state.Length;
                    }
                    if (Input.GetKeyDown(KeyCode.End))
                    {
                        cursorPos = 0;
                    }
                }
                else
                {
                    if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.RightArrow) ||
                        (Input.GetKey(KeyCode.LeftArrow) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeLeft) ||
                        (Input.GetKey(KeyCode.RightArrow) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeRight))
                    {
                        cursorPos2 = -1;
                        HandleArrows(__state);
                    }
                    if (Input.GetKeyDown(KeyCode.Home))
                    {
                        cursorPos2 = -1;
                        cursorPos  = __state.Length;
                    }
                    if (Input.GetKeyDown(KeyCode.End))
                    {
                        cursorPos2 = -1;
                        cursorPos  = 0;
                    }
                }

                if (networkManager.CurrentChatText != null)
                {
                    if (TagFound(__state, networkManager, cursorPos) || TagFound(__state, networkManager, cursorPos2))
                    {
                        __instance.ChatLabel.supportRichText        = false;
                        __instance.ChatShadowLabel.supportRichText  = false;
                        __instance.ChatShadow2Label.supportRichText = false;
                    }
                    else
                    {
                        __instance.ChatLabel.supportRichText        = true;
                        __instance.ChatShadowLabel.supportRichText  = true;
                        __instance.ChatShadow2Label.supportRichText = true;
                    }
                    networkManager.CurrentChatText = networkManager.CurrentChatText.Insert(__state.Length - cursorPos, DateTime.Now.Millisecond >= 500 ? "|" : "'");
                    if (cursorPos2 != -1 && cursorPos2 != cursorPos)
                    {
                        networkManager.CurrentChatText = networkManager.CurrentChatText.Insert(__state.Length - cursorPos2 + (cursorPos > cursorPos2 ? 1 : 0), DateTime.Now.Millisecond >= 500 ? "¦" : "'");
                    }
                }
            }
            else
            {
                if (ChatHelper.isTyping)
                {
                    ChatHelper.isTyping      = false;
                    ChatHelper.typingHistory = null;
                }

                cursorPos  = 0;
                cursorPos2 = -1;
                __instance.ChatLabel.supportRichText        = true;
                __instance.ChatShadowLabel.supportRichText  = true;
                __instance.ChatShadow2Label.supportRichText = true;
            }
        }
Esempio n. 6
0
        static void Prefix(PLInGameUI __instance, ref bool ___evenChatString, ref string __state)
        {
            PLNetworkManager networkManager = PLNetworkManager.Instance;

            if (networkManager.IsTyping)
            {
                ___evenChatString = false;
                __state           = networkManager.CurrentChatText;

                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                {
                    if (cursorPos2 == -1)
                    {
                        cursorPos2 = cursorPos;
                    }
                    if (Input.GetKeyDown(KeyCode.LeftArrow))
                    {
                        lastTimeLeft = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250;
                        if (cursorPos < __state.Length)
                        {
                            cursorPos++;
                        }
                    }
                    if (Input.GetKeyDown(KeyCode.RightArrow))
                    {
                        lastTimeRight = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250;
                        if (cursorPos > 0)
                        {
                            cursorPos--;
                        }
                    }
                    if (Input.GetKeyDown(KeyCode.Home))
                    {
                        cursorPos = __state.Length;
                    }
                    if (Input.GetKeyDown(KeyCode.End))
                    {
                        cursorPos = 0;
                    }
                    if (Input.GetKey(KeyCode.LeftArrow) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeLeft)
                    {
                        lastTimeLeft += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                        if (cursorPos < __state.Length)
                        {
                            cursorPos++;
                        }
                    }
                    if (Input.GetKey(KeyCode.RightArrow) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeRight)
                    {
                        lastTimeRight += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                        if (cursorPos > 0)
                        {
                            cursorPos--;
                        }
                    }
                }
                else
                {
                    if (Input.GetKeyDown(KeyCode.LeftArrow))
                    {
                        cursorPos2   = -1;
                        lastTimeLeft = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + 500 /*(SystemInformation.KeyboardDelay + 1) * 250*/;
                        if (cursorPos < __state.Length)
                        {
                            cursorPos++;
                        }
                    }
                    if (Input.GetKeyDown(KeyCode.RightArrow))
                    {
                        cursorPos2    = -1;
                        lastTimeRight = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + 500 /*(SystemInformation.KeyboardDelay + 1) * 250*/;
                        if (cursorPos > 0)
                        {
                            cursorPos--;
                        }
                    }
                    if (Input.GetKeyDown(KeyCode.Home))
                    {
                        cursorPos2 = -1;
                        cursorPos  = __state.Length;
                    }
                    if (Input.GetKeyDown(KeyCode.End))
                    {
                        cursorPos2 = -1;
                        cursorPos  = 0;
                    }
                    if (Input.GetKey(KeyCode.LeftArrow) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeLeft)
                    {
                        cursorPos2    = -1;
                        lastTimeLeft += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                        if (cursorPos < __state.Length)
                        {
                            cursorPos++;
                        }
                    }
                    if (Input.GetKey(KeyCode.RightArrow) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeRight)
                    {
                        cursorPos2     = -1;
                        lastTimeRight += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                        if (cursorPos > 0)
                        {
                            cursorPos--;
                        }
                    }
                }

                if (networkManager.CurrentChatText != null)
                {
                    if (TagFound(__state, networkManager, cursorPos) || TagFound(__state, networkManager, cursorPos2))
                    {
                        __instance.ChatLabel.supportRichText        = false;
                        __instance.ChatShadowLabel.supportRichText  = false;
                        __instance.ChatShadow2Label.supportRichText = false;
                    }
                    else
                    {
                        __instance.ChatLabel.supportRichText        = true;
                        __instance.ChatShadowLabel.supportRichText  = true;
                        __instance.ChatShadow2Label.supportRichText = true;
                    }
                    networkManager.CurrentChatText = networkManager.CurrentChatText.Insert(__state.Length - cursorPos, DateTime.Now.Millisecond >= 500 ? "|" : " ");
                    if (cursorPos2 != -1 && cursorPos2 != cursorPos)
                    {
                        networkManager.CurrentChatText = networkManager.CurrentChatText.Insert(__state.Length - cursorPos2 + (cursorPos > cursorPos2 ? 1 : 0), DateTime.Now.Millisecond >= 500 ? "¦" : " ");
                    }
                }
            }
            else
            {
                cursorPos  = 0;
                cursorPos2 = -1;
                __instance.ChatLabel.supportRichText        = true;
                __instance.ChatShadowLabel.supportRichText  = true;
                __instance.ChatShadow2Label.supportRichText = true;
            }
        }
Esempio n. 7
0
        //public static GameObject BrokenReactorVisual = PLEncounterManager.Instance.PlayerShip.InteriorDynamic.Find("Reactor_01_GlassBroken");
        static void Postfix(PLNetworkManager __instance, Text ___CurrentVersionLabel)
        {
            if (PLServer.Instance != null && PLEncounterManager.Instance.PlayerShip != null && PLEncounterManager.Instance.PlayerShip.ReactorInstance != null)
            {
                //string ReactorStatus = string.Empty;
                //bool ReactorIsFine = (!PLEncounterManager.Instance.PlayerShip.IsReactorOverheated() && !PLEncounterManager.Instance.PlayerShip.IsReactorTempCritical() && !PLEncounterManager.Instance.PlayerShip.IsReactorInMeltdown());

                /*
                 * This is gonna be neat.
                 *
                 * string CurrentReactorIcon = "";
                 * string ReactorIcon1 = "╪";
                 * string ReactorIcon2 = "╬";
                 * string ReactorIcon3 = "╫";
                 * string ReactorIcon4 = "║";
                 * string ReactorIcon5 = "Φ";
                 * string ReactorIcon6 = "Θ";
                 */

                if (PLEncounterManager.Instance.PlayerShip.IsReactorOverheated())
                {
                    ReactorStatus = "<color=#ff8c00>REACTOR SAFETY SHUTDOWN ENGAGED!</color> <color=#B8860B>~╫~</color>";
                }
                else if (PLEncounterManager.Instance.PlayerShip.ShouldEjectReactorCore())
                {
                    ReactorStatus = "<color=red>CORE IMPLOSION</color> <color=red><╪></color> <color=red>IMMINENT</color>";
                }
                else if (PLEncounterManager.Instance.PlayerShip.IsReactorInMeltdown())
                {
                    ReactorStatus = "<color=red>CORE</color> <color=red><╪></color> <color=red>JETTISONED</color>";
                }
                else if (PLEncounterManager.Instance.PlayerShip.IsReactorTempCritical())
                {
                    ReactorStatus = "<color=red>DANGER:</color> <color=#FFA500>THERMAL STRESS</color> <color=red><b>~╫~</b></color>";
                }
                else if (PLEncounterManager.Instance.PlayerShip.CoreInstability > 0)
                {
                    ReactorStatus = "<color=yellow>Unstable - Recovering </color><color=#ff8c00><b><<╪>></b></color>";
                }
                else
                {
                    ReactorStatus = "Stable <color=#32CD32><╫></color>";
                }
                if (PLEncounterManager.Instance.PlayerShip.CoreInstability > 0)
                {
                    ReactorStatus += " <color=#FFA500>STABILITY: " + Mathf.RoundToInt(Mathf.Clamp01(1f - PLEncounterManager.Instance.PlayerShip.CoreInstability) * 100f).ToString("000") + "%</color>";
                }
                else
                {
                    ReactorStatus += " Temperature: " + Mathf.RoundToInt(PLEncounterManager.Instance.PlayerShip.MyStats.ReactorTempCurrent / PLEncounterManager.Instance.PlayerShip.MyStats.ReactorTempMax * 100f).ToString("000") + "%";
                }

                if (IsReadoutEnabled)
                {
                    PLGlobal.SafeLabelSetText(___CurrentVersionLabel, $"{___CurrentVersionLabel.text}\n\n\n\nRSTS: {ReactorStatus}");
                }
                else if (!IsReadoutEnabled)
                {
                    ReactorStatus = string.Empty;
                }
            }
        }
 static void Postfix(PLNetworkManager __instance, Text ___CurrentVersionLabel)
 {
     PLGlobal.SafeLabelSetText(___CurrentVersionLabel, $"{___CurrentVersionLabel.text}\nPPL {PPLVersion}");
 }
        static void Prefix(PLNetworkManager __instance)
        {
            currentChatText = __instance.CurrentChatText;
            if (__instance.IsTyping)
            {
                foreach (char c in Input.inputString)
                {
                    if (c == "\b"[0])
                    {
                        if (cursorPos2 != -1 && cursorPos2 != cursorPos)
                        {
                            DeleteSelected();
                            ChatHelper.UpdateTypingHistory(currentChatText, false, true);
                        }
                        else
                        {
                            if (cursorPos != currentChatText.Length)
                            {
                                ChatHelper.UpdateTypingHistory(currentChatText, false);
                                currentChatText = currentChatText.Remove(currentChatText.Length - cursorPos - 1, 1);
                            }
                        }
                    }
                    else if (c == '\n' || c == '\r')
                    {
                        //Do nothing
                    }
                    else
                    {
                        if (cursorPos2 != -1 && cursorPos2 != cursorPos)
                        {
                            DeleteSelected();
                        }
                        ChatHelper.UpdateTypingHistory(currentChatText, true);
                        currentChatText = currentChatText.Insert(currentChatText.Length - cursorPos, c.ToString());
                    }
                }
                if (Input.GetKeyDown(KeyCode.Delete))
                {
                    lastTimeDelete = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250;
                    if (cursorPos2 != -1 && cursorPos2 != cursorPos)
                    {
                        DeleteSelected();
                        ChatHelper.UpdateTypingHistory(currentChatText, false, true);
                    }
                    else
                    {
                        ChatHelper.UpdateTypingHistory(currentChatText, false);
                        if (cursorPos > 0)
                        {
                            currentChatText = currentChatText.Remove(currentChatText.Length - cursorPos, 1);
                            cursorPos--;
                        }
                    }
                }
                if (Input.GetKey(KeyCode.Delete) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeDelete)
                {
                    ChatHelper.UpdateTypingHistory(currentChatText, false);
                    lastTimeDelete += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                    if (cursorPos > 0)
                    {
                        currentChatText = currentChatText.Remove(currentChatText.Length - cursorPos, 1);
                        cursorPos--;
                    }
                }

                if (Input.GetKeyDown(KeyCode.Tab))
                {
                    if (currentChatText.StartsWith("/"))
                    {
                        string chatText = AutoComplete(currentChatText, cursorPos);
                        if (chatText != currentChatText)
                        {
                            ChatHelper.UpdateTypingHistory(currentChatText, true, true);
                            currentChatText = chatText;
                            cursorPos2      = -1;
                        }
                    }
                    else if (currentChatText.StartsWith("!"))
                    {
                        if (publicCached)
                        {
                            string chatText = AutoComplete(currentChatText, cursorPos);
                            if (chatText != currentChatText)
                            {
                                ChatHelper.UpdateTypingHistory(currentChatText, true, true);
                                currentChatText = chatText;
                                cursorPos2      = -1;
                            }
                        }
                        else
                        {
                            HandlePublicCommands.RequestPublicCommands();
                        }
                    }
                }
            }
        }
        static void Postfix(PLNetworkManager __instance)
        {
            if (!__instance.IsTyping)
            {
                currentHistory = null;
                return;
            }

            if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
            {
                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                {
                    if (Input.GetKeyDown(KeyCode.Z))
                    {
                        lastTimeRedo = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250;
                        ChatHelper.Redo(ref currentChatText);
                    }
                    if (Input.GetKey(KeyCode.Z) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeRedo)
                    {
                        lastTimeRedo += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                        ChatHelper.Redo(ref currentChatText);
                    }
                }
                else
                {
                    if (Input.GetKeyDown(KeyCode.Z))
                    {
                        lastTimeUndo = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250;
                        ChatHelper.Undo(ref currentChatText);
                    }
                    if (Input.GetKey(KeyCode.Z) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeUndo)
                    {
                        lastTimeUndo += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                        ChatHelper.Undo(ref currentChatText);
                    }
                }
                if (Input.GetKeyDown(KeyCode.Y))
                {
                    lastTimeRedo = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250;
                    ChatHelper.Redo(ref currentChatText);
                }
                if (Input.GetKey(KeyCode.Y) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeRedo)
                {
                    lastTimeRedo += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                    ChatHelper.Redo(ref currentChatText);
                }

                if (Input.GetKeyDown(KeyCode.V))
                {
                    ChatHelper.UpdateTypingHistory(currentChatText, true, true);
                    lastTimePaste = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250;
                    if (cursorPos2 != -1 && cursorPos2 != cursorPos)
                    {
                        DeleteSelected();
                    }
                    currentChatText = currentChatText.Insert(currentChatText.Length - cursorPos, GUIUtility.systemCopyBuffer);
                    ChatHelper.UpdateTypingHistory(currentChatText, true, true);
                }
                if (Input.GetKey(KeyCode.V) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimePaste)
                {
                    ChatHelper.UpdateTypingHistory(currentChatText, true, true);
                    lastTimePaste  += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                    currentChatText = currentChatText.Insert(currentChatText.Length - cursorPos, GUIUtility.systemCopyBuffer);
                    ChatHelper.UpdateTypingHistory(currentChatText, true, true);
                }
                if (Input.GetKeyDown(KeyCode.C) && cursorPos2 != -1 && cursorPos2 != cursorPos)
                {
                    int pos;
                    int length;
                    if (cursorPos < cursorPos2)
                    {
                        pos    = currentChatText.Length - cursorPos2;
                        length = cursorPos2 - cursorPos;
                    }
                    else
                    {
                        pos    = currentChatText.Length - cursorPos;
                        length = cursorPos - cursorPos2;
                    }
                    GUIUtility.systemCopyBuffer = currentChatText.Substring(pos, length);
                }
                if (Input.GetKeyDown(KeyCode.X) && cursorPos2 != -1 && cursorPos2 != cursorPos)
                {
                    ChatHelper.UpdateTypingHistory(currentChatText, false, true);
                    int pos;
                    int length;
                    if (cursorPos < cursorPos2)
                    {
                        pos    = currentChatText.Length - cursorPos2;
                        length = cursorPos2 - cursorPos;
                    }
                    else
                    {
                        pos    = currentChatText.Length - cursorPos;
                        length = cursorPos - cursorPos2;
                    }
                    GUIUtility.systemCopyBuffer = currentChatText.Substring(pos, length);
                    DeleteSelected();
                    ChatHelper.UpdateTypingHistory(currentChatText, false, true);
                }
                if (Input.GetKeyDown(KeyCode.A))
                {
                    cursorPos  = 0;
                    cursorPos2 = currentChatText.Length;
                }
            }

            __instance.CurrentChatText = currentChatText;

            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                cursorPos  = 0;
                cursorPos2 = -1;
                if (currentHistory == null)
                {
                    ChatHelper.UpdateTypingHistory(currentChatText, true, true);
                    currentHistory = chatHistory.Last;
                }
                else
                {
                    currentHistory = currentHistory.Previous;
                }
                SetChat(__instance);
            }
            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                cursorPos  = 0;
                cursorPos2 = -1;
                if (currentHistory == null)
                {
                    currentHistory = chatHistory.First;
                }
                else
                {
                    currentHistory = currentHistory.Next;
                }
                SetChat(__instance);
            }
        }
Esempio n. 11
0
        static void Postfix(PLNetworkManager __instance)
        {
            if (!__instance.IsTyping)
            {
                curentHistory = null;
                return;
            }

            if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
            {
                if (Input.GetKeyDown(KeyCode.V))
                {
                    lastTimePaste = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250;
                    if (HarmonyHandleChat.cursorPos2 != -1 && HarmonyHandleChat.cursorPos2 != HarmonyHandleChat.cursorPos)
                    {
                        DeleteSelected();
                    }
                    currentChatText = currentChatText.Insert(currentChatText.Length - HarmonyHandleChat.cursorPos, GUIUtility.systemCopyBuffer);
                    textModified    = true;
                }
                if (Input.GetKey(KeyCode.V) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimePaste)
                {
                    lastTimePaste  += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
                    currentChatText = currentChatText.Insert(currentChatText.Length - HarmonyHandleChat.cursorPos, GUIUtility.systemCopyBuffer);
                    textModified    = true;
                }
                if (Input.GetKeyDown(KeyCode.C) && HarmonyHandleChat.cursorPos2 != -1 && HarmonyHandleChat.cursorPos2 != HarmonyHandleChat.cursorPos)
                {
                    int pos;
                    int length;
                    if (HarmonyHandleChat.cursorPos < HarmonyHandleChat.cursorPos2)
                    {
                        pos    = currentChatText.Length - HarmonyHandleChat.cursorPos2;
                        length = HarmonyHandleChat.cursorPos2 - HarmonyHandleChat.cursorPos;
                    }
                    else
                    {
                        pos    = currentChatText.Length - HarmonyHandleChat.cursorPos;
                        length = HarmonyHandleChat.cursorPos - HarmonyHandleChat.cursorPos2;
                    }
                    GUIUtility.systemCopyBuffer = currentChatText.Substring(pos, length);
                }
                if (Input.GetKeyDown(KeyCode.X) && HarmonyHandleChat.cursorPos2 != -1 && HarmonyHandleChat.cursorPos2 != HarmonyHandleChat.cursorPos)
                {
                    int pos;
                    int length;
                    if (HarmonyHandleChat.cursorPos < HarmonyHandleChat.cursorPos2)
                    {
                        pos    = currentChatText.Length - HarmonyHandleChat.cursorPos2;
                        length = HarmonyHandleChat.cursorPos2 - HarmonyHandleChat.cursorPos;
                    }
                    else
                    {
                        pos    = currentChatText.Length - HarmonyHandleChat.cursorPos;
                        length = HarmonyHandleChat.cursorPos - HarmonyHandleChat.cursorPos2;
                    }
                    GUIUtility.systemCopyBuffer = currentChatText.Substring(pos, length);
                    DeleteSelected();
                    textModified = true;
                }
                if (Input.GetKeyDown(KeyCode.A))
                {
                    HarmonyHandleChat.cursorPos  = 0;
                    HarmonyHandleChat.cursorPos2 = currentChatText.Length;
                }
            }

            if (textModified)
            {
                textModified = false;
                __instance.CurrentChatText = currentChatText;
            }

            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                HarmonyHandleChat.cursorPos  = 0;
                HarmonyHandleChat.cursorPos2 = -1;
                if (curentHistory == null)
                {
                    curentHistory = chatHistory.Last;
                }
                else
                {
                    curentHistory = curentHistory.Previous;
                }
                SetChat(__instance);
            }
            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                HarmonyHandleChat.cursorPos  = 0;
                HarmonyHandleChat.cursorPos2 = -1;
                if (curentHistory == null)
                {
                    curentHistory = chatHistory.First;
                }
                else
                {
                    curentHistory = curentHistory.Next;
                }
                SetChat(__instance);
            }
        }
Esempio n. 12
0
 static void Prefix(PLNetworkManager __instance)
 {
     currentChatText = __instance.CurrentChatText;
     if (__instance.IsTyping && (HarmonyHandleChat.cursorPos > 0 || HarmonyHandleChat.cursorPos2 > 0))
     {
         foreach (char c in Input.inputString)
         {
             if (c == "\b"[0])
             {
                 if (HarmonyHandleChat.cursorPos2 != -1 && HarmonyHandleChat.cursorPos2 != HarmonyHandleChat.cursorPos)
                 {
                     DeleteSelected();
                 }
                 else
                 {
                     if (HarmonyHandleChat.cursorPos != currentChatText.Length)
                     {
                         currentChatText = currentChatText.Remove(currentChatText.Length - HarmonyHandleChat.cursorPos - 1, 1);
                     }
                 }
                 textModified = true;
             }
             else if (c == Environment.NewLine[0] || c == "\r"[0])
             {
                 //Do nothing
             }
             else
             {
                 if (HarmonyHandleChat.cursorPos2 != -1 && HarmonyHandleChat.cursorPos2 != HarmonyHandleChat.cursorPos)
                 {
                     DeleteSelected();
                 }
                 currentChatText = currentChatText.Insert(currentChatText.Length - HarmonyHandleChat.cursorPos, c.ToString());
                 textModified    = true;
             }
         }
         if (Input.GetKeyDown(KeyCode.Delete))
         {
             lastTimeDelete = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250;
             if (HarmonyHandleChat.cursorPos2 != -1 && HarmonyHandleChat.cursorPos2 != HarmonyHandleChat.cursorPos)
             {
                 DeleteSelected();
             }
             else
             {
                 currentChatText = currentChatText.Remove(currentChatText.Length - HarmonyHandleChat.cursorPos, 1);
                 HarmonyHandleChat.cursorPos--;
             }
             textModified = true;
         }
         if (Input.GetKey(KeyCode.Delete) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeDelete)
         {
             lastTimeDelete += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/;
             currentChatText = currentChatText.Remove(currentChatText.Length - HarmonyHandleChat.cursorPos, 1);
             HarmonyHandleChat.cursorPos--;
             textModified = true;
         }
     }
     else if (__instance.IsTyping)
     {
         if (Input.GetKeyDown(KeyCode.Tab))
         {
             if (currentChatText.StartsWith("/"))
             {
                 currentChatText = AutoComplete(currentChatText, GetCommands());
                 textModified    = true;
             }
             else if (currentChatText.StartsWith("!"))
             {
                 if (publicCached)
                 {
                     currentChatText = AutoComplete(currentChatText, publicCommands);
                     textModified    = true;
                 }
                 else
                 {
                     HandlePublicCommands.RequestPublicCommands();
                 }
             }
         }
     }
 }