From e0438a7093a1bf84d2dd1ec6bc013d86b04db33b Mon Sep 17 00:00:00 2001 From: 18107 <18107@users.noreply.github.com> Date: Wed, 28 Apr 2021 10:08:05 +1000 Subject: [PATCH] Refactor --- .../Chat/Extensions/HarmonyNetworkUpdate.cs | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/PulsarPluginLoader/Chat/Extensions/HarmonyNetworkUpdate.cs b/PulsarPluginLoader/Chat/Extensions/HarmonyNetworkUpdate.cs index 5e86b5a..131bd23 100644 --- a/PulsarPluginLoader/Chat/Extensions/HarmonyNetworkUpdate.cs +++ b/PulsarPluginLoader/Chat/Extensions/HarmonyNetworkUpdate.cs @@ -11,8 +11,6 @@ class HarmonyNetworkUpdate { private static string currentChatText; - private static bool textModified = false; - private static long lastTimePaste = long.MaxValue; private static long lastTimeDelete = long.MaxValue; private static long lastTimeUndo = long.MaxValue; @@ -72,7 +70,6 @@ static void Prefix(PLNetworkManager __instance) currentChatText = currentChatText.Remove(currentChatText.Length - cursorPos - 1, 1); } } - textModified = true; } else if (c == Environment.NewLine[0] || c == "\r"[0]) { @@ -86,7 +83,6 @@ static void Prefix(PLNetworkManager __instance) } ChatHelper.UpdateTypingHistory(currentChatText, true); currentChatText = currentChatText.Insert(currentChatText.Length - cursorPos, c.ToString()); - textModified = true; } } if (Input.GetKeyDown(KeyCode.Delete)) @@ -103,7 +99,6 @@ static void Prefix(PLNetworkManager __instance) currentChatText = currentChatText.Remove(currentChatText.Length - cursorPos, 1); cursorPos--; } - textModified = true; } if (Input.GetKey(KeyCode.Delete) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeDelete) { @@ -111,7 +106,6 @@ static void Prefix(PLNetworkManager __instance) lastTimeDelete += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/; currentChatText = currentChatText.Remove(currentChatText.Length - cursorPos, 1); cursorPos--; - textModified = true; } if (Input.GetKeyDown(KeyCode.Tab)) @@ -122,7 +116,6 @@ static void Prefix(PLNetworkManager __instance) if (chatText != currentChatText) { ChatHelper.UpdateTypingHistory(currentChatText, true, true); - textModified = true; currentChatText = chatText; cursorPos2 = -1; } @@ -135,7 +128,6 @@ static void Prefix(PLNetworkManager __instance) if (chatText != currentChatText) { ChatHelper.UpdateTypingHistory(currentChatText, true, true); - textModified = true; currentChatText = chatText; cursorPos2 = -1; } @@ -165,13 +157,11 @@ static void Postfix(PLNetworkManager __instance) { lastTimeRedo = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250; ChatHelper.Redo(ref currentChatText); - textModified = true; } if (Input.GetKey(KeyCode.Z) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeRedo) { lastTimeRedo += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/; ChatHelper.Redo(ref currentChatText); - textModified = true; } } else @@ -180,26 +170,22 @@ static void Postfix(PLNetworkManager __instance) { lastTimeUndo = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250; ChatHelper.Undo(ref currentChatText); - textModified = true; } if (Input.GetKey(KeyCode.Z) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeUndo) { lastTimeUndo += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/; ChatHelper.Undo(ref currentChatText); - textModified = true; } } if (Input.GetKeyDown(KeyCode.Y)) { lastTimeRedo = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + /*(SystemInformation.KeyboardDelay + 1) **/ 250; ChatHelper.Redo(ref currentChatText); - textModified = true; } if (Input.GetKey(KeyCode.Y) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimeRedo) { lastTimeRedo += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/; ChatHelper.Redo(ref currentChatText); - textModified = true; } if (Input.GetKeyDown(KeyCode.V)) @@ -211,7 +197,6 @@ static void Postfix(PLNetworkManager __instance) DeleteSelected(); } currentChatText = currentChatText.Insert(currentChatText.Length - cursorPos, GUIUtility.systemCopyBuffer); - textModified = true; ChatHelper.UpdateTypingHistory(currentChatText, true, true); } if (Input.GetKey(KeyCode.V) && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond > lastTimePaste) @@ -219,7 +204,6 @@ static void Postfix(PLNetworkManager __instance) ChatHelper.UpdateTypingHistory(currentChatText, true, true); lastTimePaste += 30 /*(long)(1 / ((SystemInformation.KeyboardSpeed + 1) * 0.859375))*/; currentChatText = currentChatText.Insert(currentChatText.Length - cursorPos, GUIUtility.systemCopyBuffer); - textModified = true; ChatHelper.UpdateTypingHistory(currentChatText, true, true); } if (Input.GetKeyDown(KeyCode.C) && cursorPos2 != -1 && cursorPos2 != cursorPos) @@ -255,7 +239,6 @@ static void Postfix(PLNetworkManager __instance) } GUIUtility.systemCopyBuffer = currentChatText.Substring(pos, length); DeleteSelected(); - textModified = true; ChatHelper.UpdateTypingHistory(currentChatText, false, true); } if (Input.GetKeyDown(KeyCode.A)) @@ -265,11 +248,7 @@ static void Postfix(PLNetworkManager __instance) } } - if (textModified) - { - textModified = false; - __instance.CurrentChatText = currentChatText; - } + __instance.CurrentChatText = currentChatText; if (Input.GetKeyDown(KeyCode.UpArrow)) {