From fb4b6b28db82c633e008beb05e284f9f34b4d54c Mon Sep 17 00:00:00 2001 From: brian91292 <8050523+brian91292@users.noreply.github.com> Date: Sat, 6 Apr 2019 12:42:11 -0500 Subject: [PATCH] bugfixes -Escape html instead of removing it (so it still shows in chat) -Fix clearchat/clearmsg functionality --- EnhancedStreamChat/Chat/ChatHandler.cs | 16 +++++++--------- EnhancedStreamChat/EnhancedStreamChat.csproj | 12 +++++------- EnhancedStreamChat/Images/AnimationDecoder.cs | 3 +-- EnhancedStreamChat/Images/ImageDownloader.cs | 5 ++--- EnhancedStreamChat/Plugin.cs | 5 +---- EnhancedStreamChat/Properties/AssemblyInfo.cs | 4 ++-- EnhancedStreamChat/UI/Drawing.cs | 4 ++-- EnhancedStreamChat/UI/Settings.cs | 11 ++++------- 8 files changed, 24 insertions(+), 36 deletions(-) diff --git a/EnhancedStreamChat/Chat/ChatHandler.cs b/EnhancedStreamChat/Chat/ChatHandler.cs index 7983eac..d9ba3d1 100644 --- a/EnhancedStreamChat/Chat/ChatHandler.cs +++ b/EnhancedStreamChat/Chat/ChatHandler.cs @@ -1,5 +1,4 @@ -using CustomUI.Utilities; -using EnhancedStreamChat.Chat; +using EnhancedStreamChat.Chat; using EnhancedStreamChat.Textures; using EnhancedStreamChat.UI; using System; @@ -245,7 +244,7 @@ private void RegisterMessageHandlers() if (twitchMsg.channelName != TwitchLoginConfig.Instance.TwitchChannelName) return; - MessageParser.Parse(new ChatMessage(Utilities.StripHTML(twitchMsg.message), twitchMsg)); + MessageParser.Parse(new ChatMessage(Utilities.EscapeHTML(twitchMsg.message), twitchMsg)); }; // USERNOTICE handler @@ -303,7 +302,7 @@ private void RegisterMessageHandlers() { if (t.Groups["Tag"].Value == "target-user-id") { - userId = t.Groups["target-user-id"].Value; + userId = t.Groups["Value"].Value; break; } } @@ -318,12 +317,11 @@ private void RegisterMessageHandlers() { if (t.Groups["Tag"].Value == "target-msg-id") { - msgId = t.Groups["target-msg-id"].Value; + msgId = t.Groups["Value"].Value; break; } } if (msgId == String.Empty) return; - PurgeChatMessageById(msgId); }; } @@ -350,9 +348,9 @@ private void InitializeChatUI() _lastFontName = ChatConfig.Instance.FontName; StartCoroutine(Drawing.Initialize(gameObject.transform)); - _lockedSprite = UIUtilities.LoadSpriteFromResources("EnhancedStreamChat.Resources.LockedIcon.png"); + _lockedSprite = Utilities.LoadSpriteFromResources("EnhancedStreamChat.Resources.LockedIcon.png"); _lockedSprite.texture.wrapMode = TextureWrapMode.Clamp; - _unlockedSprite = UIUtilities.LoadSpriteFromResources("EnhancedStreamChat.Resources.UnlockedIcon.png"); + _unlockedSprite = Utilities.LoadSpriteFromResources("EnhancedStreamChat.Resources.UnlockedIcon.png"); _unlockedSprite.texture.wrapMode = TextureWrapMode.Clamp; _twitchChatCanvas = gameObject.AddComponent(); @@ -561,7 +559,7 @@ private void PurgeChatMessagesInternal(KeyValuePair messageInfo) return; else if (id != "!FULLCLEAR!" && !ChatConfig.Instance.ClearTimedOutMessages) return; - + bool purged = false; foreach (CustomText currentMessage in _chatMessages) { diff --git a/EnhancedStreamChat/EnhancedStreamChat.csproj b/EnhancedStreamChat/EnhancedStreamChat.csproj index 7953b73..36d0a36 100644 --- a/EnhancedStreamChat/EnhancedStreamChat.csproj +++ b/EnhancedStreamChat/EnhancedStreamChat.csproj @@ -36,15 +36,13 @@ AnyCPU - - ..\..\..\..\..\..\steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\0Harmony.dll - - - ..\..\..\..\..\..\beatsaber\Beat Saber_Data\Managed\Assembly-CSharp.dll + + False + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll - + False - ..\..\..\..\..\..\steam\steamapps\common\Beat Saber\Plugins\BeatSaberCustomUI.dll + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BeatSaberCustomUI.dll ..\..\..\..\..\..\beatsaber\Beat Saber_Data\Managed\IllusionInjector.dll diff --git a/EnhancedStreamChat/Images/AnimationDecoder.cs b/EnhancedStreamChat/Images/AnimationDecoder.cs index 6a251e1..786c5b8 100644 --- a/EnhancedStreamChat/Images/AnimationDecoder.cs +++ b/EnhancedStreamChat/Images/AnimationDecoder.cs @@ -1,5 +1,4 @@ -using CustomUI.Utilities; -using EnhancedStreamChat.Images; +using EnhancedStreamChat.Images; using EnhancedStreamChat.UI; using System; using System.Collections; diff --git a/EnhancedStreamChat/Images/ImageDownloader.cs b/EnhancedStreamChat/Images/ImageDownloader.cs index e7df24d..d41a53a 100644 --- a/EnhancedStreamChat/Images/ImageDownloader.cs +++ b/EnhancedStreamChat/Images/ImageDownloader.cs @@ -13,7 +13,6 @@ using EnhancedStreamChat.UI; using StreamCore.SimpleJSON; using System.Text.RegularExpressions; -using CustomUI.Utilities; using EnhancedStreamChat.Config; using StreamCore; using EnhancedStreamChat.Images; @@ -280,7 +279,7 @@ public static IEnumerator Download(string imagePath, TextureDownloadInfo imageDo bool localPathExists = ImageExistsLocally(ref imagePath, imageDownloadInfo, out var localFilePath); yield return Utilities.Download(imagePath, Utilities.DownloadType.Texture, null, (web) => { - sprite = UIUtilities.LoadSpriteFromTexture(DownloadHandlerTexture.GetContent(web)); + sprite = Utilities.LoadSpriteFromTexture(DownloadHandlerTexture.GetContent(web)); if (sprite) { if (!localPathExists) @@ -289,7 +288,7 @@ public static IEnumerator Download(string imagePath, TextureDownloadInfo imageDo }); } else - sprite = UIUtilities.LoadSpriteFromResources($"EnhancedStreamChat.Resources.Emojis.{imageDownloadInfo.spriteIndex.ToLower()}"); + sprite = Utilities.LoadSpriteFromResources($"EnhancedStreamChat.Resources.Emojis.{imageDownloadInfo.spriteIndex.ToLower()}"); if (sprite) { diff --git a/EnhancedStreamChat/Plugin.cs b/EnhancedStreamChat/Plugin.cs index a16ad4b..b68fd9b 100644 --- a/EnhancedStreamChat/Plugin.cs +++ b/EnhancedStreamChat/Plugin.cs @@ -8,8 +8,6 @@ using EnhancedStreamChat.UI; using System.Threading.Tasks; using System.Collections; -using CustomUI.BeatSaber; -//using EnhancedTwitchChat.Bot; using System.Runtime.CompilerServices; using TMPro; using EnhancedStreamChat.Config; @@ -22,7 +20,7 @@ public class Plugin : IPlugin { public static readonly string ModuleName = "EnhancedStreamChat"; public string Name => ModuleName; - public string Version => "2.0.0"; + public string Version => "2.0.1"; public static Plugin Instance { get; private set; } @@ -40,7 +38,6 @@ public void OnApplicationStart() { if (Instance != null) return; Instance = this; - ChatConfig = new ChatConfig(); TwitchWebSocketClient.Initialize(); diff --git a/EnhancedStreamChat/Properties/AssemblyInfo.cs b/EnhancedStreamChat/Properties/AssemblyInfo.cs index c73afa1..a17b428 100644 --- a/EnhancedStreamChat/Properties/AssemblyInfo.cs +++ b/EnhancedStreamChat/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: AssemblyVersion("2.0.1.0")] +[assembly: AssemblyFileVersion("2.0.1.0")] diff --git a/EnhancedStreamChat/UI/Drawing.cs b/EnhancedStreamChat/UI/Drawing.cs index 4232de7..e7da1cf 100644 --- a/EnhancedStreamChat/UI/Drawing.cs +++ b/EnhancedStreamChat/UI/Drawing.cs @@ -11,12 +11,12 @@ using System.Collections; using static POCs.Sanjay.SharpSnippets.Drawing.ColorExtensions; using Random = System.Random; -using CustomUI.Utilities; using System.Reflection; using EnhancedStreamChat.Config; using EnhancedStreamChat.Images; using StreamCore; using StreamCore.Chat; +using StreamCore.Utils; namespace EnhancedStreamChat.UI { @@ -100,7 +100,7 @@ private static AssetBundle Assets get { if(!_assets) - _assets = AssetBundle.LoadFromMemory(UIUtilities.GetResource(Assembly.GetExecutingAssembly(), "EnhancedStreamChat.Resources.Assets")); + _assets = AssetBundle.LoadFromMemory(Utilities.GetResource(Assembly.GetExecutingAssembly(), "EnhancedStreamChat.Resources.Assets")); return _assets; } } diff --git a/EnhancedStreamChat/UI/Settings.cs b/EnhancedStreamChat/UI/Settings.cs index 3a123e0..e98e9ee 100644 --- a/EnhancedStreamChat/UI/Settings.cs +++ b/EnhancedStreamChat/UI/Settings.cs @@ -1,8 +1,4 @@ -using CustomUI.MenuButton; -using CustomUI.Settings; -using CustomUI.Utilities; -using CustomUI.UIElements; -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -15,6 +11,7 @@ //using EnhancedTwitchIntegration.Config; using System.IO; using StreamCore.Config; +using CustomUI.Settings; namespace EnhancedStreamChat.UI { @@ -86,13 +83,13 @@ public static void OnLoad() var messageSpacing = menu.AddSlider("Message Spacing", "The amount of vertical space between each message.", 0, 20, 2, true); messageSpacing.SetValue += (spacing) => { ChatConfig.Instance.LineSpacing = spacing; }; messageSpacing.GetValue += () => { return (int)ChatConfig.Instance.LineSpacing; }; - + var textColor = menu.AddColorPicker("Text Color", "Choose the color of the menu text.", ChatConfig.Instance.TextColor); textColor.SetValue += (texCol) => { ChatConfig.Instance.TextColor = texCol; }; textColor.GetValue += () => { return ChatConfig.Instance.TextColor; }; var backgroundColor = menu.AddColorPicker("Background Color", "Choose the color of the menu background.", ChatConfig.Instance.BackgroundColor); - backgroundColor.SetValue += (bgCol) => { ChatConfig.Instance.BackgroundColor = bgCol; }; + backgroundColor.SetValue += (bgCol) => { ChatConfig.Instance.BackgroundColor = bgCol; }; backgroundColor.GetValue += () => { return ChatConfig.Instance.BackgroundColor; }; } }