Decompiled source of GUI Scale Unlocked Fix v2.0.2

GUIScaleUnlockedFix.dll

Decompiled 2 weeks ago
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.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
using Valheim.SettingsGui;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("GUIScaleUnlocked")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GUIScaleUnlocked")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("45cdc1bb-7fb9-4a40-967a-4ef9c5218ef7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GUIScaleUnlocked;

[BepInPlugin("GUIScaleUnlocked", "GUI Scale Unlocked", "2.0.0")]
[BepInProcess("valheim.exe")]
public class GUIScaleUnlocked : BaseUnityPlugin
{
	[HarmonyPatch(typeof(AccessibilitySettings), "Initialize")]
	private class Gui_Slider_Patch
	{
		public static void Prefix(ref Slider ___m_guiScaleSlider)
		{
			___m_guiScaleSlider.maxValue = guiScaleMax.Value;
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "Update")]
	private class Inventory_Tooltip_Patch
	{
		public static void Postfix(InventoryGui __instance, ref InventoryGrid ___m_containerGrid)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.m_playerGrid != (Object)null && (Object)(object)__instance.m_playerGrid.m_tooltipAnchor != (Object)null)
			{
				__instance.m_playerGrid.m_tooltipAnchor.anchoredPosition = new Vector2(playerTooltipX.Value, playerTooltipY.Value);
			}
			bool flag = __instance.IsContainerOpen();
			if ((Object)(object)___m_containerGrid != (Object)null && (Object)(object)___m_containerGrid.m_tooltipAnchor != (Object)null)
			{
				___m_containerGrid.m_tooltipAnchor.anchoredPosition = new Vector2(containerTooltipX.Value, containerTooltipY.Value);
				if (flag && (Object)(object)__instance.m_playerGrid != (Object)null && (Object)(object)__instance.m_playerGrid.m_tooltipAnchor != (Object)null)
				{
					((Transform)__instance.m_playerGrid.m_tooltipAnchor).position = ((Transform)___m_containerGrid.m_tooltipAnchor).position;
				}
			}
		}
	}

	private readonly Harmony harmony = new Harmony("GUIScaleUnlocked");

	public static ConfigEntry<float> guiScaleMax;

	private string section;

	public static ConfigEntry<float> playerTooltipX;

	public static ConfigEntry<float> playerTooltipY;

	public static ConfigEntry<float> containerTooltipX;

	public static ConfigEntry<float> containerTooltipY;

	private void Awake()
	{
		section = "User Interface Settings";
		guiScaleMax = ((BaseUnityPlugin)this).Config.Bind<float>(section, "guiScaleMax", 150f, "The maximum value of the GUI Scale slider found under the settings Accessibility tab. The vanilla game value is 115%.");
		string text = "Tooltip Positions";
		playerTooltipX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "playerTooltipX", -600f, "X offset for the player inventory tooltip.");
		playerTooltipY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "playerTooltipY", -400f, "Y offset for the player inventory tooltip.");
		containerTooltipX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "containerTooltipX", -600f, "X offset for the container/chest tooltip.");
		containerTooltipY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "containerTooltipY", -400f, "Y offset for the container/chest tooltip.");
		harmony.PatchAll();
	}
}