Decompiled source of Better UX v1.0.1

bin/Debug/net472/TABSUXMod.dll

Decompiled 6 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Landfall.TABS;
using LevelCreator;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace TABSUXMod;

public static class AutoConfirmLoadModsPatch
{
	private static MethodInfo setPermission;

	private static MethodInfo onCheckedPermission;

	public static void Apply(Harmony harmony)
	{
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — load-mods auto-confirm skipped.");
			return;
		}
		Type type = assembly.GetType("Landfall.TABS.Workshop.CustomContentLoaderModIO");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO not found — load-mods auto-confirm skipped.");
			return;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
		PropertyInfo property = type.GetProperty("DidGivePermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		setPermission = ((property != null) ? property.GetSetMethod(nonPublic: true) : null);
		onCheckedPermission = type.GetMethod("OnCheckedPermissionToLoadMods", bindingAttr);
		MethodInfo method = type.GetMethod("CheckPermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public);
		if (setPermission == null || onCheckedPermission == null || method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO members not found — load-mods auto-confirm skipped.");
			return;
		}
		MethodInfo method2 = typeof(AutoConfirmLoadModsPatch).GetMethod("CheckPermissionPrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Load-mods warning auto-confirm active.");
	}

	private static bool CheckPermissionPrefix(object __instance, bool refresh, object doneCallback)
	{
		Debug.Log((object)"[TABSUXMod] Auto-confirming 'load mods?' warning.");
		setPermission.Invoke(__instance, new object[1] { true });
		onCheckedPermission.Invoke(__instance, new object[2] { refresh, doneCallback });
		return false;
	}
}
public static class BulkDeletePatch
{
	private static readonly HashSet<UnitBlueprint> selected = new HashSet<UnitBlueprint>();

	private static readonly List<GameObject> overlays = new List<GameObject>();

	private static bool selectMode = false;

	private static Button deleteButton;

	private static TextMeshProUGUI deleteButtonLabel;

	private static MonoBehaviour sideBarInstance;

	private static MethodInfo deleteBCSCMethod;

	private static Type contentTypeFilterType;

	private static Type customContentFilePathsType;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "OnEnable")]
	public static void OnBrowserOpen(CustomContentGridBrowser __instance)
	{
		ExitSelectMode();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "Populate")]
	public static void OnBrowserPopulate(CustomContentGridBrowser __instance)
	{
		EnsureDeleteButton(__instance);
		RefreshDeleteButton();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UnitButtonBase), "Setup")]
	public static void OnUnitButtonSetup(UnitButtonBase __instance, UnitBlueprint unit)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_0092: 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)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Expected O, but got Unknown
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Expected O, but got Unknown
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Expected O, but got Unknown
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit == (Object)null)
		{
			return;
		}
		GameObject gameObject = ((Component)__instance).gameObject;
		if ((Object)(object)gameObject.transform.Find("BulkSelectOverlay") != (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("BulkSelectOverlay", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(gameObject.transform, false);
		val.SetActive(selectMode);
		overlays.Add(val);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0f, 0f, 0f, 0f);
		Button val3 = val.AddComponent<Button>();
		((Selectable)val3).targetGraphic = (Graphic)(object)val2;
		((Selectable)val3).transition = (Transition)0;
		GameObject val4 = new GameObject("Checkbox", new Type[1] { typeof(RectTransform) });
		val4.transform.SetParent(val.transform, false);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 1f);
		component2.anchorMax = new Vector2(0f, 1f);
		component2.pivot = new Vector2(0f, 1f);
		component2.anchoredPosition = new Vector2(4f, -4f);
		component2.sizeDelta = new Vector2(28f, 28f);
		Image val5 = val4.AddComponent<Image>();
		((Graphic)val5).color = new Color(0f, 0f, 0f, 0.55f);
		GameObject val6 = new GameObject("Check", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val4.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = "";
		((TMP_Text)val7).fontSize = 18f;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
		((Graphic)val7).color = Color.white;
		UnitBlueprint capturedUnit = unit;
		TextMeshProUGUI capturedCheck = val7;
		Image capturedBg = val5;
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (selectMode)
			{
				if (selected.Contains(capturedUnit))
				{
					selected.Remove(capturedUnit);
					((TMP_Text)capturedCheck).text = "";
					((Graphic)capturedBg).color = new Color(0f, 0f, 0f, 0.55f);
				}
				else
				{
					selected.Add(capturedUnit);
					((TMP_Text)capturedCheck).text = "✔";
					((Graphic)capturedBg).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
				}
				RefreshDeleteButton();
			}
		});
		if (selected.Contains(unit))
		{
			((TMP_Text)val7).text = "✔";
			((Graphic)val5).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
		}
	}

	private static void EnsureDeleteButton(CustomContentGridBrowser browser)
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Expected O, but got Unknown
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Expected O, but got Unknown
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Expected O, but got Unknown
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Expected O, but got Unknown
		if ((Object)(object)deleteButton != (Object)null && (Object)(object)((Component)deleteButton).gameObject != (Object)null)
		{
			return;
		}
		CustomContentUnitBrowser componentInChildren = ((Component)browser).GetComponentInChildren<CustomContentUnitBrowser>(true);
		if ((Object)(object)componentInChildren == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentUnitBrowser not found.");
			return;
		}
		object? obj = typeof(CustomContentUnitBrowser).GetField("layout01", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(componentInChildren);
		Component val = (Component)((obj is Component) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] layout01 field not found.");
			return;
		}
		Transform parent = val.transform.parent;
		Button val2 = null;
		foreach (Transform item in parent)
		{
			Transform val3 = item;
			if (((Object)val3).name == "New Unit")
			{
				val2 = ((Component)val3).GetComponent<Button>();
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] 'New Unit' not found in UnitGrid. Siblings:");
			{
				foreach (Transform item2 in parent)
				{
					Transform val4 = item2;
					Debug.Log((object)("[TABSUXMod] sibling: '" + ((Object)val4).name + "'"));
				}
				return;
			}
		}
		GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent, false);
		((Object)val5).name = "BulkDeleteBtn";
		deleteButton = val5.GetComponent<Button>();
		deleteButton.onClick = new ButtonClickedEvent();
		((UnityEvent)deleteButton.onClick).AddListener(new UnityAction(OnDeleteButtonClicked));
		RectTransform component = ((Component)val2).GetComponent<RectTransform>();
		RectTransform component2 = val5.GetComponent<RectTransform>();
		component2.anchorMin = component.anchorMin;
		component2.anchorMax = component.anchorMax;
		component2.pivot = component.pivot;
		component2.sizeDelta = component.sizeDelta;
		component2.anchoredPosition = component.anchoredPosition + new Vector2(component.sizeDelta.x + 8f, 0f);
		val5.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
		TextMeshProUGUI[] componentsInChildren = val5.GetComponentsInChildren<TextMeshProUGUI>();
		foreach (TextMeshProUGUI val6 in componentsInChildren)
		{
			Object.Destroy((Object)(object)((Component)val6).gameObject);
		}
		GameObject val7 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
		val7.transform.SetParent(val5.transform, false);
		RectTransform component3 = val7.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		deleteButtonLabel = val7.AddComponent<TextMeshProUGUI>();
		((TMP_Text)deleteButtonLabel).alignment = (TextAlignmentOptions)514;
		((TMP_Text)deleteButtonLabel).fontSize = 18f;
		((Graphic)deleteButtonLabel).color = Color.white;
		CacheSideBar();
	}

	private static void OnDeleteButtonClicked()
	{
		if (!selectMode)
		{
			selectMode = true;
			SetOverlaysVisible(visible: true);
			RefreshDeleteButton();
		}
		else if (selected.Count > 0)
		{
			DeleteSelected();
		}
		else
		{
			ExitSelectMode();
		}
	}

	private static void ExitSelectMode()
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		selectMode = false;
		selected.Clear();
		SetOverlaysVisible(visible: false);
		foreach (GameObject overlay in overlays)
		{
			if (!((Object)(object)overlay == (Object)null))
			{
				Transform val = overlay.transform.Find("Checkbox");
				Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.55f);
				}
				TextMeshProUGUI componentInChildren = overlay.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "";
				}
			}
		}
		RefreshDeleteButton();
	}

	private static void SetOverlaysVisible(bool visible)
	{
		overlays.RemoveAll((GameObject o) => (Object)(object)o == (Object)null);
		foreach (GameObject overlay in overlays)
		{
			overlay.SetActive(visible);
		}
	}

	private static void CacheSideBar()
	{
		if ((Object)(object)sideBarInstance != (Object)null)
		{
			return;
		}
		Assembly assembly = typeof(CustomContentGridBrowser).Assembly;
		Type type = assembly.GetType("Landfall.TABS.CustomContentSideBar");
		if (!(type == null))
		{
			Object obj = Object.FindObjectOfType(type);
			sideBarInstance = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
			if (!((Object)(object)sideBarInstance == (Object)null))
			{
				deleteBCSCMethod = type.GetMethod("DeleteBattleCreatorSharedCommandsContent", BindingFlags.Instance | BindingFlags.NonPublic);
				contentTypeFilterType = assembly.GetType("Landfall.TABS.Workshop.ContentTypeFilter");
				customContentFilePathsType = assembly.GetType("Landfall.TABS.Workshop.CustomContentFilePaths");
			}
		}
	}

	private static void RefreshDeleteButton()
	{
		if (!((Object)(object)deleteButtonLabel == (Object)null))
		{
			if (!selectMode)
			{
				((TMP_Text)deleteButtonLabel).text = "SELECT TO DELETE";
				((Selectable)deleteButton).interactable = true;
			}
			else if (selected.Count == 0)
			{
				((TMP_Text)deleteButtonLabel).text = "CANCEL";
				((Selectable)deleteButton).interactable = true;
			}
			else
			{
				((TMP_Text)deleteButtonLabel).text = $"DELETE ({selected.Count})";
				((Selectable)deleteButton).interactable = true;
			}
		}
	}

	private static void DeleteSelected()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		if (selected.Count == 0)
		{
			return;
		}
		CacheSideBar();
		if ((Object)(object)sideBarInstance == (Object)null || deleteBCSCMethod == null || contentTypeFilterType == null || customContentFilePathsType == null)
		{
			Debug.LogError((object)"[TABSUXMod] Could not resolve deletion methods via reflection.");
			return;
		}
		object obj = Enum.ToObject(contentTypeFilterType, 4);
		PropertyInfo property = customContentFilePathsType.GetProperty("UnitDirectoryPath", BindingFlags.Static | BindingFlags.Public);
		if (property == null)
		{
			Debug.LogError((object)"[TABSUXMod] UnitDirectoryPath property not found.");
			return;
		}
		string text = (string)property.GetValue(null);
		foreach (UnitBlueprint item in selected)
		{
			string text2 = text + ((object)item.Entity.GUID/*cast due to .constrained prefix*/).ToString();
			deleteBCSCMethod.Invoke(sideBarInstance, new object[3] { obj, item, text2 });
		}
		ExitSelectMode();
		CustomContentGridBrowser obj2 = Object.FindObjectOfType<CustomContentGridBrowser>();
		if (obj2 != null)
		{
			obj2.Refresh();
		}
	}
}
public static class DoubleClickPlayMapPatch
{
	private const float DoubleClickWindow = 0.4f;

	private static CustomMap lastClickedMap;

	private static float lastClickTime = -1f;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentLevelButton), "OnPointerClick")]
	public static void OnLevelButtonPointerClick(CustomContentLevelButton __instance, PointerEventData eventData)
	{
		lastClickedMap = __instance.customMap;
		lastClickTime = Time.unscaledTime;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(FactionCreatorFadeBG), "OnPointerClick")]
	public static bool OnFadePointerClick(FactionCreatorFadeBG __instance)
	{
		if ((Object)(object)lastClickedMap == (Object)null)
		{
			return true;
		}
		if (Time.unscaledTime - lastClickTime > 0.4f)
		{
			return true;
		}
		CustomContentSideBar sidebar = __instance.sidebar;
		if ((Object)(object)sidebar == (Object)null || (Object)(object)sidebar.levelParent == (Object)null || !sidebar.levelParent.activeSelf)
		{
			return true;
		}
		lastClickedMap = null;
		lastClickTime = -1f;
		sidebar.Play();
		return false;
	}
}
[BepInPlugin("joshbaier.tabsuxmod", "Better UX", "1.0.0")]
public class Launcher : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("joshbaier.tabsuxmod");
		val.PatchAll(typeof(BulkDeletePatch));
		val.PatchAll(typeof(DoubleClickPlayMapPatch));
		SuppressLaunchInvitePatch.Apply(val);
		AutoConfirmLoadModsPatch.Apply(val);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Better UX loaded.");
	}
}
public static class SuppressLaunchInvitePatch
{
	private static bool declinedFirstInvite;

	public static void Apply(Harmony harmony)
	{
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — launch invite suppression skipped.");
			return;
		}
		Type type = assembly.GetType("TFBGames.SocialProfileService");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method = type.GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService.SetState not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method2 = typeof(SuppressLaunchInvitePatch).GetMethod("SetStatePrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Launch invite suppression active (first invite of the session will be auto-declined).");
	}

	private static bool SetStatePrefix(ref object __0)
	{
		if (declinedFirstInvite)
		{
			return true;
		}
		int num = Convert.ToInt32(__0);
		if (num == 1 || num == 2)
		{
			declinedFirstInvite = true;
			Debug.Log((object)("[TABSUXMod] Auto-declined spurious launch invite (redirected SetState(" + num + ") to Idle). Later invites are untouched."));
			__0 = Enum.ToObject(__0.GetType(), 0);
		}
		return true;
	}
}

bin/Release/net472/TABSUXMod.dll

Decompiled 6 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Landfall.TABS;
using LevelCreator;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace TABSUXMod;

public static class AutoConfirmLoadModsPatch
{
	private static MethodInfo setPermission;

	private static MethodInfo onCheckedPermission;

	public static void Apply(Harmony harmony)
	{
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — load-mods auto-confirm skipped.");
			return;
		}
		Type type = assembly.GetType("Landfall.TABS.Workshop.CustomContentLoaderModIO");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO not found — load-mods auto-confirm skipped.");
			return;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
		PropertyInfo property = type.GetProperty("DidGivePermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		setPermission = ((property != null) ? property.GetSetMethod(nonPublic: true) : null);
		onCheckedPermission = type.GetMethod("OnCheckedPermissionToLoadMods", bindingAttr);
		MethodInfo method = type.GetMethod("CheckPermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public);
		if (setPermission == null || onCheckedPermission == null || method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO members not found — load-mods auto-confirm skipped.");
			return;
		}
		MethodInfo method2 = typeof(AutoConfirmLoadModsPatch).GetMethod("CheckPermissionPrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Load-mods warning auto-confirm active.");
	}

	private static bool CheckPermissionPrefix(object __instance, bool refresh, object doneCallback)
	{
		Debug.Log((object)"[TABSUXMod] Auto-confirming 'load mods?' warning.");
		setPermission.Invoke(__instance, new object[1] { true });
		onCheckedPermission.Invoke(__instance, new object[2] { refresh, doneCallback });
		return false;
	}
}
public static class BulkDeletePatch
{
	private static readonly HashSet<UnitBlueprint> selected = new HashSet<UnitBlueprint>();

	private static readonly List<GameObject> overlays = new List<GameObject>();

	private static bool selectMode = false;

	private static Button deleteButton;

	private static TextMeshProUGUI deleteButtonLabel;

	private static MonoBehaviour sideBarInstance;

	private static MethodInfo deleteBCSCMethod;

	private static Type contentTypeFilterType;

	private static Type customContentFilePathsType;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "OnEnable")]
	public static void OnBrowserOpen(CustomContentGridBrowser __instance)
	{
		ExitSelectMode();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "Populate")]
	public static void OnBrowserPopulate(CustomContentGridBrowser __instance)
	{
		EnsureDeleteButton(__instance);
		RefreshDeleteButton();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UnitButtonBase), "Setup")]
	public static void OnUnitButtonSetup(UnitButtonBase __instance, UnitBlueprint unit)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Expected O, but got Unknown
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Expected O, but got Unknown
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit == (Object)null)
		{
			return;
		}
		GameObject gameObject = ((Component)__instance).gameObject;
		if ((Object)(object)gameObject.transform.Find("BulkSelectOverlay") != (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("BulkSelectOverlay", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(gameObject.transform, false);
		val.SetActive(selectMode);
		overlays.Add(val);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0f, 0f, 0f, 0f);
		Button val3 = val.AddComponent<Button>();
		((Selectable)val3).targetGraphic = (Graphic)(object)val2;
		((Selectable)val3).transition = (Transition)0;
		GameObject val4 = new GameObject("Checkbox", new Type[1] { typeof(RectTransform) });
		val4.transform.SetParent(val.transform, false);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 1f);
		component2.anchorMax = new Vector2(0f, 1f);
		component2.pivot = new Vector2(0f, 1f);
		component2.anchoredPosition = new Vector2(4f, -4f);
		component2.sizeDelta = new Vector2(28f, 28f);
		Image val5 = val4.AddComponent<Image>();
		((Graphic)val5).color = new Color(0f, 0f, 0f, 0.55f);
		GameObject val6 = new GameObject("Check", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val4.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = "";
		((TMP_Text)val7).fontSize = 18f;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
		((Graphic)val7).color = Color.white;
		UnitBlueprint capturedUnit = unit;
		TextMeshProUGUI capturedCheck = val7;
		Image capturedBg = val5;
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			//IL_009c: 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)
			if (selectMode)
			{
				if (selected.Contains(capturedUnit))
				{
					selected.Remove(capturedUnit);
					((TMP_Text)capturedCheck).text = "";
					((Graphic)capturedBg).color = new Color(0f, 0f, 0f, 0.55f);
				}
				else
				{
					selected.Add(capturedUnit);
					((TMP_Text)capturedCheck).text = "✔";
					((Graphic)capturedBg).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
				}
				RefreshDeleteButton();
			}
		});
		if (selected.Contains(unit))
		{
			((TMP_Text)val7).text = "✔";
			((Graphic)val5).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
		}
	}

	private static void EnsureDeleteButton(CustomContentGridBrowser browser)
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Expected O, but got Unknown
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Expected O, but got Unknown
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Expected O, but got Unknown
		if ((Object)(object)deleteButton != (Object)null && (Object)(object)((Component)deleteButton).gameObject != (Object)null)
		{
			return;
		}
		CustomContentUnitBrowser componentInChildren = ((Component)browser).GetComponentInChildren<CustomContentUnitBrowser>(true);
		if ((Object)(object)componentInChildren == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentUnitBrowser not found.");
			return;
		}
		object? obj = typeof(CustomContentUnitBrowser).GetField("layout01", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(componentInChildren);
		Component val = (Component)((obj is Component) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] layout01 field not found.");
			return;
		}
		Transform parent = val.transform.parent;
		Button val2 = null;
		foreach (Transform item in parent)
		{
			Transform val3 = item;
			if (((Object)val3).name == "New Unit")
			{
				val2 = ((Component)val3).GetComponent<Button>();
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] 'New Unit' not found in UnitGrid. Siblings:");
			{
				foreach (Transform item2 in parent)
				{
					Transform val4 = item2;
					Debug.Log((object)("[TABSUXMod] sibling: '" + ((Object)val4).name + "'"));
				}
				return;
			}
		}
		GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent, false);
		((Object)val5).name = "BulkDeleteBtn";
		deleteButton = val5.GetComponent<Button>();
		deleteButton.onClick = new ButtonClickedEvent();
		((UnityEvent)deleteButton.onClick).AddListener(new UnityAction(OnDeleteButtonClicked));
		RectTransform component = ((Component)val2).GetComponent<RectTransform>();
		RectTransform component2 = val5.GetComponent<RectTransform>();
		component2.anchorMin = component.anchorMin;
		component2.anchorMax = component.anchorMax;
		component2.pivot = component.pivot;
		component2.sizeDelta = component.sizeDelta;
		component2.anchoredPosition = component.anchoredPosition + new Vector2(component.sizeDelta.x + 8f, 0f);
		val5.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
		TextMeshProUGUI[] componentsInChildren = val5.GetComponentsInChildren<TextMeshProUGUI>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Object.Destroy((Object)(object)((Component)componentsInChildren[i]).gameObject);
		}
		GameObject val6 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val5.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		deleteButtonLabel = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)deleteButtonLabel).alignment = (TextAlignmentOptions)514;
		((TMP_Text)deleteButtonLabel).fontSize = 18f;
		((Graphic)deleteButtonLabel).color = Color.white;
		CacheSideBar();
	}

	private static void OnDeleteButtonClicked()
	{
		if (!selectMode)
		{
			selectMode = true;
			SetOverlaysVisible(visible: true);
			RefreshDeleteButton();
		}
		else if (selected.Count > 0)
		{
			DeleteSelected();
		}
		else
		{
			ExitSelectMode();
		}
	}

	private static void ExitSelectMode()
	{
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		selectMode = false;
		selected.Clear();
		SetOverlaysVisible(visible: false);
		foreach (GameObject overlay in overlays)
		{
			if (!((Object)(object)overlay == (Object)null))
			{
				Transform val = overlay.transform.Find("Checkbox");
				Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.55f);
				}
				TextMeshProUGUI componentInChildren = overlay.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "";
				}
			}
		}
		RefreshDeleteButton();
	}

	private static void SetOverlaysVisible(bool visible)
	{
		overlays.RemoveAll((GameObject o) => (Object)(object)o == (Object)null);
		foreach (GameObject overlay in overlays)
		{
			overlay.SetActive(visible);
		}
	}

	private static void CacheSideBar()
	{
		if ((Object)(object)sideBarInstance != (Object)null)
		{
			return;
		}
		Assembly assembly = typeof(CustomContentGridBrowser).Assembly;
		Type type = assembly.GetType("Landfall.TABS.CustomContentSideBar");
		if (!(type == null))
		{
			Object obj = Object.FindObjectOfType(type);
			sideBarInstance = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
			if (!((Object)(object)sideBarInstance == (Object)null))
			{
				deleteBCSCMethod = type.GetMethod("DeleteBattleCreatorSharedCommandsContent", BindingFlags.Instance | BindingFlags.NonPublic);
				contentTypeFilterType = assembly.GetType("Landfall.TABS.Workshop.ContentTypeFilter");
				customContentFilePathsType = assembly.GetType("Landfall.TABS.Workshop.CustomContentFilePaths");
			}
		}
	}

	private static void RefreshDeleteButton()
	{
		if (!((Object)(object)deleteButtonLabel == (Object)null))
		{
			if (!selectMode)
			{
				((TMP_Text)deleteButtonLabel).text = "SELECT TO DELETE";
				((Selectable)deleteButton).interactable = true;
			}
			else if (selected.Count == 0)
			{
				((TMP_Text)deleteButtonLabel).text = "CANCEL";
				((Selectable)deleteButton).interactable = true;
			}
			else
			{
				((TMP_Text)deleteButtonLabel).text = $"DELETE ({selected.Count})";
				((Selectable)deleteButton).interactable = true;
			}
		}
	}

	private static void DeleteSelected()
	{
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		if (selected.Count == 0)
		{
			return;
		}
		CacheSideBar();
		if ((Object)(object)sideBarInstance == (Object)null || deleteBCSCMethod == null || contentTypeFilterType == null || customContentFilePathsType == null)
		{
			Debug.LogError((object)"[TABSUXMod] Could not resolve deletion methods via reflection.");
			return;
		}
		object obj = Enum.ToObject(contentTypeFilterType, 4);
		PropertyInfo property = customContentFilePathsType.GetProperty("UnitDirectoryPath", BindingFlags.Static | BindingFlags.Public);
		if (property == null)
		{
			Debug.LogError((object)"[TABSUXMod] UnitDirectoryPath property not found.");
			return;
		}
		string text = (string)property.GetValue(null);
		foreach (UnitBlueprint item in selected)
		{
			string text2 = text + ((object)item.Entity.GUID/*cast due to .constrained prefix*/).ToString();
			deleteBCSCMethod.Invoke(sideBarInstance, new object[3] { obj, item, text2 });
		}
		ExitSelectMode();
		CustomContentGridBrowser obj2 = Object.FindObjectOfType<CustomContentGridBrowser>();
		if (obj2 != null)
		{
			obj2.Refresh();
		}
	}
}
public static class DoubleClickPlayMapPatch
{
	private const float DoubleClickWindow = 0.4f;

	private static CustomMap lastClickedMap;

	private static float lastClickTime = -1f;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentLevelButton), "OnPointerClick")]
	public static void OnLevelButtonPointerClick(CustomContentLevelButton __instance, PointerEventData eventData)
	{
		CustomMap customMap = __instance.customMap;
		if ((Object)(object)customMap == (Object)null)
		{
			return;
		}
		float unscaledTime = Time.unscaledTime;
		bool num = (Object)(object)customMap == (Object)(object)lastClickedMap && unscaledTime - lastClickTime <= 0.4f;
		lastClickedMap = customMap;
		lastClickTime = unscaledTime;
		if (!num)
		{
			return;
		}
		lastClickedMap = null;
		lastClickTime = -1f;
		if (!((Object)(object)__instance.browserManager == (Object)null))
		{
			CustomContentSideBar customContentSideBar = __instance.browserManager.customContentSideBar;
			if (!((Object)(object)customContentSideBar == (Object)null))
			{
				customContentSideBar.Play();
			}
		}
	}
}
[BepInPlugin("joshbaier.tabsuxmod", "Better UX", "1.0.0")]
public class Launcher : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: 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_0030: Expected O, but got Unknown
		//IL_0035: Expected O, but got Unknown
		Harmony val = new Harmony("joshbaier.tabsuxmod");
		val.PatchAll(typeof(BulkDeletePatch));
		val.PatchAll(typeof(DoubleClickPlayMapPatch));
		SuppressLaunchInvitePatch.Apply(val);
		AutoConfirmLoadModsPatch.Apply(val);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Better UX loaded.");
	}
}
public static class SuppressLaunchInvitePatch
{
	private static bool declinedFirstInvite;

	public static void Apply(Harmony harmony)
	{
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — launch invite suppression skipped.");
			return;
		}
		Type type = assembly.GetType("TFBGames.SocialProfileService");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method = type.GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService.SetState not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method2 = typeof(SuppressLaunchInvitePatch).GetMethod("SetStatePrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Launch invite suppression active (first invite of the session will be auto-declined).");
	}

	private static bool SetStatePrefix(ref object __0)
	{
		if (declinedFirstInvite)
		{
			return true;
		}
		int num = Convert.ToInt32(__0);
		if (num == 1 || num == 2)
		{
			declinedFirstInvite = true;
			Debug.Log((object)("[TABSUXMod] Auto-declined spurious launch invite (redirected SetState(" + num + ") to Idle). Later invites are untouched."));
			__0 = Enum.ToObject(__0.GetType(), 0);
		}
		return true;
	}
}

obj/Debug/net472/TABSUXMod.dll

Decompiled 6 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Landfall.TABS;
using LevelCreator;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace TABSUXMod;

public static class AutoConfirmLoadModsPatch
{
	private static MethodInfo setPermission;

	private static MethodInfo onCheckedPermission;

	public static void Apply(Harmony harmony)
	{
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — load-mods auto-confirm skipped.");
			return;
		}
		Type type = assembly.GetType("Landfall.TABS.Workshop.CustomContentLoaderModIO");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO not found — load-mods auto-confirm skipped.");
			return;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
		PropertyInfo property = type.GetProperty("DidGivePermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		setPermission = ((property != null) ? property.GetSetMethod(nonPublic: true) : null);
		onCheckedPermission = type.GetMethod("OnCheckedPermissionToLoadMods", bindingAttr);
		MethodInfo method = type.GetMethod("CheckPermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public);
		if (setPermission == null || onCheckedPermission == null || method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO members not found — load-mods auto-confirm skipped.");
			return;
		}
		MethodInfo method2 = typeof(AutoConfirmLoadModsPatch).GetMethod("CheckPermissionPrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Load-mods warning auto-confirm active.");
	}

	private static bool CheckPermissionPrefix(object __instance, bool refresh, object doneCallback)
	{
		Debug.Log((object)"[TABSUXMod] Auto-confirming 'load mods?' warning.");
		setPermission.Invoke(__instance, new object[1] { true });
		onCheckedPermission.Invoke(__instance, new object[2] { refresh, doneCallback });
		return false;
	}
}
public static class BulkDeletePatch
{
	private static readonly HashSet<UnitBlueprint> selected = new HashSet<UnitBlueprint>();

	private static readonly List<GameObject> overlays = new List<GameObject>();

	private static bool selectMode = false;

	private static Button deleteButton;

	private static TextMeshProUGUI deleteButtonLabel;

	private static MonoBehaviour sideBarInstance;

	private static MethodInfo deleteBCSCMethod;

	private static Type contentTypeFilterType;

	private static Type customContentFilePathsType;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "OnEnable")]
	public static void OnBrowserOpen(CustomContentGridBrowser __instance)
	{
		ExitSelectMode();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "Populate")]
	public static void OnBrowserPopulate(CustomContentGridBrowser __instance)
	{
		EnsureDeleteButton(__instance);
		RefreshDeleteButton();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UnitButtonBase), "Setup")]
	public static void OnUnitButtonSetup(UnitButtonBase __instance, UnitBlueprint unit)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_0092: 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)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Expected O, but got Unknown
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Expected O, but got Unknown
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Expected O, but got Unknown
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit == (Object)null)
		{
			return;
		}
		GameObject gameObject = ((Component)__instance).gameObject;
		if ((Object)(object)gameObject.transform.Find("BulkSelectOverlay") != (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("BulkSelectOverlay", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(gameObject.transform, false);
		val.SetActive(selectMode);
		overlays.Add(val);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0f, 0f, 0f, 0f);
		Button val3 = val.AddComponent<Button>();
		((Selectable)val3).targetGraphic = (Graphic)(object)val2;
		((Selectable)val3).transition = (Transition)0;
		GameObject val4 = new GameObject("Checkbox", new Type[1] { typeof(RectTransform) });
		val4.transform.SetParent(val.transform, false);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 1f);
		component2.anchorMax = new Vector2(0f, 1f);
		component2.pivot = new Vector2(0f, 1f);
		component2.anchoredPosition = new Vector2(4f, -4f);
		component2.sizeDelta = new Vector2(28f, 28f);
		Image val5 = val4.AddComponent<Image>();
		((Graphic)val5).color = new Color(0f, 0f, 0f, 0.55f);
		GameObject val6 = new GameObject("Check", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val4.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = "";
		((TMP_Text)val7).fontSize = 18f;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
		((Graphic)val7).color = Color.white;
		UnitBlueprint capturedUnit = unit;
		TextMeshProUGUI capturedCheck = val7;
		Image capturedBg = val5;
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (selectMode)
			{
				if (selected.Contains(capturedUnit))
				{
					selected.Remove(capturedUnit);
					((TMP_Text)capturedCheck).text = "";
					((Graphic)capturedBg).color = new Color(0f, 0f, 0f, 0.55f);
				}
				else
				{
					selected.Add(capturedUnit);
					((TMP_Text)capturedCheck).text = "✔";
					((Graphic)capturedBg).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
				}
				RefreshDeleteButton();
			}
		});
		if (selected.Contains(unit))
		{
			((TMP_Text)val7).text = "✔";
			((Graphic)val5).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
		}
	}

	private static void EnsureDeleteButton(CustomContentGridBrowser browser)
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Expected O, but got Unknown
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Expected O, but got Unknown
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Expected O, but got Unknown
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Expected O, but got Unknown
		if ((Object)(object)deleteButton != (Object)null && (Object)(object)((Component)deleteButton).gameObject != (Object)null)
		{
			return;
		}
		CustomContentUnitBrowser componentInChildren = ((Component)browser).GetComponentInChildren<CustomContentUnitBrowser>(true);
		if ((Object)(object)componentInChildren == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentUnitBrowser not found.");
			return;
		}
		object? obj = typeof(CustomContentUnitBrowser).GetField("layout01", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(componentInChildren);
		Component val = (Component)((obj is Component) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] layout01 field not found.");
			return;
		}
		Transform parent = val.transform.parent;
		Button val2 = null;
		foreach (Transform item in parent)
		{
			Transform val3 = item;
			if (((Object)val3).name == "New Unit")
			{
				val2 = ((Component)val3).GetComponent<Button>();
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] 'New Unit' not found in UnitGrid. Siblings:");
			{
				foreach (Transform item2 in parent)
				{
					Transform val4 = item2;
					Debug.Log((object)("[TABSUXMod] sibling: '" + ((Object)val4).name + "'"));
				}
				return;
			}
		}
		GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent, false);
		((Object)val5).name = "BulkDeleteBtn";
		deleteButton = val5.GetComponent<Button>();
		deleteButton.onClick = new ButtonClickedEvent();
		((UnityEvent)deleteButton.onClick).AddListener(new UnityAction(OnDeleteButtonClicked));
		RectTransform component = ((Component)val2).GetComponent<RectTransform>();
		RectTransform component2 = val5.GetComponent<RectTransform>();
		component2.anchorMin = component.anchorMin;
		component2.anchorMax = component.anchorMax;
		component2.pivot = component.pivot;
		component2.sizeDelta = component.sizeDelta;
		component2.anchoredPosition = component.anchoredPosition + new Vector2(component.sizeDelta.x + 8f, 0f);
		val5.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
		TextMeshProUGUI[] componentsInChildren = val5.GetComponentsInChildren<TextMeshProUGUI>();
		foreach (TextMeshProUGUI val6 in componentsInChildren)
		{
			Object.Destroy((Object)(object)((Component)val6).gameObject);
		}
		GameObject val7 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
		val7.transform.SetParent(val5.transform, false);
		RectTransform component3 = val7.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		deleteButtonLabel = val7.AddComponent<TextMeshProUGUI>();
		((TMP_Text)deleteButtonLabel).alignment = (TextAlignmentOptions)514;
		((TMP_Text)deleteButtonLabel).fontSize = 18f;
		((Graphic)deleteButtonLabel).color = Color.white;
		CacheSideBar();
	}

	private static void OnDeleteButtonClicked()
	{
		if (!selectMode)
		{
			selectMode = true;
			SetOverlaysVisible(visible: true);
			RefreshDeleteButton();
		}
		else if (selected.Count > 0)
		{
			DeleteSelected();
		}
		else
		{
			ExitSelectMode();
		}
	}

	private static void ExitSelectMode()
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		selectMode = false;
		selected.Clear();
		SetOverlaysVisible(visible: false);
		foreach (GameObject overlay in overlays)
		{
			if (!((Object)(object)overlay == (Object)null))
			{
				Transform val = overlay.transform.Find("Checkbox");
				Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.55f);
				}
				TextMeshProUGUI componentInChildren = overlay.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "";
				}
			}
		}
		RefreshDeleteButton();
	}

	private static void SetOverlaysVisible(bool visible)
	{
		overlays.RemoveAll((GameObject o) => (Object)(object)o == (Object)null);
		foreach (GameObject overlay in overlays)
		{
			overlay.SetActive(visible);
		}
	}

	private static void CacheSideBar()
	{
		if ((Object)(object)sideBarInstance != (Object)null)
		{
			return;
		}
		Assembly assembly = typeof(CustomContentGridBrowser).Assembly;
		Type type = assembly.GetType("Landfall.TABS.CustomContentSideBar");
		if (!(type == null))
		{
			Object obj = Object.FindObjectOfType(type);
			sideBarInstance = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
			if (!((Object)(object)sideBarInstance == (Object)null))
			{
				deleteBCSCMethod = type.GetMethod("DeleteBattleCreatorSharedCommandsContent", BindingFlags.Instance | BindingFlags.NonPublic);
				contentTypeFilterType = assembly.GetType("Landfall.TABS.Workshop.ContentTypeFilter");
				customContentFilePathsType = assembly.GetType("Landfall.TABS.Workshop.CustomContentFilePaths");
			}
		}
	}

	private static void RefreshDeleteButton()
	{
		if (!((Object)(object)deleteButtonLabel == (Object)null))
		{
			if (!selectMode)
			{
				((TMP_Text)deleteButtonLabel).text = "SELECT TO DELETE";
				((Selectable)deleteButton).interactable = true;
			}
			else if (selected.Count == 0)
			{
				((TMP_Text)deleteButtonLabel).text = "CANCEL";
				((Selectable)deleteButton).interactable = true;
			}
			else
			{
				((TMP_Text)deleteButtonLabel).text = $"DELETE ({selected.Count})";
				((Selectable)deleteButton).interactable = true;
			}
		}
	}

	private static void DeleteSelected()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		if (selected.Count == 0)
		{
			return;
		}
		CacheSideBar();
		if ((Object)(object)sideBarInstance == (Object)null || deleteBCSCMethod == null || contentTypeFilterType == null || customContentFilePathsType == null)
		{
			Debug.LogError((object)"[TABSUXMod] Could not resolve deletion methods via reflection.");
			return;
		}
		object obj = Enum.ToObject(contentTypeFilterType, 4);
		PropertyInfo property = customContentFilePathsType.GetProperty("UnitDirectoryPath", BindingFlags.Static | BindingFlags.Public);
		if (property == null)
		{
			Debug.LogError((object)"[TABSUXMod] UnitDirectoryPath property not found.");
			return;
		}
		string text = (string)property.GetValue(null);
		foreach (UnitBlueprint item in selected)
		{
			string text2 = text + ((object)item.Entity.GUID/*cast due to .constrained prefix*/).ToString();
			deleteBCSCMethod.Invoke(sideBarInstance, new object[3] { obj, item, text2 });
		}
		ExitSelectMode();
		CustomContentGridBrowser obj2 = Object.FindObjectOfType<CustomContentGridBrowser>();
		if (obj2 != null)
		{
			obj2.Refresh();
		}
	}
}
public static class DoubleClickPlayMapPatch
{
	private const float DoubleClickWindow = 0.4f;

	private static CustomMap lastClickedMap;

	private static float lastClickTime = -1f;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentLevelButton), "OnPointerClick")]
	public static void OnLevelButtonPointerClick(CustomContentLevelButton __instance, PointerEventData eventData)
	{
		lastClickedMap = __instance.customMap;
		lastClickTime = Time.unscaledTime;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(FactionCreatorFadeBG), "OnPointerClick")]
	public static bool OnFadePointerClick(FactionCreatorFadeBG __instance)
	{
		if ((Object)(object)lastClickedMap == (Object)null)
		{
			return true;
		}
		if (Time.unscaledTime - lastClickTime > 0.4f)
		{
			return true;
		}
		CustomContentSideBar sidebar = __instance.sidebar;
		if ((Object)(object)sidebar == (Object)null || (Object)(object)sidebar.levelParent == (Object)null || !sidebar.levelParent.activeSelf)
		{
			return true;
		}
		lastClickedMap = null;
		lastClickTime = -1f;
		sidebar.Play();
		return false;
	}
}
[BepInPlugin("joshbaier.tabsuxmod", "Better UX", "1.0.0")]
public class Launcher : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("joshbaier.tabsuxmod");
		val.PatchAll(typeof(BulkDeletePatch));
		val.PatchAll(typeof(DoubleClickPlayMapPatch));
		SuppressLaunchInvitePatch.Apply(val);
		AutoConfirmLoadModsPatch.Apply(val);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Better UX loaded.");
	}
}
public static class SuppressLaunchInvitePatch
{
	private static bool declinedFirstInvite;

	public static void Apply(Harmony harmony)
	{
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — launch invite suppression skipped.");
			return;
		}
		Type type = assembly.GetType("TFBGames.SocialProfileService");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method = type.GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService.SetState not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method2 = typeof(SuppressLaunchInvitePatch).GetMethod("SetStatePrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Launch invite suppression active (first invite of the session will be auto-declined).");
	}

	private static bool SetStatePrefix(ref object __0)
	{
		if (declinedFirstInvite)
		{
			return true;
		}
		int num = Convert.ToInt32(__0);
		if (num == 1 || num == 2)
		{
			declinedFirstInvite = true;
			Debug.Log((object)("[TABSUXMod] Auto-declined spurious launch invite (redirected SetState(" + num + ") to Idle). Later invites are untouched."));
			__0 = Enum.ToObject(__0.GetType(), 0);
		}
		return true;
	}
}

obj/Release/net472/TABSUXMod.dll

Decompiled 6 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Landfall.TABS;
using LevelCreator;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace TABSUXMod;

public static class AutoConfirmLoadModsPatch
{
	private static MethodInfo setPermission;

	private static MethodInfo onCheckedPermission;

	public static void Apply(Harmony harmony)
	{
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — load-mods auto-confirm skipped.");
			return;
		}
		Type type = assembly.GetType("Landfall.TABS.Workshop.CustomContentLoaderModIO");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO not found — load-mods auto-confirm skipped.");
			return;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
		PropertyInfo property = type.GetProperty("DidGivePermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		setPermission = ((property != null) ? property.GetSetMethod(nonPublic: true) : null);
		onCheckedPermission = type.GetMethod("OnCheckedPermissionToLoadMods", bindingAttr);
		MethodInfo method = type.GetMethod("CheckPermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public);
		if (setPermission == null || onCheckedPermission == null || method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO members not found — load-mods auto-confirm skipped.");
			return;
		}
		MethodInfo method2 = typeof(AutoConfirmLoadModsPatch).GetMethod("CheckPermissionPrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Load-mods warning auto-confirm active.");
	}

	private static bool CheckPermissionPrefix(object __instance, bool refresh, object doneCallback)
	{
		Debug.Log((object)"[TABSUXMod] Auto-confirming 'load mods?' warning.");
		setPermission.Invoke(__instance, new object[1] { true });
		onCheckedPermission.Invoke(__instance, new object[2] { refresh, doneCallback });
		return false;
	}
}
public static class BulkDeletePatch
{
	private static readonly HashSet<UnitBlueprint> selected = new HashSet<UnitBlueprint>();

	private static readonly List<GameObject> overlays = new List<GameObject>();

	private static bool selectMode = false;

	private static Button deleteButton;

	private static TextMeshProUGUI deleteButtonLabel;

	private static MonoBehaviour sideBarInstance;

	private static MethodInfo deleteBCSCMethod;

	private static Type contentTypeFilterType;

	private static Type customContentFilePathsType;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "OnEnable")]
	public static void OnBrowserOpen(CustomContentGridBrowser __instance)
	{
		ExitSelectMode();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "Populate")]
	public static void OnBrowserPopulate(CustomContentGridBrowser __instance)
	{
		EnsureDeleteButton(__instance);
		RefreshDeleteButton();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UnitButtonBase), "Setup")]
	public static void OnUnitButtonSetup(UnitButtonBase __instance, UnitBlueprint unit)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Expected O, but got Unknown
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Expected O, but got Unknown
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit == (Object)null)
		{
			return;
		}
		GameObject gameObject = ((Component)__instance).gameObject;
		if ((Object)(object)gameObject.transform.Find("BulkSelectOverlay") != (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("BulkSelectOverlay", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(gameObject.transform, false);
		val.SetActive(selectMode);
		overlays.Add(val);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0f, 0f, 0f, 0f);
		Button val3 = val.AddComponent<Button>();
		((Selectable)val3).targetGraphic = (Graphic)(object)val2;
		((Selectable)val3).transition = (Transition)0;
		GameObject val4 = new GameObject("Checkbox", new Type[1] { typeof(RectTransform) });
		val4.transform.SetParent(val.transform, false);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 1f);
		component2.anchorMax = new Vector2(0f, 1f);
		component2.pivot = new Vector2(0f, 1f);
		component2.anchoredPosition = new Vector2(4f, -4f);
		component2.sizeDelta = new Vector2(28f, 28f);
		Image val5 = val4.AddComponent<Image>();
		((Graphic)val5).color = new Color(0f, 0f, 0f, 0.55f);
		GameObject val6 = new GameObject("Check", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val4.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = "";
		((TMP_Text)val7).fontSize = 18f;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
		((Graphic)val7).color = Color.white;
		UnitBlueprint capturedUnit = unit;
		TextMeshProUGUI capturedCheck = val7;
		Image capturedBg = val5;
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			//IL_009c: 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)
			if (selectMode)
			{
				if (selected.Contains(capturedUnit))
				{
					selected.Remove(capturedUnit);
					((TMP_Text)capturedCheck).text = "";
					((Graphic)capturedBg).color = new Color(0f, 0f, 0f, 0.55f);
				}
				else
				{
					selected.Add(capturedUnit);
					((TMP_Text)capturedCheck).text = "✔";
					((Graphic)capturedBg).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
				}
				RefreshDeleteButton();
			}
		});
		if (selected.Contains(unit))
		{
			((TMP_Text)val7).text = "✔";
			((Graphic)val5).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
		}
	}

	private static void EnsureDeleteButton(CustomContentGridBrowser browser)
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Expected O, but got Unknown
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Expected O, but got Unknown
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Expected O, but got Unknown
		if ((Object)(object)deleteButton != (Object)null && (Object)(object)((Component)deleteButton).gameObject != (Object)null)
		{
			return;
		}
		CustomContentUnitBrowser componentInChildren = ((Component)browser).GetComponentInChildren<CustomContentUnitBrowser>(true);
		if ((Object)(object)componentInChildren == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentUnitBrowser not found.");
			return;
		}
		object? obj = typeof(CustomContentUnitBrowser).GetField("layout01", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(componentInChildren);
		Component val = (Component)((obj is Component) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] layout01 field not found.");
			return;
		}
		Transform parent = val.transform.parent;
		Button val2 = null;
		foreach (Transform item in parent)
		{
			Transform val3 = item;
			if (((Object)val3).name == "New Unit")
			{
				val2 = ((Component)val3).GetComponent<Button>();
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] 'New Unit' not found in UnitGrid. Siblings:");
			{
				foreach (Transform item2 in parent)
				{
					Transform val4 = item2;
					Debug.Log((object)("[TABSUXMod] sibling: '" + ((Object)val4).name + "'"));
				}
				return;
			}
		}
		GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent, false);
		((Object)val5).name = "BulkDeleteBtn";
		deleteButton = val5.GetComponent<Button>();
		deleteButton.onClick = new ButtonClickedEvent();
		((UnityEvent)deleteButton.onClick).AddListener(new UnityAction(OnDeleteButtonClicked));
		RectTransform component = ((Component)val2).GetComponent<RectTransform>();
		RectTransform component2 = val5.GetComponent<RectTransform>();
		component2.anchorMin = component.anchorMin;
		component2.anchorMax = component.anchorMax;
		component2.pivot = component.pivot;
		component2.sizeDelta = component.sizeDelta;
		component2.anchoredPosition = component.anchoredPosition + new Vector2(component.sizeDelta.x + 8f, 0f);
		val5.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
		TextMeshProUGUI[] componentsInChildren = val5.GetComponentsInChildren<TextMeshProUGUI>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Object.Destroy((Object)(object)((Component)componentsInChildren[i]).gameObject);
		}
		GameObject val6 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val5.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		deleteButtonLabel = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)deleteButtonLabel).alignment = (TextAlignmentOptions)514;
		((TMP_Text)deleteButtonLabel).fontSize = 18f;
		((Graphic)deleteButtonLabel).color = Color.white;
		CacheSideBar();
	}

	private static void OnDeleteButtonClicked()
	{
		if (!selectMode)
		{
			selectMode = true;
			SetOverlaysVisible(visible: true);
			RefreshDeleteButton();
		}
		else if (selected.Count > 0)
		{
			DeleteSelected();
		}
		else
		{
			ExitSelectMode();
		}
	}

	private static void ExitSelectMode()
	{
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		selectMode = false;
		selected.Clear();
		SetOverlaysVisible(visible: false);
		foreach (GameObject overlay in overlays)
		{
			if (!((Object)(object)overlay == (Object)null))
			{
				Transform val = overlay.transform.Find("Checkbox");
				Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.55f);
				}
				TextMeshProUGUI componentInChildren = overlay.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "";
				}
			}
		}
		RefreshDeleteButton();
	}

	private static void SetOverlaysVisible(bool visible)
	{
		overlays.RemoveAll((GameObject o) => (Object)(object)o == (Object)null);
		foreach (GameObject overlay in overlays)
		{
			overlay.SetActive(visible);
		}
	}

	private static void CacheSideBar()
	{
		if ((Object)(object)sideBarInstance != (Object)null)
		{
			return;
		}
		Assembly assembly = typeof(CustomContentGridBrowser).Assembly;
		Type type = assembly.GetType("Landfall.TABS.CustomContentSideBar");
		if (!(type == null))
		{
			Object obj = Object.FindObjectOfType(type);
			sideBarInstance = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
			if (!((Object)(object)sideBarInstance == (Object)null))
			{
				deleteBCSCMethod = type.GetMethod("DeleteBattleCreatorSharedCommandsContent", BindingFlags.Instance | BindingFlags.NonPublic);
				contentTypeFilterType = assembly.GetType("Landfall.TABS.Workshop.ContentTypeFilter");
				customContentFilePathsType = assembly.GetType("Landfall.TABS.Workshop.CustomContentFilePaths");
			}
		}
	}

	private static void RefreshDeleteButton()
	{
		if (!((Object)(object)deleteButtonLabel == (Object)null))
		{
			if (!selectMode)
			{
				((TMP_Text)deleteButtonLabel).text = "SELECT TO DELETE";
				((Selectable)deleteButton).interactable = true;
			}
			else if (selected.Count == 0)
			{
				((TMP_Text)deleteButtonLabel).text = "CANCEL";
				((Selectable)deleteButton).interactable = true;
			}
			else
			{
				((TMP_Text)deleteButtonLabel).text = $"DELETE ({selected.Count})";
				((Selectable)deleteButton).interactable = true;
			}
		}
	}

	private static void DeleteSelected()
	{
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		if (selected.Count == 0)
		{
			return;
		}
		CacheSideBar();
		if ((Object)(object)sideBarInstance == (Object)null || deleteBCSCMethod == null || contentTypeFilterType == null || customContentFilePathsType == null)
		{
			Debug.LogError((object)"[TABSUXMod] Could not resolve deletion methods via reflection.");
			return;
		}
		object obj = Enum.ToObject(contentTypeFilterType, 4);
		PropertyInfo property = customContentFilePathsType.GetProperty("UnitDirectoryPath", BindingFlags.Static | BindingFlags.Public);
		if (property == null)
		{
			Debug.LogError((object)"[TABSUXMod] UnitDirectoryPath property not found.");
			return;
		}
		string text = (string)property.GetValue(null);
		foreach (UnitBlueprint item in selected)
		{
			string text2 = text + ((object)item.Entity.GUID/*cast due to .constrained prefix*/).ToString();
			deleteBCSCMethod.Invoke(sideBarInstance, new object[3] { obj, item, text2 });
		}
		ExitSelectMode();
		CustomContentGridBrowser obj2 = Object.FindObjectOfType<CustomContentGridBrowser>();
		if (obj2 != null)
		{
			obj2.Refresh();
		}
	}
}
public static class DoubleClickPlayMapPatch
{
	private const float DoubleClickWindow = 0.4f;

	private static CustomMap lastClickedMap;

	private static float lastClickTime = -1f;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentLevelButton), "OnPointerClick")]
	public static void OnLevelButtonPointerClick(CustomContentLevelButton __instance, PointerEventData eventData)
	{
		CustomMap customMap = __instance.customMap;
		if ((Object)(object)customMap == (Object)null)
		{
			return;
		}
		float unscaledTime = Time.unscaledTime;
		bool num = (Object)(object)customMap == (Object)(object)lastClickedMap && unscaledTime - lastClickTime <= 0.4f;
		lastClickedMap = customMap;
		lastClickTime = unscaledTime;
		if (!num)
		{
			return;
		}
		lastClickedMap = null;
		lastClickTime = -1f;
		if (!((Object)(object)__instance.browserManager == (Object)null))
		{
			CustomContentSideBar customContentSideBar = __instance.browserManager.customContentSideBar;
			if (!((Object)(object)customContentSideBar == (Object)null))
			{
				customContentSideBar.Play();
			}
		}
	}
}
[BepInPlugin("joshbaier.tabsuxmod", "Better UX", "1.0.0")]
public class Launcher : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: 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_0030: Expected O, but got Unknown
		//IL_0035: Expected O, but got Unknown
		Harmony val = new Harmony("joshbaier.tabsuxmod");
		val.PatchAll(typeof(BulkDeletePatch));
		val.PatchAll(typeof(DoubleClickPlayMapPatch));
		SuppressLaunchInvitePatch.Apply(val);
		AutoConfirmLoadModsPatch.Apply(val);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Better UX loaded.");
	}
}
public static class SuppressLaunchInvitePatch
{
	private static bool declinedFirstInvite;

	public static void Apply(Harmony harmony)
	{
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — launch invite suppression skipped.");
			return;
		}
		Type type = assembly.GetType("TFBGames.SocialProfileService");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method = type.GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService.SetState not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method2 = typeof(SuppressLaunchInvitePatch).GetMethod("SetStatePrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Launch invite suppression active (first invite of the session will be auto-declined).");
	}

	private static bool SetStatePrefix(ref object __0)
	{
		if (declinedFirstInvite)
		{
			return true;
		}
		int num = Convert.ToInt32(__0);
		if (num == 1 || num == 2)
		{
			declinedFirstInvite = true;
			Debug.Log((object)("[TABSUXMod] Auto-declined spurious launch invite (redirected SetState(" + num + ") to Idle). Later invites are untouched."));
			__0 = Enum.ToObject(__0.GetType(), 0);
		}
		return true;
	}
}