using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Mimic;
using Mimic.Actors;
using MimicAPI.GameAPI;
using TMPro;
using TooltipMod;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "Tooltip Mod", "1.2.0", "TheConanRider", null)]
[assembly: MelonGame("ReLUGames", "MIMESIS")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ToolTipMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+c353ad57b56f7a10714fec8a41a144258483865a")]
[assembly: AssemblyProduct("ToolTipMod")]
[assembly: AssemblyTitle("ToolTipMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace TooltipMod
{
public class Core : MelonMod
{
private Tooltip? tooltip;
public override void OnInitializeMelon()
{
tooltip = new Tooltip();
((MelonBase)this).LoggerInstance.Msg("Initialized.");
tooltip.CreateScalableCanvasWithGameFont();
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
if (tooltip != null)
{
tooltip.LoadGameFont();
}
}
public override void OnLateUpdate()
{
if (tooltip != null)
{
tooltip.UpdateToolTip();
}
}
}
internal class Tooltip
{
private int lastId = -1;
private TMP_FontAsset? desiredFontAsset;
private const string TargetFontName = "LanaPixel SDF";
private static TMP_Text? itemInfoTextComponent;
private static TMP_Text? testText;
private L10NManager? localisationManager;
public void CreateScalableCanvasWithGameFont()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("ModItemInfoCanvas");
val.AddComponent<Canvas>().renderMode = (RenderMode)0;
CanvasScaler obj = val.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(2556f, 1440f);
obj.matchWidthOrHeight = 0.5f;
val.AddComponent<GraphicRaycaster>();
Object.DontDestroyOnLoad((Object)(object)val);
GameObject val2 = new GameObject("ItemInfoTMP");
val2.transform.SetParent(val.transform, false);
itemInfoTextComponent = (TMP_Text?)(object)val2.AddComponent<TextMeshProUGUI>();
InitialiseTooltip();
}
public void InitialiseTooltip()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)itemInfoTextComponent == (Object)null)
{
MelonLogger.Error("Tried to InitialiseTextMeshPro while itemInfoTextComponent was null");
return;
}
RectTransform rectTransform = itemInfoTextComponent.rectTransform;
rectTransform.anchorMin = new Vector2(0.5f, 0f);
rectTransform.anchorMax = new Vector2(0.5f, 0f);
rectTransform.pivot = new Vector2(1f, 0f);
rectTransform.sizeDelta = new Vector2(400f, 120f);
rectTransform.anchoredPosition = new Vector2(690f, 70f);
itemInfoTextComponent.alignment = (TextAlignmentOptions)513;
((Graphic)itemInfoTextComponent).color = Color.white;
itemInfoTextComponent.text = "Loading...";
((Component)itemInfoTextComponent).gameObject.SetActive(false);
itemInfoTextComponent.fontSize = 30f;
}
public void LoadGameFont()
{
localisationManager = ManagerAPI.GetManager<L10NManager>("lcman");
if ((Object)(object)desiredFontAsset == (Object)null && (Object)(object)itemInfoTextComponent != (Object)null)
{
desiredFontAsset = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset font) => ((Object)font).name == "LanaPixel SDF"));
if ((Object)(object)desiredFontAsset == (Object)null)
{
MelonLogger.Error("Font not found in resources.");
}
else
{
itemInfoTextComponent.font = desiredFontAsset;
}
}
}
public void UpdateToolTip()
{
if ((Object)(object)itemInfoTextComponent == (Object)null)
{
MelonLogger.Error("Tried to UpdateToolTip while itemInfoTextComponent was null");
return;
}
if ((Object)(object)localisationManager == (Object)null)
{
MelonLogger.Error("Tried to UpdateToolTip while localisationManager was null");
return;
}
InventoryItem val = null;
ProtoActor localPlayer = PlayerAPI.GetLocalPlayer();
if ((Object)(object)localPlayer != (Object)null)
{
val = localPlayer.GetSelectedInventoryItem();
if (val != null && val.ItemMasterID != lastId)
{
string text = $"{localisationManager.GetText(val.MasterInfo.Name, Array.Empty<object>())}\n${val.Price.ToString()} {(float)val.MasterInfo.Weight / 1000f}kg";
itemInfoTextComponent.text = text;
((Component)itemInfoTextComponent).gameObject.SetActive(true);
lastId = val.ItemMasterID;
}
}
if ((Object)(object)localPlayer == (Object)null || val == null)
{
((Component)itemInfoTextComponent).gameObject.SetActive(false);
lastId = -1;
}
}
}
}