Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TooltipExpansion v1.1.0
TooltipExpansion.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using TooltipExpansion.CodeNShit.Monos; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("TooltipExpansion")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Azumatt")] [assembly: AssemblyProduct("TooltipExpansion")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: AssemblyFileVersion("1.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 TooltipExpansion.CodeNShit { public static class Functions { public static void ConvertTextToScrollView(GameObject tooltipObject) { Transform val = Utils.FindChild(tooltipObject.transform, "Text", (IterativeSearchType)0); if ((Object)(object)val == (Object)null) { TooltipExpansionPlugin.TooltipExpansionPluginLogger.LogWarning((object)"Tooltip does not contain a 'Text' object."); return; } TMP_Text component = ((Component)val).GetComponent<TMP_Text>(); if ((Object)(object)component == (Object)null) { TooltipExpansionPlugin.TooltipExpansionPluginLogger.LogWarning((object)"Tooltip 'Text' object is missing TMP_Text component."); return; } ((Component)component).gameObject.GetOrAddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; component.ForceMeshUpdate(false, false); Transform originalParentTransform = val.parent; val.GetSiblingIndex(); RectTransform originalTextRectTransform = (RectTransform)(object)((val is RectTransform) ? val : null); GameObject scrollRectGo = GenScrollView(ref originalParentTransform, originalTextRectTransform, component); RectTransform viewportRT = GenViewPort(ref scrollRectGo, originalTextRectTransform); ScrollRect scrollRect = GenScrollRect(ref scrollRectGo, originalTextRectTransform, ref viewportRT); GenScrollBar(ref scrollRectGo, ref scrollRect); ((Component)scrollRect).gameObject.AddComponent<ScrollWheelHandler>(); ((Component)scrollRect).gameObject.AddComponent<TooltipSizeAdjuster>(); } private static GameObject GenScrollView(ref Transform originalParentTransform, RectTransform originalTextRectTransform, TMP_Text tooltipTextComponent) { //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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown GameObject val = new GameObject("TooltipScrollView", new Type[3] { typeof(RectTransform), typeof(ScrollRect), typeof(Image) }); val.transform.SetParent(originalParentTransform, false); val.transform.SetSiblingIndex(((Transform)originalTextRectTransform).GetSiblingIndex()); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = originalTextRectTransform.anchorMin; component.anchorMax = originalTextRectTransform.anchorMax; component.pivot = originalTextRectTransform.pivot; component.anchoredPosition = originalTextRectTransform.anchoredPosition; tooltipTextComponent.ForceMeshUpdate(false, false); Rect rect = originalTextRectTransform.rect; float width = ((Rect)(ref rect)).width; float y = tooltipTextComponent.GetPreferredValues(tooltipTextComponent.text, width, 0f).y; LayoutElement val2 = val.AddComponent<LayoutElement>(); InventoryGui instance = InventoryGui.instance; float? obj; if (instance == null) { obj = null; } else { Scrollbar recipeListScroll = instance.m_recipeListScroll; if (recipeListScroll == null) { obj = null; } else { rect = recipeListScroll.handleRect.rect; obj = ((Rect)(ref rect)).width; } } float? num = obj; float valueOrDefault = num.GetValueOrDefault(); rect = originalTextRectTransform.rect; val2.preferredWidth = ((Rect)(ref rect)).width + valueOrDefault + 5f; rect = originalTextRectTransform.rect; component.sizeDelta = new Vector2(((Rect)(ref rect)).width + valueOrDefault, 0f); if (tooltipTextComponent.preferredHeight > 460f && GuiScaler.m_largeGuiScale >= 1.11f && (Object)(object)UITooltip.m_hovered != (Object)null && ((Object)UITooltip.m_hovered).name == "JC_ItemBackground") { val2.minHeight = 460f; val2.preferredHeight = 460f; } else { val2.preferredHeight = Mathf.Min(y, (float)Screen.height * 0.9f); val2.minHeight = Mathf.Min(y, 460f); } Image component2 = val.GetComponent<Image>(); ((Graphic)component2).color = new Color(0f, 0f, 0f, 0.2f); ((Graphic)component2).raycastTarget = true; return val; } private static RectTransform GenViewPort(ref GameObject scrollRectGo, RectTransform? originalTextRectTransform) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TooltipViewport", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val.transform.SetParent(scrollRectGo.transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 1f); component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; return component; } private static ScrollRect GenScrollRect(ref GameObject scrollRectGo, RectTransform originalTextRectTransform, ref RectTransform viewportRT) { ScrollRect component = scrollRectGo.GetComponent<ScrollRect>(); component.viewport = viewportRT; ((Transform)originalTextRectTransform).SetParent((Transform)(object)viewportRT, false); component.content = originalTextRectTransform; component.horizontal = false; component.vertical = true; component.verticalScrollbarVisibility = (ScrollbarVisibility)2; component.scrollSensitivity = 50f; component.verticalNormalizedPosition = 1f; component.inertia = true; component.movementType = (MovementType)2; ((UnityEventBase)component.onValueChanged).RemoveAllListeners(); return component; } private static void GenScrollBar(ref GameObject scrollRectGo, ref ScrollRect scrollRect) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) Scrollbar newScrollbar = Object.Instantiate<Scrollbar>(InventoryGui.instance.m_recipeListScroll, scrollRectGo.transform); newScrollbar.size = 0.4f; ((UnityEvent<Vector2>)(object)scrollRect.onValueChanged).AddListener((UnityAction<Vector2>)delegate { newScrollbar.size = 0.4f; }); scrollRect.verticalScrollbar = newScrollbar; ((UnityEvent<Vector2>)(object)scrollRect.onValueChanged).Invoke(new Vector2(0f, 0f)); } private static T GetOrAddComponent<T>(this GameObject targetGameObject) where T : Component { T val = targetGameObject.GetComponent<T>(); if ((Object)(object)val == (Object)null) { val = targetGameObject.AddComponent<T>(); } return val; } } [BepInPlugin("Azumatt.TooltipExpansion", "TooltipExpansion", "1.1.0")] public class TooltipExpansionPlugin : BaseUnityPlugin { internal const string ModName = "TooltipExpansion"; internal const string ModVersion = "1.1.0"; internal const string Author = "Azumatt"; private const string ModGUID = "Azumatt.TooltipExpansion"; internal static string ConnectionError = ""; private readonly Harmony _harmony = new Harmony("Azumatt.TooltipExpansion"); public static readonly ManualLogSource TooltipExpansionPluginLogger = Logger.CreateLogSource("TooltipExpansion"); public void Awake() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); } } [HarmonyPatch(typeof(UITooltip), "OnHoverStart")] public class UITooltip_OnHoverStart_Patch { [HarmonyPriority(0)] private static void Postfix(UITooltip __instance, GameObject go) { AddCompIfNeeded(UITooltip.m_tooltip, go); } private static void AddCompIfNeeded(GameObject tooltipInstance, GameObject go) { if (!((Object)(object)InventoryGui.instance == (Object)null) && !((Object)(object)go == (Object)null) && (!(((Object)go).name != "JC_ItemBackground") || ((Object)go).name.StartsWith("InventoryElement")) && (Object)(object)tooltipInstance != (Object)null && (Object)(object)tooltipInstance.GetComponent<TooltipScrollInitializer>() == (Object)null) { tooltipInstance.AddComponent<TooltipScrollInitializer>(); } } } [HarmonyPatch(typeof(Utils), "ClampUIToScreen")] public static class Utils_ClampUIToScreen_Patch { private static bool Prefix(RectTransform transform) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)transform).GetComponentInParent<ScrollRect>() != (Object)null) { return false; } Vector3[] array = (Vector3[])(object)new Vector3[4]; transform.GetWorldCorners(array); float num = 0f; float num2 = 0f; if (array[2].x > (float)Screen.width) { num = (float)Screen.width - array[2].x; } if (array[0].x < 0f) { num = 0f - array[0].x; } if (array[2].y > (float)Screen.height) { num2 = (float)Screen.height - array[2].y; } if (array[0].y < 0f) { num2 = 0f - array[0].y; } ((Transform)transform).position = ((Transform)transform).position + new Vector3(num, num2, 0f); return false; } } } namespace TooltipExpansion.CodeNShit.Monos { public class TooltipScrollInitializer : MonoBehaviour { private bool _isInitialized; private void OnEnable() { if (!_isInitialized) { Functions.ConvertTextToScrollView(((Component)this).gameObject); Canvas.ForceUpdateCanvases(); _isInitialized = true; } } } public class ScrollWheelHandler : MonoBehaviour { private ScrollRect _scrollRect; private void Awake() { _scrollRect = ((Component)this).GetComponent<ScrollRect>(); if ((Object)(object)_scrollRect == (Object)null) { TooltipExpansionPlugin.TooltipExpansionPluginLogger.LogWarning((object)("ScrollWheelHandler: No ScrollRect found on " + ((Object)((Component)this).gameObject).name)); } else { _scrollRect.verticalNormalizedPosition = 1f; } } private void Update() { if (((Component)this).gameObject.activeInHierarchy && !((Object)(object)_scrollRect == (Object)null)) { float axis = Input.GetAxis("Mouse ScrollWheel"); if (Mathf.Abs(axis) > float.Epsilon) { float num = _scrollRect.verticalNormalizedPosition + axis * 0.7f; _scrollRect.verticalNormalizedPosition = Mathf.Clamp01(num); } } } } public class TooltipSizeAdjuster : MonoBehaviour { public float maxTooltipHeight = Screen.height; private ScrollRect _scrollRectComponent; private RectTransform _scrollViewRT; private RectTransform _contentRT; private void Awake() { _scrollRectComponent = ((Component)this).GetComponent<ScrollRect>(); _scrollViewRT = ((Component)this).GetComponent<RectTransform>(); if ((Object)(object)_scrollRectComponent != (Object)null) { _contentRT = _scrollRectComponent.content; } } private void Start() { AdjustSize(); } public void AdjustSize() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_contentRT == (Object)null) && !((Object)(object)_scrollViewRT == (Object)null)) { LayoutRebuilder.ForceRebuildLayoutImmediate(_contentRT); Rect rect = _contentRT.rect; float height = ((Rect)(ref rect)).height; _scrollViewRT.SetSizeWithCurrentAnchors((Axis)1, (height < maxTooltipHeight) ? height : maxTooltipHeight); } } } }