Decompiled source of CommandMenuResizer v1.0.0

CommandMenuResizer.dll

Decompiled 7 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("CommandMenuResizer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CommandMenuResizer")]
[assembly: AssemblyTitle("CommandMenuResizer")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CommandMenuResizer;

[BepInPlugin("com.RiskOfBrainrot.CommandMenuResizer", "CommandMenuResizer", "1.0.0")]
public class CommandResizePlugin : BaseUnityPlugin
{
	public const string guid = "com.RiskOfBrainrot.CommandMenuResizer";

	public const string teamName = "RiskOfBrainrot";

	public const string modName = "CommandMenuResizer";

	public const string version = "1.0.0";

	public const int padding = 166;

	public const int iconSize = 82;

	public const int margin = 120;

	public static PluginInfo PInfo { get; private set; }

	public void Awake()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		PickupPickerPanel.SetPickupOptions += new hook_SetPickupOptions(ResizeCommandMenu);
	}

	private void ResizeCommandMenu(orig_SetPickupOptions orig, PickupPickerPanel self, Option[] options)
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		if (options != null && options.Length != 0 && self.pickerController.contextString == "ARTIFACT_COMMAND_CUBE_INTERACTION_PROMPT")
		{
			RectTransform component = ((Component)((Component)self).transform.Find("MainPanel")).GetComponent<RectTransform>();
			RectTransform component2 = ((Component)((Component)self).transform.parent).GetComponent<RectTransform>();
			int num = (int)Math.Ceiling(Math.Sqrt(options.Length));
			int num2 = (int)Math.Ceiling((float)options.Length / (float)num);
			int num3 = 82 * num2;
			Rect rect = component2.rect;
			float num4 = ((Rect)(ref rect)).height - 286f;
			if ((float)num3 > num4)
			{
				num = (int)Math.Ceiling((double)options.Length / Math.Floor(num4 / 82f));
				num2 = (int)Math.Ceiling((float)options.Length / (float)num);
			}
			self.gridlayoutGroup.constraintCount = (self.maxColumnCount = num);
			component.sizeDelta = new Vector2((float)(166 + 82 * num), (float)(166 + 82 * num2));
		}
		orig.Invoke(self, options);
	}
}