Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of TooltipFix v1.0.0
plugins/TooltipFix/TooltipFix.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using IL.RoR2.UI; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using R2API.Utils; using RoR2.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TooltipFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d290cc75ffb960d09fc5df1d11f51a2a95a766c3")] [assembly: AssemblyProduct("TooltipFix")] [assembly: AssemblyTitle("TooltipFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TooltipFix { internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber) { int num = callerPath.LastIndexOf("TooltipFix\\"); if (num >= 0) { callerPath = callerPath.Substring(num + "TooltipFix\\".Length); } return $"{callerPath}:{callerLineNumber} ({callerMemberName}) "; } internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Error_NoCallerPrefix(object data) { _logSource.LogError(data); } internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Fatal_NoCallerPrefix(object data) { _logSource.LogFatal(data); } internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Info_NoCallerPrefix(object data) { _logSource.LogInfo(data); } internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Message_NoCallerPrefix(object data) { _logSource.LogMessage(data); } internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Warning_NoCallerPrefix(object data) { _logSource.LogWarning(data); } } [BepInPlugin("Gorakh.TooltipFix", "TooltipFix", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class TooltipFixPlugin : BaseUnityPlugin { private delegate bool orig_TooltipProvider_get_tooltipIsAvailable(TooltipProvider self); [CompilerGenerated] private static class <>O { public static Manipulator <0>__TooltipController_SetTooltip_FixEmptyCheck; public static Func<orig_TooltipProvider_get_tooltipIsAvailable, TooltipProvider, bool> <1>__TooltipProvider_get_tooltipIsAvailable_CheckEmpty; } public const string PluginGUID = "Gorakh.TooltipFix"; public const string PluginAuthor = "Gorakh"; public const string PluginName = "TooltipFix"; public const string PluginVersion = "1.0.0"; private readonly List<IDetour> _hooks = new List<IDetour>(); internal static TooltipFixPlugin Instance { get; private set; } private void Awake() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown Stopwatch stopwatch = Stopwatch.StartNew(); Log.Init(((BaseUnityPlugin)this).Logger); Instance = SingletonHelper.Assign<TooltipFixPlugin>(Instance, this); object obj = <>O.<0>__TooltipController_SetTooltip_FixEmptyCheck; if (obj == null) { Manipulator val = TooltipController_SetTooltip_FixEmptyCheck; <>O.<0>__TooltipController_SetTooltip_FixEmptyCheck = val; obj = (object)val; } TooltipController.SetTooltip += (Manipulator)obj; MethodInfo methodInfo = AccessTools.DeclaredPropertyGetter(typeof(TooltipProvider), "tooltipIsAvailable"); if (methodInfo != null) { _hooks.Add((IDetour)new Hook((MethodBase)methodInfo, (Delegate)new Func<orig_TooltipProvider_get_tooltipIsAvailable, TooltipProvider, bool>(TooltipProvider_get_tooltipIsAvailable_CheckEmpty))); } else { Log.Error("Failed to find getter method for tooltipIsAvailable", "X:\\Git\\RoR2\\TooltipFix\\TooltipFix\\TooltipFixPlugin.cs", "Awake", 43); } stopwatch.Stop(); Log.Message_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalMilliseconds:F0}ms"); } private void OnDestroy() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__TooltipController_SetTooltip_FixEmptyCheck; if (obj == null) { Manipulator val = TooltipController_SetTooltip_FixEmptyCheck; <>O.<0>__TooltipController_SetTooltip_FixEmptyCheck = val; obj = (object)val; } TooltipController.SetTooltip -= (Manipulator)obj; foreach (IDetour hook in _hooks) { ((IDisposable)hook)?.Dispose(); } _hooks.Clear(); Instance = SingletonHelper.Unassign<TooltipFixPlugin>(Instance, this); } private static void TooltipController_SetTooltip_FixEmptyCheck(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int index = val.Index; val.Index = index - 1; MethodInfo titleTextGetter = AccessTools.DeclaredPropertyGetter(typeof(TooltipProvider), "titleText"); MethodInfo bodyTextGetter = AccessTools.DeclaredPropertyGetter(typeof(TooltipProvider), "bodyText"); if (val.TryGotoPrev(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)titleTextGetter) || ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)bodyTextGetter) })) { ILLabel afterIfLabel = null; if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref afterIfLabel) })) { ILLabel val2 = val.MarkLabel(); val.Index = 0; if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)titleTextGetter) || ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)bodyTextGetter) })) { ILLabel val3 = default(ILLabel); if (val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val3) && val3.Target == afterIfLabel.Target })) { val.Emit(OpCodes.Br, (object)val2); } else { Log.Error("Failed to find matching branch instruction", "X:\\Git\\RoR2\\TooltipFix\\TooltipFix\\TooltipFixPlugin.cs", "TooltipController_SetTooltip_FixEmptyCheck", 92); } } else { Log.Error("Failed to find title of body text get (from front)", "X:\\Git\\RoR2\\TooltipFix\\TooltipFix\\TooltipFixPlugin.cs", "TooltipController_SetTooltip_FixEmptyCheck", 97); } } else { Log.Error("Failed to find branch instruction", "X:\\Git\\RoR2\\TooltipFix\\TooltipFix\\TooltipFixPlugin.cs", "TooltipController_SetTooltip_FixEmptyCheck", 102); } } else { Log.Error("Failed to find title of body text get (from back)", "X:\\Git\\RoR2\\TooltipFix\\TooltipFix\\TooltipFixPlugin.cs", "TooltipController_SetTooltip_FixEmptyCheck", 107); } } private static bool TooltipProvider_get_tooltipIsAvailable_CheckEmpty(orig_TooltipProvider_get_tooltipIsAvailable orig, TooltipProvider self) { if (orig(self)) { if (string.IsNullOrEmpty(self.titleText)) { return !string.IsNullOrEmpty(self.bodyText); } return true; } return false; } } }