using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Il2CppTankAndHealerStudioAssets; using MelonLoader; using Microsoft.CodeAnalysis; using SGChatScrollbar; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(SGChatScrollbarMod), "SGChatScrollbar", "1.0.0", "Spyci", null)] [assembly: MelonColor] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Spyci")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+3e1932f7eef8160e300f150d509f0884624c65f4")] [assembly: AssemblyProduct("SGChatScrollbar")] [assembly: AssemblyTitle("SGChatScrollbar")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SGChatScrollbar { public class SGChatScrollbarMod : MelonMod { private const int MaxMessages = 100; private const float WheelPageFrac = 0.25f; private const float Eps = 0.5f; private UltimateChatBox _chat; private RectTransform _content; private RectTransform _viewport; private RectTransform _handle; private RectTransform _track; private CanvasGroup _scrollGroup; private Canvas _canvas; private float _targetY; private bool _follow = true; private bool _dragging; private float _findCooldown; public override void OnUpdate() { if ((Object)(object)_chat == (Object)null) { _findCooldown -= Time.unscaledDeltaTime; if (_findCooldown > 0f) { return; } _findCooldown = 1f; if (!TryBind()) { return; } } try { Tick(); } catch (Exception ex) { MelonLogger.Warning("[SGChatScrollbar] " + ex.GetType().Name + ": " + ex.Message); _chat = null; _dragging = false; } } private bool TryBind() { _chat = Object.FindObjectOfType(); if ((Object)(object)_chat == (Object)null) { return false; } _content = _chat.chatContentBox; _viewport = _chat.visibleChatBoundingBox; _handle = _chat.scrollbarHandle; _track = _chat.scrollbarBase; _scrollGroup = _chat.scrollbarCanvasGroup; _canvas = ((Component)_chat).GetComponentInParent(); if ((Object)(object)_content == (Object)null || (Object)(object)_viewport == (Object)null || (Object)(object)_handle == (Object)null || (Object)(object)_track == (Object)null) { _chat = null; return false; } try { _chat.maxTextInChatBox = 100; _chat.useScrollbar = true; _chat.useScrollWheel = false; _chat.visibleOnlyOnHover = false; } catch (Exception ex) { MelonLogger.Warning("[SGChatScrollbar] config: " + ex.Message); } _follow = true; MelonLogger.Msg("[SGChatScrollbar] Bound to chat box — driving native content scroll."); return true; } private void Tick() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) float num = _content.sizeDelta.y - _viewport.sizeDelta.y; if (num <= 0.5f) { _follow = true; return; } float y = _content.anchoredPosition.y; _targetY = (_follow ? num : Mathf.Clamp(_targetY, 0f, num)); HandleWheel(num); HandleDrag(num); if (_follow) { _targetY = num; } _targetY = Mathf.Clamp(_targetY, 0f, num); if (Mathf.Abs(y - _targetY) > 0.01f || _follow) { Vector2 anchoredPosition = _content.anchoredPosition; anchoredPosition.y = _targetY; _content.anchoredPosition = anchoredPosition; } _chat.ConstrainContentBox(); ForceScrollbarVisible(); } private void ForceScrollbarVisible() { try { _chat.ScrollbarActive = true; } catch { } if ((Object)(object)_scrollGroup != (Object)null) { if (_scrollGroup.alpha < 1f) { _scrollGroup.alpha = 1f; } if (!((Component)_scrollGroup).gameObject.activeSelf) { ((Component)_scrollGroup).gameObject.SetActive(true); } } if (!((Component)_track).gameObject.activeSelf) { ((Component)_track).gameObject.SetActive(true); } if (!((Component)_handle).gameObject.activeSelf) { ((Component)_handle).gameObject.SetActive(true); } } private void HandleWheel(float overflow) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) float y = Input.mouseScrollDelta.y; if (!(Mathf.Abs(y) < 0.01f) && PointerOver(_viewport)) { Rect rect = _viewport.rect; float num = Mathf.Max(20f, ((Rect)(ref rect)).height * 0.25f); _targetY = Mathf.Clamp(_targetY - y * num, 0f, overflow); _follow = _targetY >= overflow - 0.5f; } } private void HandleDrag(float overflow) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (!_dragging) { if (!Input.GetMouseButtonDown(0) || (!PointerOver(_handle) && !PointerOver(_track))) { return; } _dragging = true; } Vector2 val = default(Vector2); if (!Input.GetMouseButton(0)) { _dragging = false; } else if (RectTransformUtility.ScreenPointToLocalPointInRectangle(_track, Vector2.op_Implicit(Input.mousePosition), Cam(), ref val)) { Vector2 val2 = Rect.PointToNormalized(_track.rect, val); float num = Mathf.Clamp01(1f - val2.y); _targetY = num * overflow; _follow = num >= 0.999f; } } private Camera Cam() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_canvas != (Object)null) || (int)_canvas.renderMode == 0) { return null; } return _canvas.worldCamera; } private bool PointerOver(RectTransform rt) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rt != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(rt, Vector2.op_Implicit(Input.mousePosition), Cam()); } return false; } } }